From 825df58b2830c1450e1d855866fc485c8c81ac88 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Sun, 25 Feb 2007 01:28:37 +0000 Subject: [PATCH] Add support for selecting from multiple tuners. Suggested by: usleepless --- usr.bin/setchannel/setchannel.1 | 15 ++++++++++----- usr.bin/setchannel/setchannel.c | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/usr.bin/setchannel/setchannel.1 b/usr.bin/setchannel/setchannel.1 index 80c1b633d8eb..c51ec3c00d72 100644 --- a/usr.bin/setchannel/setchannel.1 +++ b/usr.bin/setchannel/setchannel.1 @@ -36,11 +36,8 @@ .Pp .Sh DESCRIPTION .Nm -provides support for selecting channels on the PVR250 and PVR350 via -.Pa /dev/cxm0 -(or -.Pa /dev/bktr0 -on FreeBSD 4.x) +provides support for selecting channels on Hauppauge WinTV cards, +including the PVR 150, PVR 250, PVR 350 and PVR 500. .Pp The following options are available: .Bl -tag -width indent @@ -50,6 +47,14 @@ Enable AFC. Disable AFC. .It Fl c Select composite input. +.It Fl d +Select the tuner unit number. +This is appended to the base device file name +.Pa /dev/cxm +to form a device name such as +.Pa /dev/cxm0 +or +.Pa /dev/cxm1 . .It Fl r Select radio input. .It Fl s diff --git a/usr.bin/setchannel/setchannel.c b/usr.bin/setchannel/setchannel.c index 489ef6cf1103..f6f3e2040ac6 100644 --- a/usr.bin/setchannel/setchannel.c +++ b/usr.bin/setchannel/setchannel.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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); }