162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci================================ 462306a36Sopenharmony_cividtv: Virtual Digital TV driver 562306a36Sopenharmony_ci================================ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ciAuthor: Daniel W. S. Almeida <dwlsalmeida@gmail.com>, June 2020. 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciBackground 1062306a36Sopenharmony_ci---------- 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciVidtv is a virtual DVB driver that aims to serve as a reference for driver 1362306a36Sopenharmony_ciwriters by serving as a template. It also validates the existing media DVB 1462306a36Sopenharmony_ciAPIs, thus helping userspace application writers. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciCurrently, it consists of: 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci- A fake tuner driver, which will report a bad signal quality if the chosen 1962306a36Sopenharmony_ci frequency is too far away from a table of valid frequencies for a 2062306a36Sopenharmony_ci particular delivery system. 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci- A fake demod driver, which will constantly poll the fake signal quality 2362306a36Sopenharmony_ci returned by the tuner, simulating a device that can lose/reacquire a lock 2462306a36Sopenharmony_ci on the signal depending on the CNR levels. 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci- A fake bridge driver, which is the module responsible for modprobing the 2762306a36Sopenharmony_ci fake tuner and demod modules and implementing the demux logic. This module 2862306a36Sopenharmony_ci takes parameters at initialization that will dictate how the simulation 2962306a36Sopenharmony_ci behaves. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci- Code responsible for encoding a valid MPEG Transport Stream, which is then 3262306a36Sopenharmony_ci passed to the bridge driver. This fake stream contains some hardcoded content. 3362306a36Sopenharmony_ci For now, we have a single, audio-only channel containing a single MPEG 3462306a36Sopenharmony_ci Elementary Stream, which in turn contains a SMPTE 302m encoded sine-wave. 3562306a36Sopenharmony_ci Note that this particular encoder was chosen because it is the easiest 3662306a36Sopenharmony_ci way to encode PCM audio data in a MPEG Transport Stream. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciBuilding vidtv 3962306a36Sopenharmony_ci-------------- 4062306a36Sopenharmony_cividtv is a test driver and thus is **not** enabled by default when 4162306a36Sopenharmony_cicompiling the kernel. 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciIn order to enable compilation of vidtv: 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci- Enable **DVB_TEST_DRIVERS**, then 4662306a36Sopenharmony_ci- Enable **DVB_VIDTV** 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciWhen compiled as a module, expect the following .ko files: 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci- dvb_vidtv_tuner.ko 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci- dvb_vidtv_demod.ko 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci- dvb_vidtv_bridge.ko 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ciRunning vidtv 5762306a36Sopenharmony_ci------------- 5862306a36Sopenharmony_ciWhen compiled as a module, run:: 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci modprobe vidtv 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciThat's it! The bridge driver will initialize the tuner and demod drivers as 6362306a36Sopenharmony_cipart of its own initialization. 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ciBy default, it will accept the following frequencies: 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci - 474 MHz for DVB-T/T2/C; 6862306a36Sopenharmony_ci - 11,362 GHz for DVB-S/S2. 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciFor satellite systems, the driver simulates an universal extended 7162306a36Sopenharmony_ciLNBf, with frequencies at Ku-Band, ranging from 10.7 GHz to 12.75 GHz. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciYou can optionally define some command-line arguments to vidtv. 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciCommand-line arguments to vidtv 7662306a36Sopenharmony_ci------------------------------- 7762306a36Sopenharmony_ciBelow is a list of all arguments that can be supplied to vidtv: 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cidrop_tslock_prob_on_low_snr 8062306a36Sopenharmony_ci Probability of losing the TS lock if the signal quality is bad. 8162306a36Sopenharmony_ci This probability be used by the fake demodulator driver to 8262306a36Sopenharmony_ci eventually return a status of 0 when the signal quality is not 8362306a36Sopenharmony_ci good. 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cirecover_tslock_prob_on_good_snr: 8662306a36Sopenharmony_ci Probability recovering the TS lock when the signal improves. This 8762306a36Sopenharmony_ci probability be used by the fake demodulator driver to eventually 8862306a36Sopenharmony_ci return a status of 0x1f when/if the signal quality improves. 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_cimock_power_up_delay_msec 9162306a36Sopenharmony_ci Simulate a power up delay. Default: 0. 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cimock_tune_delay_msec 9462306a36Sopenharmony_ci Simulate a tune delay. Default 0. 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_cividtv_valid_dvb_t_freqs 9762306a36Sopenharmony_ci Valid DVB-T frequencies to simulate, in Hz. 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cividtv_valid_dvb_c_freqs 10062306a36Sopenharmony_ci Valid DVB-C frequencies to simulate, in Hz. 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cividtv_valid_dvb_s_freqs 10362306a36Sopenharmony_ci Valid DVB-S/S2 frequencies to simulate at Ku-Band, in kHz. 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cimax_frequency_shift_hz, 10662306a36Sopenharmony_ci Maximum shift in HZ allowed when tuning in a channel. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_cisi_period_msec 10962306a36Sopenharmony_ci How often to send SI packets. Default: 40ms. 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_cipcr_period_msec 11262306a36Sopenharmony_ci How often to send PCR packets. Default: 40ms. 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_cimux_rate_kbytes_sec 11562306a36Sopenharmony_ci Attempt to maintain this bit rate by inserting TS null packets, if 11662306a36Sopenharmony_ci necessary. Default: 4096. 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cipcr_pid, 11962306a36Sopenharmony_ci PCR PID for all channels. Default: 0x200. 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_cimux_buf_sz_pkts, 12262306a36Sopenharmony_ci Size for the mux buffer in multiples of 188 bytes. 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_cividtv internal structure 12562306a36Sopenharmony_ci------------------------ 12662306a36Sopenharmony_ciThe kernel modules are split in the following way: 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_cividtv_tuner.[ch] 12962306a36Sopenharmony_ci Implements a fake tuner DVB driver. 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cividtv_demod.[ch] 13262306a36Sopenharmony_ci Implements a fake demodulator DVB driver. 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cividtv_bridge.[ch] 13562306a36Sopenharmony_ci Implements a bridge driver. 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ciThe MPEG related code is split in the following way: 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cividtv_ts.[ch] 14062306a36Sopenharmony_ci Code to work with MPEG TS packets, such as TS headers, adaptation 14162306a36Sopenharmony_ci fields, PCR packets and NULL packets. 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cividtv_psi.[ch] 14462306a36Sopenharmony_ci This is the PSI generator. PSI packets contain general information 14562306a36Sopenharmony_ci about a MPEG Transport Stream. A PSI generator is needed so 14662306a36Sopenharmony_ci userspace apps can retrieve information about the Transport Stream 14762306a36Sopenharmony_ci and eventually tune into a (dummy) channel. 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci Because the generator is implemented in a separate file, it can be 15062306a36Sopenharmony_ci reused elsewhere in the media subsystem. 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci Currently vidtv supports working with 5 PSI tables: PAT, PMT, 15362306a36Sopenharmony_ci SDT, NIT and EIT. 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci The specification for PAT and PMT can be found in *ISO 13818-1: 15662306a36Sopenharmony_ci Systems*, while the specification for the SDT, NIT, EIT can be found in *ETSI 15762306a36Sopenharmony_ci EN 300 468: Specification for Service Information (SI) in DVB 15862306a36Sopenharmony_ci systems*. 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci It isn't strictly necessary, but using a real TS file helps when 16162306a36Sopenharmony_ci debugging PSI tables. Vidtv currently tries to replicate the PSI 16262306a36Sopenharmony_ci structure found in this file: `TS1Globo.ts 16362306a36Sopenharmony_ci <https://tsduck.io/streams/brazil-isdb-tb/TS1globo.ts>`_. 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci A good way to visualize the structure of streams is by using 16662306a36Sopenharmony_ci `DVBInspector <https://sourceforge.net/projects/dvbinspector/>`_. 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_cividtv_pes.[ch] 16962306a36Sopenharmony_ci Implements the PES logic to convert encoder data into MPEG TS 17062306a36Sopenharmony_ci packets. These can then be fed into a TS multiplexer and eventually 17162306a36Sopenharmony_ci into userspace. 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_cividtv_encoder.h 17462306a36Sopenharmony_ci An interface for vidtv encoders. New encoders can be added to this 17562306a36Sopenharmony_ci driver by implementing the calls in this file. 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cividtv_s302m.[ch] 17862306a36Sopenharmony_ci Implements a S302M encoder to make it possible to insert PCM audio 17962306a36Sopenharmony_ci data in the generated MPEG Transport Stream. The relevant 18062306a36Sopenharmony_ci specification is available online as *SMPTE 302M-2007: Television - 18162306a36Sopenharmony_ci Mapping of AES3 Data into MPEG-2 Transport Stream*. 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci The resulting MPEG Elementary Stream is conveyed in a private 18562306a36Sopenharmony_ci stream with a S302M registration descriptor attached. 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci This shall enable passing an audio signal into userspace so it can 18862306a36Sopenharmony_ci be decoded and played by media software. The corresponding decoder 18962306a36Sopenharmony_ci in ffmpeg is located in 'libavcodec/s302m.c' and is experimental. 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_cividtv_channel.[ch] 19262306a36Sopenharmony_ci Implements a 'channel' abstraction. 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci When vidtv boots, it will create some hardcoded channels: 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci #. Their services will be concatenated to populate the SDT. 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci #. Their programs will be concatenated to populate the PAT 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci #. Their events will be concatenated to populate the EIT 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci #. For each program in the PAT, a PMT section will be created 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci #. The PMT section for a channel will be assigned its streams. 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci #. Every stream will have its corresponding encoder polled in a 20762306a36Sopenharmony_ci loop to produce TS packets. 20862306a36Sopenharmony_ci These packets may be interleaved by the muxer and then delivered 20962306a36Sopenharmony_ci to the bridge. 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cividtv_mux.[ch] 21262306a36Sopenharmony_ci Implements a MPEG TS mux, loosely based on the ffmpeg 21362306a36Sopenharmony_ci implementation in "libavcodec/mpegtsenc.c" 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci The muxer runs a loop which is responsible for: 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci #. Keeping track of the amount of time elapsed since the last 21862306a36Sopenharmony_ci iteration. 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci #. Polling encoders in order to fetch 'elapsed_time' worth of data. 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci #. Inserting PSI and/or PCR packets, if needed. 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci #. Padding the resulting stream with NULL packets if 22562306a36Sopenharmony_ci necessary in order to maintain the chosen bit rate. 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci #. Delivering the resulting TS packets to the bridge 22862306a36Sopenharmony_ci driver so it can pass them to the demux. 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ciTesting vidtv with v4l-utils 23162306a36Sopenharmony_ci---------------------------- 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ciUsing the tools in v4l-utils is a great way to test and inspect the output of 23462306a36Sopenharmony_cividtv. It is hosted here: `v4l-utils Documentation 23562306a36Sopenharmony_ci<https://linuxtv.org/wiki/index.php/V4l-utils>`_. 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ciFrom its webpage:: 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci The v4l-utils are a series of packages for handling media devices. 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci It is hosted at http://git.linuxtv.org/v4l-utils.git, and packaged 24262306a36Sopenharmony_ci on most distributions. 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci It provides a series of libraries and utilities to be used to 24562306a36Sopenharmony_ci control several aspect of the media boards. 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ciStart by installing v4l-utils and then modprobing vidtv:: 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci modprobe dvb_vidtv_bridge 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ciIf the driver is OK, it should load and its probing code will run. This will 25362306a36Sopenharmony_cipull in the tuner and demod drivers. 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ciUsing dvb-fe-tool 25662306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~ 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ciThe first step to check whether the demod loaded successfully is to run:: 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci $ dvb-fe-tool 26162306a36Sopenharmony_ci Device Dummy demod for DVB-T/T2/C/S/S2 (/dev/dvb/adapter0/frontend0) capabilities: 26262306a36Sopenharmony_ci CAN_FEC_1_2 26362306a36Sopenharmony_ci CAN_FEC_2_3 26462306a36Sopenharmony_ci CAN_FEC_3_4 26562306a36Sopenharmony_ci CAN_FEC_4_5 26662306a36Sopenharmony_ci CAN_FEC_5_6 26762306a36Sopenharmony_ci CAN_FEC_6_7 26862306a36Sopenharmony_ci CAN_FEC_7_8 26962306a36Sopenharmony_ci CAN_FEC_8_9 27062306a36Sopenharmony_ci CAN_FEC_AUTO 27162306a36Sopenharmony_ci CAN_GUARD_INTERVAL_AUTO 27262306a36Sopenharmony_ci CAN_HIERARCHY_AUTO 27362306a36Sopenharmony_ci CAN_INVERSION_AUTO 27462306a36Sopenharmony_ci CAN_QAM_16 27562306a36Sopenharmony_ci CAN_QAM_32 27662306a36Sopenharmony_ci CAN_QAM_64 27762306a36Sopenharmony_ci CAN_QAM_128 27862306a36Sopenharmony_ci CAN_QAM_256 27962306a36Sopenharmony_ci CAN_QAM_AUTO 28062306a36Sopenharmony_ci CAN_QPSK 28162306a36Sopenharmony_ci CAN_TRANSMISSION_MODE_AUTO 28262306a36Sopenharmony_ci DVB API Version 5.11, Current v5 delivery system: DVBC/ANNEX_A 28362306a36Sopenharmony_ci Supported delivery systems: 28462306a36Sopenharmony_ci DVBT 28562306a36Sopenharmony_ci DVBT2 28662306a36Sopenharmony_ci [DVBC/ANNEX_A] 28762306a36Sopenharmony_ci DVBS 28862306a36Sopenharmony_ci DVBS2 28962306a36Sopenharmony_ci Frequency range for the current standard: 29062306a36Sopenharmony_ci From: 51.0 MHz 29162306a36Sopenharmony_ci To: 2.15 GHz 29262306a36Sopenharmony_ci Step: 62.5 kHz 29362306a36Sopenharmony_ci Tolerance: 29.5 MHz 29462306a36Sopenharmony_ci Symbol rate ranges for the current standard: 29562306a36Sopenharmony_ci From: 1.00 MBauds 29662306a36Sopenharmony_ci To: 45.0 MBauds 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ciThis should return what is currently set up at the demod struct, i.e.:: 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci static const struct dvb_frontend_ops vidtv_demod_ops = { 30162306a36Sopenharmony_ci .delsys = { 30262306a36Sopenharmony_ci SYS_DVBT, 30362306a36Sopenharmony_ci SYS_DVBT2, 30462306a36Sopenharmony_ci SYS_DVBC_ANNEX_A, 30562306a36Sopenharmony_ci SYS_DVBS, 30662306a36Sopenharmony_ci SYS_DVBS2, 30762306a36Sopenharmony_ci }, 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci .info = { 31062306a36Sopenharmony_ci .name = "Dummy demod for DVB-T/T2/C/S/S2", 31162306a36Sopenharmony_ci .frequency_min_hz = 51 * MHz, 31262306a36Sopenharmony_ci .frequency_max_hz = 2150 * MHz, 31362306a36Sopenharmony_ci .frequency_stepsize_hz = 62500, 31462306a36Sopenharmony_ci .frequency_tolerance_hz = 29500 * kHz, 31562306a36Sopenharmony_ci .symbol_rate_min = 1000000, 31662306a36Sopenharmony_ci .symbol_rate_max = 45000000, 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci .caps = FE_CAN_FEC_1_2 | 31962306a36Sopenharmony_ci FE_CAN_FEC_2_3 | 32062306a36Sopenharmony_ci FE_CAN_FEC_3_4 | 32162306a36Sopenharmony_ci FE_CAN_FEC_4_5 | 32262306a36Sopenharmony_ci FE_CAN_FEC_5_6 | 32362306a36Sopenharmony_ci FE_CAN_FEC_6_7 | 32462306a36Sopenharmony_ci FE_CAN_FEC_7_8 | 32562306a36Sopenharmony_ci FE_CAN_FEC_8_9 | 32662306a36Sopenharmony_ci FE_CAN_QAM_16 | 32762306a36Sopenharmony_ci FE_CAN_QAM_64 | 32862306a36Sopenharmony_ci FE_CAN_QAM_32 | 32962306a36Sopenharmony_ci FE_CAN_QAM_128 | 33062306a36Sopenharmony_ci FE_CAN_QAM_256 | 33162306a36Sopenharmony_ci FE_CAN_QAM_AUTO | 33262306a36Sopenharmony_ci FE_CAN_QPSK | 33362306a36Sopenharmony_ci FE_CAN_FEC_AUTO | 33462306a36Sopenharmony_ci FE_CAN_INVERSION_AUTO | 33562306a36Sopenharmony_ci FE_CAN_TRANSMISSION_MODE_AUTO | 33662306a36Sopenharmony_ci FE_CAN_GUARD_INTERVAL_AUTO | 33762306a36Sopenharmony_ci FE_CAN_HIERARCHY_AUTO, 33862306a36Sopenharmony_ci } 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_ci .... 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ciFor more information on dvb-fe-tools check its online documentation here: 34362306a36Sopenharmony_ci`dvb-fe-tool Documentation 34462306a36Sopenharmony_ci<https://www.linuxtv.org/wiki/index.php/Dvb-fe-tool>`_. 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ciUsing dvb-scan 34762306a36Sopenharmony_ci~~~~~~~~~~~~~~ 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ciIn order to tune into a channel and read the PSI tables, we can use dvb-scan. 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ciFor this, one should provide a configuration file known as a 'scan file', 35262306a36Sopenharmony_cihere's an example:: 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci [Channel] 35562306a36Sopenharmony_ci FREQUENCY = 474000000 35662306a36Sopenharmony_ci MODULATION = QAM/AUTO 35762306a36Sopenharmony_ci SYMBOL_RATE = 6940000 35862306a36Sopenharmony_ci INNER_FEC = AUTO 35962306a36Sopenharmony_ci DELIVERY_SYSTEM = DVBC/ANNEX_A 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci.. note:: 36262306a36Sopenharmony_ci The parameters depend on the video standard you're testing. 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci.. note:: 36562306a36Sopenharmony_ci Vidtv is a fake driver and does not validate much of the information 36662306a36Sopenharmony_ci in the scan file. Just specifying 'FREQUENCY' and 'DELIVERY_SYSTEM' 36762306a36Sopenharmony_ci should be enough for DVB-T/DVB-T2. For DVB-S/DVB-C however, you 36862306a36Sopenharmony_ci should also provide 'SYMBOL_RATE'. 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ciYou can browse scan tables online here: `dvb-scan-tables 37162306a36Sopenharmony_ci<https://git.linuxtv.org/dtv-scan-tables.git>`_. 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ciAssuming this channel is named 'channel.conf', you can then run:: 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci $ dvbv5-scan channel.conf 37662306a36Sopenharmony_ci dvbv5-scan ~/vidtv.conf 37762306a36Sopenharmony_ci ERROR command BANDWIDTH_HZ (5) not found during retrieve 37862306a36Sopenharmony_ci Cannot calc frequency shift. Either bandwidth/symbol-rate is unavailable (yet). 37962306a36Sopenharmony_ci Scanning frequency #1 330000000 38062306a36Sopenharmony_ci (0x00) Signal= -68.00dBm 38162306a36Sopenharmony_ci Scanning frequency #2 474000000 38262306a36Sopenharmony_ci Lock (0x1f) Signal= -34.45dBm C/N= 33.74dB UCB= 0 38362306a36Sopenharmony_ci Service Beethoven, provider LinuxTV.org: digital television 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ciFor more information on dvb-scan, check its documentation online here: 38662306a36Sopenharmony_ci`dvb-scan Documentation <https://www.linuxtv.org/wiki/index.php/Dvbscan>`_. 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ciUsing dvb-zap 38962306a36Sopenharmony_ci~~~~~~~~~~~~~ 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_cidvbv5-zap is a command line tool that can be used to record MPEG-TS to disk. The 39262306a36Sopenharmony_citypical use is to tune into a channel and put it into record mode. The example 39362306a36Sopenharmony_cibelow - which is taken from the documentation - illustrates that\ [1]_:: 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci $ dvbv5-zap -c dvb_channel.conf "beethoven" -o music.ts -P -t 10 39662306a36Sopenharmony_ci using demux 'dvb0.demux0' 39762306a36Sopenharmony_ci reading channels from file 'dvb_channel.conf' 39862306a36Sopenharmony_ci tuning to 474000000 Hz 39962306a36Sopenharmony_ci pass all PID's to TS 40062306a36Sopenharmony_ci dvb_set_pesfilter 8192 40162306a36Sopenharmony_ci dvb_dev_set_bufsize: buffer set to 6160384 40262306a36Sopenharmony_ci Lock (0x1f) Quality= Good Signal= -34.66dBm C/N= 33.41dB UCB= 0 postBER= 0 preBER= 1.05x10^-3 PER= 0 40362306a36Sopenharmony_ci Lock (0x1f) Quality= Good Signal= -34.57dBm C/N= 33.46dB UCB= 0 postBER= 0 preBER= 1.05x10^-3 PER= 0 40462306a36Sopenharmony_ci Record to file 'music.ts' started 40562306a36Sopenharmony_ci received 24587768 bytes (2401 Kbytes/sec) 40662306a36Sopenharmony_ci Lock (0x1f) Quality= Good Signal= -34.42dBm C/N= 33.89dB UCB= 0 postBER= 0 preBER= 2.44x10^-3 PER= 0 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ci.. [1] In this example, it records 10 seconds with all program ID's stored 40962306a36Sopenharmony_ci at the music.ts file. 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ciThe channel can be watched by playing the contents of the stream with some 41362306a36Sopenharmony_ciplayer that recognizes the MPEG-TS format, such as ``mplayer`` or ``vlc``. 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ciBy playing the contents of the stream one can visually inspect the workings of 41662306a36Sopenharmony_cividtv, e.g., to play a recorded TS file with:: 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci $ mplayer music.ts 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_cior, alternatively, running this command on one terminal:: 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci $ dvbv5-zap -c dvb_channel.conf "beethoven" -P -r & 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ciAnd, on a second terminal, playing the contents from DVR interface with:: 42562306a36Sopenharmony_ci 42662306a36Sopenharmony_ci $ mplayer /dev/dvb/adapter0/dvr0 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ciFor more information on dvb-zap check its online documentation here: 42962306a36Sopenharmony_ci`dvb-zap Documentation 43062306a36Sopenharmony_ci<https://www.linuxtv.org/wiki/index.php/Dvbv5-zap>`_. 43162306a36Sopenharmony_ciSee also: `zap <https://www.linuxtv.org/wiki/index.php/Zap>`_. 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ciWhat can still be improved in vidtv 43562306a36Sopenharmony_ci----------------------------------- 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ciAdd *debugfs* integration 43862306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~ 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ciAlthough frontend drivers provide DVBv5 statistics via the .read_status 44162306a36Sopenharmony_cicall, a nice addition would be to make additional statistics available to 44262306a36Sopenharmony_ciuserspace via debugfs, which is a simple-to-use, RAM-based filesystem 44362306a36Sopenharmony_cispecifically designed for debug purposes. 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ciThe logic for this would be implemented on a separate file so as not to 44662306a36Sopenharmony_cipollute the frontend driver. These statistics are driver-specific and can 44762306a36Sopenharmony_cibe useful during tests. 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_ciThe Siano driver is one example of a driver using 45062306a36Sopenharmony_cidebugfs to convey driver-specific statistics to userspace and it can be 45162306a36Sopenharmony_ciused as a reference. 45262306a36Sopenharmony_ci 45362306a36Sopenharmony_ciThis should be further enabled and disabled via a Kconfig 45462306a36Sopenharmony_cioption for convenience. 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ciAdd a way to test video 45762306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~ 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_ciCurrently, vidtv can only encode PCM audio. It would be great to implement 46062306a36Sopenharmony_cia barebones version of MPEG-2 video encoding so we can also test video. The 46162306a36Sopenharmony_cifirst place to look into is *ISO 13818-2: Information technology — Generic 46262306a36Sopenharmony_cicoding of moving pictures and associated audio information — Part 2: Video*, 46362306a36Sopenharmony_ciwhich covers the encoding of compressed video in MPEG Transport Streams. 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ciThis might optionally use the Video4Linux2 Test Pattern Generator, v4l2-tpg, 46662306a36Sopenharmony_ciwhich resides at:: 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci drivers/media/common/v4l2-tpg/ 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ciAdd white noise simulation 47262306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~ 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_ciThe vidtv tuner already has code to identify whether the chosen frequency 47562306a36Sopenharmony_ciis too far away from a table of valid frequencies. For now, this means that 47662306a36Sopenharmony_cithe demodulator can eventually lose the lock on the signal, since the tuner will 47762306a36Sopenharmony_cireport a bad signal quality. 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ciA nice addition is to simulate some noise when the signal quality is bad by: 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci- Randomly dropping some TS packets. This will trigger a continuity error if the 48262306a36Sopenharmony_ci continuity counter is updated but the packet is not passed on to the demux. 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci- Updating the error statistics accordingly (e.g. BER, etc). 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_ci- Simulating some noise in the encoded data. 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_ciFunctions and structs used within vidtv 48962306a36Sopenharmony_ci--------------------------------------- 49062306a36Sopenharmony_ci 49162306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_bridge.h 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_channel.h 49462306a36Sopenharmony_ci 49562306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_demod.h 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_encoder.h 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_mux.h 50062306a36Sopenharmony_ci 50162306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_pes.h 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_psi.h 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_s302m.h 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_ts.h 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_tuner.h 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_common.c 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci.. kernel-doc:: drivers/media/test-drivers/vidtv/vidtv_tuner.c 514