media: vidtv: Implement a virtual DVB driver
Subsystems (2)
Daniel W. S. Almeida
maintainerv10 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
Current state for this driver:
- Driver generates PSI information (PAT, PMT, SDT)
- Driver generates PCR packets
- Driver generates NULL packets for padding
- PCM audio stream is decoded by ffmpeg, but no audio is heard yet.
changes in v10:
s302m encoder got reworked
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
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 | 417 +++++ 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 | 546 +++++++ .../media/test-drivers/vidtv/vidtv_bridge.h | 60 + .../media/test-drivers/vidtv/vidtv_channel.c | 306 ++++ .../media/test-drivers/vidtv/vidtv_channel.h | 76 + .../media/test-drivers/vidtv/vidtv_common.c | 89 ++ .../media/test-drivers/vidtv/vidtv_common.h | 33 + .../media/test-drivers/vidtv/vidtv_demod.c | 440 ++++++ .../media/test-drivers/vidtv/vidtv_demod.h | 73 + .../media/test-drivers/vidtv/vidtv_encoder.h | 96 ++ drivers/media/test-drivers/vidtv/vidtv_mux.c | 479 ++++++ drivers/media/test-drivers/vidtv/vidtv_mux.h | 160 ++ drivers/media/test-drivers/vidtv/vidtv_pes.c | 398 +++++ drivers/media/test-drivers/vidtv/vidtv_pes.h | 189 +++ drivers/media/test-drivers/vidtv/vidtv_psi.c | 1352 +++++++++++++++++ drivers/media/test-drivers/vidtv/vidtv_psi.h | 593 ++++++++ .../media/test-drivers/vidtv/vidtv_s302m.c | 552 +++++++ .../media/test-drivers/vidtv/vidtv_s302m.h | 90 ++ drivers/media/test-drivers/vidtv/vidtv_ts.c | 137 ++ drivers/media/test-drivers/vidtv/vidtv_ts.h | 130 ++ .../media/test-drivers/vidtv/vidtv_tuner.c | 427 ++++++ .../media/test-drivers/vidtv/vidtv_tuner.h | 43 + 28 files changed, 6732 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.28.0
Daniel W. S. Almeida
maintainerPATCH v10 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
@@ -18291,6 +18291,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
--
2.28.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Daniel W. S. Almeida
maintainerPATCH v10 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
--
2.28.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Daniel W. S. Almeida
maintainerPATCH v10 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 | 546 +++++++ .../media/test-drivers/vidtv/vidtv_bridge.h | 60 + .../media/test-drivers/vidtv/vidtv_channel.c | 306 ++++ .../media/test-drivers/vidtv/vidtv_channel.h | 76 + .../media/test-drivers/vidtv/vidtv_common.c | 89 ++ .../media/test-drivers/vidtv/vidtv_common.h | 33 + .../media/test-drivers/vidtv/vidtv_encoder.h | 96 ++ drivers/media/test-drivers/vidtv/vidtv_mux.c | 479 ++++++ drivers/media/test-drivers/vidtv/vidtv_mux.h | 160 ++ drivers/media/test-drivers/vidtv/vidtv_pes.c | 398 +++++ drivers/media/test-drivers/vidtv/vidtv_pes.h | 189 +++ drivers/media/test-drivers/vidtv/vidtv_psi.c | 1352 +++++++++++++++++ drivers/media/test-drivers/vidtv/vidtv_psi.h | 593 ++++++++ .../media/test-drivers/vidtv/vidtv_s302m.c | 552 +++++++ .../media/test-drivers/vidtv/vidtv_s302m.h | 90 ++ drivers/media/test-drivers/vidtv/vidtv_ts.c | 137 ++ drivers/media/test-drivers/vidtv/vidtv_ts.h | 130 ++ 18 files changed, 5290 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 +546 -0
546 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 +306 -0
306 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_channel.h new file +76 -0
76 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_common.c new file +89 -0
89 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_common.h new file +33 -0
@@ -0,0 +1,33 @@ +/* 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 VIDTV_SLEEP_USECS 10000 +#define VIDTV_MAX_SLEEP_USECS (2 * VIDTV_SLEEP_USECS) +#define VIDTV_DEFAULT_TS_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); + +#endif // VIDTV_COMMON_H
drivers/media/test-drivers/vidtv/vidtv_encoder.h new file +96 -0
96 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +479 -0
479 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_mux.h new file +160 -0
160 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_pes.c new file +398 -0
398 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_pes.h new file +189 -0
189 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_psi.c new file +1352 -0
559 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_psi.h new file +593 -0
593 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_s302m.c new file +552 -0
552 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_s302m.h new file +90 -0
90 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_ts.c new file +137 -0
137 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_ts.h new file +130 -0
130 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
--
2.28.0
Part of the diff is not shown here. View the raw message.
Re: [v10 3/4] media: vidtv: add a bridge driver
Hi Daniel,
Quoted 8 lines · Daniel W. S. Almeida
From: "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].
This is now commit f90cf6079bf67988 ("media: vidtv: add a bridge driver") in the media tree.
[email protected] reported the following error for an m68k allmodconfig build:
ERROR: modpost: "__udivdi3" [drivers/media/test-drivers/vidtv/dvb-vidtv-bridge.ko] undefined!
Presumably this fails on other 32-bit platforms, too.
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +8
-0+static u32 vidtv_mux_check_mux_rate (struct vidtv_mux *m) +{ +/* +* attempt to maintain a constant mux rate, padding with null packets +* if needed +*/ + +u32 nbytes =0 ;/* the number of bytes written by this function */
drivers/media/test-drivers/vidtv/vidtv_mux.c line 356
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +10
-0+ +u64 nbytes_expected;/* the number of bytes we should have written */ +u64 nbytes_streamed;/* the number of bytes we actually wrote */ +u32 num_null_pkts;/* number of null packets to bridge the gap */ + +u64 elapsed_time_msecs =jiffies_to_usecs (m->timing.current_jiffies - + m->timing.past_jiffies); + + elapsed_time_msecs =min (elapsed_time_msecs, (u64 )VIDTV_MAX_SLEEP_USECS /1000 ); + nbytes_expected =div64_u64 (m->mux_rate_kbytes_sec *1000 ,MSEC_PER_SEC );
Seriously?!?
You multiply by 1000 first, followed by a division by 1000 using an expensive 64-by-64 division?
drivers/media/test-drivers/vidtv/vidtv_mux.c line 363
Quoted 7 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +7
-0+ nbytes_expected *= elapsed_time_msecs; + + nbytes_streamed = m->mux_buf_offset; + +if (nbytes_streamed < nbytes_expected) { +/* can't write half a packet: roundup to a 188 multiple */ + nbytes_expected =roundup (nbytes_expected - nbytes_streamed,TS_PACKET_LEN );
drivers/media/test-drivers/vidtv/vidtv_mux.o: In function `vidtv_mux_tick':
vidtv_mux.c:(.text+0x788): undefined reference to `__udivdi3'
This is a 64-by-32 division, hence it should use a helper from <linux/math64.h>.
However, I'm wondering if "nbytes_expected - nbytes_streamed" is guaranteed to be a "small" number, hence a 32-by-32 division would be sufficient?
drivers/media/test-drivers/vidtv/vidtv_mux.c line 364
Quoted 1 line
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +1
-0+ num_null_pkts = nbytes_expected /TS_PACKET_LEN ;
Likewise.
Quoted 8 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +5
-0+ nbytes +=vidtv_mux_pad_with_nulls (m, num_null_pkts); + } + +return nbytes; +}
drivers/media/test-drivers/vidtv/vidtv_s302m.c line 293
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_s302m.c new file +10
-0+static void vidtv_s302m_compute_pts (struct vidtv_encoder *e) +{ +u64 count = e->sample_count; +struct vidtv_access_unit *au = e->access_units; + +while (au) { + count += au->num_samples; + + au->pts = count * +CLOCK_UNIT_90KHZ / e->sampling_rate_hz;
drivers/media/test-drivers/vidtv/vidtv_s302m.o: In function `vidtv_s302m_encode':
vidtv_s302m.c:(.text+0x2ac): undefined reference to `__udivdi3'
Likewise.
drivers/media/test-drivers/vidtv/vidtv_s302m.c
Quoted 4 lines
drivers/media/test-drivers/vidtv/vidtv_s302m.c new file +4
-0+ + au = au->next; + } +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Daniel W. S. Almeida
maintainerRe: [v10 3/4] media: vidtv: add a bridge driver
Hi Geert,
Thanks for bringing this to my attention.
Quoted 15 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c line 356
Quoted 12 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +10
-0+u32 nbytes =0 ;/* the number of bytes written by this function */ + +u64 nbytes_expected;/* the number of bytes we should have written */ +u64 nbytes_streamed;/* the number of bytes we actually wrote */ +u32 num_null_pkts;/* number of null packets to bridge the gap */ + +u64 elapsed_time_msecs =jiffies_to_usecs (m->timing.current_jiffies - + m->timing.past_jiffies); + + elapsed_time_msecs = min(elapsed_time_msecs,(u64)VIDTV_MAX_SLEEP_USECS / 1000);
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +1
-0+ nbytes_expected =div64_u64 (m->mux_rate_kbytes_sec *1000 ,MSEC_PER_SEC );Seriously?!?
Quoted 2 lines
You multiply by 1000 first, followed by a division by 1000 using an expensive 64-by-64 division?
This entire function is broken and needs a do-over :)
Quoted 1 line
using an expensive 64-by-64 division?
I am new to kernel development. I wasn't even aware that this was expensive, to be honest.
Quoted 7 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c line 363
Quoted 3 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +3
-0+if (nbytes_streamed < nbytes_expected) { +/* can't write half a packet: roundup to a 188 multiple */ + nbytes_expected =roundup (nbytes_expected - nbytes_streamed,TS_PACKET_LEN );
drivers/media/test-drivers/vidtv/vidtv_mux.o: In function `vidtv_mux_tick':
vidtv_mux.c:(.text+0x788): undefined reference to `__udivdi3'
Quoted 6 lines
This is a 64-by-32 division, hence it should use a helper from <
linux/math64.h>.However, I'm wondering if "
nbytes_expected-nbytes_streamed" is guaranteed to be a "small" number, hence a 32-by-32 division would be sufficient?
I think so.
I will send a patch to address the things you pointed out in this email.
-- thanks
-- Daniel
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [v10 3/4] media: vidtv: add a bridge driver
Hi Daniel,
Quoted 18 lines · Daniel W. S. Almeida
Quoted 15 lines
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +10
-0+u32 nbytes =0 ;/* the number of bytes written by this function */ + +u64 nbytes_expected;/* the number of bytes we should have written */ +u64 nbytes_streamed;/* the number of bytes we actually wrote */ +u32 num_null_pkts;/* number of null packets to bridge the gap */ + +u64 elapsed_time_msecs =jiffies_to_usecs (m->timing.current_jiffies - + m->timing.past_jiffies); + + elapsed_time_msecs = min(elapsed_time_msecs,Quoted 2 lines
(u64)VIDTV_MAX_SLEEP_USECS / 1000);
+nbytes_expected=div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);Seriously?!?
Quoted 2 lines
You multiply by 1000 first, followed by a division by 1000 using an expensive 64-by-64 division?
Quoted 6 lines
This entire function is broken and needs a do-over :)
Quoted 1 line
using an expensive 64-by-64 division?
I am new to kernel development. I wasn't even aware that this was expensive, to be honest.
All divisions involving 64-bit data are expensive, especially on 32-bit platforms. That's why we have the helpers in <linux/math.h>. Most of them implement simplified variants, which are less expensive.
Quoted 10 lines
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c line 363
Quoted 3 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +3
-0+if (nbytes_streamed < nbytes_expected) { +/* can't write half a packet: roundup to a 188 multiple */ + nbytes_expected =roundup (nbytes_expected - nbytes_streamed,TS_PACKET_LEN );
drivers/media/test-drivers/vidtv/vidtv_mux.o: In function `vidtv_mux_tick':
vidtv_mux.c:(.text+0x788): undefined reference to `__udivdi3'This is a 64-by-32 division, hence it should use a helper from <
linux/math64.h>.
Quoted 7 lines
Quoted 3 lines
However, I'm wondering if "
nbytes_expected-nbytes_streamed" is guaranteed to be a "small" number, hence a 32-by-32 division would be sufficient?I think so.
I will send a patch to address the things you pointed out in this email.
Thanks, looking forward to it!
Gr{oetje,eeting}s,
Geert
Signature · 9 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Daniel W. S. Almeida
maintainerRe: [v10 3/4] media: vidtv: add a bridge driver
Hi there Geert!
Sorry for breaking stuff :)
Anyways I just sent in a fix. I decided to drop that entire function because as I said, it needs a do-over and that can be done later at a slower pace.
I'm not sure on how to go about testing this properly. I tried 'make ARCH=x86' for example and it built fine, so I assume this is working?
Otherwise let me know.
-- thanks
-- Daniel
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [Linux-kernel-mentees] [v10 3/4] media: vidtv: add a bridge driver
In reply to Geert UytterhoevenHi Geert,
Em Tue, 15 Sep 2020 15:35:00 +0200
Geert Uytterhoeven <[email protected]> escreveu:
Quoted 24 lines
Hi Daniel,
Quoted 20 lines · Daniel W. S. Almeida
Quoted 15 lines
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +10
-0+u32 nbytes =0 ;/* the number of bytes written by this function */ + +u64 nbytes_expected;/* the number of bytes we should have written */ +u64 nbytes_streamed;/* the number of bytes we actually wrote */ +u32 num_null_pkts;/* number of null packets to bridge the gap */ + +u64 elapsed_time_msecs =jiffies_to_usecs (m->timing.current_jiffies - + m->timing.past_jiffies); + + elapsed_time_msecs = min(elapsed_time_msecs,Quoted 2 lines
(u64)VIDTV_MAX_SLEEP_USECS / 1000);
+nbytes_expected=div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);Seriously?!?
Quoted 2 lines
You multiply by 1000 first, followed by a division by 1000 using an expensive 64-by-64 division?
This entire function is broken and needs a do-over :)
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
using an expensive 64-by-64 division?
I am new to kernel development. I wasn't even aware that this was expensive, to be honest.
All divisions involving 64-bit data are expensive, especially on 32-bit platforms. That's why we have the helpers in <
linux/math.h>. Most of them implement simplified variants, which are less expensive.
I agree that 64-bit math is something that should be used with some care. However, it is almost unavoidable do to 64-bit divisions for digital TV.
See, digital TV system deals with frequencies that go up to 2,150 GHz (and that's after converting them from ~10 GHz range, which is done on userspace, on satellite systems).
Basically, most DVB drivers end using 64 bits math to setup clocks. Although we converted most of those cases - I guess there are still a few legacy drivers (written before 64bit archs) that use an algorithm for 64 bits division with a 32 bits result. That should be more expensive than a 64-bits division, specially on 64-bit archs.
Also, stream bit rates are at the order of up to 50 Mbits/s. So, QoS stats usually need to do 64-bit math too, in order to avoid overflows.
-
On the other hand, a few 64-bits math operations at Kernel side means nothing in terms of the systems performance, as those are usually done either at setup phase or when some data packets arrived. Most of CPU cycles ended being spent at MPEG-TS decoding and at audio/video codecs, with needs to be done for each sample, and usually spend lots of CPU (and GPU) cycles doing math and copying big chunks of data.
Thanks,
Mauro
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [v10 3/4] media: vidtv: add a bridge driver
Hi Mauro,
Quoted 29 lines · Mauro Carvalho Chehab
Em Tue, 15 Sep 2020 15:35:00 +0200
Geert Uytterhoeven <[email protected]> escreveu:Quoted 27 lines
Quoted 24 lines · Daniel W. S. Almeida
Quoted 15 lines
Quoted 10 lines
drivers/media/test-drivers/vidtv/vidtv_mux.c new file +10
-0+u32 nbytes =0 ;/* the number of bytes written by this function */ + +u64 nbytes_expected;/* the number of bytes we should have written */ +u64 nbytes_streamed;/* the number of bytes we actually wrote */ +u32 num_null_pkts;/* number of null packets to bridge the gap */ + +u64 elapsed_time_msecs =jiffies_to_usecs (m->timing.current_jiffies - + m->timing.past_jiffies); + + elapsed_time_msecs = min(elapsed_time_msecs,Quoted 2 lines
(u64)VIDTV_MAX_SLEEP_USECS / 1000);
+nbytes_expected=div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);Seriously?!?
Quoted 2 lines
You multiply by 1000 first, followed by a division by 1000 using an expensive 64-by-64 division?
This entire function is broken and needs a do-over :)
Quoted 1 line
using an expensive 64-by-64 division?
I am new to kernel development. I wasn't even aware that this was expensive, to be honest.
Quoted 7 lines
Quoted 3 lines
All divisions involving 64-bit data are expensive, especially on 32-bit platforms. That's why we have the helpers in <
linux/math.h>. Most of them implement simplified variants, which are less expensive.I agree that 64-bit math is something that should be used with some care. However, it is almost unavoidable do to 64-bit divisions for digital TV.
Sure. If 64-bit math is needed, it should be used.
The macros (and the link failure on 32-bit) exist to (a) make sure people think twice before using 64-math, and (b) let people pick a less-expensive variant if that is sufficient.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Daniel W. S. Almeida
maintainerPATCH v10 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 | 417 ++++++++++++++++++ 2 files changed, 418 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 +417 -0
417 lines not on this page · raw message
--
2.28.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Hi Daniel,
Em Fri, 21 Aug 2020 09:58:44 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:
Quoted 13 lines
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
Quoted 8 lines
Current state for this driver:
- Driver generates PSI information (PAT, PMT, SDT)
- Driver generates PCR packets
- Driver generates NULL packets for padding
- PCM audio stream is decoded by ffmpeg, but no audio is heard yet.changes in v10:
s302m encoder got reworked
Thanks for all the hard work on it. Very much appreciated!
I finally found some time to test it. For now, just a quick test from my side, without passing any arguments to the driver.
See enclosed.
While there are still a few issues there, I'm considering applying this series for Kernel 5.10.
My plan is to write some patches on the top of yours, in order to address the problems I'll find on it. If not something more critical won't be solved in time, we may still add it at staging/media. Let's see.
The problems I noticed so far are:
1. rmmod doesn't work;
2. dvbv5-stats doesn't seem to be working properly, as it is reporting signal strengh with a percentage (same for Carrier S/N ratio);
3. dvbv5-zap wrote an empty audio file (without -P flag). Probably there are still some issues at the program channel descriptor or service;
4. The provider service field is null. Perhaps we could add some string there, like "linuxtv.org".
5. Maybe we could also add a simple NIT table, just to avoid dvbv5-scan to wait for it until timeout.
Also, it probably makes sense to add a debugfs interface in order to allow injecting errors at the stream at runtime.
Regards,
Mauro
---
$ dvbv5-scan -v foobar using demux 'dvb0.demux0' Device Dummy demod for DVB-T/T2/C/S/S2 (/dev/dvb/adapter0/frontend0) capabilities: CAN_FEC_1_2 CAN_FEC_2_3 CAN_FEC_3_4 CAN_FEC_4_5 CAN_FEC_5_6 CAN_FEC_6_7 CAN_FEC_7_8 CAN_FEC_8_9 CAN_FEC_AUTO CAN_GUARD_INTERVAL_AUTO CAN_HIERARCHY_AUTO CAN_INVERSION_AUTO CAN_QAM_16 CAN_QAM_32 CAN_QAM_64 CAN_QAM_128 CAN_QAM_256 CAN_QAM_AUTO CAN_QPSK CAN_TRANSMISSION_MODE_AUTO DVB API Version 5.11, Current v5 delivery system: DVBC/ANNEX_A Supported delivery systems: DVBT DVBT2 [DVBC/ANNEX_A] DVBS DVBS2 Frequency range for the current standard: From: 51.0 MHz To: 2.15 GHz Step: 62.5 kHz Tolerance: 29.5 MHz Symbol rate ranges for the current standard: From: 1.00 MBauds To: 45.0 MBauds Failed to guess country from the current locale setting.
ERROR command BANDWIDTH_HZ (5) not found during retrieve
Cannot calc frequency shift. Either bandwidth/symbol-rate is unavailable (yet). Scanning frequency #1 330000000
FREQUENCY = 330000000
MODULATION = QAM/AUTO
INVERSION = AUTO
SYMBOL_RATE = 6940000
INNER_FEC = AUTO
DELIVERY_SYSTEM = DVBC/ANNEX_A
Got parameters for DVBC/ANNEX_A:
FREQUENCY = 330000000
MODULATION = QAM/AUTO
INVERSION = AUTO
SYMBOL_RATE = 6940000
INNER_FEC = AUTO
DELIVERY_SYSTEM = DVBC/ANNEX_A
Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0
dvb_read_sections: waiting for table ID 0x00, program ID 0x00
dvb_parse_section: received table 0x00, extension ID 0x0744, section 0/0
dvb_parse_section: table 0x00, extension ID 0x0744: done
PAT
| table_id 0x00
| section_length 13
| one 2
| zero 0
| syntax 1
| transport_stream_id 1860
| current_next 1
| version 1
| one2 3
| section_number 0
| last_section_number 0
|\ 1 program pid
| pid 0x0101: service 0x0880
Program #0 ID 0x0101, service ID 0x0880
dvb_read_sections: waiting for table ID 0x02, program ID 0x101
dvb_parse_section: received table 0x02, extension ID 0x0880, section 0/0
dvb_parse_section: table 0x02, extension ID 0x0880: done
PMT
| table_id 0x02
| section_length 24
| one 2
| zero 0
| syntax 1
| transport_stream_id 2176
| current_next 1
| version 1
| one2 3
| section_number 0
| last_section_number 0
|- pcr_pid 0200
| reserved2 7
| descriptor length 0
| zero3 0
| reserved3 15
|\
|- stream 0x0111: ISO/IEC 13818-1 Private Data (6)
| descriptor length 6
| 0x05: registration_descriptor
| 42 53 53 44 BSSD
|_ 1 streams
dvb_read_sections: waiting for table ID 0x40, program ID 0x10
ERROR dvb_read_sections: no data read on section filter
ERROR error while reading the NIT table
dvb_read_sections: waiting for table ID 0x42, program ID 0x11
dvb_parse_section: received table 0x42, extension ID 0x0744, section 0/0
dvb_parse_section: table 0x42, extension ID 0x0744: done
SDT
| table_id 0x42
| section_length 48
| one 2
| zero 1
| syntax 1
| transport_stream_id 1860
| current_next 1
| version 1
| one2 3
| section_number 0
| last_section_number 0
| network_id 1860
| reserved 255
|\
|- service 0x0880
| EIT schedule 0
| EIT present following 0
| free CA mode 0
| running status 4
| descriptor length 31
| 0x48: service_descriptor
| service type 1
| provider '(null)'
| name 'S302m: Sine Wave PCM Audio'
|_ 1 services
Service S302m: Sine Wave PCM Audio, provider (null): digital television Storing as channel S302m: Sine Wave PCM Audio
$ dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -m
...
PID FREQ SPEED TOTAL 0 25.07 p/s 36.826 Kbps 55 KB 17 25.07 p/s 36.826 Kbps 55 KB 257 25.07 p/s 36.826 Kbps 55 KB 273 1335.19 p/s 1.915 Mbps 2943 KB 512 25.07 p/s 36.826 Kbps 55 KB 8191 16775.59 p/s 24.062 Mbps 36974 KB TOT 18211.08 p/s 26.121 Mbps 40138 KB Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 $ dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -t 30 -o pcm_audio.ts using demux 'dvb0.demux0' reading channels from file 'dvb_channel.conf' service has pid type 06: 273 tuning to 330000000 Hz (0x00) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 Record to file 'pcm_audio.ts' started Forcing program stop due to timeout or terminate signal $ ls -l pcm_audio.ts -rw-r--r-- 1 mchehab mchehab 0 Sep 11 09:46 pcm_audio.ts $ dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -t 30 -o pcm_audio.ts -P using demux 'dvb0.demux0' reading channels from file 'dvb_channel.conf' service has pid type 06: 273 tuning to 330000000 Hz pass all PID's to TS dvb_set_pesfilter 8192 dvb_dev_set_bufsize: buffer set to 6160384 Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 Record to file 'pcm_audio.ts' started received 103809840 bytes (3379 Kbytes/sec) Lock (0x1f) Signal= 0.00% C/N= 0.00% UCB= 0 postBER= 0 $ ls -lh pcm_audio.ts -rw-r--r-- 1 mchehab mchehab 100M Sep 11 09:54 pcm_audio.ts
Daniel W. S. Almeida
maintainerHey Mauro,
Quoted 6 lines
Thanks for all the hard work on it. Very much appreciated!
I finally found some time to test it. For now, just a quick test from my side, without passing any arguments to the driver.
That's nice!
Quoted 4 lines
My plan is to write some patches on the top of yours, in order to address the problems I'll find on it. If not something more critical won't be solved in time, we may still add it at staging/media. Let's see.
OK
Quoted 3 lines
3. dvbv5-zap wrote an empty audio file (without -P flag). Probably there are still some issues at the program channel descriptor or service;
I don't remember whether I tried this. I tried dumping the stream to a file with dvbzap, which should work. By the way, I guess we should be comparing the output to this
$ ffmpeg -f lavfi -i sine=frequency=1000:duration=5 -ac 2 -c:a s302m -strict -2 out.ts
Since it produces a playable transport stream file that actually sounds like a sine tone.
Inspecting ffmpeg & vidtv output side by side in dvbinspector, you'll see that they're mostly the same. I have a separate PID for the PCR and some other minor differences.
Quoted 7 lines
4. The provider service field is null. Perhaps we could add some string there, like "linuxtv.org".
5. Maybe we could also add a simple NIT table, just to avoid dvbv5-scan to wait for it until timeout.Also, it probably makes sense to add a debugfs interface in order to allow injecting errors at the stream at runtime.
Sure. This is fun, sign me up for it.
As I said in a previous email, I think the buffer in vidtv_s302m.c is not exactly what we want. It sounds like noise.
I got it from here:
https://www.daycounter.com/Calculators/Sine-Generator-Calculator.phtml
I will just copy what I had in a previous email here:
Quoted 8 lines
How do I compute the values for a sine wave such that it can be played indefinitely?
I was thinking about this: (just spitballing here..)
sampling_rate_khz= 48000buffer_size=sampling_rate_khz* seconds
i = 0
Quoted 6 lines
for i <
buffer_size:
buffer[i] = 32767 *sin( 2 * PI * freq / (sampling_rate_khz * i) )but rather I want to precompute a single period for a given frequency such that I can loop on the array indefinitely
By the way, after some time trying out stuff, I guess this is actually what we need in vidtv_s302m_write_frame:
static u32 vidtv_s302m_write_frame(struct vidtv_encoder *e,
u16 sample)
{
u32 nbytes = 0;
struct vidtv_s302m_frame_16 f = {};
struct vidtv_s302m_ctx *ctx = e->ctx;
/* from ffmpeg: see s302enc.c */
u8 vucf = ctx->frame_index == 0 ? 1 : 0;
f.data[0] = reverse[sample & 0xff];
f.data[1] = reverse[(sample & 0xff00) >> 8];
f.data[2] = (vucf << 4) | (reverse[(sample & 0x0f)] >> 4);
f.data[3] = reverse[(sample & 0x0ff0) >> 4];
f.data[4] = reverse[(sample & 0xf000) >> 12] >> 4;
nbytes += vidtv_memcpy(e->encoder_buf,
e->encoder_buf_offset,
VIDTV_S302M_BUF_SZ,
&f,
sizeof(f));
e->encoder_buf_offset += nbytes;
ctx->frame_index++;
if (ctx->frame_index >= S302M_BLOCK_SZ)
ctx->frame_index = 0;
return nbytes;
}i.e. see: https://docplayer.net/37828038-For-television-mapping-of-aes3-data-into-an-mpeg-2-transport-stream.html
Figure 5, page 4.
Lastly, I am somewhat new to C, so a few things might look odd here and there. If you come across something that's too verbose tell me and I will try to tidy it up.
--thanks
-- Daniel
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Em Fri, 11 Sep 2020 09:18:20 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:
Quoted 29 lines
Hey Mauro,
Quoted 6 lines
Thanks for all the hard work on it. Very much appreciated!
I finally found some time to test it. For now, just a quick test from my side, without passing any arguments to the driver.
That's nice!
Quoted 4 lines
My plan is to write some patches on the top of yours, in order to address the problems I'll find on it. If not something more critical won't be solved in time, we may still add it at staging/media. Let's see.
OK
Quoted 3 lines
3. dvbv5-zap wrote an empty audio file (without -P flag). Probably there are still some issues at the program channel descriptor or service;
I don't remember whether I tried this. I tried dumping the stream to a file with dvbzap, which should work. By the way, I guess we should be comparing the output to this
$ ffmpeg -f lavfi -i sine=frequency=1000:duration=5 -ac 2 -c:a s302m -strict -2 out.ts
Quoted 6 lines
Since it produces a playable transport stream file that actually sounds like a sine tone.
Inspecting ffmpeg & vidtv output side by side in dvbinspector, you'll see that they're mostly the same. I have a separate PID for the PCR and some other minor differences.
The problem is here:
$ dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -t 30 -o pcm_audio.ts -P using demux 'dvb0.demux0' reading channels from file 'dvb_channel.conf' service has pid type 06: 273
See, it identified the EL type ID as type 6, which is handled by dvbv5 library here:
case 0x06: /* private data */
/*
* Those can be used by sub-titling, teletext and/or
* DVB AC-3. So, need to seek for the AC-3 descriptors
*/
dvb_desc_find(struct dvb_desc_service, desc, stream, AC_3_descriptor)
has_ac3 = 1;
dvb_desc_find(struct dvb_desc_service, desc, stream, enhanced_AC_3_descriptor)
has_ac3 = 1;
if (has_ac3) {
entry->audio_pid = realloc(entry->audio_pid,
sizeof(*entry->audio_pid) *
(audio_len + 1));
entry->audio_pid[audio_len] = pid;
audio_len++;
} else {
entry->other_el_pid = realloc(entry->other_el_pid,
sizeof(*entry->other_el_pid) *
(other_len + 1));
entry->other_el_pid[other_len].type = stream->type;
entry->other_el_pid[other_len].pid = pid;
other_len++;
}
break;Basically, it is not recognizing the stream as an audio PID, but as some other random data. Due to that, the output of dvb_channel.conf will be wrong.
As type 6 seems to be the correct one for SMPTE 302M, we need to fix dvbv5-tools (and likely other tools like kaffeine), in order to recognize it as audio as well.
Quoted 9 lines
Quoted 7 lines
4. The provider service field is null. Perhaps we could add some string there, like "linuxtv.org".
5. Maybe we could also add a simple NIT table, just to avoid dvbv5-scan to wait for it until timeout.Also, it probably makes sense to add a debugfs interface in order to allow injecting errors at the stream at runtime.
Sure. This is fun, sign me up for it.
Well, if you have some spare time, you could try to write a debugfs binding for vidtv. The best would be to have it on a separate file. Failing to bind debugfs should not prevent loading the bridge driver.
Quoted 2 lines
As I said in a previous email, I think the buffer in
vidtv_s302m.cis not exactly what we want. It sounds like noise.
Yeah, after changing dvb_channel.conf to:
[S302m: Sine Wave PCM Audio]
SERVICE_ID = 2176
AUDIO_PID = 273
FREQUENCY = 330000000
MODULATION = QAM/AUTO
INVERSION = AUTO
SYMBOL_RATE = 6940000
INNER_FEC = AUTO
DELIVERY_SYSTEM = DVBC/ANNEX_A
(e. g. changing "PID_06" to "AUDIO_PID")
I was able to record and play it.
Anyway, the actual sound doesn't matter much here, at least for the first version, as this could be changed later on.
Quoted 2 lines
I got it from here:
https://www.daycounter.com/Calculators/Sine-Generator-Calculator.phtml
On a quick look at the s302m_sin_lut table, it is indeed a sinal waveform, with a DC offset on it (in order to convert it to unsigned), as "0" is 0x8000.
The "noise" is actually looks like "humm". This is periodic, it seems.
Quoted 4 lines
By the way, after some time trying out stuff, I guess this is actually what we need in
vidtv_s302m_write_frame:static u32 vidtv_s302m_write_frame(struct
vidtv_encoder*e,
Quoted 15 lines
u16 sample)
{
u32 nbytes = 0;
struct vidtv_s302m_frame_16 f = {};
struct vidtv_s302m_ctx *ctx = e->ctx;
/* from ffmpeg: see s302enc.c */
u8 vucf = ctx->frame_index == 0 ? 1 : 0;
f.data[0] = reverse[sample & 0xff];
f.data[1] = reverse[(sample & 0xff00) >> 8];
f.data[2] = (vucf << 4) | (reverse[(sample & 0x0f)] >> 4);
f.data[3] = reverse[(sample & 0x0ff0) >> 4];
f.data[4] = reverse[(sample & 0xf000) >> 12] >> 4;doing that didn't work. Yet, this check inside the driver:
#ifdef __LITTLE_ENDIAN
f.data[0] = reverse[f.data[0]];
f.data[1] = reverse[f.data[1]];
f.data[2] = reverse[f.data[2]];
f.data[3] = reverse[f.data[3]];
f.data[4] = reverse[f.data[4]];
#endifSeems plain wrong, as you're already ensuring the endiannes it is needed when you're doing things like "sample & 0xff".
Thanks,
Mauro
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Em Fri, 11 Sep 2020 15:10:46 +0200
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 58 lines
Em Fri, 11 Sep 2020 09:18:20 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:Quoted 11 lines
Quoted 3 lines
3. dvbv5-zap wrote an empty audio file (without -P flag). Probably there are still some issues at the program channel descriptor or service;
I don't remember whether I tried this. I tried dumping the stream to a file with dvbzap, which should work. By the way, I guess we should be comparing the output to this
$ ffmpeg -f lavfi -i sine=frequency=1000:duration=5 -ac 2 -c:a s302m -strict -2 out.tsQuoted 6 lines
Since it produces a playable transport stream file that actually sounds like a sine tone.
Inspecting ffmpeg & vidtv output side by side in dvbinspector, you'll see that they're mostly the same. I have a separate PID for the PCR and some other minor differences.
The problem is here:
$ dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -t 30 -o pcm_audio.ts -P using demux 'dvb0.demux0' reading channels from file 'dvb_channel.conf' service has pid type 06: 273See, it identified the EL type ID as type 6, which is handled by dvbv5 library here:
case 0x06: /* private data */ /* * Those can be used by sub-titling, teletext and/or * DVB AC-3. So, need to seek for the AC-3 descriptors */ dvb_desc_find(struct dvb_desc_service, desc, stream, AC_3_descriptor) has_ac3 = 1; dvb_desc_find(struct dvb_desc_service, desc, stream, enhanced_AC_3_descriptor) has_ac3 = 1; if (has_ac3) { entry->audio_pid = realloc(entry->audio_pid, sizeof(*entry->audio_pid) * (audio_len + 1)); entry->audio_pid[audio_len] = pid; audio_len++; } else { entry->other_el_pid = realloc(entry->other_el_pid, sizeof(*entry->other_el_pid) * (other_len + 1)); entry->other_el_pid[other_len].type = stream->type; entry->other_el_pid[other_len].pid = pid; other_len++; } break;
Quoted 7 lines
Basically, it is not recognizing the stream as an audio PID, but as some other random data. Due to that, the output of dvb_channel.conf will be wrong.
As type 6 seems to be the correct one for SMPTE 302M, we need to fix dvbv5-tools (and likely other tools like kaffeine), in order to recognize it as audio as well.
Ok, I guess I got what should be done here. ETSI TS 102 154 says that SMPTE 302M should use the "registration_descriptor".
From the specs, such descriptor should be filled with format_identifier = 0x42535344.
We need to add this on both at v4l-utils and at the vidtv driver.
Thanks,
Mauro
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Daniel W. S. Almeida
maintainerHi Mauro,
Quoted 7 lines
Ok, I guess I got what should be done here. ETSI TS 102 154 says that SMPTE 302M should use the "
registration_descriptor".From the specs, such descriptor should be filled with
format_identifier=0x42535344.We need to add this on both at v4l-utils and at the vidtv driver.
vidtv will already attach a registration descriptor for s302m audio, i.e.
dvb_parse_section: table 0x02, extension ID 0x0880: done PMT
| table_id 0x02 | section_length 24 | one 2 | zero 0 | syntax 1 | transport_stream_id 2176 | current_next 1 | version 1 | one2 3 | section_number 0 | last_section_number 0 |- pcr_pid 0200 | reserved2 7 | descriptor length 0 | zero3 0 | reserved3 15 |\ |- stream 0x0111: ISO/IEC 13818-1 Private Data (6) | descriptor length 6 | 0x05: registration_descriptor | 42 53 53 44 BSSD <<<<<<<<<<< here it is |_ 1 streams
So I guess I need to add support for it on v4l-utils then? Any tips on how to get started?
By the way,
Quoted 4 lines
My plan is to write some patches on the top of yours, in order to address the problems I'll find on it. If not something more critical won't be solved in time, we may still add it at staging/media. Let's see.
Can you teach me how this works in git? Am I supposed to cherry-pick your patches, or apply & rebase -i & squash, or something else?
Quoted 4 lines
Well, if you have some spare time, you could try to write a debugfs binding for vidtv. The best would be to have it on a separate file. Failing to bind debugfs should not prevent loading the bridge driver.
Sure, can you provide more details on how this and vidtv should play together? I will catch up on
the documentation for debugfs in the meantime
As for vidtv_s302m_write_frame:
Quoted 1 line
doing that didn't work. Yet, this check inside the driver:
What didn't work? It didn't compile? I should have sent a proper diff but I was short on time, sorry...
-- thanks
-- Daniel
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Em Fri, 11 Sep 2020 23:54:15 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:
Quoted 37 lines
Hi Mauro,
Quoted 7 lines
Ok, I guess I got what should be done here. ETSI TS 102 154 says that SMPTE 302M should use the "
registration_descriptor".From the specs, such descriptor should be filled with
format_identifier=0x42535344.We need to add this on both at v4l-utils and at the vidtv driver.
vidtv will already attach a registration descriptor for s302m audio, i.e.
dvb_parse_section: table0x02, extension ID0x0880: done PMT| table_id 0x02 | section_length 24 | one 2 | zero 0 | syntax 1 | transport_stream_id 2176 | current_next 1 | version 1 | one2 3 | section_number 0 | last_section_number 0 |- pcr_pid 0200 | reserved2 7 | descriptor length 0 | zero3 0 | reserved3 15 |\ |- stream 0x0111: ISO/IEC 13818-1 Private Data (6) | descriptor length 6 | 0x05: registration_descriptor | 42 53 53 44 BSSD <<<<<<<<<<< here it is |_ 1 streams
Quoted 2 lines
So I guess I need to add support for it on v4l-utils then? Any tips on how to get started?
This is easier if I do myself than to explain it, especially because the registration descriptor is not decoded yet.
Just added support for decoding the registration descriptor:
https://git.linuxtv.org/v4l-utils.git/commit/?id=d070107d6267f617bb7331d84507701c8e2d673c
The actual patch making dvbv5-scan libraries to support it is trivial:
https://git.linuxtv.org/v4l-utils.git/commit/?id=fcbd7fae7c2208e01a7f670f8ba2f34d62ea6a4d
Quoted 10 lines
By the way,
Quoted 4 lines
My plan is to write some patches on the top of yours, in order to address the problems I'll find on it. If not something more critical won't be solved in time, we may still add it at staging/media. Let's see.
Can you teach me how this works in git? Am I supposed to cherry-pick your patches, or apply & rebase -i & squash, or something else?
Well, the basic stuff is all there: the driver loads and unloads fine (after my patch), and it does what's expected. So, no need to put it under staging.
I'll just merge the 4 patches from you, plus the one I wrote fixing unloading it at the media tree.
You can write any other patch on the top of it.
I'll do the same, c/c you on the patches I write afterwards.
Quoted 8 lines
Quoted 4 lines
Well, if you have some spare time, you could try to write a debugfs binding for vidtv. The best would be to have it on a separate file. Failing to bind debugfs should not prevent loading the bridge driver.
Sure, can you provide more details on how this and vidtv should play together? I will catch up on
the documentation for debugfs in the meantime
I'm thinking on something like:
echo 1 >/sys/kernel/debug/vidtv/discontinuity
to generate a frame numbering discontinuity
and other things like that, changing S/N ratio and other parameters and injecting errors, in order to test the effects on user apps.
Quoted 7 lines
As for
vidtv_s302m_write_frame:Quoted 1 line
doing that didn't work. Yet, this check inside the driver:
What didn't work? It didn't compile? I should have sent a proper diff but I was short on time, sorry...
No. I meant the audio was not a sinusoidal wave after such change.
-
Anyway, now that rmmod is working, modifying the driver is a lot easier, as you don't need to reboot the Kernel every time.
you could just do something like this:
$ sudo rmmod dvb_vidtv_bridge dvb_vidtv_demod dvb_vidtv_tuner; make drivers/media/test-drivers/ && sudo cp drivers/media/test-drivers/vidtv/*.ko /lib/modules/5.9.0-rc1+/kernel/drivers/media/test-drivers/vidtv/ && sudo modprobe dvb-vidtv-bridge && dvbv5-zap -c dvb_channel.conf "S302m: Sine Wave PCM Audio" -P -v -t 4 -o pcm_audio.ts
which is a lot faster.
Thanks,
Mauro
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Hi Daniel,
First of all, thank you for all your work on this. I see that Mauro merged this v10, and after testing I posted a patch for the Kconfig, since that seems to be wrong.
I have some more questions below, my apologies if that's been asked before.
Quoted 64 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.
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 debugfsCurrent state for this driver:
- Driver generates PSI information (PAT, PMT, SDT)
- Driver generates PCR packets
- Driver generates NULL packets for padding
- PCM audio stream is decoded by ffmpeg, but no audio is heard yet.changes in v10:
s302m encoder got reworkedThe 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**
Quoted 7 lines
When compiled as a module, expect the following .ko files:
- dvb_vidtv_tuner.ko
- dvb_vidtv_demod.ko
- dvb_vidtv_bridge.ko
Why the dvb_ prefix? All virtual drivers just start with 'vi'.
And wouldn't it make more sense to call dvb_vidtv_bridge.ko just vidtv.ko? Just like the other virtual media drivers?
Quoted 7 lines
Running vidtv
-------------
When compiled as a module, run::modprobe
dvb_vidtv_bridge
Quoted 8 lines
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
============================
For regression testing of vidtv during the daily build it would be great if the contrib/test/test-media script can be enhanced to include vidtv.
This is run during the daily build with a kernel that has lockdep and many other checks enabled, so it is very helpful to verify that no regressions happened.
Note that this script relies on the /dev/mediaX devices to run the tests. I noticed that vidtv doesn't appear to create a /dev/mediaX device, even though CONFIG_MEDIA_CONTROLLER_DVB=y. This is definitely something that would be good to support in vidtv.
Regards,
Hans
Quoted 173 lines
Start by installing v4l-utils and then modprobing vidtv::
modprobe
dvb_vidtv_bridgeIf 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-toolThis 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_ANOTE:
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.confUsing 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/dvr0Daniel 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 | 417 +++++ 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 | 546 +++++++ .../media/test-drivers/vidtv/vidtv_bridge.h | 60 + .../media/test-drivers/vidtv/vidtv_channel.c | 306 ++++ .../media/test-drivers/vidtv/vidtv_channel.h | 76 + .../media/test-drivers/vidtv/vidtv_common.c | 89 ++ .../media/test-drivers/vidtv/vidtv_common.h | 33 + .../media/test-drivers/vidtv/vidtv_demod.c | 440 ++++++ .../media/test-drivers/vidtv/vidtv_demod.h | 73 + .../media/test-drivers/vidtv/vidtv_encoder.h | 96 ++ drivers/media/test-drivers/vidtv/vidtv_mux.c | 479 ++++++ drivers/media/test-drivers/vidtv/vidtv_mux.h | 160 ++ drivers/media/test-drivers/vidtv/vidtv_pes.c | 398 +++++ drivers/media/test-drivers/vidtv/vidtv_pes.h | 189 +++ drivers/media/test-drivers/vidtv/vidtv_psi.c | 1352 +++++++++++++++++ drivers/media/test-drivers/vidtv/vidtv_psi.h | 593 ++++++++ .../media/test-drivers/vidtv/vidtv_s302m.c | 552 +++++++ .../media/test-drivers/vidtv/vidtv_s302m.h | 90 ++ drivers/media/test-drivers/vidtv/vidtv_ts.c | 137 ++ drivers/media/test-drivers/vidtv/vidtv_ts.h | 130 ++ .../media/test-drivers/vidtv/vidtv_tuner.c | 427 ++++++ .../media/test-drivers/vidtv/vidtv_tuner.h | 43 + 28 files changed, 6732 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
Hi Hans/Daniel,
Em Sat, 12 Sep 2020 10:21:59 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 14 lines
Quoted 14 lines
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
Quoted 8 lines
Quoted 3 lines
- dvb_vidtv_demod.ko
- dvb_vidtv_bridge.ko
Why the
dvb_prefix? All virtual drivers just start with 'vi'.And wouldn't it make more sense to call dvb_vidtv_bridge.ko just vidtv.ko? Just like the other virtual media drivers?
It is a sort of standard to use dvb_* for pure digital tv bridge drivers.
Yet, I agree with you that at least an alias is needed. earlier today, I wrote a patch with such purpose:
https://patchwork.linuxtv.org/project/linux-media/patch/fccf254e33bdd169dde6bdd6f941cf773c82a1c0.1599901499.git.mchehab+huawei@kernel.org/
Still, maybe we should move dvb_vidtv_tuner.ko and dvb_vidtv_demod.ko to dvb-frontends and rename them. Not 100% sure about that, though.
I would also rename vidtv_bridge.c to just vidtv.c.
Thanks,
Mauro
Daniel W. S. Almeida
maintainerHi Hans and Mauro & all
Quoted 4 lines
Why the
dvb_prefix? All virtual drivers just start with 'vi'.And wouldn't it make more sense to call dvb_vidtv_bridge.ko just vidtv.ko? Just like the other virtual media drivers?
I guess Mauro was the one to come up with the dvb_* prefix for the kernel modules for the reasons he explicited up in this thread.
As far as dvb_vidtv_bridge.ko and vidtv_bridge.c, I just wanted to be verbose so that people would look at this and see that it is the code for a bridge driver, since this is also supposed to be a template.
Also because I had some trouble myself figuring out what was what when first browsing through other dvb drivers. That said, I am 100% onboard with renaming this to vidtv.ko or whatever seems more appropiate :)
Quoted 2 lines
Yet, I agree with you that at least an alias is needed. earlier today, I wrote a patch with such purpose:
If you all would like to just leave this at that ^ I am also ok with it.
Quoted 1 line
For regression testing of vidtv during the daily build it would be
great if
Quoted 1 line
the contrib/test/test-media script can be enhanced to include vidtv.
Sure, I can do that if you'd like. Can you provide some tips on how to get started? :)
Quoted 1 line
Note that this script relies on the
/dev/mediaXdevices to run the
tests. I
Quoted 2 lines
noticed that vidtv doesn't appear to create a
/dev/mediaXdevice, even thoughCONFIG_MEDIA_CONTROLLER_DVB=y. This is definitely something that would
be good
Quoted 1 line
to support in vidtv.
I didn't write any code for this specifically. I was under the impression that the dvb core would create any/all the necessary files. Mauro?
Quoted 8 lines
I'm thinking on something like:
echo 1 >/sys/kernel/debug/vidtv/discontinuity
to generate a frame numbering discontinuity
and other things like that, changing S/N ratio and other parameters and injecting errors, in order to test the effects on user apps.
Can you provide an initial list of things you would like to see? I can then implement these and we can go from there
When you say 'frame numbering discontinuity', do you mean having a gap in the the TS continuity counter for a given pid?
For the s302m encoder, maybe we can add some noise to the samples?
Quoted 1 line
changing S/N ratio
Btw 'lose lock if signal goes bad' code in vidtv_tuner.c and vidtv_demod.c does not work currently. Mainly because they expect an array of valid frequencies to compare to and as of now there's no default.
I mean these, just to be clear:
static unsigned int vidtv_valid_dvb_t_freqs[NUM_VALID_TUNER_FREQS]; module_param_array(vidtv_valid_dvb_t_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_t_freqs,
"Valid DVB-T frequencies to simulate");
static unsigned int vidtv_valid_dvb_c_freqs[NUM_VALID_TUNER_FREQS]; module_param_array(vidtv_valid_dvb_c_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_c_freqs,
"Valid DVB-C frequencies to simulate");
static unsigned int vidtv_valid_dvb_s_freqs[NUM_VALID_TUNER_FREQS]; module_param_array(vidtv_valid_dvb_s_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_s_freqs,
"Valid DVB-C frequencies to simulate");
static unsigned int max_frequency_shift_hz; module_param(max_frequency_shift_hz, uint, 0); MODULE_PARM_DESC(max_frequency_shift_hz,
"Maximum shift in HZ allowed when tuning in a channel")
Quoted 1 line
No. I meant the audio was not a sinusoidal wave after such change.
This encoder is dead simple and yet I have been struggling :/
Here is the relevant decoding code in libavcodec/s302m.c:
for (; buf_size > 4; buf_size -= 5) {
*o++ = (ff_reverse[buf[1]] << 8) |
ff_reverse[buf[0]];
*o++ = (ff_reverse[buf[4] & 0xf0] << 12) |
(ff_reverse[buf[3]] << 4) |
(ff_reverse[buf[2]] >> 4);
buf += 5;
}I am somewhat confident that the opposite to the above is precisely what I sent you last:
Quoted 5 lines
f.data[0] = reverse[sample &
0xff];
f.data[1] = reverse[(sample &0xff00) >> 8]; f.data[2] = (vucf << 4) | (reverse[(sample &0x0f)] >> 4); f.data[3] = reverse[(sample &0x0ff0) >> 4]; f.data[4] = reverse[(sample &0xf000) >> 12] >> 4;
Their encoder, which works perfectly of course, is:
libavcodec/s302menc.c:
for (c = 0; c < frame->nb_samples; c++) {
uint8_t vucf = s->framing_index == 0 ? 0x10 : 0;
for (channels = 0; channels < avctx->channels; channels +=
2) {
o[0] = ff_reverse[ samples[0] & 0xFF];
o[1] = ff_reverse[(samples[0] & 0xFF00) >> 8];
o[2] = ff_reverse[(samples[1] & 0x0F) << 4] | vucf;
o[3] = ff_reverse[(samples[1] & 0x0FF0) >> 4];
o[4] = ff_reverse[(samples[1] & 0xF000) >> 12];
o += 5;
samples += 2;
}
s->framing_index++;
if (s->framing_index >= 192)
s->framing_index = 0;
}In which samples[0] and samples[1] are the same for stereo audio.
If you feel like we should only address this later I can drop this subject but as we've both established, the encoder in v10 is flat out wrong. Your call :)
-- thanks
-- Daniel
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Em Sat, 12 Sep 2020 11:49:01 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:
Quoted 11 lines
Hi Hans and Mauro & all
Quoted 4 lines
Why the
dvb_prefix? All virtual drivers just start with 'vi'.And wouldn't it make more sense to call dvb_vidtv_bridge.ko just vidtv.ko? Just like the other virtual media drivers?
I guess Mauro was the one to come up with the dvb_* prefix for the kernel modules for the reasons he explicited up in this thread.
Quoted 7 lines
As far as dvb_vidtv_bridge.ko and
vidtv_bridge.c, I just wanted to be verbose so that people would look at this and see that it is the code for a bridge driver, since this is also supposed to be a template.Also because I had some trouble myself figuring out what was what when first browsing through other dvb drivers. That said, I am 100% onboard with renaming this to vidtv.ko or whatever seems more appropiate :)
Let us think a little bit about that.
Quoted 5 lines
Quoted 4 lines
Yet, I agree with you that at least an alias is needed. earlier today, I wrote a patch with such purpose:
Quoted 8 lines
If you all would like to just leave this at that ^ I am also ok with it.
Quoted 1 line
For regression testing of vidtv during the daily build it would be
great if
Quoted 1 line
the contrib/test/test-media script can be enhanced to include vidtv.
Sure, I can do that if you'd like. Can you provide some tips on how to get started? :)
Hans can explain it better, but the hole idea is to have a set of userspace apps that will ensure that drivers will properly implement the DVB API.
I suspect that, before that (or together with such tooling), we need to properly implement the frontend ioctl, validating the per delivery system parameters, as, right now, it just accepts anything from userspace.
Quoted 9 lines
Quoted 1 line
Note that this script relies on the
/dev/mediaXdevices to run thetests. I
Quoted 2 lines
noticed that vidtv doesn't appear to create a
/dev/mediaXdevice, even thoughCONFIG_MEDIA_CONTROLLER_DVB=y. This is definitely something that wouldbe good
Quoted 1 line
to support in vidtv.
I didn't write any code for this specifically. I was under the impression that the dvb core would create any/all the necessary files. Mauro?
It should be easy to implement support for it. The core does almost everything. Drivers just need to initialize the media controller.
See for example:
drivers/media/usb/em28xx/em28xx-dvb.c
Quoted 11 lines
Quoted 8 lines
I'm thinking on something like:
echo 1 >/sys/kernel/debug/vidtv/discontinuity
to generate a frame numbering discontinuity
and other things like that, changing S/N ratio and other parameters and injecting errors, in order to test the effects on user apps.
Can you provide an initial list of things you would like to see? I can then implement these and we can go from there
Well, things that could help identifying bugs on userspace...
Quoted 3 lines
When you say 'frame numbering discontinuity', do you mean having a gap in the the TS continuity counter for a given pid?
... like this. Yeah, adding a gap a TS continuity counter.
Other things could be to add noise to frames and increment the dvbv5-stat numbers and shifting bits and/or dropping 188-byte frames.
With that regards, I'm planning to add support for dvb5-stat myself, as this should be trivial for me. Once support gets added, changing the stats is just a matter of increment some counters at fe cache.
Quoted 2 lines
For the s302m encoder, maybe we can add some noise to the samples?
Yes.
Quoted 22 lines
Quoted 2 lines
changing S/N ratio
Btw 'lose lock if signal goes bad' code in
vidtv_tuner.candvidtv_demod.cdoes not work currently. Mainly because they expect an array of valid frequencies to compare to and as of now there's no default.I mean these, just to be clear:
static unsigned int vidtv_valid_dvb_t_freqs[NUM_VALID_TUNER_FREQS];
module_param_array(vidtv_valid_dvb_t_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_t_freqs,
"Valid DVB-T frequencies to simulate");static unsigned int vidtv_valid_dvb_c_freqs[NUM_VALID_TUNER_FREQS];
module_param_array(vidtv_valid_dvb_c_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_c_freqs,"Valid DVB-C frequencies to simulate");static unsigned int vidtv_valid_dvb_s_freqs[NUM_VALID_TUNER_FREQS];
module_param_array(vidtv_valid_dvb_s_freqs, uint, NULL, 0); MODULE_PARM_DESC(vidtv_valid_dvb_s_freqs,
Quoted 6 lines
"Valid DVB-C frequencies to simulate");static unsigned int
max_frequency_shift_hz;module_param(max_frequency_shift_hz, uint, 0); MODULE_PARM_DESC(max_frequency_shift_hz,
"Maximum shift in HZ allowed when tuning in a channel")
Yes, I know (btw, there's a bug on its implementation - I'm working on a fix ATM).
There are two different things here. With the above, you're simulating tuning at a wrong frequency.
Another thing would be to have a parameter forcing errors.
This can be helpful to dynamically inject errors on a tuned channel, and see how apps will behave.
Quoted 3 lines
Quoted 1 line
No. I meant the audio was not a sinusoidal wave after such change.
This encoder is dead simple and yet I have been struggling :/
:-)
That happens. As I said, for now this is not too important. The way it is, it is already possible to test userspace.
Yet, it would be nice to get it fixed, and maybe change the code in the future to play some simple public domain music (or maybe some random music using for example a pentatonic scale). Avoiding a single periodic waveform can help tracking other issues when there are package drops.
Quoted 46 lines
Here is the relevant decoding code in
libavcodec/s302m.c:for (; buf_size > 4; buf_size -= 5) { *o++ = (ff_reverse[buf[1]] << 8) | ff_reverse[buf[0]]; *o++ = (ff_reverse[buf[4] & 0xf0] << 12) | (ff_reverse[buf[3]] << 4) | (ff_reverse[buf[2]] >> 4); buf += 5; }I am somewhat confident that the opposite to the above is precisely what I sent you last:
Quoted 5 lines
f.data[0] = reverse[sample &
0xff];
f.data[1] = reverse[(sample &0xff00) >> 8]; f.data[2] = (vucf << 4) | (reverse[(sample &0x0f)] >> 4); f.data[3] = reverse[(sample &0x0ff0) >> 4]; f.data[4] = reverse[(sample &0xf000) >> 12] >> 4;Their encoder, which works perfectly of course, is:
libavcodec/s302menc.c:for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x10 : 0; for (channels = 0; channels < avctx->channels; channels += 2) { o[0] = ff_reverse[ samples[0] & 0xFF]; o[1] = ff_reverse[(samples[0] & 0xFF00) >> 8]; o[2] = ff_reverse[(samples[1] & 0x0F) << 4] | vucf; o[3] = ff_reverse[(samples[1] & 0x0FF0) >> 4]; o[4] = ff_reverse[(samples[1] & 0xF000) >> 12]; o += 5; samples += 2; } s->framing_index++; if (s->framing_index >= 192) s->framing_index = 0; }
Quoted 5 lines
In which samples[0] and samples[1] are the same for stereo audio.
If you feel like we should only address this later I can drop this subject but as we've both established, the encoder in v10 is flat out wrong. Your call :)
Well, if you're confident and had it tested, feel free to submit a patch ;-)
Thanks,
Mauro
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 38 lines · Mauro Carvalho Chehab
Em Sat, 12 Sep 2020 11:49:01 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:Quoted 11 lines
Hi Hans and Mauro & all
Quoted 4 lines
Why the
dvb_prefix? All virtual drivers just start with 'vi'.And wouldn't it make more sense to call dvb_vidtv_bridge.ko just vidtv.ko? Just like the other virtual media drivers?
I guess Mauro was the one to come up with the dvb_* prefix for the kernel modules for the reasons he explicited up in this thread.
Quoted 7 lines
As far as dvb_vidtv_bridge.ko and
vidtv_bridge.c, I just wanted to be verbose so that people would look at this and see that it is the code for a bridge driver, since this is also supposed to be a template.Also because I had some trouble myself figuring out what was what when first browsing through other dvb drivers. That said, I am 100% onboard with renaming this to vidtv.ko or whatever seems more appropiate :)
Let us think a little bit about that.
Quoted 5 lines
Quoted 4 lines
Yet, I agree with you that at least an alias is needed. earlier today, I wrote a patch with such purpose:
Quoted 8 lines
If you all would like to just leave this at that ^ I am also ok with it.
Quoted 1 line
For regression testing of vidtv during the daily build it would be
great if
Quoted 1 line
the contrib/test/test-media script can be enhanced to include vidtv.
Sure, I can do that if you'd like. Can you provide some tips on how to get started? :)
Quoted 8 lines
Hans can explain it better, but the hole idea is to have a set of userspace apps that will ensure that drivers will properly implement the DVB API.
I suspect that, before that (or together with such tooling), we need to properly implement the frontend ioctl, validating the per delivery system parameters, as, right now, it just accepts anything from userspace.
Daniel, if you look at the test-media script, then you'll see that it has separate sections for each virtual driver. It's probably best to look at the vim2m driver tests since that's the easiest.
It loads the module, then it starts v4l2-compliance to test the API. This utility basically tries all V4L2 APIs and checks that the driver conforms to the spec.
Note that you see options like '-m platform:vim2m' that selects which /dev/media device to use based on the name and v4l2-compliance (or v4l2-ctl with the -z option) then walks the topology of the media device and tests all interfaces it finds.
Hence my question about media controller support in vidtv: this should be supported there as well since it allows you to write these test sequences without having to know which /dev/fooX device should be used.
After the compliance test is run the script tests unbind/bind (always a nasty test) and checks for memory leaks (if enabled in the kernel).
Much of this test sequence can be copied for vidtv, but you need something else for the compliance test. It would for now be enough to have some quick check with the existing dvb utils from v4l-utils to see that the basics work.
IMHO I think a dtv-compliance utility along the lines of v4l2-compliance and cec-compliance should be created.
I'm actually wondering whether the dtv compliance tests shouldn't be part of v4l2-compliance (which would have to be renamed to media-compliance in that case) since there are hybrid drivers supporting both in the same media topology.
This would make compliance tests possible where analog/digital TV mode handling is tested (i.e. if analog TV is in use, then trying to use digital TV would return EBUSY and vice versa).
It would require some work in v4l2-compliance.cpp to make this possible, but I can do that myself.
Compliance tests have proven to be a great method of testing for regressions and testing drivers in general.
Note that it takes a lot of time to create good compliance tests, but you just start with some simple tests and expand it over time.
Regards,
Hans
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 20 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.
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 debugfsCurrent state for this driver:
- Driver generates PSI information (PAT, PMT, SDT)
- Driver generates PCR packets
- Driver generates NULL packets for padding
- PCM audio stream is decoded by ffmpeg, but no audio is heard yet.
Quoted 2 lines
changes in v10:
s302m encoder got reworked
Hi Daniel, Mauro,
When compiling for a 32 bit system I get these warnings:
linux-5.9-rc1-i686: WARNINGS
In file included from ./include/linux/kernel.h:15,
from ./include/asm-generic/bug.h:20,
from ./arch/x86/include/asm/bug.h:93,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/config-compat.h:12,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/compat.h:10,
from <command-line>:/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_common.c: In function 'vidtv_memcpy':./include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~./include/linux/printk.h:508:10: note: in definition of macro 'printk_ratelimited'
508 | printk(fmt, ##__VA_ARGS__); \
| ^~~
./include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
./include/linux/printk.h:522:21: note: in expansion of macro 'KERN_ERR'
522 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_common.c:46:3: note: in expansion of macro 'pr_err_ratelimited'
46 | pr_err_ratelimited("overflow detected, skipping. Try increasing the buffer size. Needed %lu, had %zu\n",
| ^~~~~~~~~~~~~~~~~~/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_common.c: In function 'vidtv_memset':./include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~./include/linux/printk.h:508:10: note: in definition of macro 'printk_ratelimited'
508 | printk(fmt, ##__VA_ARGS__); \
| ^~~
./include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
| ^~~~~~~~
./include/linux/printk.h:522:21: note: in expansion of macro 'KERN_ERR'
522 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~
/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_common.c:82:3: note: in expansion of macro 'pr_err_ratelimited'
82 | pr_err_ratelimited("overflow detected, skipping. Try increasing the buffer size. Needed %lu, had %zu\n",
| ^~~~~~~~~~~~~~~~~~
In file included from ./include/linux/kernel.h:15,
from ./include/asm-generic/bug.h:20,
from ./arch/x86/include/asm/bug.h:93,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/config-compat.h:12,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/compat.h:10,
from <command-line>:/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_s302m.c: In function 'vidtv_s302m_write_frames':./include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'u32' {aka 'unsigned int'} [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~./include/linux/printk.h:508:10: note: in definition of macro 'printk_ratelimited'
508 | printk(fmt, ##__VA_ARGS__); \
| ^~~
./include/linux/kern_levels.h:12:22: note: in expansion of macro 'KERN_SOH'
12 | #define KERN_WARNING KERN_SOH "4" /* warning conditions */
| ^~~~~~~~
./include/linux/printk.h:524:21: note: in expansion of macro 'KERN_WARNING'
524 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~
/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_s302m.c:426:4: note: in expansion of macro 'pr_warn_ratelimited'
426 | pr_warn_ratelimited("write size was %d, expected %lu\n",
| ^~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/bitops.h:5,
from ./include/linux/kernel.h:12,
from ./include/asm-generic/bug.h:20,
from ./arch/x86/include/asm/bug.h:93,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/config-compat.h:12,
from /home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/compat.h:10,
from <command-line>:/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_pes.c: In function 'vidtv_pes_write_pts_dts':./include/linux/bits.h:36:11: warning: right shift count is negative [-Wshift-count-negative]
36 | (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
| ^~./include/linux/bits.h:38:31: note: in expansion of macro '__GENMASK'
38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~/home/hans/work/build/trees/i686/linux-5.9-rc1/media_build/v4l/vidtv_pes.c:99:10: note: in expansion of macro 'GENMASK'
99 | mask1 = GENMASK(32, 30);
| ^~~~~~~Please take a look at this.
Regards,
Hans
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees