media: vidtv: implement a virtual DVB driver
Subsystems (2)
Daniel W. S. Almeida
maintainerv7 cover media: vidtv: implement a virtual DVB driver
From: "Daniel W. S. Almeida" <[email protected]>
This series is work in progress. It represents the current work done on a virtual DVB driver for the Linux media subsystem. I am new to the media subsystem and to kernel development in general.
This driver aims to:
- Serve as template for new DVB driver writers
- Help userspace application writers in general
- Push fake audio/video to userspace for testing purposes
- Push debug information to userspace via debugfs
The Virtual Digital TV Driver (vidtv)
Background
----------
Vidtv is a virtual DVB driver that aims to serve as a reference for driver writers by serving as a template. It also validates the existing media DVB APIs, thus helping userspace application writers.
Currently, it consists of:
- A fake tuner driver, which will report a bad signal quality if the chosen frequency is too far away from a table of valid frequencies for a particular delivery system.
- A fake demod driver, which will constantly poll the fake signal quality returned by the tuner, simulating a device that can lose/reacquire a lock on the signal depending on the CNR levels.
- A fake bridge driver, which is the module responsible for modprobing the fake tuner and demod modules and implementing the demux logic. This module takes parameters at initialization that will dictate how the simulation behaves.
- Code reponsible for encoding a valid MPEG Transport Stream, which is then passed to the bridge driver. This fake stream contains some hardcoded content. For now, we have a single, audio-only channel containing a single MPEG Elementary Stream, which in turn contains a SMPTE 302m encoded sine-wave. Note that this particular encoder was chosen because it is the easiest way to encode PCM audio data in a MPEG Transport Stream.
Building vidtv
--------------
vidtv is a test driver and thus is **not** enabled by default when compiling the kernel.
In order to enable compilation of vidtv:
- Enable **DVB_TEST_DRIVERS**, then
- Enable **DVB_VIDTV**
When compiled as a module, expect the following .ko files:
- dvb_vidtv_tuner.ko
- dvb_vidtv_demod.ko
- dvb_vidtv_bridge.ko
Running vidtv
-------------
When compiled as a module, run::
modprobe dvb_vidtv_bridge
That's it! The bridge driver will initialize the tuner and demod drivers as part of its own initialization.
You can optionally define some command-line arguments to vidtv, see the documentation for more info.
Testing vidtv with v4l-utils
============================
Start by installing v4l-utils and then modprobing vidtv::
modprobe dvb_vidtv_bridge
If the driver is OK, it should load and its probing code will run. This will pull in the tuner and demod drivers.
Using dvb-fe-tool
-----------------
The first step to check whether the demod loaded successfully is to run::
$ dvb-fe-tool
This should return what is currently set up at the demod struct, i.e.::
static const struct dvb_frontend_ops vidtv_demod_ops = {
.delsys = {
SYS_DVBT,
SYS_DVBT2,
SYS_DVBC_ANNEX_A,
SYS_DVBS,
SYS_DVBS2,
},
.info = {
.name = "Dummy demod for DVB-T/T2/C/S/S2",
.frequency_min_hz = 51 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 62500,
.frequency_tolerance_hz = 29500 * kHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 |
FE_CAN_FEC_5_6 |
FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 |
FE_CAN_FEC_8_9 |
FE_CAN_QAM_16 |
FE_CAN_QAM_64 |
FE_CAN_QAM_32 |
FE_CAN_QAM_128 |
FE_CAN_QAM_256 |
FE_CAN_QAM_AUTO |
FE_CAN_QPSK |
FE_CAN_FEC_AUTO |
FE_CAN_INVERSION_AUTO |
FE_CAN_TRANSMISSION_MODE_AUTO |
FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_HIERARCHY_AUTO,
}
....Using dvb-scan
--------------
In order to tune into a channel and read the PSI tables, we can use dvb-scan.
For this, one should provide a configuration file known as a 'scan file', here's an example::
[Channel]
FREQUENCY = 330000000
MODULATION = QAM/AUTO
SYMBOL_RATE = 6940000
INNER_FEC = AUTO
DELIVERY_SYSTEM = DVBC/ANNEX_A
NOTE:
The parameters depend on the video standard you're testing.
NOTE:
Vidtv is a fake driver and does not validate much of the information in the scan file. Just specifying 'FREQUENCY' and 'DELIVERY_SYSTEM' should be enough for DVB-T/DVB-T2. For DVB-S/DVB-C however, you should also provide 'SYMBOL_RATE'.
Assuming this channel is named 'channel.conf', you can then run::
$ dvbv5-scan dresden_dvbc_channel.conf
Using dvb-zap
-------------
dvbv5-zap is a command line tool that can be used to record MPEG-TS to disk. The typical use is to tune into a channel and put it into record mode. The example below - which is taken from the documentation - illustrates that::
$ 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 openedThe channel can be watched by playing the contents of the DVR interface, with some player that recognizes the MPEG-TS format, such as *mplayer* or *vlc*.
By playing the contents of the stream one can visually inspect the workings of vidtv, e.g.::
$ mplayer /dev/dvb/adapter0/dvr0
Changes in v7:
Collapse commits (10->4)
Add RestructuredText documentation
Fix checkpatch warnings
Add calls to dvb_module_release and i2c_del_adapter in the bridge driver Add kernel-doc comments
Changes in v6:
Addressed the following issues:
- Makefile was not actually compiling everything;
- The bridge driver should be a platform driver;
- There are lots of warnings and other errors produced by the driver.
Changes in v5:
Removed all calls to WARN_ON in favor of pr_warn_ratelimited Add a #define for pr_fmt
Reworked the byte swapping logic for big/little endian support:
big endian fields now prepended with __beXX for 'sparse' checks bitfields now laid in reverse order if LITTLE_ENDIAN_BITFIELD
is set
media: vidtv: implement a tuner driver
Return -EINVAL instead of -1 in vidtv_tuner_check_frequency_shift
media: vidtv: implement a demodulator driver
Add POLL_THRD_TIME #define
Implement dvb_frontend_ops as a single struct instead of three
media: vidtv: move config structs into a separate header
Removed this commit, configs are now in vidtv_tuner.h and vidtv_demod.h
media: vidtv: add a bridge driver
module_param: all fs permissions set to 0
removed param 'chosen_delsys'
module_param: removed "optional" string: all module_params are optional renamed vidtv_bridge -> vidtv_bridg: so the source code and module names
are different
media: vidtv: add wrappers for memcpy and memset
Added kernel-docs
write address is now computed internally
media: vidtv: add MPEG TS common code
Drop packets if the buffer is full
media: vidtv: implement a PSI generator
Removed vidtv_psi_ts_psi_write_stuffing()
Forcibly align misaligned buffers
Drop packets if buffer is full
media: vidtv: implement a PES packetizer
Remove vidtv_extract_bits() in favor of GENMASK() and bitwise & Forcibly align misaligned buffers
media: vidtv: Implement a SMPTE 302M encoder
Added kernel-docs for struct vidtv_encoder
media: vidtv: Add a MPEG Transport Stream Multiplexer
Added check for minimum and maximum buffer size.
Drop packets if buffer is full
Changes in v4:
Added a PES packetizer
Implemented a minimum version of the SMPTE 302m encoder for AES3 audio Fixed endianness in the PSI generator, converting fields to big endian where applicable Added a minimal TS mux abstraction
Changes in v3:
Added a bridge driver
Renamed the driver to vidtv
Renamed/reworked commits into smaller pieces
Moved the driver into its own directory
Fixed the code for the signal strength in the tuner
Removed useless enums in the tuner driver (e.g. lock_status, power_status...) Reworked the logic for the poll_snr thread in the demodulator driver Moved MPEG related code to the bridge driver, as it controls the demux logic Changed literals to #defines, used sizeof in place of integer literals when computing the size of PSI structs
Moved the MPEG PSI tables to the heap to reduce stack space usage Now using usleep_range in place of msleep_interruptible in the MPEG TS thread Wrapped memcpy and memset to protect against buffer overflow when writing to the MPEG TS buffer.
Changes in v2:
Attempted not to break assignments into multiple lines as much as possible. Code now passes checkpatch strict mode
media: dvb_dummy_tuner: implement driver skeleton Changed snr values to mili db
Return value from 0-100 to indicate how far off the requested frequency is from a valid one
Use the frequency shift to interpolate between 34dB and 10dB if we can not match against the SNR lookup table
Remove sleep calls for suspend/resume
Fix memcpy call for the config struct
media: dvb_dummy_fe.c: lose TS lock on bad snr Randomly recover the TS lock if the signal quality improves
media: dvb_dummy_fe.c: write PSI information into DMX buffer Split the patch into multiple header/source files
Hexadecimal literals are now lower case
Prefer short function names / reduce function signatures
Add #defines for constants when computing section lengths
Change signature for functions that take a dummy channel as argument (i.e. channels* is now channels[NUM_CHANNELS]) Daniel W. S. Almeida (4):
media: vidtv: implement a tuner driver
media: vidtv: implement a demodulator driver
media: vidtv: add a bridge driver
media: Documentation: vidtv: Add ReST documentation for vidtv
.../driver-api/media/drivers/index.rst | 1 + .../driver-api/media/drivers/vidtv.rst | 415 ++++++ MAINTAINERS | 8 + drivers/media/test-drivers/Kconfig | 16 + drivers/media/test-drivers/Makefile | 1 + drivers/media/test-drivers/vidtv/Kconfig | 11 + drivers/media/test-drivers/vidtv/Makefile | 9 + .../media/test-drivers/vidtv/vidtv_bridge.c | 520 ++++++++ .../media/test-drivers/vidtv/vidtv_bridge.h | 60 + .../media/test-drivers/vidtv/vidtv_channel.c | 327 +++++ .../media/test-drivers/vidtv/vidtv_channel.h | 82 ++ .../media/test-drivers/vidtv/vidtv_common.c | 86 ++ .../media/test-drivers/vidtv/vidtv_common.h | 34 + .../media/test-drivers/vidtv/vidtv_demod.c | 440 +++++++ .../media/test-drivers/vidtv/vidtv_demod.h | 73 ++ .../media/test-drivers/vidtv/vidtv_encoder.h | 103 ++ drivers/media/test-drivers/vidtv/vidtv_mux.c | 437 +++++++ drivers/media/test-drivers/vidtv/vidtv_mux.h | 157 +++ drivers/media/test-drivers/vidtv/vidtv_pes.c | 450 +++++++ drivers/media/test-drivers/vidtv/vidtv_pes.h | 243 ++++ drivers/media/test-drivers/vidtv/vidtv_psi.c | 1160 +++++++++++++++++ drivers/media/test-drivers/vidtv/vidtv_psi.h | 674 ++++++++++ .../media/test-drivers/vidtv/vidtv_s302m.c | 643 +++++++++ .../media/test-drivers/vidtv/vidtv_s302m.h | 141 ++ drivers/media/test-drivers/vidtv/vidtv_ts.c | 165 +++ drivers/media/test-drivers/vidtv/vidtv_ts.h | 138 ++ .../media/test-drivers/vidtv/vidtv_tuner.c | 427 ++++++ .../media/test-drivers/vidtv/vidtv_tuner.h | 43 + 28 files changed, 6864 insertions(+) create mode 100644 Documentation/driver-api/media/drivers/vidtv.rst create mode 100644 drivers/media/test-drivers/vidtv/Kconfig create mode 100644 drivers/media/test-drivers/vidtv/Makefile create mode 100644 drivers/media/test-drivers/vidtv/vidtv_bridge.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_bridge.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_channel.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_channel.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_common.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_common.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_demod.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_demod.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_encoder.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_mux.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_mux.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_pes.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_pes.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_psi.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_psi.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_s302m.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_s302m.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_ts.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_ts.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_tuner.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_tuner.h
Signature · 1 line
2.27.0
Daniel W. S. Almeida
maintainerRFC v7 1/4 media: vidtv: implement a tuner driver
From: "Daniel W. S. Almeida" <[email protected]>
The virtual DVB test driver serves as a reference DVB driver and helps validate the existing APIs in the media subsystem. It can also aid developers working on userspace applications.
This dummy tuner should support common TV standards such as DVB-T/T2/S/S2, ISDB-T and ATSC when completed.
--- MAINTAINERS | 8 + drivers/media/test-drivers/Kconfig | 16 + drivers/media/test-drivers/Makefile | 1 + drivers/media/test-drivers/vidtv/Kconfig | 11 + drivers/media/test-drivers/vidtv/Makefile | 5 + .../media/test-drivers/vidtv/vidtv_tuner.c | 427 ++++++++++++++++++ .../media/test-drivers/vidtv/vidtv_tuner.h | 43 ++ 7 files changed, 511 insertions(+) create mode 100644 drivers/media/test-drivers/vidtv/Kconfig create mode 100644 drivers/media/test-drivers/vidtv/Makefile create mode 100644 drivers/media/test-drivers/vidtv/vidtv_tuner.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_tuner.h
MAINTAINERS +8 -0
@@ -18043,6 +18043,14 @@ W: https://linuxtv.org T: git git://linuxtv.org/media_tree.git F: drivers/media/test-drivers/vivid/* +VIDTV VIRTUAL DIGITAL TV DRIVER +M: Daniel W. S. Almeida <[email protected]> +L: [email protected] +S: Maintained +W: https://linuxtv.org +T: git git://linuxtv.org/media_tree.git +F: drivers/media/test-drivers/vidtv/* + VLYNQ BUS M: Florian Fainelli <[email protected]> L: [email protected] (subscribers-only)
drivers/media/test-drivers/Kconfig +16 -0
@@ -4,6 +4,16 @@ menuconfig V4L_TEST_DRIVERS bool "V4L test drivers" depends on VIDEO_DEV +menuconfig DVB_TEST_DRIVERS + bool "DVB test drivers" + depends on DVB_CORE && MEDIA_SUPPORT && I2C + help + Enables DVB test drivers. + + This enables the DVB test drivers. They are meant as an aid for + DVB device driver writers and developers working on userspace + media applications. + if V4L_TEST_DRIVERS source "drivers/media/test-drivers/vimc/Kconfig"
@@ -24,3 +34,9 @@ config VIDEO_VIM2M source "drivers/media/test-drivers/vicodec/Kconfig" endif #V4L_TEST_DRIVERS + +if DVB_TEST_DRIVERS + +source "drivers/media/test-drivers/vidtv/Kconfig" + +endif #DVB_TEST_DRIVERS
drivers/media/test-drivers/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_VIDEO_VIMC) += vimc/ obj-$(CONFIG_VIDEO_VIVID) += vivid/ obj-$(CONFIG_VIDEO_VIM2M) += vim2m.o obj-$(CONFIG_VIDEO_VICODEC) += vicodec/ +obj-$(CONFIG_DVB_VIDTV) += vidtv/
drivers/media/test-drivers/vidtv/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only +config DVB_VIDTV + tristate "Virtual DVB Driver (vidtv)" + depends on DVB_CORE && MEDIA_SUPPORT && I2C + help + The virtual DVB test driver serves as a reference DVB driver and helps + validate the existing APIs in the media subsystem. It can also aid developers + working on userspace applications. + + + When in doubt, say N.
drivers/media/test-drivers/vidtv/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +dvb-vidtv-tuner-objs := vidtv_tuner.o + +obj-$(CONFIG_DVB_VIDTV) += dvb-vidtv-tuner.o
drivers/media/test-drivers/vidtv/vidtv_tuner.c new file +427 -0
427 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_tuner.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.27.0
Daniel W. S. Almeida
maintainerRFC v7 2/4 media: vidtv: implement a demodulator driver
In reply to Daniel W. S. AlmeidaFrom: "Daniel W. S. Almeida" <[email protected]>
Implement a I2C demodulator driver, simulating support for DVB-T, DVB-C and DVB-S.
This demodulator will periodically check the signal quality against a table and drop the TS lock if it drops below a threshold value, regaining it in the event that the signal improves.
--- drivers/media/test-drivers/vidtv/Makefile | 3 +- .../media/test-drivers/vidtv/vidtv_demod.c | 440 ++++++++++++++++++ .../media/test-drivers/vidtv/vidtv_demod.h | 73 +++ 3 files changed, 515 insertions(+), 1 deletion(-) create mode 100644 drivers/media/test-drivers/vidtv/vidtv_demod.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_demod.h
drivers/media/test-drivers/vidtv/Makefile +2 -1
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 dvb-vidtv-tuner-objs := vidtv_tuner.o +dvb-vidtv-demod-objs := vidtv_demod.o -obj-$(CONFIG_DVB_VIDTV) += dvb-vidtv-tuner.o +obj-$(CONFIG_DVB_VIDTV) += dvb-vidtv-tuner.o dvb-vidtv-demod.o
drivers/media/test-drivers/vidtv/vidtv_demod.c new file +440 -0
440 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_demod.h new file +73 -0
73 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Daniel W. S. Almeida
maintainerRFC v7 3/4 media: vidtv: add a bridge driver
In reply to Daniel W. S. AlmeidaFrom: "Daniel W. S. Almeida" <[email protected]>
Digital TV devices consist of several independent hardware components which are controlled by different drivers.
Each media device is controlled by a group of cooperating drivers with the bridge driver as the main driver.
This patch adds a bridge driver for the Virtual Digital TV driver [vidtv].
The bridge driver binds to the other drivers, that is, vidtv_tuner and vidtv_demod and implements the digital demux logic, providing userspace with a MPEG Transport Stream.
The MPEG related code is split in the following way:
- vidtv_ts: code to work with MPEG TS packets, such as TS headers, adaptation fields, PCR packets and NULL packets.
- vidtv_psi: this is the PSI generator.
PSI packets contain general information about a MPEG Transport Stream. A PSI generator is needed so userspace apps can retrieve information about the Transport Stream and eventually tune into a (dummy) channel.
Because the generator is implemented in a separate file, it can be reused elsewhere in the media subsystem.
Currently vidtv supports working with 3 PSI tables:
PAT, PMT and SDT.
- vidtv_pes: implements the PES logic to convert encoder data into MPEG TS packets. These can then be fed into a TS multiplexer and eventually into userspace.
- vidtv_s302m: implements a S302M encoder to make it possible to insert PCM audio data in the generated MPEG Transport Stream.
This shall enable passing an audio signal into userspace so it can be decoded and played by media software.
- vidtv_channels: Implements a 'channel' abstraction
When vidtv boots, it will create some hardcoded channels:
Their services will be concatenated to populate the SDT. Their programs will be concatenated to populate the PAT For each program in the PAT, a PMT section will be created The PMT section for a channel will be assigned its streams. Every stream will have its corresponding encoder polled to produce TS packets
These packets may be interleaved by the mux and then delivered to the bridge
- vidtv_mux - Implements a MPEG TS mux, loosely based on the ffmpeg implementation
The multiplexer is responsible for polling encoders, interleaving packets, padding the resulting stream with NULL packets if necessary and then delivering the resulting TS packets to the bridge driver so it can feed the demux.
--- drivers/media/test-drivers/vidtv/Makefile | 5 +- .../media/test-drivers/vidtv/vidtv_bridge.c | 520 ++++++++ .../media/test-drivers/vidtv/vidtv_bridge.h | 60 + .../media/test-drivers/vidtv/vidtv_channel.c | 327 +++++ .../media/test-drivers/vidtv/vidtv_channel.h | 82 ++ .../media/test-drivers/vidtv/vidtv_common.c | 86 ++ .../media/test-drivers/vidtv/vidtv_common.h | 34 + .../media/test-drivers/vidtv/vidtv_encoder.h | 103 ++ drivers/media/test-drivers/vidtv/vidtv_mux.c | 437 +++++++ drivers/media/test-drivers/vidtv/vidtv_mux.h | 157 +++ drivers/media/test-drivers/vidtv/vidtv_pes.c | 450 +++++++ drivers/media/test-drivers/vidtv/vidtv_pes.h | 243 ++++ drivers/media/test-drivers/vidtv/vidtv_psi.c | 1160 +++++++++++++++++ drivers/media/test-drivers/vidtv/vidtv_psi.h | 674 ++++++++++ .../media/test-drivers/vidtv/vidtv_s302m.c | 643 +++++++++ .../media/test-drivers/vidtv/vidtv_s302m.h | 141 ++ drivers/media/test-drivers/vidtv/vidtv_ts.c | 165 +++ drivers/media/test-drivers/vidtv/vidtv_ts.h | 138 ++ 18 files changed, 5424 insertions(+), 1 deletion(-) create mode 100644 drivers/media/test-drivers/vidtv/vidtv_bridge.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_bridge.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_channel.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_channel.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_common.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_common.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_encoder.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_mux.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_mux.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_pes.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_pes.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_psi.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_psi.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_s302m.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_s302m.h create mode 100644 drivers/media/test-drivers/vidtv/vidtv_ts.c create mode 100644 drivers/media/test-drivers/vidtv/vidtv_ts.h
drivers/media/test-drivers/vidtv/Makefile +4 -1
@@ -2,5 +2,8 @@ dvb-vidtv-tuner-objs := vidtv_tuner.o dvb-vidtv-demod-objs := vidtv_demod.o +dvb-vidtv-bridge-objs := vidtv_bridge.o vidtv_common.o vidtv_ts.o vidtv_psi.o \ + vidtv_pes.o vidtv_s302m.o vidtv_channel.o vidtv_mux.o -obj-$(CONFIG_DVB_VIDTV) += dvb-vidtv-tuner.o dvb-vidtv-demod.o +obj-$(CONFIG_DVB_VIDTV) += dvb-vidtv-tuner.o dvb-vidtv-demod.o \ + dvb-vidtv-bridge.o
drivers/media/test-drivers/vidtv/vidtv_bridge.c new file +520 -0
520 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_bridge.h new file +60 -0
60 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_channel.c new file +327 -0
327 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_channel.h new file +82 -0
82 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_common.c new file +86 -0
86 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* The Virtual DVB test driver serves as a reference DVB driver and helps +* validate the existing APIs in the media subsystem. It can also aid +* developers working on userspace applications. +* +* Copyright (C) 2020 Daniel W. S. Almeida +*/ + +#ifndef VIDTV_COMMON_H +#define VIDTV_COMMON_H + +#include <linux/types.h> + +#define CLOCK_UNIT_90KHZ 90000 +#define CLOCK_UNIT_27MHZ 27000000 +#define SLEEP_USECS 10000 +#define TRANSPORT_STREAM_ID 0x744 + +u32 vidtv_memcpy (void *to, +size_t to_offset, +size_t to_size, +const void *from, +size_t len); + +u32 vidtv_memset (void *to, +size_t to_offset, +size_t to_size, +int c, +size_t len); + +u64 vidtv_extract_bits (u64 value,u8 start_bit,u8 nbits); + +#endif // VIDTV_COMMON_H
drivers/media/test-drivers/vidtv/vidtv_encoder.h new file +103 -0
103 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +437 -0
437 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_mux.h new file +157 -0
157 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_pes.c new file +450 -0
450 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_pes.h new file +243 -0
243 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_psi.c new file +1160 -0
492 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_psi.h new file +674 -0
674 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_s302m.c new file +643 -0
643 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_s302m.h new file +141 -0
141 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_ts.c new file +165 -0
165 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_ts.h new file +138 -0
138 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.27.0
Part of the diff is not shown here. View the raw message.
kernel test robot
build botRe: [RFC, WIP, v7 3/4] media: vidtv: add a bridge driver
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi "Daniel,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on linus/master next-20200608]
[cannot apply to linux/master v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-W-S-Almeida/media-vidtv-implement-a-virtual-DVB-driver/20200609-031704 base: git://linuxtv.org/media_tree.git master config: m68k-allmodconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
In file included from include/linux/bitops.h:5,
from include/linux/kernel.h:12,
from include/linux/list.h:9,
from include/linux/rculist.h:10,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/ratelimit.h:6,
from drivers/media/test-drivers/vidtv/vidtv_pes.c:18:drivers/media/test-drivers/vidtv/vidtv_pes.c: In function 'vidtv_pes_write_pts_dts':
>> include/linux/bits.h:37:11: warning: right shift count is negative [-Wshift-count-negative] 37 | (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) | ^~ >> include/linux/bits.h:39:31: note: in expansion of macro '__GENMASK' 39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) | ^~~~~~~~~ >> drivers/media/test-drivers/vidtv/vidtv_pes.c:96:33: note: in expansion of macro 'GENMASK' 96 | pts_dts.pts1 = (args.pts & GENMASK(32, 30)) >> 30; | ^~~~~~~ >> include/linux/bits.h:37:11: warning: right shift count is negative [-Wshift-count-negative] 37 | (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) | ^~ >> include/linux/bits.h:39:31: note: in expansion of macro '__GENMASK'
39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~drivers/media/test-drivers/vidtv/vidtv_pes.c:105:33: note: in expansion of macro 'GENMASK'
105 | pts_dts.dts1 = (args.dts & GENMASK(32, 30)) >> 30;
| ^~~~~~~
>> include/linux/bits.h:37:11: warning: right shift count is negative [-Wshift-count-negative] 37 | (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) | ^~ >> include/linux/bits.h:39:31: note: in expansion of macro '__GENMASK'
39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~drivers/media/test-drivers/vidtv/vidtv_pes.c:117:33: note: in expansion of macro 'GENMASK'
117 | pts_dts.pts1 = (args.pts & GENMASK(32, 30)) >> 30;
| ^~~~~~~
vim +/GENMASK +96 drivers/media/test-drivers/vidtv/vidtv_pes.c
15
16 #include <linux/types.h>
17 #include <linux/printk.h>
> 18 #include <linux/ratelimit.h>
19
20 #include "vidtv_pes.h"
21 #include "vidtv_common.h"
22 #include "vidtv_ts.h"
23
24 #define PRIVATE_STREAM_1_ID 0xbd /* private_stream_1. See SMPTE 302M-2007 p.6 */
25 #define PES_HEADER_MAX_STUFFING_BYTES 32
26 #define PES_TS_HEADER_MAX_STUFFING_BYTES 182
27
28 static u32 vidtv_pes_op_get_regular_len(bool send_pts, bool send_dts)
29 {
30 u32 len = 0;
31
32 /* the flags must always be sent */
33 len += sizeof(struct vidtv_pes_optional);
34
35 /* From all optionals, we might send these for now */
36 if (send_pts && send_dts)
37 len += sizeof(struct vidtv_pes_optional_pts_dts);
38 else if (send_pts)
39 len += sizeof(struct vidtv_pes_optional_pts);
40
41 return len;
42 }
43
44 static u32 vidtv_pes_h_get_regular_len(bool send_pts, bool send_dts)
45 {
46 /* PES header length notwithstanding stuffing bytes */
47 u32 len = 0;
48
49 len += sizeof(struct vidtv_mpeg_pes);
50 len += vidtv_pes_op_get_regular_len(send_pts, send_dts);
51
52 return len;
53 }
54
55 static u32 vidtv_pes_write_header_stuffing(struct vidtv_mpeg_pes *pes_h,
56 struct pes_header_write_args args)
57 {
58 /*
59 * This is a fixed 8-bit value equal to '1111 1111' that can be inserted
60 * by the encoder, for example to meet the requirements of the channel.
61 * It is discarded by the decoder. No more than 32 stuffing bytes shall
62 * be present in one PES packet header.
63 */
64 if (args.n_pes_h_s_bytes > PES_HEADER_MAX_STUFFING_BYTES) {
65 pr_warn_ratelimited("More than 32 stuffing bytes in PES packet header\n");
66 args.n_pes_h_s_bytes = PES_HEADER_MAX_STUFFING_BYTES;
67 }
68
69 /* gives the length of the remainder of the PES header in bytes */
70 pes_h->length += args.n_pes_h_s_bytes;
71
72 return vidtv_memset(args.dest_buf,
73 args.dest_offset,
74 args.dest_buf_sz,
75 TS_FILL_BYTE,
76 args.n_pes_h_s_bytes);
77 }
78
79 static u32 vidtv_pes_write_pts_dts(struct pes_header_write_args args)
80 {
81 u32 nbytes = 0; /* the number of bytes written by this function */
82
83 struct vidtv_pes_optional_pts pts = {};
84 struct vidtv_pes_optional_pts_dts pts_dts = {};
85 void *op = NULL;
86 size_t op_sz = 0;
87
88 if (!args.send_pts && args.send_dts)
89 return 0;
90
91 /* see ISO/IEC 13818-1 : 2000 p. 32 */
92
93 if (args.send_pts && args.send_dts) {
94 pts_dts.three = 0x3;
95
> 96 pts_dts.pts1 = (args.pts & GENMASK(32, 30)) >> 30;
97 pts_dts.marker1 = 0x1;
98 pts_dts.pts2 = (args.pts & GENMASK(29, 15)) >> 15;
99 pts_dts.marker2 = 0x1;
100 pts_dts.pts3 = args.pts & GENMASK(14, 0);
101 pts_dts.marker3 = 0x1;
102
103 pts_dts.one = 0x1;
104
105 pts_dts.dts1 = (args.dts & GENMASK(32, 30)) >> 30;
106 pts_dts.marker1 = 0x1;
107 pts_dts.dts2 = (args.dts & GENMASK(29, 15)) >> 15;
108 pts_dts.marker2 = 0x1;
109 pts_dts.dts3 = args.dts & GENMASK(14, 0);
110 pts_dts.marker3 = 0x1;
111
112 op = &pts_dts;
113 op_sz = sizeof(pts_dts);
114
115 } else if (args.send_pts) {
116 pts.two = 0x2;
117 pts_dts.pts1 = (args.pts & GENMASK(32, 30)) >> 30;
118 pts_dts.marker1 = 0x1;
119 pts_dts.pts2 = (args.pts & GENMASK(29, 15)) >> 15;
120 pts_dts.marker2 = 0x1;
121 pts_dts.pts3 = args.pts & GENMASK(14, 0);
122 pts_dts.marker3 = 0x1;
123
124 op = &pts;
125 op_sz = sizeof(pts);
126 }
127
128 /* copy PTS/DTS optional */
129 nbytes += vidtv_memcpy(args.dest_buf,
130 args.dest_offset + nbytes,
131 args.dest_buf_sz,
132 op,
133 op_sz); 134
135 return nbytes;
136 }
137
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [RFC, WIP, v7 3/4] media: vidtv: add a bridge driver
In reply to Daniel W. S. Almeida[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi "Daniel,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linuxtv-media/master]
[cannot apply to linux/master v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-W-S-Almeida/media-vidtv-implement-a-virtual-DVB-driver/20200609-031704 base: git://linuxtv.org/media_tree.git master config: mips-allyesconfig (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
mips-linux-ld: drivers/media/test-drivers/vidtv/vidtv_mux.o: in function `vidtv_mux_tick':
>> vidtv_mux.c:(.text.vidtv_mux_tick+0x83c): undefined reference to `__udivdi3' >> mips-linux-ld: vidtv_mux.c:(.text.vidtv_mux_tick+0x864): undefined reference to `__udivdi3'
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Daniel W. S. Almeida
maintainerRFC v7 4/4 media: Documentation: vidtv: Add ReST documentation for vidtv
In reply to Daniel W. S. AlmeidaFrom: "Daniel W. S. Almeida" <[email protected]>
Add documentation for the Virtual Digital TV driver (vidtv) in the Restructured Text (ReST) format.
This discusses:
- What is vidtv
- Why vidtv is needed
- How to build and run vidtv
- How vidtv is structured
- How to test vidtv
- How to improve vidtv
--- .../driver-api/media/drivers/index.rst | 1 + .../driver-api/media/drivers/vidtv.rst | 415 ++++++++++++++++++ 2 files changed, 416 insertions(+) create mode 100644 Documentation/driver-api/media/drivers/vidtv.rst
Documentation/driver-api/media/drivers/index.rst +1 -0
@@ -35,4 +35,5 @@ Digital TV drivers dvb-usb frontends + vidtv contributors
Documentation/driver-api/media/drivers/vidtv.rst new file +415 -0
415 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Hi Mauro,
Quoted 6 lines · Daniel W. S. Almeida
From: "Daniel W. S. Almeida" <[email protected]>
This series is work in progress. It represents the current work done on a virtual DVB driver for the Linux media subsystem. I am new to the media subsystem and to kernel development in general.
Quoted 7 lines
This driver aims to:
- Serve as template for new DVB driver writers
- Help userspace application writers in general
- Push fake audio/video to userspace for testing purposes
- Push debug information to userspace via debugfs
The Virtual Digital TV Driver (vidtv)
Any feedback on this patch series for Daniel. He has been waiting for reviews and feedback from media developers for a while now.
Please review the patches and give him feedback and help him with next steps.
thanks,
-- Shuah
Em Fri, 24 Jul 2020 17:43:55 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 17 lines
Hi Mauro,
Quoted 6 lines · Daniel W. S. Almeida
From: "Daniel W. S. Almeida" <[email protected]>
This series is work in progress. It represents the current work done on a virtual DVB driver for the Linux media subsystem. I am new to the media subsystem and to kernel development in general.
Quoted 7 lines
This driver aims to:
- Serve as template for new DVB driver writers
- Help userspace application writers in general
- Push fake audio/video to userspace for testing purposes
- Push debug information to userspace via debugfs
The Virtual Digital TV Driver (vidtv)
Quoted 5 lines
Any feedback on this patch series for Daniel. He has been waiting for reviews and feedback from media developers for a while now.
Please review the patches and give him feedback and help him with next steps.
I'll seek for some time to look and review them next week.
What's the current status of it? Is it probing properly and working fine, or are there any known bugs at the code?
Thanks,
Mauro