All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] Better handle pads for tuning/decoder part of the devices
@ 2018-08-01 15:55 Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 01/13] media: v4l2: remove VBI output pad Mauro Carvalho Chehab
                   ` (13 more replies)
  0 siblings, 14 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Kees Cook,
	Devin Heitmueller, Philippe Ombredanne, Pravin Shedge,
	Brian Warner, Bhumika Goyal, Kate Stewart, Max Kellermann,
	Shuah Khan, Michael Krufky, Laurent Pinchart, Sakari Ailus,
	Antti Palosaari, Nasser Afshin, Marco Felsch,
	Javier Martinez Canillas, Hans Verkuil, Philipp Zabel,
	Gustavo A. R. Silva, Thomas Gleixner, Hans Verkuil,
	Greg Kroah-Hartman

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(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 01/13] media: v4l2: remove VBI output pad
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices Mauro Carvalho Chehab
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab,
	Gustavo A. R. Silva, Devin Heitmueller, Hans Verkuil,
	Brian Warner, Sakari Ailus, Marco Felsch, Philipp Zabel,
	Nasser Afshin, Javier Martinez Canillas, Kees Cook, Shuah Khan,
	Pravin Shedge, Laurent Pinchart

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).

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 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(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index f285096a48f0..198dd2b6f326 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -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;
 
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index b07114b5efb2..4c72db58dfd2 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -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;
 
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 76e6bed5a1da..66235e10acdd 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -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;
 
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 9e76de2411ae..267d143c3a48 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -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,
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 0fc185a2ce90..982bab3530f6 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -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)
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 2634d9dc9916..7c9c781b16a9 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -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
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 01/13] media: v4l2: remove VBI output pad Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-09-26 14:09   ` Laurent Pinchart
  2018-08-01 15:55 ` [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Antti Palosaari,
	Michael Krufky, Devin Heitmueller, Hans Verkuil,
	Gustavo A. R. Silva, Brian Warner, Sakari Ailus, Marco Felsch,
	Philipp Zabel, Nasser Afshin, Javier Martinez Canillas,
	Kees Cook

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 <mchehab+samsung@kernel.org>
---
 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(+)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 198dd2b6f326..583fdaa7339f 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -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),
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 3db966db83eb..3b9c729fbd52 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -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;
 
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 4c72db58dfd2..8798a06c212f 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -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;
 
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 66235e10acdd..5037a03b5442 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -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;
 
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 267d143c3a48..c4e2df197bf9 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -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,
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 9e34d31d724d..d222912662d7 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -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]);
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 4713ba65e1c2..51a1b26199e6 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -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);
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 7f858c39753c..d4c32ccd0930 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -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;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 3aa3d58d1d58..8bfbe6b59fa9 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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;
 };
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 01/13] media: v4l2: remove VBI output pad Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-09-26 14:44   ` Laurent Pinchart
  2018-08-01 15:55 ` [PATCH 04/13] media: dvb: use signals to discover pads Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Laurent Pinchart,
	Pravin Shedge, Hans Verkuil, Shuah Khan

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
different entities.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 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(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 3498551e618e..0b1cb3559140 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -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)
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 982bab3530f6..1925e1a3b861 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -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);
 		if (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:
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 8bfbe6b59fa9..ac8b93e46167 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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.
  *
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 04/13] media: dvb: use signals to discover pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 05/13] media: au0828: use signals instead of hardcoding a pad number Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Sakari Ailus, Max Kellermann

On tuner pads, multiple signals are present. Be sure to get
the right PAD by using them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/dvb-core/dvbdev.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 3c8778570331..50f174248eef 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -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);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 05/13] media: au0828: use signals instead of hardcoding a pad number
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 04/13] media: dvb: use signals to discover pads Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 06/13] media: au8522: declare its own pads Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Gustavo A. R. Silva

When creating the audio link, use pad signals, instead of
hardcoding using the pad index number.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/usb/au0828/au0828-core.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index cd363a2100d4..4729b2a2f21c 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -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);
 	}
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 06/13] media: au8522: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 05/13] media: au0828: use signals instead of hardcoding a pad number Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 07/13] media: msp3400: " Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Devin Heitmueller, Gustavo A. R. Silva

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/dvb-frontends/au8522_decoder.c | 12 ++++++------
 drivers/media/dvb-frontends/au8522_priv.h    |  9 ++++++++-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 583fdaa7339f..b2dd20ffd002 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -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),
diff --git a/drivers/media/dvb-frontends/au8522_priv.h b/drivers/media/dvb-frontends/au8522_priv.h
index 2043c1744753..68299d2705f7 100644
--- a/drivers/media/dvb-frontends/au8522_priv.h
+++ b/drivers/media/dvb-frontends/au8522_priv.h
@@ -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
 };
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 07/13] media: msp3400: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 06/13] media: au8522: declare its own pads Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 08/13] media: saa7115: " Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Thomas Gleixner,
	Kate Stewart, Philippe Ombredanne, Greg Kroah-Hartman

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/i2c/msp3400-driver.c | 8 ++++----
 drivers/media/i2c/msp3400-driver.h | 8 +++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index 3b9c729fbd52..ef70fe0c77a1 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -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;
 
diff --git a/drivers/media/i2c/msp3400-driver.h b/drivers/media/i2c/msp3400-driver.h
index b6c7698bce5a..2bb9d5ff1bbd 100644
--- a/drivers/media/i2c/msp3400-driver.h
+++ b/drivers/media/i2c/msp3400-driver.h
@@ -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
 };
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 08/13] media: saa7115: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 07/13] media: msp3400: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 09/13] media: tvp5150: " Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Sakari Ailus, Brian Warner

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/i2c/saa7115.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 8798a06c212f..09bedbc71567 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 09/13] media: tvp5150: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (7 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 08/13] media: saa7115: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 10/13] media: si2157: " Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Marco Felsch,
	Philipp Zabel, Nasser Afshin, Javier Martinez Canillas

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/i2c/tvp5150.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 5037a03b5442..a9f7c70ca25c 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -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;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 10/13] media: si2157: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (8 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 09/13] media: tvp5150: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 11/13] media: saa7134: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Antti Palosaari

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/tuners/si2157.c      | 14 +++++++-------
 drivers/media/tuners/si2157_priv.h |  9 ++++++++-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index d222912662d7..dc21a86c0175 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -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)
diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h
index e6436f74abaa..129a35e4e11b 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -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
 
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 11/13] media: saa7134: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (9 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 10/13] media: si2157: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 12/13] media: mxl111sf: " Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Kees Cook,
	Hans Verkuil, Bhumika Goyal

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/pci/saa7134/saa7134-core.c | 10 +++++-----
 drivers/media/pci/saa7134/saa7134.h      |  8 +++++++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index c4e2df197bf9..8984b1bf57a5 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -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");
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index d99e937a98c1..ac05a38aa728 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 12/13] media: mxl111sf: declare its own pads
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (10 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 11/13] media: saa7134: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-01 15:55 ` [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes Mauro Carvalho Chehab
  2018-08-02  9:12 ` [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Hans Verkuil
  13 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Michael Krufky

As we don't need anymore to share pad numbers with similar
drivers, use its own pad definition instead of a global
model.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 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(-)

diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 51a1b26199e6..7454672fbec9 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -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;
 
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.h b/drivers/media/usb/dvb-usb-v2/mxl111sf.h
index 22253d4908eb..ed98654ba7fd 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.h
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.h
@@ -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
 };
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (11 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 12/13] media: mxl111sf: " Mauro Carvalho Chehab
@ 2018-08-01 15:55 ` Mauro Carvalho Chehab
  2018-08-02  9:08   ` Hans Verkuil
  2018-08-02  9:12 ` [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Hans Verkuil
  13 siblings, 1 reply; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-01 15:55 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil

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 <mchehab+samsung@kernel.org>
---
 drivers/media/v4l2-core/tuner-core.c | 13 +++++
 include/media/v4l2-mc.h              | 76 ----------------------------
 2 files changed, 13 insertions(+), 76 deletions(-)

diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index d4c32ccd0930..e35438ca0b50 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -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;
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 7c9c781b16a9..bf5043c1ab6b 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes
  2018-08-01 15:55 ` [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes Mauro Carvalho Chehab
@ 2018-08-02  9:08   ` Hans Verkuil
  2018-08-02  9:30     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 22+ messages in thread
From: Hans Verkuil @ 2018-08-02  9:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: Mauro Carvalho Chehab

On 08/01/18 17:55, Mauro Carvalho Chehab wrote:
> 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 <mchehab+samsung@kernel.org>
> ---
>  drivers/media/v4l2-core/tuner-core.c | 13 +++++
>  include/media/v4l2-mc.h              | 76 ----------------------------
>  2 files changed, 13 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> index d4c32ccd0930..e35438ca0b50 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -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
> +};

Shouldn't the enum documentation be copied as well instead of just the
enums themselves?

Regards,

	Hans

> +
>  struct tuner {
>  	/* device */
>  	struct dvb_frontend fe;
> diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
> index 7c9c781b16a9..bf5043c1ab6b 100644
> --- a/include/media/v4l2-mc.h
> +++ b/include/media/v4l2-mc.h
> @@ -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;
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 00/13] Better handle pads for tuning/decoder part of the devices
  2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
                   ` (12 preceding siblings ...)
  2018-08-01 15:55 ` [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes Mauro Carvalho Chehab
@ 2018-08-02  9:12 ` Hans Verkuil
  2018-08-02  9:39   ` Mauro Carvalho Chehab
  13 siblings, 1 reply; 22+ messages in thread
From: Hans Verkuil @ 2018-08-02  9:12 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Kees Cook, Devin Heitmueller,
	Philippe Ombredanne, Pravin Shedge, Brian Warner, Bhumika Goyal,
	Kate Stewart, Max Kellermann, Shuah Khan, Michael Krufky,
	Laurent Pinchart, Sakari Ailus, Antti Palosaari, Nasser Afshin,
	Marco Felsch, Javier Martinez Canillas, Hans Verkuil,
	Philipp Zabel, Gustavo A. R. Silva, Thomas Gleixner,
	Greg Kroah-Hartman

On 08/01/18 17:55, Mauro Carvalho Chehab wrote:
> 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.

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 <hans.verkuil@cisco.com>

And after adding back the documentation for the enums in patch 13 you
can add my Ack to that one as well.

Regards,

	Hans

> 
> 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(-)
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes
  2018-08-02  9:08   ` Hans Verkuil
@ 2018-08-02  9:30     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-02  9:30 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Thu, 2 Aug 2018 11:08:52 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 08/01/18 17:55, Mauro Carvalho Chehab wrote:
> > 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 <mchehab+samsung@kernel.org>
> > ---
> >  drivers/media/v4l2-core/tuner-core.c | 13 +++++
> >  include/media/v4l2-mc.h              | 76 ----------------------------
> >  2 files changed, 13 insertions(+), 76 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> > index d4c32ccd0930..e35438ca0b50 100644
> > --- a/drivers/media/v4l2-core/tuner-core.c
> > +++ b/drivers/media/v4l2-core/tuner-core.c
> > @@ -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
> > +};  
> 
> 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.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index d4c32ccd0930..47228145473f 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -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;
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 7c9c781b16a9..bf5043c1ab6b 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -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;

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 00/13] Better handle pads for tuning/decoder part of the devices
  2018-08-02  9:12 ` [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Hans Verkuil
@ 2018-08-02  9:39   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-08-02  9:39 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Kees Cook,
	Devin Heitmueller, Philippe Ombredanne, Pravin Shedge,
	Brian Warner, Bhumika Goyal, Kate Stewart, Max Kellermann,
	Shuah Khan, Michael Krufky, Laurent Pinchart, Sakari Ailus,
	Antti Palosaari, Nasser Afshin, Marco Felsch,
	Javier Martinez Canillas, Hans Verkuil, Philipp Zabel,
	Gustavo A. R. Silva, Thomas Gleixner, Greg Kroah-Hartman

Em Thu, 2 Aug 2018 11:12:23 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 08/01/18 17:55, Mauro Carvalho Chehab wrote:
> > 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.  
> 
> 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 <hans.verkuil@cisco.com>
> 
> 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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices
  2018-08-01 15:55 ` [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices Mauro Carvalho Chehab
@ 2018-09-26 14:09   ` Laurent Pinchart
  2018-09-27 10:01     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Pinchart @ 2018-09-26 14:09 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Antti Palosaari,
	Michael Krufky, Devin Heitmueller, Hans Verkuil,
	Gustavo A. R. Silva, Brian Warner, Sakari Ailus, Marco Felsch,
	Philipp Zabel, Nasser Afshin, Javier Martinez Canillas,
	Kees Cook

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.

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 <mchehab+samsung@kernel.org>
> ---
>  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]

> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 3aa3d58d1d58..8bfbe6b59fa9 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -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".

> + *
> + * @PAD_SIGNAL_DEFAULT

Shouldn't we use a MEDIA_PAD_ prefix ?

> + *	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.

> + * @PAD_SIGNAL_ANALOG

This isn't a very good name given that PAD_SIGNAL_TV_CARRIERS is also analog.

> + *	The pad contains an analog signa. It can be Radio Frequency,

s/signa/signal/

> + *	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 ...".

> 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/  / /

> + *	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.

> + */
> +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;

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).

>  	unsigned long flags;
>  };


-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines
  2018-08-01 15:55 ` [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines Mauro Carvalho Chehab
@ 2018-09-26 14:44   ` Laurent Pinchart
  2018-09-27 10:40     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 22+ messages in thread
From: Laurent Pinchart @ 2018-09-26 14:44 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Pravin Shedge,
	Hans Verkuil, Shuah Khan

Hi Mauro,

Thank you for the patch.

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/

> different entities.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
> ---
>  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(-)
> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index 3498551e618e..0b1cb3559140 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -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;

is is never negative, please use an unsigned int.

> +	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)
> diff --git a/drivers/media/v4l2-core/v4l2-mc.c
> b/drivers/media/v4l2-core/v4l2-mc.c index 982bab3530f6..1925e1a3b861 100644
> --- a/drivers/media/v4l2-core/v4l2-mc.c
> +++ b/drivers/media/v4l2-core/v4l2-mc.c
> @@ -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);
>  		if (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:
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 8bfbe6b59fa9..ac8b93e46167 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -675,6 +675,25 @@ static inline void media_entity_cleanup(struct
> media_entity *entity) {} #define media_entity_cleanup(entity) do { } while
> (false)
>  #endif
> 
> +

Extra blank line.

> +/**
> + * 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.

> + *
> + * @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.

> + * @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.
>   *

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices
  2018-09-26 14:09   ` Laurent Pinchart
@ 2018-09-27 10:01     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-09-27 10:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Antti Palosaari,
	Michael Krufky, Devin Heitmueller, Hans Verkuil,
	Gustavo A. R. Silva, Brian Warner, Sakari Ailus, Marco Felsch,
	Philipp Zabel, Nasser Afshin, Javier Martinez Canillas,
	Kees Cook

Em Wed, 26 Sep 2018 17:09:19 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> 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.
> 
> 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 <mchehab+samsung@kernel.org>
> > ---
> >  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]
> 
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 3aa3d58d1d58..8bfbe6b59fa9 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -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".

Ok.

> 
> > + *
> > + * @PAD_SIGNAL_DEFAULT  
> 
> Shouldn't we use a MEDIA_PAD_ prefix ?

Ok.
> 
> > + *	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."

> 
> > + * @PAD_SIGNAL_ANALOG  
> 
> This isn't a very good name given that PAD_SIGNAL_TV_CARRIERS is also analog.
> 
> > + *	The pad contains an analog signa. It can be Radio Frequency,  
> 
> s/signa/signal/

Ok (this is actually fixed already at the version applied).

> > + *	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".

> > 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/  / /
> 
> > + *	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.

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)

> > + */
> > +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;  
> 
> 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.


> >  	unsigned 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.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index b7171bf094fb..14e9b1db72a0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -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,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index b2dd20ffd002..1f99e6238eb8 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -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),
diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c
index c63be01059b2..935dfec2b405 100644
--- a/drivers/media/i2c/msp3400-driver.c
+++ b/drivers/media/i2c/msp3400-driver.c
@@ -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;
 
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 6bc278aa31fc..d74065890a80 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -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;
 
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index f5b234e4599d..45be245442e0 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -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;
 
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 8984b1bf57a5..f4933e5b4850 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -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,
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index d389f1fc237a..17992f9fab09 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -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]);
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 1fdb1601dc65..484b620879c0 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -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,
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 85cdf593a9ad..1ebe04a3e7dd 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -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);
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 03a340cb5a9b..061b13821367 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -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;
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 014a2a97cadd..f559e47cf8e8 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -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;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index e5f6960d92f6..837f806593f5 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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_*``)

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines
  2018-09-26 14:44   ` Laurent Pinchart
@ 2018-09-27 10:40     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 22+ messages in thread
From: Mauro Carvalho Chehab @ 2018-09-27 10:40 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Pravin Shedge,
	Hans Verkuil, Shuah Khan

Em Wed, 26 Sep 2018 17:44:53 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> 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/
> 
> > different entities.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
> > ---
> >  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(-)
> > 
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index 3498551e618e..0b1cb3559140 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -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;  
> 
> is is never negative, please use an unsigned int.
> 
> > +	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)
> > diff --git a/drivers/media/v4l2-core/v4l2-mc.c
> > b/drivers/media/v4l2-core/v4l2-mc.c index 982bab3530f6..1925e1a3b861 100644
> > --- a/drivers/media/v4l2-core/v4l2-mc.c
> > +++ b/drivers/media/v4l2-core/v4l2-mc.c
> > @@ -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);
> >  		if (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:
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 8bfbe6b59fa9..ac8b93e46167 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -675,6 +675,25 @@ static inline void media_entity_cleanup(struct
> > media_entity *entity) {} #define media_entity_cleanup(entity) do { } while
> > (false)
> >  #endif
> > 
> > +  
> 
> Extra blank line.
> 
> > +/**
> > + * 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.
> 
> > + *
> > + * @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.
> 
> > + * @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.
> >   *  
> 

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.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 14e9b1db72a0..3e18a3c3e701 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -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,
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 0b1cb3559140..019cc499e986 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -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,
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 484b620879c0..fa42de03da38 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -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,
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index f559e47cf8e8..ce80020117cb 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -105,10 +105,12 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 	/* Link the tuner and IF video output pads */
 	if (tuner) {
 		if (if_vid) {
-			pad_source = media_get_pad_index(tuner, false,
+			pad_source = media_entity_find_pad(tuner,
+							   MEDIA_PAD_FL_SOURCE,
+							   MEDIA_PAD_SIGNAL_ANALOG);
+			pad_sink = media_entity_find_pad(if_vid,
+							 MEDIA_PAD_FL_SINK,
 							 MEDIA_PAD_SIGNAL_ANALOG);
-			pad_sink = media_get_pad_index(if_vid, true,
-						       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);
@@ -122,10 +124,12 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 				return ret;
 			}
 
-			pad_source = media_get_pad_index(if_vid, false,
+			pad_source = media_entity_find_pad(if_vid,
+							   MEDIA_PAD_FL_SOURCE,
+							   MEDIA_PAD_SIGNAL_ANALOG);
+			pad_sink = media_entity_find_pad(decoder,
+							 MEDIA_PAD_FL_SINK,
 							 MEDIA_PAD_SIGNAL_ANALOG);
-			pad_sink = media_get_pad_index(decoder, true,
-						       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);
@@ -139,10 +143,12 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 				return ret;
 			}
 		} else {
-			pad_source = media_get_pad_index(tuner, false,
+			pad_source = media_entity_find_pad(tuner,
+							   MEDIA_PAD_FL_SOURCE,
+							   MEDIA_PAD_SIGNAL_ANALOG);
+			pad_sink = media_entity_find_pad(decoder,
+							 MEDIA_PAD_FL_SINK,
 							 MEDIA_PAD_SIGNAL_ANALOG);
-			pad_sink = media_get_pad_index(decoder, true,
-						       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);
@@ -156,10 +162,12 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 		}
 
 		if (if_aud) {
-			pad_source = media_get_pad_index(tuner, false,
+			pad_source = media_entity_find_pad(tuner,
+							   MEDIA_PAD_FL_SOURCE,
+							   MEDIA_PAD_SIGNAL_AUDIO);
+			pad_sink = media_entity_find_pad(if_aud,
+							 MEDIA_PAD_FL_SINK,
 							 MEDIA_PAD_SIGNAL_AUDIO);
-			pad_sink = media_get_pad_index(if_aud, true,
-						       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 +188,9 @@ 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, MEDIA_PAD_SIGNAL_DV);
+		pad_source = media_entity_find_pad(decoder,
+						   MEDIA_PAD_FL_SOURCE,
+						   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 +205,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 	}
 
 	if (io_swradio) {
-		pad_source = media_get_pad_index(decoder, false, MEDIA_PAD_SIGNAL_DV);
+		pad_source = media_entity_find_pad(decoder,
+						   MEDIA_PAD_FL_SOURCE,
+						   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 +222,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 	}
 
 	if (io_vbi) {
-		pad_source = media_get_pad_index(decoder, false, MEDIA_PAD_SIGNAL_DV);
+		pad_source = media_entity_find_pad(decoder,
+						   MEDIA_PAD_FL_SOURCE,
+						   MEDIA_PAD_SIGNAL_DV);
 		if (pad_source < 0) {
 			dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n");
 			return -EINVAL;
@@ -231,8 +245,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 		case MEDIA_ENT_F_CONN_RF:
 			if (!tuner)
 				continue;
-			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) {
 				dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n");
 				return -EINVAL;
@@ -243,8 +258,9 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
 			break;
 		case MEDIA_ENT_F_CONN_SVIDEO:
 		case MEDIA_ENT_F_CONN_COMPOSITE:
-			pad_sink = media_get_pad_index(decoder, true,
-						       MEDIA_PAD_SIGNAL_ANALOG);
+			pad_sink = media_entity_find_pad(decoder,
+							 MEDIA_PAD_FL_SINK,
+							 MEDIA_PAD_SIGNAL_ANALOG);
 			if (pad_sink < 0) {
 				dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n");
 				return -EINVAL;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 837f806593f5..46a955468fb2 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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.

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-09-27 16:58 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 15:55 [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 01/13] media: v4l2: remove VBI output pad Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 02/13] media: v4l2: taint pads with the signal types for consumer devices Mauro Carvalho Chehab
2018-09-26 14:09   ` Laurent Pinchart
2018-09-27 10:01     ` Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 03/13] v4l2-mc: switch it to use the new approach to setup pipelines Mauro Carvalho Chehab
2018-09-26 14:44   ` Laurent Pinchart
2018-09-27 10:40     ` Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 04/13] media: dvb: use signals to discover pads Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 05/13] media: au0828: use signals instead of hardcoding a pad number Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 06/13] media: au8522: declare its own pads Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 07/13] media: msp3400: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 08/13] media: saa7115: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 09/13] media: tvp5150: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 10/13] media: si2157: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 11/13] media: saa7134: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 12/13] media: mxl111sf: " Mauro Carvalho Chehab
2018-08-01 15:55 ` [PATCH 13/13] media: v4l2-mc: get rid of global pad indexes Mauro Carvalho Chehab
2018-08-02  9:08   ` Hans Verkuil
2018-08-02  9:30     ` Mauro Carvalho Chehab
2018-08-02  9:12 ` [PATCH 00/13] Better handle pads for tuning/decoder part of the devices Hans Verkuil
2018-08-02  9:39   ` Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.