From 0eb303ccfd22edea47db1b3803e315ed2b54c168 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 12 Dec 2009 10:45:51 -0800 Subject: [PATCH] fmtools 0.2.5. Adds -t option for selecting the tuner on multi-tuner boards (radio-cadet, etc). --- Changes | 3 +++ README | 11 +++++++++++ fm.c | 60 +++++++++++++++++++++++++++++++++++++----------------------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/Changes b/Changes index 668486d..2339bb0 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +Mon Apr 12 20:32:13 MDT 1999 + - -t option for selecting the tuner on multi-tuner boards (radio-cadet, etc) + Wed Feb 3 13:13:01 MST 1999 - fmtools 0.2.4 released - 'devices' target added to Makefile diff --git a/README b/README index 39fc67d..d69badd 100644 --- a/README +++ b/README @@ -71,6 +71,17 @@ say the increment value for volume changes with + and - is 6554 - approximately 10%. These values were obtained by playing around with the numbers until things behaved the way I wanted. +There are some other options available: + +-o - override card frequency range - Some radio card drivers don't actively + enforce the frequencies that you can tune to. Use this switch and fm + will send any frequency you want to the driver. + +-t - select tuner - Certain cards have multiple tuners - usually used for + different bands. The ADS Cadet driver is apparently the first one to + support this v4l feature. The first tuner is 0, the second is 1, and + so on. + fmscan ====== diff --git a/fm.c b/fm.c index 44549c5..4e4ee38 100644 --- a/fm.c +++ b/fm.c @@ -28,23 +28,21 @@ #include #include -/* please don't report me to the committee to abolish global variables ... - - they've been removed! */ - void help(char *prog) { - printf ("usage: %s [-h] [-o] [-q] |on|off []\n", prog); + printf ("usage: %s [-h] [-o] [-q] [-t ] |on|off []\n", prog); printf ("\n"); - printf ("-h - display this help\n"); - printf ("-o - override frequency range limits in card\n"); - printf ("-q - quiet mode\n"); - printf (" - frequency in MHz (i.e. 94.3)\n"); - printf ("on - turn radio on\n"); - printf ("off - turn radio off (mute)\n"); - printf ("+ - increase volume\n"); - printf ("- - decrease volume\n"); - printf (" - intensity (0-65535)\n"); + printf ("-h - display this help\n"); + printf ("-o - override frequency range limits in card\n"); + printf ("-q - quiet mode\n"); + printf ("-t - select tuner \n"); + printf (" - tuner number - first one is 0, next one 1, etc\n"); + printf (" - frequency in MHz (i.e. 94.3)\n"); + printf ("on - turn radio on\n"); + printf ("off - turn radio off (mute)\n"); + printf ("+ - increase volume\n"); + printf ("- - decrease volume\n"); + printf (" - intensity (0-65535)\n"); exit (1); } @@ -85,29 +83,28 @@ int main(int argc, char **argv) char *progname; extern char *optarg; extern int optind, opterr, optopt; + int tuner = 0; if ((argc < 2) || (argc > 4)) { - printf ("usage: %s [-h] [-o] [-q] |on|off []\n", argv[0]); + printf ("usage: %s [-h] [-o] [-q] [-t ] |on|off []\n", argv[0]); exit (1); } progname = argv[0]; /* used after getopt munges argv[] */ - fd = open ("/dev/radio0", O_RDONLY); - if (fd == -1) { - perror ("Unable to open /dev/radio0"); - exit (1); - } - getconfig(&defaultvol, &increment); - while ((i = getopt(argc, argv, "+qho")) != EOF) { + while ((i = getopt(argc, argv, "+qhot:")) != EOF) { switch (i) { case 'q': quiet = 1; break; case 'o': override = 1; + break; + case 't': + tuner = atoi(optarg); + break; case 'h': default: help(argv[0]); @@ -126,6 +123,13 @@ int main(int argc, char **argv) if (argc == 0) /* no frequency, on|off, or +|- given */ help (progname); + /* moved here so -h works without a device */ + fd = open ("/dev/radio0", O_RDONLY); + if (fd == -1) { + perror ("Unable to open /dev/radio0"); + exit (1); + } + if (!strcmp("off", argv[0])) { /* mute the radio */ va.audio = 0; va.volume = 0; @@ -177,7 +181,13 @@ int main(int argc, char **argv) /* at this point, we are trying to tune to a frequency */ - vt.tuner = 0; + vt.tuner = tuner; + ret = ioctl(fd, VIDIOCSTUNER, &vt); /* set tuner # */ + if (ret < 0) { + perror ("set tuner"); + exit (1); + } + ret = ioctl(fd, VIDIOCGTUNER, &vt); /* get frequency range */ if (ret == -1 || (vt.flags & VIDEO_TUNER_LOW) == 0) @@ -197,6 +207,10 @@ int main(int argc, char **argv) /* frequency sanity checked, proceed */ ret = ioctl (fd, VIDIOCSFREQ, &freq); + if (ret < 0) { + perror ("set freq"); + exit (1); + } va.audio = 0; va.volume = tunevol; -- 2.11.4.GIT