Better handle pads for tuning/decoder part of the devices
Subsystems (5)
cover Better handle pads for tuning/decoder part of the devices
At PC consumer devices, it is very common that the bridge same driver to be attached to different types of tuners and demods. We need a way for the Kernel to properly identify what kind of signal is provided by each PAD, in order to properly setup the pipelines.
The previous approach were to hardcode a fixed number of PADs for all elements of the same type. This is not good, as different devices may actually have a different number of pads.
It was acceptable in the past, as there were a promisse of adding "soon" a properties API that would allow to identify the type for each PADs, but this was never merged (or even a patchset got submitted).
So, replace this approach by another one: add a "taint" mark to pads that contain different types of signals.
I tried to minimize the number of signals, in order to make it simpler to convert from the past way.
For now, it is tested only with a simple grabber device. I intend to do more tests before merging it, but it would be interesting to have this merged for Kernel 4.19, as we'll now be exposing the pad index via the MC API version 2.
Mauro Carvalho Chehab (13):
media: v4l2: remove VBI output pad
media: v4l2: taint pads with the signal types for consumer devices
v4l2-mc: switch it to use the new approach to setup pipelines
media: dvb: use signals to discover pads
media: au0828: use signals instead of hardcoding a pad number
media: au8522: declare its own pads
media: msp3400: declare its own pads
media: saa7115: declare its own pads
media: tvp5150: declare its own pads
media: si2157: declare its own pads
media: saa7134: declare its own pads
media: mxl111sf: declare its own pads
media: v4l2-mc: get rid of global pad indexes
drivers/media/dvb-core/dvbdev.c | 19 +++-- drivers/media/dvb-frontends/au8522_decoder.c | 10 ++- drivers/media/dvb-frontends/au8522_priv.h | 9 ++- drivers/media/i2c/msp3400-driver.c | 6 +- drivers/media/i2c/msp3400-driver.h | 8 +- drivers/media/i2c/saa7115.c | 18 +++-- drivers/media/i2c/tvp5150.c | 21 ++++-- drivers/media/media-entity.c | 26 +++++++ drivers/media/pci/saa7134/saa7134-core.c | 9 ++- drivers/media/pci/saa7134/saa7134.h | 8 +- drivers/media/tuners/si2157.c | 11 ++- drivers/media/tuners/si2157_priv.h | 9 ++- drivers/media/usb/au0828/au0828-core.c | 12 +-- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 8 +- drivers/media/usb/dvb-usb-v2/mxl111sf.h | 8 +- drivers/media/v4l2-core/tuner-core.c | 18 +++++ drivers/media/v4l2-core/v4l2-mc.c | 73 +++++++++++++----- include/media/media-entity.h | 54 ++++++++++++++ include/media/v4l2-mc.h | 78 -------------------- 19 files changed, 266 insertions(+), 139 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/13 media: v4l2: remove VBI output pad
The signal there is the same as the video output (well, except for sliced VBI, but let's simplify the model and ignore it, at least for now - as it is routed together with raw VBI).
--- drivers/media/dvb-frontends/au8522_decoder.c | 1 - drivers/media/i2c/saa7115.c | 1 - drivers/media/i2c/tvp5150.c | 1 - drivers/media/pci/saa7134/saa7134-core.c | 1 - drivers/media/v4l2-core/v4l2-mc.c | 2 +- include/media/v4l2-mc.h | 2 -- 6 files changed, 1 insertion(+), 7 deletions(-)
drivers/media/dvb-frontends/au8522_decoder.c +0 -1
@@ -720,7 +720,6 @@ static int au8522_probe(struct i2c_client *client, state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; state->pads[DEMOD_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/i2c/saa7115.c +0 -1
@@ -1836,7 +1836,6 @@ static int saa711x_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/i2c/tvp5150.c +0 -1
@@ -1501,7 +1501,6 @@ static int tvp5150_probe(struct i2c_client *c,#if defined(CONFIG_MEDIA_CONTROLLER ) core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - core->pads[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/pci/saa7134/saa7134-core.c +0 -1
@@ -847,7 +847,6 @@ static void saa7134_create_entities(struct saa7134_dev *dev) dev->demod.name ="saa713x" ; dev->demod_pad[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; dev->demod_pad[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->demod_pad[DEMOD_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; dev->demod.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS,
drivers/media/v4l2-core/v4l2-mc.c +1 -1
@@ -147,7 +147,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_vbi) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VBI_OUT , + ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , io_vbi,0 ,MEDIA_LNK_FL_ENABLED );if (ret)
include/media/v4l2-mc.h +0 -2
@@ -89,14 +89,12 @@ enum if_aud_dec_pad_index {* * @DEMOD_PAD_IF_INPUT: IF input sink pad. * @DEMOD_PAD_VID_OUT: Video output source pad. -* @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad. * @DEMOD_PAD_AUDIO_OUT: Audio output source pad. * @DEMOD_NUM_PADS: Maximum number of output pads. */ enum demod_pad_index {DEMOD_PAD_IF_INPUT ,DEMOD_PAD_VID_OUT , -DEMOD_PAD_VBI_OUT ,DEMOD_PAD_AUDIO_OUT ,DEMOD_NUM_PADS };
Signature · 1 line
2.17.1
PATCH 2/13 media: v4l2: taint pads with the signal types for consumer devices
In reply to Mauro Carvalho ChehabConsumer devices are provided with a wide diferent range of types supported by the same driver, allowing different configutations.
In order to make easier to setup media controller links, "taint" pads with the signal type it carries.
While here, get rid of DEMOD_PAD_VBI_OUT, as the signal it carries is actually the same as the normal video output.
The difference happens at the video/VBI interface:
- for VBI, only the hidden lines are streamed;
- for video, the stream is usually cropped to hide the vbi lines.
--- drivers/media/dvb-frontends/au8522_decoder.c | 3 ++ drivers/media/i2c/msp3400-driver.c | 2 ++ drivers/media/i2c/saa7115.c | 2 ++ drivers/media/i2c/tvp5150.c | 2 ++ drivers/media/pci/saa7134/saa7134-core.c | 2 ++ drivers/media/tuners/si2157.c | 3 ++ drivers/media/usb/dvb-usb-v2/mxl111sf.c | 2 ++ drivers/media/v4l2-core/tuner-core.c | 5 +++ include/media/media-entity.h | 35 ++++++++++++++++++++ 9 files changed, 56 insertions(+)
drivers/media/dvb-frontends/au8522_decoder.c +3 -0
@@ -719,8 +719,11 @@ static int au8522_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; state->pads[DEMOD_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[DEMOD_PAD_AUDIO_OUT ].sig_type =PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
drivers/media/i2c/msp3400-driver.c +2 -0
@@ -704,7 +704,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[IF_AUD_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[IF_AUD_DEC_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_AUDIO ; state->pads[IF_AUD_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[IF_AUD_DEC_PAD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_IF_AUD_DECODER ;
drivers/media/i2c/saa7115.c +2 -0
@@ -1835,7 +1835,9 @@ static int saa711x_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/i2c/tvp5150.c +2 -0
@@ -1500,7 +1500,9 @@ static int tvp5150_probe(struct i2c_client *c,#if defined(CONFIG_MEDIA_CONTROLLER ) core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + core->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + core->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/pci/saa7134/saa7134-core.c +2 -0
@@ -846,7 +846,9 @@ static void saa7134_create_entities(struct saa7134_dev *dev)if (!decoder) { dev->demod.name ="saa713x" ; dev->demod_pad[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + dev->demod_pad[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; dev->demod_pad[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->demod_pad[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; dev->demod.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS,
drivers/media/tuners/si2157.c +3 -0
@@ -469,8 +469,11 @@ static int si2157_probe(struct i2c_client *client, dev->ent.function =MEDIA_ENT_F_TUNER ; dev->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + dev->pad[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; dev->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->pad[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; dev->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->pad[TUNER_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; ret =media_entity_pads_init (&dev->ent,TUNER_NUM_PADS , &dev->pad[0 ]);
drivers/media/usb/dvb-usb-v2/mxl111sf.c +2 -0
@@ -893,7 +893,9 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) state->tuner.function =MEDIA_ENT_F_TUNER ; state->tuner.name ="mxl111sf tuner" ; state->tuner_pads[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->tuner_pads[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; state->tuner_pads[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->tuner_pads[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; ret =media_entity_pads_init (&state->tuner,TUNER_NUM_PADS , state->tuner_pads);
drivers/media/v4l2-core/tuner-core.c +5 -0
@@ -685,15 +685,20 @@ static int tuner_probe(struct i2c_client *client,*/ if (t->type ==TUNER_TDA9887 ) { t->pad[IF_VID_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + t->pad[IF_VID_DEC_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; t->pad[IF_VID_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[IF_VID_DEC_PAD_OUT ].sig_type =PAD_SIGNAL_DV ; ret =media_entity_pads_init (&t->sd.entity,IF_VID_DEC_PAD_NUM_PADS , &t->pad[0 ]); t->sd.entity.function =MEDIA_ENT_F_IF_VID_DECODER ; }else { t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + t->pad[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; t->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + t->pad[TUNER_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; ret =media_entity_pads_init (&t->sd.entity,TUNER_NUM_PADS , &t->pad[0 ]); t->sd.entity.function =MEDIA_ENT_F_TUNER ;
include/media/media-entity.h +35 -0
@@ -155,6 +155,40 @@ struct media_link {bool is_backlink; }; +/** +* struct media_pad_signal_type - type of the signal inside a media pad +* +* @PAD_SIGNAL_DEFAULT +* Default signal. Use this when all inputs or all outputs are +* uniquely identified by the pad number. +* @PAD_SIGNAL_ANALOG +* The pad contains an analog signa. It can be Radio Frequency, +* Intermediate Frequency or baseband signal. +* Tuner inputs, composite and s-video signals should use it. +* On tuner sources, this is used for digital TV demodulators and for +* IF-PLL demodulator like tda9887. +* @PAD_SIGNAL_TV_CARRIERS +* The pad contains analog signals carrying either a digital or an analog +* modulated (or baseband) signal. This is provided by tuner source +* pads and used by analog TV standard decoders and by digital TV demods. +* @PAD_SIGNAL_DV +* Contains a digital video signal, with can be a bitstream of samples +* taken from an analog TV video source. On such case, it usually +* contains the VBI data on it. +* @PAD_SIGNAL_AUDIO +* Contains an Intermediate Frequency analog signal from an audio +* sub-carrier or an audio bitstream. IF signals are provided by tuners +* and consumed by audio AM/FM decoders. Bitstream audio is provided by +* an audio decoder. +*/ +enum media_pad_signal_type { +PAD_SIGNAL_DEFAULT =0 , +PAD_SIGNAL_ANALOG , +PAD_SIGNAL_TV_CARRIERS , +PAD_SIGNAL_DV , +PAD_SIGNAL_AUDIO , +}; +/** * struct media_pad - A media pad graph object. *
@@ -169,6 +203,7 @@ struct media_pad {struct media_gobj graph_obj;/* must be first field in struct */ struct media_entity *entity;u16 index; +enum media_pad_signal_type sig_type;unsigned long flags; };
Signature · 1 line
2.17.1
Laurent Pinchart
maintainerRe: [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices
Hi Mauro,
Thank you for the patch.
Could you please CC me on patches touching the media controller core ? I can send a MAINTAINERS patch to make sure that gets handled automatically.
Quoted 26 lines · On Wednesday, 1 August 2018 18:55:04 EEST Mauro Carvalho Chehab wrote:
Consumer devices are provided with a wide diferent range of types supported by the same driver, allowing different configutations.
In order to make easier to setup media controller links, "taint" pads with the signal type it carries.
While here, get rid of
DEMOD_PAD_VBI_OUT, as the signal it carries is actually the same as the normal video output.The difference happens at the video/VBI interface:
- for VBI, only the hidden lines are streamed;
- for video, the stream is usually cropped to hide the vbi lines.Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/dvb-frontends/au8522_decoder.c | 3 ++ drivers/media/i2c/msp3400-driver.c | 2 ++ drivers/media/i2c/saa7115.c | 2 ++ drivers/media/i2c/tvp5150.c | 2 ++ drivers/media/pci/saa7134/saa7134-core.c | 2 ++ drivers/media/tuners/si2157.c | 3 ++ drivers/media/usb/dvb-usb-v2/mxl111sf.c | 2 ++ drivers/media/v4l2-core/tuner-core.c | 5 +++ include/media/media-entity.h | 35 ++++++++++++++++++++ 9 files changed, 56 insertions(+)
[snip]
include/media/media-entity.h struct media_link { · line 159
Quoted 10 lines
include/media/media-entity.h +2
-0@@ -155,6 +155,40 @@ struct media_link {bool is_backlink; }; +/** +* struct media_pad_signal_type - type of the signal inside a media pad
I'd say "carried by a media pad" instead of "inside a media pad".
include/media/media-entity.h struct media_link { · line 161
Quoted 2 lines
include/media/media-entity.h +2
-0+* +* @PAD_SIGNAL_DEFAULT
Shouldn't we use a MEDIA_PAD_ prefix ?
include/media/media-entity.h struct media_link { · line 163
Quoted 2 lines
include/media/media-entity.h +2
-0+* Default signal. Use this when all inputs or all outputs are +* uniquely identified by the pad number.
How about "Use this when the pad can carry a single signal type" ? I understand your formulation as meaning that all pads of the entity have to be of the default type, or none can be.
include/media/media-entity.h struct media_link { · line 164
Quoted 1 line
include/media/media-entity.h +1
-0+* @PAD_SIGNAL_ANALOG
This isn't a very good name given that PAD_SIGNAL_TV_CARRIERS is also analog.
include/media/media-entity.h struct media_link { · line 165
Quoted 1 line
include/media/media-entity.h +1
-0+* The pad contains an analog signa. It can be Radio Frequency,
s/signa/signal/
include/media/media-entity.h struct media_link {
Quoted 7 lines
include/media/media-entity.h +7
-0+* Intermediate Frequency or baseband signal. +* Tuner inputs, composite and s-video signals should use it. +* On tuner sources, this is used for digital TV demodulators and for +* IF-PLL demodulator like tda9887. +* @PAD_SIGNAL_TV_CARRIERS +* The pad contains analog signals carrying either a digital or an analog +* modulated (or baseband) signal.
As above, maybe "The pad carries either ...".
Quoted 10 lines
This is provided by tuner source
+ * pads and used by analog TV standard decoders and by digital TV demods.
+ * @PAD_SIGNAL_DV
+ * Contains a digital video signal, with can be a bitstream of samples
+ * taken from an analog TV video source. On such case, it usually
+ * contains the VBI data on it.
+ * @PAD_SIGNAL_AUDIO
+ * Contains an Intermediate Frequency analog signal from an audio
+ * sub-carrier or an audio bitstream. IF signals are provided by tuners
+ * and consumed by audio AM/FM decoders. Bitstream audio is provided by
s/ / /
Quoted 1 line
+ * an audio decoder.
Generally speaking the types you propose here seem quite ad-hoc, without much coherency. For instance you split analog and digital video, but group all audio under a single type. It's also not very clear from the description how to handle analog video, as it could match both PAD_SIGNAL_ANALOG and PAD_SIGNAL_TV_CARRIERS. Both of those types also accept analog baseband signals. I think this should be reworked, it doesn't sound very usable except for the specific use case that this series tries to address.
Quoted 13 lines
+ */
include/media/media-entity.h +8
-0+enum media_pad_signal_type { +PAD_SIGNAL_DEFAULT =0 , +PAD_SIGNAL_ANALOG , +PAD_SIGNAL_TV_CARRIERS , +PAD_SIGNAL_DV , +PAD_SIGNAL_AUDIO , +}; +/** * struct media_pad - A media pad graph object. *
include/media/media-entity.h struct media_pad { · line 206
Quoted 4 lines
include/media/media-entity.h +1
-0@@ -169,6 +203,7 @@ struct media_pad {struct media_gobj graph_obj;/* must be first field in struct */ struct media_entity *entity;u16 index; +enum media_pad_signal_type sig_type;
Missing kerneldoc and Documentation/ update ? It's important to document the use cases, and in particular whether the type should be static or can vary (as in whether a pad can carry different types over time).
Quoted 2 lines
include/media/media-entity.h +0
-0unsigned long flags; };
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices
Em Wed, 26 Sep 2018 17:09:19 +0300
Laurent Pinchart <[email protected]> escreveu:
Quoted 45 lines
Hi Mauro,
Thank you for the patch.
Could you please CC me on patches touching the media controller core ? I can send a
MAINTAINERSpatch to make sure that gets handled automatically.Quoted 26 lines · On Wednesday, 1 August 2018 18:55:04 EEST Mauro Carvalho Chehab wrote:
Consumer devices are provided with a wide diferent range of types supported by the same driver, allowing different configutations.
In order to make easier to setup media controller links, "taint" pads with the signal type it carries.
While here, get rid of
DEMOD_PAD_VBI_OUT, as the signal it carries is actually the same as the normal video output.The difference happens at the video/VBI interface:
- for VBI, only the hidden lines are streamed;
- for video, the stream is usually cropped to hide the vbi lines.Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/dvb-frontends/au8522_decoder.c | 3 ++ drivers/media/i2c/msp3400-driver.c | 2 ++ drivers/media/i2c/saa7115.c | 2 ++ drivers/media/i2c/tvp5150.c | 2 ++ drivers/media/pci/saa7134/saa7134-core.c | 2 ++ drivers/media/tuners/si2157.c | 3 ++ drivers/media/usb/dvb-usb-v2/mxl111sf.c | 2 ++ drivers/media/v4l2-core/tuner-core.c | 5 +++ include/media/media-entity.h | 35 ++++++++++++++++++++ 9 files changed, 56 insertions(+)[snip]
Quoted 8 lines
include/media/media-entity.h +0
-0@@ -155,6 +155,40 @@ struct media_link {bool is_backlink; };
Quoted 4 lines
include/media/media-entity.h struct media_link { · line 159
Quoted 2 lines
include/media/media-entity.h +2
-0+/** +* struct media_pad_signal_type - type of the signal inside a media pad I'd say "carried by a media pad" instead of "inside a media pad".
Ok.
Quoted 5 lines
include/media/media-entity.h struct media_link { · line 161
Quoted 3 lines
include/media/media-entity.h +2
-0+* +* @PAD_SIGNAL_DEFAULT Shouldn't we use a
MEDIA_PAD_prefix ?
Ok.
Quoted 7 lines
include/media/media-entity.h struct media_link { · line 163
Quoted 3 lines
include/media/media-entity.h +2
-0+* Default signal. Use this when all inputs or all outputs are +* uniquely identified by the pad number. How about "Use this when the pad can carry a single signal type" ? I understand your formulation as meaning that all pads of the entity have to be of the default type, or none can be.
Describing the MEDIA_PAD_SIGNAL_DEFAULT is not trivial.
Basically, almost all pads at the subsystem are MEDIA_PAD_SIGNAL_DEFAULT.
Only certain types of entities need to "taint" the pad (usually, the entities related to the tuning and audio/video decoding stages).
In other words, the decision if it should either use MEDIA_PAD_SIGNAL_DEFAULT or not is per-entity (and not per-pad).
Typically, it is needed when a certain entity function may have pads at the same direction with different meanings.
A real example would be a digital tuner entity that has two pad sources:
- pad source #0 - carries a RF signal;
- pad source #1 - carries a digital audio signal.
On this case, both pad sources should use a signal different than MEDIA_PAD_SIGNAL_DEFAULT.
Writing it on a concise way is not a trivial task ;-)
Maybe something like would work:
"Default signal. Use this when there's no need to specify the
signal carried inside a pad."
Quoted 8 lines
include/media/media-entity.h struct media_link { · line 164
Quoted 2 lines
include/media/media-entity.h +1
-0+* @PAD_SIGNAL_ANALOG This isn't a very good name given that
PAD_SIGNAL_TV_CARRIERSis also analog.include/media/media-entity.h struct media_link { · line 165
Quoted 1 line
include/media/media-entity.h +1
-0+* The pad contains an analog signa. It can be Radio Frequency, s/signa/signal/
Ok (this is actually fixed already at the version applied).
Quoted 9 lines
include/media/media-entity.h struct media_link { · line 172
Quoted 7 lines
include/media/media-entity.h +7
-0+* Intermediate Frequency or baseband signal. +* Tuner inputs, composite and s-video signals should use it. +* On tuner sources, this is used for digital TV demodulators and for +* IF-PLL demodulator like tda9887. +* @PAD_SIGNAL_TV_CARRIERS +* The pad contains analog signals carrying either a digital or an analog +* modulated (or baseband) signal. As above, maybe "The pad carries either ...".
Replaced "contains" with "carries".
Quoted 15 lines
Quoted 10 lines
This is provided by tuner source
+ * pads and used by analog TV standard decoders and by digital TV demods.
+ * @PAD_SIGNAL_DV
+ * Contains a digital video signal, with can be a bitstream of samples
+ * taken from an analog TV video source. On such case, it usually
+ * contains the VBI data on it.
+ * @PAD_SIGNAL_AUDIO
+ * Contains an Intermediate Frequency analog signal from an audio
+ * sub-carrier or an audio bitstream. IF signals are provided by tuners
+ * and consumed by audio AM/FM decoders. Bitstream audio is provided bys/ / /
Quoted 1 line
+ * an audio decoder.
Quoted 7 lines
Generally speaking the types you propose here seem quite ad-hoc, without much coherency. For instance you split analog and digital video, but group all audio under a single type. It's also not very clear from the description how to handle analog video, as it could match both
PAD_SIGNAL_ANALOGandPAD_SIGNAL_TV_CARRIERS. Both of those types also accept analog baseband signals. I think this should be reworked, it doesn't sound very usable except for the specific use case that this series tries to address.
The goal here is to be able "taint" the signal to a certain group. It might have been called as "blue", "red", "green", but using a more coherent name for a group where the signal belongs make easier to add the right taints at the pads.
With regards with PAD_SIGNAL_ANALOG versus PAD_SIGNAL_TV_CARRIERS, fully agreed.
Actually, I noticed the same issue you pointed: it is not clear where to use PAD_SIGNAL_ANALOG or PAD_SIGNAL_TV_CARRIERS. So, I got rid of the latter at the second version of this patch:
Date: Sat, 15 Sep 2018 17:14:17 -0300 Subject: [PATCH v2 02/14] media: v4l2: taint pads with the signal types for consumer devices
After that, there are only 3 types of signal:
PAD_SIGNAL_ANALOG - any kind of analog signal (either baseband or RF/IF)
PAD_SIGNAL_DV - any kind of digital video signal
PAD_SIGNAL_AUDIO - any kind of audio signal (either analog or digital)
Quoted 13 lines
Quoted 13 lines
+ */
include/media/media-entity.h +8
-0+enum media_pad_signal_type { +PAD_SIGNAL_DEFAULT =0 , +PAD_SIGNAL_ANALOG , +PAD_SIGNAL_TV_CARRIERS , +PAD_SIGNAL_DV , +PAD_SIGNAL_AUDIO , +}; +/** * struct media_pad - A media pad graph object. * @@ -169,6 +203,7 @@ struct media_pad {
Quoted 8 lines
include/media/media-entity.h struct media_pad { · line 206
Quoted 4 lines
include/media/media-entity.h +1
-0struct media_gobj graph_obj;/* must be first field in struct */ struct media_entity *entity;u16 index; +enum media_pad_signal_type sig_type;Missing kerneldoc and
Documentation/update ? It's important to document the use cases, and in particular whether the type should be static or can vary (as in whether a pad can carry different types over time).
I don't see any use cases where the type of the signal can vary over time. If we ever need that, then we would need another signal type (like MEDIA_PAD_DYNAMIC_AUDIO_OR_VIDEO).
What about this?
* @sig_type: Type of the signal that a media pad supports. This is used * when an entity function may have different kinds of signals * on different pads of the same direction (source/sink). For * example, if an entity has 2 pad sinks where one carries * an analog video while the other carries an audio signal.
Quoted 4 lines
include/media/media-entity.h struct media_pad { · line 208
Quoted 2 lines
include/media/media-entity.h +0
-0unsigned long flags; };
Thanks,
Mauro
media: improve media pad signal documentation
There are some things at the media pad signal documentation that are not precise. Improve its documentation and rename from
PAD_SIGNAL_* -> MEDIA_PAD_SIGNAL
in order to better document its usage inside the drivers.
drivers/media/dvb-core/dvbdev.c +2 -2
@@ -691,7 +691,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, false); }else { pad_sink =media_get_pad_index (tuner, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_sink <0 )return -EINVAL ; ret = media_create_pad_links(mdev,
@@ -708,7 +708,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,if (ntuner && ndemod) { pad_source =media_get_pad_index (tuner, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_source)return -EINVAL ; ret = media_create_pad_links(mdev,
drivers/media/dvb-frontends/au8522_decoder.c +3 -3
@@ -719,11 +719,11 @@ static int au8522_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[AU8522_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[AU8522_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->pads[AU8522_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[AU8522_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + state->pads[AU8522_PAD_VID_OUT ].sig_type =MEDIA_PAD_SIGNAL_DV ; state->pads[AU8522_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[AU8522_PAD_AUDIO_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[AU8522_PAD_AUDIO_OUT ].sig_type =MEDIA_PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
drivers/media/i2c/msp3400-driver.c +2 -2
@@ -704,9 +704,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[MSP3400_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[MSP3400_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[MSP3400_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_AUDIO ; state->pads[MSP3400_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[MSP3400_PAD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[MSP3400_PAD_OUT ].sig_type =MEDIA_PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_IF_AUD_DECODER ;
drivers/media/i2c/saa7115.c +2 -2
@@ -1841,9 +1841,9 @@ static int saa711x_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) state->pads[SAA711X_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[SAA711X_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->pads[SAA711X_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; state->pads[SAA711X_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[SAA711X_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + state->pads[SAA711X_PAD_VID_OUT ].sig_type =MEDIA_PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/i2c/tvp5150.c +2 -2
@@ -1738,9 +1738,9 @@ static int tvp5150_probe(struct i2c_client *c,#if defined(CONFIG_MEDIA_CONTROLLER ) core->pads[TVP5150_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - core->pads[TVP5150_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + core->pads[TVP5150_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; core->pads[TVP5150_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - core->pads[TVP5150_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + core->pads[TVP5150_PAD_VID_OUT ].sig_type =MEDIA_PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ;
drivers/media/pci/saa7134/saa7134-core.c +2 -2
@@ -846,9 +846,9 @@ static void saa7134_create_entities(struct saa7134_dev *dev)if (!decoder) { dev->demod.name ="saa713x" ; dev->demod_pad[SAA7134_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - dev->demod_pad[SAA7134_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + dev->demod_pad[SAA7134_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; dev->demod_pad[SAA7134_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->demod_pad[SAA7134_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + dev->demod_pad[SAA7134_PAD_VID_OUT ].sig_type =MEDIA_PAD_SIGNAL_DV ; dev->demod.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&dev->demod, SAA7134_NUM_PADS,
drivers/media/tuners/si2157.c +3 -3
@@ -469,11 +469,11 @@ static int si2157_probe(struct i2c_client *client, dev->ent.function =MEDIA_ENT_F_TUNER ; dev->pad[SI2157_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - dev->pad[SI2157_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + dev->pad[SI2157_PAD_RF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; dev->pad[SI2157_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->pad[SI2157_PAD_VID_OUT ].sig_type =PAD_SIGNAL_ANALOG ; + dev->pad[SI2157_PAD_VID_OUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; dev->pad[SI2157_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->pad[SI2157_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + dev->pad[SI2157_PAD_AUD_OUT ].sig_type =MEDIA_PAD_SIGNAL_AUDIO ; ret =media_entity_pads_init (&dev->ent,SI2157_NUM_PADS , &dev->pad[0 ]);
drivers/media/usb/au0828/au0828-core.c +1 -1
@@ -267,7 +267,7 @@ static void au0828_media_graph_notify(struct media_entity *new, create_link:if (decoder && mixer) { ret =media_get_pad_index (decoder, false, -PAD_SIGNAL_AUDIO ); +MEDIA_PAD_SIGNAL_AUDIO );if (ret >=0 ) ret = media_create_pad_link(decoder, ret, mixer, 0,
drivers/media/usb/dvb-usb-v2/mxl111sf.c +2 -2
@@ -893,9 +893,9 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) state->tuner.function =MEDIA_ENT_F_TUNER ; state->tuner.name ="mxl111sf tuner" ; state->tuner_pads[MXL111SF_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->tuner_pads[MXL111SF_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->tuner_pads[MXL111SF_PAD_RF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; state->tuner_pads[MXL111SF_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->tuner_pads[MXL111SF_PAD_OUTPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->tuner_pads[MXL111SF_PAD_OUTPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; ret =media_entity_pads_init (&state->tuner,MXL111SF_NUM_PADS , state->tuner_pads);
drivers/media/v4l2-core/tuner-core.c +5 -5
@@ -732,20 +732,20 @@ static int tuner_probe(struct i2c_client *client,*/ if (t->type ==TUNER_TDA9887 ) { t->pad[IF_VID_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - t->pad[IF_VID_DEC_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + t->pad[IF_VID_DEC_PAD_IF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; t->pad[IF_VID_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - t->pad[IF_VID_DEC_PAD_OUT ].sig_type =PAD_SIGNAL_ANALOG ; + t->pad[IF_VID_DEC_PAD_OUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; ret =media_entity_pads_init (&t->sd.entity,IF_VID_DEC_PAD_NUM_PADS , &t->pad[0 ]); t->sd.entity.function =MEDIA_ENT_F_IF_VID_DECODER ; }else { t->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - t->pad[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + t->pad[TUNER_PAD_RF_INPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; t->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; - t->pad[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_ANALOG ; + t->pad[TUNER_PAD_OUTPUT ].sig_type =MEDIA_PAD_SIGNAL_ANALOG ; t->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - t->pad[TUNER_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + t->pad[TUNER_PAD_AUD_OUT ].sig_type =MEDIA_PAD_SIGNAL_AUDIO ; ret =media_entity_pads_init (&t->sd.entity,TUNER_NUM_PADS , &t->pad[0 ]); t->sd.entity.function =MEDIA_ENT_F_TUNER ;
drivers/media/v4l2-core/v4l2-mc.c +13 -13
@@ -106,9 +106,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)if (tuner) {if (if_vid) { pad_source =media_get_pad_index (tuner, false, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG ); pad_sink =media_get_pad_index (if_vid, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_source <0 || pad_sink <0 ) {dev_warn (mdev->dev,"Couldn't get tuner and/or PLL pad(s): (%d, %d)\n" , pad_source, pad_sink);
@@ -123,9 +123,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) } pad_source =media_get_pad_index (if_vid, false, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG ); pad_sink =media_get_pad_index (decoder, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_source <0 || pad_sink <0 ) {dev_warn (mdev->dev,"get decoder and/or PLL pad(s): (%d, %d)\n" , pad_source, pad_sink);
@@ -140,9 +140,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) } }else { pad_source =media_get_pad_index (tuner, false, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG ); pad_sink =media_get_pad_index (decoder, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_source <0 || pad_sink <0 ) {dev_warn (mdev->dev,"couldn't get tuner and/or decoder pad(s): (%d, %d)\n" , pad_source, pad_sink);
@@ -157,9 +157,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)if (if_aud) { pad_source =media_get_pad_index (tuner, false, -PAD_SIGNAL_AUDIO ); +MEDIA_PAD_SIGNAL_AUDIO ); pad_sink =media_get_pad_index (if_aud, true, -PAD_SIGNAL_AUDIO ); +MEDIA_PAD_SIGNAL_AUDIO );if (pad_source <0 || pad_sink <0 ) {dev_warn (mdev->dev,"couldn't get tuner and/or decoder pad(s) for audio: (%d, %d)\n" , pad_source, pad_sink);
@@ -180,7 +180,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)/* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) { - pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); + pad_source =media_get_pad_index (decoder, false,MEDIA_PAD_SIGNAL_DV );if (pad_source <0 ) {dev_warn (mdev->dev,"couldn't get decoder output pad for V4L I/O\n" );return -EINVAL ;
@@ -195,7 +195,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_swradio) { - pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); + pad_source =media_get_pad_index (decoder, false,MEDIA_PAD_SIGNAL_DV );if (pad_source <0 ) {dev_warn (mdev->dev,"couldn't get decoder output pad for SDR\n" );return -EINVAL ;
@@ -210,7 +210,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_vbi) { - pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); + pad_source =media_get_pad_index (decoder, false,MEDIA_PAD_SIGNAL_DV );if (pad_source <0 ) {dev_warn (mdev->dev,"couldn't get decoder output pad for VBI\n" );return -EINVAL ;
@@ -232,7 +232,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)if (!tuner)continue ; pad_sink =media_get_pad_index (tuner, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_sink <0 ) {dev_warn (mdev->dev,"couldn't get tuner analog pad sink\n" );return -EINVAL ;
@@ -244,7 +244,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)case MEDIA_ENT_F_CONN_SVIDEO :case MEDIA_ENT_F_CONN_COMPOSITE : pad_sink =media_get_pad_index (decoder, true, -PAD_SIGNAL_ANALOG ); +MEDIA_PAD_SIGNAL_ANALOG );if (pad_sink <0 ) {dev_warn (mdev->dev,"couldn't get tuner analog pad sink\n" );return -EINVAL ;
include/media/media-entity.h +19 -15
@@ -156,31 +156,31 @@ struct media_link { };/** -* enum media_pad_signal_type - type of the signal inside a media pad +* enum media_pad_signal_type - type of the signal carried by a media pad * -* @PAD_SIGNAL_DEFAULT: -* Default signal. Use this when all inputs or all outputs are -* uniquely identified by the pad number. -* @PAD_SIGNAL_ANALOG: -* The pad contains an analog signal. It can be Radio Frequency, +* @MEDIA_PAD_SIGNAL_DEFAULT: +* Default signal. Default signal. Use this when there's no need to +* specify the signal carried inside a pad. +* @MEDIA_PAD_SIGNAL_ANALOG: +* The pad carries an analog signal. It can be Radio Frequency, * Intermediate Frequency, a baseband signal or sub-cariers. * Tuner inputs, IF-PLL demodulators, composite and s-video signals * should use it. -* @PAD_SIGNAL_DV: -* Contains a digital video signal, with can be a bitstream of samples +* @MEDIA_PAD_SIGNAL_DV: +* Pad carries a digital video signal, with can be a bitstream of samples * taken from an analog TV video source. On such case, it usually * contains the VBI data on it. -* @PAD_SIGNAL_AUDIO: -* Contains an Intermediate Frequency analog signal from an audio +* @MEDIA_PAD_SIGNAL_AUDIO: +* Pad carries an Intermediate Frequency analog signal from an audio * sub-carrier or an audio bitstream. IF signals are provided by tuners * and consumed by audio AM/FM decoders. Bitstream audio is provided by * an audio decoder. */ enum media_pad_signal_type { -PAD_SIGNAL_DEFAULT =0 , -PAD_SIGNAL_ANALOG , -PAD_SIGNAL_DV , -PAD_SIGNAL_AUDIO , +MEDIA_PAD_SIGNAL_DEFAULT =0 , +MEDIA_PAD_SIGNAL_ANALOG , +MEDIA_PAD_SIGNAL_DV , +MEDIA_PAD_SIGNAL_AUDIO , };/**
@@ -189,7 +189,11 @@ enum media_pad_signal_type {* @graph_obj: Embedded structure containing the media object common data * @entity: Entity this pad belongs to * @index: Pad index in the entity pads array, numbered from 0 to n -* @sig_type: Type of the signal inside a media pad +* @sig_type: Type of the signal that a media pad supports. This is used +* when an entity function may have different kinds of signals +* on different pads of the same direction (source/sink). For +* example, if an entity has 2 pad sinks where one carries +* an analog video while the other carries an audio signal. * @flags: Pad flags, as defined in * :ref:`include/uapi/linux/media.h <media_header>` * (seek for ``MEDIA_PAD_FL_*``)
PATCH 3/13 v4l2-mc: switch it to use the new approach to setup pipelines
In reply to Mauro Carvalho ChehabInstead of relying on a static map for pids, use the new sig_type "taint" type to setup the pipelines with the same tipe between different entities.
--- drivers/media/media-entity.c | 26 +++++++++++ drivers/media/v4l2-core/v4l2-mc.c | 73 ++++++++++++++++++++++++------- include/media/media-entity.h | 19 ++++++++ 3 files changed, 101 insertions(+), 17 deletions(-)
drivers/media/media-entity.c +26 -0
@@ -662,6 +662,32 @@ static void __media_entity_remove_link(struct media_entity *entity,kfree (link); } +int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type) +{ +int i; +bool pad_is_sink; + +if (!entity) +return -EINVAL ; + +for (i =0 ; i < entity->num_pads; i++) { +if (entity->pads[i].flags ==MEDIA_PAD_FL_SINK ) + pad_is_sink = true; +else if (entity->pads[i].flags ==MEDIA_PAD_FL_SOURCE ) + pad_is_sink = false; +else +continue ;/* This is an error! */ + +if (pad_is_sink != is_sink) +continue ; +if (entity->pads[i].sig_type == sig_type) +return i; + } +return -EINVAL ; +} +EXPORT_SYMBOL_GPL (media_get_pad_index); +int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags)
drivers/media/v4l2-core/v4l2-mc.c +56 -17
128 lines not on this page · raw message
include/media/media-entity.h +19 -0
@@ -675,6 +675,25 @@ static inline void media_entity_cleanup(struct media_entity *entity) {}#define media_entity_cleanup (entity) do { } while (false)#endif + +/** +* media_get_pad_index() - retrieves a pad index from an entity +* +* @entity: entity where the pads belong +* @is_sink: true if the pad is a sink, false if it is a source +* @sig_type: type of signal of the pad to be search +* +* This helper function finds the first pad index inside an entity that +* satisfies both @is_sink and @sig_type conditions. +* +* Return: +* +* On success, return the pad number. If the pad was not found or the media +* entity is a NULL pointer, return -EINVAL. +*/ +int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type); +/** * media_create_pad_link() - creates a link between two entities. *
Signature · 1 line
2.17.1
Laurent Pinchart
maintainerRe: [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines
Hi Mauro,
Thank you for the patch.
Quoted 2 lines · On Wednesday, 1 August 2018 18:55:05 EEST Mauro Carvalho Chehab wrote:
Instead of relying on a static map for pids, use the new
sig_type"taint" type to setup the pipelines with the same tipe between
s/tipe/type/
Quoted 14 lines
different entities.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/media-entity.c | 26 +++++++++++ drivers/media/v4l2-core/v4l2-mc.c | 73 ++++++++++++++++++++++++------- include/media/media-entity.h | 19 ++++++++ 3 files changed, 101 insertions(+), 17 deletions(-)drivers/media/media-entity.c +0
-0
drivers/media/media-entity.c static void __media_entity_remove_link(struct · line 668
Quoted 7 lines
drivers/media/media-entity.c +4
-0@@ -662,6 +662,32 @@ static void __media_entity_remove_link(structmedia_entity *entity,kfree (link ); } +int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type) +{ +int i;
is is never negative, please use an unsigned int.
Quoted 173 lines
drivers/media/media-entity.c +22
-0+bool pad_is_sink; + +if (!entity) +return -EINVAL ; + +for (i =0 ; i < entity->num_pads; i++) { +if (entity->pads[i].flags ==MEDIA_PAD_FL_SINK ) + pad_is_sink = true; +else if (entity->pads[i].flags ==MEDIA_PAD_FL_SOURCE ) + pad_is_sink = false; +else +continue ;/* This is an error! */ + +if (pad_is_sink != is_sink) +continue ; +if (entity->pads[i].sig_type == sig_type) +return i; + } +return -EINVAL ; +} +EXPORT_SYMBOL_GPL (media_get_pad_index); +int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-mc.cindex982bab3530f6..1925e1a3b861100644drivers/media/v4l2-core/v4l2-mc.c +38
-12@@ -28,7 +28,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)struct media_entity *io_v4l =NULL , *io_vbi =NULL , *io_swradio =NULL ;bool is_webcam = false;u32 flags; -int ret; +int ret, pad_sink, pad_source;if (!mdev)return 0 ;@@ -97,29 +97,52 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) /* Link the tuner and IF video output pads */if (tuner) {if (if_vid) { - ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , - if_vid, -IF_VID_DEC_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); + pad_sink =media_get_pad_index (if_vid, true, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + if_vid, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; - ret =media_create_pad_link (if_vid,IF_VID_DEC_PAD_OUT , - decoder,DEMOD_PAD_IF_INPUT , + + pad_source =media_get_pad_index (if_vid, false, +PAD_SIGNAL_DV ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_DV ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (if_vid, pad_source, + decoder, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; }else { - ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , - decoder,DEMOD_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + decoder, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; }if (if_aud) { - ret =media_create_pad_link (tuner,TUNER_PAD_AUD_OUT , - if_aud, -IF_AUD_DEC_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_AUDIO ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_AUDIO ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + if_aud, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret;@@ -131,7 +154,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)/* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_v4l,0 ,MEDIA_LNK_FL_ENABLED );drivers/media/v4l2-core/v4l2-mc.c +18
-5if (ret)@@ -139,7 +165,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_swradio) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_swradio,0 ,MEDIA_LNK_FL_ENABLED );if (ret)@@ -147,7 +176,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_vbi) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_vbi,0 ,MEDIA_LNK_FL_ENABLED );if (ret)@@ -161,15 +193,22 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) case MEDIA_ENT_F_CONN_RF:if (!tuner)continue ; - + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 ) +return -EINVAL ; ret =media_create_pad_link (entity,0 , tuner, -TUNER_PAD_RF_INPUT , + pad_source, flags);break ;case MEDIA_ENT_F_CONN_SVIDEO :case MEDIA_ENT_F_CONN_COMPOSITE : + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_ANALOG ); +if (pad_sink <0 ) +return -EINVAL ; ret =media_create_pad_link (entity,0 , decoder, -DEMOD_PAD_IF_INPUT , + pad_sink, flags);break ;default :include/media/media-entity.h +0
-0@@ -675,6 +675,25 @@ static inline void media_entity_cleanup(struct
media_entity*entity) {} #definemedia_entity_cleanup(entity)do { } while (false)
#endif
Quoted 1 line
+
Extra blank line.
Quoted 2 lines
+/**
+ *media_get_pad_index()- retrieves a pad index from an entity
I think a better name would be media_entity_find_pad(), similarly to media_entity_find_link(), as the function searches for a pad given a direction and signal type. A *_get_*() function name hints of reference counting.
Quoted 3 lines
+ *
+ * @entity: entity where the pads belong
+ * @is_sink: true if the pad is a sink, false if it is a source
Could we use pad flags instead ? It's easier to read
pad = media_get_pad_index(entity, MEDIA_PAD_FL_SINK, ...);
than
pad = media_get_pad_index(entity, true, ...);
As an added bonus that would allow the caller to search for any pad with a given signal type by specifying MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE.
Quoted 16 lines
+ * @sig_type: type of signal of the pad to be search
+ *
+ * This helper function finds the first pad index inside an entity that
+ * satisfies both @is_sink and @sig_type conditions.
+ *
+ * Return:
+ *
+ * On success, return the pad number. If the pad was not found or the media
+ * entity is a NULL pointer, return-EINVAL.
+ */include/media/media-entity.h +3
-0+int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type); +/** * media_create_pad_link() - creates a link between two entities. *
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines
Em Wed, 26 Sep 2018 17:44:53 +0300
Laurent Pinchart <[email protected]> escreveu:
Quoted 233 lines
Hi Mauro,
Thank you for the patch.
Quoted 2 lines · On Wednesday, 1 August 2018 18:55:05 EEST Mauro Carvalho Chehab wrote:
Instead of relying on a static map for pids, use the new
sig_type"taint" type to setup the pipelines with the same tipe betweens/tipe/type/
Quoted 14 lines
different entities.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/media-entity.c | 26 +++++++++++ drivers/media/v4l2-core/v4l2-mc.c | 73 ++++++++++++++++++++++++------- include/media/media-entity.h | 19 ++++++++ 3 files changed, 101 insertions(+), 17 deletions(-)drivers/media/media-entity.c +0
-0drivers/media/media-entity.c static void __media_entity_remove_link(struct · line 668
Quoted 7 lines
drivers/media/media-entity.c +4
-0@@ -662,6 +662,32 @@ static void __media_entity_remove_link(structmedia_entity *entity,kfree (link ); } +int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type) +{ +int i;is is never negative, please use an unsigned int.
Quoted 173 lines
drivers/media/media-entity.c +22
-0+bool pad_is_sink; + +if (!entity) +return -EINVAL ; + +for (i =0 ; i < entity->num_pads; i++) { +if (entity->pads[i].flags ==MEDIA_PAD_FL_SINK ) + pad_is_sink = true; +else if (entity->pads[i].flags ==MEDIA_PAD_FL_SOURCE ) + pad_is_sink = false; +else +continue ;/* This is an error! */ + +if (pad_is_sink != is_sink) +continue ; +if (entity->pads[i].sig_type == sig_type) +return i; + } +return -EINVAL ; +} +EXPORT_SYMBOL_GPL (media_get_pad_index); +int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-mc.cindex982bab3530f6..1925e1a3b861100644drivers/media/v4l2-core/v4l2-mc.c +38
-12@@ -28,7 +28,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)struct media_entity *io_v4l =NULL , *io_vbi =NULL , *io_swradio =NULL ;bool is_webcam = false;u32 flags; -int ret; +int ret, pad_sink, pad_source;if (!mdev)return 0 ;@@ -97,29 +97,52 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) /* Link the tuner and IF video output pads */if (tuner) {if (if_vid) { - ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , - if_vid, -IF_VID_DEC_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); + pad_sink =media_get_pad_index (if_vid, true, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + if_vid, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; - ret =media_create_pad_link (if_vid,IF_VID_DEC_PAD_OUT , - decoder,DEMOD_PAD_IF_INPUT , + + pad_source =media_get_pad_index (if_vid, false, +PAD_SIGNAL_DV ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_DV ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (if_vid, pad_source, + decoder, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; }else { - ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , - decoder,DEMOD_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + decoder, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret; }if (if_aud) { - ret =media_create_pad_link (tuner,TUNER_PAD_AUD_OUT , - if_aud, -IF_AUD_DEC_PAD_IF_INPUT , + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_AUDIO ); + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_AUDIO ); +if (pad_source <0 || pad_sink <0 ) +return -EINVAL ; + ret =media_create_pad_link (tuner, pad_source, + if_aud, pad_sink,MEDIA_LNK_FL_ENABLED );if (ret)return ret;@@ -131,7 +154,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)/* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_v4l,0 ,MEDIA_LNK_FL_ENABLED );drivers/media/v4l2-core/v4l2-mc.c +18
-5if (ret)@@ -139,7 +165,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_swradio) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_swradio,0 ,MEDIA_LNK_FL_ENABLED );if (ret)@@ -147,7 +176,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) }if (io_vbi) { - ret =media_create_pad_link (decoder,DEMOD_PAD_VID_OUT , + pad_source =media_get_pad_index (decoder, false,PAD_SIGNAL_DV ); +if (pad_source <0 ) +return -EINVAL ; + ret =media_create_pad_link (decoder, pad_source, io_vbi,0 ,MEDIA_LNK_FL_ENABLED );if (ret)@@ -161,15 +193,22 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) case MEDIA_ENT_F_CONN_RF:if (!tuner)continue ; - + pad_source =media_get_pad_index (tuner, false, +PAD_SIGNAL_ANALOG ); +if (pad_source <0 ) +return -EINVAL ; ret =media_create_pad_link (entity,0 , tuner, -TUNER_PAD_RF_INPUT , + pad_source, flags);break ;case MEDIA_ENT_F_CONN_SVIDEO :case MEDIA_ENT_F_CONN_COMPOSITE : + pad_sink =media_get_pad_index (decoder, true, +PAD_SIGNAL_ANALOG ); +if (pad_sink <0 ) +return -EINVAL ; ret =media_create_pad_link (entity,0 , decoder, -DEMOD_PAD_IF_INPUT , + pad_sink, flags);break ;default :include/media/media-entity.h +0
-0@@ -675,6 +675,25 @@ static inline void media_entity_cleanup(struct
media_entity*entity) {} #definemedia_entity_cleanup(entity)do { } while (false)
#endifQuoted 1 line
+
Extra blank line.
Quoted 2 lines
+/**
+ *media_get_pad_index()- retrieves a pad index from an entityI think a better name would be
media_entity_find_pad(), similarly tomedia_entity_find_link(), as the function searches for a pad given a direction and signal type. A *_get_*() function name hints of reference counting.Quoted 3 lines
+ *
+ * @entity: entity where the pads belong
+ * @is_sink: true if the pad is a sink, false if it is a sourceCould we use pad flags instead ? It's easier to read
pad = media_get_pad_index(entity, MEDIA_PAD_FL_SINK, ...);than
pad = media_get_pad_index(entity, true, ...);As an added bonus that would allow the caller to search for any pad with a given signal type by specifying
MEDIA_PAD_FL_SINK|MEDIA_PAD_FL_SOURCE.
Quoted 17 lines
Quoted 10 lines
+ * @sig_type: type of signal of the pad to be search
+ *
+ * This helper function finds the first pad index inside an entity that
+ * satisfies both @is_sink and @sig_type conditions.
+ *
+ * Return:
+ *
+ * On success, return the pad number. If the pad was not found or the media
+ * entity is a NULL pointer, return-EINVAL.
+ */include/media/media-entity.h
Quoted 6 lines
include/media/media-entity.h +3
-0+int media_get_pad_index (struct media_entity *entity,bool is_sink, +enum media_pad_signal_type sig_type); +/** * media_create_pad_link() - creates a link between two entities. *
All comments make sense. follow up patch enclosed.
Thanks,
Mauro
[PATCH] media: mc: make media_get_pad_index() more generic
Instead of passing a boolean, use the pad flags. That makes the function simpler and more generic, as it can now find a pad that it is either sink or source.
While here, use unsigned int for the loop var.
drivers/media/dvb-core/dvbdev.c +6 -4
@@ -690,8 +690,9 @@ int dvb_create_media_graph(struct dvb_adapter *adap,MEDIA_LNK_FL_ENABLED , false); }else { - pad_sink =media_get_pad_index (tuner, true, -MEDIA_PAD_SIGNAL_ANALOG ); + pad_sink =media_entity_find_pad (tuner, +MEDIA_PAD_FL_SINK , +MEDIA_PAD_SIGNAL_ANALOG );if (pad_sink <0 )return -EINVAL ; ret = media_create_pad_links(mdev,
@@ -707,8 +708,9 @@ int dvb_create_media_graph(struct dvb_adapter *adap, }if (ntuner && ndemod) { - pad_source =media_get_pad_index (tuner, true, -MEDIA_PAD_SIGNAL_ANALOG ); + pad_source =media_entity_find_pad (tuner, +MEDIA_PAD_FL_SINK , +MEDIA_PAD_SIGNAL_ANALOG );if (pad_source)return -EINVAL ; ret = media_create_pad_links(mdev,
drivers/media/media-entity.c +5 -13
@@ -662,31 +662,23 @@ static void __media_entity_remove_link(struct media_entity *entity,kfree (link); } -int media_get_pad_index (struct media_entity *entity,bool is_sink, +int media_entity_find_pad (struct media_entity *entity,u32 flags,enum media_pad_signal_type sig_type) { -int i; +unsigned int i;bool pad_is_sink;if (!entity)return -EINVAL ;for (i =0 ; i < entity->num_pads; i++) { -if (entity->pads[i].flags ==MEDIA_PAD_FL_SINK ) - pad_is_sink = true; -else if (entity->pads[i].flags ==MEDIA_PAD_FL_SOURCE ) - pad_is_sink = false; -else -continue ;/* This is an error! */ - -if (pad_is_sink != is_sink) -continue ; -if (entity->pads[i].sig_type == sig_type) +if ((entity->pads[i].flags & flags) && + (entity->pads[i].sig_type == sig_type))return i; }return -EINVAL ; } -EXPORT_SYMBOL_GPL (media_get_pad_index); +EXPORT_SYMBOL_GPL (media_entity_find_pad); int media_create_pad_link(struct media_entity *source, u16 source_pad,
drivers/media/usb/au0828/au0828-core.c +2 -2
@@ -266,8 +266,8 @@ static void au0828_media_graph_notify(struct media_entity *new, create_link:if (decoder && mixer) { - ret =media_get_pad_index (decoder, false, -MEDIA_PAD_SIGNAL_AUDIO ); + ret =media_entity_find_pad (decoder,MEDIA_PAD_FL_SOURCE , +MEDIA_PAD_SIGNAL_AUDIO );if (ret >=0 ) ret = media_create_pad_link(decoder, ret, mixer, 0,
drivers/media/v4l2-core/v4l2-mc.c +35 -19
112 lines not on this page · raw message
include/media/media-entity.h +8 -5
@@ -675,22 +675,25 @@ static inline void media_entity_cleanup(struct media_entity *entity) {}#endif /** -* media_get_pad_index() - retrieves a pad index from an entity +* media_entity_find_pad() - retrieves a pad index from an entity * * @entity: entity where the pads belong -* @is_sink: true if the pad is a sink, false if it is a source +* @flags: Link flags, as defined in +* :ref:`include/uapi/linux/media.h <media_header>` +* ( seek for ``MEDIA_LNK_FL_*``). Shouldn't be zero. * @sig_type: type of signal of the pad to be search * * This helper function finds the first pad index inside an entity that -* satisfies both @is_sink and @sig_type conditions. +* satisfies contains one or more of the flags specified at @flags +* and whose type matches @sig_type. * * Return: * * On success, return the pad number. If the pad was not found or the media * entity is a NULL pointer, return -EINVAL. */ -int media_get_pad_index (struct media_entity *entity,bool is_sink, -enum media_pad_signal_type sig_type); +int media_entity_find_pad (struct media_entity *entity,u32 flags, +enum media_pad_signal_type sig_type);/** * media_create_pad_link() - creates a link between two entities.
PATCH 4/13 media: dvb: use signals to discover pads
In reply to Mauro Carvalho ChehabOn tuner pads, multiple signals are present. Be sure to get the right PAD by using them.
--- drivers/media/dvb-core/dvbdev.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/media/dvb-core/dvbdev.c +14 -5
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,unsigned demux_pad =0 ;unsigned dvr_pad =0 ;unsigned ntuner =0 , ndemod =0 ; -int ret; +int ret, pad_source, pad_sink;static const char *connector_name ="Television" ;if (!mdev)
@@ -681,7 +681,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,if (ret)return ret; -if (!ntuner) +if (!ntuner) { ret = media_create_pad_links(mdev, MEDIA_ENT_F_CONN_RF, conn, 0,
@@ -689,22 +689,31 @@ int dvb_create_media_graph(struct dvb_adapter *adap, demod,0 ,MEDIA_LNK_FL_ENABLED , false); - else + }else { + pad_sink =media_get_pad_index (tuner, true, +PAD_SIGNAL_ANALOG ); +if (pad_sink <0 ) +return -EINVAL ; ret =media_create_pad_links (mdev,MEDIA_ENT_F_CONN_RF , conn,0 ,MEDIA_ENT_F_TUNER , - tuner,TUNER_PAD_RF_INPUT , + tuner, pad_sink,MEDIA_LNK_FL_ENABLED , false); + }if (ret)return ret; }if (ntuner && ndemod) { + pad_source =media_get_pad_index (tuner, true, +PAD_SIGNAL_ANALOG ); +if (pad_source) +return -EINVAL ; ret =media_create_pad_links (mdev,MEDIA_ENT_F_TUNER , - tuner,TUNER_PAD_OUTPUT , + tuner, pad_source,MEDIA_ENT_F_DTV_DEMOD , demod,0 ,MEDIA_LNK_FL_ENABLED , false);
Signature · 1 line
2.17.1
PATCH 5/13 media: au0828: use signals instead of hardcoding a pad number
In reply to Mauro Carvalho ChehabWhen creating the audio link, use pad signals, instead of hardcoding using the pad index number.
--- drivers/media/usb/au0828/au0828-core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/media/usb/au0828/au0828-core.c +7 -5
@@ -266,11 +266,13 @@ static void au0828_media_graph_notify(struct media_entity *new, create_link:if (decoder && mixer) { - ret =media_create_pad_link (decoder, -DEMOD_PAD_AUDIO_OUT , - mixer,0 , -MEDIA_LNK_FL_ENABLED ); -if (ret) + ret =media_get_pad_index (decoder, false, +PAD_SIGNAL_AUDIO ); +if (ret >=0 ) + ret =media_create_pad_link (decoder, ret, + mixer,0 , +MEDIA_LNK_FL_ENABLED ); +if (ret <0 )dev_err (&dev->usbdev->dev,"Mixer Pad Link Create Error: %d\n" , ret); }
Signature · 1 line
2.17.1
PATCH 6/13 media: au8522: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/dvb-frontends/au8522_decoder.c | 12 ++++++------ drivers/media/dvb-frontends/au8522_priv.h | 9 ++++++++- 2 files changed, 14 insertions(+), 7 deletions(-)
drivers/media/dvb-frontends/au8522_decoder.c +6 -6
@@ -718,12 +718,12 @@ static int au8522_probe(struct i2c_client *client,v4l2_i2c_subdev_init (sd, client, &au8522_ops);#if defined(CONFIG_MEDIA_CONTROLLER ) - state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; - state->pads[DEMOD_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[DEMOD_PAD_AUDIO_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[AU8522_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[AU8522_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + state->pads[AU8522_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_AUDIO_OUT ].sig_type =PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
drivers/media/dvb-frontends/au8522_priv.h +8 -1
@@ -40,6 +40,13 @@#define AU8522_DIGITAL_MODE 1#define AU8522_SUSPEND_MODE 2 +enum au8522_pads { +AU8522_PAD_IF_INPUT , +AU8522_PAD_VID_OUT , +AU8522_PAD_AUDIO_OUT , +AU8522_NUM_PADS +}; +struct au8522_state {struct i2c_client *c;struct i2c_adapter *i2c;
@@ -71,7 +78,7 @@ struct au8522_state {struct v4l2_ctrl_handler hdl;#ifdef CONFIG_MEDIA_CONTROLLER -struct media_pad pads[DEMOD_NUM_PADS ]; +struct media_pad pads[AU8522_NUM_PADS ];#endif };
Signature · 1 line
2.17.1
PATCH 7/13 media: msp3400: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/i2c/msp3400-driver.c | 8 ++++---- drivers/media/i2c/msp3400-driver.h | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/media/i2c/msp3400-driver.c +4 -4
@@ -703,10 +703,10 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)v4l2_i2c_subdev_init (sd, client, &msp_ops);#if defined(CONFIG_MEDIA_CONTROLLER ) - state->pads[IF_AUD_DEC_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[IF_AUD_DEC_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_AUDIO ; - state->pads[IF_AUD_DEC_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[IF_AUD_DEC_PAD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[MSP3400_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[MSP3400_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_AUDIO ; + state->pads[MSP3400_PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[MSP3400_PAD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; sd->entity.function =MEDIA_ENT_F_IF_AUD_DECODER ;
drivers/media/i2c/msp3400-driver.h +7 -1
@@ -52,6 +52,12 @@ extern int msp_standard;extern bool msp_dolby;extern int msp_stereo_thresh; +enum msp3400_pads { +MSP3400_PAD_IF_INPUT , +MSP3400_PAD_OUT , +MSP3400_NUM_PADS +}; +struct msp_state {struct v4l2_subdev sd;struct v4l2_ctrl_handler hdl;
@@ -106,7 +112,7 @@ struct msp_state { unsigned int watch_stereo:1;#if IS_ENABLED (CONFIG_MEDIA_CONTROLLER ) -struct media_pad pads[IF_AUD_DEC_PAD_NUM_PADS ]; +struct media_pad pads[MSP3400_NUM_PADS ];#endif };
Signature · 1 line
2.17.1
PATCH 8/13 media: saa7115: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/i2c/saa7115.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/media/i2c/saa7115.c +13 -6
@@ -59,10 +59,17 @@ enum saa711x_model { SAA7118, }; + +enum saa711x_pads { +SAA711X_PAD_IF_INPUT , +SAA711X_PAD_VID_OUT , +SAA711X_NUM_PADS +}; +struct saa711x_state {struct v4l2_subdev sd;#ifdef CONFIG_MEDIA_CONTROLLER -struct media_pad pads[DEMOD_NUM_PADS ]; +struct media_pad pads[SAA711X_NUM_PADS ];#endif struct v4l2_ctrl_handler hdl;
@@ -1834,14 +1841,14 @@ static int saa711x_probe(struct i2c_client *client,v4l2_i2c_subdev_init (sd, client, &saa711x_ops);#if defined(CONFIG_MEDIA_CONTROLLER ) - state->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - state->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + state->pads[SAA711X_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->pads[SAA711X_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->pads[SAA711X_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[SAA711X_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; - ret =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , state->pads); + ret =media_entity_pads_init (&sd->entity,SAA711X_NUM_PADS , state->pads);if (ret <0 )return ret;#endif
Signature · 1 line
2.17.1
PATCH 9/13 media: tvp5150: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/i2c/tvp5150.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/media/i2c/tvp5150.c +14 -8
@@ -38,10 +38,16 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)"); #define dprintk0(__dev, __arg...) dev_dbg_lvl(__dev, 0, 0, __arg) +enum tvp5150_pads { +TVP5150_PAD_IF_INPUT , +TVP5150_PAD_VID_OUT , +TVP5150_NUM_PADS +}; +struct tvp5150 {struct v4l2_subdev sd;#ifdef CONFIG_MEDIA_CONTROLLER -struct media_pad pads[DEMOD_NUM_PADS ]; +struct media_pad pads[TVP5150_NUM_PADS ];struct media_entity input_ent[TVP5150_INPUT_NUM ];struct media_pad input_pad[TVP5150_INPUT_NUM ];#endif
@@ -866,7 +872,7 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,struct v4l2_mbus_framefmt *f;struct tvp5150 *decoder =to_tvp5150 (sd); -if (!format || (format->pad !=DEMOD_PAD_VID_OUT )) +if (!format || (format->pad !=TVP5150_PAD_VID_OUT ))return -EINVAL ; f = &format->format;
@@ -1217,7 +1223,7 @@ static int tvp5150_registered(struct v4l2_subdev *sd)return ret; ret =media_create_pad_link (input,0 , &sd->entity, -DEMOD_PAD_IF_INPUT ,0 ); +TVP5150_PAD_IF_INPUT ,0 );if (ret <0 ) {media_device_unregister_entity (input);return ret;
@@ -1499,14 +1505,14 @@ static int tvp5150_probe(struct i2c_client *c, sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;#if defined(CONFIG_MEDIA_CONTROLLER ) - core->pads[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - core->pads[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - core->pads[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - core->pads[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + core->pads[TVP5150_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + core->pads[TVP5150_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + core->pads[TVP5150_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + core->pads[TVP5150_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; - res =media_entity_pads_init (&sd->entity,DEMOD_NUM_PADS , core->pads); + res =media_entity_pads_init (&sd->entity,TVP5150_NUM_PADS , core->pads);if (res <0 )return res;
Signature · 1 line
2.17.1
PATCH 10/13 media: si2157: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/tuners/si2157.c | 14 +++++++------- drivers/media/tuners/si2157_priv.h | 9 ++++++++- 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/media/tuners/si2157.c +7 -7
@@ -468,14 +468,14 @@ static int si2157_probe(struct i2c_client *client, dev->ent.name =KBUILD_MODNAME ; dev->ent.function =MEDIA_ENT_F_TUNER ; - dev->pad[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - dev->pad[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - dev->pad[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->pad[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; - dev->pad[TUNER_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->pad[TUNER_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; + dev->pad[SI2157_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + dev->pad[SI2157_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + dev->pad[SI2157_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->pad[SI2157_PAD_VID_OUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; + dev->pad[SI2157_PAD_AUD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->pad[SI2157_PAD_AUD_OUT ].sig_type =PAD_SIGNAL_AUDIO ; - ret =media_entity_pads_init (&dev->ent,TUNER_NUM_PADS , + ret =media_entity_pads_init (&dev->ent,SI2157_NUM_PADS , &dev->pad[0 ]);if (ret)
drivers/media/tuners/si2157_priv.h +8 -1
@@ -21,6 +21,13 @@#include <media/v4l2-mc.h> #include "si2157.h" +enum si2157_pads { +SI2157_PAD_RF_INPUT , +SI2157_PAD_VID_OUT , +SI2157_PAD_AUD_OUT , +SI2157_NUM_PADS +}; +/* state struct */ struct si2157_dev {struct mutex i2c_mutex;
@@ -35,7 +42,7 @@ struct si2157_dev {#if defined(CONFIG_MEDIA_CONTROLLER )struct media_device *mdev;struct media_entity ent; -struct media_pad pad[TUNER_NUM_PADS ]; +struct media_pad pad[SI2157_NUM_PADS ];#endif };
Signature · 1 line
2.17.1
PATCH 11/13 media: saa7134: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/pci/saa7134/saa7134-core.c | 10 +++++----- drivers/media/pci/saa7134/saa7134.h | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/media/pci/saa7134/saa7134-core.c +5 -5
@@ -845,13 +845,13 @@ static void saa7134_create_entities(struct saa7134_dev *dev)*/ if (!decoder) { dev->demod.name ="saa713x" ; - dev->demod_pad[DEMOD_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - dev->demod_pad[DEMOD_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - dev->demod_pad[DEMOD_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - dev->demod_pad[DEMOD_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; + dev->demod_pad[SAA7134_PAD_IF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + dev->demod_pad[SAA7134_PAD_IF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + dev->demod_pad[SAA7134_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + dev->demod_pad[SAA7134_PAD_VID_OUT ].sig_type =PAD_SIGNAL_DV ; dev->demod.function =MEDIA_ENT_F_ATV_DECODER ; - ret =media_entity_pads_init (&dev->demod,DEMOD_NUM_PADS , + ret =media_entity_pads_init (&dev->demod,SAA7134_NUM_PADS , dev->demod_pad);if (ret <0 )pr_err ("failed to initialize demod pad!\n" );
drivers/media/pci/saa7134/saa7134.h +7 -1
@@ -547,6 +547,12 @@ struct saa7134_mpeg_ops { unsigned long status); }; +enum saa7134_pads { +SAA7134_PAD_IF_INPUT , +SAA7134_PAD_VID_OUT , +SAA7134_NUM_PADS +}; +/* global device status */ struct saa7134_dev {struct list_head devlist;
@@ -674,7 +680,7 @@ struct saa7134_dev {struct media_pad input_pad[SAA7134_INPUT_MAX +1 ];struct media_entity demod; -struct media_pad demod_pad[DEMOD_NUM_PADS ]; +struct media_pad demod_pad[SAA7134_NUM_PADS ];struct media_pad video_pad, vbi_pad;struct media_entity *decoder;
Signature · 1 line
2.17.1
PATCH 12/13 media: mxl111sf: declare its own pads
In reply to Mauro Carvalho ChehabAs we don't need anymore to share pad numbers with similar drivers, use its own pad definition instead of a global model.
--- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 10 +++++----- drivers/media/usb/dvb-usb-v2/mxl111sf.h | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/mxl111sf.c +5 -5
@@ -892,13 +892,13 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap)#ifdef CONFIG_MEDIA_CONTROLLER_DVB state->tuner.function =MEDIA_ENT_F_TUNER ; state->tuner.name ="mxl111sf tuner" ; - state->tuner_pads[TUNER_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; - state->tuner_pads[TUNER_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; - state->tuner_pads[TUNER_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; - state->tuner_pads[TUNER_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; + state->tuner_pads[MXL111SF_PAD_RF_INPUT ].flags =MEDIA_PAD_FL_SINK ; + state->tuner_pads[MXL111SF_PAD_RF_INPUT ].sig_type =PAD_SIGNAL_ANALOG ; + state->tuner_pads[MXL111SF_PAD_OUTPUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->tuner_pads[MXL111SF_PAD_OUTPUT ].sig_type =PAD_SIGNAL_TV_CARRIERS ; ret =media_entity_pads_init (&state->tuner, -TUNER_NUM_PADS , state->tuner_pads); +MXL111SF_NUM_PADS , state->tuner_pads);if (ret)return ret;
drivers/media/usb/dvb-usb-v2/mxl111sf.h +7 -1
@@ -52,6 +52,12 @@ struct mxl111sf_adap_state {int (*fe_sleep)(struct dvb_frontend *); }; +enum mxl111sf_pads { +MXL111SF_PAD_RF_INPUT , +MXL111SF_PAD_OUTPUT , +MXL111SF_NUM_PADS +}; +struct mxl111sf_state {struct dvb_usb_device *d;
@@ -94,7 +100,7 @@ struct mxl111sf_state {struct mutex msg_lock;#ifdef CONFIG_MEDIA_CONTROLLER_DVB struct media_entity tuner; -struct media_pad tuner_pads[2 ]; +struct media_pad tuner_pads[MXL111SF_NUM_PADS ];#endif };
Signature · 1 line
2.17.1
PATCH 13/13 media: v4l2-mc: get rid of global pad indexes
In reply to Mauro Carvalho ChehabNow that all drivers are using pad signal types, we can get rid of the global static definition, as routes are stablished using the pad signal type.
The tuner and IF-PLL pads are now used only by the tuner core, so move the definitions to be there.
--- drivers/media/v4l2-core/tuner-core.c | 13 +++++ include/media/v4l2-mc.h | 76 ---------------------------- 2 files changed, 13 insertions(+), 76 deletions(-)
drivers/media/v4l2-core/tuner-core.c +13 -0
@@ -97,6 +97,19 @@ static const struct v4l2_subdev_ops tuner_ops;* Internal struct used inside the driver */ +enum tuner_pad_index { +TUNER_PAD_RF_INPUT , +TUNER_PAD_OUTPUT , +TUNER_PAD_AUD_OUT , +TUNER_NUM_PADS +}; + +enum if_vid_dec_pad_index { +IF_VID_DEC_PAD_IF_INPUT , +IF_VID_DEC_PAD_OUT , +IF_VID_DEC_PAD_NUM_PADS +}; +struct tuner {/* device */ struct dvb_frontend fe;
include/media/v4l2-mc.h +0 -76
82 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes
Quoted 23 lines · Mauro Carvalho Chehab
Now that all drivers are using pad signal types, we can get rid of the global static definition, as routes are stablished using the pad signal type.
The tuner and IF-PLL pads are now used only by the tuner core, so move the definitions to be there.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/v4l2-core/tuner-core.c | 13 +++++ include/media/v4l2-mc.h | 76 ---------------------------- 2 files changed, 13 insertions(+), 76 deletions(-)drivers/media/v4l2-core/tuner-core.c +2
-0@@ -97,6 +97,19 @@ static const struct v4l2_subdev_ops tuner_ops;* Internal struct used inside the driver */ +enum tuner_pad_index { +TUNER_PAD_RF_INPUT ,
drivers/media/v4l2-core/tuner-core.c static const struct v4l2_subdev_ops tuner_ops; · line 111
Quoted 10 lines
drivers/media/v4l2-core/tuner-core.c +10
-0+TUNER_PAD_OUTPUT , +TUNER_PAD_AUD_OUT , + TUNER_NUM_PADS +}; + +enum if_vid_dec_pad_index { +IF_VID_DEC_PAD_IF_INPUT , +IF_VID_DEC_PAD_OUT , +IF_VID_DEC_PAD_NUM_PADS +};
Shouldn't the enum documentation be copied as well instead of just the enums themselves?
Regards,
Hans
Quoted 92 lines
drivers/media/v4l2-core/tuner-core.c +1
-0+struct tuner {/* device */ struct dvb_frontend fe;include/media/v4l2-mc.h +0
-76@@ -23,82 +23,6 @@#include <media/v4l2-dev.h> #include <linux/types.h> -/** -* enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER -* -* @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a -* RF connector entity. -* @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video -* chrominance and luminance or the hole bandwidth -* of the signal converted to an Intermediate Frequency -* (IF) or to baseband (on zero-IF tuners). -* @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode -* analog TV signals have an extra pad for audio output. -* Old tuners use an analog stage with a saw filter for -* the audio IF frequency. The output of the pad is, in -* this case, the audio IF, with should be decoded either -* by the bridge chipset (that's the case of cx2388x -* chipsets) or may require an external IF sound -* processor, like msp34xx. On modern silicon tuners, -* the audio IF decoder is usually incorporated at the -* tuner. On such case, the output of this pad is an -* audio sampled data. -* @TUNER_NUM_PADS: Number of pads of the tuner. -*/ -enum tuner_pad_index { -TUNER_PAD_RF_INPUT , -TUNER_PAD_OUTPUT , -TUNER_PAD_AUD_OUT , -TUNER_NUM_PADS -}; - -/** -* enum if_vid_dec_pad_index - video IF-PLL pad index for -* MEDIA_ENT_F_IF_VID_DECODER -* -* @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad -* @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the -* video chrominance and luminance IF signals. -* @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL. -*/ -enum if_vid_dec_pad_index { -IF_VID_DEC_PAD_IF_INPUT , -IF_VID_DEC_PAD_OUT , -IF_VID_DEC_PAD_NUM_PADS -}; - -/** -* enum if_aud_dec_pad_index - audio/sound IF-PLL pad index for -* MEDIA_ENT_F_IF_AUD_DECODER -* -* @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad -* @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the -* audio sampled stream data, usually connected -* to the bridge bus via an Inter-IC Sound (I2S) -* bus. -* @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL. -*/ -enum if_aud_dec_pad_index { -IF_AUD_DEC_PAD_IF_INPUT , -IF_AUD_DEC_PAD_OUT , -IF_AUD_DEC_PAD_NUM_PADS -}; - -/** -* enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER -* -* @DEMOD_PAD_IF_INPUT: IF input sink pad. -* @DEMOD_PAD_VID_OUT: Video output source pad. -* @DEMOD_PAD_AUDIO_OUT: Audio output source pad. -* @DEMOD_NUM_PADS: Maximum number of output pads. -*/ -enum demod_pad_index { -DEMOD_PAD_IF_INPUT , -DEMOD_PAD_VID_OUT , -DEMOD_PAD_AUDIO_OUT , -DEMOD_NUM_PADS -}; -/* We don't need to include pci.h or usb.h here */ struct pci_dev ;struct usb_device ;
Re: [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes
Em Thu, 2 Aug 2018 11:08:52 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 22 lines · Mauro Carvalho Chehab
Quoted 21 lines
Now that all drivers are using pad signal types, we can get rid of the global static definition, as routes are stablished using the pad signal type.
The tuner and IF-PLL pads are now used only by the tuner core, so move the definitions to be there.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/v4l2-core/tuner-core.c | 13 +++++ include/media/v4l2-mc.h | 76 ---------------------------- 2 files changed, 13 insertions(+), 76 deletions(-)drivers/media/v4l2-core/tuner-core.c +0
-0@@ -97,6 +97,19 @@ static const struct v4l2_subdev_ops tuner_ops;* Internal struct used inside the driver */
Quoted 15 lines
drivers/media/v4l2-core/tuner-core.c static const struct v4l2_subdev_ops tuner_ops; · line 111
Quoted 12 lines
drivers/media/v4l2-core/tuner-core.c +12
-0+enum tuner_pad_index { +TUNER_PAD_RF_INPUT , +TUNER_PAD_OUTPUT , +TUNER_PAD_AUD_OUT , +TUNER_NUM_PADS +}; + +enum if_vid_dec_pad_index { +IF_VID_DEC_PAD_IF_INPUT , +IF_VID_DEC_PAD_OUT , +IF_VID_DEC_PAD_NUM_PADS +};Shouldn't the enum documentation be copied as well instead of just the enums themselves?
I was in doubt about that too :-)
When this was global, documentation was a need, as all drivers should do the same. Now that it is local, and all external parties use are the sig_types, the information became less relevant, being internal to tuner-core.
Yet, it doesn't hurt copying the documentation here, so I'll add it.
See enclosed.
Thanks,
Mauro
[PATCHv2 13/13] media: v4l2-mc: get rid of global pad indexes
Now that all drivers are using pad signal types, we can get rid of the global static definition, as routes are stablished using the pad signal type.
The tuner and IF-PLL pads are now used only by the tuner core, so move the definitions to be there.
drivers/media/v4l2-core/tuner-core.c +48 -1
@@ -94,9 +94,56 @@ static const struct v4l2_subdev_ops tuner_ops; }while (0 )/* -* Internal struct used inside the driver +* Internal enums/struct used inside the driver */ +/** +* enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER +* +* @TUNER_PAD_RF_INPUT: +* Radiofrequency (RF) sink pad, usually linked to a RF connector entity. +* @TUNER_PAD_OUTPUT: +* tuner video output source pad. Contains the video chrominance +* and luminance or the hole bandwidth of the signal converted to +* an Intermediate Frequency (IF) or to baseband (on zero-IF tuners). +* @TUNER_PAD_AUD_OUT: +* Tuner audio output source pad. Tuners used to decode analog TV +* signals have an extra pad for audio output. Old tuners use an +* analog stage with a saw filter for the audio IF frequency. The +* output of the pad is, in this case, the audio IF, with should be +* decoded either by the bridge chipset (that's the case of cx2388x +* chipsets) or may require an external IF sound processor, like +* msp34xx. On modern silicon tuners, the audio IF decoder is usually +* incorporated at the tuner. On such case, the output of this pad +* is an audio sampled data. +* @TUNER_NUM_PADS: +* Number of pads of the tuner. +*/ +enum tuner_pad_index { +TUNER_PAD_RF_INPUT , +TUNER_PAD_OUTPUT , +TUNER_PAD_AUD_OUT , +TUNER_NUM_PADS +}; + +/** +* enum if_vid_dec_pad_index - video IF-PLL pad index +* for MEDIA_ENT_F_IF_VID_DECODER +* +* @IF_VID_DEC_PAD_IF_INPUT: +* video Intermediate Frequency (IF) sink pad +* @IF_VID_DEC_PAD_OUT: +* IF-PLL video output source pad. Contains the video chrominance +* and luminance IF signals. +* @IF_VID_DEC_PAD_NUM_PADS: +* Number of pads of the video IF-PLL. +*/ +enum if_vid_dec_pad_index { +IF_VID_DEC_PAD_IF_INPUT , +IF_VID_DEC_PAD_OUT , +IF_VID_DEC_PAD_NUM_PADS +}; + struct tuner { /* device */ struct dvb_frontend fe;
include/media/v4l2-mc.h +0 -76
82 lines not on this page · raw message
Quoted 16 lines · Mauro Carvalho Chehab
At PC consumer devices, it is very common that the bridge same driver to be attached to different types of tuners and demods. We need a way for the Kernel to properly identify what kind of signal is provided by each PAD, in order to properly setup the pipelines.
The previous approach were to hardcode a fixed number of PADs for all elements of the same type. This is not good, as different devices may actually have a different number of pads.
It was acceptable in the past, as there were a promisse of adding "soon" a properties API that would allow to identify the type for each PADs, but this was never merged (or even a patchset got submitted).
So, replace this approach by another one: add a "taint" mark to pads that contain different types of signals.
Quoted 7 lines
I tried to minimize the number of signals, in order to make it simpler to convert from the past way.
For now, it is tested only with a simple grabber device. I intend to do more tests before merging it, but it would be interesting to have this merged for Kernel 4.19, as we'll now be exposing the pad index via the MC API version 2.
Other than a small comment for the last patch I didn't see anything problematical in this series. It doesn't touch on the public API or on any of the non-tuner drivers. So for patches 1-12:
And after adding back the documentation for the enums in patch 13 you can add my Ack to that one as well.
Regards,
Hans
Quoted 37 lines
Mauro Carvalho Chehab (13):
media: v4l2: remove VBI output pad
media: v4l2: taint pads with the signal types for consumer devices
v4l2-mc: switch it to use the new approach to setup pipelines
media: dvb: use signals to discover pads
media: au0828: use signals instead of hardcoding a pad number
media: au8522: declare its own pads
media: msp3400: declare its own pads
media: saa7115: declare its own pads
media: tvp5150: declare its own pads
media: si2157: declare its own pads
media: saa7134: declare its own pads
media: mxl111sf: declare its own pads
media: v4l2-mc: get rid of global pad indexesdrivers/media/dvb-core/dvbdev.c | 19 +++-- drivers/media/dvb-frontends/au8522_decoder.c | 10 ++- drivers/media/dvb-frontends/au8522_priv.h | 9 ++- drivers/media/i2c/msp3400-driver.c | 6 +- drivers/media/i2c/msp3400-driver.h | 8 +- drivers/media/i2c/saa7115.c | 18 +++-- drivers/media/i2c/tvp5150.c | 21 ++++-- drivers/media/media-entity.c | 26 +++++++ drivers/media/pci/saa7134/saa7134-core.c | 9 ++- drivers/media/pci/saa7134/saa7134.h | 8 +- drivers/media/tuners/si2157.c | 11 ++- drivers/media/tuners/si2157_priv.h | 9 ++- drivers/media/usb/au0828/au0828-core.c | 12 +-- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 8 +- drivers/media/usb/dvb-usb-v2/mxl111sf.h | 8 +- drivers/media/v4l2-core/tuner-core.c | 18 +++++ drivers/media/v4l2-core/v4l2-mc.c | 73 +++++++++++++----- include/media/media-entity.h | 54 ++++++++++++++ include/media/v4l2-mc.h | 78 -------------------- 19 files changed, 266 insertions(+), 139 deletions(-)
Em Thu, 2 Aug 2018 11:12:23 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 25 lines · Mauro Carvalho Chehab
Quoted 16 lines
At PC consumer devices, it is very common that the bridge same driver to be attached to different types of tuners and demods. We need a way for the Kernel to properly identify what kind of signal is provided by each PAD, in order to properly setup the pipelines.
The previous approach were to hardcode a fixed number of PADs for all elements of the same type. This is not good, as different devices may actually have a different number of pads.
It was acceptable in the past, as there were a promisse of adding "soon" a properties API that would allow to identify the type for each PADs, but this was never merged (or even a patchset got submitted).
So, replace this approach by another one: add a "taint" mark to pads that contain different types of signals.
Quoted 7 lines
I tried to minimize the number of signals, in order to make it simpler to convert from the past way.
For now, it is tested only with a simple grabber device. I intend to do more tests before merging it, but it would be interesting to have this merged for Kernel 4.19, as we'll now be exposing the pad index via the MC API version 2.
Quoted 8 lines
Other than a small comment for the last patch I didn't see anything problematical in this series. It doesn't touch on the public API or on any of the non-tuner drivers. So for patches 1-12:
Acked-by Hans Verkuil <[email protected]>And after adding back the documentation for the enums in patch 13 you can add my Ack to that one as well.
Thank you! I changed patch 13 to keep the documentation and added your ack:
https://git.linuxtv.org/mchehab/experimental.git/log/?h=pad-fix-3
Thanks,
Mauro