All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3 0/8] media/mc: fix inconsistencies
@ 2018-06-21  7:19 Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 1/8] media: add 'index' to struct media_v2_pad Hans Verkuil
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media

From: Hans Verkuil <hans.verkuil@cisco.com>

This patch series sits on top of this pull request:

https://patchwork.linuxtv.org/patch/50453/

That pull request cleans up the tables in the documentation, making it
easier to add new entries.

This series is v3 of my previous attempt:

https://www.spinics.net/lists/linux-media/msg132218.html

The goal is to fix the inconsistencies between the 'old' and 'new' 
MC API. I hate the terms 'old' and 'new', there is nothing wrong IMHO with 
using an 'old' API if it meets the needs of the application.

The differences between v2 and v3 are that I changed that I changed
the defines that test if the index or flags fields are present:

/*
 * Appeared in 4.19.0.
 *
 * The media_version argument comes from the media_version field in
 * struct media_device_info.
 */
#define MEDIA_V2_PAD_HAS_INDEX(media_version) \
       ((media_version) >= ((4 << 16) | (19 << 8) | 0))

KERNEL_VERSION cannot be used in a public header, and my previous
attempt used 0x00041300, which isn't as readable as what I do now.
I also expanded the comment before the define pointing to struct
media_device_info. I also did the same in the documentation.

I dropped the patches adding a function field to struct media_entity_desc.
Instead I started the work to ensure all drivers set function correctly.

I still want to add a 'function' field to struct media_entity_desc but
step one is to make sure drivers actually set function correctly. I'll
revisit this once that's done.

Making G_TOPOLOGY useful is urgently needed since I think that will be
very helpful for the work we want to do on library support for complex
cameras.

Regards,

	Hans

Hans Verkuil (8):
  media: add 'index' to struct media_v2_pad
  media-ioc-g-topology.rst: document new 'index' field
  media: add flags field to struct media_v2_entity
  media-ioc-g-topology.rst: document new 'flags' field
  media.h: add MEDIA_ENT_F_DTV_ENCODER
  ad9389b/adv7511: set proper media entity function
  adv7180/tvp514x/tvp7002: fix entity function
  media/i2c: add missing entity functions

 .../uapi/mediactl/media-ioc-g-topology.rst    | 21 ++++++++++++---
 .../media/uapi/mediactl/media-types.rst       |  7 +++++
 drivers/media/i2c/ad9389b.c                   |  1 +
 drivers/media/i2c/adv7180.c                   |  2 +-
 drivers/media/i2c/adv7511.c                   |  1 +
 drivers/media/i2c/adv7604.c                   |  1 +
 drivers/media/i2c/adv7842.c                   |  1 +
 drivers/media/i2c/et8ek8/et8ek8_driver.c      |  1 +
 drivers/media/i2c/mt9m032.c                   |  1 +
 drivers/media/i2c/mt9p031.c                   |  1 +
 drivers/media/i2c/mt9t001.c                   |  1 +
 drivers/media/i2c/mt9v032.c                   |  1 +
 drivers/media/i2c/tvp514x.c                   |  2 +-
 drivers/media/i2c/tvp7002.c                   |  2 +-
 drivers/media/media-device.c                  |  2 ++
 include/uapi/linux/media.h                    | 27 ++++++++++++++++---
 16 files changed, 63 insertions(+), 9 deletions(-)

-- 
2.17.0

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

* [PATCHv3 1/8] media: add 'index' to struct media_v2_pad
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 2/8] media-ioc-g-topology.rst: document new 'index' field Hans Verkuil
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hansverk@cisco.com>

The v2 pad structure never exposed the pad index, which made it impossible
to call the MEDIA_IOC_SETUP_LINK ioctl, which needs that information.

It is really trivial to just expose this information, so implement this.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
---
 drivers/media/media-device.c |  1 +
 include/uapi/linux/media.h   | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 47bb2254fbfd..047d38372a27 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -331,6 +331,7 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
 		kpad.id = pad->graph_obj.id;
 		kpad.entity_id = pad->entity->graph_obj.id;
 		kpad.flags = pad->flags;
