Bengt Mårtensson > Private Site
 
Font size:      

Analog and Digital Video- and Audio-outputs on the dBox with Neutrino

Revision history

DateDescription
2006-01-05 Initial version.
2006-01-17 Added digital audio. Added volume control (analog and digital). Some more information on the Philips. Reference to controldc. Moved "Connectors" as the first subsection of "Hardware". Misc. small improvements.
2006-01-22 Added reference to modding article. No analog output by DD.
2006-02-22 Added comments on muting.
2006-03-29 Delete Sagem bug: it has been fixed.
2006-06-05 Updated for my recent CVS check-ins, in particular extended syntax for scart.conf. Merged in the avsstuff article, which is now obsolete.
2006-06-14 Wrote the Appendix. Moved the fblk-table to there.
2006-06-17 Small fixes to the tables in the appendix, in particular, the case a2 = 4.
2006-06-25 Extended and corrected info on the Philips audio/video switching.
2006-07-01 Still more on the Philips (thx Pleymo): replaced a1 and a2.

Introduction

In this article, the analog audio and video outputs, their possibilities and limitations are discussed. From the software side, only Neutrino will be considered.

An understanding of the Scart connector is essential. For information, including pin-out, on the Scart connector, see Wikipedia. For the sequel, we remark that the FBLK-Signal (pin 16) ("Fast BLanKing") can be considered as having the semantics: "when active, an RGB signal is available and should be used".

For a general overview of the dBox hardware, we refer to this block diagram.

Tuxbox is a hobby project!

It should always be kept in mind that the present project is a hobby project. This means, among other things, that tools get written for two purposes: For exploring and debugging, and for presenting actual functionality to the user. In a professional project, the exploring and debugging parts are generally never distributed to customers, or disabled (cf. the debug mode of the dBox). In a hobby project, based on open source, things are different: if something is not finished, or works only partially, it is, at most, "hidden" behind an option like ENABLE_EXPERIMENTAL_FEATURES. The goal is more often to take the hardware to the limit, rather than just releasing perfectly working, well documented and easily understandable features to the customers. Please keep this in mind when griping!

For example, the dBox was almost surely not intended to generate YUV video -- then it would have had RCA-outputs. It turns out that the video encoder used (see below) is perfectly able to generate YUV as well as the formats Betanova needed. If a low-cost-version, not containing YUV-capacities, were available, it would probably have been used instead.

Another issue here is configuration options and -files. Often, in particular when, as is here the case, writing software for hardware for which no complete documentation is available, the software author writes his software as a qualified guesswork. To guard for guessings or design decisions that turned out to be wrong, configuration options are thrown in. Although better than the alternative, this is not a good thing: It basically means that the programmer is delegating the work to the user. Getting it right is better than making it configurable!

Terminology

YUV
The signal format we refer to as "YUV" should properly be called "YCbCr". Since the latter is awkward both to write and to pronounce, and since Neutrino uses the former, we will say "YUV" (which strictly speaking means something different).
dBox
refers to a dBox2 from Nokia, Philips, or Sagem, in either cable or satellite version.

The dBox can...

  • Generate the following video formats on the TV-Scart output:
    • YUV (+ CVBS)
    • YUV (+ VBS)
    • RGB (+ CVBS)
    • SVideo
    • CVBS
  • Generate the following video formats on the VCR-Scart:
    • CVBS
    • SVideo
  • Pass any video format (using up to 4 signals (RGB, YUV, SVideo, CVBS,...)) (+ audio) from the VCR-Scart to the TV-Scart. The Sagem can do this even in deep standby.
  • Pass CVBS-Video and analog sound from the TV-Scart to the VCR-Scart and RCA audio outputs.
  • Generate correct aspect ratio information on pin8 on TV Output
  • Generate correct FBLK signal on pin 16 on the TV-Scart

