1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun================================ 4*4882a593Smuzhiyunvidtv: Virtual Digital TV driver 5*4882a593Smuzhiyun================================ 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunAuthor: Daniel W. S. Almeida <dwlsalmeida@gmail.com>, June 2020. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunBackground 10*4882a593Smuzhiyun---------- 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunVidtv is a virtual DVB driver that aims to serve as a reference for driver 13*4882a593Smuzhiyunwriters by serving as a template. It also validates the existing media DVB 14*4882a593SmuzhiyunAPIs, thus helping userspace application writers. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunCurrently, it consists of: 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun- A fake tuner driver, which will report a bad signal quality if the chosen 19*4882a593Smuzhiyun frequency is too far away from a table of valid frequencies for a 20*4882a593Smuzhiyun particular delivery system. 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun- A fake demod driver, which will constantly poll the fake signal quality 23*4882a593Smuzhiyun returned by the tuner, simulating a device that can lose/reacquire a lock 24*4882a593Smuzhiyun on the signal depending on the CNR levels. 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun- A fake bridge driver, which is the module responsible for modprobing the 27*4882a593Smuzhiyun fake tuner and demod modules and implementing the demux logic. This module 28*4882a593Smuzhiyun takes parameters at initialization that will dictate how the simulation 29*4882a593Smuzhiyun behaves. 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun- Code reponsible for encoding a valid MPEG Transport Stream, which is then 32*4882a593Smuzhiyun passed to the bridge driver. This fake stream contains some hardcoded content. 33*4882a593Smuzhiyun For now, we have a single, audio-only channel containing a single MPEG 34*4882a593Smuzhiyun Elementary Stream, which in turn contains a SMPTE 302m encoded sine-wave. 35*4882a593Smuzhiyun Note that this particular encoder was chosen because it is the easiest 36*4882a593Smuzhiyun way to encode PCM audio data in a MPEG Transport Stream. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunBuilding vidtv 39*4882a593Smuzhiyun-------------- 40*4882a593Smuzhiyunvidtv is a test driver and thus is **not** enabled by default when 41*4882a593Smuzhiyuncompiling the kernel. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunIn order to enable compilation of vidtv: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun- Enable **DVB_TEST_DRIVERS**, then 46*4882a593Smuzhiyun- Enable **DVB_VIDTV** 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunWhen compiled as a module, expect the following .ko files: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun- dvb_vidtv_tuner.ko 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun- dvb_vidtv_demod.ko 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun- dvb_vidtv_bridge.ko 55*4882a593Smuzhiyun 56*4882a593SmuzhiyunRunning vidtv 57*4882a593Smuzhiyun------------- 58*4882a593SmuzhiyunWhen compiled as a module, run:: 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun modprobe vidtv 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunThat's it! The bridge driver will initialize the tuner and demod drivers as 63*4882a593Smuzhiyunpart of its own initialization. 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunBy default, it will accept the following frequencies: 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun - 474 MHz for DVB-T/T2/C; 68*4882a593Smuzhiyun - 11,362 GHz for DVB-S/S2. 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunFor satellite systems, the driver simulates an universal extended 71*4882a593SmuzhiyunLNBf, with frequencies at Ku-Band, ranging from 10.7 GHz to 12.75 GHz. 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunYou can optionally define some command-line arguments to vidtv. 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunCommand-line arguments to vidtv 76*4882a593Smuzhiyun------------------------------- 77*4882a593SmuzhiyunBelow is a list of all arguments that can be supplied to vidtv: 78*4882a593Smuzhiyun 79*4882a593Smuzhiyundrop_tslock_prob_on_low_snr 80*4882a593Smuzhiyun Probability of losing the TS lock if the signal quality is bad. 81*4882a593Smuzhiyun This probability be used by the fake demodulator driver to 82*4882a593Smuzhiyun eventually return a status of 0 when the signal quality is not 83*4882a593Smuzhiyun good. 84*4882a593Smuzhiyun 85*4882a593Smuzhiyunrecover_tslock_prob_on_good_snr: 86*4882a593Smuzhiyun Probability recovering the TS lock when the signal improves. This 87*4882a593Smuzhiyun probability be used by the fake demodulator driver to eventually 88*4882a593Smuzhiyun return a status of 0x1f when/if the signal quality improves. 89*4882a593Smuzhiyun 90*4882a593Smuzhiyunmock_power_up_delay_msec 91*4882a593Smuzhiyun Simulate a power up delay. Default: 0. 92*4882a593Smuzhiyun 93*4882a593Smuzhiyunmock_tune_delay_msec 94*4882a593Smuzhiyun Simulate a tune delay. Default 0. 95*4882a593Smuzhiyun 96*4882a593Smuzhiyunvidtv_valid_dvb_t_freqs 97*4882a593Smuzhiyun Valid DVB-T frequencies to simulate, in Hz. 98*4882a593Smuzhiyun 99*4882a593Smuzhiyunvidtv_valid_dvb_c_freqs 100*4882a593Smuzhiyun Valid DVB-C frequencies to simulate, in Hz. 101*4882a593Smuzhiyun 102*4882a593Smuzhiyunvidtv_valid_dvb_s_freqs 103*4882a593Smuzhiyun Valid DVB-S/S2 frequencies to simulate at Ku-Band, in kHz. 104*4882a593Smuzhiyun 105*4882a593Smuzhiyunmax_frequency_shift_hz, 106*4882a593Smuzhiyun Maximum shift in HZ allowed when tuning in a channel. 107*4882a593Smuzhiyun 108*4882a593Smuzhiyunsi_period_msec 109*4882a593Smuzhiyun How often to send SI packets. Default: 40ms. 110*4882a593Smuzhiyun 111*4882a593Smuzhiyunpcr_period_msec 112*4882a593Smuzhiyun How often to send PCR packets. Default: 40ms. 113*4882a593Smuzhiyun 114*4882a593Smuzhiyunmux_rate_kbytes_sec 115*4882a593Smuzhiyun Attempt to maintain this bit rate by inserting TS null packets, if 116*4882a593Smuzhiyun necessary. Default: 4096. 117*4882a593Smuzhiyun 118*4882a593Smuzhiyunpcr_pid, 119*4882a593Smuzhiyun PCR PID for all channels. Default: 0x200. 120*4882a593Smuzhiyun 121*4882a593Smuzhiyunmux_buf_sz_pkts, 122*4882a593Smuzhiyun Size for the mux buffer in multiples of 188 bytes. 123*4882a593Smuzhiyun 124*4882a593Smuzhiyunvidtv internal structure 125*4882a593Smuzhiyun------------------------ 126*4882a593SmuzhiyunThe kernel modules are split in the following way: 127*4882a593Smuzhiyun 128*4882a593Smuzhiyunvidtv_tuner.[ch] 129*4882a593Smuzhiyun Implements a fake tuner DVB driver. 130*4882a593Smuzhiyun 131*4882a593Smuzhiyunvidtv_demod.[ch] 132*4882a593Smuzhiyun Implements a fake demodulator DVB driver. 133*4882a593Smuzhiyun 134*4882a593Smuzhiyunvidtv_bridge.[ch] 135*4882a593Smuzhiyun Implements a bridge driver. 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunThe MPEG related code is split in the following way: 138*4882a593Smuzhiyun 139*4882a593Smuzhiyunvidtv_ts.[ch] 140*4882a593Smuzhiyun Code to work with MPEG TS packets, such as TS headers, adaptation 141*4882a593Smuzhiyun fields, PCR packets and NULL packets. 142*4882a593Smuzhiyun 143*4882a593Smuzhiyunvidtv_psi.[ch] 144*4882a593Smuzhiyun This is the PSI generator. PSI packets contain general information 145*4882a593Smuzhiyun about a MPEG Transport Stream. A PSI generator is needed so 146*4882a593Smuzhiyun userspace apps can retrieve information about the Transport Stream 147*4882a593Smuzhiyun and eventually tune into a (dummy) channel. 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun Because the generator is implemented in a separate file, it can be 150*4882a593Smuzhiyun reused elsewhere in the media subsystem. 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun Currently vidtv supports working with 5 PSI tables: PAT, PMT, 153*4882a593Smuzhiyun SDT, NIT and EIT. 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun The specification for PAT and PMT can be found in *ISO 13818-1: 156*4882a593Smuzhiyun Systems*, while the specification for the SDT, NIT, EIT can be found in *ETSI 157*4882a593Smuzhiyun EN 300 468: Specification for Service Information (SI) in DVB 158*4882a593Smuzhiyun systems*. 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun It isn't strictly necessary, but using a real TS file helps when 161*4882a593Smuzhiyun debugging PSI tables. Vidtv currently tries to replicate the PSI 162*4882a593Smuzhiyun structure found in this file: `TS1Globo.ts 163*4882a593Smuzhiyun <https://tsduck.io/streams/brazil-isdb-tb/TS1globo.ts>`_. 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun A good way to visualize the structure of streams is by using 166*4882a593Smuzhiyun `DVBInspector <https://sourceforge.net/projects/dvbinspector/>`_. 167*4882a593Smuzhiyun 168*4882a593Smuzhiyunvidtv_pes.[ch] 169*4882a593Smuzhiyun Implements the PES logic to convert encoder data into MPEG TS 170*4882a593Smuzhiyun packets. These can then be fed into a TS multiplexer and eventually 171*4882a593Smuzhiyun into userspace. 172*4882a593Smuzhiyun 173*4882a593Smuzhiyunvidtv_encoder.h 174*4882a593Smuzhiyun An interface for vidtv encoders. New encoders can be added to this 175*4882a593Smuzhiyun driver by implementing the calls in this file. 176*4882a593Smuzhiyun 177*4882a593Smuzhiyunvidtv_s302m.[ch] 178*4882a593Smuzhiyun Implements a S302M encoder to make it possible to insert PCM audio 179*4882a593Smuzhiyun data in the generated MPEG Transport Stream. The relevant 180*4882a593Smuzhiyun specification is available online as *SMPTE 302M-2007: Television - 181*4882a593Smuzhiyun Mapping of AES3 Data into MPEG-2 Transport Stream*. 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun The resulting MPEG Elementary Stream is conveyed in a private 185*4882a593Smuzhiyun stream with a S302M registration descriptor attached. 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun This shall enable passing an audio signal into userspace so it can 188*4882a593Smuzhiyun be decoded and played by media software. The corresponding decoder 189*4882a593Smuzhiyun in ffmpeg is located in 'libavcodec/s302m.c' and is experimental. 190*4882a593Smuzhiyun 191*4882a593Smuzhiyunvidtv_channel.[ch] 192*4882a593Smuzhiyun Implements a 'channel' abstraction. 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun When vidtv boots, it will create some hardcoded channels: 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun #. Their services will be concatenated to populate the SDT. 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun #. Their programs will be concatenated to populate the PAT 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun #. Their events will be concatenated to populate the EIT 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun #. For each program in the PAT, a PMT section will be created 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun #. The PMT section for a channel will be assigned its streams. 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun #. Every stream will have its corresponding encoder polled in a 207*4882a593Smuzhiyun loop to produce TS packets. 208*4882a593Smuzhiyun These packets may be interleaved by the muxer and then delivered 209*4882a593Smuzhiyun to the bridge. 210*4882a593Smuzhiyun 211*4882a593Smuzhiyunvidtv_mux.[ch] 212*4882a593Smuzhiyun Implements a MPEG TS mux, loosely based on the ffmpeg 213*4882a593Smuzhiyun implementation in "libavcodec/mpegtsenc.c" 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun The muxer runs a loop which is responsible for: 216*4882a593Smuzhiyun 217*4882a593Smuzhiyun #. Keeping track of the amount of time elapsed since the last 218*4882a593Smuzhiyun iteration. 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun #. Polling encoders in order to fetch 'elapsed_time' worth of data. 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun #. Inserting PSI and/or PCR packets, if needed. 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun #. Padding the resulting stream with NULL packets if 225*4882a593Smuzhiyun necessary in order to maintain the chosen bit rate. 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun #. Delivering the resulting TS packets to the bridge 228*4882a593Smuzhiyun driver so it can pass them to the demux. 229*4882a593Smuzhiyun 230*4882a593SmuzhiyunTesting vidtv with v4l-utils 231*4882a593Smuzhiyun---------------------------- 232*4882a593Smuzhiyun 233*4882a593SmuzhiyunUsing the tools in v4l-utils is a great way to test and inspect the output of 234*4882a593Smuzhiyunvidtv. It is hosted here: `v4l-utils Documentation 235*4882a593Smuzhiyun<https://linuxtv.org/wiki/index.php/V4l-utils>`_. 236*4882a593Smuzhiyun 237*4882a593SmuzhiyunFrom its webpage:: 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun The v4l-utils are a series of packages for handling media devices. 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun It is hosted at http://git.linuxtv.org/v4l-utils.git, and packaged 242*4882a593Smuzhiyun on most distributions. 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun It provides a series of libraries and utilities to be used to 245*4882a593Smuzhiyun control several aspect of the media boards. 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun 248*4882a593SmuzhiyunStart by installing v4l-utils and then modprobing vidtv:: 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun modprobe dvb_vidtv_bridge 251*4882a593Smuzhiyun 252*4882a593SmuzhiyunIf the driver is OK, it should load and its probing code will run. This will 253*4882a593Smuzhiyunpull in the tuner and demod drivers. 254*4882a593Smuzhiyun 255*4882a593SmuzhiyunUsing dvb-fe-tool 256*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~ 257*4882a593Smuzhiyun 258*4882a593SmuzhiyunThe first step to check whether the demod loaded successfully is to run:: 259*4882a593Smuzhiyun 260*4882a593Smuzhiyun $ dvb-fe-tool 261*4882a593Smuzhiyun Device Dummy demod for DVB-T/T2/C/S/S2 (/dev/dvb/adapter0/frontend0) capabilities: 262*4882a593Smuzhiyun CAN_FEC_1_2 263*4882a593Smuzhiyun CAN_FEC_2_3 264*4882a593Smuzhiyun CAN_FEC_3_4 265*4882a593Smuzhiyun CAN_FEC_4_5 266*4882a593Smuzhiyun CAN_FEC_5_6 267*4882a593Smuzhiyun CAN_FEC_6_7 268*4882a593Smuzhiyun CAN_FEC_7_8 269*4882a593Smuzhiyun CAN_FEC_8_9 270*4882a593Smuzhiyun CAN_FEC_AUTO 271*4882a593Smuzhiyun CAN_GUARD_INTERVAL_AUTO 272*4882a593Smuzhiyun CAN_HIERARCHY_AUTO 273*4882a593Smuzhiyun CAN_INVERSION_AUTO 274*4882a593Smuzhiyun CAN_QAM_16 275*4882a593Smuzhiyun CAN_QAM_32 276*4882a593Smuzhiyun CAN_QAM_64 277*4882a593Smuzhiyun CAN_QAM_128 278*4882a593Smuzhiyun CAN_QAM_256 279*4882a593Smuzhiyun CAN_QAM_AUTO 280*4882a593Smuzhiyun CAN_QPSK 281*4882a593Smuzhiyun CAN_TRANSMISSION_MODE_AUTO 282*4882a593Smuzhiyun DVB API Version 5.11, Current v5 delivery system: DVBC/ANNEX_A 283*4882a593Smuzhiyun Supported delivery systems: 284*4882a593Smuzhiyun DVBT 285*4882a593Smuzhiyun DVBT2 286*4882a593Smuzhiyun [DVBC/ANNEX_A] 287*4882a593Smuzhiyun DVBS 288*4882a593Smuzhiyun DVBS2 289*4882a593Smuzhiyun Frequency range for the current standard: 290*4882a593Smuzhiyun From: 51.0 MHz 291*4882a593Smuzhiyun To: 2.15 GHz 292*4882a593Smuzhiyun Step: 62.5 kHz 293*4882a593Smuzhiyun Tolerance: 29.5 MHz 294*4882a593Smuzhiyun Symbol rate ranges for the current standard: 295*4882a593Smuzhiyun From: 1.00 MBauds 296*4882a593Smuzhiyun To: 45.0 MBauds 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunThis should return what is currently set up at the demod struct, i.e.:: 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun static const struct dvb_frontend_ops vidtv_demod_ops = { 301*4882a593Smuzhiyun .delsys = { 302*4882a593Smuzhiyun SYS_DVBT, 303*4882a593Smuzhiyun SYS_DVBT2, 304*4882a593Smuzhiyun SYS_DVBC_ANNEX_A, 305*4882a593Smuzhiyun SYS_DVBS, 306*4882a593Smuzhiyun SYS_DVBS2, 307*4882a593Smuzhiyun }, 308*4882a593Smuzhiyun 309*4882a593Smuzhiyun .info = { 310*4882a593Smuzhiyun .name = "Dummy demod for DVB-T/T2/C/S/S2", 311*4882a593Smuzhiyun .frequency_min_hz = 51 * MHz, 312*4882a593Smuzhiyun .frequency_max_hz = 2150 * MHz, 313*4882a593Smuzhiyun .frequency_stepsize_hz = 62500, 314*4882a593Smuzhiyun .frequency_tolerance_hz = 29500 * kHz, 315*4882a593Smuzhiyun .symbol_rate_min = 1000000, 316*4882a593Smuzhiyun .symbol_rate_max = 45000000, 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun .caps = FE_CAN_FEC_1_2 | 319*4882a593Smuzhiyun FE_CAN_FEC_2_3 | 320*4882a593Smuzhiyun FE_CAN_FEC_3_4 | 321*4882a593Smuzhiyun FE_CAN_FEC_4_5 | 322*4882a593Smuzhiyun FE_CAN_FEC_5_6 | 323*4882a593Smuzhiyun FE_CAN_FEC_6_7 | 324*4882a593Smuzhiyun FE_CAN_FEC_7_8 | 325*4882a593Smuzhiyun FE_CAN_FEC_8_9 | 326*4882a593Smuzhiyun FE_CAN_QAM_16 | 327*4882a593Smuzhiyun FE_CAN_QAM_64 | 328*4882a593Smuzhiyun FE_CAN_QAM_32 | 329*4882a593Smuzhiyun FE_CAN_QAM_128 | 330*4882a593Smuzhiyun FE_CAN_QAM_256 | 331*4882a593Smuzhiyun FE_CAN_QAM_AUTO | 332*4882a593Smuzhiyun FE_CAN_QPSK | 333*4882a593Smuzhiyun FE_CAN_FEC_AUTO | 334*4882a593Smuzhiyun FE_CAN_INVERSION_AUTO | 335*4882a593Smuzhiyun FE_CAN_TRANSMISSION_MODE_AUTO | 336*4882a593Smuzhiyun FE_CAN_GUARD_INTERVAL_AUTO | 337*4882a593Smuzhiyun FE_CAN_HIERARCHY_AUTO, 338*4882a593Smuzhiyun } 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun .... 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunFor more information on dvb-fe-tools check its online documentation here: 343*4882a593Smuzhiyun`dvb-fe-tool Documentation 344*4882a593Smuzhiyun<https://www.linuxtv.org/wiki/index.php/Dvb-fe-tool>`_. 345*4882a593Smuzhiyun 346*4882a593SmuzhiyunUsing dvb-scan 347*4882a593Smuzhiyun~~~~~~~~~~~~~~ 348*4882a593Smuzhiyun 349*4882a593SmuzhiyunIn order to tune into a channel and read the PSI tables, we can use dvb-scan. 350*4882a593Smuzhiyun 351*4882a593SmuzhiyunFor this, one should provide a configuration file known as a 'scan file', 352*4882a593Smuzhiyunhere's an example:: 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun [Channel] 355*4882a593Smuzhiyun FREQUENCY = 474000000 356*4882a593Smuzhiyun MODULATION = QAM/AUTO 357*4882a593Smuzhiyun SYMBOL_RATE = 6940000 358*4882a593Smuzhiyun INNER_FEC = AUTO 359*4882a593Smuzhiyun DELIVERY_SYSTEM = DVBC/ANNEX_A 360*4882a593Smuzhiyun 361*4882a593Smuzhiyun.. note:: 362*4882a593Smuzhiyun The parameters depend on the video standard you're testing. 363*4882a593Smuzhiyun 364*4882a593Smuzhiyun.. note:: 365*4882a593Smuzhiyun Vidtv is a fake driver and does not validate much of the information 366*4882a593Smuzhiyun in the scan file. Just specifying 'FREQUENCY' and 'DELIVERY_SYSTEM' 367*4882a593Smuzhiyun should be enough for DVB-T/DVB-T2. For DVB-S/DVB-C however, you 368*4882a593Smuzhiyun should also provide 'SYMBOL_RATE'. 369*4882a593Smuzhiyun 370*4882a593SmuzhiyunYou can browse scan tables online here: `dvb-scan-tables 371*4882a593Smuzhiyun<https://git.linuxtv.org/dtv-scan-tables.git>`_. 372*4882a593Smuzhiyun 373*4882a593SmuzhiyunAssuming this channel is named 'channel.conf', you can then run:: 374*4882a593Smuzhiyun 375*4882a593Smuzhiyun $ dvbv5-scan channel.conf 376*4882a593Smuzhiyun dvbv5-scan ~/vidtv.conf 377*4882a593Smuzhiyun ERROR command BANDWIDTH_HZ (5) not found during retrieve 378*4882a593Smuzhiyun Cannot calc frequency shift. Either bandwidth/symbol-rate is unavailable (yet). 379*4882a593Smuzhiyun Scanning frequency #1 330000000 380*4882a593Smuzhiyun (0x00) Signal= -68.00dBm 381*4882a593Smuzhiyun Scanning frequency #2 474000000 382*4882a593Smuzhiyun Lock (0x1f) Signal= -34.45dBm C/N= 33.74dB UCB= 0 383*4882a593Smuzhiyun Service Beethoven, provider LinuxTV.org: digital television 384*4882a593Smuzhiyun 385*4882a593SmuzhiyunFor more information on dvb-scan, check its documentation online here: 386*4882a593Smuzhiyun`dvb-scan Documentation <https://www.linuxtv.org/wiki/index.php/Dvbscan>`_. 387*4882a593Smuzhiyun 388*4882a593SmuzhiyunUsing dvb-zap 389*4882a593Smuzhiyun~~~~~~~~~~~~~ 390*4882a593Smuzhiyun 391*4882a593Smuzhiyundvbv5-zap is a command line tool that can be used to record MPEG-TS to disk. The 392*4882a593Smuzhiyuntypical use is to tune into a channel and put it into record mode. The example 393*4882a593Smuzhiyunbelow - which is taken from the documentation - illustrates that\ [1]_:: 394*4882a593Smuzhiyun 395*4882a593Smuzhiyun $ dvbv5-zap -c dvb_channel.conf "beethoven" -o music.ts -P -t 10 396*4882a593Smuzhiyun using demux 'dvb0.demux0' 397*4882a593Smuzhiyun reading channels from file 'dvb_channel.conf' 398*4882a593Smuzhiyun tuning to 474000000 Hz 399*4882a593Smuzhiyun pass all PID's to TS 400*4882a593Smuzhiyun dvb_set_pesfilter 8192 401*4882a593Smuzhiyun dvb_dev_set_bufsize: buffer set to 6160384 402*4882a593Smuzhiyun Lock (0x1f) Quality= Good Signal= -34.66dBm C/N= 33.41dB UCB= 0 postBER= 0 preBER= 1.05x10^-3 PER= 0 403*4882a593Smuzhiyun Lock (0x1f) Quality= Good Signal= -34.57dBm C/N= 33.46dB UCB= 0 postBER= 0 preBER= 1.05x10^-3 PER= 0 404*4882a593Smuzhiyun Record to file 'music.ts' started 405*4882a593Smuzhiyun received 24587768 bytes (2401 Kbytes/sec) 406*4882a593Smuzhiyun Lock (0x1f) Quality= Good Signal= -34.42dBm C/N= 33.89dB UCB= 0 postBER= 0 preBER= 2.44x10^-3 PER= 0 407*4882a593Smuzhiyun 408*4882a593Smuzhiyun.. [1] In this example, it records 10 seconds with all program ID's stored 409*4882a593Smuzhiyun at the music.ts file. 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun 412*4882a593SmuzhiyunThe channel can be watched by playing the contents of the stream with some 413*4882a593Smuzhiyunplayer that recognizes the MPEG-TS format, such as ``mplayer`` or ``vlc``. 414*4882a593Smuzhiyun 415*4882a593SmuzhiyunBy playing the contents of the stream one can visually inspect the workings of 416*4882a593Smuzhiyunvidtv, e.g., to play a recorded TS file with:: 417*4882a593Smuzhiyun 418*4882a593Smuzhiyun $ mplayer music.ts 419*4882a593Smuzhiyun 420*4882a593Smuzhiyunor, alternatively, running this command on one terminal:: 421*4882a593Smuzhiyun 422*4882a593Smuzhiyun $ dvbv5-zap -c dvb_channel.conf "beethoven" -P -r & 423*4882a593Smuzhiyun 424*4882a593SmuzhiyunAnd, on a second terminal, playing the contents from DVR interface with:: 425*4882a593Smuzhiyun 426*4882a593Smuzhiyun $ mplayer /dev/dvb/adapter0/dvr0 427*4882a593Smuzhiyun 428*4882a593SmuzhiyunFor more information on dvb-zap check its online documentation here: 429*4882a593Smuzhiyun`dvb-zap Documentation 430*4882a593Smuzhiyun<https://www.linuxtv.org/wiki/index.php/Dvbv5-zap>`_. 431*4882a593SmuzhiyunSee also: `zap <https://www.linuxtv.org/wiki/index.php/Zap>`_. 432*4882a593Smuzhiyun 433*4882a593Smuzhiyun 434*4882a593SmuzhiyunWhat can still be improved in vidtv 435*4882a593Smuzhiyun----------------------------------- 436*4882a593Smuzhiyun 437*4882a593SmuzhiyunAdd *debugfs* integration 438*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~ 439*4882a593Smuzhiyun 440*4882a593SmuzhiyunAlthough frontend drivers provide DVBv5 statistics via the .read_status 441*4882a593Smuzhiyuncall, a nice addition would be to make additional statistics available to 442*4882a593Smuzhiyunuserspace via debugfs, which is a simple-to-use, RAM-based filesystem 443*4882a593Smuzhiyunspecifically designed for debug purposes. 444*4882a593Smuzhiyun 445*4882a593SmuzhiyunThe logic for this would be implemented on a separate file so as not to 446*4882a593Smuzhiyunpollute the frontend driver. These statistics are driver-specific and can 447*4882a593Smuzhiyunbe useful during tests. 448*4882a593Smuzhiyun 449*4882a593SmuzhiyunThe Siano driver is one example of a driver using 450*4882a593Smuzhiyundebugfs to convey driver-specific statistics to userspace and it can be 451*4882a593Smuzhiyunused as a reference. 452*4882a593Smuzhiyun 453*4882a593SmuzhiyunThis should be further enabled and disabled via a Kconfig 454*4882a593Smuzhiyunoption for convenience. 455*4882a593Smuzhiyun 456*4882a593SmuzhiyunAdd a way to test video 457*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~ 458*4882a593Smuzhiyun 459*4882a593SmuzhiyunCurrently, vidtv can only encode PCM audio. It would be great to implement 460*4882a593Smuzhiyuna barebones version of MPEG-2 video encoding so we can also test video. The 461*4882a593Smuzhiyunfirst place to look into is *ISO 13818-2: Information technology — Generic 462*4882a593Smuzhiyuncoding of moving pictures and associated audio information — Part 2: Video*, 463*4882a593Smuzhiyunwhich covers the encoding of compressed video in MPEG Transport Streams. 464*4882a593Smuzhiyun 465*4882a593SmuzhiyunThis might optionally use the Video4Linux2 Test Pattern Generator, v4l2-tpg, 466*4882a593Smuzhiyunwhich resides at:: 467*4882a593Smuzhiyun 468*4882a593Smuzhiyun drivers/media/common/v4l2-tpg/ 469*4882a593Smuzhiyun 470*4882a593Smuzhiyun 471*4882a593SmuzhiyunAdd white noise simulation 472*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~ 473*4882a593Smuzhiyun 474*4882a593SmuzhiyunThe vidtv tuner already has code to identify whether the chosen frequency 475*4882a593Smuzhiyunis too far away from a table of valid frequencies. For now, this means that 476*4882a593Smuzhiyunthe demodulator can eventually lose the lock on the signal, since the tuner will 477*4882a593Smuzhiyunreport a bad signal quality. 478*4882a593Smuzhiyun 479*4882a593SmuzhiyunA nice addition is to simulate some noise when the signal quality is bad by: 480*4882a593Smuzhiyun 481*4882a593Smuzhiyun- Randomly dropping some TS packets. This will trigger a continuity error if the 482*4882a593Smuzhiyun continuity counter is updated but the packet is not passed on to the demux. 483*4882a593Smuzhiyun 484*4882a593Smuzhiyun- Updating the error statistics accordingly (e.g. BER, etc). 485*4882a593Smuzhiyun 486*4882a593Smuzhiyun- Simulating some noise in the encoded data. 487*4882a593Smuzhiyun 488*4882a593SmuzhiyunFunctions and structs used within vidtv 489*4882a593Smuzhiyun--------------------------------------- 490*4882a593Smuzhiyun 491*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_bridge.h 492*4882a593Smuzhiyun 493*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_channel.h 494*4882a593Smuzhiyun 495*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_demod.h 496*4882a593Smuzhiyun 497*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_encoder.h 498*4882a593Smuzhiyun 499*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_mux.h 500*4882a593Smuzhiyun 501*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_pes.h 502*4882a593Smuzhiyun 503*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_psi.h 504*4882a593Smuzhiyun 505*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_s302m.h 506*4882a593Smuzhiyun 507*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_ts.h 508*4882a593Smuzhiyun 509*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_tuner.h 510*4882a593Smuzhiyun 511*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_common.c 512*4882a593Smuzhiyun 513*4882a593Smuzhiyun.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_tuner.c 514