[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

behaviour of bktr(4)'s /dev/tuner0



I set out to write a program called tunerctl, like sysctl, audioctl,
radioctl, etc.  However, this device does a couple things on open(2)
close(2) that make this nearly impossible.

First, on open(2), /dev/tuner0 automatically unmutes the audio, and
mutes it again on close.  This seems strange to me.  The radio(4)
devices do not do this, or it wouldn't be possible to effectively
unmute the audio with radioctl(1).

Second, on open(2), /dev/tuner0 resets driver variables without changing
anything in the hardware.  For example, if the tuner is opened and set,
and then opened again, it will not report the channel it is tuned to.
It will report the default values.

Anyway, I have been using the following patch for some time and the
only problem so far is fxtv doesn't explicitly mute audio when closed.
This moves audio control initialization to attach routines, and mutes
the audio as well.  Also, makes the driver not reset variables
containing hardware information.

BKTR_NO_OPEN_RESET must be defined for these changes to be effective.

-- 
<jakemsr_(_at_)_jakemsr_(_dot_)_com>

Index: sys/dev/pci/bktr/bktr_core.c
===================================================================
RCS file: /home/cvs/OpenBSD/src/sys/dev/pci/bktr/bktr_core.c,v
retrieving revision 1.13
diff -u -r1.13 bktr_core.c
--- sys/dev/pci/bktr/bktr_core.c	29 Jun 2004 12:24:57 -0000	1.13
+++ sys/dev/pci/bktr/bktr_core.c	23 Mar 2005 06:19:05 -0000
@@ -617,6 +617,15 @@
 
 	/* Initialise any MSP34xx or TDA98xx audio chips */
 	init_audio_devices(bktr);
+
+#ifdef BKTR_NO_OPEN_RESET
+	/* enable drivers on the GPIO port that control the MUXes */
+	OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) | bktr->card.gpio_mux_bits);
+
+	/* mute the audio stream */
+	set_audio( bktr, AUDIO_MUTE );
+#endif
+
 }
 
 
@@ -1087,6 +1096,8 @@
 		return( 0 );
 
 	bktr->tflags |= TUNER_OPEN;
+
+#ifndef BKTR_NO_OPEN_RESET
 	bktr->tuner.frequency = 0;
 	bktr->tuner.channel = 0;
 	bktr->tuner.chnlset = DEFAULT_CHNLSET;
@@ -1101,6 +1112,7 @@
 
 	/* Initialise any audio chips, eg MSP34xx or TDA98xx */
 	init_audio_devices( bktr );
+#endif
 
 	return( 0 );
 }
@@ -1143,11 +1155,13 @@
 {
 	bktr->tflags &= ~TUNER_OPEN;
 
+#ifndef BKTR_NO_OPEN_RESET
 	/* mute the audio by switching the mux */
 	set_audio( bktr, AUDIO_MUTE );
 
 	/* disable drivers on the GPIO port that control the MUXes */
 	OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) & ~bktr->card.gpio_mux_bits);
+#endif
 
 	return( 0 );
 }



Visit your host, monkey.org