+		kpad.index = pad->index;
 
 		if (copy_to_user(upad, &kpad, sizeof(kpad)))
 			ret = -EFAULT;
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 86c7dcc9cba3..f6338bd57929 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -305,11 +305,21 @@ struct media_v2_interface {
 	};
 } __attribute__ ((packed));
 
+/*
+ * Appeared in 4.19.0.
+ *
+ * The media_version argument comes from the media_version field in
+ * struct media_device_info.
+ */
+#define MEDIA_V2_PAD_HAS_INDEX(media_version) \
+	((media_version) >= ((4 << 16) | (19 << 8) | 0))
+
 struct media_v2_pad {
 	__u32 id;
 	__u32 entity_id;
 	__u32 flags;
-	__u32 reserved[5];
+	__u32 index;
+	__u32 reserved[4];
 } __attribute__ ((packed));
 
 struct media_v2_link {
-- 
2.17.0

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

* [PATCHv3 2/8] media-ioc-g-topology.rst: document new 'index' field
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 1/8] media: add 'index' to struct media_v2_pad Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 3/8] media: add flags field to struct media_v2_entity Hans Verkuil
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Document the new struct media_v2_pad 'index' field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 .../media/uapi/mediactl/media-ioc-g-topology.rst      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
index a3f259f83b25..24ab34b22df2 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
@@ -176,7 +176,7 @@ desired arrays with the media graph elements.
     *  -  struct media_v2_intf_devnode
        -  ``devnode``
        -  Used only for device node interfaces. See
-	  :c:type:`media_v2_intf_devnode` for details..
+	  :c:type:`media_v2_intf_devnode` for details.
 
 
 .. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}|
@@ -218,7 +218,14 @@ desired arrays with the media graph elements.
        -  Pad flags, see :ref:`media-pad-flag` for more details.
 
     *  -  __u32
-       -  ``reserved``\ [5]
+       -  ``index``
+       -  0-based pad index. Only valid if ``MEDIA_V2_PAD_HAS_INDEX(media_version)``
+	  returns true. The ``media_version`` is defined in struct
+	  :c:type:`media_device_info` and can be retrieved using
+	  :ref:`MEDIA_IOC_DEVICE_INFO`.
+
+    *  -  __u32
+       -  ``reserved``\ [4]
        -  Reserved for future extensions. Drivers and applications must set
 	  this array to zero.
 
-- 
2.17.0

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

* [PATCHv3 3/8] media: add flags field to struct media_v2_entity
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 1/8] media: add 'index' to struct media_v2_pad Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 2/8] media-ioc-g-topology.rst: document new 'index' field Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 4/8] media-ioc-g-topology.rst: document new 'flags' field Hans Verkuil
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hansverk@cisco.com>

The v2 entity structure never exposed the entity flags, which made it
impossible to detect connector or default entities.

It is really trivial to just expose this information, so implement this.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
---
 drivers/media/media-device.c |  1 +
 include/uapi/linux/media.h   | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 047d38372a27..14959b19a342 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -266,6 +266,7 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
 		memset(&kentity, 0, sizeof(kentity));
 		kentity.id = entity->graph_obj.id;
 		kentity.function = entity->function;
+		kentity.flags = entity->flags;
 		strlcpy(kentity.name, entity->name,
 			sizeof(kentity.name));
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index f6338bd57929..ebd2cda67833 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -280,11 +280,21 @@ struct media_links_enum {
  * MC next gen API definitions
  */
 
+/*
+ * Appeared in 4.19.0.
+ *
+ * The media_version argument comes from the media_version field in
+ * struct media_device_info.
+ */
+#define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \
+	((media_version) >= ((4 << 16) | (19 << 8) | 0))
+
 struct media_v2_entity {
 	__u32 id;
 	char name[64];
 	__u32 function;		/* Main function of the entity */
-	__u32 reserved[6];
+	__u32 flags;
+	__u32 reserved[5];
 } __attribute__ ((packed));
 
 /* Should match the specific fields at media_intf_devnode */
-- 
2.17.0

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

* [PATCHv3 4/8] media-ioc-g-topology.rst: document new 'flags' field
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (2 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 3/8] media: add flags field to struct media_v2_entity Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 5/8] media.h: add MEDIA_ENT_F_DTV_ENCODER Hans Verkuil
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Document the new struct media_v2_entity 'flags' field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 .../media/uapi/mediactl/media-ioc-g-topology.rst       | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
index 24ab34b22df2..86d1f7d577c8 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
@@ -142,7 +142,15 @@ desired arrays with the media graph elements.
        -  Entity main function, see :ref:`media-entity-functions` for details.
 
     *  -  __u32
