summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2006-02-05 23:52:59 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2006-02-05 23:52:59 +0000
commit7cc1affea2cac75c404f2ca54731d6f4fde1fcb0 (patch)
treeabf33957907d00247bc4de64d25b6e3e1e7f2a76
parent669e9351d44c2c6115953978f7d285f7895f1a68 (diff)
improve support for TV tuning via radio(4) by:
- adding a TV or radio mode flag to struct radio_info for radio(4) and a similar flag to struct TUNER for bktr(4) to make tuning mode explicit - reporting the proper frequency when in TV mode - documenting the mode flag and cleaning up some grammar OK mickey@, robert@
-rw-r--r--share/man/man4/radio.428
-rw-r--r--sys/dev/pci/bktr/bktr_os.c67
-rw-r--r--sys/dev/pci/bktr/bktr_reg.h5
-rw-r--r--sys/dev/pci/bktr/bktr_tuner.c6
-rw-r--r--sys/sys/radioio.h5
-rw-r--r--usr.bin/radioctl/radioctl.126
-rw-r--r--usr.bin/radioctl/radioctl.c11
7 files changed, 105 insertions, 43 deletions
diff --git a/share/man/man4/radio.4 b/share/man/man4/radio.4
index 465840619ed..8f9a617a6a4 100644
--- a/share/man/man4/radio.4
+++ b/share/man/man4/radio.4
@@ -1,5 +1,5 @@
.\" $RuOBSD: radio.4,v 1.4 2001/10/26 05:38:43 form Exp $
-.\" $OpenBSD: radio.4,v 1.23 2005/12/07 10:57:21 jmc Exp $
+.\" $OpenBSD: radio.4,v 1.24 2006/02/05 23:52:57 jakemsr Exp $
.\"
.\" Copyright (c) 2001 Vladimir Popov
.\" All rights reserved.
@@ -86,6 +86,9 @@ struct radio_info {
u_int32_t info;
#define RADIO_INFO_STEREO (1<<0)
#define RADIO_INFO_SIGNAL (1<<1)
+ u_int32_t tuner_mode;
+#define RADIO_TUNER_MODE_RADIO (1<<0)
+#define RADIO_TUNER_MODE_TV (1<<1)
u_int32_t chan;
u_int32_t chnlset;
};
@@ -118,6 +121,18 @@ The
field is the frequency in kHz the card is tuned to.
.Pp
The
+.Va tuner_mode
+field is current tuning mode of the tuner.
+Valid modes are:
+.Pp
+.Bl -tag -width indent -compact
+.It Dv RADIO_TUNER_MODE_RADIO
+The tuner operates in Fm radio mode.
+.It Dv RADIO_TUNER_MODE_TV
+The tuner operates in TV mode.
+.El
+.Pp
+The
.Va caps
field is read-only and describes the card capabilities.
The capabilities can have the following values:
@@ -162,8 +177,11 @@ holds the TV channel the card is tuned to.
.Pp
The
.Va chnlset
-specifies the TV channel set currently being used
-(Western Europe being the default):
+specifies the TV channel set currently being used.
+The tuner uses the current channel set to derive the tuning frequency
+from the channel number.
+Western Europe is the default channel set.
+The following is a list of valid channel sets:
.Bl -tag -width indent -compact
.Pp
.It 1
@@ -190,8 +208,8 @@ France
Either
.Va freq
or
-.Va chan Ns / Ns Va chnlset
-have to be used to tune into FM radio stations or TV channels,
+.Va chan
+can be used to tune to FM radio stations or TV channels,
respectively.
Some devices may not support both functionalities.
.Sh CHIPSETS
diff --git a/sys/dev/pci/bktr/bktr_os.c b/sys/dev/pci/bktr/bktr_os.c
index 0db3a38dc1c..af54a42bb3d 100644
--- a/sys/dev/pci/bktr/bktr_os.c
+++ b/sys/dev/pci/bktr/bktr_os.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bktr_os.c,v 1.23 2006/01/15 20:38:41 jakemsr Exp $ */
+/* $OpenBSD: bktr_os.c,v 1.24 2006/02/05 23:52:58 jakemsr Exp $ */
/* $FreeBSD: src/sys/dev/bktr/bktr_os.c,v 1.20 2000/10/20 08:16:53 roger Exp $ */
/*
@@ -1272,39 +1272,42 @@ bktr_set_info(void *v, struct radio_info *ri)
init_audio_devices(sc);
}
- if (ri->chan) {
- if (ri->chan < MIN_TV_CHAN)
- ri->chan = MIN_TV_CHAN;
- if (ri->chan > MAX_TV_CHAN)
- ri->chan = MAX_TV_CHAN;
+ set_audio(sc, AUDIO_INTERN); /* use internal audio */
+ temp_mute(sc, TRUE);
+
+ if (ri->tuner_mode == RADIO_TUNER_MODE_TV) {
+ if (ri->chan) {
+ if (ri->chan < MIN_TV_CHAN)
+ ri->chan = MIN_TV_CHAN;
+ if (ri->chan > MAX_TV_CHAN)
+ ri->chan = MAX_TV_CHAN;
+
+ chan = ri->chan;
+ ri->chan = tv_channel(sc, chan);
+ tv->tuner_mode = BT848_TUNER_MODE_TV;
+ } else {
+ ri->chan = tv->channel;
+ }
} else {
- if (ri->freq < MIN_FM_FREQ)
- ri->freq = MIN_FM_FREQ;
- if (ri->freq > MAX_FM_FREQ)
- ri->freq = MAX_FM_FREQ;
+ if (ri->freq) {
+ if (ri->freq < MIN_FM_FREQ)
+ ri->freq = MIN_FM_FREQ;
+ if (ri->freq > MAX_FM_FREQ)
+ ri->freq = MAX_FM_FREQ;
+
+ freq = ri->freq / 10;
+ ri->freq = tv_freq(sc, freq, FM_RADIO_FREQUENCY) * 10;
+ tv->tuner_mode = BT848_TUNER_MODE_RADIO;
+ } else {
+ ri->freq = tv->frequency;
+ }
}
- freq = ri->freq / 10;
- chan = ri->chan;
-
if (ri->chnlset >= CHNLSET_MIN && ri->chnlset <= CHNLSET_MAX)
tv->chnlset = ri->chnlset;
else
tv->chnlset = DEFAULT_CHNLSET;
- set_audio(sc, AUDIO_INTERN); /* use internal audio */
- temp_mute(sc, TRUE);
-
- /*
- * We only need to set the frequency if we are using
- * FM Radio. If the channel is > 0 then call tv_channel(),
- * which will set the correct TV frequency.
- */
- if (!ri->chan)
- ri->freq = tv_freq(sc, freq, FM_RADIO_FREQUENCY) * 10;
- else
- ri->chan = tv_channel(sc, chan);
-
temp_mute(sc, FALSE);
return (0);
@@ -1322,12 +1325,22 @@ bktr_get_info(void *v, struct radio_info *ri)
#define STATUSBIT_STEREO 0x10
ri->mute = (int)sc->audio_mute_state ? 1 : 0;
ri->caps = RADIO_CAPS_DETECT_STEREO | RADIO_CAPS_HW_AFC;
- ri->freq = tv->frequency * 10;
ri->info = (status & STATUSBIT_STEREO) ? RADIO_INFO_STEREO : 0;
/* not yet supported */
ri->volume = ri->rfreq = ri->lock = 0;
+ switch (tv->tuner_mode) {
+ case BT848_TUNER_MODE_TV:
+ ri->tuner_mode = RADIO_TUNER_MODE_TV;
+ ri->freq = tv->frequency * 1000 / 16;
+ break;
+ case BT848_TUNER_MODE_RADIO:
+ ri->tuner_mode = RADIO_TUNER_MODE_RADIO;
+ ri->freq = tv->frequency * 10;
+ break;
+ }
+
/*
* The field ri->stereo is used to forcible switch to
* mono/stereo, not as an indicator of received signal quality.
diff --git a/sys/dev/pci/bktr/bktr_reg.h b/sys/dev/pci/bktr/bktr_reg.h
index 909f6d4cf5a..2232ef1f59b 100644
--- a/sys/dev/pci/bktr/bktr_reg.h
+++ b/sys/dev/pci/bktr/bktr_reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bktr_reg.h,v 1.8 2005/11/21 18:16:41 millert Exp $ */
+/* $OpenBSD: bktr_reg.h,v 1.9 2006/02/05 23:52:58 jakemsr Exp $ */
/*
* $FreeBSD: src/sys/dev/bktr/bktr_reg.h,v 1.42 2000/10/31 13:09:56 roger Exp $
*
@@ -415,6 +415,9 @@ struct TVTUNER {
u_char band;
u_char afc;
u_char radio_mode; /* current mode of the radio mode */
+ int tuner_mode; /* current tuning mode */
+#define BT848_TUNER_MODE_TV 1
+#define BT848_TUNER_MODE_RADIO 2
};
/* description of the PHYSICAL tuner */
diff --git a/sys/dev/pci/bktr/bktr_tuner.c b/sys/dev/pci/bktr/bktr_tuner.c
index 31b93309f34..c1d7b53e232 100644
--- a/sys/dev/pci/bktr/bktr_tuner.c
+++ b/sys/dev/pci/bktr/bktr_tuner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bktr_tuner.c,v 1.3 2003/02/11 19:20:28 mickey Exp $ */
+/* $OpenBSD: bktr_tuner.c,v 1.4 2006/02/05 23:52:58 jakemsr Exp $ */
/* $FreeBSD: src/sys/dev/bktr/bktr_tuner.c,v 1.9 2000/10/19 07:33:28 roger Exp $ */
/*
@@ -801,6 +801,8 @@ tv_freq( bktr_ptr_t bktr, int frequency, int type )
else
band_select = HIGH_BAND;
+ bktr->tuner.tuner_mode = BT848_TUNER_MODE_TV;
+
#if defined( TEST_TUNER_AFC )
if ( bktr->tuner.afc )
frequency -= 4;
@@ -863,6 +865,8 @@ tv_freq( bktr_ptr_t bktr, int frequency, int type )
if ( type == FM_RADIO_FREQUENCY ) {
band_select = FM_RADIO_BAND;
+ bktr->tuner.tuner_mode = BT848_TUNER_MODE_RADIO;
+
/*
* N = { fRF(pc) + fIF(pc) }/step_size
* The step size is 50kHz for FM radio.
diff --git a/sys/sys/radioio.h b/sys/sys/radioio.h
index 2df603c8488..defe1f1daf8 100644
--- a/sys/sys/radioio.h
+++ b/sys/sys/radioio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: radioio.h,v 1.3 2005/12/05 15:16:26 robert Exp $ */
+/* $OpenBSD: radioio.h,v 1.4 2006/02/05 23:52:57 jakemsr Exp $ */
/* $RuOBSD: radioio.h,v 1.4 2001/10/18 16:51:36 pva Exp $ */
/*
@@ -61,6 +61,9 @@ struct radio_info {
u_int32_t info;
#define RADIO_INFO_STEREO (1<<0)
#define RADIO_INFO_SIGNAL (1<<1)
+ u_int32_t tuner_mode;
+#define RADIO_TUNER_MODE_RADIO (1<<0)
+#define RADIO_TUNER_MODE_TV (1<<1)
u_int32_t chan;
u_int32_t chnlset;
};
diff --git a/usr.bin/radioctl/radioctl.1 b/usr.bin/radioctl/radioctl.1
index 77a5c06bf1d..fa5d2d34b20 100644
--- a/usr.bin/radioctl/radioctl.1
+++ b/usr.bin/radioctl/radioctl.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: radioctl.1,v 1.10 2005/12/06 12:58:50 jmc Exp $
+.\" $OpenBSD: radioctl.1,v 1.11 2006/02/05 23:52:58 jakemsr Exp $
.\"
.\" Copyright (c) 2001 Vladimir Popov
.\" All rights reserved.
@@ -104,11 +104,18 @@ or
Read-write controls:
.Bl -tag -width Ds
.It Ar channel
+Specifies the TV channel.
Integer value from 0 to 150.
+Using the
+.Ar channel
+control puts the tuner in
+.Dq TV
+mode.
.It Ar chnlset
-Specifies the TV channel set currently being used
-.Pf ( Dq weurope
-being the default):
+Specifies the TV channel set.
+The tuner uses the current channel set to derive a frequency from the
+.Ar channel .
+The following is a list of valid channel sets:
.Pp
.Bl -tag -width "australiaXX" -offset indent -compact
.It nabcst
@@ -131,7 +138,13 @@ Australia
France
.El
.It Ar frequency
+Specifies the FM frequency in MHz.
Float value from 87.5 to 108.0.
+Using the
+.Ar frequency
+control puts the tuner in
+.Dq radio
+mode.
.It Ar volume
Integer value from 0 to 255.
.It Ar mute
@@ -155,8 +168,8 @@ Can be 5 mkV, 10 mkV, 30 mkV and 150 mkV.
Not all cards allow the station locking sensitivity to be changed.
.El
.Pp
-All the remaining controls (signal, stereo and card capabilities) are read-only
-and can be viewed using option
+All the remaining controls (mode, signal, stereo and card capabilities)
+are read-only and can be viewed using option
.Fl a .
.Sh ENVIRONMENT
The following environment variable affects the execution of
@@ -183,6 +196,7 @@ mute=off
reference=50kHz
signal=on
stereo=on
+mode: radio
card capabilities:
manageable mono/stereo
.Ed
diff --git a/usr.bin/radioctl/radioctl.c b/usr.bin/radioctl/radioctl.c
index b9c98628f7d..41f6e94af34 100644
--- a/usr.bin/radioctl/radioctl.c
+++ b/usr.bin/radioctl/radioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radioctl.c,v 1.12 2005/12/05 16:30:24 robert Exp $ */
+/* $OpenBSD: radioctl.c,v 1.13 2006/02/05 23:52:58 jakemsr Exp $ */
/* $RuOBSD: radioctl.c,v 1.4 2001/10/20 18:09:10 pva Exp $ */
/*
@@ -296,6 +296,7 @@ change_value(const struct opt_t o)
update_value(o.sign, &ri.volume, o.value);
break;
case OPTION_FREQUENCY:
+ ri.tuner_mode = RADIO_TUNER_MODE_RADIO;
update_value(o.sign, &ri.freq, o.value);
break;
case OPTION_REFERENCE:
@@ -322,6 +323,7 @@ change_value(const struct opt_t o)
ri.mute = o.value;
break;
case OPTION_CHANNEL:
+ ri.tuner_mode = RADIO_TUNER_MODE_TV;
update_value(o.sign, &ri.chan, o.value);
break;
case OPTION_CHNLSET:
@@ -600,8 +602,13 @@ print_vars(int silent, int show_choices)
printf("%s\n", ri.info & RADIO_INFO_STEREO ? onchar : offchar);
}
- if (!silent)
+ if (!silent) {
+ printf("mode: %s\n",
+ ri.tuner_mode == RADIO_TUNER_MODE_TV ? "TV" : "radio");
+
puts("card capabilities:");
+ }
+
if (ri.caps & RADIO_CAPS_SET_MONO)
puts("\tmanageable mono/stereo");
if (ri.caps & RADIO_CAPS_HW_SEARCH)