xref: /OK3568_Linux_fs/kernel/Documentation/driver-api/media/drivers/bttv-devel.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunThe bttv driver
4*4882a593Smuzhiyun===============
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunbttv and sound mini howto
7*4882a593Smuzhiyun-------------------------
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunThere are a lot of different bt848/849/878/879 based boards available.
10*4882a593SmuzhiyunMaking video work often is not a big deal, because this is handled
11*4882a593Smuzhiyuncompletely by the bt8xx chip, which is common on all boards.  But
12*4882a593Smuzhiyunsound is handled in slightly different ways on each board.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunTo handle the grabber boards correctly, there is a array tvcards[] in
15*4882a593Smuzhiyunbttv-cards.c, which holds the information required for each board.
16*4882a593SmuzhiyunSound will work only, if the correct entry is used (for video it often
17*4882a593Smuzhiyunmakes no difference).  The bttv driver prints a line to the kernel
18*4882a593Smuzhiyunlog, telling which card type is used.  Like this one::
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun	bttv0: model: BT848(Hauppauge old) [autodetected]
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunYou should verify this is correct.  If it isn't, you have to pass the
23*4882a593Smuzhiyuncorrect board type as insmod argument, ``insmod bttv card=2`` for
24*4882a593Smuzhiyunexample.  The file :doc:`/admin-guide/media/bttv-cardlist` has a list
25*4882a593Smuzhiyunof valid arguments for card.
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunIf your card isn't listed there, you might check the source code for
28*4882a593Smuzhiyunnew entries which are not listed yet.  If there isn't one for your
29*4882a593Smuzhiyuncard, you can check if one of the existing entries does work for you
30*4882a593Smuzhiyun(just trial and error...).
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunSome boards have an extra processor for sound to do stereo decoding
33*4882a593Smuzhiyunand other nice features.  The msp34xx chips are used by Hauppauge for
34*4882a593Smuzhiyunexample.  If your board has one, you might have to load a helper
35*4882a593Smuzhiyunmodule like ``msp3400`` to make sound work.  If there isn't one for the
36*4882a593Smuzhiyunchip used on your board:  Bad luck.  Start writing a new one.  Well,
37*4882a593Smuzhiyunyou might want to check the video4linux mailing list archive first...
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunOf course you need a correctly installed soundcard unless you have the
40*4882a593Smuzhiyunspeakers connected directly to the grabber board.  Hint: check the
41*4882a593Smuzhiyunmixer settings too.  ALSA for example has everything muted by default.
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunHow sound works in detail
45*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunStill doesn't work?  Looks like some driver hacking is required.
48*4882a593SmuzhiyunBelow is a do-it-yourself description for you.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunThe bt8xx chips have 32 general purpose pins, and registers to control
51*4882a593Smuzhiyunthese pins.  One register is the output enable register
52*4882a593Smuzhiyun(``BT848_GPIO_OUT_EN``), it says which pins are actively driven by the
53*4882a593Smuzhiyunbt848 chip.  Another one is the data register (``BT848_GPIO_DATA``), where
54*4882a593Smuzhiyunyou can get/set the status if these pins.  They can be used for input
55*4882a593Smuzhiyunand output.
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunMost grabber board vendors use these pins to control an external chip
58*4882a593Smuzhiyunwhich does the sound routing.  But every board is a little different.
59*4882a593SmuzhiyunThese pins are also used by some companies to drive remote control
60*4882a593Smuzhiyunreceiver chips.  Some boards use the i2c bus instead of the gpio pins
61*4882a593Smuzhiyunto connect the mux chip.
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunAs mentioned above, there is a array which holds the required
64*4882a593Smuzhiyuninformation for each known board.  You basically have to create a new
65*4882a593Smuzhiyunline for your board.  The important fields are these two::
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun  struct tvcard
68*4882a593Smuzhiyun  {
69*4882a593Smuzhiyun	[ ... ]
70*4882a593Smuzhiyun	u32 gpiomask;
71*4882a593Smuzhiyun	u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
72*4882a593Smuzhiyun  };
73*4882a593Smuzhiyun
74*4882a593Smuzhiyungpiomask specifies which pins are used to control the audio mux chip.
75*4882a593SmuzhiyunThe corresponding bits in the output enable register
76*4882a593Smuzhiyun(``BT848_GPIO_OUT_EN``) will be set as these pins must be driven by the
77*4882a593Smuzhiyunbt848 chip.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunThe ``audiomux[]`` array holds the data values for the different inputs
80*4882a593Smuzhiyun(i.e. which pins must be high/low for tuner/mute/...).  This will be
81*4882a593Smuzhiyunwritten to the data register (``BT848_GPIO_DATA``) to switch the audio
82*4882a593Smuzhiyunmux.
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun
85*4882a593SmuzhiyunWhat you have to do is figure out the correct values for gpiomask and
86*4882a593Smuzhiyunthe audiomux array.  If you have Windows and the drivers four your
87*4882a593Smuzhiyuncard installed, you might to check out if you can read these registers
88*4882a593Smuzhiyunvalues used by the windows driver.  A tool to do this is available
89*4882a593Smuzhiyunfrom http://btwincap.sourceforge.net/download.html.
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunYou might also dig around in the ``*.ini`` files of the Windows applications.
92*4882a593SmuzhiyunYou can have a look at the board to see which of the gpio pins are
93*4882a593Smuzhiyunconnected at all and then start trial-and-error ...
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunStarting with release 0.7.41 bttv has a number of insmod options to
97*4882a593Smuzhiyunmake the gpio debugging easier:
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun	=================	==============================================
100*4882a593Smuzhiyun	bttv_gpio=0/1		enable/disable gpio debug messages
101*4882a593Smuzhiyun	gpiomask=n		set the gpiomask value
102*4882a593Smuzhiyun	audiomux=i,j,...	set the values of the audiomux array
103*4882a593Smuzhiyun	audioall=a		set the values of the audiomux array (one
104*4882a593Smuzhiyun				value for all array elements, useful to check
105*4882a593Smuzhiyun				out which effect the particular value has).
106*4882a593Smuzhiyun	=================	==============================================
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunThe messages printed with ``bttv_gpio=1`` look like this::
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun	bttv0: gpio: en=00000027, out=00000024 in=00ffffd8 [audio: off]
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun	en  =	output _en_able register (BT848_GPIO_OUT_EN)
113*4882a593Smuzhiyun	out =	_out_put bits of the data register (BT848_GPIO_DATA),
114*4882a593Smuzhiyun		i.e. BT848_GPIO_DATA & BT848_GPIO_OUT_EN
115*4882a593Smuzhiyun	in  = 	_in_put bits of the data register,
116*4882a593Smuzhiyun		i.e. BT848_GPIO_DATA & ~BT848_GPIO_OUT_EN
117