linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel W. S. Almeida" <dwlsalmeida@gmail.com>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: kstewart@linuxfoundation.org, sean@mess.org,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	linux-kernel-mentees@lists.linuxfoundation.org,
	allison@lohutok.net, linux-media@vger.kernel.org
Subject: Re: [Linux-kernel-mentees] [RFC, WIP, v4 05/11] media: vidtv: add a bridge driver
Date: Sat, 2 May 2020 18:12:06 -0300	[thread overview]
Message-ID: <ce98a09d-0f46-bff2-e0fd-fddbec81a815@gmail.com> (raw)
In-Reply-To: <20200502083030.2314349d@coco.lan>

Hi Mauro, thanks for reviewing this.

On 5/2/20 3:30 AM, Mauro Carvalho Chehab wrote:
 > Em Sat,  2 May 2020 00:22:10 -0300
 > "Daniel W. S. Almeida" <dwlsalmeida@gmail.com> escreveu:
 >
 >> From: "Daniel W. S. Almeida" <dwlsalmeida@gmail.com>
 >>
 >> 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.
 >>
 >> Move config structs to a common header so they can be used by the bridge
 >> driver and by their respective drivers.
 >>
 >> Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
 >> ---
 >>   drivers/media/test-drivers/vidtv/Makefile     |   2 +-
 >>   .../media/test-drivers/vidtv/vidtv_bridge.c   | 379 ++++++++++++++++++
 >>   .../media/test-drivers/vidtv/vidtv_bridge.h   |  37 ++
 >>   3 files changed, 417 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
 >>
 >> diff --git a/drivers/media/test-drivers/vidtv/Makefile 
b/drivers/media/test-drivers/vidtv/Makefile
 >> index 36ba00ddc0d1e..a9f1993dd5443 100644
 >> --- a/drivers/media/test-drivers/vidtv/Makefile
 >> +++ b/drivers/media/test-drivers/vidtv/Makefile
 >> @@ -1,3 +1,3 @@
 >>   # SPDX-License-Identifier: GPL-2.0
 >>
 >> -obj-$(CONFIG_DVB_VIDTV)	+= vidtv_tuner.o  vidtv_demod.o
 >> +obj-$(CONFIG_DVB_VIDTV)	+= vidtv_tuner.o vidtv_demod.o vidtv_bridge.o
 >> diff --git a/drivers/media/test-drivers/vidtv/vidtv_bridge.c 
b/drivers/media/test-drivers/vidtv/vidtv_bridge.c
 >> new file mode 100644
 >> index 0000000000000..05ca4027c869f
 >> --- /dev/null
 >> +++ b/drivers/media/test-drivers/vidtv/vidtv_bridge.c
 >> @@ -0,0 +1,379 @@
 >> +// SPDX-License-Identifier: GPL-2.0
 >> +/*
 >> + * The Virtual DTV 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.
 >> + *
 >> + * Written by Daniel W. S. Almeida <dwlsalmeida@gmail.com>
 >> + */
 >> +
 >> +#include <linux/types.h>
 >> +#include <linux/moduleparam.h>
 >> +#include <linux/mutex.h>
 >> +#include <linux/workqueue.h>
 >> +#include <linux/time.h>
 >> +#include "vidtv_bridge.h"
 >> +
 >> +#define TS_BUF_MAX_SZ (128 * 188)
 >> +#define TUNER_DEFAULT_ADDR 0x68
 >> +#define DEMOD_DEFAULT_ADDR 0x60
 >> +
 >> +MODULE_AUTHOR("Daniel W. S. Almeida");
 >> +MODULE_LICENSE("GPL");
 >> +
 >
 >> +static unsigned int drop_tslock_prob_on_low_snr;
 >> +module_param(drop_tslock_prob_on_low_snr, uint, 0644);
 >> +MODULE_PARM_DESC(drop_tslock_prob_on_low_snr,
 >> +		 "Probability of losing the TS lock if the signal quality is bad");
 >> +
 >> +static unsigned int recover_tslock_prob_on_good_snr;
 >> +module_param(recover_tslock_prob_on_good_snr, uint, 0644);
 >> +MODULE_PARM_DESC(recover_tslock_prob_on_good_snr,
 >> +		 "Probability recovering the TS lock when the signal improves");
 >
 > The FS permissions should be reviewed. IMHO, we should allow the
 > group which owns the /dev to be able to change values when they can
 > be changed in runtime.
 >
 > Yet, be sure that changing it on runtime won't cause race conditions.
 >
 > For the two above, I guess the permissions for those should be, instead,
 > 0664.
 >
 >> +
 >> +static unsigned int mock_power_up_delay_msec;
 >> +module_param(mock_power_up_delay_msec, uint, 0644);
 >> +MODULE_PARM_DESC(mock_power_up_delay_msec, "Simulate a power up 
delay");
 >
 > What's the sense of allowing changing it after the probe? I guess
 > permissions should be 0444 here.
 >
 >> +
 >> +static unsigned int mock_tune_delay_msec;
 >> +module_param(mock_tune_delay_msec, uint, 0644);
 >> +MODULE_PARM_DESC(mock_tune_delay_msec, "Simulate a tune delay");
 >
 > Same here: I guess 0664 would work better.
 >
 >> +
 >> +static unsigned int vidtv_valid_dvb_t_freqs[8];
 >> +module_param_array(vidtv_valid_dvb_t_freqs, uint, NULL, 0644);
 >> +MODULE_PARM_DESC(vidtv_valid_dvb_t_freqs,
 >> +		 "Valid DVB-T frequencies to simulate");
 >> +
 >> +static unsigned int vidtv_valid_dvb_c_freqs[8];
 >> +module_param_array(vidtv_valid_dvb_c_freqs, uint, NULL, 0644);
 >> +MODULE_PARM_DESC(vidtv_valid_dvb_c_freqs,
 >> +		 "Valid DVB-C frequencies to simulate");
 >> +
 >> +static unsigned int vidtv_valid_dvb_s_freqs[8];
 >> +module_param_array(vidtv_valid_dvb_s_freqs, uint, NULL, 0644);
 >> +MODULE_PARM_DESC(vidtv_valid_dvb_s_freqs,
 >> +		 "Valid DVB-C frequencies to simulate");
 >
 > Can those be changed in runtime without causing race conditions?
 >
 >> +
 >> +static unsigned int max_frequency_shift_hz;
 >> +module_param(max_frequency_shift_hz, uint, 0644);
 >> +MODULE_PARM_DESC(max_frequency_shift_hz,
 >> +		 "Maximum shift in HZ allowed when tuning in a channel");
 >
 > 0664?
 >
 >> +
 >> +static unsigned int chosen_delsys = SYS_DVBT;
 >> +module_param(chosen_delsys, uint, 0644);
 >> +MODULE_PARM_DESC(chosen_delsys,
 >> +		 "The delivery system to simulate. Currently supported: DVB-T, 
DVB-C, DVB-S");
 >
 > Hmm... in order to allow changing this value on runtime, as you proposed,
 > you should use module_param_cb(). The callback would allow touching the
 > delsys only if the driver is not in use. Otherwise, it would return 
-EBUSY.
 > Also, permissions should be 0664.

Actually, my bad here. I used some other media driver as an example for 
module_param(), I did not intend to be able to change any of these 
during runtime at all, I only wanted to be able to set them at module 
load time. In fact, IIRC, these parameters are used when first setting 
up the driver and then they are not used anymore. Therefore, maybe "0" 
is more fitting?

 > Hmm... in order to allow changing this value on runtime, as you proposed,
 > you should use module_param_cb(). The callback would allow touching the
 > delsys only if the driver is not in use. Otherwise, it would return 
-EBUSY.
 > Also, permissions should be 0664.
 >
 > Btw, after thinking a little bit about that, I would take one step 
back on
 > my demod review, changing it and the bridge's logic to allow 
chosen_delsys,
 > while keeping just one struct for DVB info parameters.
 >
 > The way I see is that the logic here should be changed in order to use a
 > a bitmask for the chosen_delsys, like:
 >
 > 	bit 0: DVB-T
 > 	bit 1: DVB-T2
 > 	bit 2: DVB-C
 > 	bit 3: DVB-S
 > 	bit 4: DVB-S2
 >
 > Of course you will need to document the meaning for each bit somewhere.
 >
 > The default should be to have all supported types enabled.
 >
 > As there's no ops that would allow the bridge driver to change it
 > dynamically, you should instead implement the "chosen_delsys" directly
 > at the demod's driver.

Given what I said above about it being a misunderstanding on my part, do 
you still want to see this?

 > while keeping just one struct for DVB info parameters.

What do you mean by this?


 >> +static unsigned int ts_buf_sz = 20 * 188;
 >> +module_param(ts_buf_sz, uint, 0644);
 >> +MODULE_PARM_DESC(ts_buf_sz, "Optional size for the TS buffer");
 >
 > Huh? Userspace can already change it via an ioctl. Why adding a parameter
 > for that?

This is actually misplaced: it was supposed to be in the last patch for 
this series and probably got left behind as I was moving code around.

Maybe the name I chose was a bit confusing? I called the code 
responsible for collecting ES data from different encoders into a single 
buffer a "mux". Its buffer was thus named "ts_buf". This parameter 
dictates the size allocated at runtime with vmalloc(). This buffer later 
gets passed to dvb_dmx_swfilter().

The source code for this is in patch 11.

It is loosely based on what ffmpeg has going on at libavformat/mpegtsenc.c


- Daniel

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2020-05-02 21:12 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02  3:22 [Linux-kernel-mentees] [RFC, WIP, v4 00/11] media: vidtv: implement a virtual DVB driver Daniel W. S. Almeida
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 01/11] media: vidtv: add Kconfig entry Daniel W. S. Almeida
2020-05-02  4:58   ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 02/11] media: vidtv: implement a tuner driver Daniel W. S. Almeida
2020-05-02  5:27   ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 03/11] media: vidtv: implement a demodulator driver Daniel W. S. Almeida
2020-05-02  5:58   ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 04/11] media: vidtv: move config structs into a separate header Daniel W. S. Almeida
2020-05-02  6:02   ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 05/11] media: vidtv: add a bridge driver Daniel W. S. Almeida
2020-05-02  6:30   ` Mauro Carvalho Chehab
2020-05-02 21:12     ` Daniel W. S. Almeida [this message]
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 06/11] media: vidtv: add wrappers for memcpy and memset Daniel W. S. Almeida
2020-05-02  6:40   ` Mauro Carvalho Chehab
2020-05-03  7:06     ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 07/11] media: vidtv: add MPEG TS common code Daniel W. S. Almeida
2020-05-02  7:09   ` Mauro Carvalho Chehab
2020-05-02 22:22     ` Daniel W. S. Almeida
2020-05-03  9:50       ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 08/11] media: vidtv: implement a PSI generator Daniel W. S. Almeida
2020-05-03  7:51   ` Mauro Carvalho Chehab
2020-05-06  6:28     ` Daniel W. S. Almeida
2020-05-06  8:36       ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 09/11] media: vidtv: implement a PES packetizer Daniel W. S. Almeida
2020-05-03  8:16   ` Mauro Carvalho Chehab
2020-05-06  6:55     ` Daniel W. S. Almeida
2020-05-06  8:59       ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 10/11] media: vidtv: Implement a SMPTE 302M encoder Daniel W. S. Almeida
2020-05-03  8:57   ` Mauro Carvalho Chehab
2020-05-02  3:22 ` [Linux-kernel-mentees] [RFC, WIP, v4 11/11] media: vidtv: Add a MPEG Transport Stream Multiplexer Daniel W. S. Almeida
2020-05-03  9:13   ` Mauro Carvalho Chehab
2020-05-06  7:05     ` Daniel W. S. Almeida
2020-05-06  9:01       ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce98a09d-0f46-bff2-e0fd-fddbec81a815@gmail.com \
    --to=dwlsalmeida@gmail.com \
    --cc=allison@lohutok.net \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=sean@mess.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).