The dBox can not...

  • Not all video-format combinations can be generated simultaneously. In particular, when generating RGB or YUV, only CVBS and VBS are possible in addition.
  • Generate progressive video.
  • Generate analog output from Dolby digital (AC-3) sound. (Would require decoder, costing license fee.)
  • Digitalize video from the VCR-Scart
  • Make any conversion on the video (or audio) from the VCR-Scart
  • Sagem cannot deliver different audio output on the TV-Scart and the RCA audio outputs.
  • Generate correct aspect ratio information on pin8 on VCR output (at least not on Nokias, hardware is missing)
  • Output digital video in the sense of e.g. IEEE 1394 ("Firewire"). (However, it can, supported by a suitable server, capture digital video to disk files.)
  • Some models (equipped with AViA 500) cannot disable the S/P-Dif output once enabled, see below.
  • Not all analog audio output can be attenuated or muted.

General on volume control

To prepare for the sequel, we give a general discussion of volume control for a signal source (like a DVB receiver). First of all, the term "volume control" is a bit of a misnormer: A signal source is generating an audio signal. This signal is typically sent to an amplifier (or a TV), which amplifies the signal and sends it to loudspeakers. The volume is normally "controlled" from the amplifier by its volume control, which effectively determines the gain of the amplifier. What the signal source can do, is to attenuate the signal. We will use this term for the rest of the article.

Normal usage should therefore be to bypass attenuation, i.e. all "volume controls" in signal sources should be set to maximum. At least theoretically, all usage of attenuation will lead to some quality loss.

It is generally accepted that perceived "loudness" relates logarithmically to sound pressure. This means that a "volume knob" should preferably take the logarithmic dependence into account and invert it, otherwise almost all of the "regulating power" will come at the right end of the scale. A volume control/attenuation with this property is called logarithmic. (Strictly speaking, "exponential" would be more appropriate, since what it does is to invert a logarithmic function...) A volume control not having this property is sometimes called linear, while it maps user input to attenuation linearly.

The Hardware

Connectors

The dBox comes with two SCART connectors, marked "TV'' and "VCR'' respectively. We will subsequently refer to these as "the TV-Scart" and the "VCR-Scart", even if they are connected to something else. Note that they are differently located on different hardware: The Sagem has the TV-Scart on top, and the VCR-Scart on bottom, while it is the other way around on Nokia and Philips.

For our purposes, the TV-Scart has four video-output pins, two audio-output pins, one video-input pin, and two audio input pins. Pin 8 (aspect ratio) and pin 16 (FBLK) are to be considered as outputs. The VCR-Scart has four video-input pins; however one of those (R (or Y), pin 15) can also be an output (necessary for SVideo output signal). There is one (alternatively two, see last sentence) video output pin(s). Finally, there are two audio inputs and two audio outputs. Pin 8 and pin 16 both exclusively work as inputs.

There are also a pair of RCA audio outputs, and an optical Toslink S/P-Dif digital audio output.

The Video Encoder

All dBoxes share the same digital video encoder, a SAA7126H from Philips. Data sheet is available here. It generates analog video signals in RGB, CVBS, SVideo, or YUV format, depending on what commands it has been sent from its driver (source). Most importantly, it generates up to four output signals, so we can immediately conclude that, for example, RGB and SVideo output simultaneously cannot be possible, since it would require 3 (R, G, B) + 2 (Y and C) = 5 signals.

The video encoder can be manipulated from the command line using a nifty little program named saa.

Digital audio

Digital audio is generated by the AViA chip from the DVB stream, which is then feed to the S/P-Dif output directly. For this reason, it is not possible for, e.g., the Neutrino audio player to use it.

The AViA chip can attenuate the volume in the digital domain. It can also mute the signal. This is in Neutrino called ost volume control or digital volume control. It cannot attenuate, or mute, Dolby Digital signals. The current software does not make "logarithmic volume control".

Often, the dBox is connected to an AV-Amplifier using both digital and analog audio connections. If the AV-Amplifier detects a signal on the digital input, this is selected instead of the analog input. Thus, for analog sound to be reproduced, the digital output has be be turned off. Unfortunately, the AViA 500 cannot turn off the S/P-Dif output once activated. Therefore, users of this setup may have to turn their AV-Amplifier manually to analog input.