-       -  ``reserved``\ [6]
+       -  ``flags``
+       -  Entity flags, see :ref:`media-entity-flag` for details.
+	  Only valid if ``MEDIA_V2_ENTITY_HAS_FLAGS(media_version)``
+	  returns true. The ``media_version`` is defined in struct
+	  :c:type:`media_device_info` and can be retrieved using
+	  :ref:`MEDIA_IOC_DEVICE_INFO`.
+
+    *  -  __u32
+       -  ``reserved``\ [5]
        -  Reserved for future extensions. Drivers and applications must set
 	  this array to zero.
 
-- 
2.17.0

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

* [PATCHv3 5/8] media.h: add MEDIA_ENT_F_DTV_ENCODER
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (3 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 4/8] media-ioc-g-topology.rst: document new 'flags' field Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 6/8] ad9389b/adv7511: set proper media entity function Hans Verkuil
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Add a new function for digital video encoders such as HDMI transmitters.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/media/uapi/mediactl/media-types.rst | 7 +++++++
 include/uapi/linux/media.h                        | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/media/uapi/mediactl/media-types.rst b/Documentation/media/uapi/mediactl/media-types.rst
index 96910cf2eaaa..1db40c1f45d2 100644
--- a/Documentation/media/uapi/mediactl/media-types.rst
+++ b/Documentation/media/uapi/mediactl/media-types.rst
@@ -206,6 +206,13 @@ Types and flags used to represent the media graph elements
 	  and output it in some digital video standard, with appropriate
 	  timing signals.
 
