xref: /linux/Documentation/driver-api/media/drivers/bttv-devel.rst (revision a169c44e58190bbdaf9c8d345cd445eec2c2b010)
1577a7ad3SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2577a7ad3SMauro Carvalho Chehab
3577a7ad3SMauro Carvalho ChehabThe bttv driver
4577a7ad3SMauro Carvalho Chehab===============
5577a7ad3SMauro Carvalho Chehab
6577a7ad3SMauro Carvalho Chehabbttv and sound mini howto
7577a7ad3SMauro Carvalho Chehab-------------------------
8577a7ad3SMauro Carvalho Chehab
9577a7ad3SMauro Carvalho ChehabThere are a lot of different bt848/849/878/879 based boards available.
10577a7ad3SMauro Carvalho ChehabMaking video work often is not a big deal, because this is handled
11577a7ad3SMauro Carvalho Chehabcompletely by the bt8xx chip, which is common on all boards.  But
12577a7ad3SMauro Carvalho Chehabsound is handled in slightly different ways on each board.
13577a7ad3SMauro Carvalho Chehab
14577a7ad3SMauro Carvalho ChehabTo handle the grabber boards correctly, there is a array tvcards[] in
15577a7ad3SMauro Carvalho Chehabbttv-cards.c, which holds the information required for each board.
16577a7ad3SMauro Carvalho ChehabSound will work only, if the correct entry is used (for video it often
17577a7ad3SMauro Carvalho Chehabmakes no difference).  The bttv driver prints a line to the kernel
184605a610SMauro Carvalho Chehablog, telling which card type is used.  Like this one::
19577a7ad3SMauro Carvalho Chehab
20577a7ad3SMauro Carvalho Chehab	bttv0: model: BT848(Hauppauge old) [autodetected]
21577a7ad3SMauro Carvalho Chehab
22577a7ad3SMauro Carvalho ChehabYou should verify this is correct.  If it isn't, you have to pass the
234605a610SMauro Carvalho Chehabcorrect board type as insmod argument, ``insmod bttv card=2`` for
24*a169c44eSMauro Carvalho Chehabexample.  The file Documentation/admin-guide/media/bttv-cardlist.rst has a list
254605a610SMauro Carvalho Chehabof valid arguments for card.
264605a610SMauro Carvalho Chehab
27577a7ad3SMauro Carvalho ChehabIf your card isn't listed there, you might check the source code for
28577a7ad3SMauro Carvalho Chehabnew entries which are not listed yet.  If there isn't one for your
29577a7ad3SMauro Carvalho Chehabcard, you can check if one of the existing entries does work for you
30577a7ad3SMauro Carvalho Chehab(just trial and error...).
31577a7ad3SMauro Carvalho Chehab
32577a7ad3SMauro Carvalho ChehabSome boards have an extra processor for sound to do stereo decoding
33577a7ad3SMauro Carvalho Chehaband other nice features.  The msp34xx chips are used by Hauppauge for
34577a7ad3SMauro Carvalho Chehabexample.  If your board has one, you might have to load a helper
354605a610SMauro Carvalho Chehabmodule like ``msp3400`` to make sound work.  If there isn't one for the
36577a7ad3SMauro Carvalho Chehabchip used on your board:  Bad luck.  Start writing a new one.  Well,
37577a7ad3SMauro Carvalho Chehabyou might want to check the video4linux mailing list archive first...
38577a7ad3SMauro Carvalho Chehab
39577a7ad3SMauro Carvalho ChehabOf course you need a correctly installed soundcard unless you have the
40577a7ad3SMauro Carvalho Chehabspeakers connected directly to the grabber board.  Hint: check the
41577a7ad3SMauro Carvalho Chehabmixer settings too.  ALSA for example has everything muted by default.
42577a7ad3SMauro Carvalho Chehab
43577a7ad3SMauro Carvalho Chehab
44577a7ad3SMauro Carvalho ChehabHow sound works in detail
45577a7ad3SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~~~~~~~
46577a7ad3SMauro Carvalho Chehab
47577a7ad3SMauro Carvalho ChehabStill doesn't work?  Looks like some driver hacking is required.
48577a7ad3SMauro Carvalho ChehabBelow is a do-it-yourself description for you.
49577a7ad3SMauro Carvalho Chehab
50577a7ad3SMauro Carvalho ChehabThe bt8xx chips have 32 general purpose pins, and registers to control
51577a7ad3SMauro Carvalho Chehabthese pins.  One register is the output enable register
524605a610SMauro Carvalho Chehab(``BT848_GPIO_OUT_EN``), it says which pins are actively driven by the
534605a610SMauro Carvalho Chehabbt848 chip.  Another one is the data register (``BT848_GPIO_DATA``), where
54577a7ad3SMauro Carvalho Chehabyou can get/set the status if these pins.  They can be used for input
55577a7ad3SMauro Carvalho Chehaband output.
56577a7ad3SMauro Carvalho Chehab
57577a7ad3SMauro Carvalho ChehabMost grabber board vendors use these pins to control an external chip
58577a7ad3SMauro Carvalho Chehabwhich does the sound routing.  But every board is a little different.
59577a7ad3SMauro Carvalho ChehabThese pins are also used by some companies to drive remote control
60577a7ad3SMauro Carvalho Chehabreceiver chips.  Some boards use the i2c bus instead of the gpio pins
61577a7ad3SMauro Carvalho Chehabto connect the mux chip.
62577a7ad3SMauro Carvalho Chehab
63577a7ad3SMauro Carvalho ChehabAs mentioned above, there is a array which holds the required
64577a7ad3SMauro Carvalho Chehabinformation for each known board.  You basically have to create a new
654605a610SMauro Carvalho Chehabline for your board.  The important fields are these two::
66577a7ad3SMauro Carvalho Chehab
67577a7ad3SMauro Carvalho Chehab  struct tvcard
68577a7ad3SMauro Carvalho Chehab  {
69577a7ad3SMauro Carvalho Chehab	[ ... ]
70577a7ad3SMauro Carvalho Chehab	u32 gpiomask;
71577a7ad3SMauro Carvalho Chehab	u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
72577a7ad3SMauro Carvalho Chehab  };
73577a7ad3SMauro Carvalho Chehab
74577a7ad3SMauro Carvalho Chehabgpiomask specifies which pins are used to control the audio mux chip.
75577a7ad3SMauro Carvalho ChehabThe corresponding bits in the output enable register
764605a610SMauro Carvalho Chehab(``BT848_GPIO_OUT_EN``) will be set as these pins must be driven by the
77577a7ad3SMauro Carvalho Chehabbt848 chip.
78577a7ad3SMauro Carvalho Chehab
794605a610SMauro Carvalho ChehabThe ``audiomux[]`` array holds the data values for the different inputs
80577a7ad3SMauro Carvalho Chehab(i.e. which pins must be high/low for tuner/mute/...).  This will be
814605a610SMauro Carvalho Chehabwritten to the data register (``BT848_GPIO_DATA``) to switch the audio
82577a7ad3SMauro Carvalho Chehabmux.
83577a7ad3SMauro Carvalho Chehab
84577a7ad3SMauro Carvalho Chehab
85577a7ad3SMauro Carvalho ChehabWhat you have to do is figure out the correct values for gpiomask and
86577a7ad3SMauro Carvalho Chehabthe audiomux array.  If you have Windows and the drivers four your
87577a7ad3SMauro Carvalho Chehabcard installed, you might to check out if you can read these registers
88577a7ad3SMauro Carvalho Chehabvalues used by the windows driver.  A tool to do this is available
894605a610SMauro Carvalho Chehabfrom http://btwincap.sourceforge.net/download.html.
90577a7ad3SMauro Carvalho Chehab
914605a610SMauro Carvalho ChehabYou might also dig around in the ``*.ini`` files of the Windows applications.
92577a7ad3SMauro Carvalho ChehabYou can have a look at the board to see which of the gpio pins are
93577a7ad3SMauro Carvalho Chehabconnected at all and then start trial-and-error ...
94577a7ad3SMauro Carvalho Chehab
95577a7ad3SMauro Carvalho Chehab
96577a7ad3SMauro Carvalho ChehabStarting with release 0.7.41 bttv has a number of insmod options to
97577a7ad3SMauro Carvalho Chehabmake the gpio debugging easier:
98577a7ad3SMauro Carvalho Chehab
994605a610SMauro Carvalho Chehab	=================	==============================================
100577a7ad3SMauro Carvalho Chehab	bttv_gpio=0/1		enable/disable gpio debug messages
101577a7ad3SMauro Carvalho Chehab	gpiomask=n		set the gpiomask value
102577a7ad3SMauro Carvalho Chehab	audiomux=i,j,...	set the values of the audiomux array
103577a7ad3SMauro Carvalho Chehab	audioall=a		set the values of the audiomux array (one
104577a7ad3SMauro Carvalho Chehab				value for all array elements, useful to check
105577a7ad3SMauro Carvalho Chehab				out which effect the particular value has).
1064605a610SMauro Carvalho Chehab	=================	==============================================
107577a7ad3SMauro Carvalho Chehab
1084605a610SMauro Carvalho ChehabThe messages printed with ``bttv_gpio=1`` look like this::
109577a7ad3SMauro Carvalho Chehab
110577a7ad3SMauro Carvalho Chehab	bttv0: gpio: en=00000027, out=00000024 in=00ffffd8 [audio: off]
111577a7ad3SMauro Carvalho Chehab
112577a7ad3SMauro Carvalho Chehab	en  =	output _en_able register (BT848_GPIO_OUT_EN)
113577a7ad3SMauro Carvalho Chehab	out =	_out_put bits of the data register (BT848_GPIO_DATA),
114577a7ad3SMauro Carvalho Chehab		i.e. BT848_GPIO_DATA & BT848_GPIO_OUT_EN
115577a7ad3SMauro Carvalho Chehab	in  = 	_in_put bits of the data register,
116577a7ad3SMauro Carvalho Chehab		i.e. BT848_GPIO_DATA & ~BT848_GPIO_OUT_EN
117