There is an open bug in the OST-muting, see this Tuxbox Wiki Article, that after a channel zap, "breaks" muting, despite Neutrino claims muting is still on.

The AV-Switch

There are three sources of analog video and audio inside the dBox: From the DVB-receiver (up to four video signals + audio), from the VCR-Scart (to be considered as four signals + audio), and from the TV-Scart (one signal (CVBS) + audio). To select which of these inputs are sent to the different outputs is the task for a component we refer to as the AV-Switch. Here, the different vendors differ considerably: Nokia uses a CXA2092 chip, for which no data sheet is known. (See this however.) (Probably the author of the driver for the chip had a very good connection to SONY?) Sagem uses a CXA2126Q (data sheet here), while Philips uses a STV6412A (data sheet here). For our purposes, the differences between the chips has been conveniently wrapped in the drivers, with the exception of the configuration, see below. Most importantly, however, is that the chip in the Sagem has only two output channels (video as well as audio). This means that the RCA outputs always output the same audio as the TV-Scart, and that some configuration options are accepted, but meaningless on the Sagem. The Nokia has a third video output from the AV-Switch, however, the corresponding pins on the chips are not connected to anything. It is possible to solder appropriate components to the right pins, and thus to achieve a third, independently controllable, video output (CVBS only). For the Nokia, pin 27 on the CXA2092 should be used. (I have done this modification to my Nokia. This is described in this article.)

Analog volume attenuation

The AV-Switch can also attenuate or mute some of its analog audio outputs. In all cases, what can be attenuated, can be muted, and vice versa. Again, here the boxes from the different vendors differ:

Nokia
The Nokia (at least the AViA 500 models) attenuates the TV-Scart, but not the VCR-scart and not the RCA jacks. (It has been claimed that there are AViA-600 based Nokias that does attenuate the RCA jacks, despite the fact that they also uses CXA2092. I do not consider these rumors plausible.)
Sagem
The Sagem attenuates the first audio switch, feeding the TV-Scart and the RCA jacks. The other audio switch, feeding the VCR-scart is not attenuated.
Philips
The Philips, also having "only" two audio-switches, behaves almost identically to the Sagem. The only difference is that the chip (stv6412) would allow the driver to decide whether the RCA jack output is being attenuated or not. The driver author has decided to turn on the attenuation unconditionally.

We mention that controld uses a volume scale from 0 (sound off) to 100 (no attenuation), while the AV-switch uses 63 (sound off) to 0 (no attenuation), the latter roughly corresponding to the attenuation in dB (disposing the minus-sign). The mapping from controld-volume to AV-switch-volume is exponential, to make up a logarithmic volume control.

The Switching matrix

The AV-Switch consists of two or three selectors for audio and video respectively. Each selector (switch) is controlled by a three-bit number (i.e. an integer between 0 and 7), selecting a particular input to send to its output. This input consists of one (CVBS), two (SVideo), or four (RGB/YUV + [C]VBS) signals.

For Sagem, v1 (a1) is the switch selecting the video (audio) to be sent to the TV-Scart (and the RCA audio outputs), while v2 (a2) is selecting video (audio) to be sent to the VCR-Scart. For the Nokia, v1, a1, and v2 are as with the Sagem, however, the audio switch selecting audio to the VCR-Scart is called a3. The audio switch a2 selects audio to the RCA outputs. I do not have access to a Philips box, but this is how I interpret the data sheet of the STV-chip and the code of the STV6412 driver: v1 selects the output to the VCR Scart (like v1 for the others). v2 selects the RGB-source, i.e., the output from the RGB-pins on the TV Scart. Finally, v3 selects the "composite output" (pin 19) on the TV Scart. There are two audio switches, a1 and a2, selecting audio for TV Scart and VCR Scart respectively. The RCA-outputs are feed with the same signal as the TV-Scart. The chip makes it possible to select whether they are volume attenuated or not. Optionally, it is even possible to select between stereo and mono (= just replacing L and right by their average) on the TV- and VCR-Scart, but not on the RCA jacks. These possibilities are presently not used by the driver.

