Btaudio (bt878): Difference between revisions

From LinuxTVWiki
Jump to navigation Jump to search
No edit summary
Line 64: Line 64:
</table>
</table>


The analog device created by the btaudio driver has three mixer channels, called Line1, Line2, and Line3. The sound comes through on Line2 (cf. [[btaudio#Instructions | Instructions]] section above). One of the line inputs that show up in the mixer is an internal mux switch between STV and SML. The other is a switch for a single stage 6dB preamp boost for the audio signal. The input gain control in the audio A/D (Line2 in the mixer) has 15 gain settings, from 0.5 times (-6db) to 3 times (10db) - this is in addition to the 6dB switchable audio preamp boost. What gain setting you need depends on the magnitude of the input signal from the tuner. The audio A/D is designed with a nominal input signal of 0.5V RMS, but the tuner input could be very different.
The analog device created by the btaudio driver has three mixer channels, called Line1, Line2, and Line3. The sound comes through on Line2 (cf. [[btaudio#Instructions | Instructions]] section above). One of the line inputs that show up in the mixer is an internal mux switch between STV and SML. According to the datasheet, section 2.15.1, the mux is controlled by A_SEL; if this value is set to 3, mux is disabled.


The other is a switch for a single stage 6dB preamp boost for the audio signal. The input gain control in the audio A/D (Line2 in the mixer) has 13 gain settings, from 0.5 times (-6db) to 2.5 times (8db) - this is in addition to the 6dB switchable audio preamp boost. What gain setting you need depends on the magnitude of the input signal from the tuner. The audio A/D is designed with a nominal input signal of 0.5V RMS, but the tuner input could be very different.
The ADC audio stage runs a 1.792MHz clock with valid hardware decimation values between 4 and 15 (controlled by bits 8-11 of local register 0x10C, the so-called DA_SDR register).

The ADC audio stage runs a 1.792MHz clock with valid hardware decimation values between 4 and 15 (controlled by bits 8-11 of local register 0x10C, Audio Control Register (GPIO_DMA_CTL).


Juan uses these commands to test the device:
Juan uses these commands to test the device:
Line 88: Line 90:


Juan notes that it's possible to force the ADC to accept a decimation value lower than 4 for even higher sampling rates.
Juan notes that it's possible to force the ADC to accept a decimation value lower than 4 for even higher sampling rates.

The datasheet (section 2.15.1) explains that


As for which cards are supported, David Martin writes,
As for which cards are supported, David Martin writes,

Revision as of 04:46, 28 April 2005

The btaudio kernel module allows you to get the audio from your tuner card directly over the PCI bus without using a patch cable to your sound card. This is useful if you would like to reserve your sound card for other functions, if you want to have multiple tuner cards in one computer, or if your sound card does not handle full-duplex.

Instructions

Supported cards

Although all cards with BT878 or 879 chips are capable of supporting btaudio, not all cards do. In some cases, the manufacturer elected not to connect the TV tuner analogue audio out to one of the two ADC analogue inputs, which means you'll get no sound from btaudio. There are also documented cases (see [[TVCapture_98#Getting_the_sound_directly_off_the_tv_card | TVCapture_98]) where the card is wired correctly, but the btaudio driver fails.

According to Robert Kulagowski on the MythTV HowTo, you need a bttv tuner device with an MSP34xx chip; this is incorrect.

In practice, these cards are known to work with btaudio; the real set of working cards is likely much higher:

   * ATI TV Wonder
   * Hauppauge WinTV-radio with dbx-TV stereo, model 401
   * Hauppauge WinTV-Theater, model 495, 498 (Europe)
   * Hauppauge WinTV Express, models 751, 753 (but see note)

Note: Hauppauge model labels are often uninformative. For example, the box labeled model 753 may contain one of these:

* board #44804 rev #D183, auto card=10; tuner TCL2002MB-3 (hidden sticker), but has to be forced to tuner=41 (Phillips PAL-MK(FI1216MK)
* board #44804 rev #D108, auto card=10; tuner FI1215MK5 (hidden sticker), autodetected as tuner=5.

The following cards are said not to work, but it's not known if they are wired the wrong way or not supported by btaudio:

   * Pinnacle Studio PCTV Pro 
   * ATI TV Wonder VE
   * Leadtek Winfast 2000 XP (PAL, UK and NTSC)
   * I/O Magic PC-PVR 

The following cards have been reported to work, but the quality is poor:

   * Avermedia AVerTV Studio (no digital DSP output, "whiney noise" on analog)

The list may not be very informative; YMMV.

Technical background

The bt878 and bt879 (the latter no longer in production) include a high-frequency Analog to Digital Converter, supporting both 8 and 16 bits audio at 448000 samples per second.

Juan Domenech Fernandez has written up his experiments with the "low frequency ADC that comes with the Bt878A chip" in two parts; these articles provide valuable technical detail about the hardware driven by btaudio:

The 878/9 audio ADC has three inputs - STV (Sound TV), SML (Sound Mic/Line), and SFM (Sound FM) (not all chips have the latter).

On the datasheet, the relevant pins are 94, 98, and 100, and you need to inspect your card to see how the card manufacturer has used these pins:

    http://www.domenech.org/bt878a-adc/conexant-fusion-878a-pin-out-bt878a-adc.png

These ADC pins serve the following functions:

Pin Signal Description
100 STV I TV sound input from TV tuner.
98 SFM I FM sound input from FM tuner.
94 SML I MIC/line input.

The analog device created by the btaudio driver has three mixer channels, called Line1, Line2, and Line3. The sound comes through on Line2 (cf. Instructions section above). One of the line inputs that show up in the mixer is an internal mux switch between STV and SML. According to the datasheet, section 2.15.1, the mux is controlled by A_SEL; if this value is set to 3, mux is disabled.

The other is a switch for a single stage 6dB preamp boost for the audio signal. The input gain control in the audio A/D (Line2 in the mixer) has 13 gain settings, from 0.5 times (-6db) to 2.5 times (8db) - this is in addition to the 6dB switchable audio preamp boost. What gain setting you need depends on the magnitude of the input signal from the tuner. The audio A/D is designed with a nominal input signal of 0.5V RMS, but the tuner input could be very different.

The ADC audio stage runs a 1.792MHz clock with valid hardware decimation values between 4 and 15 (controlled by bits 8-11 of local register 0x10C, Audio Control Register (GPIO_DMA_CTL).

Juan uses these commands to test the device:

 sox -w -r 448000 -t ossdsp /dev/dsp1 -t .wav test.wav

The dmesg results indicates which decimation values are used to downsample, yielding this table of twelve valid hardware rates:

 4:   448    kHz
 5:   358.4  kHz
 6:   298.67 kHz
 7:   256    kHz
 8:   224    kHz
 9:   199.1  kHz
10:   179.2  kHz
11:   162.9  kHz
12:   149.3  kHz
13:   137.8  kHz
14:   128    kHz
15:   119.47 kHz

Juan notes that it's possible to force the ADC to accept a decimation value lower than 4 for even higher sampling rates.

The datasheet (section 2.15.1) explains that

As for which cards are supported, David Martin writes,

"Every BT878/879 card has an onboard audio ADC with two analogue inputs. The BT879 (a rare bird and now out of production AFAIK) also has a pair of FM/FM stereo inputs as well. There is also a digital audio packetizer and FIFO buffer for DMA audio transport across the PCI bus to the host PC. All of this is on the BT87x silicon - identical on every card - and accessible via the btaudio driver. As a result the btaudio driver is almost entirely card agnostic. It only does a few things, roughly something like:

  1. Control the ADC switching mux to determine which of the two analogue input lines will be sampled.
  2. Control the ADC input gain (ie. the volume)
  3. Control the digital low pass filter to set the decimation factor and, hence, the digital output frequency.
  4. Control the digital audio packetizer input selection (the ADC or the external digital line in).
  5. Set the digital audio packetizer output mode and characteristics for the PCI bus data transfer.

That's it. All of that functionality is contained within the BT87x silicon, and is identical on every card.

In every case the btaudio analogue device should produce output when you ask for it. That is most certainly my experience. I can foresee exactly two different cases as two what this analogue output will be like:

  1. If the designer of a given card has elected to connect the TV tuner analogue audio out to one of the two ADC analogue inputs (usually pin 100 on the BT87x), you will get the broadcast audio. The quality of the output can vary wildly from card to card (from good to unusably awful), but there will be output of the TV audio. Sometimes you can play around with sample frequencies and input gain settings and improve things. Sometimes you can't.
  2. If the designer of the given card elected not to connect the tuner analogue audio output to the BT87x audio ADC then you will get static or silence. Nothing short of a soldering iron will help you in this case.

In my experience, the greatest majority of cards fall into the first category. Most designs seem to hook up the tuner mono TV audio to the BT87x STV pin. In some cases cards have multiple signal sources (a tuner and an external composite video and audio input pair, for example). In these designs there will be an analogue switching IC between the two input sources and the BT87x. Usually the the audio inputs bypass the switcher IC and the tuner is on the STV pin and the auxiliary audio is on the LINE pin. I have seen at least one card where the switcher IC routes both audio and video, and with the audio output from the switch only going to the external audio out, so you can use btaudio for the TV tuner, but not for the external audio input.

Digital audio input is only slightly different. Most analogue capture cards have nothing connected to the inputs and they don't work - if you try and use the btaudio digital input you app will freeze and nothing will happen. Some cards might have NICAM stereo decoders or FM/FM stereo decoders on board and they might produce i2s output and be connected to the BT87x digital audio input line. I have never had one in my hands to speak authoritatively about such a design.

The long and short of this is that analog mono audio via btaudio should either "just work" or it won't work at all and there is essentially nothing you can do about it if it doesn't, although I would expect the latter case to be in the minority. Digital audio won't work in the majority of cases because there is no external digital audio source to drive it."

Adding a third category to this account by David Martin is Petr Vandrovec's account of making btaudio work by means of a Win98 card initialization; this indicates there are bt87x cards that are physically capable of working with btaudio, but lack some element in the driver.