From c510cac8e72997ce45a27091c28a0569432bf10d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 12 Dec 2009 10:48:12 -0800 Subject: [PATCH] fmtools version 0.99.1 --- Changes => CHANGES | 35 ++++++++++++++++++ COPYING | 11 +++--- Makefile | 44 +++++++++++++++++++---- fm.1 | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fm.c | 52 ++++++++++++++++----------- fmscan.1 | 77 +++++++++++++++++++++++++++++++++++++++ fmscan.c | 11 ++++-- version.h | 2 ++ 8 files changed, 301 insertions(+), 35 deletions(-) rename Changes => CHANGES (55%) create mode 100644 fm.1 create mode 100644 fmscan.1 create mode 100644 version.h diff --git a/Changes b/CHANGES similarity index 55% rename from Changes rename to CHANGES index da006be..ae3b257 100644 --- a/Changes +++ b/CHANGES @@ -1,3 +1,38 @@ +0.99.1: + +Fri Aug 16 23:08:30 CDT 2002 / Russell Kroll + + - fm, fmscan: fix the FSF's address in the headers + +Fri Aug 16 23:07:49 CDT 2002 / Russell Kroll + + - COPYING: put in the modern version of the GPL v2, with the correct + address for the FSF. + +Fri Aug 16 23:05:33 CDT 2002 / Russell Kroll + + - Makefile: reworked a bunch of stuff, and added such useful things + like install targets. Hopefully this will make packaging less of + a hack. + +Fri Aug 16 22:55:41 CDT 2002 / Russell Kroll + + - fm: do the VIDIOCGAUDIO first so there's always good data in the struct + +Fri Aug 16 22:48:10 CDT 2002 / Russell Kroll + + - fm.1: incorporated the man page written by Ben Pfaff. + +Fri Aug 16 22:47:01 CDT 2002 / Russell Kroll + + - fm: set va.balance to 32768 rather than relying on whatever junk + happens to be in the struct. Reported by ahmet inan. + +Fri Aug 16 22:43:47 CDT 2002 / Russell Kroll + + - fm: applied patch from Viktor Rosenfeld to fix the rounding so that + channels like 99.95 MHz can be tuned. + 0.99.0: Sat Feb 3 22:41:12 CST 2001 - Russell Kroll diff --git a/COPYING b/COPYING index a43ea21..5b6e7c6 100644 --- a/COPYING +++ b/COPYING @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -279,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - Appendix: How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) 19yy + Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -305,14 +305,15 @@ the "copyright" line and a pointer to where the full notice is found. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/Makefile b/Makefile index dc46e11..2bdcb61 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,49 @@ CC = gcc CFLAGS = -Wall -O2 -all : fm fmscan +INSTALL = /usr/bin/install -fm : fm.c +# Since fmtools doesn't use configure, these paths are provided here +# to make packaging easier. Just override them when doing 'make install'. + +BINPATH = $(DESTDIR)/usr/local/bin +BINMODE = 0755 +MANPATH = $(DESTDIR)/usr/local/man/man1 +MANMODE = 0644 + +TARGETS = fm fmscan + +all: $(TARGETS) + +fm: fm.c $(CC) $(CFLAGS) -o fm fm.c -lm -fmscan : fmscan.c +fmscan: fmscan.c $(CC) $(CFLAGS) -o fmscan fmscan.c -lm -clean : - rm -f *~ *.o fm fmscan +clean: + rm -f *~ *.o $(TARGETS) + +install: all install-bin install-man + +install-bin: + if (test ! -d $(BINPATH)); \ + then \ + mkdir -p $(BINPATH); \ + fi + for f in $(TARGETS) ; do \ + $(INSTALL) -m $(BINMODE) $$f $(BINPATH); \ + done + +install-man: + if (test ! -d $(MANPATH)); \ + then \ + mkdir -p $(MANPATH); \ + fi + for f in $(TARGETS) ; do \ + $(INSTALL) -m $(MANMODE) $$f.1 $(MANPATH); \ + done -devices : +devices: mknod /dev/radio0 c 81 64 ln -s /dev/radio0 /dev/radio diff --git a/fm.1 b/fm.1 new file mode 100644 index 0000000..51efbbe --- /dev/null +++ b/fm.1 @@ -0,0 +1,104 @@ +.TH FM 1 "fm 0.99.1" +.SH NAME +fm \- control frequency, volume, mute/unmute of FM radio card +.SH SYNOPSIS +.HP +.B fm +[ +.B \-h +] [ +.B \-o +] [ +.B \-q +] [ +.B \-d +.I device +] [ +.B \-t +.I tuner +] +.B on +| +.B off +| +.B + +| +.B \- +| +.B freq +[ +.I volume +] +.SH DESCRIPTION +.B fm +is a program to control the frequency, volume, and mute/unmute state +of an FM radio card, using the video4linux interface introduced in +2.1.x series Linux kernels. +.SS OPTIONS +.PP +.TP +.B \-h +Print a usage message to standard output, and exit. +.TP +.B \-o +Ignore frequency range limits of card. Use if you suspect that the +card supports a wider frequency range than its driver believes. +.TP +.B \-q +Quiet mode. Keeps information on station and volume from being +printed on standard output. +.TP +\fB\-d \fIdevice +Sets \fIdevice\fR as the device to tune. The default is +\fB/dev/radio0\fR. +.TP +\fB\-t \fItuner +Sets \fItuner\fR as the tuner on the selected device to adjust. The +default is tuner 0. Most radio devices have only a single tuner. +.TP +.BI freq +Frequency to tune the radio to, in MHz. For instance, \fB88.9\fR +specifies a frequency of 88.9 MHz. AM tuner values are also specified +in MHz; for instance, 530 kHz would be specified as \fB.530\fR. +.TP +.BI on +Turn the radio on (unmute). +.TP +.BI off +Turn the radio off (mute). +.TP +.BI volume +Specify the desired volume, in percent. Not all radio devices support +volume control. +.TP +.BI + +Increase the current volume. +.TP +.BI - +Decrease the current volume. +.SH FILES +.TP +\fI$HOME\fB/.fmrc\fR +Optional configuration file used to set default volume and +volume increments, in percents. Specify default volume with a line of +the form +.BI VOL +percent. Specify volume increments with a line of the form +.BI INCR +percent. + +If this file does not exist then the defaults are 12.5% volume and 10% +volume increments. +.SH SEE ALSO +.TP +Additional documentation: +.B /usr/doc/fmtools/README +.TP +The fmtools homepage: +.B http://www.exploits.org/v4l/fmtools.html +.TP +The video4linux webpage: +.B http://roadrunner.swansea.uk.linux.org/v4l.shtml +.SH AUTHORS +Russell Kroll . This manpage written by Ben +Pfaff for Debian GNU/Linux. diff --git a/fm.c b/fm.c index 287b544..28060ec 100644 --- a/fm.c +++ b/fm.c @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -29,10 +29,15 @@ #include #include +#include "version.h" + +#define DEFAULT_DEVICE "/dev/radio0" + void help(char *prog) { - printf("usage: %s [-h] [-o] [-q] [-d ] [-t ] |on|off []\n", prog); - printf("\n"); + printf("fmtools fm version %s\n\n", FMT_VERSION); + printf("usage: %s [-h] [-o] [-q] [-d ] [-t ] |on|off []\n\n", prog); + printf("A small controller for Video for Linux radio devices.\n\n"); printf(" -h display this help\n"); printf(" -o override frequency range limits of card\n"); printf(" -q quiet mode\n"); @@ -84,8 +89,9 @@ int main(int argc, char **argv) /* need at least a frequency */ if (argc < 2) { - printf ("usage: %s [-h] [-o] [-q] [-d ] [-t ] |on|off []\n", argv[0]); - exit (1); + printf("usage: %s [-h] [-o] [-q] [-d ] [-t ] " + "|on|off []\n", argv[0]); + exit(1); } progname = argv[0]; /* used after getopt munges argv[] */ @@ -125,14 +131,24 @@ int main(int argc, char **argv) tunevol = defaultvol; if (!dev) - dev = strdup("/dev/radio0"); /* use default */ + dev = DEFAULT_DEVICE; fd = open(dev, O_RDONLY); if (fd < 0) { - fprintf(stderr, "Unable to open %s: %s\n", dev, strerror(errno)); + fprintf(stderr, "Unable to open %s: %s\n", + dev, strerror(errno)); exit(1); } + ret = ioctl(fd, VIDIOCGAUDIO, &va); + if (ret < 0) { + perror("ioctl VIDIOCGAUDIO"); + exit(1); + } + + /* initialize this so it doesn't pick up random junk data */ + va.balance = 32768; + if (!strcmp("off", argv[0])) { /* mute the radio */ va.audio = 0; va.volume = 0; @@ -144,7 +160,7 @@ int main(int argc, char **argv) } if (!quiet) - printf ("Radio muted\n"); + printf("Radio muted\n"); exit(0); } @@ -164,12 +180,6 @@ int main(int argc, char **argv) exit(0); } - ret = ioctl(fd, VIDIOCGAUDIO, &va); - if (ret < 0) { - perror("ioctl VIDIOCGAUDIO"); - exit(1); - } - if (argv[0][0] == '+') { /* volume up */ if ((va.volume + increment) > 65535) va.volume = 65535; /* catch overflows in __u16 */ @@ -180,13 +190,13 @@ int main(int argc, char **argv) printf("Setting volume to %2.2f%%\n", (va.volume / 655.35)); - ret = ioctl (fd, VIDIOCSAUDIO, &va); + ret = ioctl(fd, VIDIOCSAUDIO, &va); if (ret < 0) { perror("ioctl VIDIOCSAUDIO"); exit(1); } - exit (0); + exit(0); } if (argv[0][0] == '-') { /* volume down */ @@ -199,13 +209,13 @@ int main(int argc, char **argv) printf("Setting volume to %2.2f%%\n", (va.volume / 655.35)); - ret = ioctl (fd, VIDIOCSAUDIO, &va); + ret = ioctl(fd, VIDIOCSAUDIO, &va); if (ret < 0) { perror("ioctl VIDIOCSAUDIO"); exit(1); } - exit (0); + exit(0); } /* at this point, we are trying to tune to a frequency */ @@ -228,7 +238,7 @@ int main(int argc, char **argv) else fact = 16000.; - freq = ceil(atof(argv[0]) * fact); /* rounding up matters */ + freq = rint(atof(argv[0]) * fact); /* rounding to nearest int */ if ((freq < vt.rangelow) || (freq > vt.rangehigh)) { if (override == 0) { @@ -243,7 +253,7 @@ int main(int argc, char **argv) ret = ioctl(fd, VIDIOCSFREQ, &freq); if (ret < 0) { perror("ioctl VIDIOCSFREQ"); - exit (1); + exit(1); } va.audio = 0; @@ -258,7 +268,7 @@ int main(int argc, char **argv) } if (!quiet) - printf ("Radio tuned to %2.1f MHz at %2.2f%% volume\n", + printf("Radio tuned to %2.2f MHz at %2.2f%% volume\n", (freq / fact), (tunevol / 655.35)); return 0; diff --git a/fmscan.1 b/fmscan.1 new file mode 100644 index 0000000..0c83c10 --- /dev/null +++ b/fmscan.1 @@ -0,0 +1,77 @@ +.TH FM 1 "fmscan 0.99.1" +.SH NAME +fmscan \- scan FM band for radio stations +.SH SYNOPSIS +.HP +.B fm +[ +.B \-h +] [ +.B \-d +.I device +] [ +.B \-s +.I freq +] [ +.B \-e +.I freq +] [ +.I \-i +.I freq +] +.SH DESCRIPTION +.B fmscan +is a program to scan a frequency band for radio stations, using the +video4linux interface introduced in 2.1.x series Linux kernels. It +shows which ones have a accumulated signal strength of 50% or higher. +This process can take a while, and results vary greatly depending on the +radio card in use. +.SS OPTIONS +.PP +.TP +.B \-h +Print a usage message to standard output, and exit. +.TP +\fB\-d \fIdevice +Sets \fIdevice\fR as the device to tune. The default is +\fB/dev/radio0\fR. +.TP +\fB\-s \fIfreq +Starting frequency for scan, in MHz. Default: 87.9. +.TP +\fB\-e \fIfreq +Ending frequency for scan, in MHz. Default: 107.9. +.TP +\fB\-i \fIfreq +Increment between scanned channels, in MHz. Default: 0.2. +.SH BUGS +This program may not do much if your radio card's driver doesn't support +fine tuning in 1/16000 MHz offsets. By default, v4l assumes 1/16 MHz +tuning units, which introduces evil rounding errors on many frequencies. +If in doubt, grep for VIDEO_TUNER_LOW in your driver's source. +.PP +Supports only tuner 0 on any given device. +.SH SEE ALSO +.TP +Additional documentation: +.B /usr/doc/fmtools/README +.TP +The fmtools homepage: +.B http://www.exploits.org/v4l/fmtools.html +.TP +The video4linux webpage: +.B http://roadrunner.swansea.uk.linux.org/v4l.shtml +.SH AUTHORS +Russell Kroll . This manpage written by Ben +Pfaff for Debian GNU/Linux, based on +fmtools source and documentation. +---------------------------------------------------------------------- + +HTH, + +Ben. + +-- +"I didn't say it was your fault. + I said I was going to blame it on you." + diff --git a/fmscan.c b/fmscan.c index 229e888..00662e0 100644 --- a/fmscan.c +++ b/fmscan.c @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -28,6 +28,8 @@ #include #include +#include "version.h" + #define TRIES 25 /* get 25 samples */ #define LOCKTIME 400000 /* wait 400ms for card to lock on */ #define SAMPLEDELAY 15000 /* wait 15ms between samples */ @@ -35,8 +37,11 @@ void help(char *prog) { + printf("fmtools fmscan version %s\n\n", FMT_VERSION); printf("usage: %s [-h] [-d ] [-s ] [-e ] [-i ]\n\n", prog); + printf("Auxiliary program to scan a frequency band for radio stations.\n\n"); + printf(" -h - display this help\n"); printf(" -d - select device (default: /dev/radio0)\n"); printf(" -s - set start of scanning range to \n"); @@ -44,7 +49,7 @@ void help(char *prog) printf(" -i - set increment value between channels to \n"); printf(" - a value in the format nnn.nn (MHz)\n"); - exit (0); + exit(0); } int main(int argc, char **argv) @@ -153,6 +158,6 @@ int main(int argc, char **argv) (freq / (double) fact), perc * 100.0); } - close (fd); + close(fd); return 0; } diff --git a/version.h b/version.h new file mode 100644 index 0000000..b33f458 --- /dev/null +++ b/version.h @@ -0,0 +1,2 @@ +#define FMT_VERSION "0.99.1" + -- 2.11.4.GIT