The CXA2126 driver does not recognize the ioctl commands AVSIOSASW3 and AVSIOGASW3 (setting and getting of a3 respectively). The STV6412 driver recognizes them as synonyms (!!) to AVSIOSASW2 and AVSIOGASW2 (setting and getting of a2). (We should preferably change this.)

The semantics of the entries in the routing tables are given in the Appendix.

The FBLK Setting

The FBLK setting in the switch determines how the FBLK output on the TV-Scart (pin 16) is controlled. The semantic of the entry is given in the Appendix. For passing VCR-Scart video input to the TV-Scart, it would be natural to let FBLK follow the VCR-Scart input.

The settings of the AV-Switch can be examined as well as manipulated from the command line with the program switch.

The Software: controld

For our discussion, the dBox operates either in DVB-mode (generating video from DVB transmissions) or Scart-Mode (routing analog video from the VCR-Scart). The task for the high level software is to, according to vendor, the selected operating mode, and the preferred formats for "TV-" and "VCR-Output", to send the appropriate commands to the saa-driver, enabling it to generate suitable signals on its four output lines, and to send the correct routing commands to the AV Switch. For this, the daemon controld is responsible. The neutrino main program sends controld messages, and can provide controld with user configurable parameters.

controld is a daemon program, responding to messages sent to it. There exists messages for setting and getting video format, volume, aspect ratio, etc. A command line program, named controldc, for sending these messages is presented on my patch page. This is roughly speaking a "brother" to switch and saa.

The configuration file scart.conf

The present controld knows 6 cases, depending on vendor (Nokia, Sagem, Philips) and operating mode (DVB, Scart). There is a configuration file, /var/tuxbox/config/scart.conf. In the simplest case, for all the different cases (in the sense above), there is an array of 6 (or optionally 7) numbers, in turn: v1 a1 v2 a2 v3 a3 fblk (their meaning was explained above). These numbers are fed to the respective switching matrices, and, in the case of Scart-Mode, to the FBLK-switch. A scart.conf using this "classic" syntax might look like:

#typ_vcr/dvb: 	v1 a1 v2 a2 v3 a3 (vcr_only: fblk)
nokia_scart: 	3  2  1  0  1  1
nokia_dvb: 	5  1  1  0  1  1
sagem_scart: 	2  1  0  0  0  0
sagem_dvb: 	0  0  0  0  0  0
philips_scart: 	3  3  2  2  3  2 
philips_dvb: 	1  1  1  1  1  1

This is not a complete solution. There are simply too few parameters to be able to cover all cases we have with different TV formats. There is not even a possibility to select the output format of the VCR-Scart: Either you get CVBS or SVideo, in the latter case, when using a CVBS-Connection, the VCR picture turns black-and-white (the "Terminator bug" in the Tuxbox forum). People often could not use the same scart.conf for SVideo as for RGB.

Since 2006-05-27, controld understands an extended syntax and semantic for scart.conf, containing many more parameters, thus (hopefully) enabling one configuration to work in all situations. A scart.conf adhering to the new syntax may look like

#		    v1      a1           v2                   a2       v3   a3 fblk
nokia_scart:     {3 3 3 3 3} 2 {{1 7} {1 7} {1 7} {1 7} {1 7}} 2 {3 3 3 3 3} 2 2
nokia_dvb:       {1 5 4 5 5} 1 {{1 2} {1 7} {1 2} {7 7} {1 7}} 1 {0 0 0 0 0} 1
sagem_scart:     {2 2 2 2 2} 1 {{0 0} {0 0} {0 0} {0 0} {0 0}} 1 {0 0 0 0 0} 1 3
sagem_dvb:       {0 0 1 0 0} 0 {{0 1} {0 7} {0 1} {7 7} {0 7}} 0 {0 0 0 0 0} 0
philips_scart:   {3 3 3 3 3} 3 {{2 2} {2 2} {2 2} {2 2} {2 2}} 2 {3 3 3 3 3} 2 3
philips_dvb:     {1 1 1 1 1} 1 {{1 1} {1 1} {1 1} {1 1} {1 1}} 1 {1 1 1 1 1} 1

For v1, instead of a single number, it is now possible to give an array (using the syntax above) consisting of five numbers, corresponding to the TV-Video signal format (in order) CVBS, RGB, S-Video, YUV+VBS, and YUV+CVBS. Using a single number, like in the old version, is also possible, For v2, there is a double array, the pairs correspond to the TV-Video format as in v1; the first digit in the pair corresponds to VCR-Signal type CVBS, while the second one corresponds to VCR-Signal type S-Video. Also here the old syntax is possible. Finally, v3 has the same syntax as v1.

It should be noted that, due to restrictions in the hardware (discussed above), the VCR-Signal type S-Video is possible only together with TV-Signal format CVBS and S-Video. For this, Neutrino makes it impossible to select non-working combination.

Passing the DVD-Player through

Passing the analog video and audio from the VCR-Scart is really quite straightforward. Both the four video-signals are passed through, as well as the aspect ratio on pin8 and the FBLK signal on pin 16. In particular, the video format on TV-output is the same as on VCR-Input, no matter what TV-Video Format you have selected in the Neutrino menus!

As far as I am aware of, no significant quality reduction result.

... in deep standby?

The Sagem can route VCR-Video through in deep standby. It will not be started by active-going pin 8 on the VCR-Scart. The Nokia can not do this, and will boot on active-going pin8 on the VCR-Scart. The Philips is reported to behave like the Nokia.

Although it is "correct behavior" of the Nokia to boot by active-going pin 8, this can be annoying at times: say that you want to play a CD with your DVD-Player that is connected to the VCR-Scart. Since the front processor is responsible for this behavior, there is nothing we can do to affect it. Of course, cutting pin8 either in the Scart-cable or within the dBox may be acceptable. However, aspect ratio switching will no longer work, which may or may not be acceptable.

In my modding article a hardware modification is described, that will stop the wake-up, but will not cripple the aspect ratio switching: Cut the pin8-connection within the dBox. Connect the connection from the VCR to the base of a simple NPN-transistor (e.g. BC547). Connect its collector to a point that is around 12 V in operation, but 0 V when in deep standby. The emitter of the transistor goes to the remaining part of the pin8-connection, facing the dBox electronics. This makes up an emitter follower. When the collector is 12 V, the emitter follows the base (= pin8 of the SCART), when the collector is 0 V, the emitter is also 0 V.

When Neutrino has booted, it will not go into Scart-mode even if the VCR-Scart is active (pin 8), as opposed to Betanova. A fix for this is presented on my patch-page.

Hooking up for YUV-Output

Although not originally planned by the hardware designers, the dBox is capable of high-quality YUV-output. As should be clear from the above, this requires neither special hardware, funny parameters, or black magic in any form. YUV is delivered on the RGB pins on the SCART: Y on the Green pin (pin11), U (really Cb) on the Blue pin (pin 7), and V (really Cr) on the Red pin (pin 15). Since TVs, Projectors, and AV Receivers inputting YUV almost exclusively use RCA jacks, an appropriate cable and/or adapter is required. It is not hard to solder one (using 75 ohm RG-59 coaxial cable), however, an off-the-shelf "SCART-to-RGB" cable of good quality, like the Clicktronic HC 401-100, will work and is not too expensive. Attach a "Y"-label to the Green plug, "U" (or "Cb") to the Blue plug, and "V" (or "Cr") label to the Red plug if it makes you feel more comfortable :-). In the menu dBox -> Settings -> Video -> VideoOutput select the entry "YUV + CVBS". Ready!

Using the above settings, an ordinary TV will present an acceptable picture, using the CVBS input. Using the CVS version, FBLK will be active, and the TV will (because instructed so by FBLK!) take YUV for RGB, presenting a very greenish picture. Everything looks like "The Matrix"...

Myths

Do I need a special cable/adapter?
No. Rumors exist, that Y "should" be taken from the CVBS-pin (pin 19). There may, at some point in time, have been images around for which this was either necessary or sensible. If it was ever true, it is not true for current CVS sources, or current (legal) images.
I have heard that I must select "YUV + VBS" as video format.
You can select "YUV + VBS" or "YUV + CVBS", it produces the same YUV output. Using "YUV + CVBS" has no disadvantages, using "YUV + VBS" makes (color) video output on the VCR-Scart impossible. This myth seems to be related to the first one.

