Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 The bttv driver
0004 ===============
0005 
0006 bttv and sound mini howto
0007 -------------------------
0008 
0009 There are a lot of different bt848/849/878/879 based boards available.
0010 Making video work often is not a big deal, because this is handled
0011 completely by the bt8xx chip, which is common on all boards.  But
0012 sound is handled in slightly different ways on each board.
0013 
0014 To handle the grabber boards correctly, there is a array tvcards[] in
0015 bttv-cards.c, which holds the information required for each board.
0016 Sound will work only, if the correct entry is used (for video it often
0017 makes no difference).  The bttv driver prints a line to the kernel
0018 log, telling which card type is used.  Like this one::
0019 
0020         bttv0: model: BT848(Hauppauge old) [autodetected]
0021 
0022 You should verify this is correct.  If it isn't, you have to pass the
0023 correct board type as insmod argument, ``insmod bttv card=2`` for
0024 example.  The file Documentation/admin-guide/media/bttv-cardlist.rst has a list
0025 of valid arguments for card.
0026 
0027 If your card isn't listed there, you might check the source code for
0028 new entries which are not listed yet.  If there isn't one for your
0029 card, you can check if one of the existing entries does work for you
0030 (just trial and error...).
0031 
0032 Some boards have an extra processor for sound to do stereo decoding
0033 and other nice features.  The msp34xx chips are used by Hauppauge for
0034 example.  If your board has one, you might have to load a helper
0035 module like ``msp3400`` to make sound work.  If there isn't one for the
0036 chip used on your board:  Bad luck.  Start writing a new one.  Well,
0037 you might want to check the video4linux mailing list archive first...
0038 
0039 Of course you need a correctly installed soundcard unless you have the
0040 speakers connected directly to the grabber board.  Hint: check the
0041 mixer settings too.  ALSA for example has everything muted by default.
0042 
0043 
0044 How sound works in detail
0045 ~~~~~~~~~~~~~~~~~~~~~~~~~
0046 
0047 Still doesn't work?  Looks like some driver hacking is required.
0048 Below is a do-it-yourself description for you.
0049 
0050 The bt8xx chips have 32 general purpose pins, and registers to control
0051 these pins.  One register is the output enable register
0052 (``BT848_GPIO_OUT_EN``), it says which pins are actively driven by the
0053 bt848 chip.  Another one is the data register (``BT848_GPIO_DATA``), where
0054 you can get/set the status if these pins.  They can be used for input
0055 and output.
0056 
0057 Most grabber board vendors use these pins to control an external chip
0058 which does the sound routing.  But every board is a little different.
0059 These pins are also used by some companies to drive remote control
0060 receiver chips.  Some boards use the i2c bus instead of the gpio pins
0061 to connect the mux chip.
0062 
0063 As mentioned above, there is a array which holds the required
0064 information for each known board.  You basically have to create a new
0065 line for your board.  The important fields are these two::
0066 
0067   struct tvcard
0068   {
0069         [ ... ]
0070         u32 gpiomask;
0071         u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
0072   };
0073 
0074 gpiomask specifies which pins are used to control the audio mux chip.
0075 The corresponding bits in the output enable register
0076 (``BT848_GPIO_OUT_EN``) will be set as these pins must be driven by the
0077 bt848 chip.
0078 
0079 The ``audiomux[]`` array holds the data values for the different inputs
0080 (i.e. which pins must be high/low for tuner/mute/...).  This will be
0081 written to the data register (``BT848_GPIO_DATA``) to switch the audio
0082 mux.
0083 
0084 
0085 What you have to do is figure out the correct values for gpiomask and
0086 the audiomux array.  If you have Windows and the drivers four your
0087 card installed, you might to check out if you can read these registers
0088 values used by the windows driver.  A tool to do this is available
0089 from http://btwincap.sourceforge.net/download.html.
0090 
0091 You might also dig around in the ``*.ini`` files of the Windows applications.
0092 You can have a look at the board to see which of the gpio pins are
0093 connected at all and then start trial-and-error ...
0094 
0095 
0096 Starting with release 0.7.41 bttv has a number of insmod options to
0097 make the gpio debugging easier:
0098 
0099         =================       ==============================================
0100         bttv_gpio=0/1           enable/disable gpio debug messages
0101         gpiomask=n              set the gpiomask value
0102         audiomux=i,j,...        set the values of the audiomux array
0103         audioall=a              set the values of the audiomux array (one
0104                                 value for all array elements, useful to check
0105                                 out which effect the particular value has).
0106         =================       ==============================================
0107 
0108 The messages printed with ``bttv_gpio=1`` look like this::
0109 
0110         bttv0: gpio: en=00000027, out=00000024 in=00ffffd8 [audio: off]
0111 
0112         en  =   output _en_able register (BT848_GPIO_OUT_EN)
0113         out =   _out_put bits of the data register (BT848_GPIO_DATA),
0114                 i.e. BT848_GPIO_DATA & BT848_GPIO_OUT_EN
0115         in  =   _in_put bits of the data register,
0116                 i.e. BT848_GPIO_DATA & ~BT848_GPIO_OUT_EN