From q@coyote.dnsalias.net  Wed Jan  8 08:37:04 2003
Return-Path: <q@coyote.dnsalias.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2EAD437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 08:37:04 -0800 (PST)
Received: from wrzx35.rz.uni-wuerzburg.de (wrzx35.rz.uni-wuerzburg.de [132.187.3.35])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BFDC143E4A
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 08:37:02 -0800 (PST)
	(envelope-from q@coyote.dnsalias.net)
Received: from wrzx34.rz.uni-wuerzburg.de (wrzx34.rz.uni-wuerzburg.de [132.187.3.34])
	by wrzx35.rz.uni-wuerzburg.de (8.8.8/8.8.8/uniwue-MM-1.05) with ESMTP id RAA253202
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 8 Jan 2003 17:36:57 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by virusscan.rz.uni-wuerzburg.de (Postfix) with ESMTP id 182CA6756D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 17:31:42 +0100 (CET)
Received: from wrzx07.rz.uni-wuerzburg.de (wrzx07.rz.uni-wuerzburg.de [132.187.1.7])
	by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id 6C82067563
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 17:31:41 +0100 (CET)
Received: from spamchecker (localhost [127.0.0.1])
	by spamcheck.rz.uni-wuerzburg.de (Postfix) with ESMTP id C4A484650
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 17:31:35 +0100 (CET)
Received: from coyote.dnsalias.net (gb-007.galgenberg.net [132.187.222.7])
	by wrzx07.rz.uni-wuerzburg.de (Postfix) with ESMTP id 219B9464B
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  8 Jan 2003 17:31:35 +0100 (CET)
Received: (from q@localhost)
	by coyote.dnsalias.net (8.12.6/8.12.6/Submit) id h08GVZY2053340;
	Wed, 8 Jan 2003 17:31:35 +0100 (CET)
Message-Id: <200301081631.h08GVZY2053340@coyote.dnsalias.net>
Date: Wed, 8 Jan 2003 17:31:35 +0100 (CET)
From: Ulrich Spoerlein <q@uni.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Make sound work on TV-cards with MSDP3415D-B3 chip
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46872
>Category:       kern
>Synopsis:       Make sound work on TV-cards with MSDP3415D-B3 chip
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    alex
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 08 08:40:01 PST 2003
>Closed-Date:    Wed Oct 22 08:47:27 PDT 2003
>Last-Modified:  Wed Oct 22 08:47:27 PDT 2003
>Originator:     Ulrich Spoerlein
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD coyote.dnsalias.net 4.7-STABLE FreeBSD 4.7-STABLE #1: Mon Nov 18 09:46:38 CET 2002 root@coyote.dnsalias.net:/usr/obj/usr/src/sys/COYOTE i386

% dmesg|grep bktr
bktr0: <BrookTree 878> mem 0xd7000000-0xd7000fff irq 7 at device 11.0 on pci0
bktr0: Hauppauge Model 44354 C221
bktr0: Detected a MSP3415D-B3 at 0x80
bktr0: Hauppauge WinCast/TV, Philips FR1216 PAL FM tuner, msp3400c stereo, remote control.

>Description:
Ok, this problem is a bit more complex. The above is a WinTV Stereo FM card purchased in Germany. It has the MSP34154D-B3 chip, responsible for Stereo sound on FM-Radio and TV. But sadly, nearly all TV applications are unable to initialize the sound-chip (fxtv works, when 'internal audio' is selected), although the initialization looks right (i triple-checked with the documentation available on that chip).

There is one work-around for getting sound: Start a radio application (xmradio), then start for example xawtv and switch the channel. Voila, sound. The ugly thing is, this won't work if you're trying to capture with ffmpeg or mencoder.

After trying nearly all ways of initializing this chip, i just copied the initialization from the FM Tuner to the TV Tuner part and ... it works every time.

	
>How-To-Repeat:
Buy one of these cards (i think the german cards are special) and try for yourself :)
	
>Fix:
Ok, this Fix is not very nice. I abused slow_msp_audio, but i didn't want to add another field to the bktr struct.
I changed the auto_detect value, because the specs say: Results exceeding 0x07ff indicate an active autodetect
	

--- bktr.patch begins here ---
--- sys/dev/bktr/bktr_audio.c	1 Nov 2000 09:36:14 -0000	1.2.2.4
+++ sys/dev/bktr/bktr_audio.c	10 Dec 2002 12:48:35 -0000
@@ -482,7 +482,7 @@
 
     msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0030,0x2003);/* Enable Auto format detection */
     msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0020);/* Standard Select Reg. = BTSC-Stereo*/
-    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000E,0x2403);/* darned if I know */
+    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000e,0x2403);/* FM prescale */
     msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0320);/* Source select = (St or A) */
 					                     /* & Ch. Matrix = St */
     msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
@@ -500,8 +500,15 @@
     msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
     msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0100); /* DSP In = MONO IN */
   }
