24
Aug 21, 2014 © 2014 SAMSUNG Electronics Co. Not to be used for commercial purpose without getting permission All information, opinions and ideas herein are exclusively the author's own opinion Open Source Group – Silicon Valley Samsung Research Brazil Building Digital TV support on Linux Mauro Carvalho Chehab Linux Kernel Expert Samsung Open Source Group

Building Digital TV support on Linux - Linux Foundation

  • Upload
    vodien

  • View
    222

  • Download
    7

Embed Size (px)

Citation preview

Page 1: Building Digital TV support on Linux - Linux Foundation

Aug 21, 2014

© 2014 SAMSUNG Electronics Co.

Not to be used for commercial purpose without getting permissionAll information, opinions and ideas herein are exclusively the author's own opinionOpen Source Group – Silicon Valley

Samsung Research Brazil

Building Digital TV support on Linux

Mauro Carvalho ChehabLinux Kernel Expert

Samsung Open Source Group

Page 2: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Biography● Maintainer of the media and EDAC subystems at the Linux

Kernel

● Works at Samsung Research Brazil as R&D Director on Open Source, being part of the Samsung's Open Source Group.

● Worked during 5 years at Red Hat, where, besides maintaining the upstream Kernel subsystems, were also responsible for maintaining several subsystems at RHEL's Kernel;

● Developed several device drivers for video stream capture and analog/digital TV reception at the Linux Kernel, including most of the drivers for the Brazilian digital TV standard (SBTVD / ISDB-T).

Page 3: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Digital TV challenges● Major standards:

– ATSC - Advanced Television System Committee● Defined in United States

– DVB - Digital Video Broadcasting● Defined in Europe

– ISDB – Integrated Services Digital Broadcasting Terrestrial

● Defined in Japan– DTMB - Digital Terrestrial Multimedia Broadcast

● Defined in China

Page 4: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Digital TV challenges● Digital TV variants:

– Terrestrial (air) standards are used by air broadcasts: ATSC, DVB-T, DVB-T2, ISDB-T, DMB;

– Cable standards are used by cable operators: DVB-C, DVB-C2, ClearQAM (DVB-C Annex B), ISDB-C;

– Satellite standards are used by Satellite operators: DVB-S, DVB-S2, ISDB-S.

Page 5: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Digital TV Terrestrial Standards

Source: http://en.wikipedia.org/wiki/File:Digital_broadcast_standards.svg

Updated in November, 2013Note: DVB-T2 is gradually replacing DVB-T

Page 6: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

8 Mhz

TV Digital standards

Video Elem. Stream

Audio Elem. Stream

Modulation

Transport

Channel1.7 Mhz 5 Mhz 6 Mhz 7 Mhz 10 Mhz

VSB COFDM COFDM-BSTQAM QPSK

MPEG2 – Transport Stream

MPEG2 MPEG4

280i LD 480iSDTV 720pEDTV 1080iHDTV

MPEG2-BC MPEG2-AAC

DOLBYAC3

MPEG4-AAC

Copyright © 2006-2014 Mauro Carvalho Chehab – GPLv2 licensed

Page 7: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

8 Mhz

TV Digital Linux Mapping

Video Elem. Stream

Audio Elem. Stream

Modulation

Transport

Channel1.7 Mhz 5 Mhz 6 Mhz 7 Mhz 10 Mhz

VSB COFDM COFDM-BSTQAM QPSK

MPEG2 – Transport Stream

MPEG2 MPEG4

280i LD 480iSDTV 720pEDTV 1080iHDTV

MPEG2-BC MPEG2-AAC

DOLBYAC3

MPEG4-AAC

Copyright © 2006-2014 Mauro Carvalho Chehab – GPLv2 licensed

Kernelspace

Userspace

Page 8: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Media device block diagram

TunerFM/TV

Audio decoder

Video decoder

Audio encoder

Button Key/IR input logic

EEPROM

Sensor

Bridge to CPU/Chipset bus

I2C

Bus

Sys

tem

Bus

Frontend

SEC

Transport Stream filter

Conditional Access Module

Video encoder

Radio / Analog TV

Digital TV

PS.: picture is not complete: other blocks may be present,Like audio/video A/D and D/A, HDMI decoder/encoder, etc.

Webcam

PCI,USB,PCIe,...Processing blocks

Smartcard

Page 9: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

●Video4Linux API (version 2)

TunerFM/TV

Audio decoder

Video decoder

Audio encoder

Sensor

Video encoder

Radio / Analog TV

Webcam

● For webcams, video inputs/outputs and radio, video and analog TV

● Extensions for Software Digital Radio added (Drivers in staging as API might change)

● Audio output uses the standard ALSA API

Page 10: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

●Remote Controller / Input APIs

Button Key/IR input logic

● Used for Remote Controllers and Webcam buttons● It is an extension of the standard Linux Input API (evdev)

Page 11: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Linux Kernel DTV APIs

● Despite being called Linux DVB API, it covers all standards

● Each frontend, CA and Demux device on a DTV card is exported

● The frontend control is complex, as it is standard-dependent and Country dependent;

● Satellite Equipment Control (SEC) setup is also complex:

– Contorls LNBf and smart devices (DiSEqC);

Frontend

SEC

Transport Stream filter

Conditional Access Module

Digital TV

DVB Frontend API

DVB CA API

DVB Demux API Smartcard

Frontend

SEC

Transport Stream filter

Conditional Access Module

Digital TV

DVB Frontend API

DVB CA API

DVB Demux API

Page 12: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Media Controller API

● To control complex devices with configurable pipelines

● Currently, used only on embedded devices and on UVC (USB Video Class)

● Subdev API

– To control each single logical element on such complex devices

Page 13: Building Digital TV support on Linux - Linux Foundation

13

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Summary of Media Kernel APIs● APIs described at: http://linuxtv.org/downloads/v4l-dvb-apis/

– Video4Linux API (version 2)● For webcams, video inputs/outputs and radio, video and analog

TV– Linux DVB API (version 5)

● For digital TV inputs– Remote Controller / Input evdev APIs

● For Remote Controllers– Media Controller and Subdev APIs

● To control complex devices with configurable pipelines● The Advanced Linux Sound Architecture (ALSA)

– For audio inputs, outputs, mixers (and sequencers)● Standard input evdev API

– For webcam/grabber buttons and remote controllers

Page 14: Building Digital TV support on Linux - Linux Foundation

14

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

DVB API history● DVBv1: the old Nokia API (1998-1999?)

– Developed/Implemented for a Nokia project developed by Convergence

● DVBv2: major re-factoring step (2000-2002?)

– Stabilized the API for DVB-T/C/S; ATSC

● DVBv3: namespace cleanups

– First version on Kernel – Jun/2003 – for Kernel v2.5.74

● DVBv4: An abandoned WIP project (2004-2005)

– Meant to add all features for STB, but never finished.

● DVBv5: Current version

– Committed in Kernel 2.6.28 (2008).

– Added full multi-standard support. Frontend-only changes.

– New standards generally support DVBv3 legacy calls, with drawbacks

Page 15: Building Digital TV support on Linux - Linux Foundation

15

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

CHANNELTRANSPONDER

MPEG TS example

MPEG TS

Service 1

Video

Audio 1

Audio 2

Service 2

Video

Audio 1

Audio 2

PID 100

PID 101

PID 102

PID 200

PID 231

PID 554

Virtual Channel 17.1

Virtual Channel 17.2

Other PIDs

Page 16: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Userspace library: libdvbv5● Abstracts the difference between DVBv3 and DVBv5;

● Written from scratch to fully support DVBv5;

● Provide a standard way to work with all DVB standards;

● Offers functions to discover the TV streams (“channels”) that are present inside a transport stream;

● Offers functions to read/write both legacy data formats used by DVBv3 applications and to read/write data compatible with DVBv5.

● It is new: the API just stabilized in April, 2014.

– Currently, used by DVBv5 utils and by some other tools;

– New projects should start using it.

Page 17: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

DVBv5 utils and libdvbv5● DVBv5 utils:

– Uses the libdvbv5 as basis for scan/zap and read/write channel files;

– It consists of 4 tools:

● Both DVBv5 utils and libdvbv5 are packaged together with v4l-utils:

– http://git.linuxtv.org/cgit.cgi/v4l-utils.git/

● The dynamic library is released on v4l-utils version 1.2 (Jun, 28 2014)

dvbv5-scan Scans the channel transponders and gets the services available there

dvbv5-zap Locks into a channel (zap), allowing other applications to get the stream at the dvr devices or to monitor the stream

dvb-fe-tool Lists frontend properties and allow to manually set the DVB frontend

dvb-format-convert Converts from/to several other formats used by DVBv3 apps

Page 18: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

GUI apps using libdvbv5● Kaffeine has a recent experimental addition of libdvbv5 support:

– It is a KDE media player with support for several types of input, including Digital TV (ATSC, DVB-S, DVB-S2 and DVB-C);

– The experimental patches also adds support for ISDB-T;

– Should not be hard to add support for DVB-T2 and other modern standards;

– Need more testing and bug fixes;

– Located at: http://git.linuxtv.org/cgit.cgi/mchehab/kaffeine.git/● Tvdaemon:

– It is a TV streaming server;

– It is a fork/rewrite of tvheadend;

– Located at: https://github.com/neolynx/tvdaemon

Page 19: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

DVB-C Scan Example$ dvbv5-scan ~/dvbc-teste -I channel

Scanning frequency #1 573000000

Lock (0x1f) Quality= Good Signal= 100.00% C/N= -13.80dB UCB= 0 postBER= 3.14x10^-3 PER= 0

Service SBT, provider (null): digital television

Service Globo, provider Globo: digital television

Service Record, provider (null): digital television

Service Band, provider (null): digital television

...

Service Trilhas Sonoras, provider (null): digital radio

New transponder/channel found: #2: 579000000

...

New transponder/channel found: #39: 507000000

Page 20: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Service zap example$ dvbv5-zap -c dvb_channel.conf "trilhas sonoras" -r

using demux '/dev/dvb/adapter0/demux0'

reading channels from file 'dvb_channel.conf'

service has pid type 05: 204

tuning to 573000000 Hz

audio pid 104

dvb_set_pesfilter 104

Lock (0x1f) Quality= Good Signal= 100.00% C/N= -13.80dB UCB= 70 postBER= 3.14x10^-3 PER= 0

DVR interface '/dev/dvb/adapter0/dvr0' can now be opened

Page 21: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

DVB DVR device play$ mplayer -cache 800 /dev/dvb/adapter0/dvr0

MPlayer SVN-r37077-4.8.2 (C) 2000-2014 MPlayer Team

TS file format detected.

NO VIDEO! AUDIO MPA(pid=104) NO SUBS (yet)! PROGRAM N. 0

==================================================================

Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III

AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)

Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)

==================================================================

AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)

Video: no video

Starting playback...

Page 22: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

DVB transponder traffic monitor$ dvbv5-zap -c dvb_channel.conf 573000000 -m

using demux '/dev/dvb/adapter0/demux0'

reading channels from file 'dvb_channel.conf'

service has pid type 05: 204

tuning to 573000000 Hz

Lock (0x1f) Quality= Good Signal= 100.00% C/N= -13.90dB UCB= 384 postBER= 96.8x10^-6 PER= 0

dvb_set_pesfilter to 0x2000

PID FREQ SPEED TOTAL

0000 9.88 p/s 14.5 Kbps 1 KB

0001 1.98 p/s 2.9 Kbps 376 B

0010 18.77 p/s 27.6 Kbps 3 KB

0011 48.42 p/s 71.1 Kbps 8 KB

0012 1455.53 p/s 2137.8 Kbps 270 KB

...

1fff 1033.60 p/s 1518.1 Kbps 192 KB

TOT 25296.44 p/s 37154.2 Kbps 4700 KB

Page 23: Building Digital TV support on Linux - Linux Foundation

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

How to contribute● Main discussions and patches related to both Kernel drivers and

libdvbv5 happen via mailing lists:

[email protected]

● How to get and test the latest drivers:

– See http://git.linuxtv.org/media_build.git

● Upstream development tree:

– http://git.linuxtv.org/media_tree.git

● DVBv5 tools and libdvbv5:

– http://git.linuxtv.org/v4l-utils.git

● Wiki pages: http://linuxtv.org/wiki/

● IRC channel: irc.freenode.net

– channels #v4l and #linuxtv

– Can be assessed via http://webchat.freenode.net/

Page 24: Building Digital TV support on Linux - Linux Foundation

24

Thank you.

© 2014 SAMSUNG Electronics Co.Open Source Group – Silicon ValleySamsung Research Brazil

Questions?