Open Topics, loose ends

Data Lines

Pins 10 and 12 of the Scart connector are "Data Lines", used for such applications as synchronizing channels on TVs and VCRs. There are a number of commercial names around (AV-Link, EasyLink, ...) but to my knowledge, no open protocols have been proposed for this. According to the circuit diagram for the Nokia, pin 10 of the TV-Scart carries the label "SCART_AV_LINK", and is connected to the CPU. To the best of my knowledge, this has never been put to use, nether by Betanova or from any free software. Pin 12 is not connected.

Random Problems

My Sagem show the following behavior: If selecting RGB or YUV as TV-Format, inputting an RGB Video signal and letting FBLK go active, then somehow the output consists of the DVD-Picture with a DVB-picture superimposed! Workarounds would be to lower FBLK, or selecting another TV Video format (it is not used anyhow during Scart-mode pass-thru).

Feedback wanted

Found any mistakes or holes? Have information I don't have (in particular regarding the Philips dBox)? Feedback of any sort is solicited, either in the forum or to me directly.

Appendix. Semantics of the routing table entries

Signal sources are denoted by DVB, VCR, and TV, the latter being the CVBS signal input (pin 20) on the TV-Scart. The number behind the slash is the number of useful connected lines. Identical entries in the column, e.g. "DVB/2" appears twice in v1/Nokia, do not always generate identical results, since they may correspond to different input pins on the AV-Switch, hooked up through slightly different passive components. By Philips, "AUX" denotes an auxiliary input to the switch, almost surely not useful in an unmodified Philips dBox. A hardware modification may be possible, enabling these to be connected to a video/audio source. By a1 and v2 on the Philips, only two bits are used, instead of three by Nokia and Sagem. Therefore, the values 4 – 7 are "impossible".

v1
ValueNokia (TV)Sagem (TV)Philips (VCR)
0 TV/1; DVB/3 DVB/4 Off
1 DVB/1 DVB/2 DVB/2
2 DVB/2 VCR/4 DVB/2
3 VCR/4 Not used TV/1
4 DVB/2 DVB/2 AUX/1
5 DVB/4 TV/1 Not allowed
6 DVB/3 Not used Not allowed
7 Off Off Not allowed
v2
ValueNokia (VCR)Sagem (VCR)Philips (TV (RGB-Pins))
0 TV/1 DVB/2 Off
1 DVB/1 DVB/2 DVB/3
2 DVB/2 VCR/2 VCR/3
3 VCR/2 Not used Not allowed
4 DVB/2 DVB/2 Impossible
5 Off TV/1 Impossible
6 Off Not used Impossible
7 Off Off Impossible
v3
ValueNokia (only with HW mod.)Philips (TV/CVBS (Pin 19))
0 TV/1 Off
1 Off DVB/1
2 DVB/1 DVB/1
3 VCR/1 VCR/1
4 DVB/1 AUX/1
5 Off Not allowed
6 Off Not allowed
7 Off Not allowed
a1
ValueNokia (TV)Sagem (TV+Aux)Philips (VCR)
0 Off DVB Off
1 DVB VCR DVB
2 VCR Not used TV
3 Off TV AUX
4 Off Off Impossible
a2
ValueNokia (Aux)Sagem (VCR)Philips (TV+Aux)
0 Off DVB Off
1 DVB VCR DVB
2 VCR Not used VCR
3 TV TV AUX
4 Off Off TV
a3
ValueNokia (VCR)
0 Off
1 DVB
2 Off
3 TV
fblk
ValueNokiaSagemPhilips
0Forced inactiveForced inactiveForced inactive
1Forced activeForced activeForced active
2Follows the FBLK of the VCR-Scart inputFollows the FBLK of the DVB video encoderFollows the FBLK of the DVB video encoder
3?Follows the FBLK of the VCR-Scart inputFollows the FBLK of the VCR-Scart input