요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
The bttv driver
===============
bttv and sound mini howto
-------------------------
There are a lot of different bt848/849/878/879 based boards available.
Making video work often is not a big deal, because this is handled
completely by the bt8xx chip, which is common on all boards. But
sound is handled in slightly different ways on each board.
To handle the grabber boards correctly, there is a array tvcards[] in
bttv-cards.c, which holds the information required for each board.
Sound will work only, if the correct entry is used (for video it often
makes no difference). The bttv driver prints a line to the kernel
log, telling which card type is used. Like this one::
bttv0: model: BT848(Hauppauge old) [autodetected]
You should verify this is correct. If it isn't, you have to pass the
correct board type as insmod argument, ``insmod bttv card=2`` for
example. The file Documentation/admin-guide/media/bttv-cardlist.rst has a list
of valid arguments for card.
If your card isn't listed there, you might check the source code for
new entries which are not listed yet. If there isn't one for your
card, you can check if one of the existing entries does work for you
(just trial and error...).
Some boards have an extra processor for sound to do stereo decoding
and other nice features. The msp34xx chips are used by Hauppauge for
example. If your board has one, you might have to load a helper
module like ``msp3400`` to make sound work. If there isn't one for the
chip used on your board: Bad luck. Start writing a new one. Well,
you might want to check the video4linux mailing list archive first...
Of course you need a correctly installed soundcard unless you have the
speakers connected directly to the grabber board. Hint: check the
mixer settings too. ALSA for example has everything muted by default.
How sound works in detail
~~~~~~~~~~~~~~~~~~~~~~~~~
Still doesn't work? Looks like some driver hacking is required.
Below is a do-it-yourself description for you.
The bt8xx chips have 32 general purpose pins, and registers to control
these pins. One register is the output enable register
(``BT848_GPIO_OUT_EN``), it says which pins are actively driven by the
bt848 chip. Another one is the data register (``BT848_GPIO_DATA``), where
you can get/set the status if these pins. They can be used for input
and output.
Most grabber board vendors use these pins to control an external chip
which does the sound routing. But every board is a little different.
These pins are also used by some companies to drive remote control
receiver chips. Some boards use the i2c bus instead of the gpio pins
to connect the mux chip.
As mentioned above, there is a array which holds the required
information for each known board. You basically have to create a new
line for your board. The important fields are these two::
struct tvcard
{
[ ... ]
u32 gpiomask;
u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
};
gpiomask specifies which pins are used to control the audio mux chip.
The corresponding bits in the output enable register
(``BT848_GPIO_OUT_EN``) will be set as these pins must be driven by the
bt848 chip.
The ``audiomux[]`` array holds the data values for the different inputs
(i.e. which pins must be high/low for tuner/mute/...). This will be
written to the data register (``BT848_GPIO_DATA``) to switch the audio
mux.
What you have to do is figure out the correct values for gpiomask and
the audiomux array. If you have Windows and the drivers four your
card installed, you might to check out if you can read these registers
values used by the windows driver. A tool to do this is available
from http://btwincap.sourceforge.net/download.html.
You might also dig around in the ``*.ini`` files of the Windows applications.
You can have a look at the board to see which of the gpio pins are
connected at all and then start trial-and-error ...
Starting with release 0.7.41 bttv has a number of insmod options to
make the gpio debugging easier:
================= ==============================================
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).
================= ==============================================
The messages printed with ``bttv_gpio=1`` look like this::
bttv0: gpio: en=00000027, out=00000024 in=00ffffd8 [audio: off]
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
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
bttv driver와 sound mini howto
1-8이 문서는 GPL-2.0 SPDX license를 사용하는 `The bttv driver` 문서이며, bttv와 sound 설정을 위한 mini howto를 제공합니다.
Video보다 board별 차이가 큰 sound routing에 초점을 둡니다.
Board별 sound와 tvcards[] 선택
9-25bt848/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`에 있습니다.
Sound routing 문제를 해결하기 위한 첫 점검 순서입니다.
새 board, sound processor와 soundcard
26-43Card가 목록에 없다면 아직 문서에 반영되지 않은 새 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합니다.
Board entry 이후 helper chip과 host soundcard를 차례로 확인합니다.
Sound routing GPIO hardware
44-61Sound가 계속 동작하지 않으면 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도 있습니다.
Board 설계에 따라 GPIO 또는 I2C가 external mux를 제어합니다.
Enable mask와 data bit를 구분합니다.
struct tvcard의 gpiomask와 audiomux
62-83Known 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`에 씁니다.
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를 시작할 수도 있습니다.
가능한 정보 source를 안전한 순서로 활용합니다.
GPIO debugging insmod option
96-107bttv 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).
================= ==============================================
원문의 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 상태를 해석할 수 있습니다.
한 data register에서 output과 input bit를 분리합니다.
요약과 해설
bttv-devel.rst:1-116bttv 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을 역추적하고 검증할 수 있습니다.