diff options
author | grog <grog@FreeBSD.org> | 2007-02-25 01:28:37 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2007-02-25 01:28:37 +0000 |
commit | 2812c02b775888222ed8f48107e9c24201816af3 (patch) | |
tree | c0e7168f12524e0a89d07df2414b9f830fa5d7ab /usr.bin/setchannel/setchannel.c | |
parent | 75775b9c23d4e6129d2319b6c87e27832525799b (diff) | |
download | FreeBSD-src-2812c02b775888222ed8f48107e9c24201816af3.zip FreeBSD-src-2812c02b775888222ed8f48107e9c24201816af3.tar.gz |
Add support for selecting from multiple tuners.
Suggested by: usleepless <usleepless@gmail.com>
Diffstat (limited to 'usr.bin/setchannel/setchannel.c')
-rw-r--r-- | usr.bin/setchannel/setchannel.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.bin/setchannel/setchannel.c b/usr.bin/setchannel/setchannel.c index 489ef6c..f6f3e20 100644 --- a/usr.bin/setchannel/setchannel.c +++ b/usr.bin/setchannel/setchannel.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <stdlib.h> #include <ctype.h> +#include <errno.h> #include <fcntl.h> #include <string.h> #include <sys/types.h> @@ -55,6 +56,7 @@ usage() "[-g geom] [-m chnl_set] [chnl | freq]\n" " -a Enable / disable AFC.\n" " -c Select composite input.\n" + " -d Select tuner unit number.\n" " -r Select radio input.\n" " -s Select svideo input.\n" " -t Select tuner.\n" @@ -78,6 +80,9 @@ usage() CHNLSET_JPNCABLE, CHNLSET_AUSTRALIA, CHNLSET_FRANCE); } +#define DEVNAME_BASE "/dev/cxm" +char dev_name[16]; + int main(int argc, char *argv[]) { @@ -89,6 +94,7 @@ main(int argc, char *argv[]) int channel_set; int i; int status; + int unit; int tfd; unsigned int channel; unsigned int fraction; @@ -105,11 +111,13 @@ main(int argc, char *argv[]) device = 0; freq = 0; status = 0; + unit = 0; x_size = 0; y_size = 0; - while ((c = getopt(argc, argv, "a:crg:m:st")) != -1) + while ((c = getopt(argc, argv, "a:cd:rg:m:st")) != -1) switch (c) { + case 'a': if (strcasecmp(optarg, "on") == 0) afc = 1; @@ -126,6 +134,10 @@ main(int argc, char *argv[]) audio = -1; break; + case 'd': + unit = atoi(optarg); + break; + case 'r': device = 0; audio = AUDIO_INTERN; @@ -202,9 +214,11 @@ main(int argc, char *argv[]) exit(1); } - tfd = open("/dev/cxm0", O_RDONLY); + sprintf(dev_name, DEVNAME_BASE "%d", unit); + tfd = open(dev_name, O_RDONLY); if (tfd < 0) { - perror("open() of /dev/cxm0 failed."); + fprintf(stderr, "Can't open %s: %s (%d)\n", dev_name, + strerror(errno), errno); exit(1); } |