patch for bktr(4): don't reset tuner on open/close

Jacob Meuser jakemsr at jakemsr.com
Sat Apr 23 15:55:09 PDT 2005


the following is a patch that is in OpenBSD's bktr.

the idea is to not reset the tuner device on open(2) and close(2).

effects:
  - don't need to hold /dev/tuner open to get audio.
  - selected channelset won't get clobbered on open/close.  IMO, the
    current behaviour here is idiotic.  the channelset has nothing to
    do with the hardware.  it is internally used by the driver.  also,
    this is IMO a much cleaner fix to the problems with V4L programs
    not tuning properly because they never set the channelset.  now
    the correct channelset can be set at bootup with something like
    bsdbktrtvtune or whatever, instead of rebuilding the kernel with
    the default channelset hardcoded into the driver.

BTW, I haven't tested this on FreeBSD at all.  it might need some
tweaking.  the diff is also set up so that BKTR_NO_OPEN_RESET must
be defined to enable it.  ultimately, I think this should be the
default behaviour.

-- 
<jakemsr at jakemsr.com>

Index: bktr_core.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/bktr/bktr_core.c,v
retrieving revision 1.138
diff -u -r1.138 bktr_core.c
--- bktr_core.c	9 Jan 2005 17:42:03 -0000	1.138
+++ bktr_core.c	23 Apr 2005 22:41:30 -0000
@@ -626,6 +626,14 @@
 	/* 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
+
 #ifdef BKTR_NEW_MSP34XX_DRIVER
 	/* setup the kenrel thread */
 	err = msp_attach( bktr );
@@ -1106,6 +1114,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;
@@ -1120,7 +1130,8 @@
 
 	/* Initialise any audio chips, eg MSP34xx or TDA98xx */
 	init_audio_devices( bktr );
-	
+#endif
+
 	return( 0 );
 }
 
@@ -1162,11 +1173,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 );
 }


More information about the freebsd-multimedia mailing list