-
-
+  /* MSP3415D-B3 SPECIAL CASE  Use same calls as setting up the FM Tuner */
+  /* (for Hauppauge 44xxx card with Tuner Type 0x15) */
+  else if( bktr->slow_msp_audio == 3){
+    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000, 0x7300); /* 0 db volume */
+    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x000d, 0x7f00); /* scart prescale */
+    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008, 0x0220); /* SCART | STEREO */
+    msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0013, 0x0200); /* DSP In = SC2_IN_L/R */
+  }
+	
   /* MSP3410/MSP3415 - countries with mono, stereo using 2 FM channels and NICAM */
   /* FAST sound scheme */
   else if (bktr->slow_msp_audio == 0) {
@@ -524,7 +531,7 @@
       DELAY(100000);
       auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e);
       loops++;
-    } while (auto_detect > 0xff && loops < 50);
+    } while (auto_detect > 0x07ff && loops < 500);
     if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n",
 			    bktr_name(bktr), loops*10, auto_detect);
 
--- sys/dev/bktr/bktr_card.c	1 Nov 2000 09:36:14 -0000	1.9.2.4
+++ sys/dev/bktr/bktr_card.c	10 Dec 2002 12:48:36 -0000
@@ -995,11 +995,12 @@
 
                   case 0x15:
 		    select_tuner( bktr, PHILIPS_FR1216_PAL );
+		    bktr->slow_msp_audio = 3;
 		    goto checkDBX;
 
                   case 0x2a:
-		    bktr->msp_use_mono_source = 1;
 		    select_tuner( bktr, PHILIPS_FR1216_PAL );
+		    bktr->msp_use_mono_source = 1;
 		    goto checkDBX;
 
 	          default :
--- bktr.patch ends here ---
>Release-Note:
>Audit-Trail:

From: Drazen Ferencic <drazen@avalon.hr>
To: freebsd-gnats-submit@FreeBSD.org
Cc: q@uni.de
Subject: Re: kern/46872: Make sound work on TV-cards with MSDP3415D-B3 chip
Date: Mon, 20 Jan 2003 20:34:42 +0100

 Hi
 
 Your patch works fine. The only thing I needed to do is to run sysctl -w 
 hw.bt848.slow_msp_audio=3. Default value is -1.
 
 My hardware:
 
 bktr0: <BrookTree 878> mem 0xee800000-0xee800fff irq 9 at device 12.0 on pci2
 bktr0: Hauppauge Model 44354 D147
 bktr0: Warning - Unknown Hauppauge Tuner 0x2f
 bktr0: Detected a MSP3415D-B3 at 0x80
 bktr0: Hauppauge WinCast/TV, Philips PAL I tuner, msp3400c stereo, remote 
 control.
 
 Best regards,
 
 -- 
 Drazen Ferencic
 

From: Ulrich Spoerlein <q@uni.de>
To: Drazen Ferencic <drazen@avalon.hr>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/46872: Make sound work on TV-cards with MSDP3415D-B3 chip
Date: Tue, 21 Jan 2003 13:21:00 +0100

 On 2003/01/20-11:40:02 Drazen Ferencic wrote:
 
 > Your patch works fine. The only thing I needed to do is to run sysctl -w 
 > hw.bt848.slow_msp_audio=3. Default value is -1.
 > 
 > My hardware:
 > 
 > bktr0: <BrookTree 878> mem 0xee800000-0xee800fff irq 9 at device 12.0 on pci2
 > bktr0: Hauppauge Model 44354 D147
 > bktr0: Warning - Unknown Hauppauge Tuner 0x2f
 > bktr0: Detected a MSP3415D-B3 at 0x80
 > bktr0: Hauppauge WinCast/TV, Philips PAL I tuner, msp3400c stereo, remote 
 > control.
 
 Interessting, could you tell me the exact Version String of your tuner? You
 might need to open your case and look on the card if there's anything from
 'Philips'. It's probably something like FM1246 or FR1246 or similar.
 
 Is this a card advertised as stereo or mono?
 Could you please try it with hw.bt848.slow_msp_audio=1 and =2?
State-Changed-From-To: open->feedback 
State-Changed-By: alex 
State-Changed-When: Sun Oct 5 15:03:45 PDT 2003 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=46872 
Responsible-Changed-From-To: freebsd-bugs->alex 
Responsible-Changed-By: alex 
Responsible-Changed-When: Sun Oct 5 15:04:30 PDT 2003 
Responsible-Changed-Why:  
Could you by chance test this on a -CURRENT box? 

I've committed a port of the driver a while back which 
fixed this for me and should fix this as well for you. 

Try it with the BKTR_NEW_MSP34XX_DRIVER option in the kernel-config. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46872 
State-Changed-From-To: feedback->closed 
State-Changed-By: alex 
State-Changed-When: Wed Oct 22 08:46:27 PDT 2003 
State-Changed-Why:  
According to the submitter, the new kernel option works. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46872 
>Unformatted:
