Documentation/driver-api/media/drivers/bttv-devel.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

The bttv driver

bt848/849/878/879 board의 card type, helper sound chip과 GPIO audio mux 값을 식별·debug하는 mini howto입니다.

Source pathDocumentation/driver-api/media/drivers/bttv-devel.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

bttv-devel.rst:1-116

bttv video path는 공통 bt8xx chip 덕분에 비교적 일관되지만 sound routing은 board-specific입니다. 먼저 kernel log의 card model과 `tvcards[]` entry를 확인하고, 필요한 sound helper module·soundcard mixer를 점검해야 합니다.

새 board 지원에는 `gpiomask`로 output pin을 정하고 입력별 `audiomux[]` 값을 찾아야 합니다. Debug option과 `BT848_GPIO_DATA` bit 분리를 이용하면 board wiring을 역추적하고 검증할 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

bttv driver와 sound mini howto

1-8

이 문서는 GPL-2.0 SPDX license를 사용하는 `The bttv driver` 문서이며, bttv와 sound 설정을 위한 mini howto를 제공합니다.

bttv mini howto 범위
항목범위
Driverbttv
Chip familybt848/849/878/879
주제Board detection, sound helper, GPIO audio mux debugging
LicenseGPL-2.0

Video보다 board별 차이가 큰 sound routing에 초점을 둡니다.

Board별 sound와 tvcards[] 선택

9-25

bt848/849/878/879 기반 board는 매우 다양합니다. Video는 모든 board에 공통인 bt8xx chip이 전부 처리하므로 대체로 쉽게 동작하지만 sound 처리 방식은 board마다 조금씩 다릅니다.

Grabber board를 올바르게 처리하기 위해 `bttv-cards.c`의 `tvcards[]` array가 각 board에 필요한 정보를 보관합니다. Video는 다른 entry로도 동작할 수 있지만 sound는 정확한 entry를 선택해야 합니다.

bttv driver는 사용 중인 card type을 kernel log에 다음처럼 출력합니다.

bttv0: model: BT848(Hauppauge old) [autodetected]

이 식별 결과가 맞는지 확인해야 합니다. 틀렸다면 `insmod bttv card=2`처럼 올바른 board type을 insmod argument로 전달합니다. Valid `card` argument 목록은 `Documentation/admin-guide/media/bttv-cardlist.rst`에 있습니다.

bttv board type 확인
bttv module loadKernel log의 model line 확인실제 board와 일치?예: 해당 tvcards[] entry 사용아니오: bttv-cardlist.rst에서 card id 확인insmod bttv card=NSound 재검증

Sound routing 문제를 해결하기 위한 첫 점검 순서입니다.

새 board, sound processor와 soundcard

26-43

Card가 목록에 없다면 아직 문서에 반영되지 않은 새 source entry가 있는지 먼저 확인합니다. 없다면 기존 entry를 trial-and-error로 시험할 수 있습니다.

일부 board에는 stereo decoding 등의 기능을 위한 별도 sound processor가 있습니다. 예를 들어 Hauppauge는 `msp34xx` chip을 사용합니다. 이런 chip이 있으면 sound를 위해 `msp3400` 같은 helper module을 load해야 할 수 있습니다.

사용 중인 chip의 helper가 없다면 새 module을 작성해야 하지만 먼저 video4linux mailing-list archive를 확인하는 편이 좋습니다.

Speaker를 grabber board에 직접 연결하지 않았다면 정상 설치된 soundcard도 필요합니다. Mixer 설정도 확인해야 하며 ALSA는 기본적으로 모든 channel을 mute합니다.

Sound failure 진단
정확한 tvcards[] entryBoard에 msp34xx 등 sound processor 존재?예: msp3400 helper module loadHelper 없음: mailing list·driver 구현 확인Speaker가 grabber에 직접 연결?아니오: host soundcard 설치 확인ALSA mixer mute 해제

Board entry 이후 helper chip과 host soundcard를 차례로 확인합니다.

Sound routing GPIO hardware

44-61

Sound가 계속 동작하지 않으면 driver hacking이 필요할 수 있습니다. bt8xx chip에는 32개 general-purpose pin과 이를 제어하는 register가 있습니다.

Output enable register `BT848_GPIO_OUT_EN`은 bt848 chip이 능동적으로 drive할 pin을 정합니다. Data register `BT848_GPIO_DATA`에서는 pin status를 읽거나 설정할 수 있어 input과 output 모두에 사용합니다.

대부분 grabber board vendor는 이 pin으로 sound routing을 담당하는 external chip을 제어하지만 wiring은 board마다 다릅니다. 일부는 remote-control receiver chip을 구동하는 데도 GPIO를 사용하고, audio mux chip을 GPIO 대신 I2C bus로 연결하는 board도 있습니다.

bt8xx audio routing path
bt8xx32 GPIO pinsBT848_GPIO_OUT_EN + BT848_GPIO_DATAExternal audio mux 또는 remote-control receiver대안: I2C bus로 audio mux 연결Tuner·radio·external·internal·mute·stereo routing

Board 설계에 따라 GPIO 또는 I2C가 external mux를 제어합니다.

GPIO register 역할
Register역할
BT848_GPIO_OUT_ENChip이 drive할 output pin 선택
BT848_GPIO_DATAPin high/low read·write
GPIO pin count32
DirectionInput과 output 모두 가능

Enable mask와 data bit를 구분합니다.

struct tvcard의 gpiomask와 audiomux

62-83

Known board별 정보를 담는 array에 새 board line을 추가해야 하며 중요한 field는 다음 둘입니다.

struct tvcard
{
      [ ... ]
      u32 gpiomask;
      u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
};

`gpiomask`는 audio mux chip을 제어하는 pin을 지정합니다. 이 pin을 bt848이 drive해야 하므로 대응 bit가 `BT848_GPIO_OUT_EN`에 설정됩니다.

`audiomux[]`는 tuner, radio, external, internal, mute, stereo input 각각에서 어떤 pin을 high 또는 low로 만들지 나타내는 data value를 보관합니다. Audio mux를 전환할 때 이 값을 `BT848_GPIO_DATA`에 씁니다.

tvcard audio field
Field크기·순서사용처
gpiomasku32 bit maskBT848_GPIO_OUT_EN에 set
audiomux[0]TunerBT848_GPIO_DATA
audiomux[1]RadioBT848_GPIO_DATA
audiomux[2]ExternalBT848_GPIO_DATA
audiomux[3]InternalBT848_GPIO_DATA
audiomux[4]MuteBT848_GPIO_DATA
audiomux[5]StereoBT848_GPIO_DATA

Board entry가 GPIO direction과 mux value를 정의합니다.

Board별 GPIO value 찾기

84-95

실제 작업은 올바른 `gpiomask`와 `audiomux` array 값을 알아내는 것입니다. Windows와 해당 card driver가 설치되어 있다면 Windows driver가 쓰는 register 값을 읽어 볼 수 있고, 이를 위한 tool은 `http://btwincap.sourceforge.net/download.html`에서 제공합니다.

Windows application의 `*.ini` file을 살펴보는 방법도 있습니다. Board를 직접 보고 실제로 연결된 GPIO pin을 확인한 뒤 trial-and-error를 시작할 수도 있습니다.

gpiomask·audiomux reverse engineering
정확한 board model 확인Windows driver register capture*.ini 설정 검색PCB에서 연결 GPIO 추적Candidate gpiomask 설정입력별 audiomux 값 시험Sound routing 결과 기록tvcards[] entry 확정

가능한 정보 source를 안전한 순서로 활용합니다.

GPIO debugging insmod option

96-107

bttv 0.7.41부터 GPIO debugging을 쉽게 하는 여러 insmod option을 제공합니다. `bttv_gpio=0/1`은 debug message를 끄거나 켜고, `gpiomask=n`은 mask를, `audiomux=i,j,...`는 array element별 값을 설정합니다.

`audioall=a`는 모든 `audiomux` element를 같은 값으로 설정하여 특정 값의 효과를 확인하는 데 유용합니다.

=================        ==============================================
bttv_gpio=0/1                enable/disable gpio debug messages
gpiomask=n                set the gpiomask value
audiomux=i,j,...        set the values of the audiomux array
audioall=a                set the values of the audiomux array (one
                        value for all array elements, useful to check
                        out which effect the particular value has).
=================        ==============================================
bttv GPIO debug option
Option기능
bttv_gpio=0/1GPIO debug message disable/enable
gpiomask=ngpiomask 값 설정
audiomux=i,j,...입력별 audiomux array 설정
audioall=a모든 audiomux element에 같은 값 설정

원문의 option 표를 구조화했습니다.

GPIO debug log 해석

108-116

`bttv_gpio=1`일 때 출력되는 message 예시는 다음과 같습니다.

bttv0: gpio: en=00000027, out=00000024 in=00ffffd8 [audio: off]

각 field 계산식은 다음과 같습니다.

en  =        output _en_able register (BT848_GPIO_OUT_EN)
out =        _out_put bits of the data register (BT848_GPIO_DATA),
        i.e. BT848_GPIO_DATA & BT848_GPIO_OUT_EN
in  =         _in_put bits of the data register,
        i.e. BT848_GPIO_DATA & ~BT848_GPIO_OUT_EN

`en`은 `BT848_GPIO_OUT_EN`, `out`은 `BT848_GPIO_DATA & BT848_GPIO_OUT_EN`, `in`은 `BT848_GPIO_DATA & ~BT848_GPIO_OUT_EN`입니다. 따라서 enable mask로 output과 input bit를 분리해 현재 audio routing 상태를 해석할 수 있습니다.

GPIO log field decoding
Field의미
enBT848_GPIO_OUT_ENOutput-enable mask
outBT848_GPIO_DATA & BT848_GPIO_OUT_ENChip이 drive하는 output bit
inBT848_GPIO_DATA & ~BT848_GPIO_OUT_EN외부에서 읽는 input bit
audioDecoded routing state예: off

한 data register에서 output과 input bit를 분리합니다.