+    *  -  ``MEDIA_ENT_F_DTV_ENCODER``
+       -  Digital video encoder. The basic function of the video encoder is
+	  to accept digital video from some digital video standard with
+	  appropriate timing signals (usually a parallel video bus with sync
+	  signals) and output this to a digital video output connector such
+	  as HDMI or DisplayPort.
+
 ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
 
 .. _media-entity-flag:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index ebd2cda67833..58be49e1adca 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -90,10 +90,11 @@ struct media_device_info {
 #define MEDIA_ENT_F_LENS			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
 
 /*
- * Video decoder functions
+ * Video decoder/encoder functions
  */
 #define MEDIA_ENT_F_ATV_DECODER			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
 #define MEDIA_ENT_F_DTV_DECODER			(MEDIA_ENT_F_BASE + 0x6001)
+#define MEDIA_ENT_F_DTV_ENCODER			(MEDIA_ENT_F_BASE + 0x6002)
 
 /*
  * Digital TV, analog TV, radio and/or software defined radio tuner functions.
-- 
2.17.0

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

* [PATCHv3 6/8] ad9389b/adv7511: set proper media entity function
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (4 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 5/8] media.h: add MEDIA_ENT_F_DTV_ENCODER Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 7/8] adv7180/tvp514x/tvp7002: fix " Hans Verkuil
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

These two drivers both have function MEDIA_ENT_F_DTV_ENCODER.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/ad9389b.c | 1 +
 drivers/media/i2c/adv7511.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 91ff06088572..0dfd94fcd18e 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -1134,6 +1134,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id *
 		goto err_hdl;
 	}
 	state->pad.flags = MEDIA_PAD_FL_SINK;
+	sd->entity.function = MEDIA_ENT_F_DTV_ENCODER;
 	err = media_entity_pads_init(&sd->entity, 1, &state->pad);
 	if (err)
 		goto err_hdl;
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 5731751d3f2a..d837617930b9 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -1847,6 +1847,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
 		goto err_hdl;
 	}
 	state->pad.flags = MEDIA_PAD_FL_SINK;
+	sd->entity.function = MEDIA_ENT_F_DTV_ENCODER;
 	err = media_entity_pads_init(&sd->entity, 1, &state->pad);
 	if (err)
 		goto err_hdl;
-- 
2.17.0

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

* [PATCHv3 7/8] adv7180/tvp514x/tvp7002: fix entity function
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (5 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 6/8] ad9389b/adv7511: set proper media entity function Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-21  7:19 ` [PATCHv3 8/8] media/i2c: add missing entity functions Hans Verkuil
  2018-06-28 12:29 ` [PATCHv3 0/8] media/mc: fix inconsistencies Sakari Ailus
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The entity function was ORed with the flags field instead of
assigned to the function field. Correct this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/adv7180.c | 2 +-
 drivers/media/i2c/tvp514x.c | 2 +-
 drivers/media/i2c/tvp7002.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 25d24a3f10a7..a727d7f806a1 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1335,7 +1335,7 @@ static int adv7180_probe(struct i2c_client *client,
 		goto err_unregister_vpp_client;
 
 	state->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_pads_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 6a9890531d01..675b9ae212ab 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1084,7 +1084,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	decoder->pad.flags = MEDIA_PAD_FL_SOURCE;
 	decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
+	decoder->sd.entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_pads_init(&decoder->sd.entity, 1, &decoder->pad);
 	if (ret < 0) {
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 4599b7e28a8d..4f5c627579c7 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1010,7 +1010,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	device->pad.flags = MEDIA_PAD_FL_SOURCE;
 	device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
+	device->sd.entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_pads_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
-- 
2.17.0

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

* [PATCHv3 8/8] media/i2c: add missing entity functions
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (6 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 7/8] adv7180/tvp514x/tvp7002: fix " Hans Verkuil
@ 2018-06-21  7:19 ` Hans Verkuil
  2018-06-28 12:29 ` [PATCHv3 0/8] media/mc: fix inconsistencies Sakari Ailus
  8 siblings, 0 replies; 10+ messages in thread
From: Hans Verkuil @ 2018-06-21  7:19 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Several drivers in media/i2c do not set the entity function.
Correct this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/adv7604.c              | 1 +
 drivers/media/i2c/adv7842.c              | 1 +
 drivers/media/i2c/et8ek8/et8ek8_driver.c | 1 +
 drivers/media/i2c/mt9m032.c              | 1 +
 drivers/media/i2c/mt9p031.c              | 1 +
 drivers/media/i2c/mt9t001.c              | 1 +
 drivers/media/i2c/mt9v032.c              | 1 +
 7 files changed, 7 insertions(+)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index cac2081e876e..f2df509e34f0 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3502,6 +3502,7 @@ static int adv76xx_probe(struct i2c_client *client,
 	for (i = 0; i < state->source_pad; ++i)
 		state->pads[i].flags = MEDIA_PAD_FL_SINK;
 	state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE;
+	sd->entity.function = MEDIA_ENT_F_DTV_DECODER;
 
 	err = media_entity_pads_init(&sd->entity, state->source_pad + 1,
 				state->pads);
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index fddac32e5051..56da071f99cb 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -3541,6 +3541,7 @@ static int adv7842_probe(struct i2c_client *client,
 	INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug,
 			adv7842_delayed_work_enable_hotplug);
 
+	sd->entity.function = MEDIA_ENT_F_DTV_DECODER;
 	state->pad.flags = MEDIA_PAD_FL_SOURCE;
 	err = media_entity_pads_init(&sd->entity, 1, &state->pad);
 	if (err)
diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index e9eff9039ef5..37ef38947e01 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -1446,6 +1446,7 @@ static int et8ek8_probe(struct i2c_client *client,
 	sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	sensor->subdev.internal_ops = &et8ek8_internal_ops;
 
+	sensor->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad);
 	if (ret < 0) {
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 6a9e068462fd..b385f2b632ad 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -793,6 +793,7 @@ static int mt9m032_probe(struct i2c_client *client,
 	v4l2_ctrl_cluster(2, &sensor->hflip);
 
 	sensor->subdev.ctrl_handler = &sensor->ctrls;
+	sensor->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad);
 	if (ret < 0)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 91d822fc4443..715be3632b01 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1111,6 +1111,7 @@ static int mt9p031_probe(struct i2c_client *client,
 	v4l2_i2c_subdev_init(&mt9p031->subdev, client, &mt9p031_subdev_ops);
 	mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops;
 
+	mt9p031->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	mt9p031->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&mt9p031->subdev.entity, 1, &mt9p031->pad);
 	if (ret < 0)
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 9d981d9f5686..f683d2cb0486 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -943,6 +943,7 @@ static int mt9t001_probe(struct i2c_client *client,
 	mt9t001->subdev.internal_ops = &mt9t001_subdev_internal_ops;
 	mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
+	mt9t001->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&mt9t001->subdev.entity, 1, &mt9t001->pad);
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 4de63b2df334..f74730d24d8f 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1162,6 +1162,7 @@ static int mt9v032_probe(struct i2c_client *client,
 	mt9v032->subdev.internal_ops = &mt9v032_subdev_internal_ops;
 	mt9v032->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
+	mt9v032->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&mt9v032->subdev.entity, 1, &mt9v032->pad);
 	if (ret < 0)
-- 
2.17.0

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

* Re: [PATCHv3 0/8] media/mc: fix inconsistencies
  2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
                   ` (7 preceding siblings ...)
  2018-06-21  7:19 ` [PATCHv3 8/8] media/i2c: add missing entity functions Hans Verkuil
@ 2018-06-28 12:29 ` Sakari Ailus
  8 siblings, 0 replies; 10+ messages in thread
From: Sakari Ailus @ 2018-06-28 12:29 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

On Thu, Jun 21, 2018 at 09:19:06AM +0200, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This patch series sits on top of this pull request:
> 
> https://patchwork.linuxtv.org/patch/50453/
> 
> That pull request cleans up the tables in the documentation, making it
> easier to add new entries.
> 
> This series is v3 of my previous attempt:
> 
> https://www.spinics.net/lists/linux-media/msg132218.html
> 
> The goal is to fix the inconsistencies between the 'old' and 'new' 
> MC API. I hate the terms 'old' and 'new', there is nothing wrong IMHO with 
> using an 'old' API if it meets the needs of the application.
> 
> The differences between v2 and v3 are that I changed that I changed
> the defines that test if the index or flags fields are present:
> 
> /*
>  * Appeared in 4.19.0.
>  *
>  * The media_version argument comes from the media_version field in
>  * struct media_device_info.
>  */
> #define MEDIA_V2_PAD_HAS_INDEX(media_version) \
>        ((media_version) >= ((4 << 16) | (19 << 8) | 0))
> 
> KERNEL_VERSION cannot be used in a public header, and my previous
> attempt used 0x00041300, which isn't as readable as what I do now.
> I also expanded the comment before the define pointing to struct
> media_device_info. I also did the same in the documentation.
> 
> I dropped the patches adding a function field to struct media_entity_desc.
> Instead I started the work to ensure all drivers set function correctly.
> 
> I still want to add a 'function' field to struct media_entity_desc but
> step one is to make sure drivers actually set function correctly. I'll
> revisit this once that's done.
> 
> Making G_TOPOLOGY useful is urgently needed since I think that will be
> very helpful for the work we want to do on library support for complex
> cameras.

For the set:

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi

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

end of thread, other threads:[~2018-06-28 12:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-21  7:19 [PATCHv3 0/8] media/mc: fix inconsistencies Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 1/8] media: add 'index' to struct media_v2_pad Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 2/8] media-ioc-g-topology.rst: document new 'index' field Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 3/8] media: add flags field to struct media_v2_entity Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 4/8] media-ioc-g-topology.rst: document new 'flags' field Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 5/8] media.h: add MEDIA_ENT_F_DTV_ENCODER Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 6/8] ad9389b/adv7511: set proper media entity function Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 7/8] adv7180/tvp514x/tvp7002: fix " Hans Verkuil
2018-06-21  7:19 ` [PATCHv3 8/8] media/i2c: add missing entity functions Hans Verkuil
2018-06-28 12:29 ` [PATCHv3 0/8] media/mc: fix inconsistencies Sakari Ailus

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.