All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] MC fixes, improvements and cleanups
@ 2015-09-06 17:30 Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
                   ` (17 more replies)
  0 siblings, 18 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

This patch series go after the previous series:
	"MC next generation patches"
	http://www.spinics.net/lists/linux-media/msg93108.html

It contains a series of fixes and cleanup the MC  Next gen.

The first patches add connector entities to represent RF, S-Video and Composite
interfaces on an analog device and fixes some bugs:
  [media] tuner-core: add an input pad
  [media] au0828: add support for the connectors
  [media] au0828: Create connector links
  [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  [media] media-controller: enable all interface links at init
  [media] media.h: create connector entities for hybrid TV devices

The next sequence of patches enforce __must_check to pads and links creation,
as requested by Hans Verkuil:
  [media] dvbdev: returns error if graph object creation fails
  [media] dvb core: must check dvb_create_media_graph()
  [media] media-entity: enforce check of interface and links creation
  [media] cx231xx: enforce check for graph creation
  [media] au0828:: enforce check for graph creation
  [media] media-entity: must check media_create_pad_link()

The next patches do the entity function rename as agreed at the meeting we had on
IRC last Wednesday, and exposes it via G_TOPOLOGY:
  [media] media-entity.h: rename entity.type to entity.function
  [media] media-device: export the entity function via new ioctl
  [media] uapi/media.h: Rename entities types to functions
  [media] DocBook: update entities documentation

The final patches are some cleanups at the dvbdev link creation:
  [media] dvbdev: move indirect links on dvr/demux to a separate function
  [media] dvbdev: Don't create indirect links

The last patch deserves a better explanation: entities may direct or indirect control
a device, on non-v4l2-subdev-centric devices. We're not creating the indirect
interface control links at V4L2 side. I decided to remove it also from the dvbdev
side. Implementing support for it is not hard, but let's do it only when we have some
usecases.

There aren't much things to be done for the merge of the MC next gen series on
(scheduled for Kernel 4.4). On my  my lists, the remaining items are:

TODO for next Kernel version (goal: Kernel version 4.4):
=========================================================

- Add Javier's fixup patches with fixes for some platform drivers
  and uvc;

- Find entities that belong to V4L2 or DVB via the interfaces,
  in order to enable/disable the inteface links when the device
  gets busy;

TODO for a next versions:
=========================

- Remove unused fields from media_entity (like major, minor, revision,
  group_id, num_links, num_backlinks, num_pads)

- dynamic entity/interface/link creation and removal;

- SETUP_LINK_V2 with dynamic support;

- dynamic pad creation and removal (needed?);

- multiple function per entity support;

- indirect interface links support;

- MC properties API.

Userspace:
==========

- Create a library with v2 API;

- Use the v2 API library on qv4l2/libdvbv5/xawtv/libv4l;

- Add the libudev/libsysfs logic at mc_nextgen_test to convert
  a devnode major/minor into a /dev/* name;


Mauro Carvalho Chehab (18):
  [media] tuner-core: add an input pad
  [media] au0828: add support for the connectors
  [media] au0828: Create connector links
  [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  [media] media-controller: enable all interface links at init
  [media] media.h: create connector entities for hybrid TV devices
  [media] dvbdev: returns error if graph object creation fails
  [media] dvb core: must check dvb_create_media_graph()
  [media] media-entity: enforce check of interface and links creation
  [media] cx231xx: enforce check for graph creation
  [media] au0828:: enforce check for graph creation
  [media] media-entity: must check media_create_pad_link()
  [media] media-entity.h: rename entity.type to entity.function
  [media] media-device: export the entity function via new ioctl
  [media] uapi/media.h: Rename entities types to functions
  [media] DocBook: update entities documentation
  [media] dvbdev: move indirect links on dvr/demux to a separate
    function
  [media] dvbdev: Don't create indirect links

 .../DocBook/media/v4l/media-ioc-enum-entities.xml  |  58 ++--
 Documentation/video4linux/v4l2-framework.txt       |   4 +-
 drivers/media/common/siano/smsdvb-main.c           |   6 +-
 drivers/media/dvb-core/dvbdev.c                    | 343 ++++++++++++---------
 drivers/media/dvb-core/dvbdev.h                    |   7 +-
 drivers/media/dvb-frontends/au8522_decoder.c       |   2 +-
 drivers/media/i2c/adp1653.c                        |   2 +-
 drivers/media/i2c/adv7180.c                        |   2 +-
 drivers/media/i2c/as3645a.c                        |   2 +-
 drivers/media/i2c/cx25840/cx25840-core.c           |   2 +-
 drivers/media/i2c/lm3560.c                         |   2 +-
 drivers/media/i2c/lm3646.c                         |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c             |   2 +-
 drivers/media/i2c/noon010pc30.c                    |   2 +-
 drivers/media/i2c/ov2659.c                         |   2 +-
 drivers/media/i2c/ov9650.c                         |   2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c           |   4 +-
 drivers/media/i2c/s5k4ecgx.c                       |   2 +-
 drivers/media/i2c/s5k5baf.c                        |   6 +-
 drivers/media/i2c/s5k6aa.c                         |   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c             |   2 +-
 drivers/media/i2c/tvp514x.c                        |   2 +-
 drivers/media/i2c/tvp7002.c                        |   2 +-
 drivers/media/media-device.c                       |  10 +-
 drivers/media/media-entity.c                       |   1 +
 drivers/media/platform/xilinx/xilinx-dma.c         |   2 +-
 drivers/media/usb/au0828/au0828-core.c             |  94 +++++-
 drivers/media/usb/au0828/au0828-dvb.c              |   8 +-
 drivers/media/usb/au0828/au0828-video.c            |  76 ++++-
 drivers/media/usb/au0828/au0828.h                  |   3 +-
 drivers/media/usb/cx231xx/cx231xx-cards.c          |  46 ++-
 drivers/media/usb/cx231xx/cx231xx-dvb.c            |   6 +-
 drivers/media/usb/cx231xx/cx231xx-video.c          |   2 +-
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c        |   4 +-
 drivers/media/usb/dvb-usb/dvb-usb-dvb.c            |   6 +-
 drivers/media/v4l2-core/tuner-core.c               |  10 +-
 drivers/media/v4l2-core/v4l2-dev.c                 |  17 +-
 drivers/media/v4l2-core/v4l2-device.c              |   2 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c     |   2 +-
 drivers/media/v4l2-core/v4l2-subdev.c              |   6 +-
 include/media/media-entity.h                       |  46 +--
 include/media/tuner.h                              |   8 +
 include/uapi/linux/media.h                         | 120 +++----
 43 files changed, 586 insertions(+), 343 deletions(-)

-- 
2.4.3



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

* [PATCH 01/18] [media] tuner-core: add an input pad
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 14:48   ` Hans Verkuil
  2015-11-23 20:01   ` Laurent Pinchart
  2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
                   ` (16 subsequent siblings)
  17 siblings, 2 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Shuah Khan,
	Matthias Schwarzott, Antti Palosaari, Olli Salonen,
	Tommi Rantala, Lad, Prabhakar, Sakari Ailus, Laurent Pinchart,
	Krzysztof Kozlowski

Tuners actually have at least one connector on its
input.

Add a PAD to connect it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index f00f1a5f279c..a8e7e2398f7a 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -34,6 +34,9 @@
 #include <linux/mutex.h>
 #include "dvbdev.h"
 
+/* Due to enum tuner_pad_index */
+#include <media/tuner.h>
+
 static DEFINE_MUTEX(dvbdev_mutex);
 static int dvbdev_debug;
 
@@ -552,7 +555,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
 	}
 
 	if (tuner && demod)
-		media_create_pad_link(tuner, 0, demod, 0, 0);
+		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
 
 	if (demod && demux)
 		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index e28cabe65934..f54c7d10f350 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -27,6 +27,9 @@
 #include <media/v4l2-common.h>
 #include <linux/mutex.h>
 
+/* Due to enum tuner_pad_index */
+#include <media/tuner.h>
+
 /*
  * 1 = General debug messages
  * 2 = USB handling
@@ -260,7 +263,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 		return;
 
 	if (tuner)
-		media_create_pad_link(tuner, 0, decoder, 0,
+		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
 				      MEDIA_LNK_FL_ENABLED);
 	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
 			      MEDIA_LNK_FL_ENABLED);
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 3b5c9ae39ad3..1070d87efc65 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1264,7 +1264,7 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
 		return;
 
 	if (tuner)
-		media_create_pad_link(tuner, 0, decoder, 0,
+		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
 					 MEDIA_LNK_FL_ENABLED);
 	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
 				 MEDIA_LNK_FL_ENABLED);
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 100b8f069640..b90f2a52db96 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -134,8 +134,9 @@ struct tuner {
 	unsigned int        type; /* chip type id */
 	void                *config;
 	const char          *name;
+
 #if defined(CONFIG_MEDIA_CONTROLLER)
-	struct media_pad	pad;
+	struct media_pad	pad[TUNER_NUM_PADS];
 #endif
 };
 
@@ -695,11 +696,12 @@ static int tuner_probe(struct i2c_client *client,
 	/* Should be just before return */
 register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
-	t->pad.flags = MEDIA_PAD_FL_SOURCE;
+	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
+	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
 	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
 	t->sd.entity.name = t->name;
 
-	ret = media_entity_init(&t->sd.entity, 1, &t->pad);
+	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
 	if (ret < 0) {
 		tuner_err("failed to initialize media entity!\n");
 		kfree(t);
diff --git a/include/media/tuner.h b/include/media/tuner.h
index b46ebb48fe74..95835c8069dd 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -25,6 +25,14 @@
 
 #include <linux/videodev2.h>
 
+/* Tuner PADs */
+/* FIXME: is this the right place for it? */
+enum tuner_pad_index {
+	TUNER_PAD_RF_INPUT,
+	TUNER_PAD_IF_OUTPUT,
+	TUNER_NUM_PADS
+};
+
 #define ADDR_UNSET (255)
 
 #define TUNER_TEMIC_PAL			0        /* 4002 FH5 (3X 7756, 9483) */
-- 
2.4.3



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

* [PATCH 02/18] [media] au0828: add support for the connectors
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 14:57   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 03/18] [media] au0828: Create connector links Mauro Carvalho Chehab
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab,
	Hans Verkuil, Shuah Khan, Lad, Prabhakar, Julia Lawall

Depending on the input, an au0828 may have a different
number of connectors. add entities to represent them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index f54c7d10f350..fe9a60484343 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -153,11 +153,26 @@ static void au0828_usb_release(struct au0828_dev *dev)
 }
 
 #ifdef CONFIG_VIDEO_AU0828_V4L2
+
+static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+	int i;
+
+	for (i = 0; i < AU0828_MAX_INPUT; i++) {
+		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
+			return;
+		media_device_unregister_entity(&dev->input_ent[i]);
+	}
+#endif
+}
+
 static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
 {
 	struct au0828_dev *dev =
 		container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
 
+	au0828_usb_v4l2_media_release(dev);
 	v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
 	v4l2_device_unregister(&dev->v4l2_dev);
 	au0828_usb_release(dev);
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 4511e2893282..806b8d320bae 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1793,6 +1793,69 @@ static int au0828_vb2_setup(struct au0828_dev *dev)
 	return 0;
 }
 
+static void au0828_analog_create_entities(struct au0828_dev *dev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	static const char *inames[] = {
+		[AU0828_VMUX_COMPOSITE] = "Composite",
+		[AU0828_VMUX_SVIDEO] = "S-Video",
+		[AU0828_VMUX_CABLE] = "Cable TV",
+		[AU0828_VMUX_TELEVISION] = "Television",
+		[AU0828_VMUX_DVB] = "DVB",
+		[AU0828_VMUX_DEBUG] = "tv debug"
+	};
+	int ret, i;
+
+	/* Initialize Video and VBI pads */
+	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
+	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
+	if (ret < 0)
+		pr_err("failed to initialize video media entity!\n");
+
+	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
+	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
+	if (ret < 0)
+		pr_err("failed to initialize vbi media entity!\n");
+
+	/* Create entities for each input connector */
+	for (i = 0; i < AU0828_MAX_INPUT; i++) {
+		struct media_entity *ent = &dev->input_ent[i];
+
+		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
+			break;
+
+		ent->name = inames[AUVI_INPUT(i).type];
+		ent->flags = MEDIA_ENT_FL_CONNECTOR;
+		dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+		switch(AUVI_INPUT(i).type) {
+		case AU0828_VMUX_COMPOSITE:
+			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
+			break;
+		case AU0828_VMUX_SVIDEO:
+			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
+			break;
+		case AU0828_VMUX_CABLE:
+		case AU0828_VMUX_TELEVISION:
+		case AU0828_VMUX_DVB:
+			ent->type = MEDIA_ENT_T_CONN_RF;
+			break;
+		default: /* AU0828_VMUX_DEBUG */
+			ent->type = MEDIA_ENT_T_CONN_TEST;
+			break;
+		}
+
+		ret = media_entity_init(ent, 1, &dev->input_pad[i]);
+		if (ret < 0)
+			pr_err("failed to initialize input pad[%d]!\n", i);
+
+		ret = media_device_register_entity(dev->media_dev, ent);
+		if (ret < 0)
+			pr_err("failed to register input entity %d!\n", i);
+	}
+#endif
+}
+
 /**************************************************************************/
 
 int au0828_analog_register(struct au0828_dev *dev,
@@ -1881,17 +1944,8 @@ int au0828_analog_register(struct au0828_dev *dev,
 	dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock;
 	strcpy(dev->vbi_dev.name, "au0828a vbi");
 
-#if defined(CONFIG_MEDIA_CONTROLLER)
-	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
-	if (ret < 0)
-		pr_err("failed to initialize video media entity!\n");
-
-	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
-	if (ret < 0)
-		pr_err("failed to initialize vbi media entity!\n");
-#endif
+	/* Init entities at the Media Controller */
+	au0828_analog_create_entities(dev);
 
 	/* initialize videobuf2 stuff */
 	retval = au0828_vb2_setup(dev);
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
index d3644b3fe6fa..b7940c54d006 100644
--- a/drivers/media/usb/au0828/au0828.h
+++ b/drivers/media/usb/au0828/au0828.h
@@ -93,7 +93,6 @@ struct au0828_board {
 	unsigned char has_ir_i2c:1;
 	unsigned char has_analog:1;
 	struct au0828_input input[AU0828_MAX_INPUT];
-
 };
 
 struct au0828_dvb {
@@ -281,6 +280,8 @@ struct au0828_dev {
 	struct media_device *media_dev;
 	struct media_pad video_pad, vbi_pad;
 	struct media_entity *decoder;
+	struct media_entity input_ent[AU0828_MAX_INPUT];
+	struct media_pad input_pad[AU0828_MAX_INPUT];
 #endif
 };
 
-- 
2.4.3



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

* [PATCH 03/18] [media] au0828: Create connector links
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab,
	Shuah Khan, Hans Verkuil

Now that connectors are entities, we need to represent the
connector links.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index fe9a60484343..35c607c35155 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -257,6 +257,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 	struct media_device *mdev = dev->media_dev;
 	struct media_entity *entity;
 	struct media_entity *tuner = NULL, *decoder = NULL;
+	int i;
 
 	if (!mdev)
 		return;
@@ -274,6 +275,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 
 	/* Analog setup, using tuner as a link */
 
+	/* Something bad happened! */
 	if (!decoder)
 		return;
 
@@ -284,6 +286,30 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 			      MEDIA_LNK_FL_ENABLED);
 	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
 			      MEDIA_LNK_FL_ENABLED);
+
+	for (i = 0; i < AU0828_MAX_INPUT; i++) {
+		struct media_entity *ent = &dev->input_ent[i];
+
+		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
+			break;
+
+		switch(AUVI_INPUT(i).type) {
+		case AU0828_VMUX_CABLE:
+		case AU0828_VMUX_TELEVISION:
+		case AU0828_VMUX_DVB:
+			if (tuner)
+				media_create_pad_link(ent, 0, tuner,
+						      TUNER_PAD_RF_INPUT,
+						      MEDIA_LNK_FL_ENABLED);
+			break;
+		case AU0828_VMUX_COMPOSITE:
+		case AU0828_VMUX_SVIDEO:
+		default: /* AU0828_VMUX_DEBUG */
+			/* FIXME: fix the decoder PAD */
+			media_create_pad_link(ent, 0, decoder, 0, 0);
+			break;
+		}
+	}
 #endif
 }
 
-- 
2.4.3



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

* [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 03/18] [media] au0828: Create connector links Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 14:58   ` Hans Verkuil
  2015-11-23 19:56   ` Laurent Pinchart
  2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
                   ` (13 subsequent siblings)
  17 siblings, 2 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab

Due to the graph traversal algorithm currently in usage, we
need a copy of all data links. Those backlinks should not be
send to userspace, as otherwise, all links there will be
duplicated.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 0238885fcc74..97eb97d9b662 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -333,6 +333,9 @@ static long __media_device_get_topology(struct media_device *mdev,
 	/* Get links and number of links */
 	i = 0;
 	media_device_for_each_link(link, mdev) {
+		if (link->is_backlink)
+			continue;
+
 		i++;
 
 		if (ret || !topo->links)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index cd4d767644df..4868b8269204 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -648,6 +648,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 	backlink->source = &source->pads[source_pad];
 	backlink->sink = &sink->pads[sink_pad];
 	backlink->flags = flags;
+	backlink->is_backlink = true;
 
 	/* Initialize graph object embedded at the new link */
 	media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index e1a89899deef..3d389f142a1d 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -96,6 +96,7 @@ struct media_pipeline {
  * @reverse:	Pointer to the link for the reverse direction of a pad to pad
  *		link.
  * @flags:	Link flags, as defined at uapi/media.h (MEDIA_LNK_FL_*)
+ * @is_backlink: Indicate if the link is a backlink.
  */
 struct media_link {
 	struct media_gobj graph_obj;
@@ -112,6 +113,7 @@ struct media_link {
 	};
 	struct media_link *reverse;
 	unsigned long flags;
+	bool is_backlink;
 };
 
 /**
-- 
2.4.3



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

* [PATCH 05/18] [media] media-controller: enable all interface links at init
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:18   ` Hans Verkuil
  2015-11-23 19:46   ` Laurent Pinchart
  2015-09-06 17:30 ` [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices Mauro Carvalho Chehab
                   ` (12 subsequent siblings)
  17 siblings, 2 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus

Interface links are normally enabled, meaning that the interfaces are
bound to the entities. So, any ioctl send to the interface are reflected
at the entities managed by the interface.

However, when a device is usage, other interfaces for the same hardware
could be decoupled from the entities linked to them, because the
hardware may have some parts busy.

That's for example, what happens when an hybrid TV device is in usage.
If it is streaming analog TV or capturing signals from S-Video/Composite
connectors, typically the digital part of the hardware can't be used and
vice-versa.

This is generally due to some internal hardware or firmware limitation,
that it is not easily mapped via data pipelines.

What the Kernel drivers do internally is that they decouple the hardware
from the interface. So, all changes, if allowed, are done only at some
interface cache, but not physically changed at the hardware.

The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data
links. So, let's use the same flag to indicate if ether the interface
to entity link is bound/enabled or not.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index a8e7e2398f7a..5c4fb41060b4 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -396,7 +396,8 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
 	if (!dvbdev->entity || !dvbdev->intf_devnode)
 		return;
 
-	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0);
+	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
+			       MEDIA_LNK_FL_ENABLED);
 
 #endif
 }
@@ -583,20 +584,24 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
 	media_device_for_each_intf(intf, mdev) {
 		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
-			media_create_intf_link(ca, intf, 0);
+			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
 
 		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
-			media_create_intf_link(tuner, intf, 0);
+			media_create_intf_link(tuner, intf,
+					       MEDIA_LNK_FL_ENABLED);
 
 		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
-			media_create_intf_link(demux, intf, 0);
+			media_create_intf_link(demux, intf,
+					       MEDIA_LNK_FL_ENABLED);
 
 		media_device_for_each_entity(entity, mdev) {
 			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strcmp(entity->name, DVR_TSOUT))
-					media_create_intf_link(entity, intf, 0);
+					media_create_intf_link(entity, intf,
+							       MEDIA_LNK_FL_ENABLED);
 				if (!strcmp(entity->name, DEMUX_TSOUT))
-					media_create_intf_link(entity, intf, 0);
+					media_create_intf_link(entity, intf,
+							       MEDIA_LNK_FL_ENABLED);
 				break;
 			}
 		}
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 07123dd569c4..8429da66754a 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -788,7 +788,8 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
-					      &vdev->intf_devnode->intf, 0);
+					      &vdev->intf_devnode->intf,
+					      MEDIA_LNK_FL_ENABLED);
 		if (!link) {
 			media_devnode_remove(vdev->intf_devnode);
 			media_device_unregister_entity(&vdev->entity);
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index e788a085ba96..bb58d90fde5e 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -256,7 +256,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
 
 			link = media_create_intf_link(&sd->entity,
 						      &vdev->intf_devnode->intf,
-						      0);
+						      MEDIA_LNK_FL_ENABLED);
 			if (!link)
 				goto clean_up;
 		}
-- 
2.4.3



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

* [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:19     ` Hans Verkuil
  2015-11-23 18:09     ` Laurent Pinchart
  2015-09-06 17:30 ` [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  17 siblings, 2 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, linux-api

Add entities to represent the connectors that exists inside a
hybrid TV device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index b17f6763aff4..69433405aec2 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -61,6 +61,7 @@ struct media_device_info {
 #define MEDIA_ENT_T_DVB_BASE		0x00000000
 #define MEDIA_ENT_T_V4L2_BASE		0x00010000
 #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
+#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
 
 /*
  * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
@@ -105,6 +106,13 @@ struct media_device_info {
 #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
 #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
 
+/* Connectors */
+#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
+#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
+#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
+	/* For internal test signal generators and other debug connectors */
+#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
+
 #ifndef __KERNEL__
 /* Legacy symbols used to avoid userspace compilation breakages */
 #define MEDIA_ENT_TYPE_SHIFT		16
@@ -121,9 +129,9 @@ struct media_device_info {
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
 #endif
 
-/* Entity types */
-
+/* Entity flags */
 #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
+#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)
 
 struct media_entity_desc {
 	__u32 id;
-- 
2.4.3



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

* [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:20   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph() Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Jonathan Corbet

Right now, if something gets wrong at dvb_create_media_entity()
or at dvb_create_media_graph(), the device will still be
registered.

Change the logic to properly handle it and free all media graph
objects if something goes wrong at dvb_register_device().

Also, change the logic at dvb_create_media_graph() to return
an error code if something goes wrong. It is up to the
caller to implement the right logic and to call
dvb_unregister_device() to unregister the already-created
objects.

While here, add a missing logic to unregister the created
interfaces.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 5c4fb41060b4..5c51084a331a 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -183,7 +183,29 @@ skip:
 	return -ENFILE;
 }
 
-static void dvb_create_tsout_entity(struct dvb_device *dvbdev,
+static void dvb_media_device_free(struct dvb_device *dvbdev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
+	if (dvbdev->entity) {
+		int i;
+
+		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
+			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
+			kfree(dvbdev->tsout_entity[i].name);
+		}
+		media_device_unregister_entity(dvbdev->entity);
+
+		kfree(dvbdev->entity);
+		kfree(dvbdev->pads);
+		kfree(dvbdev->tsout_entity);
+		kfree(dvbdev->tsout_pads);
+	}
+	if (dvbdev->intf_devnode)
+		media_devnode_remove(dvbdev->intf_devnode);
+#endif
+}
+
+static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 				    const char *name, int npads)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
@@ -192,77 +214,60 @@ static void dvb_create_tsout_entity(struct dvb_device *dvbdev,
 	dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads),
 				     GFP_KERNEL);
 	if (!dvbdev->tsout_pads)
-		return;
+		return -ENOMEM;
+
 	dvbdev->tsout_entity = kcalloc(npads, sizeof(*dvbdev->tsout_entity),
 				       GFP_KERNEL);
-	if (!dvbdev->tsout_entity) {
-		kfree(dvbdev->tsout_pads);
-		dvbdev->tsout_pads = NULL;
-		return;
-	}
+	if (!dvbdev->tsout_entity)
+		return -ENOMEM;
+
 	for (i = 0; i < npads; i++) {
 		struct media_pad *pads = &dvbdev->tsout_pads[i];
 		struct media_entity *entity = &dvbdev->tsout_entity[i];
 
 		entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i);
-		if (!entity->name) {
-			ret = -ENOMEM;
-			break;
-		}
+		if (!entity->name)
+			return ret;
 
 		entity->type = MEDIA_ENT_T_DVB_TSOUT;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
 		if (ret < 0)
-			break;
+			return ret;
 
 		ret = media_device_register_entity(dvbdev->adapter->mdev,
 						   entity);
 		if (ret < 0)
-			break;
+			return ret;
 	}
-
-	if (!ret) {
-		dvbdev->tsout_num_entities = npads;
-		return;
-	}
-
-	for (i--; i >= 0; i--) {
-		media_device_unregister_entity(&dvbdev->tsout_entity[i]);
-		kfree(dvbdev->tsout_entity[i].name);
-	}
-
-	printk(KERN_ERR
-		"%s: media_device_register_entity failed for %s\n",
-		__func__, name);
-
-	kfree(dvbdev->tsout_entity);
-	kfree(dvbdev->tsout_pads);
-	dvbdev->tsout_entity = NULL;
-	dvbdev->tsout_pads = NULL;
 #endif
+	return 0;
 }
 
 #define DEMUX_TSOUT	"demux-tsout"
 #define DVR_TSOUT	"dvr-tsout"
 
-static void dvb_create_media_entity(struct dvb_device *dvbdev,
-				    int type, int demux_sink_pads)
+static int dvb_create_media_entity(struct dvb_device *dvbdev,
+				   int type, int demux_sink_pads)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
-	int i, ret = 0, npads;
+	int i, ret, npads;
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
 		npads = 2;
 		break;
 	case DVB_DEVICE_DVR:
-		dvb_create_tsout_entity(dvbdev, DVR_TSOUT, demux_sink_pads);
-		return;
+		ret = dvb_create_tsout_entity(dvbdev, DVR_TSOUT,
+					      demux_sink_pads);
+		return ret;
 	case DVB_DEVICE_DEMUX:
 		npads = 1 + demux_sink_pads;
-		dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT, demux_sink_pads);
+		ret = dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT,
+					      demux_sink_pads);
+		if (ret < 0)
+			return ret;
 		break;
 	case DVB_DEVICE_CA:
 		npads = 2;
@@ -277,24 +282,22 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,
 		 * the Media Controller, let's not create the decap
 		 * entities yet.
 		 */
-		return;
+		return 0;
 	default:
-		return;
+		return 0;
 	}
 
 	dvbdev->entity = kzalloc(sizeof(*dvbdev->entity), GFP_KERNEL);
 	if (!dvbdev->entity)
-		return;
+		return -ENOMEM;
 
 	dvbdev->entity->name = dvbdev->name;
 
 	if (npads) {
 		dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads),
 				       GFP_KERNEL);
-		if (!dvbdev->pads) {
-			kfree(dvbdev->entity);
-			return;
-		}
+		if (!dvbdev->pads)
+			return -ENOMEM;
 	}
 
 	switch (type) {
@@ -316,49 +319,43 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,
 		break;
 	default:
 		kfree(dvbdev->entity);
+		kfree(dvbdev->pads);
 		dvbdev->entity = NULL;
-		return;
+		return 0;
 	}
 
-	if (npads)
+	if (npads) {
 		ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads);
-	if (!ret)
-		ret = media_device_register_entity(dvbdev->adapter->mdev,
-						   dvbdev->entity);
-	if (ret < 0) {
-		printk(KERN_ERR
-			"%s: media_device_register_entity failed for %s\n",
-			__func__, dvbdev->entity->name);
-
-		media_device_unregister_entity(dvbdev->entity);
-		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
-			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
-			kfree(dvbdev->tsout_entity[i].name);
-		}
-		kfree(dvbdev->pads);
-		kfree(dvbdev->entity);
-		kfree(dvbdev->tsout_pads);
-		kfree(dvbdev->tsout_entity);
-		dvbdev->entity = NULL;
-		return;
+		if (ret)
+			return ret;
 	}
+	ret = media_device_register_entity(dvbdev->adapter->mdev,
+					   dvbdev->entity);
+	if (ret)
+		return (ret);
 
 	printk(KERN_DEBUG "%s: media entity '%s' registered.\n",
 		__func__, dvbdev->entity->name);
+
 #endif
+	return 0;
 }
 
-static void dvb_register_media_device(struct dvb_device *dvbdev,
-				      int type, int minor,
-				      unsigned demux_sink_pads)
+static int dvb_register_media_device(struct dvb_device *dvbdev,
+				     int type, int minor,
+				     unsigned demux_sink_pads)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
+	struct media_link *link;
 	u32 intf_type;
+	int ret;
 
 	if (!dvbdev->adapter->mdev)
-		return;
+		return 0;
 
-	dvb_create_media_entity(dvbdev, type, demux_sink_pads);
+	ret = dvb_create_media_entity(dvbdev, type, demux_sink_pads);
+	if (ret)
+		return ret;
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
@@ -377,13 +374,16 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
 		intf_type = MEDIA_INTF_T_DVB_NET;
 		break;
 	default:
-		return;
+		return 0;
 	}
 
 	dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev,
-						 intf_type, 0,
-						 DVB_MAJOR, minor,
-						 GFP_KERNEL);
+						    intf_type, 0,
+						    DVB_MAJOR, minor,
+						    GFP_KERNEL);
+
+	if (!dvbdev->intf_devnode)
+		return -ENOMEM;
 
 	/*
 	 * Create the "obvious" link, e. g. the ones that represent
@@ -393,13 +393,15 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
 	 *		DVB demux intf -> dvr
 	 */
 
-	if (!dvbdev->entity || !dvbdev->intf_devnode)
-		return;
-
-	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
-			       MEDIA_LNK_FL_ENABLED);
+	if (!dvbdev->entity)
+		return 0;
 
+	link = media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
+				      MEDIA_LNK_FL_ENABLED);
+	if (!link)
+		return -ENOMEM;
 #endif
+	return 0;
 }
 
 int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
@@ -410,7 +412,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 	struct file_operations *dvbdevfops;
 	struct device *clsdev;
 	int minor;
-	int id;
+	int id, ret;
 
 	mutex_lock(&dvbdev_register_lock);
 
@@ -428,6 +430,17 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		return -ENOMEM;
 	}
 
+	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
+	if (ret) {
+		printk(KERN_ERR
+		      "%s: dvb_register_media_device failed to create the mediagraph\n",
+		      __func__);
+
+		dvb_media_device_free(dvbdev);
+		mutex_unlock(&dvbdev_register_lock);
+		return ret;
+	}
+
 	dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
 
 	if (!dvbdevfops){
@@ -483,8 +496,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 	dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
 		adap->num, dnames[type], id, minor, minor);
 
-	dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
-
 	return 0;
 }
 EXPORT_SYMBOL(dvb_register_device);
@@ -499,25 +510,10 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
 	dvb_minors[dvbdev->minor] = NULL;
 	up_write(&minor_rwsem);
 
+	dvb_media_device_free(dvbdev);
+
 	device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor));
 
-#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
-	if (dvbdev->entity) {
-		int i;
-
-		media_device_unregister_entity(dvbdev->entity);
-		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
-			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
-			kfree(dvbdev->tsout_entity[i].name);
-		}
-
-		kfree(dvbdev->entity);
-		kfree(dvbdev->pads);
-		kfree(dvbdev->tsout_entity);
-		kfree(dvbdev->tsout_pads);
-	}
-#endif
-
 	list_del (&dvbdev->list_head);
 	kfree (dvbdev->fops);
 	kfree (dvbdev);
@@ -526,17 +522,19 @@ EXPORT_SYMBOL(dvb_unregister_device);
 
 
 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
-void dvb_create_media_graph(struct dvb_adapter *adap)
+int dvb_create_media_graph(struct dvb_adapter *adap)
 {
 	struct media_device *mdev = adap->mdev;
 	struct media_entity *entity, *tuner = NULL, *demod = NULL;
 	struct media_entity *demux = NULL, *ca = NULL;
+	struct media_link *link;
 	struct media_interface *intf;
 	unsigned demux_pad = 0;
 	unsigned dvr_pad = 0;
+	int ret;
 
 	if (!mdev)
-		return;
+		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->type) {
@@ -555,57 +553,94 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 	}
 
-	if (tuner && demod)
-		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
+	if (tuner && demod) {
+		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
+					    demod, 0, MEDIA_LNK_FL_ENABLED);
+		if (ret)
+			return ret;
+	}
 
-	if (demod && demux)
-		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
-	if (demux && ca)
-		media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
+	if (demod && demux) {
+		ret = media_create_pad_link(demod, 1, demux,
+					    0, MEDIA_LNK_FL_ENABLED);
+		if (ret)
+			return -ENOMEM;
+	}
+	if (demux && ca) {
+		ret = media_create_pad_link(demux, 1, ca,
+					    0, MEDIA_LNK_FL_ENABLED);
+		if (!ret)
+			return -ENOMEM;
+	}
 
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
 			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strncmp(entity->name, DVR_TSOUT,
-					strlen(DVR_TSOUT)))
-					media_create_pad_link(demux,
-							      ++dvr_pad,
-							entity, 0, 0);
+				    strlen(DVR_TSOUT))) {
+					ret = media_create_pad_link(demux,
+								++dvr_pad,
+							    entity, 0, 0);
+					if (ret)
+						return ret;
+				}
 				if (!strncmp(entity->name, DEMUX_TSOUT,
-					strlen(DEMUX_TSOUT)))
-					media_create_pad_link(demux,
+				    strlen(DEMUX_TSOUT))) {
+					ret = media_create_pad_link(demux,
 							      ++demux_pad,
-							entity, 0, 0);
+							    entity, 0, 0);
+					if (ret)
+						return ret;
+				}
 			}
 		}
 	}
 
 	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
 	media_device_for_each_intf(intf, mdev) {
-		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
-			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
+		if (intf->type == MEDIA_INTF_T_DVB_CA && ca) {
+			link = media_create_intf_link(ca, intf,
+						      MEDIA_LNK_FL_ENABLED);
+			if (!link)
+				return -ENOMEM;
+		}
 
-		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
-			media_create_intf_link(tuner, intf,
-					       MEDIA_LNK_FL_ENABLED);
+		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) {
+			link = media_create_intf_link(tuner, intf,
+						      MEDIA_LNK_FL_ENABLED);
+			if (!link)
+				return -ENOMEM;
+		}
 
-		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
-			media_create_intf_link(demux, intf,
-					       MEDIA_LNK_FL_ENABLED);
+		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) {
+			link = media_create_intf_link(demux, intf,
+						      MEDIA_LNK_FL_ENABLED);
+			if (!link)
+				return -ENOMEM;
+		}
 
 		media_device_for_each_entity(entity, mdev) {
 			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
-				if (!strcmp(entity->name, DVR_TSOUT))
-					media_create_intf_link(entity, intf,
-							       MEDIA_LNK_FL_ENABLED);
-				if (!strcmp(entity->name, DEMUX_TSOUT))
-					media_create_intf_link(entity, intf,
-							       MEDIA_LNK_FL_ENABLED);
+				if (!strcmp(entity->name, DVR_TSOUT)) {
+					link = media_create_intf_link(entity,
+							intf,
+							MEDIA_LNK_FL_ENABLED);
+					if (!link)
+						return -ENOMEM;
+				}
+				if (!strcmp(entity->name, DEMUX_TSOUT)) {
+					link = media_create_intf_link(entity,
+							intf,
+							MEDIA_LNK_FL_ENABLED);
+					if (!link)
+						return -ENOMEM;
+				}
 				break;
 			}
 		}
 	}
+	return 0;
 }
 EXPORT_SYMBOL_GPL(dvb_create_media_graph);
 #endif
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 0b140e8595de..9e24aafeb9ea 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -210,7 +210,7 @@ int dvb_register_device(struct dvb_adapter *adap,
 void dvb_unregister_device(struct dvb_device *dvbdev);
 
 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
-void dvb_create_media_graph(struct dvb_adapter *adap);
+int dvb_create_media_graph(struct dvb_adapter *adap);
 static inline void dvb_register_media_controller(struct dvb_adapter *adap,
 						 struct media_device *mdev)
 {
@@ -218,7 +218,10 @@ static inline void dvb_register_media_controller(struct dvb_adapter *adap,
 }
 
 #else
-static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
+static inline int dvb_create_media_graph(struct dvb_adapter *adap)
+{
+	return 0;
+};
 #define dvb_register_media_controller(a, b) {}
 #endif
 
-- 
2.4.3



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

* [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph()
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:22   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 09/18] [media] media-entity: enforce check of interface and links creation Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Antti Palosaari, Stefan Richter,
	Hans Verkuil, Jonathan Corbet,
	Rafael Lourenço de Lima Chehab, Michael Ira Krufky,
	Richard Vollkommer, Devin Heitmueller, Matthias Schwarzott,
	Olli Salonen, Luis de Bethencourt

If media controller is enabled and mdev is filled, it should
ensure that the media graph will be properly initialized.

Enforce that.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
index f4305ae800f4..ab345490a43a 100644
--- a/drivers/media/common/siano/smsdvb-main.c
+++ b/drivers/media/common/siano/smsdvb-main.c
@@ -1183,7 +1183,11 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
 	if (smsdvb_debugfs_create(client) < 0)
 		pr_info("failed to create debugfs node\n");
 
-	dvb_create_media_graph(&client->adapter);
+	rc = dvb_create_media_graph(&client->adapter);
+	if (rc < 0) {
+		pr_err("dvb_create_media_graph failed %d\n", rc);
+		goto client_error;
+	}
 
 	pr_info("DVB interface registered.\n");
 	return 0;
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 5c51084a331a..df2fe4cc2d47 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -430,17 +430,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		return -ENOMEM;
 	}
 
-	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
-	if (ret) {
-		printk(KERN_ERR
-		      "%s: dvb_register_media_device failed to create the mediagraph\n",
-		      __func__);
-
-		dvb_media_device_free(dvbdev);
-		mutex_unlock(&dvbdev_register_lock);
-		return ret;
-	}
-
 	dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
 
 	if (!dvbdevfops){
@@ -493,6 +482,17 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
 		return PTR_ERR(clsdev);
 	}
+
+	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
+	if (ret) {
+		printk(KERN_ERR
+		      "%s: dvb_register_media_device failed to create the media graph\n",
+		      __func__);
+
+		dvb_unregister_device(dvbdev);
+		return ret;
+	}
+
 	dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
 		adap->num, dnames[type], id, minor, minor);
 
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 9e24aafeb9ea..bd9fac91c7b9 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -210,7 +210,7 @@ int dvb_register_device(struct dvb_adapter *adap,
 void dvb_unregister_device(struct dvb_device *dvbdev);
 
 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
-int dvb_create_media_graph(struct dvb_adapter *adap);
+__must_check int dvb_create_media_graph(struct dvb_adapter *adap);
 static inline void dvb_register_media_controller(struct dvb_adapter *adap,
 						 struct media_device *mdev)
 {
diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index c01772c4f9f0..cd542b49a6c2 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -486,12 +486,14 @@ static int dvb_register(struct au0828_dev *dev)
 	dvb->start_count = 0;
 	dvb->stop_count = 0;
 
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-	dvb_create_media_graph(&dvb->adapter);
-#endif
+	result = dvb_create_media_graph(&dvb->adapter);
+	if (result < 0)
+		goto fail_create_graph;
 
 	return 0;
 
+fail_create_graph:
+	dvb_net_release(&dvb->net);
 fail_fe_conn:
 	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
 fail_fe_mem:
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 66ee161fc7ba..aaf8ef246f13 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -551,10 +551,14 @@ static int register_dvb(struct cx231xx_dvb *dvb,
 
 	/* register network adapter */
 	dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
-	dvb_create_media_graph(&dvb->adapter);
+	result = dvb_create_media_graph(&dvb->adapter);
+	if (result < 0)
+		goto fail_create_graph;
 
 	return 0;
 
+fail_create_graph:
+	dvb_net_release(&dvb->net);
 fail_fe_conn:
 	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
 fail_fe_mem:
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index f5df9eaba04f..6d3f61f6dc77 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -698,7 +698,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
 		}
 	}
 
-	dvb_create_media_graph(&adap->dvb_adap);
+	ret = dvb_create_media_graph(&adap->dvb_adap);
+	if (ret < 0)
+		goto err_dvb_unregister_frontend;
 
 	return 0;
 
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
index 8a260c854653..b51dbdf03f42 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
@@ -318,10 +318,12 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
 
 		adap->num_frontends_initialized++;
 	}
+	if (ret)
+		return ret;
 
-	dvb_create_media_graph(&adap->dvb_adap);
+	ret = dvb_create_media_graph(&adap->dvb_adap);
 
-	return 0;
+	return ret;
 }
 
 int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
-- 
2.4.3



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

* [PATCH 09/18] [media] media-entity: enforce check of interface and links creation
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (7 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph() Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:23   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 10/18] [media] cx231xx: enforce check for graph creation Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab

Drivers should check if interfaces and interface links were
created. Add a must_check for them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 3d389f142a1d..62f882d872b1 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -370,14 +370,16 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
 					     struct media_pipeline *pipe);
 void media_entity_pipeline_stop(struct media_entity *entity);
 
-struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
-						u32 type, u32 flags,
-						u32 major, u32 minor,
-						gfp_t gfp_flags);
+struct media_intf_devnode *
+__must_check media_devnode_create(struct media_device *mdev,
+				  u32 type, u32 flags,
+				  u32 major, u32 minor,
+				  gfp_t gfp_flags);
 void media_devnode_remove(struct media_intf_devnode *devnode);
-struct media_link *media_create_intf_link(struct media_entity *entity,
-					    struct media_interface *intf,
-					    u32 flags);
+struct media_link *
+__must_check media_create_intf_link(struct media_entity *entity,
+				    struct media_interface *intf,
+				    u32 flags);
 void media_remove_intf_link(struct media_link *link);
 void __media_remove_intf_links(struct media_interface *intf);
 void media_remove_intf_links(struct media_interface *intf);
-- 
2.4.3



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

* [PATCH 10/18] [media] cx231xx: enforce check for graph creation
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (8 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 09/18] [media] media-entity: enforce check of interface and links creation Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:23   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 11/18] [media] au0828:: " Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Matthias Schwarzott, Antti Palosaari,
	Hans Verkuil, Olli Salonen, Tommi Rantala

If the graph creation fails, don't register the device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 1070d87efc65..c05aaef85491 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1185,8 +1185,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev)
 */
 void cx231xx_release_resources(struct cx231xx *dev)
 {
-	cx231xx_unregister_media_device(dev);
-
 	cx231xx_release_analog_resources(dev);
 
 	cx231xx_remove_from_devlist(dev);
@@ -1199,6 +1197,8 @@ void cx231xx_release_resources(struct cx231xx *dev)
 	/* delete v4l2 device */
 	v4l2_device_unregister(&dev->v4l2_dev);
 
+	cx231xx_unregister_media_device(dev);
+
 	usb_put_dev(dev->udev);
 
 	/* Mark device as unused */
@@ -1237,15 +1237,16 @@ static void cx231xx_media_device_register(struct cx231xx *dev,
 #endif
 }
 
-static void cx231xx_create_media_graph(struct cx231xx *dev)
+static int cx231xx_create_media_graph(struct cx231xx *dev)
 {
 #ifdef CONFIG_MEDIA_CONTROLLER
 	struct media_device *mdev = dev->media_dev;
 	struct media_entity *entity;
 	struct media_entity *tuner = NULL, *decoder = NULL;
+	int ret;
 
 	if (!mdev)
-		return;
+		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->type) {
@@ -1261,16 +1262,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
 	/* Analog setup, using tuner as a link */
 
 	if (!decoder)
-		return;
+		return 0;
 
-	if (tuner)
-		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
-					 MEDIA_LNK_FL_ENABLED);
-	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
-				 MEDIA_LNK_FL_ENABLED);
-	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
-				 MEDIA_LNK_FL_ENABLED);
+	if (tuner) {
+		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
+					    MEDIA_LNK_FL_ENABLED);
+		if (ret < 0)
+			return ret;
+	}
+	ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
+				    MEDIA_LNK_FL_ENABLED);
+	if (ret < 0)
+		return ret;
+	ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
+				    MEDIA_LNK_FL_ENABLED);
+	if (ret < 0)
+		return ret;
 #endif
+	return 0;
 }
 
 /*
@@ -1732,9 +1741,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
 	/* load other modules required */
 	request_modules(dev);
 
-	cx231xx_create_media_graph(dev);
+	retval = cx231xx_create_media_graph(dev);
+	if (retval < 0) {
+		cx231xx_release_resources(dev);
+	}
 
-	return 0;
+	return retval;
 err_video_alt:
 	/* cx231xx_uninit_dev: */
 	cx231xx_close_extension(dev);
-- 
2.4.3



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

* [PATCH 11/18] [media] au0828:: enforce check for graph creation
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (9 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 10/18] [media] cx231xx: enforce check for graph creation Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:23   ` Hans Verkuil
  2015-09-06 17:30 ` [PATCH 12/18] [media] media-entity: must check media_create_pad_link() Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab,
	Hans Verkuil, Shuah Khan

If the graph creation fails, don't register the device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 35c607c35155..399c6712faf9 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -172,9 +172,9 @@ static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
 	struct au0828_dev *dev =
 		container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
 
-	au0828_usb_v4l2_media_release(dev);
 	v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
 	v4l2_device_unregister(&dev->v4l2_dev);
+	au0828_usb_v4l2_media_release(dev);
 	au0828_usb_release(dev);
 }
 #endif
@@ -251,16 +251,16 @@ static void au0828_media_device_register(struct au0828_dev *dev,
 }
 
 
-static void au0828_create_media_graph(struct au0828_dev *dev)
+static int au0828_create_media_graph(struct au0828_dev *dev)
 {
 #ifdef CONFIG_MEDIA_CONTROLLER
 	struct media_device *mdev = dev->media_dev;
 	struct media_entity *entity;
 	struct media_entity *tuner = NULL, *decoder = NULL;
-	int i;
+	int i, ret;
 
 	if (!mdev)
-		return;
+		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->type) {
@@ -277,15 +277,23 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 
 	/* Something bad happened! */
 	if (!decoder)
-		return;
+		return -EINVAL;
 
-	if (tuner)
-		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
-				      MEDIA_LNK_FL_ENABLED);
-	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
-			      MEDIA_LNK_FL_ENABLED);
-	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
-			      MEDIA_LNK_FL_ENABLED);
+	if (tuner) {
+		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
+					    decoder, 0,
+				            MEDIA_LNK_FL_ENABLED);
+		if (ret)
+			return ret;
+	}
+	ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
+			 	    MEDIA_LNK_FL_ENABLED);
+	if (ret)
+		return ret;
+	ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
+				    MEDIA_LNK_FL_ENABLED);
+	if (ret)
+		return ret;
 
 	for (i = 0; i < AU0828_MAX_INPUT; i++) {
 		struct media_entity *ent = &dev->input_ent[i];
@@ -297,20 +305,27 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			if (tuner)
-				media_create_pad_link(ent, 0, tuner,
-						      TUNER_PAD_RF_INPUT,
-						      MEDIA_LNK_FL_ENABLED);
+			if (!tuner)
+				break;
+
+			ret = media_create_pad_link(ent, 0, tuner,
+						    TUNER_PAD_RF_INPUT,
+						    MEDIA_LNK_FL_ENABLED);
+			if (ret)
+				return ret;
 			break;
 		case AU0828_VMUX_COMPOSITE:
 		case AU0828_VMUX_SVIDEO:
 		default: /* AU0828_VMUX_DEBUG */
 			/* FIXME: fix the decoder PAD */
-			media_create_pad_link(ent, 0, decoder, 0, 0);
+			ret = media_create_pad_link(ent, 0, decoder, 0, 0);
+			if (ret)
+				return ret;
 			break;
 		}
 	}
 #endif
+	return 0;
 }
 
 static int au0828_usb_probe(struct usb_interface *interface,
@@ -425,7 +440,12 @@ static int au0828_usb_probe(struct usb_interface *interface,
 
 	mutex_unlock(&dev->lock);
 
-	au0828_create_media_graph(dev);
+	retval = au0828_create_media_graph(dev);
+	if (retval) {
+		pr_err("%s() au0282_dev_register failed to create graph\n",
+		       __func__);
+		au0828_usb_disconnect(interface);
+	}
 
 	return retval;
 }
-- 
2.4.3



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

* [PATCH 12/18] [media] media-entity: must check media_create_pad_link()
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (10 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 11/18] [media] au0828:: " Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-11 15:24   ` Hans Verkuil
  2015-11-23 17:54   ` Laurent Pinchart
  2015-09-06 17:30   ` Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  17 siblings, 2 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab

Drivers should check if media_create_pad_link() actually
worked.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 62f882d872b1..8bdc10dcc5e7 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -348,8 +348,9 @@ int media_entity_init(struct media_entity *entity, u16 num_pads,
 		      struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
-int media_create_pad_link(struct media_entity *source, u16 source_pad,
-		struct media_entity *sink, u16 sink_pad, u32 flags);
+__must_check int media_create_pad_link(struct media_entity *source,
+			u16 source_pad,	struct media_entity *sink,
+			u16 sink_pad, u32 flags);
 void __media_entity_remove_links(struct media_entity *entity);
 void media_entity_remove_links(struct media_entity *entity);
 
-- 
2.4.3



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

* [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, Sakari Ailus,
	Laurent Pinchart, Kyungmin Park, Heungjun Kim, Lad, Prabhakar,
	Andrzej Hajda, Hyun Kwon, Michal Simek, Sören Brinkmann,
	Hans Verkuil, Krzysztof Kozlowski,
	Rafael Lourenço de Lima Chehab, Boris BREZILLON,
	Joe Perches, Sylwester Nawrocki, Shuah Khan, Markus Elfring,
	Matthias Schwarzott, Antti Palosaari, Olli Salonen,
	Tommi Rantala, Jacek Anaszewski, Bryan Wu, Lars-Peter Clausen,
	linux-doc, linux-arm-kernel

Entities should have one or more functions. Calling it as a
type proofed to not be correct, as an entity could eventually
have more than one type.

So, rename the field as function.

Please notice that this patch doesn't extend support for
multiple function entities. Such change will happen when
we have real case drivers using it.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 109cc3792534..2e0fc28fa12f 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -303,8 +303,8 @@ calling media_entity_init():
 	err = media_entity_init(&sd->entity, npads, pads);
 
 The pads array must have been previously initialized. There is no need to
-manually set the struct media_entity type and name fields, but the revision
-field must be initialized if needed.
+manually set the struct media_entity function and name fields, but the
+revision field must be initialized if needed.
 
 A reference to the entity will be automatically acquired/released when the
 subdev device node (if any) is opened/closed.
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index df2fe4cc2d47..e925909bc99e 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return ret;
 
-		entity->type = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_T_DVB_TSOUT;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -537,7 +537,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
@@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 55cd42a584a5..a6fbe78a70e3 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 5f76997f6e07..2b8f72ac0f7d 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index 9d579a836f79..a49ef7d6df18 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 270135d06b32..d48a3a4df96b 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 9bd9def0852c..7c1abdca39d0 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index 4160e18af607..d609f2fa8e6c 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index f718a1009e4c..206319b88d7a 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index a9761251b970..6cd407bcfddf 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 6bce9832ab7b..c085dec69201 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 8a8eb593fc23..2862244a6488 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index abae37321c0c..3f55168cce47 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index d207ddce31b6..45f6e6f2585a 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 0513196bd48c..22dfeadf7672 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 39a461f9d9bb..71162c02d6d7 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 5aa49eb393a9..bb1f891a1eb6 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 97eb97d9b662..ccef9621d147 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -108,7 +108,7 @@ static long media_device_enum_entities(struct media_device *mdev,
 	u_ent.id = media_entity_id(ent);
 	if (ent->name)
 		strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
-	u_ent.type = ent->type;
+	u_ent.type = ent->function;
 	u_ent.revision = ent->revision;
 	u_ent.flags = ent->flags;
 	u_ent.group_id = ent->group_id;
@@ -614,8 +614,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->type == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_T_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8e14841bf445..8bee7313a497 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->type != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 399c6712faf9..44a2ab3c85ab 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -263,7 +263,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 806b8d320bae..5c01f37cd0b8 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch(AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->type = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_T_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->type = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_T_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index c05aaef85491..b01d6bce3cf6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1249,7 +1249,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index e8baff4d6290..ed4a49c850c7 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index b90f2a52db96..e8fc5ec8fc35 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 8429da66754a..2446b2d8fe66 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.type = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 34c489fed55e..cf7b3cb9a373 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b3bcc8253182..b440cb66669c 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,9 +535,9 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
-	     pad->entity->type, pad->entity->name);
+	     pad->entity->function, pad->entity->name);
 
 	return -EINVAL;
 }
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 8bdc10dcc5e7..10f7d5f0eb66 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -152,7 +152,8 @@ struct media_entity_operations {
  *
  * @graph_obj:	Embedded structure containing the media object common data.
  * @name:	Entity name.
- * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
+ * @function:	Entity main function, as defined at uapi/media.h
+ *		(MEDIA_ENT_F_*)
  * @revision:	Entity revision - OBSOLETE - should be removed soon.
  * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
  * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
@@ -179,7 +180,7 @@ struct media_entity_operations {
 struct media_entity {
 	struct media_gobj graph_obj;	/* must be first field in struct */
 	const char *name;
-	u32 type;
+	u32 function;
 	u32 revision;
 	unsigned long flags;
 	u32 group_id;
@@ -277,7 +278,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 	if (!entity)
 		return false;
 
-	switch (entity->type) {
+	switch (entity->function) {
 	case MEDIA_ENT_T_V4L2_VIDEO:
 	case MEDIA_ENT_T_V4L2_VBI:
 	case MEDIA_ENT_T_V4L2_SWRADIO:
@@ -292,7 +293,7 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 	if (!entity)
 		return false;
 
-	switch (entity->type) {
+	switch (entity->function) {
 	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
 	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
 	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-- 
2.4.3



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

* [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: linux-arm-kernel

Entities should have one or more functions. Calling it as a
type proofed to not be correct, as an entity could eventually
have more than one type.

So, rename the field as function.

Please notice that this patch doesn't extend support for
multiple function entities. Such change will happen when
we have real case drivers using it.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 109cc3792534..2e0fc28fa12f 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -303,8 +303,8 @@ calling media_entity_init():
 	err = media_entity_init(&sd->entity, npads, pads);
 
 The pads array must have been previously initialized. There is no need to
-manually set the struct media_entity type and name fields, but the revision
-field must be initialized if needed.
+manually set the struct media_entity function and name fields, but the
+revision field must be initialized if needed.
 
 A reference to the entity will be automatically acquired/released when the
 subdev device node (if any) is opened/closed.
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index df2fe4cc2d47..e925909bc99e 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return ret;
 
-		entity->type = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_T_DVB_TSOUT;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->type = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -537,7 +537,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
@@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index 55cd42a584a5..a6fbe78a70e3 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 5f76997f6e07..2b8f72ac0f7d 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index 9d579a836f79..a49ef7d6df18 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 270135d06b32..d48a3a4df96b 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 9bd9def0852c..7c1abdca39d0 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index 4160e18af607..d609f2fa8e6c 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index f718a1009e4c..206319b88d7a 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index a9761251b970..6cd407bcfddf 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 6bce9832ab7b..c085dec69201 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 8a8eb593fc23..2862244a6488 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index abae37321c0c..3f55168cce47 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index d207ddce31b6..45f6e6f2585a 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 0513196bd48c..22dfeadf7672 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 39a461f9d9bb..71162c02d6d7 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 5aa49eb393a9..bb1f891a1eb6 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 97eb97d9b662..ccef9621d147 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -108,7 +108,7 @@ static long media_device_enum_entities(struct media_device *mdev,
 	u_ent.id = media_entity_id(ent);
 	if (ent->name)
 		strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
-	u_ent.type = ent->type;
+	u_ent.type = ent->function;
 	u_ent.revision = ent->revision;
 	u_ent.flags = ent->flags;
 	u_ent.group_id = ent->group_id;
@@ -614,8 +614,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->type == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_T_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8e14841bf445..8bee7313a497 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->type != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 399c6712faf9..44a2ab3c85ab 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -263,7 +263,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 806b8d320bae..5c01f37cd0b8 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch(AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->type = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_T_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->type = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_T_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index c05aaef85491..b01d6bce3cf6 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1249,7 +1249,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 		return 0;
 
 	media_device_for_each_entity(entity, mdev) {
-		switch (entity->type) {
+		switch (entity->function) {
 		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
 			tuner = entity;
 			break;
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index e8baff4d6290..ed4a49c850c7 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index b90f2a52db96..e8fc5ec8fc35 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 8429da66754a..2446b2d8fe66 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.type = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 34c489fed55e..cf7b3cb9a373 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b3bcc8253182..b440cb66669c 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,9 +535,9 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
-	     pad->entity->type, pad->entity->name);
+	     pad->entity->function, pad->entity->name);
 
 	return -EINVAL;
 }
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 8bdc10dcc5e7..10f7d5f0eb66 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -152,7 +152,8 @@ struct media_entity_operations {
  *
  * @graph_obj:	Embedded structure containing the media object common data.
  * @name:	Entity name.
- * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
+ * @function:	Entity main function, as defined at uapi/media.h
+ *		(MEDIA_ENT_F_*)
  * @revision:	Entity revision - OBSOLETE - should be removed soon.
  * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
  * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
@@ -179,7 +180,7 @@ struct media_entity_operations {
 struct media_entity {
 	struct media_gobj graph_obj;	/* must be first field in struct */
 	const char *name;
-	u32 type;
+	u32 function;
 	u32 revision;
 	unsigned long flags;
 	u32 group_id;
@@ -277,7 +278,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 	if (!entity)
 		return false;
 
-	switch (entity->type) {
+	switch (entity->function) {
 	case MEDIA_ENT_T_V4L2_VIDEO:
 	case MEDIA_ENT_T_V4L2_VBI:
 	case MEDIA_ENT_T_V4L2_SWRADIO:
@@ -292,7 +293,7 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 	if (!entity)
 		return false;
 
-	switch (entity->type) {
+	switch (entity->function) {
 	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
 	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
 	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-- 
2.4.3

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

* [PATCH 14/18] [media] media-device: export the entity function via new ioctl
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, linux-api

Now that entities have a main function, expose it via
MEDIA_IOC_G_TOPOLOGY ioctl.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index ccef9621d147..32090030c342 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -263,6 +263,7 @@ static long __media_device_get_topology(struct media_device *mdev,
 		/* Copy fields to userspace struct if not error */
 		memset(&uentity, 0, sizeof(uentity));
 		uentity.id = entity->graph_obj.id;
+		uentity.function = entity->function;
 		strncpy(uentity.name, entity->name,
 			sizeof(uentity.name));
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 69433405aec2..d232cc680c67 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -284,7 +284,8 @@ struct media_links_enum {
 struct media_v2_entity {
 	__u32 id;
 	char name[64];		/* FIXME: move to a property? (RFC says so) */
-	__u16 reserved[14];
+	__u32 function;		/* Main function of the entity */
+	__u16 reserved[12];
 };
 
 /* Should match the specific fields at media_intf_devnode */
-- 
2.4.3



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

* [PATCH 14/18] [media] media-device: export the entity function via new ioctl
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, linux-api-u79uwXL29TY76Z2rM5mHXA

Now that entities have a main function, expose it via
MEDIA_IOC_G_TOPOLOGY ioctl.

Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index ccef9621d147..32090030c342 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -263,6 +263,7 @@ static long __media_device_get_topology(struct media_device *mdev,
 		/* Copy fields to userspace struct if not error */
 		memset(&uentity, 0, sizeof(uentity));
 		uentity.id = entity->graph_obj.id;
+		uentity.function = entity->function;
 		strncpy(uentity.name, entity->name,
 			sizeof(uentity.name));
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 69433405aec2..d232cc680c67 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -284,7 +284,8 @@ struct media_links_enum {
 struct media_v2_entity {
 	__u32 id;
 	char name[64];		/* FIXME: move to a property? (RFC says so) */
-	__u16 reserved[14];
+	__u32 function;		/* Main function of the entity */
+	__u16 reserved[12];
 };
 
 /* Should match the specific fields at media_intf_devnode */
-- 
2.4.3

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

* [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Sakari Ailus, Lars-Peter Clausen,
	Laurent Pinchart, Kyungmin Park, Heungjun Kim, Lad, Prabhakar,
	Andrzej Hajda, Hyun Kwon, Michal Simek, Sören Brinkmann,
	Hans Verkuil, Rafael Lourenço de Lima Chehab,
	Krzysztof Kozlowski, Boris BREZILLON, Joe Perches,
	Sylwester Nawrocki, Ricardo Ribalda Delgado,
	Guennadi Liakhovetski, Axel Lin, Shuah Khan, Julia Lawall,
	Markus Elfring, Matthias Schwarzott, Antti Palosaari,
	Olli Salonen, Tommi Rantala, Scott Jiang, Bryan Wu,
	Jacek Anaszewski, linux-arm-kernel, linux-api

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_V4L2_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_V4L2_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_MPEG_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_DTV_TSOUT
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index e925909bc99e..8527fc40e6a0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return ret;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_MPEG_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -538,16 +538,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_MPEG_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 2b8f72ac0f7d..0ce7a8426d59 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index bab91a1e1525..af888f6c1de0 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index a49ef7d6df18..c5462fd9c0fb 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index d48a3a4df96b..479b3efc3f3d 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 7c1abdca39d0..8c7b4a2d465e 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index d609f2fa8e6c..71344c6596a3 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 206319b88d7a..08dad1140a07 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 6cd407bcfddf..aff081324d76 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index c085dec69201..e49254f4341d 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 2862244a6488..b133464f3b73 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 3f55168cce47..456899fe9cb0 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	oif_sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 45f6e6f2585a..c5001d5ab4ca 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 22dfeadf7672..3a10e50b3620 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 71162c02d6d7..95c1951bc9df 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index bb1f891a1eb6..2911ac2746c1 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11801636d901..fad7fcb49e9c 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 3630f3e2a4c7..765781ae8613 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 32090030c342..13987710e5bc 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -615,8 +615,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8bee7313a497..bc244a0049bd 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 44a2ab3c85ab..1c12285428fe 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -264,10 +264,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 5c01f37cd0b8..f041433f2334 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch(AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index b01d6bce3cf6..022b30099a89 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index ed4a49c850c7..7e67b1096012 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 2446b2d8fe66..430aa2330d07 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d70aedc75998 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 10f7d5f0eb66..9cbb10079024 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -279,9 +279,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO:
 		return true;
 	default:
 		return false;
@@ -294,11 +292,11 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index d232cc680c67..90e90a6e62bf 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,86 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are spased just to
+ * make easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
-
-	/*
-	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
-	 * in order to preserve backward compatibility.
-	 * Drivers should change to the proper subdev type before
-	 * registering the entity.
-	 */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
+/*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
 	/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
+ * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
+ * in order to preserve backward compatibility.
+ * Drivers should change to the proper subdev type before
+ * registering the entity.
+ */
+
+#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */
-- 
2.4.3



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

* [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Sakari Ailus, Lars-Peter Clausen,
	Laurent Pinchart, Kyungmin Park, Heungjun Kim, Lad, Prabhakar,
	Andrzej Hajda, Hyun Kwon, Michal Simek, Sören Brinkmann,
	Hans Verkuil, Rafael Lourenço de Lima Chehab,
	Krzysztof Kozlowski, Boris BREZILLON, Joe Perches,
	Sylwester Nawrocki, Ricardo Ribalda Delgado,
	Guennadi Liakhovetski

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_V4L2_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_V4L2_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_MPEG_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_DTV_TSOUT
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index e925909bc99e..8527fc40e6a0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return ret;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_MPEG_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -538,16 +538,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_MPEG_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 2b8f72ac0f7d..0ce7a8426d59 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index bab91a1e1525..af888f6c1de0 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index a49ef7d6df18..c5462fd9c0fb 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index d48a3a4df96b..479b3efc3f3d 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 7c1abdca39d0..8c7b4a2d465e 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index d609f2fa8e6c..71344c6596a3 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 206319b88d7a..08dad1140a07 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 6cd407bcfddf..aff081324d76 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index c085dec69201..e49254f4341d 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 2862244a6488..b133464f3b73 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 3f55168cce47..456899fe9cb0 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	oif_sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 45f6e6f2585a..c5001d5ab4ca 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 22dfeadf7672..3a10e50b3620 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 71162c02d6d7..95c1951bc9df 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index bb1f891a1eb6..2911ac2746c1 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11801636d901..fad7fcb49e9c 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 3630f3e2a4c7..765781ae8613 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 32090030c342..13987710e5bc 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -615,8 +615,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8bee7313a497..bc244a0049bd 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 44a2ab3c85ab..1c12285428fe 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -264,10 +264,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 5c01f37cd0b8..f041433f2334 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch(AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index b01d6bce3cf6..022b30099a89 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index ed4a49c850c7..7e67b1096012 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 2446b2d8fe66..430aa2330d07 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d70aedc75998 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 10f7d5f0eb66..9cbb10079024 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -279,9 +279,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO:
 		return true;
 	default:
 		return false;
@@ -294,11 +292,11 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index d232cc680c67..90e90a6e62bf 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,86 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are spased just to
+ * make easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
-
-	/*
-	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
-	 * in order to preserve backward compatibility.
-	 * Drivers should change to the proper subdev type before
-	 * registering the entity.
-	 */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
+/*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
 	/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
+ * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
+ * in order to preserve backward compatibility.
+ * Drivers should change to the proper subdev type before
+ * registering the entity.
+ */
+
+#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */
-- 
2.4.3

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

* [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-06 17:30   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: linux-arm-kernel

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_V4L2_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_V4L2_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_MPEG_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_DTV_TSOUT
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index e925909bc99e..8527fc40e6a0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return ret;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_MPEG_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -538,16 +538,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_MPEG_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 2b8f72ac0f7d..0ce7a8426d59 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index bab91a1e1525..af888f6c1de0 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index a49ef7d6df18..c5462fd9c0fb 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index d48a3a4df96b..479b3efc3f3d 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 7c1abdca39d0..8c7b4a2d465e 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index d609f2fa8e6c..71344c6596a3 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 206319b88d7a..08dad1140a07 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 6cd407bcfddf..aff081324d76 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index c085dec69201..e49254f4341d 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 2862244a6488..b133464f3b73 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 3f55168cce47..456899fe9cb0 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	oif_sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 45f6e6f2585a..c5001d5ab4ca 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 22dfeadf7672..3a10e50b3620 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index 71162c02d6d7..95c1951bc9df 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index bb1f891a1eb6..2911ac2746c1 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11801636d901..fad7fcb49e9c 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 3630f3e2a4c7..765781ae8613 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 32090030c342..13987710e5bc 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -615,8 +615,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 8bee7313a497..bc244a0049bd 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 44a2ab3c85ab..1c12285428fe 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -264,10 +264,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 5c01f37cd0b8..f041433f2334 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch(AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index b01d6bce3cf6..022b30099a89 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index ed4a49c850c7..7e67b1096012 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 2446b2d8fe66..430aa2330d07 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d70aedc75998 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 10f7d5f0eb66..9cbb10079024 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -279,9 +279,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO:
 		return true;
 	default:
 		return false;
@@ -294,11 +292,11 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index d232cc680c67..90e90a6e62bf 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,86 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are spased just to
+ * make easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
-
-	/*
-	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
-	 * in order to preserve backward compatibility.
-	 * Drivers should change to the proper subdev type before
-	 * registering the entity.
-	 */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
+/*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
 	/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
+ * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
+ * in order to preserve backward compatibility.
+ * Drivers should change to the proper subdev type before
+ * registering the entity.
+ */
+
+#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */
-- 
2.4.3

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

* [PATCH 16/18] [media] DocBook: update entities documentation
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (14 preceding siblings ...)
  2015-09-06 17:30   ` Mauro Carvalho Chehab
@ 2015-09-06 17:30 ` Mauro Carvalho Chehab
  2015-09-06 17:31 ` [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Mauro Carvalho Chehab
  2015-09-06 17:31 ` [PATCH 18/18] [media] dvbdev: Don't create indirect links Mauro Carvalho Chehab
  17 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:30 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, Hans Verkuil, linux-doc

Due to the rename, the documentation became outdated.

Update it to reflect what's there at media.h.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
index bc101516e372..f9bfe8094d6d 100644
--- a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
+++ b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml
@@ -179,54 +179,60 @@
         <colspec colname="c2"/>
 	<tbody valign="top">
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_UNKNOWN</constant> and <constant>MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN</constant></entry>
+	    <entry><constant>MEDIA_ENT_F_UNKNOWN</constant> and <constant>MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN</constant></entry>
 	    <entry>Unknown entity. That generally indicates that
 	    a driver didn't initialize properly the entity, with is a Kernel bug</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry>
-	    <entry>V4L video streaming input or output entity</entry>
+	    <entry><constant>MEDIA_ENT_F_IO</constant></entry>
+	    <entry>Data streaming input and/or output entity.</entry>
 	  </row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_VBI</constant></entry>
-	    <entry>V4L VBI streaming input or output entity</entry>
+	  <row>
+	    <entry><constant>MEDIA_ENT_F_DTV_DEMOD</constant></entry>
+	    <entry>Digital TV demodulator entity.</entry>
+	  </row>
+	  <row>
+	    <entry><constant>MEDIA_ENT_F_MPEG_TS_DEMUX</constant></entry>
+	    <entry>MPEG Transport stream demux entity. Could be implemented on hardware or in Kernelspace by the Linux DVB subsystem.</entry>
 	  </row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SWRADIO</constant></entry>
-	    <entry>V4L Sofware Digital Radio (SDR) streaming input or output entity</entry>
+	  <row>
+	    <entry><constant>MEDIA_ENT_F_DTV_CA</constant></entry>
+	    <entry>Digital TV Conditional Access module (CAM) entity</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_DVB_DEMOD</constant></entry>
-	    <entry>DVB demodulator entity</entry>
+	    <entry><constant>MEDIA_ENT_F_DTV_NET_DECAP</constant></entry>
+	    <entry>Digital TV network ULE/MLE desencapsulation entity. Could be implemented on hardware or in Kernelspace</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_DVB_DEMUX</constant></entry>
-	    <entry>DVB demux entity. Could be implemented on hardware or in Kernelspace</entry>
+	    <entry><constant>MEDIA_ENT_F_CONN_RF</constant></entry>
+	    <entry>Connector for a Radio Frequency (RF) signal.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_DVB_TSOUT</constant></entry>
-	    <entry>DVB Transport Stream output entity</entry>
+	    <entry><constant>MEDIA_ENT_F_CONN_SVIDEO</constant></entry>
+	    <entry>Connector for a S-Video signal.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_DVB_CA</constant></entry>
-	    <entry>DVB Conditional Access module (CAM) entity</entry>
+	    <entry><constant>MEDIA_ENT_F_CONN_COMPOSITE</constant></entry>
+	    <entry>Connector for a RGB composite signal.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_DVB_DEMOD_NET_DECAP</constant></entry>
-	    <entry>DVB network ULE/MLE desencapsulation entity. Could be implemented on hardware or in Kernelspace</entry>
+	    <entry><constant>MEDIA_ENT_F_CONN_TEST</constant></entry>
+	    <entry>Connector for a test generator.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_SENSOR</constant></entry>
-	    <entry>Camera video sensor entity</entry>
+	    <entry><constant>MEDIA_ENT_F_CAM_SENSOR</constant></entry>
+	    <entry>Camera video sensor entity.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_FLASH</constant></entry>
-	    <entry>Flash controller entity</entry>
+	    <entry><constant>MEDIA_ENT_F_FLASH</constant></entry>
+	    <entry>Flash controller entity.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_LENS</constant></entry>
-	    <entry>Lens controller entity</entry>
+	    <entry><constant>MEDIA_ENT_F_LENS</constant></entry>
+	    <entry>Lens controller entity.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_DECODER</constant></entry>
+	    <entry><constant>MEDIA_ENT_F_ATV_DECODER</constant></entry>
 	    <entry>Analog video decoder, the basic function of the video decoder
 	    is to accept analogue video from a wide variety of sources such as
 	    broadcast, DVD players, cameras and video cassette recorders, in
@@ -236,8 +242,8 @@
 	    signals.</entry>
 	  </row>
 	  <row>
-	    <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_TUNER</constant></entry>
-	    <entry>Digital TV, analog TV, radio and/or software radio tuner</entry>
+	    <entry><constant>MEDIA_ENT_F_TUNER</constant></entry>
+	    <entry>Digital TV, analog TV, radio and/or software radio tuner.</entry>
 	  </row>
 	</tbody>
       </tgroup>
-- 
2.4.3



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

* [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (15 preceding siblings ...)
  2015-09-06 17:30 ` [PATCH 16/18] [media] DocBook: update entities documentation Mauro Carvalho Chehab
@ 2015-09-06 17:31 ` Mauro Carvalho Chehab
  2015-09-11 15:38   ` Hans Verkuil
  2015-09-06 17:31 ` [PATCH 18/18] [media] dvbdev: Don't create indirect links Mauro Carvalho Chehab
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:31 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Hans Verkuil

Cleanup the code a little bit by moving the routine that creates
links between DVR and demux to the I/O entitis into a separate
function.

While here, fix the code to use strncmp() instead of strcmp().

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 8527fc40e6a0..ea76fe54e0e4 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -522,6 +522,28 @@ EXPORT_SYMBOL(dvb_unregister_device);
 
 
 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
+
+static int dvb_create_io_intf_links(struct dvb_adapter *adap,
+				    struct media_interface *intf,
+				    char *name)
+{
+	struct media_device *mdev = adap->mdev;
+	struct media_entity *entity;
+	struct media_link *link;
+
+	media_device_for_each_entity(entity, mdev) {
+		if (entity->function == MEDIA_ENT_F_IO) {
+			if (strncmp(entity->name, name, strlen(name)))
+				continue;
+			link = media_create_intf_link(entity, intf,
+						      MEDIA_LNK_FL_ENABLED);
+			if (!link)
+				return -ENOMEM;
+		}
+	}
+	return 0;
+}
+
 int dvb_create_media_graph(struct dvb_adapter *adap)
 {
 	struct media_device *mdev = adap->mdev;
@@ -619,25 +641,15 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 			if (!link)
 				return -ENOMEM;
 		}
-
-		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_F_IO) {
-				if (!strcmp(entity->name, DVR_TSOUT)) {
-					link = media_create_intf_link(entity,
-							intf,
-							MEDIA_LNK_FL_ENABLED);
-					if (!link)
-						return -ENOMEM;
-				}
-				if (!strcmp(entity->name, DEMUX_TSOUT)) {
-					link = media_create_intf_link(entity,
-							intf,
-							MEDIA_LNK_FL_ENABLED);
-					if (!link)
-						return -ENOMEM;
-				}
-				break;
-			}
+		if (intf->type == MEDIA_INTF_T_DVB_DVR) {
+			ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT);
+			if (ret)
+				return ret;
+		}
+		if (intf->type == MEDIA_INTF_T_DVB_DEMUX) {
+			ret = dvb_create_io_intf_links(adap, intf, DEMUX_TSOUT);
+			if (ret)
+				return ret;
 		}
 	}
 	return 0;
-- 
2.4.3



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

* [PATCH 18/18] [media] dvbdev: Don't create indirect links
  2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
                   ` (16 preceding siblings ...)
  2015-09-06 17:31 ` [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Mauro Carvalho Chehab
@ 2015-09-06 17:31 ` Mauro Carvalho Chehab
  2015-09-11 15:48   ` Hans Verkuil
  17 siblings, 1 reply; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-09-06 17:31 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Hans Verkuil

Indirect links are those whose the interface indirectly controls
other functions.

There are two interfaces that have indirect controls at the DVB
side:
- the network interface, with also controls the demux;
- the DVR interface with also controls the demux.

One could argue that the frontend control to the tuner is indirect.
Well, that's debateable. There's no way to create subdef interfaces
for tuner and demod, as those devices are tightly coupled. So, it
was decided that just one interface is the best to control both
entities, and there's no plan (or easy way) to decouple both. So,
the DVB frontend interface should link to both entities.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index ea76fe54e0e4..e9f24c1479dd 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -619,7 +619,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 	}
 
-	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
+	/* Create interface links for FE->tuner, DVR->demux and CA->ca */
 	media_device_for_each_intf(intf, mdev) {
 		if (intf->type == MEDIA_INTF_T_DVB_CA && ca) {
 			link = media_create_intf_link(ca, intf,
@@ -634,13 +634,19 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 			if (!link)
 				return -ENOMEM;
 		}
-
+#if 0
+		/*
+		 * Indirect link - let's not create yet, as we don't know how
+		 *		   to handle indirect links, nor if this will
+		 *		   actually be needed.
+		 */
 		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) {
 			link = media_create_intf_link(demux, intf,
 						      MEDIA_LNK_FL_ENABLED);
 			if (!link)
 				return -ENOMEM;
 		}
+#endif
 		if (intf->type == MEDIA_INTF_T_DVB_DVR) {
 			ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT);
 			if (ret)
-- 
2.4.3



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

* Re: [PATCH 01/18] [media] tuner-core: add an input pad
  2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
@ 2015-09-11 14:48   ` Hans Verkuil
  2015-11-23 20:01   ` Laurent Pinchart
  1 sibling, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 14:48 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Hans Verkuil, Rafael Lourenço de Lima Chehab, Shuah Khan,
	Matthias Schwarzott, Antti Palosaari, Olli Salonen,
	Tommi Rantala, Lad, Prabhakar, Sakari Ailus, Laurent Pinchart,
	Krzysztof Kozlowski

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Tuners actually have at least one connector on its
> input.
> 
> Add a PAD to connect it.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

And yes, I do think tuner.h is the best place for the pad info.

Regards,

	Hans

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index f00f1a5f279c..a8e7e2398f7a 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -34,6 +34,9 @@
>  #include <linux/mutex.h>
>  #include "dvbdev.h"
>  
> +/* Due to enum tuner_pad_index */
> +#include <media/tuner.h>
> +
>  static DEFINE_MUTEX(dvbdev_mutex);
>  static int dvbdev_debug;
>  
> @@ -552,7 +555,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
>  	}
>  
>  	if (tuner && demod)
> -		media_create_pad_link(tuner, 0, demod, 0, 0);
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
>  
>  	if (demod && demux)
>  		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index e28cabe65934..f54c7d10f350 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -27,6 +27,9 @@
>  #include <media/v4l2-common.h>
>  #include <linux/mutex.h>
>  
> +/* Due to enum tuner_pad_index */
> +#include <media/tuner.h>
> +
>  /*
>   * 1 = General debug messages
>   * 2 = USB handling
> @@ -260,7 +263,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
>  		return;
>  
>  	if (tuner)
> -		media_create_pad_link(tuner, 0, decoder, 0,
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
>  				      MEDIA_LNK_FL_ENABLED);
>  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
>  			      MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index 3b5c9ae39ad3..1070d87efc65 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1264,7 +1264,7 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
>  		return;
>  
>  	if (tuner)
> -		media_create_pad_link(tuner, 0, decoder, 0,
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
>  					 MEDIA_LNK_FL_ENABLED);
>  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
>  				 MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> index 100b8f069640..b90f2a52db96 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -134,8 +134,9 @@ struct tuner {
>  	unsigned int        type; /* chip type id */
>  	void                *config;
>  	const char          *name;
> +
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> -	struct media_pad	pad;
> +	struct media_pad	pad[TUNER_NUM_PADS];
>  #endif
>  };
>  
> @@ -695,11 +696,12 @@ static int tuner_probe(struct i2c_client *client,
>  	/* Should be just before return */
>  register_client:
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> -	t->pad.flags = MEDIA_PAD_FL_SOURCE;
> +	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
> +	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
>  	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
>  	t->sd.entity.name = t->name;
>  
> -	ret = media_entity_init(&t->sd.entity, 1, &t->pad);
> +	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
>  	if (ret < 0) {
>  		tuner_err("failed to initialize media entity!\n");
>  		kfree(t);
> diff --git a/include/media/tuner.h b/include/media/tuner.h
> index b46ebb48fe74..95835c8069dd 100644
> --- a/include/media/tuner.h
> +++ b/include/media/tuner.h
> @@ -25,6 +25,14 @@
>  
>  #include <linux/videodev2.h>
>  
> +/* Tuner PADs */
> +/* FIXME: is this the right place for it? */
> +enum tuner_pad_index {
> +	TUNER_PAD_RF_INPUT,
> +	TUNER_PAD_IF_OUTPUT,
> +	TUNER_NUM_PADS
> +};
> +
>  #define ADDR_UNSET (255)
>  
>  #define TUNER_TEMIC_PAL			0        /* 4002 FH5 (3X 7756, 9483) */
> 


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

* Re: [PATCH 02/18] [media] au0828: add support for the connectors
  2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
@ 2015-09-11 14:57   ` Hans Verkuil
  2015-12-10 18:24     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 14:57 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Rafael Lourenço de Lima Chehab, Hans Verkuil, Shuah Khan,
	Lad, Prabhakar, Julia Lawall

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Depending on the input, an au0828 may have a different
> number of connectors. add entities to represent them.

Hmm, this patch uses the new connector defines that are only added in patch 6!
So this doesn't compile.

Is there a reason why the connector support is needed now? I would prefer to have
this in a separate follow-up patch series.

Regards,

	Hans

> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index f54c7d10f350..fe9a60484343 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -153,11 +153,26 @@ static void au0828_usb_release(struct au0828_dev *dev)
>  }
>  
>  #ifdef CONFIG_VIDEO_AU0828_V4L2
> +
> +static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
> +{
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +	int i;
> +
> +	for (i = 0; i < AU0828_MAX_INPUT; i++) {
> +		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
> +			return;
> +		media_device_unregister_entity(&dev->input_ent[i]);
> +	}
> +#endif
> +}
> +
>  static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
>  {
>  	struct au0828_dev *dev =
>  		container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
>  
> +	au0828_usb_v4l2_media_release(dev);
>  	v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
>  	v4l2_device_unregister(&dev->v4l2_dev);
>  	au0828_usb_release(dev);
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 4511e2893282..806b8d320bae 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -1793,6 +1793,69 @@ static int au0828_vb2_setup(struct au0828_dev *dev)
>  	return 0;
>  }
>  
> +static void au0828_analog_create_entities(struct au0828_dev *dev)
> +{
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	static const char *inames[] = {
> +		[AU0828_VMUX_COMPOSITE] = "Composite",
> +		[AU0828_VMUX_SVIDEO] = "S-Video",
> +		[AU0828_VMUX_CABLE] = "Cable TV",
> +		[AU0828_VMUX_TELEVISION] = "Television",
> +		[AU0828_VMUX_DVB] = "DVB",
> +		[AU0828_VMUX_DEBUG] = "tv debug"
> +	};
> +	int ret, i;
> +
> +	/* Initialize Video and VBI pads */
> +	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
> +	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
> +	if (ret < 0)
> +		pr_err("failed to initialize video media entity!\n");
> +
> +	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
> +	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
> +	if (ret < 0)
> +		pr_err("failed to initialize vbi media entity!\n");
> +
> +	/* Create entities for each input connector */
> +	for (i = 0; i < AU0828_MAX_INPUT; i++) {
> +		struct media_entity *ent = &dev->input_ent[i];
> +
> +		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
> +			break;
> +
> +		ent->name = inames[AUVI_INPUT(i).type];
> +		ent->flags = MEDIA_ENT_FL_CONNECTOR;
> +		dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
> +
> +		switch(AUVI_INPUT(i).type) {
> +		case AU0828_VMUX_COMPOSITE:
> +			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
> +			break;
> +		case AU0828_VMUX_SVIDEO:
> +			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
> +			break;
> +		case AU0828_VMUX_CABLE:
> +		case AU0828_VMUX_TELEVISION:
> +		case AU0828_VMUX_DVB:
> +			ent->type = MEDIA_ENT_T_CONN_RF;
> +			break;
> +		default: /* AU0828_VMUX_DEBUG */
> +			ent->type = MEDIA_ENT_T_CONN_TEST;
> +			break;
> +		}
> +
> +		ret = media_entity_init(ent, 1, &dev->input_pad[i]);
> +		if (ret < 0)
> +			pr_err("failed to initialize input pad[%d]!\n", i);
> +
> +		ret = media_device_register_entity(dev->media_dev, ent);
> +		if (ret < 0)
> +			pr_err("failed to register input entity %d!\n", i);
> +	}
> +#endif
> +}
> +
>  /**************************************************************************/
>  
>  int au0828_analog_register(struct au0828_dev *dev,
> @@ -1881,17 +1944,8 @@ int au0828_analog_register(struct au0828_dev *dev,
>  	dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock;
>  	strcpy(dev->vbi_dev.name, "au0828a vbi");
>  
> -#if defined(CONFIG_MEDIA_CONTROLLER)
> -	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
> -	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
> -	if (ret < 0)
> -		pr_err("failed to initialize video media entity!\n");
> -
> -	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
> -	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
> -	if (ret < 0)
> -		pr_err("failed to initialize vbi media entity!\n");
> -#endif
> +	/* Init entities at the Media Controller */
> +	au0828_analog_create_entities(dev);
>  
>  	/* initialize videobuf2 stuff */
>  	retval = au0828_vb2_setup(dev);
> diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
> index d3644b3fe6fa..b7940c54d006 100644
> --- a/drivers/media/usb/au0828/au0828.h
> +++ b/drivers/media/usb/au0828/au0828.h
> @@ -93,7 +93,6 @@ struct au0828_board {
>  	unsigned char has_ir_i2c:1;
>  	unsigned char has_analog:1;
>  	struct au0828_input input[AU0828_MAX_INPUT];
> -
>  };
>  
>  struct au0828_dvb {
> @@ -281,6 +280,8 @@ struct au0828_dev {
>  	struct media_device *media_dev;
>  	struct media_pad video_pad, vbi_pad;
>  	struct media_entity *decoder;
> +	struct media_entity input_ent[AU0828_MAX_INPUT];
> +	struct media_pad input_pad[AU0828_MAX_INPUT];
>  #endif
>  };
>  
> 


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

* Re: [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
@ 2015-09-11 14:58   ` Hans Verkuil
  2015-11-23 19:56   ` Laurent Pinchart
  1 sibling, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 14:58 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Due to the graph traversal algorithm currently in usage, we
> need a copy of all data links. Those backlinks should not be
> send to userspace, as otherwise, all links there will be
> duplicated.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 0238885fcc74..97eb97d9b662 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -333,6 +333,9 @@ static long __media_device_get_topology(struct media_device *mdev,
>  	/* Get links and number of links */
>  	i = 0;
>  	media_device_for_each_link(link, mdev) {
> +		if (link->is_backlink)
> +			continue;
> +
>  		i++;
>  
>  		if (ret || !topo->links)
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index cd4d767644df..4868b8269204 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -648,6 +648,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
>  	backlink->source = &source->pads[source_pad];
>  	backlink->sink = &sink->pads[sink_pad];
>  	backlink->flags = flags;
> +	backlink->is_backlink = true;
>  
>  	/* Initialize graph object embedded at the new link */
>  	media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index e1a89899deef..3d389f142a1d 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -96,6 +96,7 @@ struct media_pipeline {
>   * @reverse:	Pointer to the link for the reverse direction of a pad to pad
>   *		link.
>   * @flags:	Link flags, as defined at uapi/media.h (MEDIA_LNK_FL_*)
> + * @is_backlink: Indicate if the link is a backlink.
>   */
>  struct media_link {
>  	struct media_gobj graph_obj;
> @@ -112,6 +113,7 @@ struct media_link {
>  	};
>  	struct media_link *reverse;
>  	unsigned long flags;
> +	bool is_backlink;
>  };
>  
>  /**
> 


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

* Re: [PATCH 05/18] [media] media-controller: enable all interface links at init
  2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
@ 2015-09-11 15:18   ` Hans Verkuil
  2015-11-23 19:46   ` Laurent Pinchart
  1 sibling, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Hans Verkuil, Sakari Ailus

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Interface links are normally enabled, meaning that the interfaces are
> bound to the entities. So, any ioctl send to the interface are reflected
> at the entities managed by the interface.
> 
> However, when a device is usage, other interfaces for the same hardware

s/usage/used/

> could be decoupled from the entities linked to them, because the
> hardware may have some parts busy.
> 
> That's for example, what happens when an hybrid TV device is in usage.

s/usage/use/

> If it is streaming analog TV or capturing signals from S-Video/Composite
> connectors, typically the digital part of the hardware can't be used and
> vice-versa.
> 
> This is generally due to some internal hardware or firmware limitation,
> that it is not easily mapped via data pipelines.
> 
> What the Kernel drivers do internally is that they decouple the hardware
> from the interface. So, all changes, if allowed, are done only at some
> interface cache, but not physically changed at the hardware.
> 
> The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data
> links. So, let's use the same flag to indicate if ether the interface

s/ether/either/

> to entity link is bound/enabled or not.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index a8e7e2398f7a..5c4fb41060b4 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -396,7 +396,8 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
>  	if (!dvbdev->entity || !dvbdev->intf_devnode)
>  		return;
>  
> -	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0);
> +	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
> +			       MEDIA_LNK_FL_ENABLED);
>  
>  #endif
>  }
> @@ -583,20 +584,24 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
>  	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
>  	media_device_for_each_intf(intf, mdev) {
>  		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
> -			media_create_intf_link(ca, intf, 0);
> +			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
>  
>  		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
> -			media_create_intf_link(tuner, intf, 0);
> +			media_create_intf_link(tuner, intf,
> +					       MEDIA_LNK_FL_ENABLED);
>  
>  		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
> -			media_create_intf_link(demux, intf, 0);
> +			media_create_intf_link(demux, intf,
> +					       MEDIA_LNK_FL_ENABLED);
>  
>  		media_device_for_each_entity(entity, mdev) {
>  			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strcmp(entity->name, DVR_TSOUT))
> -					media_create_intf_link(entity, intf, 0);
> +					media_create_intf_link(entity, intf,
> +							       MEDIA_LNK_FL_ENABLED);
>  				if (!strcmp(entity->name, DEMUX_TSOUT))
> -					media_create_intf_link(entity, intf, 0);
> +					media_create_intf_link(entity, intf,
> +							       MEDIA_LNK_FL_ENABLED);
>  				break;
>  			}
>  		}
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index 07123dd569c4..8429da66754a 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -788,7 +788,8 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  		struct media_link *link;
>  
>  		link = media_create_intf_link(&vdev->entity,
> -					      &vdev->intf_devnode->intf, 0);
> +					      &vdev->intf_devnode->intf,
> +					      MEDIA_LNK_FL_ENABLED);
>  		if (!link) {
>  			media_devnode_remove(vdev->intf_devnode);
>  			media_device_unregister_entity(&vdev->entity);
> diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
> index e788a085ba96..bb58d90fde5e 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -256,7 +256,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
>  
>  			link = media_create_intf_link(&sd->entity,
>  						      &vdev->intf_devnode->intf,
> -						      0);
> +						      MEDIA_LNK_FL_ENABLED);
>  			if (!link)
>  				goto clean_up;
>  		}
> 


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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
@ 2015-09-11 15:19     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: linux-api

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Add entities to represent the connectors that exists inside a
> hybrid TV device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index b17f6763aff4..69433405aec2 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -61,6 +61,7 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_BASE		0x00000000
>  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
>  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
>  
>  /*
>   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> @@ -105,6 +106,13 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
>  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
>  
> +/* Connectors */
> +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)

Please start at BASE + 1.

With that change:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +	/* For internal test signal generators and other debug connectors */
> +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> +
>  #ifndef __KERNEL__
>  /* Legacy symbols used to avoid userspace compilation breakages */
>  #define MEDIA_ENT_TYPE_SHIFT		16
> @@ -121,9 +129,9 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
>  #endif
>  
> -/* Entity types */
> -
> +/* Entity flags */
>  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)
>  
>  struct media_entity_desc {
>  	__u32 id;
> 


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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
@ 2015-09-11 15:19     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Add entities to represent the connectors that exists inside a
> hybrid TV device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index b17f6763aff4..69433405aec2 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -61,6 +61,7 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_BASE		0x00000000
>  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
>  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
>  
>  /*
>   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> @@ -105,6 +106,13 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
>  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
>  
> +/* Connectors */
> +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)

Please start at BASE + 1.

With that change:

Acked-by: Hans Verkuil <hans.verkuil-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>

> +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +	/* For internal test signal generators and other debug connectors */
> +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> +
>  #ifndef __KERNEL__
>  /* Legacy symbols used to avoid userspace compilation breakages */
>  #define MEDIA_ENT_TYPE_SHIFT		16
> @@ -121,9 +129,9 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
>  #endif
>  
> -/* Entity types */
> -
> +/* Entity flags */
>  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)
>  
>  struct media_entity_desc {
>  	__u32 id;
> 

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

* Re: [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails
  2015-09-06 17:30 ` [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails Mauro Carvalho Chehab
@ 2015-09-11 15:20   ` Hans Verkuil
  2015-12-10 17:33     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:20 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Hans Verkuil, Jonathan Corbet

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Right now, if something gets wrong at dvb_create_media_entity()
> or at dvb_create_media_graph(), the device will still be
> registered.
> 
> Change the logic to properly handle it and free all media graph
> objects if something goes wrong at dvb_register_device().
> 
> Also, change the logic at dvb_create_media_graph() to return
> an error code if something goes wrong. It is up to the
> caller to implement the right logic and to call
> dvb_unregister_device() to unregister the already-created
> objects.
> 
> While here, add a missing logic to unregister the created
> interfaces.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 5c4fb41060b4..5c51084a331a 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -183,7 +183,29 @@ skip:
>  	return -ENFILE;
>  }
>  
> -static void dvb_create_tsout_entity(struct dvb_device *dvbdev,
> +static void dvb_media_device_free(struct dvb_device *dvbdev)
> +{
> +#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
> +	if (dvbdev->entity) {
> +		int i;
> +
> +		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
> +			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
> +			kfree(dvbdev->tsout_entity[i].name);
> +		}
> +		media_device_unregister_entity(dvbdev->entity);
> +
> +		kfree(dvbdev->entity);
> +		kfree(dvbdev->pads);
> +		kfree(dvbdev->tsout_entity);
> +		kfree(dvbdev->tsout_pads);
> +	}
> +	if (dvbdev->intf_devnode)
> +		media_devnode_remove(dvbdev->intf_devnode);
> +#endif
> +}
> +
> +static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  				    const char *name, int npads)
>  {
>  #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
> @@ -192,77 +214,60 @@ static void dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  	dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads),
>  				     GFP_KERNEL);
>  	if (!dvbdev->tsout_pads)
> -		return;
> +		return -ENOMEM;
> +
>  	dvbdev->tsout_entity = kcalloc(npads, sizeof(*dvbdev->tsout_entity),
>  				       GFP_KERNEL);
> -	if (!dvbdev->tsout_entity) {
> -		kfree(dvbdev->tsout_pads);
> -		dvbdev->tsout_pads = NULL;
> -		return;
> -	}
> +	if (!dvbdev->tsout_entity)
> +		return -ENOMEM;
> +
>  	for (i = 0; i < npads; i++) {
>  		struct media_pad *pads = &dvbdev->tsout_pads[i];
>  		struct media_entity *entity = &dvbdev->tsout_entity[i];
>  
>  		entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i);
> -		if (!entity->name) {
> -			ret = -ENOMEM;
> -			break;
> -		}
> +		if (!entity->name)
> +			return ret;
>  
>  		entity->type = MEDIA_ENT_T_DVB_TSOUT;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
>  		if (ret < 0)
> -			break;
> +			return ret;
>  
>  		ret = media_device_register_entity(dvbdev->adapter->mdev,
>  						   entity);
>  		if (ret < 0)
> -			break;
> +			return ret;
>  	}
> -
> -	if (!ret) {
> -		dvbdev->tsout_num_entities = npads;
> -		return;
> -	}
> -
> -	for (i--; i >= 0; i--) {
> -		media_device_unregister_entity(&dvbdev->tsout_entity[i]);
> -		kfree(dvbdev->tsout_entity[i].name);
> -	}
> -
> -	printk(KERN_ERR
> -		"%s: media_device_register_entity failed for %s\n",
> -		__func__, name);
> -
> -	kfree(dvbdev->tsout_entity);
> -	kfree(dvbdev->tsout_pads);
> -	dvbdev->tsout_entity = NULL;
> -	dvbdev->tsout_pads = NULL;
>  #endif
> +	return 0;
>  }
>  
>  #define DEMUX_TSOUT	"demux-tsout"
>  #define DVR_TSOUT	"dvr-tsout"
>  
> -static void dvb_create_media_entity(struct dvb_device *dvbdev,
> -				    int type, int demux_sink_pads)
> +static int dvb_create_media_entity(struct dvb_device *dvbdev,
> +				   int type, int demux_sink_pads)
>  {
>  #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
> -	int i, ret = 0, npads;
> +	int i, ret, npads;
>  
>  	switch (type) {
>  	case DVB_DEVICE_FRONTEND:
>  		npads = 2;
>  		break;
>  	case DVB_DEVICE_DVR:
> -		dvb_create_tsout_entity(dvbdev, DVR_TSOUT, demux_sink_pads);
> -		return;
> +		ret = dvb_create_tsout_entity(dvbdev, DVR_TSOUT,
> +					      demux_sink_pads);
> +		return ret;
>  	case DVB_DEVICE_DEMUX:
>  		npads = 1 + demux_sink_pads;
> -		dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT, demux_sink_pads);
> +		ret = dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT,
> +					      demux_sink_pads);
> +		if (ret < 0)
> +			return ret;
>  		break;
>  	case DVB_DEVICE_CA:
>  		npads = 2;
> @@ -277,24 +282,22 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,
>  		 * the Media Controller, let's not create the decap
>  		 * entities yet.
>  		 */
> -		return;
> +		return 0;
>  	default:
> -		return;
> +		return 0;
>  	}
>  
>  	dvbdev->entity = kzalloc(sizeof(*dvbdev->entity), GFP_KERNEL);
>  	if (!dvbdev->entity)
> -		return;
> +		return -ENOMEM;
>  
>  	dvbdev->entity->name = dvbdev->name;
>  
>  	if (npads) {
>  		dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads),
>  				       GFP_KERNEL);
> -		if (!dvbdev->pads) {
> -			kfree(dvbdev->entity);
> -			return;
> -		}
> +		if (!dvbdev->pads)
> +			return -ENOMEM;
>  	}
>  
>  	switch (type) {
> @@ -316,49 +319,43 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,
>  		break;
>  	default:
>  		kfree(dvbdev->entity);
> +		kfree(dvbdev->pads);
>  		dvbdev->entity = NULL;
> -		return;
> +		return 0;
>  	}
>  
> -	if (npads)
> +	if (npads) {
>  		ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads);
> -	if (!ret)
> -		ret = media_device_register_entity(dvbdev->adapter->mdev,
> -						   dvbdev->entity);
> -	if (ret < 0) {
> -		printk(KERN_ERR
> -			"%s: media_device_register_entity failed for %s\n",
> -			__func__, dvbdev->entity->name);
> -
> -		media_device_unregister_entity(dvbdev->entity);
> -		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
> -			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
> -			kfree(dvbdev->tsout_entity[i].name);
> -		}
> -		kfree(dvbdev->pads);
> -		kfree(dvbdev->entity);
> -		kfree(dvbdev->tsout_pads);
> -		kfree(dvbdev->tsout_entity);
> -		dvbdev->entity = NULL;
> -		return;
> +		if (ret)
> +			return ret;
>  	}
> +	ret = media_device_register_entity(dvbdev->adapter->mdev,
> +					   dvbdev->entity);
> +	if (ret)
> +		return (ret);
>  
>  	printk(KERN_DEBUG "%s: media entity '%s' registered.\n",
>  		__func__, dvbdev->entity->name);
> +
>  #endif
> +	return 0;
>  }
>  
> -static void dvb_register_media_device(struct dvb_device *dvbdev,
> -				      int type, int minor,
> -				      unsigned demux_sink_pads)
> +static int dvb_register_media_device(struct dvb_device *dvbdev,
> +				     int type, int minor,
> +				     unsigned demux_sink_pads)
>  {
>  #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
> +	struct media_link *link;
>  	u32 intf_type;
> +	int ret;
>  
>  	if (!dvbdev->adapter->mdev)
> -		return;
> +		return 0;
>  
> -	dvb_create_media_entity(dvbdev, type, demux_sink_pads);
> +	ret = dvb_create_media_entity(dvbdev, type, demux_sink_pads);
> +	if (ret)
> +		return ret;
>  
>  	switch (type) {
>  	case DVB_DEVICE_FRONTEND:
> @@ -377,13 +374,16 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
>  		intf_type = MEDIA_INTF_T_DVB_NET;
>  		break;
>  	default:
> -		return;
> +		return 0;
>  	}
>  
>  	dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev,
> -						 intf_type, 0,
> -						 DVB_MAJOR, minor,
> -						 GFP_KERNEL);
> +						    intf_type, 0,
> +						    DVB_MAJOR, minor,
> +						    GFP_KERNEL);
> +
> +	if (!dvbdev->intf_devnode)
> +		return -ENOMEM;
>  
>  	/*
>  	 * Create the "obvious" link, e. g. the ones that represent
> @@ -393,13 +393,15 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
>  	 *		DVB demux intf -> dvr
>  	 */
>  
> -	if (!dvbdev->entity || !dvbdev->intf_devnode)
> -		return;
> -
> -	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
> -			       MEDIA_LNK_FL_ENABLED);
> +	if (!dvbdev->entity)
> +		return 0;
>  
> +	link = media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
> +				      MEDIA_LNK_FL_ENABLED);
> +	if (!link)
> +		return -ENOMEM;
>  #endif
> +	return 0;
>  }
>  
>  int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
> @@ -410,7 +412,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  	struct file_operations *dvbdevfops;
>  	struct device *clsdev;
>  	int minor;
> -	int id;
> +	int id, ret;
>  
>  	mutex_lock(&dvbdev_register_lock);
>  
> @@ -428,6 +430,17 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  		return -ENOMEM;
>  	}
>  
> +	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
> +	if (ret) {
> +		printk(KERN_ERR
> +		      "%s: dvb_register_media_device failed to create the mediagraph\n",
> +		      __func__);
> +
> +		dvb_media_device_free(dvbdev);
> +		mutex_unlock(&dvbdev_register_lock);
> +		return ret;
> +	}
> +
>  	dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
>  
>  	if (!dvbdevfops){
> @@ -483,8 +496,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  	dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
>  		adap->num, dnames[type], id, minor, minor);
>  
> -	dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
> -
>  	return 0;
>  }
>  EXPORT_SYMBOL(dvb_register_device);
> @@ -499,25 +510,10 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
>  	dvb_minors[dvbdev->minor] = NULL;
>  	up_write(&minor_rwsem);
>  
> +	dvb_media_device_free(dvbdev);
> +
>  	device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor));
>  
> -#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
> -	if (dvbdev->entity) {
> -		int i;
> -
> -		media_device_unregister_entity(dvbdev->entity);
> -		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
> -			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
> -			kfree(dvbdev->tsout_entity[i].name);
> -		}
> -
> -		kfree(dvbdev->entity);
> -		kfree(dvbdev->pads);
> -		kfree(dvbdev->tsout_entity);
> -		kfree(dvbdev->tsout_pads);
> -	}
> -#endif
> -
>  	list_del (&dvbdev->list_head);
>  	kfree (dvbdev->fops);
>  	kfree (dvbdev);
> @@ -526,17 +522,19 @@ EXPORT_SYMBOL(dvb_unregister_device);
>  
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -void dvb_create_media_graph(struct dvb_adapter *adap)
> +int dvb_create_media_graph(struct dvb_adapter *adap)
>  {
>  	struct media_device *mdev = adap->mdev;
>  	struct media_entity *entity, *tuner = NULL, *demod = NULL;
>  	struct media_entity *demux = NULL, *ca = NULL;
> +	struct media_link *link;
>  	struct media_interface *intf;
>  	unsigned demux_pad = 0;
>  	unsigned dvr_pad = 0;
> +	int ret;
>  
>  	if (!mdev)
> -		return;
> +		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
>  		switch (entity->type) {
> @@ -555,57 +553,94 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
>  		}
>  	}
>  
> -	if (tuner && demod)
> -		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
> +	if (tuner && demod) {
> +		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
> +					    demod, 0, MEDIA_LNK_FL_ENABLED);
> +		if (ret)
> +			return ret;
> +	}
>  
> -	if (demod && demux)
> -		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
> -	if (demux && ca)
> -		media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
> +	if (demod && demux) {
> +		ret = media_create_pad_link(demod, 1, demux,
> +					    0, MEDIA_LNK_FL_ENABLED);
> +		if (ret)
> +			return -ENOMEM;
> +	}
> +	if (demux && ca) {
> +		ret = media_create_pad_link(demux, 1, ca,
> +					    0, MEDIA_LNK_FL_ENABLED);
> +		if (!ret)
> +			return -ENOMEM;
> +	}
>  
>  	/* Create demux links for each ringbuffer/pad */
>  	if (demux) {
>  		media_device_for_each_entity(entity, mdev) {
>  			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strncmp(entity->name, DVR_TSOUT,
> -					strlen(DVR_TSOUT)))
> -					media_create_pad_link(demux,
> -							      ++dvr_pad,
> -							entity, 0, 0);
> +				    strlen(DVR_TSOUT))) {
> +					ret = media_create_pad_link(demux,
> +								++dvr_pad,
> +							    entity, 0, 0);
> +					if (ret)
> +						return ret;
> +				}
>  				if (!strncmp(entity->name, DEMUX_TSOUT,
> -					strlen(DEMUX_TSOUT)))
> -					media_create_pad_link(demux,
> +				    strlen(DEMUX_TSOUT))) {
> +					ret = media_create_pad_link(demux,
>  							      ++demux_pad,
> -							entity, 0, 0);
> +							    entity, 0, 0);
> +					if (ret)
> +						return ret;
> +				}
>  			}
>  		}
>  	}
>  
>  	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
>  	media_device_for_each_intf(intf, mdev) {
> -		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
> -			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
> +		if (intf->type == MEDIA_INTF_T_DVB_CA && ca) {
> +			link = media_create_intf_link(ca, intf,
> +						      MEDIA_LNK_FL_ENABLED);
> +			if (!link)
> +				return -ENOMEM;
> +		}
>  
> -		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
> -			media_create_intf_link(tuner, intf,
> -					       MEDIA_LNK_FL_ENABLED);
> +		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) {
> +			link = media_create_intf_link(tuner, intf,
> +						      MEDIA_LNK_FL_ENABLED);
> +			if (!link)
> +				return -ENOMEM;
> +		}
>  
> -		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
> -			media_create_intf_link(demux, intf,
> -					       MEDIA_LNK_FL_ENABLED);
> +		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) {
> +			link = media_create_intf_link(demux, intf,
> +						      MEDIA_LNK_FL_ENABLED);
> +			if (!link)
> +				return -ENOMEM;
> +		}
>  
>  		media_device_for_each_entity(entity, mdev) {
>  			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> -				if (!strcmp(entity->name, DVR_TSOUT))
> -					media_create_intf_link(entity, intf,
> -							       MEDIA_LNK_FL_ENABLED);
> -				if (!strcmp(entity->name, DEMUX_TSOUT))
> -					media_create_intf_link(entity, intf,
> -							       MEDIA_LNK_FL_ENABLED);
> +				if (!strcmp(entity->name, DVR_TSOUT)) {
> +					link = media_create_intf_link(entity,
> +							intf,
> +							MEDIA_LNK_FL_ENABLED);
> +					if (!link)
> +						return -ENOMEM;
> +				}
> +				if (!strcmp(entity->name, DEMUX_TSOUT)) {
> +					link = media_create_intf_link(entity,
> +							intf,
> +							MEDIA_LNK_FL_ENABLED);
> +					if (!link)
> +						return -ENOMEM;
> +				}
>  				break;
>  			}
>  		}
>  	}
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(dvb_create_media_graph);
>  #endif
> diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
> index 0b140e8595de..9e24aafeb9ea 100644
> --- a/drivers/media/dvb-core/dvbdev.h
> +++ b/drivers/media/dvb-core/dvbdev.h
> @@ -210,7 +210,7 @@ int dvb_register_device(struct dvb_adapter *adap,
>  void dvb_unregister_device(struct dvb_device *dvbdev);
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -void dvb_create_media_graph(struct dvb_adapter *adap);
> +int dvb_create_media_graph(struct dvb_adapter *adap);
>  static inline void dvb_register_media_controller(struct dvb_adapter *adap,
>  						 struct media_device *mdev)
>  {
> @@ -218,7 +218,10 @@ static inline void dvb_register_media_controller(struct dvb_adapter *adap,
>  }
>  
>  #else
> -static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
> +static inline int dvb_create_media_graph(struct dvb_adapter *adap)
> +{
> +	return 0;
> +};
>  #define dvb_register_media_controller(a, b) {}
>  #endif
>  
> 


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

* Re: [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph()
  2015-09-06 17:30 ` [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph() Mauro Carvalho Chehab
@ 2015-09-11 15:22   ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Antti Palosaari, Stefan Richter, Hans Verkuil, Jonathan Corbet,
	Rafael Lourenço de Lima Chehab, Michael Ira Krufky,
	Richard Vollkommer, Devin Heitmueller, Matthias Schwarzott,
	Olli Salonen, Luis de Bethencourt

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> If media controller is enabled and mdev is filled, it should
> ensure that the media graph will be properly initialized.
> 
> Enforce that.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
> index f4305ae800f4..ab345490a43a 100644
> --- a/drivers/media/common/siano/smsdvb-main.c
> +++ b/drivers/media/common/siano/smsdvb-main.c
> @@ -1183,7 +1183,11 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
>  	if (smsdvb_debugfs_create(client) < 0)
>  		pr_info("failed to create debugfs node\n");
>  
> -	dvb_create_media_graph(&client->adapter);
> +	rc = dvb_create_media_graph(&client->adapter);
> +	if (rc < 0) {
> +		pr_err("dvb_create_media_graph failed %d\n", rc);
> +		goto client_error;
> +	}
>  
>  	pr_info("DVB interface registered.\n");
>  	return 0;
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 5c51084a331a..df2fe4cc2d47 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -430,17 +430,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  		return -ENOMEM;
>  	}
>  
> -	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
> -	if (ret) {
> -		printk(KERN_ERR
> -		      "%s: dvb_register_media_device failed to create the mediagraph\n",
> -		      __func__);
> -
> -		dvb_media_device_free(dvbdev);
> -		mutex_unlock(&dvbdev_register_lock);
> -		return ret;
> -	}
> -
>  	dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
>  
>  	if (!dvbdevfops){
> @@ -493,6 +482,17 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
>  		       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
>  		return PTR_ERR(clsdev);
>  	}
> +
> +	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
> +	if (ret) {
> +		printk(KERN_ERR
> +		      "%s: dvb_register_media_device failed to create the media graph\n",
> +		      __func__);
> +
> +		dvb_unregister_device(dvbdev);
> +		return ret;
> +	}
> +
>  	dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
>  		adap->num, dnames[type], id, minor, minor);
>  
> diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
> index 9e24aafeb9ea..bd9fac91c7b9 100644
> --- a/drivers/media/dvb-core/dvbdev.h
> +++ b/drivers/media/dvb-core/dvbdev.h
> @@ -210,7 +210,7 @@ int dvb_register_device(struct dvb_adapter *adap,
>  void dvb_unregister_device(struct dvb_device *dvbdev);
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -int dvb_create_media_graph(struct dvb_adapter *adap);
> +__must_check int dvb_create_media_graph(struct dvb_adapter *adap);
>  static inline void dvb_register_media_controller(struct dvb_adapter *adap,
>  						 struct media_device *mdev)
>  {
> diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
> index c01772c4f9f0..cd542b49a6c2 100644
> --- a/drivers/media/usb/au0828/au0828-dvb.c
> +++ b/drivers/media/usb/au0828/au0828-dvb.c
> @@ -486,12 +486,14 @@ static int dvb_register(struct au0828_dev *dev)
>  	dvb->start_count = 0;
>  	dvb->stop_count = 0;
>  
> -#ifdef CONFIG_MEDIA_CONTROLLER_DVB
> -	dvb_create_media_graph(&dvb->adapter);
> -#endif
> +	result = dvb_create_media_graph(&dvb->adapter);
> +	if (result < 0)
> +		goto fail_create_graph;
>  
>  	return 0;
>  
> +fail_create_graph:
> +	dvb_net_release(&dvb->net);
>  fail_fe_conn:
>  	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
>  fail_fe_mem:
> diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> index 66ee161fc7ba..aaf8ef246f13 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> @@ -551,10 +551,14 @@ static int register_dvb(struct cx231xx_dvb *dvb,
>  
>  	/* register network adapter */
>  	dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
> -	dvb_create_media_graph(&dvb->adapter);
> +	result = dvb_create_media_graph(&dvb->adapter);
> +	if (result < 0)
> +		goto fail_create_graph;
>  
>  	return 0;
>  
> +fail_create_graph:
> +	dvb_net_release(&dvb->net);
>  fail_fe_conn:
>  	dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
>  fail_fe_mem:
> diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> index f5df9eaba04f..6d3f61f6dc77 100644
> --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> @@ -698,7 +698,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
>  		}
>  	}
>  
> -	dvb_create_media_graph(&adap->dvb_adap);
> +	ret = dvb_create_media_graph(&adap->dvb_adap);
> +	if (ret < 0)
> +		goto err_dvb_unregister_frontend;
>  
>  	return 0;
>  
> diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> index 8a260c854653..b51dbdf03f42 100644
> --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c
> @@ -318,10 +318,12 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
>  
>  		adap->num_frontends_initialized++;
>  	}
> +	if (ret)
> +		return ret;
>  
> -	dvb_create_media_graph(&adap->dvb_adap);
> +	ret = dvb_create_media_graph(&adap->dvb_adap);
>  
> -	return 0;
> +	return ret;
>  }
>  
>  int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
> 


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

* Re: [PATCH 09/18] [media] media-entity: enforce check of interface and links creation
  2015-09-06 17:30 ` [PATCH 09/18] [media] media-entity: enforce check of interface and links creation Mauro Carvalho Chehab
@ 2015-09-11 15:23   ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Drivers should check if interfaces and interface links were
> created. Add a must_check for them.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 3d389f142a1d..62f882d872b1 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -370,14 +370,16 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
>  					     struct media_pipeline *pipe);
>  void media_entity_pipeline_stop(struct media_entity *entity);
>  
> -struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
> -						u32 type, u32 flags,
> -						u32 major, u32 minor,
> -						gfp_t gfp_flags);
> +struct media_intf_devnode *
> +__must_check media_devnode_create(struct media_device *mdev,
> +				  u32 type, u32 flags,
> +				  u32 major, u32 minor,
> +				  gfp_t gfp_flags);
>  void media_devnode_remove(struct media_intf_devnode *devnode);
> -struct media_link *media_create_intf_link(struct media_entity *entity,
> -					    struct media_interface *intf,
> -					    u32 flags);
> +struct media_link *
> +__must_check media_create_intf_link(struct media_entity *entity,
> +				    struct media_interface *intf,
> +				    u32 flags);
>  void media_remove_intf_link(struct media_link *link);
>  void __media_remove_intf_links(struct media_interface *intf);
>  void media_remove_intf_links(struct media_interface *intf);
> 


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

* Re: [PATCH 10/18] [media] cx231xx: enforce check for graph creation
  2015-09-06 17:30 ` [PATCH 10/18] [media] cx231xx: enforce check for graph creation Mauro Carvalho Chehab
@ 2015-09-11 15:23   ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Matthias Schwarzott, Antti Palosaari, Olli Salonen, Tommi Rantala

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> If the graph creation fails, don't register the device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index 1070d87efc65..c05aaef85491 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1185,8 +1185,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev)
>  */
>  void cx231xx_release_resources(struct cx231xx *dev)
>  {
> -	cx231xx_unregister_media_device(dev);
> -
>  	cx231xx_release_analog_resources(dev);
>  
>  	cx231xx_remove_from_devlist(dev);
> @@ -1199,6 +1197,8 @@ void cx231xx_release_resources(struct cx231xx *dev)
>  	/* delete v4l2 device */
>  	v4l2_device_unregister(&dev->v4l2_dev);
>  
> +	cx231xx_unregister_media_device(dev);
> +
>  	usb_put_dev(dev->udev);
>  
>  	/* Mark device as unused */
> @@ -1237,15 +1237,16 @@ static void cx231xx_media_device_register(struct cx231xx *dev,
>  #endif
>  }
>  
> -static void cx231xx_create_media_graph(struct cx231xx *dev)
> +static int cx231xx_create_media_graph(struct cx231xx *dev)
>  {
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	struct media_device *mdev = dev->media_dev;
>  	struct media_entity *entity;
>  	struct media_entity *tuner = NULL, *decoder = NULL;
> +	int ret;
>  
>  	if (!mdev)
> -		return;
> +		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
>  		switch (entity->type) {
> @@ -1261,16 +1262,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
>  	/* Analog setup, using tuner as a link */
>  
>  	if (!decoder)
> -		return;
> +		return 0;
>  
> -	if (tuner)
> -		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
> -					 MEDIA_LNK_FL_ENABLED);
> -	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> -				 MEDIA_LNK_FL_ENABLED);
> -	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
> -				 MEDIA_LNK_FL_ENABLED);
> +	if (tuner) {
> +		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
> +					    MEDIA_LNK_FL_ENABLED);
> +		if (ret < 0)
> +			return ret;
> +	}
> +	ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> +				    MEDIA_LNK_FL_ENABLED);
> +	if (ret < 0)
> +		return ret;
> +	ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
> +				    MEDIA_LNK_FL_ENABLED);
> +	if (ret < 0)
> +		return ret;
>  #endif
> +	return 0;
>  }
>  
>  /*
> @@ -1732,9 +1741,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
>  	/* load other modules required */
>  	request_modules(dev);
>  
> -	cx231xx_create_media_graph(dev);
> +	retval = cx231xx_create_media_graph(dev);
> +	if (retval < 0) {
> +		cx231xx_release_resources(dev);
> +	}
>  
> -	return 0;
> +	return retval;
>  err_video_alt:
>  	/* cx231xx_uninit_dev: */
>  	cx231xx_close_extension(dev);
> 


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

* Re: [PATCH 11/18] [media] au0828:: enforce check for graph creation
  2015-09-06 17:30 ` [PATCH 11/18] [media] au0828:: " Mauro Carvalho Chehab
@ 2015-09-11 15:23   ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Rafael Lourenço de Lima Chehab, Hans Verkuil, Shuah Khan

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> If the graph creation fails, don't register the device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index 35c607c35155..399c6712faf9 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -172,9 +172,9 @@ static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
>  	struct au0828_dev *dev =
>  		container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
>  
> -	au0828_usb_v4l2_media_release(dev);
>  	v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
>  	v4l2_device_unregister(&dev->v4l2_dev);
> +	au0828_usb_v4l2_media_release(dev);
>  	au0828_usb_release(dev);
>  }
>  #endif
> @@ -251,16 +251,16 @@ static void au0828_media_device_register(struct au0828_dev *dev,
>  }
>  
>  
> -static void au0828_create_media_graph(struct au0828_dev *dev)
> +static int au0828_create_media_graph(struct au0828_dev *dev)
>  {
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	struct media_device *mdev = dev->media_dev;
>  	struct media_entity *entity;
>  	struct media_entity *tuner = NULL, *decoder = NULL;
> -	int i;
> +	int i, ret;
>  
>  	if (!mdev)
> -		return;
> +		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
>  		switch (entity->type) {
> @@ -277,15 +277,23 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
>  
>  	/* Something bad happened! */
>  	if (!decoder)
> -		return;
> +		return -EINVAL;
>  
> -	if (tuner)
> -		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
> -				      MEDIA_LNK_FL_ENABLED);
> -	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> -			      MEDIA_LNK_FL_ENABLED);
> -	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
> -			      MEDIA_LNK_FL_ENABLED);
> +	if (tuner) {
> +		ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
> +					    decoder, 0,
> +				            MEDIA_LNK_FL_ENABLED);
> +		if (ret)
> +			return ret;
> +	}
> +	ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> +			 	    MEDIA_LNK_FL_ENABLED);
> +	if (ret)
> +		return ret;
> +	ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
> +				    MEDIA_LNK_FL_ENABLED);
> +	if (ret)
> +		return ret;
>  
>  	for (i = 0; i < AU0828_MAX_INPUT; i++) {
>  		struct media_entity *ent = &dev->input_ent[i];
> @@ -297,20 +305,27 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
>  		case AU0828_VMUX_CABLE:
>  		case AU0828_VMUX_TELEVISION:
>  		case AU0828_VMUX_DVB:
> -			if (tuner)
> -				media_create_pad_link(ent, 0, tuner,
> -						      TUNER_PAD_RF_INPUT,
> -						      MEDIA_LNK_FL_ENABLED);
> +			if (!tuner)
> +				break;
> +
> +			ret = media_create_pad_link(ent, 0, tuner,
> +						    TUNER_PAD_RF_INPUT,
> +						    MEDIA_LNK_FL_ENABLED);
> +			if (ret)
> +				return ret;
>  			break;
>  		case AU0828_VMUX_COMPOSITE:
>  		case AU0828_VMUX_SVIDEO:
>  		default: /* AU0828_VMUX_DEBUG */
>  			/* FIXME: fix the decoder PAD */
> -			media_create_pad_link(ent, 0, decoder, 0, 0);
> +			ret = media_create_pad_link(ent, 0, decoder, 0, 0);
> +			if (ret)
> +				return ret;
>  			break;
>  		}
>  	}
>  #endif
> +	return 0;
>  }
>  
>  static int au0828_usb_probe(struct usb_interface *interface,
> @@ -425,7 +440,12 @@ static int au0828_usb_probe(struct usb_interface *interface,
>  
>  	mutex_unlock(&dev->lock);
>  
> -	au0828_create_media_graph(dev);
> +	retval = au0828_create_media_graph(dev);
> +	if (retval) {
> +		pr_err("%s() au0282_dev_register failed to create graph\n",
> +		       __func__);
> +		au0828_usb_disconnect(interface);
> +	}
>  
>  	return retval;
>  }
> 


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

* Re: [PATCH 12/18] [media] media-entity: must check media_create_pad_link()
  2015-09-06 17:30 ` [PATCH 12/18] [media] media-entity: must check media_create_pad_link() Mauro Carvalho Chehab
@ 2015-09-11 15:24   ` Hans Verkuil
  2015-11-23 17:54   ` Laurent Pinchart
  1 sibling, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:24 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Drivers should check if media_create_pad_link() actually
> worked.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 62f882d872b1..8bdc10dcc5e7 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -348,8 +348,9 @@ int media_entity_init(struct media_entity *entity, u16 num_pads,
>  		      struct media_pad *pads);
>  void media_entity_cleanup(struct media_entity *entity);
>  
> -int media_create_pad_link(struct media_entity *source, u16 source_pad,
> -		struct media_entity *sink, u16 sink_pad, u32 flags);
> +__must_check int media_create_pad_link(struct media_entity *source,
> +			u16 source_pad,	struct media_entity *sink,
> +			u16 sink_pad, u32 flags);
>  void __media_entity_remove_links(struct media_entity *entity);
>  void media_entity_remove_links(struct media_entity *entity);
>  
> 


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

* Re: [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
  2015-09-06 17:30   ` Mauro Carvalho Chehab
@ 2015-09-11 15:25     ` Hans Verkuil
  -1 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:25 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Jonathan Corbet, Sakari Ailus, Laurent Pinchart, Kyungmin Park,
	Heungjun Kim, Lad, Prabhakar, Andrzej Hajda, Hyun Kwon,
	Michal Simek, Sören Brinkmann, Hans Verkuil,
	Krzysztof Kozlowski, Rafael Lourenço de Lima Chehab,
	Boris BREZILLON, Joe Perches, Sylwester Nawrocki, Shuah Khan,
	Markus Elfring, Matthias Schwarzott, Antti Palosaari,
	Olli Salonen, Tommi Rantala, Jacek Anaszewski, Bryan Wu,
	Lars-Peter Clausen, linux-doc, linux-arm-kernel

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Entities should have one or more functions. Calling it as a
> type proofed to not be correct, as an entity could eventually
> have more than one type.
> 
> So, rename the field as function.
> 
> Please notice that this patch doesn't extend support for
> multiple function entities. Such change will happen when
> we have real case drivers using it.
> 
> No functional changes.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

I like this!

> 
> diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
> index 109cc3792534..2e0fc28fa12f 100644
> --- a/Documentation/video4linux/v4l2-framework.txt
> +++ b/Documentation/video4linux/v4l2-framework.txt
> @@ -303,8 +303,8 @@ calling media_entity_init():
>  	err = media_entity_init(&sd->entity, npads, pads);
>  
>  The pads array must have been previously initialized. There is no need to
> -manually set the struct media_entity type and name fields, but the revision
> -field must be initialized if needed.
> +manually set the struct media_entity function and name fields, but the
> +revision field must be initialized if needed.
>  
>  A reference to the entity will be automatically acquired/released when the
>  subdev device node (if any) is opened/closed.
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index df2fe4cc2d47..e925909bc99e 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  		if (!entity->name)
>  			return ret;
>  
> -		entity->type = MEDIA_ENT_T_DVB_TSOUT;
> +		entity->function = MEDIA_ENT_T_DVB_TSOUT;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
> @@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
>  
>  	switch (type) {
>  	case DVB_DEVICE_FRONTEND:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
>  	case DVB_DEVICE_DEMUX:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		for (i = 1; i < npads; i++)
>  			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
>  	case DVB_DEVICE_CA:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_CA;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
> @@ -537,7 +537,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> @@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  	/* Create demux links for each ringbuffer/pad */
>  	if (demux) {
>  		media_device_for_each_entity(entity, mdev) {
> -			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> +			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strncmp(entity->name, DVR_TSOUT,
>  				    strlen(DVR_TSOUT))) {
>  					ret = media_create_pad_link(demux,
> @@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  		}
>  
>  		media_device_for_each_entity(entity, mdev) {
> -			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> +			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strcmp(entity->name, DVR_TSOUT)) {
>  					link = media_create_intf_link(entity,
>  							intf,
> diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
> index 55cd42a584a5..a6fbe78a70e3 100644
> --- a/drivers/media/dvb-frontends/au8522_decoder.c
> +++ b/drivers/media/dvb-frontends/au8522_decoder.c
> @@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
>  	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
>  	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
>  
>  	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
>  				state->pads);
> diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
> index 5f76997f6e07..2b8f72ac0f7d 100644
> --- a/drivers/media/i2c/adp1653.c
> +++ b/drivers/media/i2c/adp1653.c
> @@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		goto free_and_quit;
>  
> -	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	return 0;
>  
> diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
> index 9d579a836f79..a49ef7d6df18 100644
> --- a/drivers/media/i2c/as3645a.c
> +++ b/drivers/media/i2c/as3645a.c
> @@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		goto done;
>  
> -	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	mutex_init(&flash->power_lock);
>  
> diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
> index 270135d06b32..d48a3a4df96b 100644
> --- a/drivers/media/i2c/cx25840/cx25840-core.c
> +++ b/drivers/media/i2c/cx25840/cx25840-core.c
> @@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
>  	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
>  	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
>  
>  	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
>  				state->pads);
> diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
> index 9bd9def0852c..7c1abdca39d0 100644
> --- a/drivers/media/i2c/lm3560.c
> +++ b/drivers/media/i2c/lm3560.c
> @@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
>  	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
>  	if (rval < 0)
>  		goto err_out;
> -	flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	return rval;
>  
> diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
> index 4160e18af607..d609f2fa8e6c 100644
> --- a/drivers/media/i2c/lm3646.c
> +++ b/drivers/media/i2c/lm3646.c
> @@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
>  	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
>  	if (rval < 0)
>  		goto err_out;
> -	flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  	return rval;
>  
>  err_out:
> diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
> index f718a1009e4c..206319b88d7a 100644
> --- a/drivers/media/i2c/m5mols/m5mols_core.c
> +++ b/drivers/media/i2c/m5mols/m5mols_core.c
> @@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
>  	ret = media_entity_init(&sd->entity, 1, &info->pad);
>  	if (ret < 0)
>  		return ret;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	init_waitqueue_head(&info->irq_waitq);
>  	mutex_init(&info->lock);
> diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
> index a9761251b970..6cd407bcfddf 100644
> --- a/drivers/media/i2c/noon010pc30.c
> +++ b/drivers/media/i2c/noon010pc30.c
> @@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
>  		goto np_err;
>  
>  	info->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &info->pad);
>  	if (ret < 0)
>  		goto np_err;
> diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
> index 6bce9832ab7b..c085dec69201 100644
> --- a/drivers/media/i2c/ov2659.c
> +++ b/drivers/media/i2c/ov2659.c
> @@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
>  
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
>  	if (ret < 0) {
>  		v4l2_ctrl_handler_free(&ov2659->ctrls);
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index 8a8eb593fc23..2862244a6488 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
>  		return ret;
>  
>  	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
>  	if (ret < 0)
>  		return ret;
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index abae37321c0c..3f55168cce47 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
>  
>  	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
>  	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
>  							state->sensor_pads);
> @@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
>  	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
>  	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
>  	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
> -	oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
>  							state->oif_pads);
> diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
> index d207ddce31b6..45f6e6f2585a 100644
> --- a/drivers/media/i2c/s5k4ecgx.c
> +++ b/drivers/media/i2c/s5k4ecgx.c
> @@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &priv->pad);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 0513196bd48c..22dfeadf7672 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
>  
>  static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
>  {
> -	return sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  }
>  
>  static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
> @@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
>  	if (ret < 0)
>  		goto err;
> @@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
>  
>  	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
>  
>  	if (!ret)
> diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
> index 39a461f9d9bb..71162c02d6d7 100644
> --- a/drivers/media/i2c/s5k6aa.c
> +++ b/drivers/media/i2c/s5k6aa.c
> @@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
> index 5aa49eb393a9..bb1f891a1eb6 100644
> --- a/drivers/media/i2c/smiapp/smiapp-core.c
> +++ b/drivers/media/i2c/smiapp/smiapp-core.c
> @@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
>  
>  	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
>  
> -	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	/* final steps */
>  	smiapp_read_frame_fmt(sensor);
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 97eb97d9b662..ccef9621d147 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -108,7 +108,7 @@ static long media_device_enum_entities(struct media_device *mdev,
>  	u_ent.id = media_entity_id(ent);
>  	if (ent->name)
>  		strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
> -	u_ent.type = ent->type;
> +	u_ent.type = ent->function;
>  	u_ent.revision = ent->revision;
>  	u_ent.flags = ent->flags;
>  	u_ent.group_id = ent->group_id;
> @@ -614,8 +614,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
>  {
>  	int i;
>  
> -	if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
> -	    entity->type == MEDIA_ENT_T_UNKNOWN)
> +	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
> +	    entity->function == MEDIA_ENT_T_UNKNOWN)
>  		dev_warn(mdev->dev,
>  			 "Entity type for entity %s was not initialized!\n",
>  			 entity->name);
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
> index 8e14841bf445..8bee7313a497 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.c
> +++ b/drivers/media/platform/xilinx/xilinx-dma.c
> @@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
>  	while ((entity = media_entity_graph_walk_next(&graph))) {
>  		struct xvip_dma *dma;
>  
> -		if (entity->type != MEDIA_ENT_T_V4L2_VIDEO)
> +		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
>  			continue;
>  
>  		dma = to_xvip_dma(media_entity_to_video_device(entity));
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index 399c6712faf9..44a2ab3c85ab 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -263,7 +263,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 806b8d320bae..5c01f37cd0b8 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
>  
>  		switch(AUVI_INPUT(i).type) {
>  		case AU0828_VMUX_COMPOSITE:
> -			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
> +			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
>  			break;
>  		case AU0828_VMUX_SVIDEO:
> -			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
> +			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
>  			break;
>  		case AU0828_VMUX_CABLE:
>  		case AU0828_VMUX_TELEVISION:
>  		case AU0828_VMUX_DVB:
> -			ent->type = MEDIA_ENT_T_CONN_RF;
> +			ent->function = MEDIA_ENT_T_CONN_RF;
>  			break;
>  		default: /* AU0828_VMUX_DEBUG */
> -			ent->type = MEDIA_ENT_T_CONN_TEST;
> +			ent->function = MEDIA_ENT_T_CONN_TEST;
>  			break;
>  		}
>  
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index c05aaef85491..b01d6bce3cf6 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1249,7 +1249,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
> index e8baff4d6290..ed4a49c850c7 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-video.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-video.c
> @@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
>  	 * this should be enough for the actual needs.
>  	 */
>  	media_device_for_each_entity(entity, mdev) {
> -		if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
> +		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
>  			decoder = entity;
>  			break;
>  		}
> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> index b90f2a52db96..e8fc5ec8fc35 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -698,7 +698,7 @@ register_client:
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
> -	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
> +	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
>  	t->sd.entity.name = t->name;
>  
>  	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index 8429da66754a..2446b2d8fe66 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
>  	if (v4l2_dev->mdev) {
>  		/* Remove interfaces and interface links */
>  		media_devnode_remove(vdev->intf_devnode);
> -		if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN)
> +		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
>  			media_device_unregister_entity(&vdev->entity);
>  	}
>  #endif
> @@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  	if (!vdev->v4l2_dev->mdev)
>  		return 0;
>  
> -	vdev->entity.type = MEDIA_ENT_T_UNKNOWN;
> +	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
>  
>  	switch (type) {
>  	case VFL_TYPE_GRABBER:
>  		intf_type = MEDIA_INTF_T_V4L_VIDEO;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
>  		break;
>  	case VFL_TYPE_VBI:
>  		intf_type = MEDIA_INTF_T_V4L_VBI;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_VBI;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
>  		break;
>  	case VFL_TYPE_SDR:
>  		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
>  		break;
>  	case VFL_TYPE_RADIO:
>  		intf_type = MEDIA_INTF_T_V4L_RADIO;
> @@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  		return 0;
>  	}
>  
> -	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
> +	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
>  		vdev->entity.name = vdev->name;
>  
>  		/* Needed just for backward compatibility with legacy MC API */
> @@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  		return -ENOMEM;
>  	}
>  
> -	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
> +	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
>  		struct media_link *link;
>  
>  		link = media_create_intf_link(&vdev->entity,
> diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> index 34c489fed55e..cf7b3cb9a373 100644
> --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
> +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> @@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
>  	if (ret < 0)
>  		return ERR_PTR(ret);
>  
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	ret = v4l2_flash_init_controls(v4l2_flash, config);
>  	if (ret < 0)
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index b3bcc8253182..b440cb66669c 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -535,9 +535,9 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
>  		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
>  	}
>  
> -	WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO,
> +	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
>  	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
> -	     pad->entity->type, pad->entity->name);
> +	     pad->entity->function, pad->entity->name);
>  
>  	return -EINVAL;
>  }
> @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
>  	sd->host_priv = NULL;
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	sd->entity.name = sd->name;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
>  #endif
>  }
>  EXPORT_SYMBOL(v4l2_subdev_init);
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 8bdc10dcc5e7..10f7d5f0eb66 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -152,7 +152,8 @@ struct media_entity_operations {
>   *
>   * @graph_obj:	Embedded structure containing the media object common data.
>   * @name:	Entity name.
> - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> + * @function:	Entity main function, as defined at uapi/media.h
> + *		(MEDIA_ENT_F_*)
>   * @revision:	Entity revision - OBSOLETE - should be removed soon.
>   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
>   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
> @@ -179,7 +180,7 @@ struct media_entity_operations {
>  struct media_entity {
>  	struct media_gobj graph_obj;	/* must be first field in struct */
>  	const char *name;
> -	u32 type;
> +	u32 function;
>  	u32 revision;
>  	unsigned long flags;
>  	u32 group_id;
> @@ -277,7 +278,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
>  	if (!entity)
>  		return false;
>  
> -	switch (entity->type) {
> +	switch (entity->function) {
>  	case MEDIA_ENT_T_V4L2_VIDEO:
>  	case MEDIA_ENT_T_V4L2_VBI:
>  	case MEDIA_ENT_T_V4L2_SWRADIO:
> @@ -292,7 +293,7 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
>  	if (!entity)
>  		return false;
>  
> -	switch (entity->type) {
> +	switch (entity->function) {
>  	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
>  	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
>  	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
> 


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

* [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
@ 2015-09-11 15:25     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Entities should have one or more functions. Calling it as a
> type proofed to not be correct, as an entity could eventually
> have more than one type.
> 
> So, rename the field as function.
> 
> Please notice that this patch doesn't extend support for
> multiple function entities. Such change will happen when
> we have real case drivers using it.
> 
> No functional changes.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

I like this!

> 
> diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
> index 109cc3792534..2e0fc28fa12f 100644
> --- a/Documentation/video4linux/v4l2-framework.txt
> +++ b/Documentation/video4linux/v4l2-framework.txt
> @@ -303,8 +303,8 @@ calling media_entity_init():
>  	err = media_entity_init(&sd->entity, npads, pads);
>  
>  The pads array must have been previously initialized. There is no need to
> -manually set the struct media_entity type and name fields, but the revision
> -field must be initialized if needed.
> +manually set the struct media_entity function and name fields, but the
> +revision field must be initialized if needed.
>  
>  A reference to the entity will be automatically acquired/released when the
>  subdev device node (if any) is opened/closed.
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index df2fe4cc2d47..e925909bc99e 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  		if (!entity->name)
>  			return ret;
>  
> -		entity->type = MEDIA_ENT_T_DVB_TSOUT;
> +		entity->function = MEDIA_ENT_T_DVB_TSOUT;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
> @@ -302,18 +302,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
>  
>  	switch (type) {
>  	case DVB_DEVICE_FRONTEND:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
>  	case DVB_DEVICE_DEMUX:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		for (i = 1; i < npads; i++)
>  			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
>  	case DVB_DEVICE_CA:
> -		dvbdev->entity->type = MEDIA_ENT_T_DVB_CA;
> +		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
>  		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
>  		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
>  		break;
> @@ -537,7 +537,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> @@ -576,7 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  	/* Create demux links for each ringbuffer/pad */
>  	if (demux) {
>  		media_device_for_each_entity(entity, mdev) {
> -			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> +			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strncmp(entity->name, DVR_TSOUT,
>  				    strlen(DVR_TSOUT))) {
>  					ret = media_create_pad_link(demux,
> @@ -621,7 +621,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  		}
>  
>  		media_device_for_each_entity(entity, mdev) {
> -			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> +			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strcmp(entity->name, DVR_TSOUT)) {
>  					link = media_create_intf_link(entity,
>  							intf,
> diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
> index 55cd42a584a5..a6fbe78a70e3 100644
> --- a/drivers/media/dvb-frontends/au8522_decoder.c
> +++ b/drivers/media/dvb-frontends/au8522_decoder.c
> @@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
>  	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
>  	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
>  
>  	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
>  				state->pads);
> diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
> index 5f76997f6e07..2b8f72ac0f7d 100644
> --- a/drivers/media/i2c/adp1653.c
> +++ b/drivers/media/i2c/adp1653.c
> @@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		goto free_and_quit;
>  
> -	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	return 0;
>  
> diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
> index 9d579a836f79..a49ef7d6df18 100644
> --- a/drivers/media/i2c/as3645a.c
> +++ b/drivers/media/i2c/as3645a.c
> @@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		goto done;
>  
> -	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	mutex_init(&flash->power_lock);
>  
> diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
> index 270135d06b32..d48a3a4df96b 100644
> --- a/drivers/media/i2c/cx25840/cx25840-core.c
> +++ b/drivers/media/i2c/cx25840/cx25840-core.c
> @@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
>  	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
>  	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
>  
>  	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
>  				state->pads);
> diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
> index 9bd9def0852c..7c1abdca39d0 100644
> --- a/drivers/media/i2c/lm3560.c
> +++ b/drivers/media/i2c/lm3560.c
> @@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
>  	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
>  	if (rval < 0)
>  		goto err_out;
> -	flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	return rval;
>  
> diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
> index 4160e18af607..d609f2fa8e6c 100644
> --- a/drivers/media/i2c/lm3646.c
> +++ b/drivers/media/i2c/lm3646.c
> @@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
>  	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
>  	if (rval < 0)
>  		goto err_out;
> -	flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  	return rval;
>  
>  err_out:
> diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
> index f718a1009e4c..206319b88d7a 100644
> --- a/drivers/media/i2c/m5mols/m5mols_core.c
> +++ b/drivers/media/i2c/m5mols/m5mols_core.c
> @@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
>  	ret = media_entity_init(&sd->entity, 1, &info->pad);
>  	if (ret < 0)
>  		return ret;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	init_waitqueue_head(&info->irq_waitq);
>  	mutex_init(&info->lock);
> diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
> index a9761251b970..6cd407bcfddf 100644
> --- a/drivers/media/i2c/noon010pc30.c
> +++ b/drivers/media/i2c/noon010pc30.c
> @@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
>  		goto np_err;
>  
>  	info->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &info->pad);
>  	if (ret < 0)
>  		goto np_err;
> diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
> index 6bce9832ab7b..c085dec69201 100644
> --- a/drivers/media/i2c/ov2659.c
> +++ b/drivers/media/i2c/ov2659.c
> @@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
>  
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
>  	if (ret < 0) {
>  		v4l2_ctrl_handler_free(&ov2659->ctrls);
> diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
> index 8a8eb593fc23..2862244a6488 100644
> --- a/drivers/media/i2c/ov9650.c
> +++ b/drivers/media/i2c/ov9650.c
> @@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
>  		return ret;
>  
>  	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
>  	if (ret < 0)
>  		return ret;
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index abae37321c0c..3f55168cce47 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
>  
>  	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
>  	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
>  							state->sensor_pads);
> @@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
>  	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
>  	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
>  	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
> -	oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
>  							state->oif_pads);
> diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
> index d207ddce31b6..45f6e6f2585a 100644
> --- a/drivers/media/i2c/s5k4ecgx.c
> +++ b/drivers/media/i2c/s5k4ecgx.c
> @@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &priv->pad);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 0513196bd48c..22dfeadf7672 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
>  
>  static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
>  {
> -	return sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  }
>  
>  static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
> @@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
>  	if (ret < 0)
>  		goto err;
> @@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
>  
>  	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
>  	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
>  
>  	if (!ret)
> diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
> index 39a461f9d9bb..71162c02d6d7 100644
> --- a/drivers/media/i2c/s5k6aa.c
> +++ b/drivers/media/i2c/s5k6aa.c
> @@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
>  	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>  
>  	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
>  	if (ret)
>  		return ret;
> diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
> index 5aa49eb393a9..bb1f891a1eb6 100644
> --- a/drivers/media/i2c/smiapp/smiapp-core.c
> +++ b/drivers/media/i2c/smiapp/smiapp-core.c
> @@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
>  
>  	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
>  
> -	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
> +	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
>  
>  	/* final steps */
>  	smiapp_read_frame_fmt(sensor);
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 97eb97d9b662..ccef9621d147 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -108,7 +108,7 @@ static long media_device_enum_entities(struct media_device *mdev,
>  	u_ent.id = media_entity_id(ent);
>  	if (ent->name)
>  		strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
> -	u_ent.type = ent->type;
> +	u_ent.type = ent->function;
>  	u_ent.revision = ent->revision;
>  	u_ent.flags = ent->flags;
>  	u_ent.group_id = ent->group_id;
> @@ -614,8 +614,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
>  {
>  	int i;
>  
> -	if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
> -	    entity->type == MEDIA_ENT_T_UNKNOWN)
> +	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
> +	    entity->function == MEDIA_ENT_T_UNKNOWN)
>  		dev_warn(mdev->dev,
>  			 "Entity type for entity %s was not initialized!\n",
>  			 entity->name);
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
> index 8e14841bf445..8bee7313a497 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.c
> +++ b/drivers/media/platform/xilinx/xilinx-dma.c
> @@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
>  	while ((entity = media_entity_graph_walk_next(&graph))) {
>  		struct xvip_dma *dma;
>  
> -		if (entity->type != MEDIA_ENT_T_V4L2_VIDEO)
> +		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
>  			continue;
>  
>  		dma = to_xvip_dma(media_entity_to_video_device(entity));
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index 399c6712faf9..44a2ab3c85ab 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -263,7 +263,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 806b8d320bae..5c01f37cd0b8 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -1830,18 +1830,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
>  
>  		switch(AUVI_INPUT(i).type) {
>  		case AU0828_VMUX_COMPOSITE:
> -			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
> +			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
>  			break;
>  		case AU0828_VMUX_SVIDEO:
> -			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
> +			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
>  			break;
>  		case AU0828_VMUX_CABLE:
>  		case AU0828_VMUX_TELEVISION:
>  		case AU0828_VMUX_DVB:
> -			ent->type = MEDIA_ENT_T_CONN_RF;
> +			ent->function = MEDIA_ENT_T_CONN_RF;
>  			break;
>  		default: /* AU0828_VMUX_DEBUG */
> -			ent->type = MEDIA_ENT_T_CONN_TEST;
> +			ent->function = MEDIA_ENT_T_CONN_TEST;
>  			break;
>  		}
>  
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index c05aaef85491..b01d6bce3cf6 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1249,7 +1249,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
>  		return 0;
>  
>  	media_device_for_each_entity(entity, mdev) {
> -		switch (entity->type) {
> +		switch (entity->function) {
>  		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
>  			tuner = entity;
>  			break;
> diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
> index e8baff4d6290..ed4a49c850c7 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-video.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-video.c
> @@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
>  	 * this should be enough for the actual needs.
>  	 */
>  	media_device_for_each_entity(entity, mdev) {
> -		if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
> +		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
>  			decoder = entity;
>  			break;
>  		}
> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> index b90f2a52db96..e8fc5ec8fc35 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -698,7 +698,7 @@ register_client:
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
>  	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
> -	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
> +	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
>  	t->sd.entity.name = t->name;
>  
>  	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index 8429da66754a..2446b2d8fe66 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
>  	if (v4l2_dev->mdev) {
>  		/* Remove interfaces and interface links */
>  		media_devnode_remove(vdev->intf_devnode);
> -		if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN)
> +		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
>  			media_device_unregister_entity(&vdev->entity);
>  	}
>  #endif
> @@ -726,20 +726,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  	if (!vdev->v4l2_dev->mdev)
>  		return 0;
>  
> -	vdev->entity.type = MEDIA_ENT_T_UNKNOWN;
> +	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
>  
>  	switch (type) {
>  	case VFL_TYPE_GRABBER:
>  		intf_type = MEDIA_INTF_T_V4L_VIDEO;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
>  		break;
>  	case VFL_TYPE_VBI:
>  		intf_type = MEDIA_INTF_T_V4L_VBI;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_VBI;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
>  		break;
>  	case VFL_TYPE_SDR:
>  		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
> -		vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO;
> +		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
>  		break;
>  	case VFL_TYPE_RADIO:
>  		intf_type = MEDIA_INTF_T_V4L_RADIO;
> @@ -757,7 +757,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  		return 0;
>  	}
>  
> -	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
> +	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
>  		vdev->entity.name = vdev->name;
>  
>  		/* Needed just for backward compatibility with legacy MC API */
> @@ -784,7 +784,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  		return -ENOMEM;
>  	}
>  
> -	if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) {
> +	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
>  		struct media_link *link;
>  
>  		link = media_create_intf_link(&vdev->entity,
> diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> index 34c489fed55e..cf7b3cb9a373 100644
> --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
> +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> @@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
>  	if (ret < 0)
>  		return ERR_PTR(ret);
>  
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
>  
>  	ret = v4l2_flash_init_controls(v4l2_flash, config);
>  	if (ret < 0)
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index b3bcc8253182..b440cb66669c 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -535,9 +535,9 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
>  		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
>  	}
>  
> -	WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO,
> +	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
>  	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
> -	     pad->entity->type, pad->entity->name);
> +	     pad->entity->function, pad->entity->name);
>  
>  	return -EINVAL;
>  }
> @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
>  	sd->host_priv = NULL;
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	sd->entity.name = sd->name;
> -	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
> +	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
>  #endif
>  }
>  EXPORT_SYMBOL(v4l2_subdev_init);
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 8bdc10dcc5e7..10f7d5f0eb66 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -152,7 +152,8 @@ struct media_entity_operations {
>   *
>   * @graph_obj:	Embedded structure containing the media object common data.
>   * @name:	Entity name.
> - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> + * @function:	Entity main function, as defined at uapi/media.h
> + *		(MEDIA_ENT_F_*)
>   * @revision:	Entity revision - OBSOLETE - should be removed soon.
>   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
>   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
> @@ -179,7 +180,7 @@ struct media_entity_operations {
>  struct media_entity {
>  	struct media_gobj graph_obj;	/* must be first field in struct */
>  	const char *name;
> -	u32 type;
> +	u32 function;
>  	u32 revision;
>  	unsigned long flags;
>  	u32 group_id;
> @@ -277,7 +278,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
>  	if (!entity)
>  		return false;
>  
> -	switch (entity->type) {
> +	switch (entity->function) {
>  	case MEDIA_ENT_T_V4L2_VIDEO:
>  	case MEDIA_ENT_T_V4L2_VBI:
>  	case MEDIA_ENT_T_V4L2_SWRADIO:
> @@ -292,7 +293,7 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
>  	if (!entity)
>  		return false;
>  
> -	switch (entity->type) {
> +	switch (entity->function) {
>  	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
>  	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
>  	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
> 

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

* Re: [PATCH 14/18] [media] media-device: export the entity function via new ioctl
  2015-09-06 17:30   ` Mauro Carvalho Chehab
  (?)
@ 2015-09-11 15:26   ` Hans Verkuil
  -1 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:26 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: linux-api

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Now that entities have a main function, expose it via
> MEDIA_IOC_G_TOPOLOGY ioctl.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index ccef9621d147..32090030c342 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct media_device *mdev,
>  		/* Copy fields to userspace struct if not error */
>  		memset(&uentity, 0, sizeof(uentity));
>  		uentity.id = entity->graph_obj.id;
> +		uentity.function = entity->function;
>  		strncpy(uentity.name, entity->name,
>  			sizeof(uentity.name));
>  
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index 69433405aec2..d232cc680c67 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -284,7 +284,8 @@ struct media_links_enum {
>  struct media_v2_entity {
>  	__u32 id;
>  	char name[64];		/* FIXME: move to a property? (RFC says so) */
> -	__u16 reserved[14];
> +	__u32 function;		/* Main function of the entity */
> +	__u16 reserved[12];
>  };
>  
>  /* Should match the specific fields at media_intf_devnode */
> 


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

* Re: [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-11 15:36     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:36 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Sakari Ailus, Lars-Peter Clausen, Laurent Pinchart,
	Kyungmin Park, Heungjun Kim, Lad, Prabhakar, Andrzej Hajda,
	Hyun Kwon, Michal Simek, Sören Brinkmann, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Krzysztof Kozlowski,
	Boris BREZILLON, Joe Perches, Sylwester Nawrocki,
	Ricardo Ribalda Delgado, Guennadi Liakhovetski, Axel Lin,
	Shuah Khan, Julia Lawall, Markus Elfring, Matthias Schwarzott,
	Antti Palosaari, Olli Salonen, Tommi Rantala, Scott Jiang,
	Bryan Wu, Jacek Anaszewski, linux-arm-kernel, linux-api

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> and add the backward compatibility bits.
> 
> The changes at the .c files was generated by the following
> coccinelle script:
> 


> @@
> -MEDIA_ENT_T_DVB_DEMUX
> +MEDIA_ENT_F_MPEG_TS_DEMUX

I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

> @@
> @@
> -MEDIA_ENT_T_DVB_TSOUT
> +MEDIA_ENT_F_DTV_TSOUT

Shouldn't this be MEDIA_ENT_F_IO?

> @@
> @@
> -MEDIA_ENT_T_DVB_CA
> +MEDIA_ENT_F_DTV_CA
> @@
> @@
> -MEDIA_ENT_T_DVB_NET_DECAP
> +MEDIA_ENT_F_DTV_NET_DECAP
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index e925909bc99e..8527fc40e6a0 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  		if (!entity->name)
>  			return ret;
>  
> -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> +		entity->function = MEDIA_ENT_F_IO;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index d232cc680c67..90e90a6e62bf 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -46,87 +46,86 @@ struct media_device_info {
>   * Initial value to be used when a new entity is created
>   * Drivers should change it to something useful
>   */
> -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> +#define MEDIA_ENT_F_UNKNOWN	0x00000000
>  
>  /*
> - * Base numbers for entity types
> + * Base number ranges for entity functions
>   *
> - * Please notice that the huge gap of 16 bits for each base is overkill!
> - * 8 bits is more than enough to avoid starving entity types for each
> - * subsystem.
> - *
> - * However, It is kept this way just to avoid binary breakages with the
> - * namespace provided on legacy versions of this header.
> + * NOTE: those ranges and entity function number are spased just to

s/spased/phased/

> + * make easier to maintain this file. Userspace should not rely on

s/make/make it/

> + * the ranges to identify a group of function types, as newer
> + * functions can be added with any name within the full u32 range.
>   */
> -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> +#define MEDIA_ENT_F_BASE		0x00000000
> +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
>  
>  /*
> - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> - *	read()/write() data I/O associated with the V4L2 devnodes.
> + * DVB entities
>   */
> -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> -	/*
> -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> -	 * to be declared for FB, ALSA and DVB entities.
> -	 * As those values were never actually used in practice, we're just
> -	 * adding them as backward compatibility macros and keeping the
> -	 * numberspace clean here. This way, we avoid breaking compilation,
> -	 * in the case of having some userspace application using the old
> -	 * symbols.
> -	 */
> -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> -
> -/* V4L2 Sub-device entities */
> -
> -	/*
> -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> -	 * in order to preserve backward compatibility.
> -	 * Drivers should change to the proper subdev type before
> -	 * registering the entity.
> -	 */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> -	/* A converter of analogue video to its digital representation. */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> -	/* Tuner entity is actually both V4L2 and DVB subdev */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
>  
> -/* DVB entities */
> -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> -
> -/* Connectors */
> -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +/*
> + * Connectors
> + */
> +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
>  	/* For internal test signal generators and other debug connectors */
> -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> +
> +/*
> + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> + * with the legacy v1 API.The number range is out of range by purpose:
> + * several previously reserved numbers got excluded from this range.
> + *
> + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> + * in order to preserve backward compatibility.
> + * Drivers should change to the proper subdev type before
> + * registering the entity.
> + */
> +
> +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> +
> +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> +
> +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
>  
>  #ifndef __KERNEL__
> -/* Legacy symbols used to avoid userspace compilation breakages */
> +
> +/*
> + * Legacy symbols used to avoid userspace compilation breakages
> + *
> + * Those symbols map the entity function into types and should be
> + * used only on legacy programs for legacy hardware. Don't rely
> + * on those for MEDIA_IOC_G_TOPOLOGY.
> + */
>  #define MEDIA_ENT_TYPE_SHIFT		16
>  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
>  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
>  
> -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> -
> +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
>  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
>  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> +
> +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
>  #endif
>  
>  /* Entity flags */
> 

Overall I really like this.

Regards,

	Hans

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

* Re: [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-11 15:36     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:36 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Sakari Ailus, Lars-Peter Clausen, Laurent Pinchart,
	Kyungmin Park, Heungjun Kim, Lad, Prabhakar, Andrzej Hajda,
	Hyun Kwon, Michal Simek, Sören Brinkmann, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Krzysztof Kozlowski,
	Boris BREZILLON, Joe Perches, Sylwester Nawrocki,
	Ricardo Ribalda Delgado, Guennadi Liakhovetski, Axel Lin

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> and add the backward compatibility bits.
> 
> The changes at the .c files was generated by the following
> coccinelle script:
> 


> @@
> -MEDIA_ENT_T_DVB_DEMUX
> +MEDIA_ENT_F_MPEG_TS_DEMUX

I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

> @@
> @@
> -MEDIA_ENT_T_DVB_TSOUT
> +MEDIA_ENT_F_DTV_TSOUT

Shouldn't this be MEDIA_ENT_F_IO?

> @@
> @@
> -MEDIA_ENT_T_DVB_CA
> +MEDIA_ENT_F_DTV_CA
> @@
> @@
> -MEDIA_ENT_T_DVB_NET_DECAP
> +MEDIA_ENT_F_DTV_NET_DECAP
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index e925909bc99e..8527fc40e6a0 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  		if (!entity->name)
>  			return ret;
>  
> -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> +		entity->function = MEDIA_ENT_F_IO;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index d232cc680c67..90e90a6e62bf 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -46,87 +46,86 @@ struct media_device_info {
>   * Initial value to be used when a new entity is created
>   * Drivers should change it to something useful
>   */
> -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> +#define MEDIA_ENT_F_UNKNOWN	0x00000000
>  
>  /*
> - * Base numbers for entity types
> + * Base number ranges for entity functions
>   *
> - * Please notice that the huge gap of 16 bits for each base is overkill!
> - * 8 bits is more than enough to avoid starving entity types for each
> - * subsystem.
> - *
> - * However, It is kept this way just to avoid binary breakages with the
> - * namespace provided on legacy versions of this header.
> + * NOTE: those ranges and entity function number are spased just to

s/spased/phased/

> + * make easier to maintain this file. Userspace should not rely on

s/make/make it/

> + * the ranges to identify a group of function types, as newer
> + * functions can be added with any name within the full u32 range.
>   */
> -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> +#define MEDIA_ENT_F_BASE		0x00000000
> +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
>  
>  /*
> - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> - *	read()/write() data I/O associated with the V4L2 devnodes.
> + * DVB entities
>   */
> -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> -	/*
> -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> -	 * to be declared for FB, ALSA and DVB entities.
> -	 * As those values were never actually used in practice, we're just
> -	 * adding them as backward compatibility macros and keeping the
> -	 * numberspace clean here. This way, we avoid breaking compilation,
> -	 * in the case of having some userspace application using the old
> -	 * symbols.
> -	 */
> -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> -
> -/* V4L2 Sub-device entities */
> -
> -	/*
> -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> -	 * in order to preserve backward compatibility.
> -	 * Drivers should change to the proper subdev type before
> -	 * registering the entity.
> -	 */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> -	/* A converter of analogue video to its digital representation. */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> -	/* Tuner entity is actually both V4L2 and DVB subdev */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
>  
> -/* DVB entities */
> -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> -
> -/* Connectors */
> -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +/*
> + * Connectors
> + */
> +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
>  	/* For internal test signal generators and other debug connectors */
> -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> +
> +/*
> + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> + * with the legacy v1 API.The number range is out of range by purpose:
> + * several previously reserved numbers got excluded from this range.
> + *
> + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> + * in order to preserve backward compatibility.
> + * Drivers should change to the proper subdev type before
> + * registering the entity.
> + */
> +
> +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> +
> +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> +
> +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
>  
>  #ifndef __KERNEL__
> -/* Legacy symbols used to avoid userspace compilation breakages */
> +
> +/*
> + * Legacy symbols used to avoid userspace compilation breakages
> + *
> + * Those symbols map the entity function into types and should be
> + * used only on legacy programs for legacy hardware. Don't rely
> + * on those for MEDIA_IOC_G_TOPOLOGY.
> + */
>  #define MEDIA_ENT_TYPE_SHIFT		16
>  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
>  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
>  
> -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> -
> +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
>  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
>  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> +
> +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
>  #endif
>  
>  /* Entity flags */
> 

Overall I really like this.

Regards,

	Hans

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

* [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-09-11 15:36     ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> and add the backward compatibility bits.
> 
> The changes at the .c files was generated by the following
> coccinelle script:
> 


> @@
> -MEDIA_ENT_T_DVB_DEMUX
> +MEDIA_ENT_F_MPEG_TS_DEMUX

I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

> @@
> @@
> -MEDIA_ENT_T_DVB_TSOUT
> +MEDIA_ENT_F_DTV_TSOUT

Shouldn't this be MEDIA_ENT_F_IO?

> @@
> @@
> -MEDIA_ENT_T_DVB_CA
> +MEDIA_ENT_F_DTV_CA
> @@
> @@
> -MEDIA_ENT_T_DVB_NET_DECAP
> +MEDIA_ENT_F_DTV_NET_DECAP
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index e925909bc99e..8527fc40e6a0 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
>  		if (!entity->name)
>  			return ret;
>  
> -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> +		entity->function = MEDIA_ENT_F_IO;
>  		pads->flags = MEDIA_PAD_FL_SINK;
>  
>  		ret = media_entity_init(entity, 1, pads);
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index d232cc680c67..90e90a6e62bf 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -46,87 +46,86 @@ struct media_device_info {
>   * Initial value to be used when a new entity is created
>   * Drivers should change it to something useful
>   */
> -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> +#define MEDIA_ENT_F_UNKNOWN	0x00000000
>  
>  /*
> - * Base numbers for entity types
> + * Base number ranges for entity functions
>   *
> - * Please notice that the huge gap of 16 bits for each base is overkill!
> - * 8 bits is more than enough to avoid starving entity types for each
> - * subsystem.
> - *
> - * However, It is kept this way just to avoid binary breakages with the
> - * namespace provided on legacy versions of this header.
> + * NOTE: those ranges and entity function number are spased just to

s/spased/phased/

> + * make easier to maintain this file. Userspace should not rely on

s/make/make it/

> + * the ranges to identify a group of function types, as newer
> + * functions can be added with any name within the full u32 range.
>   */
> -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> +#define MEDIA_ENT_F_BASE		0x00000000
> +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
>  
>  /*
> - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> - *	read()/write() data I/O associated with the V4L2 devnodes.
> + * DVB entities
>   */
> -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> -	/*
> -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> -	 * to be declared for FB, ALSA and DVB entities.
> -	 * As those values were never actually used in practice, we're just
> -	 * adding them as backward compatibility macros and keeping the
> -	 * numberspace clean here. This way, we avoid breaking compilation,
> -	 * in the case of having some userspace application using the old
> -	 * symbols.
> -	 */
> -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> -
> -/* V4L2 Sub-device entities */
> -
> -	/*
> -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> -	 * in order to preserve backward compatibility.
> -	 * Drivers should change to the proper subdev type before
> -	 * registering the entity.
> -	 */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> -	/* A converter of analogue video to its digital representation. */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> -	/* Tuner entity is actually both V4L2 and DVB subdev */
> -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
>  
> -/* DVB entities */
> -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> -
> -/* Connectors */
> -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +/*
> + * Connectors
> + */
> +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
>  	/* For internal test signal generators and other debug connectors */
> -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> +
> +/*
> + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> + * with the legacy v1 API.The number range is out of range by purpose:
> + * several previously reserved numbers got excluded from this range.
> + *
> + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> + * in order to preserve backward compatibility.
> + * Drivers should change to the proper subdev type before
> + * registering the entity.
> + */
> +
> +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> +
> +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> +
> +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
>  
>  #ifndef __KERNEL__
> -/* Legacy symbols used to avoid userspace compilation breakages */
> +
> +/*
> + * Legacy symbols used to avoid userspace compilation breakages
> + *
> + * Those symbols map the entity function into types and should be
> + * used only on legacy programs for legacy hardware. Don't rely
> + * on those for MEDIA_IOC_G_TOPOLOGY.
> + */
>  #define MEDIA_ENT_TYPE_SHIFT		16
>  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
>  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
>  
> -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> -
> -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> -
> +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
>  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
>  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> +
> +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
>  #endif
>  
>  /* Entity flags */
> 

Overall I really like this.

Regards,

	Hans

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

* Re: [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function
  2015-09-06 17:31 ` [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Mauro Carvalho Chehab
@ 2015-09-11 15:38   ` Hans Verkuil
  0 siblings, 0 replies; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:38 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: Hans Verkuil

On 09/06/2015 07:31 PM, Mauro Carvalho Chehab wrote:
> Cleanup the code a little bit by moving the routine that creates
> links between DVR and demux to the I/O entitis into a separate
> function.
> 
> While here, fix the code to use strncmp() instead of strcmp().
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 8527fc40e6a0..ea76fe54e0e4 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -522,6 +522,28 @@ EXPORT_SYMBOL(dvb_unregister_device);
>  
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> +
> +static int dvb_create_io_intf_links(struct dvb_adapter *adap,
> +				    struct media_interface *intf,
> +				    char *name)
> +{
> +	struct media_device *mdev = adap->mdev;
> +	struct media_entity *entity;
> +	struct media_link *link;
> +
> +	media_device_for_each_entity(entity, mdev) {
> +		if (entity->function == MEDIA_ENT_F_IO) {
> +			if (strncmp(entity->name, name, strlen(name)))
> +				continue;
> +			link = media_create_intf_link(entity, intf,
> +						      MEDIA_LNK_FL_ENABLED);
> +			if (!link)
> +				return -ENOMEM;
> +		}
> +	}
> +	return 0;
> +}
> +
>  int dvb_create_media_graph(struct dvb_adapter *adap)
>  {
>  	struct media_device *mdev = adap->mdev;
> @@ -619,25 +641,15 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  			if (!link)
>  				return -ENOMEM;
>  		}
> -
> -		media_device_for_each_entity(entity, mdev) {
> -			if (entity->function == MEDIA_ENT_F_IO) {
> -				if (!strcmp(entity->name, DVR_TSOUT)) {
> -					link = media_create_intf_link(entity,
> -							intf,
> -							MEDIA_LNK_FL_ENABLED);
> -					if (!link)
> -						return -ENOMEM;
> -				}
> -				if (!strcmp(entity->name, DEMUX_TSOUT)) {
> -					link = media_create_intf_link(entity,
> -							intf,
> -							MEDIA_LNK_FL_ENABLED);
> -					if (!link)
> -						return -ENOMEM;
> -				}
> -				break;
> -			}
> +		if (intf->type == MEDIA_INTF_T_DVB_DVR) {
> +			ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT);
> +			if (ret)
> +				return ret;
> +		}
> +		if (intf->type == MEDIA_INTF_T_DVB_DEMUX) {
> +			ret = dvb_create_io_intf_links(adap, intf, DEMUX_TSOUT);
> +			if (ret)
> +				return ret;
>  		}
>  	}
>  	return 0;
> 


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

* Re: [PATCH 18/18] [media] dvbdev: Don't create indirect links
  2015-09-06 17:31 ` [PATCH 18/18] [media] dvbdev: Don't create indirect links Mauro Carvalho Chehab
@ 2015-09-11 15:48   ` Hans Verkuil
  2015-12-10 20:20     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 69+ messages in thread
From: Hans Verkuil @ 2015-09-11 15:48 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: Hans Verkuil

On 09/06/2015 07:31 PM, Mauro Carvalho Chehab wrote:
> Indirect links are those whose the interface indirectly controls

s/the//

> other functions.
> 
> There are two interfaces that have indirect controls at the DVB
> side:
> - the network interface, with also controls the demux;

s/with/which/

> - the DVR interface with also controls the demux.

ditto

> 
> One could argue that the frontend control to the tuner is indirect.
> Well, that's debateable. There's no way to create subdef interfaces

s/debateable/debatable/
s/subdef/subdev/

> for tuner and demod, as those devices are tightly coupled. So, it
> was decided that just one interface is the best to control both
> entities, and there's no plan (or easy way) to decouple both. So,
> the DVB frontend interface should link to both entities.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

With the typos fixed:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Note: I am not convinced that the dvr->demux indirect link isn't needed, but
it can be enabled later, so it's OK for me to keep it under #if 0 for now.

Regards,

	Hans

> 
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index ea76fe54e0e4..e9f24c1479dd 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -619,7 +619,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  		}
>  	}
>  
> -	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
> +	/* Create interface links for FE->tuner, DVR->demux and CA->ca */
>  	media_device_for_each_intf(intf, mdev) {
>  		if (intf->type == MEDIA_INTF_T_DVB_CA && ca) {
>  			link = media_create_intf_link(ca, intf,
> @@ -634,13 +634,19 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
>  			if (!link)
>  				return -ENOMEM;
>  		}
> -
> +#if 0
> +		/*
> +		 * Indirect link - let's not create yet, as we don't know how
> +		 *		   to handle indirect links, nor if this will
> +		 *		   actually be needed.
> +		 */
>  		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) {
>  			link = media_create_intf_link(demux, intf,
>  						      MEDIA_LNK_FL_ENABLED);
>  			if (!link)
>  				return -ENOMEM;
>  		}
> +#endif
>  		if (intf->type == MEDIA_INTF_T_DVB_DVR) {
>  			ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT);
>  			if (ret)
> 



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

* Re: [PATCH 14/18] [media] media-device: export the entity function via new ioctl
@ 2015-11-23 17:46     ` Laurent Pinchart
  0 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 17:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, linux-api

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:57 Mauro Carvalho Chehab wrote:
> Now that entities have a main function, expose it via
> MEDIA_IOC_G_TOPOLOGY ioctl.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index ccef9621d147..32090030c342 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct
> media_device *mdev, /* Copy fields to userspace struct if not error */
>  		memset(&uentity, 0, sizeof(uentity));
>  		uentity.id = entity->graph_obj.id;
> +		uentity.function = entity->function;
>  		strncpy(uentity.name, entity->name,
>  			sizeof(uentity.name));
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index 69433405aec2..d232cc680c67 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -284,7 +284,8 @@ struct media_links_enum {
>  struct media_v2_entity {
>  	__u32 id;
>  	char name[64];		/* FIXME: move to a property? (RFC says so) */
> -	__u16 reserved[14];
> +	__u32 function;		/* Main function of the entity */

Shouldn't we use kerneldoc instead of inline comments ?

Also, as this is the main function only, I'd mention that in the subject line. 
The implementation itself looks fine to me, I'll discuss the API over the 
documentation patch.

> +	__u16 reserved[12];
>  };
> 
>  /* Should match the specific fields at media_intf_devnode */

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 14/18] [media] media-device: export the entity function via new ioctl
@ 2015-11-23 17:46     ` Laurent Pinchart
  0 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 17:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, linux-api-u79uwXL29TY76Z2rM5mHXA

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:57 Mauro Carvalho Chehab wrote:
> Now that entities have a main function, expose it via
> MEDIA_IOC_G_TOPOLOGY ioctl.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index ccef9621d147..32090030c342 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct
> media_device *mdev, /* Copy fields to userspace struct if not error */
>  		memset(&uentity, 0, sizeof(uentity));
>  		uentity.id = entity->graph_obj.id;
> +		uentity.function = entity->function;
>  		strncpy(uentity.name, entity->name,
>  			sizeof(uentity.name));
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index 69433405aec2..d232cc680c67 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -284,7 +284,8 @@ struct media_links_enum {
>  struct media_v2_entity {
>  	__u32 id;
>  	char name[64];		/* FIXME: move to a property? (RFC says so) */
> -	__u16 reserved[14];
> +	__u32 function;		/* Main function of the entity */

Shouldn't we use kerneldoc instead of inline comments ?

Also, as this is the main function only, I'd mention that in the subject line. 
The implementation itself looks fine to me, I'll discuss the API over the 
documentation patch.

> +	__u16 reserved[12];
>  };
> 
>  /* Should match the specific fields at media_intf_devnode */

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
  2015-09-06 17:30   ` Mauro Carvalho Chehab
@ 2015-11-23 17:51     ` Laurent Pinchart
  -1 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 17:51 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Jonathan Corbet, Sakari Ailus,
	Kyungmin Park, Heungjun Kim, Lad, Prabhakar, Andrzej Hajda,
	Hyun Kwon, Michal Simek, Sören Brinkmann, Hans Verkuil,
	Krzysztof Kozlowski, Rafael Lourenço de Lima Chehab,
	Boris BREZILLON, Joe Perches, Sylwester Nawrocki, Shuah Khan,
	Markus Elfring, Matthias Schwarzott, Antti Palosaari,
	Olli Salonen, Tommi Rantala, Jacek Anaszewski, Bryan Wu,
	Lars-Peter Clausen, linux-doc, linux-arm-kernel

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:56 Mauro Carvalho Chehab wrote:
> Entities should have one or more functions. Calling it as a
> type proofed to not be correct, as an entity could eventually

s/proofed/proved/

> have more than one type.
> 
> So, rename the field as function.

s/as/to/

> Please notice that this patch doesn't extend support for
> multiple function entities. Such change will happen when
> we have real case drivers using it.
> 
> No functional changes.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

[snip]

> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 8bdc10dcc5e7..10f7d5f0eb66 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -152,7 +152,8 @@ struct media_entity_operations {
>   *
>   * @graph_obj:	Embedded structure containing the media object common data.
>   * @name:	Entity name.
> - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> + * @function:	Entity main function, as defined at uapi/media.h
> + *		(MEDIA_ENT_F_*)

I would squash this patch with "uapi/media.h: Rename entities types to 
functions" as they essentially touch the same lines. If you want to keep them 
separate I would use MEDIA_ENT_T_* here and rename it to MEDIA_ENT_F_* in 
"uapi/media.h: Rename entities types to functions".

>   * @revision:	Entity revision - OBSOLETE - should be removed soon.
>   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
>   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.

[snip]

-- 
Regards,

Laurent Pinchart


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

* [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
@ 2015-11-23 17:51     ` Laurent Pinchart
  0 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 17:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:56 Mauro Carvalho Chehab wrote:
> Entities should have one or more functions. Calling it as a
> type proofed to not be correct, as an entity could eventually

s/proofed/proved/

> have more than one type.
> 
> So, rename the field as function.

s/as/to/

> Please notice that this patch doesn't extend support for
> multiple function entities. Such change will happen when
> we have real case drivers using it.
> 
> No functional changes.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

[snip]

> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 8bdc10dcc5e7..10f7d5f0eb66 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -152,7 +152,8 @@ struct media_entity_operations {
>   *
>   * @graph_obj:	Embedded structure containing the media object common data.
>   * @name:	Entity name.
> - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> + * @function:	Entity main function, as defined at uapi/media.h
> + *		(MEDIA_ENT_F_*)

I would squash this patch with "uapi/media.h: Rename entities types to 
functions" as they essentially touch the same lines. If you want to keep them 
separate I would use MEDIA_ENT_T_* here and rename it to MEDIA_ENT_F_* in 
"uapi/media.h: Rename entities types to functions".

>   * @revision:	Entity revision - OBSOLETE - should be removed soon.
>   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
>   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.

[snip]

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 12/18] [media] media-entity: must check media_create_pad_link()
  2015-09-06 17:30 ` [PATCH 12/18] [media] media-entity: must check media_create_pad_link() Mauro Carvalho Chehab
  2015-09-11 15:24   ` Hans Verkuil
@ 2015-11-23 17:54   ` Laurent Pinchart
  2015-12-10 19:13     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 17:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:55 Mauro Carvalho Chehab wrote:
> Drivers should check if media_create_pad_link() actually
> worked.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 62f882d872b1..8bdc10dcc5e7 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -348,8 +348,9 @@ int media_entity_init(struct media_entity *entity, u16
> num_pads, struct media_pad *pads);
>  void media_entity_cleanup(struct media_entity *entity);
> 
> -int media_create_pad_link(struct media_entity *source, u16 source_pad,
> -		struct media_entity *sink, u16 sink_pad, u32 flags);
> +__must_check int media_create_pad_link(struct media_entity *source,
> +			u16 source_pad,	struct media_entity *sink,

s/,\t/, /

> +			u16 sink_pad, u32 flags);

And it would make sense to squash this with the patch that introduces 
media_create_pad_link().

>  void __media_entity_remove_links(struct media_entity *entity);
>  void media_entity_remove_links(struct media_entity *entity);

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
@ 2015-11-23 18:09     ` Laurent Pinchart
  0 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 18:09 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, linux-api

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:49 Mauro Carvalho Chehab wrote:
> Add entities to represent the connectors that exists inside a
> hybrid TV device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index b17f6763aff4..69433405aec2 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -61,6 +61,7 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_BASE		0x00000000
>  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
>  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> 
>  /*
>   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> @@ -105,6 +106,13 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
>  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> 
> +/* Connectors */
> +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +	/* For internal test signal generators and other debug connectors */

No need to a \t at the beginning of the line.

> +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)

I'd like to see more information about this.

When later renaming types to functions you rename this type as well, and I'm 
still not convinced that we shouldn't have both types and functions.

Let's discuss these topics and the one below on the documentation patches.

>  #ifndef __KERNEL__
>  /* Legacy symbols used to avoid userspace compilation breakages */
>  #define MEDIA_ENT_TYPE_SHIFT		16
> @@ -121,9 +129,9 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
>  #endif
> 
> -/* Entity types */
> -
> +/* Entity flags */
>  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)

Ditto, I'm not sure about the use cases.

>  struct media_entity_desc {
>  	__u32 id;

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
@ 2015-11-23 18:09     ` Laurent Pinchart
  0 siblings, 0 replies; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 18:09 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, linux-api-u79uwXL29TY76Z2rM5mHXA

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:49 Mauro Carvalho Chehab wrote:
> Add entities to represent the connectors that exists inside a
> hybrid TV device.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> 
> diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> index b17f6763aff4..69433405aec2 100644
> --- a/include/uapi/linux/media.h
> +++ b/include/uapi/linux/media.h
> @@ -61,6 +61,7 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_BASE		0x00000000
>  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
>  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> 
>  /*
>   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> @@ -105,6 +106,13 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
>  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> 
> +/* Connectors */
> +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> +	/* For internal test signal generators and other debug connectors */

No need to a \t at the beginning of the line.

> +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)

I'd like to see more information about this.

When later renaming types to functions you rename this type as well, and I'm 
still not convinced that we shouldn't have both types and functions.

Let's discuss these topics and the one below on the documentation patches.

>  #ifndef __KERNEL__
>  /* Legacy symbols used to avoid userspace compilation breakages */
>  #define MEDIA_ENT_TYPE_SHIFT		16
> @@ -121,9 +129,9 @@ struct media_device_info {
>  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
>  #endif
> 
> -/* Entity types */
> -
> +/* Entity flags */
>  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)

Ditto, I'm not sure about the use cases.

>  struct media_entity_desc {
>  	__u32 id;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 05/18] [media] media-controller: enable all interface links at init
  2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
  2015-09-11 15:18   ` Hans Verkuil
@ 2015-11-23 19:46   ` Laurent Pinchart
  2015-12-10 11:37     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 19:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Hans Verkuil, Sakari Ailus

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:48 Mauro Carvalho Chehab wrote:
> Interface links are normally enabled, meaning that the interfaces are
> bound to the entities. So, any ioctl send to the interface are reflected

s/send/sent/

> at the entities managed by the interface.
> 
> However, when a device is usage, other interfaces for the same hardware

s/usage/in use/

> could be decoupled from the entities linked to them, because the
> hardware may have some parts busy.
> 
> That's for example, what happens when an hybrid TV device is in usage.

s/usage/use/

> If it is streaming analog TV or capturing signals from S-Video/Composite
> connectors, typically the digital part of the hardware can't be used and
> vice-versa.
> 
> This is generally due to some internal hardware or firmware limitation,
> that it is not easily mapped via data pipelines.
> 
> What the Kernel drivers do internally is that they decouple the hardware
> from the interface. So, all changes, if allowed, are done only at some
> interface cache, but not physically changed at the hardware.
> 
> The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data
> links. So, let's use the same flag to indicate if ether the interface

s/ether/either/

> to entity link is bound/enabled or not.

I believe we'll need to experiment with the interface links to see what's 
really needed there. As a general rule I'd like to avoid exposing too much 
information to userspace without a clear indication that the information is 
actually needed, as it's always easier to expose additional information later 
than to remove information already exposed.

For this reason I'd like to see as a first step how we would do in userspace 
without making those links dynamic. If we then realize that we're lacking 
information we'll decide on the best course of action and on exactly what to 
expose and how to expose it, using concrete userspace use cases.

> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c
> b/drivers/media/dvb-core/dvbdev.c index a8e7e2398f7a..5c4fb41060b4 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -396,7 +396,8 @@ static void dvb_register_media_device(struct dvb_device
> *dvbdev, if (!dvbdev->entity || !dvbdev->intf_devnode)
>  		return;
> 
> -	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0);
> +	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
> +			       MEDIA_LNK_FL_ENABLED);
> 
>  #endif
>  }
> @@ -583,20 +584,24 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
>  	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca 
*/
> media_device_for_each_intf(intf, mdev) {
>  		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
> -			media_create_intf_link(ca, intf, 0);
> +			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
> 
>  		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
> -			media_create_intf_link(tuner, intf, 0);
> +			media_create_intf_link(tuner, intf,
> +					       MEDIA_LNK_FL_ENABLED);
> 
>  		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
> -			media_create_intf_link(demux, intf, 0);
> +			media_create_intf_link(demux, intf,
> +					       MEDIA_LNK_FL_ENABLED);
> 
>  		media_device_for_each_entity(entity, mdev) {
>  			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
>  				if (!strcmp(entity->name, DVR_TSOUT))
> -					media_create_intf_link(entity, intf, 0);
> +					media_create_intf_link(entity, intf,
> +							       MEDIA_LNK_FL_ENABLED);
>  				if (!strcmp(entity->name, DEMUX_TSOUT))
> -					media_create_intf_link(entity, intf, 0);
> +					media_create_intf_link(entity, intf,
> +							       MEDIA_LNK_FL_ENABLED);
>  				break;
>  			}
>  		}
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c
> b/drivers/media/v4l2-core/v4l2-dev.c index 07123dd569c4..8429da66754a
> 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -788,7 +788,8 @@ static int video_register_media_controller(struct
> video_device *vdev, int type) struct media_link *link;
> 
>  		link = media_create_intf_link(&vdev->entity,
> -					      &vdev->intf_devnode->intf, 0);
> +					      &vdev->intf_devnode->intf,
> +					      MEDIA_LNK_FL_ENABLED);
>  		if (!link) {
>  			media_devnode_remove(vdev->intf_devnode);
>  			media_device_unregister_entity(&vdev->entity);
> diff --git a/drivers/media/v4l2-core/v4l2-device.c
> b/drivers/media/v4l2-core/v4l2-device.c index e788a085ba96..bb58d90fde5e
> 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -256,7 +256,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device
> *v4l2_dev)
> 
>  			link = media_create_intf_link(&sd->entity,
>  						      &vdev->intf_devnode->intf,
> -						      0);
> +						      MEDIA_LNK_FL_ENABLED);
>  			if (!link)
>  				goto clean_up;
>  		}

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
  2015-09-11 14:58   ` Hans Verkuil
@ 2015-11-23 19:56   ` Laurent Pinchart
  2015-11-24 10:57     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 19:56 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:47 Mauro Carvalho Chehab wrote:
> Due to the graph traversal algorithm currently in usage, we
> need a copy of all data links. Those backlinks should not be
> send to userspace, as otherwise, all links there will be
> duplicated.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 0238885fcc74..97eb97d9b662 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -333,6 +333,9 @@ static long __media_device_get_topology(struct
> media_device *mdev, /* Get links and number of links */
>  	i = 0;
>  	media_device_for_each_link(link, mdev) {
> +		if (link->is_backlink)
> +			continue;
> +
>  		i++;
> 
>  		if (ret || !topo->links)
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index cd4d767644df..4868b8269204 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -648,6 +648,7 @@ media_create_pad_link(struct media_entity *source, u16
> source_pad, backlink->source = &source->pads[source_pad];
>  	backlink->sink = &sink->pads[sink_pad];
>  	backlink->flags = flags;
> +	backlink->is_backlink = true;
> 
>  	/* Initialize graph object embedded at the new link */
>  	media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index e1a89899deef..3d389f142a1d 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -96,6 +96,7 @@ struct media_pipeline {
>   * @reverse:	Pointer to the link for the reverse direction of a pad to 
pad
>   *		link.
>   * @flags:	Link flags, as defined at uapi/media.h (MEDIA_LNK_FL_*)
> + * @is_backlink: Indicate if the link is a backlink.
>   */
>  struct media_link {
>  	struct media_gobj graph_obj;
> @@ -112,6 +113,7 @@ struct media_link {
>  	};
>  	struct media_link *reverse;
>  	unsigned long flags;
> +	bool is_backlink;

I agree with the purpose of this patch (and as stated for other patches in the 
series I believe you should squash it with the patch that introduces the 
G_TOPOLOGY ioctl) but I won't whether you couldn't do with the additional 
variable by adding a flag for backlinks (flag that wouldn't be shown to 
userspace).

Now that I think about it an even better implementation could be to avoid 
creating backlinks at all. As links are now dynamically allocated you could 
have two struct list_head in the link structure, one for the source and one 
for the sink. It sounds too easy to be true, I wonder if I'm overlooking 
something.

>  };
> 
>  /**

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 01/18] [media] tuner-core: add an input pad
  2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
  2015-09-11 14:48   ` Hans Verkuil
@ 2015-11-23 20:01   ` Laurent Pinchart
  2015-11-24 11:00     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 69+ messages in thread
From: Laurent Pinchart @ 2015-11-23 20:01 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Shuah Khan,
	Matthias Schwarzott, Antti Palosaari, Olli Salonen,
	Tommi Rantala, Lad, Prabhakar, Sakari Ailus, Krzysztof Kozlowski

Hi Mauro,

Thank you for the patch.

On Sunday 06 September 2015 14:30:44 Mauro Carvalho Chehab wrote:
> Tuners actually have at least one connector on its
> input.
> 
> Add a PAD to connect it.

The patch looks fine to me, but have you checked that there are no driver 
instantiating a tuner that would get confused by this additional pad, for 
instance in graph traversal code ?

Additionally it should be documented somewhere that drivers instantiating 
tuners are responsible for creating and linking a connector to the tuner 
input.

> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/dvb-core/dvbdev.c
> b/drivers/media/dvb-core/dvbdev.c index f00f1a5f279c..a8e7e2398f7a 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -34,6 +34,9 @@
>  #include <linux/mutex.h>
>  #include "dvbdev.h"
> 
> +/* Due to enum tuner_pad_index */
> +#include <media/tuner.h>
> +
>  static DEFINE_MUTEX(dvbdev_mutex);
>  static int dvbdev_debug;
> 
> @@ -552,7 +555,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
>  	}
> 
>  	if (tuner && demod)
> -		media_create_pad_link(tuner, 0, demod, 0, 0);
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
> 
>  	if (demod && demux)
>  		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/usb/au0828/au0828-core.c
> b/drivers/media/usb/au0828/au0828-core.c index e28cabe65934..f54c7d10f350
> 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -27,6 +27,9 @@
>  #include <media/v4l2-common.h>
>  #include <linux/mutex.h>
> 
> +/* Due to enum tuner_pad_index */
> +#include <media/tuner.h>
> +
>  /*
>   * 1 = General debug messages
>   * 2 = USB handling
> @@ -260,7 +263,7 @@ static void au0828_create_media_graph(struct au0828_dev
> *dev) return;
> 
>  	if (tuner)
> -		media_create_pad_link(tuner, 0, decoder, 0,
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
>  				      MEDIA_LNK_FL_ENABLED);
>  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
>  			      MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c
> b/drivers/media/usb/cx231xx/cx231xx-cards.c index
> 3b5c9ae39ad3..1070d87efc65 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1264,7 +1264,7 @@ static void cx231xx_create_media_graph(struct cx231xx
> *dev) return;
> 
>  	if (tuner)
> -		media_create_pad_link(tuner, 0, decoder, 0,
> +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
>  					 MEDIA_LNK_FL_ENABLED);
>  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
>  				 MEDIA_LNK_FL_ENABLED);
> diff --git a/drivers/media/v4l2-core/tuner-core.c
> b/drivers/media/v4l2-core/tuner-core.c index 100b8f069640..b90f2a52db96
> 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -134,8 +134,9 @@ struct tuner {
>  	unsigned int        type; /* chip type id */
>  	void                *config;
>  	const char          *name;
> +
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> -	struct media_pad	pad;
> +	struct media_pad	pad[TUNER_NUM_PADS];
>  #endif
>  };
> 
> @@ -695,11 +696,12 @@ static int tuner_probe(struct i2c_client *client,
>  	/* Should be just before return */
>  register_client:
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> -	t->pad.flags = MEDIA_PAD_FL_SOURCE;
> +	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
> +	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
>  	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
>  	t->sd.entity.name = t->name;
> 
> -	ret = media_entity_init(&t->sd.entity, 1, &t->pad);
> +	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
>  	if (ret < 0) {
>  		tuner_err("failed to initialize media entity!\n");
>  		kfree(t);
> diff --git a/include/media/tuner.h b/include/media/tuner.h
> index b46ebb48fe74..95835c8069dd 100644
> --- a/include/media/tuner.h
> +++ b/include/media/tuner.h
> @@ -25,6 +25,14 @@
> 
>  #include <linux/videodev2.h>
> 
> +/* Tuner PADs */
> +/* FIXME: is this the right place for it? */
> +enum tuner_pad_index {
> +	TUNER_PAD_RF_INPUT,
> +	TUNER_PAD_IF_OUTPUT,
> +	TUNER_NUM_PADS
> +};
> +
>  #define ADDR_UNSET (255)
> 
>  #define TUNER_TEMIC_PAL			0        /* 4002 FH5 (3X 7756, 9483) */

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 14/18] [media] media-device: export the entity function via new ioctl
  2015-11-23 17:46     ` Laurent Pinchart
@ 2015-11-24 10:27       ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 10:27 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List, linux-api

Em Mon, 23 Nov 2015 19:46:22 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:57 Mauro Carvalho Chehab wrote:
> > Now that entities have a main function, expose it via
> > MEDIA_IOC_G_TOPOLOGY ioctl.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> > index ccef9621d147..32090030c342 100644
> > --- a/drivers/media/media-device.c
> > +++ b/drivers/media/media-device.c
> > @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct
> > media_device *mdev, /* Copy fields to userspace struct if not error */
> >  		memset(&uentity, 0, sizeof(uentity));
> >  		uentity.id = entity->graph_obj.id;
> > +		uentity.function = entity->function;
> >  		strncpy(uentity.name, entity->name,
> >  			sizeof(uentity.name));
> > 
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index 69433405aec2..d232cc680c67 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -284,7 +284,8 @@ struct media_links_enum {
> >  struct media_v2_entity {
> >  	__u32 id;
> >  	char name[64];		/* FIXME: move to a property? (RFC says so) */
> > -	__u16 reserved[14];
> > +	__u32 function;		/* Main function of the entity */
> 
> Shouldn't we use kerneldoc instead of inline comments ?

We don't use kernel-doc for uAPI. Instead, we document those via the
media infrastructure DocBook.

I don't object to use the same format here, but adding the uAPI stuff
to both device-drivers.xml and media_api.xml doesn't seem right.

That's said, we may eventually change the media infrastructure DocBook
to also run the kernel-doc script and benefit of kernel-doc markups
also for the uAPI, but this is out of the scope of this work, and would
take some time to do it.

So, at least for now, I would keep the comments like the above.

> 
> Also, as this is the main function only, I'd mention that in the subject line. 

OK.

> The implementation itself looks fine to me, I'll discuss the API over the 
> documentation patch.

Ok.
> 
> > +	__u16 reserved[12];
> >  };
> > 
> >  /* Should match the specific fields at media_intf_devnode */
> 

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

* Re: [PATCH 14/18] [media] media-device: export the entity function via new ioctl
@ 2015-11-24 10:27       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 10:27 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, linux-api-u79uwXL29TY76Z2rM5mHXA

Em Mon, 23 Nov 2015 19:46:22 +0200
Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:57 Mauro Carvalho Chehab wrote:
> > Now that entities have a main function, expose it via
> > MEDIA_IOC_G_TOPOLOGY ioctl.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> > 
> > diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> > index ccef9621d147..32090030c342 100644
> > --- a/drivers/media/media-device.c
> > +++ b/drivers/media/media-device.c
> > @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct
> > media_device *mdev, /* Copy fields to userspace struct if not error */
> >  		memset(&uentity, 0, sizeof(uentity));
> >  		uentity.id = entity->graph_obj.id;
> > +		uentity.function = entity->function;
> >  		strncpy(uentity.name, entity->name,
> >  			sizeof(uentity.name));
> > 
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index 69433405aec2..d232cc680c67 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -284,7 +284,8 @@ struct media_links_enum {
> >  struct media_v2_entity {
> >  	__u32 id;
> >  	char name[64];		/* FIXME: move to a property? (RFC says so) */
> > -	__u16 reserved[14];
> > +	__u32 function;		/* Main function of the entity */
> 
> Shouldn't we use kerneldoc instead of inline comments ?

We don't use kernel-doc for uAPI. Instead, we document those via the
media infrastructure DocBook.

I don't object to use the same format here, but adding the uAPI stuff
to both device-drivers.xml and media_api.xml doesn't seem right.

That's said, we may eventually change the media infrastructure DocBook
to also run the kernel-doc script and benefit of kernel-doc markups
also for the uAPI, but this is out of the scope of this work, and would
take some time to do it.

So, at least for now, I would keep the comments like the above.

> 
> Also, as this is the main function only, I'd mention that in the subject line. 

OK.

> The implementation itself looks fine to me, I'll discuss the API over the 
> documentation patch.

Ok.
> 
> > +	__u16 reserved[12];
> >  };
> > 
> >  /* Should match the specific fields at media_intf_devnode */
> 

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

* Re: [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
  2015-11-23 17:51     ` Laurent Pinchart
@ 2015-11-24 10:32       ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 10:32 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, Jonathan Corbet, Sakari Ailus,
	Kyungmin Park, Heungjun Kim, Lad, Prabhakar, Andrzej Hajda,
	Hyun Kwon, Michal Simek, Sören Brinkmann, Hans Verkuil,
	Krzysztof Kozlowski, Rafael Lourenço de Lima Chehab,
	Boris BREZILLON, Joe Perches, Sylwester Nawrocki, Shuah Khan,
	Markus Elfring, Matthias Schwarzott, Antti Palosaari,
	Olli Salonen, Tommi Rantala, Jacek Anaszewski, Bryan Wu,
	Lars-Peter Clausen, linux-doc, linux-arm-kernel

Em Mon, 23 Nov 2015 19:51:41 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:56 Mauro Carvalho Chehab wrote:
> > Entities should have one or more functions. Calling it as a
> > type proofed to not be correct, as an entity could eventually
> 
> s/proofed/proved/
> 
> > have more than one type.
> > 
> > So, rename the field as function.
> 
> s/as/to/
> 
> > Please notice that this patch doesn't extend support for
> > multiple function entities. Such change will happen when
> > we have real case drivers using it.
> > 
> > No functional changes.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> [snip]
> 
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 8bdc10dcc5e7..10f7d5f0eb66 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -152,7 +152,8 @@ struct media_entity_operations {
> >   *
> >   * @graph_obj:	Embedded structure containing the media object common data.
> >   * @name:	Entity name.
> > - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> > + * @function:	Entity main function, as defined at uapi/media.h
> > + *		(MEDIA_ENT_F_*)
> 
> I would squash this patch with "uapi/media.h: Rename entities types to 
> functions" as they essentially touch the same lines. 

They touch at the same lines, but the rationale is different. Keeping
it separate is, IMHO, better, as one logical change per patch is preferred.

> If you want to keep them 
> separate I would use MEDIA_ENT_T_* here and rename it to MEDIA_ENT_F_* in 
> "uapi/media.h: Rename entities types to functions".

IMHO, that would be confusing, as this patch would be incomplete, and
the other one would be renaming from MEDIA_ENT_T_* to MEDIA_ENT_F_*
due to a reason that it is on a different patch.

> 
> >   * @revision:	Entity revision - OBSOLETE - should be removed soon.
> >   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
> >   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
> 
> [snip]
> 

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

* [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function
@ 2015-11-24 10:32       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

Em Mon, 23 Nov 2015 19:51:41 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:56 Mauro Carvalho Chehab wrote:
> > Entities should have one or more functions. Calling it as a
> > type proofed to not be correct, as an entity could eventually
> 
> s/proofed/proved/
> 
> > have more than one type.
> > 
> > So, rename the field as function.
> 
> s/as/to/
> 
> > Please notice that this patch doesn't extend support for
> > multiple function entities. Such change will happen when
> > we have real case drivers using it.
> > 
> > No functional changes.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> [snip]
> 
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 8bdc10dcc5e7..10f7d5f0eb66 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -152,7 +152,8 @@ struct media_entity_operations {
> >   *
> >   * @graph_obj:	Embedded structure containing the media object common data.
> >   * @name:	Entity name.
> > - * @type:	Entity type, as defined at uapi/media.h (MEDIA_ENT_T_*)
> > + * @function:	Entity main function, as defined at uapi/media.h
> > + *		(MEDIA_ENT_F_*)
> 
> I would squash this patch with "uapi/media.h: Rename entities types to 
> functions" as they essentially touch the same lines. 

They touch at the same lines, but the rationale is different. Keeping
it separate is, IMHO, better, as one logical change per patch is preferred.

> If you want to keep them 
> separate I would use MEDIA_ENT_T_* here and rename it to MEDIA_ENT_F_* in 
> "uapi/media.h: Rename entities types to functions".

IMHO, that would be confusing, as this patch would be incomplete, and
the other one would be renaming from MEDIA_ENT_T_* to MEDIA_ENT_F_*
due to a reason that it is on a different patch.

> 
> >   * @revision:	Entity revision - OBSOLETE - should be removed soon.
> >   * @flags:	Entity flags, as defined at uapi/media.h (MEDIA_ENT_FL_*)
> >   * @group_id:	Entity group ID - OBSOLETE - should be removed soon.
> 
> [snip]
> 

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

* Re: [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl
  2015-11-23 19:56   ` Laurent Pinchart
@ 2015-11-24 10:57     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 10:57 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

Em Mon, 23 Nov 2015 21:56:50 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:47 Mauro Carvalho Chehab wrote:
> > Due to the graph traversal algorithm currently in usage, we
> > need a copy of all data links. Those backlinks should not be
> > send to userspace, as otherwise, all links there will be
> > duplicated.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> > index 0238885fcc74..97eb97d9b662 100644
> > --- a/drivers/media/media-device.c
> > +++ b/drivers/media/media-device.c
> > @@ -333,6 +333,9 @@ static long __media_device_get_topology(struct
> > media_device *mdev, /* Get links and number of links */
> >  	i = 0;
> >  	media_device_for_each_link(link, mdev) {
> > +		if (link->is_backlink)
> > +			continue;
> > +
> >  		i++;
> > 
> >  		if (ret || !topo->links)
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index cd4d767644df..4868b8269204 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -648,6 +648,7 @@ media_create_pad_link(struct media_entity *source, u16
> > source_pad, backlink->source = &source->pads[source_pad];
> >  	backlink->sink = &sink->pads[sink_pad];
> >  	backlink->flags = flags;
> > +	backlink->is_backlink = true;
> > 
> >  	/* Initialize graph object embedded at the new link */
> >  	media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index e1a89899deef..3d389f142a1d 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -96,6 +96,7 @@ struct media_pipeline {
> >   * @reverse:	Pointer to the link for the reverse direction of a pad to 
> pad
> >   *		link.
> >   * @flags:	Link flags, as defined at uapi/media.h (MEDIA_LNK_FL_*)
> > + * @is_backlink: Indicate if the link is a backlink.
> >   */
> >  struct media_link {
> >  	struct media_gobj graph_obj;
> > @@ -112,6 +113,7 @@ struct media_link {
> >  	};
> >  	struct media_link *reverse;
> >  	unsigned long flags;
> > +	bool is_backlink;
> 
> I agree with the purpose of this patch (and as stated for other patches in the 
> series I believe you should squash it with the patch that introduces the 
> G_TOPOLOGY ioctl) but I won't whether you couldn't do with the additional 
> variable by adding a flag for backlinks (flag that wouldn't be shown to 
> userspace).
> 
> Now that I think about it an even better implementation could be to avoid 
> creating backlinks at all. As links are now dynamically allocated you could 
> have two struct list_head in the link structure, one for the source and one 
> for the sink. It sounds too easy to be true, I wonder if I'm overlooking 
> something.

I tried that. This was actually one of my pans. However, it is not as
trivial as it seems. I explored several different alternatives:

1) we could have two lists at struct media_entity, one for links and another
one for backlinks:

struct media_link {
	...
	struct list_head list;
	...
};

struct media_entity {
	...
	struct list_head links;
	struct list_head backlinks;
	...
};

And add the link to either one of the list. However, in such case,
container_of() would not work, because the offset of the data at the 
struct media_entity will be different, if the link is at the links
or backlinks list.

2) to have 2 lists also at struct media_link, one for the links and
another one for the backlinks, but this will require non trivial
changes at the graph traversal logic.

I can foresee some other alternatives that I didn't try yet:

- to use a separate data struct for the backlinks, like:
	struct media_obj_group {
		struct *media_object;
		struct list_head list;
	}
  and use this to store backlinks. Again, would require nontrivial
  changes at the graph traversal logic and would end by spending
  some extra memory for the backlinks;

- using the same structs as already defined, patching all routines
  that use links to add the capability for them to identify if the
  link is actually a backlink. This would be non-trivial and may
  be messy.

So, while I would love to get rid of backlinks, fixing it is not
trivial at all.

Regards,
Mauro

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

* Re: [PATCH 01/18] [media] tuner-core: add an input pad
  2015-11-23 20:01   ` Laurent Pinchart
@ 2015-11-24 11:00     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-11-24 11:00 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Shuah Khan,
	Matthias Schwarzott, Antti Palosaari, Olli Salonen,
	Tommi Rantala, Lad, Prabhakar, Sakari Ailus, Krzysztof Kozlowski

Em Mon, 23 Nov 2015 22:01:23 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:44 Mauro Carvalho Chehab wrote:
> > Tuners actually have at least one connector on its
> > input.
> > 
> > Add a PAD to connect it.
> 
> The patch looks fine to me, but have you checked that there are no driver 
> instantiating a tuner that would get confused by this additional pad, for 
> instance in graph traversal code ?

The only drivers that use tuners ATM are the hybrid TV drivers that
we're adding. My plan is to have all of those fixed in time for 4.5.

> Additionally it should be documented somewhere that drivers instantiating 
> tuners are responsible for creating and linking a connector to the tuner 
> input.

True. I'll add it at the documentation.

> 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c
> > b/drivers/media/dvb-core/dvbdev.c index f00f1a5f279c..a8e7e2398f7a 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -34,6 +34,9 @@
> >  #include <linux/mutex.h>
> >  #include "dvbdev.h"
> > 
> > +/* Due to enum tuner_pad_index */
> > +#include <media/tuner.h>
> > +
> >  static DEFINE_MUTEX(dvbdev_mutex);
> >  static int dvbdev_debug;
> > 
> > @@ -552,7 +555,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
> >  	}
> > 
> >  	if (tuner && demod)
> > -		media_create_pad_link(tuner, 0, demod, 0, 0);
> > +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0);
> > 
> >  	if (demod && demux)
> >  		media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
> > diff --git a/drivers/media/usb/au0828/au0828-core.c
> > b/drivers/media/usb/au0828/au0828-core.c index e28cabe65934..f54c7d10f350
> > 100644
> > --- a/drivers/media/usb/au0828/au0828-core.c
> > +++ b/drivers/media/usb/au0828/au0828-core.c
> > @@ -27,6 +27,9 @@
> >  #include <media/v4l2-common.h>
> >  #include <linux/mutex.h>
> > 
> > +/* Due to enum tuner_pad_index */
> > +#include <media/tuner.h>
> > +
> >  /*
> >   * 1 = General debug messages
> >   * 2 = USB handling
> > @@ -260,7 +263,7 @@ static void au0828_create_media_graph(struct au0828_dev
> > *dev) return;
> > 
> >  	if (tuner)
> > -		media_create_pad_link(tuner, 0, decoder, 0,
> > +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
> >  				      MEDIA_LNK_FL_ENABLED);
> >  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> >  			      MEDIA_LNK_FL_ENABLED);
> > diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c
> > b/drivers/media/usb/cx231xx/cx231xx-cards.c index
> > 3b5c9ae39ad3..1070d87efc65 100644
> > --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> > +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> > @@ -1264,7 +1264,7 @@ static void cx231xx_create_media_graph(struct cx231xx
> > *dev) return;
> > 
> >  	if (tuner)
> > -		media_create_pad_link(tuner, 0, decoder, 0,
> > +		media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
> >  					 MEDIA_LNK_FL_ENABLED);
> >  	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
> >  				 MEDIA_LNK_FL_ENABLED);
> > diff --git a/drivers/media/v4l2-core/tuner-core.c
> > b/drivers/media/v4l2-core/tuner-core.c index 100b8f069640..b90f2a52db96
> > 100644
> > --- a/drivers/media/v4l2-core/tuner-core.c
> > +++ b/drivers/media/v4l2-core/tuner-core.c
> > @@ -134,8 +134,9 @@ struct tuner {
> >  	unsigned int        type; /* chip type id */
> >  	void                *config;
> >  	const char          *name;
> > +
> >  #if defined(CONFIG_MEDIA_CONTROLLER)
> > -	struct media_pad	pad;
> > +	struct media_pad	pad[TUNER_NUM_PADS];
> >  #endif
> >  };
> > 
> > @@ -695,11 +696,12 @@ static int tuner_probe(struct i2c_client *client,
> >  	/* Should be just before return */
> >  register_client:
> >  #if defined(CONFIG_MEDIA_CONTROLLER)
> > -	t->pad.flags = MEDIA_PAD_FL_SOURCE;
> > +	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
> > +	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
> >  	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
> >  	t->sd.entity.name = t->name;
> > 
> > -	ret = media_entity_init(&t->sd.entity, 1, &t->pad);
> > +	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
> >  	if (ret < 0) {
> >  		tuner_err("failed to initialize media entity!\n");
> >  		kfree(t);
> > diff --git a/include/media/tuner.h b/include/media/tuner.h
> > index b46ebb48fe74..95835c8069dd 100644
> > --- a/include/media/tuner.h
> > +++ b/include/media/tuner.h
> > @@ -25,6 +25,14 @@
> > 
> >  #include <linux/videodev2.h>
> > 
> > +/* Tuner PADs */
> > +/* FIXME: is this the right place for it? */
> > +enum tuner_pad_index {
> > +	TUNER_PAD_RF_INPUT,
> > +	TUNER_PAD_IF_OUTPUT,
> > +	TUNER_NUM_PADS
> > +};
> > +
> >  #define ADDR_UNSET (255)
> > 
> >  #define TUNER_TEMIC_PAL			0        /* 4002 FH5 (3X 7756, 9483) */
> 

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

* Re: [PATCH 05/18] [media] media-controller: enable all interface links at init
  2015-11-23 19:46   ` Laurent Pinchart
@ 2015-12-10 11:37     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 11:37 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List, Hans Verkuil, Sakari Ailus

Em Mon, 23 Nov 2015 21:46:53 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:48 Mauro Carvalho Chehab wrote:
> > Interface links are normally enabled, meaning that the interfaces are
> > bound to the entities. So, any ioctl send to the interface are reflected
> 
> s/send/sent/
> 
> > at the entities managed by the interface.
> > 
> > However, when a device is usage, other interfaces for the same hardware
> 
> s/usage/in use/
> 
> > could be decoupled from the entities linked to them, because the
> > hardware may have some parts busy.
> > 
> > That's for example, what happens when an hybrid TV device is in usage.
> 
> s/usage/use/
> 
> > If it is streaming analog TV or capturing signals from S-Video/Composite
> > connectors, typically the digital part of the hardware can't be used and
> > vice-versa.
> > 
> > This is generally due to some internal hardware or firmware limitation,
> > that it is not easily mapped via data pipelines.
> > 
> > What the Kernel drivers do internally is that they decouple the hardware
> > from the interface. So, all changes, if allowed, are done only at some
> > interface cache, but not physically changed at the hardware.
> > 
> > The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data
> > links. So, let's use the same flag to indicate if ether the interface
> 
> s/ether/either/
> 
> > to entity link is bound/enabled or not.
> 
> I believe we'll need to experiment with the interface links to see what's 
> really needed there. As a general rule I'd like to avoid exposing too much 
> information to userspace without a clear indication that the information is 
> actually needed, as it's always easier to expose additional information later 
> than to remove information already exposed.
> 
> For this reason I'd like to see as a first step how we would do in userspace 
> without making those links dynamic. If we then realize that we're lacking 
> information we'll decide on the best course of action and on exactly what to 
> expose and how to expose it, using concrete userspace use cases.

As discussed during MC workshop, the need of marking an interface link as
active or not is because, on complex devices like hybrid TV ones, typically
either the analog side of the digital side of the device is disabled.

So, for example, if an hybrid device is working in digital mode, any
change done via the V4L2 interfaces should not be applied to the hardware.
The interface should either cache such changes to be applied the next
time the device would switch to analog mode or return EBUSY.

In other words, the link between the interface and the hardware entities
are disabled.

This is needed internally at the MC representation of the hardware
(and one of the main reasons why we need MC on hybrid devices).

Applications also need such information, as, except for a couple
applications:
	- xawtv4, (with is not a popular one)
	- mythTV
All other open source applications I'm aware of are either digital only
or analog only and some radio applications even run as applets.

So, the user may have more than one application running at the same time,
being one active and the other would need to report that it cannot be
activated because the device is busy.

So, this change is actually needed.

Anyway, I'm splitting this patch in two parts: one for DVB and another
one for V4L, as I'm reordering some patches on the final rebase due
to some troubles detected with KASAN and DEBUG_KMEMLEAK, and splitting
it avoids merge conflicts.

> 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c
> > b/drivers/media/dvb-core/dvbdev.c index a8e7e2398f7a..5c4fb41060b4 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -396,7 +396,8 @@ static void dvb_register_media_device(struct dvb_device
> > *dvbdev, if (!dvbdev->entity || !dvbdev->intf_devnode)
> >  		return;
> > 
> > -	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0);
> > +	media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf,
> > +			       MEDIA_LNK_FL_ENABLED);
> > 
> >  #endif
> >  }
> > @@ -583,20 +584,24 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
> >  	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca 
> */
> > media_device_for_each_intf(intf, mdev) {
> >  		if (intf->type == MEDIA_INTF_T_DVB_CA && ca)
> > -			media_create_intf_link(ca, intf, 0);
> > +			media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED);
> > 
> >  		if (intf->type == MEDIA_INTF_T_DVB_FE && tuner)
> > -			media_create_intf_link(tuner, intf, 0);
> > +			media_create_intf_link(tuner, intf,
> > +					       MEDIA_LNK_FL_ENABLED);
> > 
> >  		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux)
> > -			media_create_intf_link(demux, intf, 0);
> > +			media_create_intf_link(demux, intf,
> > +					       MEDIA_LNK_FL_ENABLED);
> > 
> >  		media_device_for_each_entity(entity, mdev) {
> >  			if (entity->type == MEDIA_ENT_T_DVB_TSOUT) {
> >  				if (!strcmp(entity->name, DVR_TSOUT))
> > -					media_create_intf_link(entity, intf, 0);
> > +					media_create_intf_link(entity, intf,
> > +							       MEDIA_LNK_FL_ENABLED);
> >  				if (!strcmp(entity->name, DEMUX_TSOUT))
> > -					media_create_intf_link(entity, intf, 0);
> > +					media_create_intf_link(entity, intf,
> > +							       MEDIA_LNK_FL_ENABLED);
> >  				break;
> >  			}
> >  		}
> > diff --git a/drivers/media/v4l2-core/v4l2-dev.c
> > b/drivers/media/v4l2-core/v4l2-dev.c index 07123dd569c4..8429da66754a
> > 100644
> > --- a/drivers/media/v4l2-core/v4l2-dev.c
> > +++ b/drivers/media/v4l2-core/v4l2-dev.c
> > @@ -788,7 +788,8 @@ static int video_register_media_controller(struct
> > video_device *vdev, int type) struct media_link *link;
> > 
> >  		link = media_create_intf_link(&vdev->entity,
> > -					      &vdev->intf_devnode->intf, 0);
> > +					      &vdev->intf_devnode->intf,
> > +					      MEDIA_LNK_FL_ENABLED);
> >  		if (!link) {
> >  			media_devnode_remove(vdev->intf_devnode);
> >  			media_device_unregister_entity(&vdev->entity);
> > diff --git a/drivers/media/v4l2-core/v4l2-device.c
> > b/drivers/media/v4l2-core/v4l2-device.c index e788a085ba96..bb58d90fde5e
> > 100644
> > --- a/drivers/media/v4l2-core/v4l2-device.c
> > +++ b/drivers/media/v4l2-core/v4l2-device.c
> > @@ -256,7 +256,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device
> > *v4l2_dev)
> > 
> >  			link = media_create_intf_link(&sd->entity,
> >  						      &vdev->intf_devnode->intf,
> > -						      0);
> > +						      MEDIA_LNK_FL_ENABLED);
> >  			if (!link)
> >  				goto clean_up;
> >  		}
> 

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

* Re: [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails
  2015-09-11 15:20   ` Hans Verkuil
@ 2015-12-10 17:33     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 17:33 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Hans Verkuil, Jonathan Corbet

Em Fri, 11 Sep 2015 17:20:47 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> > Right now, if something gets wrong at dvb_create_media_entity()
> > or at dvb_create_media_graph(), the device will still be
> > registered.
> > 
> > Change the logic to properly handle it and free all media graph
> > objects if something goes wrong at dvb_register_device().
> > 
> > Also, change the logic at dvb_create_media_graph() to return
> > an error code if something goes wrong. It is up to the
> > caller to implement the right logic and to call
> > dvb_unregister_device() to unregister the already-created
> > objects.
> > 
> > While here, add a missing logic to unregister the created
> > interfaces.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

I did a lot of tests today with KASAN and I found some issues on
this patch. So, I'm folding it with the enclosed changes:

commit e919f3fc27a329814c064b4c3f110a4a4e80284c
Author: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Date:   Thu Dec 10 10:48:00 2015 -0200

    fixup
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 5c51084a331a..bc650c637fc0 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -187,21 +187,32 @@ static void dvb_media_device_free(struct dvb_device *dvbdev)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
 	if (dvbdev->entity) {
+		media_device_unregister_entity(dvbdev->entity);
+		kfree(dvbdev->entity);
+		kfree(dvbdev->pads);
+		dvbdev->entity = NULL;
+		dvbdev->pads = NULL;
+	}
+
+	if (dvbdev->tsout_entity) {
 		int i;
 
 		for (i = 0; i < dvbdev->tsout_num_entities; i++) {
 			media_device_unregister_entity(&dvbdev->tsout_entity[i]);
 			kfree(dvbdev->tsout_entity[i].name);
 		}
-		media_device_unregister_entity(dvbdev->entity);
-
-		kfree(dvbdev->entity);
-		kfree(dvbdev->pads);
 		kfree(dvbdev->tsout_entity);
 		kfree(dvbdev->tsout_pads);
+		dvbdev->tsout_entity = NULL;
+		dvbdev->tsout_pads = NULL;
+
+		dvbdev->tsout_num_entities = 0;
 	}
-	if (dvbdev->intf_devnode)
+
+	if (dvbdev->intf_devnode) {
 		media_devnode_remove(dvbdev->intf_devnode);
+		dvbdev->intf_devnode = NULL;
+	}
 #endif
 }
 
@@ -221,13 +232,15 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 	if (!dvbdev->tsout_entity)
 		return -ENOMEM;
 
+	dvbdev->tsout_num_entities = npads;
+
 	for (i = 0; i < npads; i++) {
 		struct media_pad *pads = &dvbdev->tsout_pads[i];
 		struct media_entity *entity = &dvbdev->tsout_entity[i];
 
 		entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i);
 		if (!entity->name)
-			return ret;
+			return -ENOMEM;
 
 		entity->type = MEDIA_ENT_T_DVB_TSOUT;
 		pads->flags = MEDIA_PAD_FL_SINK;
@@ -318,9 +331,11 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	default:
+		/* Should never happen, as the first switch prevents it */
 		kfree(dvbdev->entity);
 		kfree(dvbdev->pads);
 		dvbdev->entity = NULL;
+		dvbdev->pads = NULL;
 		return 0;
 	}
 
@@ -423,24 +438,13 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 		return -ENFILE;
 	}
 
-	*pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL);
+	*pdvbdev = dvbdev = kzalloc(sizeof(*dvbdev), GFP_KERNEL);
 
 	if (!dvbdev){
 		mutex_unlock(&dvbdev_register_lock);
 		return -ENOMEM;
 	}
 
-	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
-	if (ret) {
-		printk(KERN_ERR
-		      "%s: dvb_register_media_device failed to create the mediagraph\n",
-		      __func__);
-
-		dvb_media_device_free(dvbdev);
-		mutex_unlock(&dvbdev_register_lock);
-		return ret;
-	}
-
 	dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
 
 	if (!dvbdevfops){
@@ -483,6 +487,20 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 	dvb_minors[minor] = dvbdev;
 	up_write(&minor_rwsem);
 
+	ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads);
+	if (ret) {
+		printk(KERN_ERR
+		      "%s: dvb_register_media_device failed to create the mediagraph\n",
+		      __func__);
+
+		dvb_media_device_free(dvbdev);
+		kfree(dvbdevfops);
+		kfree(dvbdev);
+		up_write(&minor_rwsem);
+		mutex_unlock(&dvbdev_register_lock);
+		return ret;
+	}
+
 	mutex_unlock(&dvbdev_register_lock);
 
 	clsdev = device_create(dvb_class, adap->device,
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 96700843b1e4..c7d97190a67e 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -576,6 +576,10 @@ void media_device_unregister(struct media_device *mdev)
 	struct media_entity *next;
 	struct media_interface *intf, *tmp_intf;
 
+	/* Remove all entities from the media device */
+	list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
+		media_device_unregister_entity(entity);
+
 	/* Remove all interfaces from the media device */
 	spin_lock(&mdev->lock);
 	list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces,
@@ -586,9 +590,6 @@ void media_device_unregister(struct media_device *mdev)
 	}
 	spin_unlock(&mdev->lock);
 
-	list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
-		media_device_unregister_entity(entity);
-
 	device_remove_file(&mdev->devnode.dev, &dev_attr_model);
 	media_devnode_unregister(&mdev->devnode);
 
@@ -654,8 +655,7 @@ void media_device_unregister_entity(struct media_entity *entity)
 	/* Remove all interface links pointing to this entity */
 	list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) {
 		list_for_each_entry_safe(link, tmp, &intf->links, list) {
-			if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY
-			    && link->entity == entity)
+			if (link->entity == entity)
 				__media_remove_intf_link(link);
 		}
 	}



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

* Re: [PATCH 02/18] [media] au0828: add support for the connectors
  2015-09-11 14:57   ` Hans Verkuil
@ 2015-12-10 18:24     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 18:24 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Rafael Lourenço de Lima Chehab,
	Hans Verkuil, Shuah Khan, Lad, Prabhakar, Julia Lawall

Em Fri, 11 Sep 2015 16:57:22 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> > Depending on the input, an au0828 may have a different
> > number of connectors. add entities to represent them.
> 
> Hmm, this patch uses the new connector defines that are only added in patch 6!
> So this doesn't compile.

It is compiling fine here, perhaps due to some patch reorder during one
of the hundreds of rebase that this long patch series the needed
patch was moved already.

> 
> Is there a reason why the connector support is needed now? I would prefer to have
> this in a separate follow-up patch series.

Better to add those connectors earlier than later, as we need to
double check that the ALSA patches that Shuah did will work fine
also for the Composite/S-Video cases.

Regards,
Mauro
> 
> Regards,
> 
> 	Hans
> 
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> > index f54c7d10f350..fe9a60484343 100644
> > --- a/drivers/media/usb/au0828/au0828-core.c
> > +++ b/drivers/media/usb/au0828/au0828-core.c
> > @@ -153,11 +153,26 @@ static void au0828_usb_release(struct au0828_dev *dev)
> >  }
> >  
> >  #ifdef CONFIG_VIDEO_AU0828_V4L2
> > +
> > +static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
> > +{
> > +#ifdef CONFIG_MEDIA_CONTROLLER
> > +	int i;
> > +
> > +	for (i = 0; i < AU0828_MAX_INPUT; i++) {
> > +		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
> > +			return;
> > +		media_device_unregister_entity(&dev->input_ent[i]);
> > +	}
> > +#endif
> > +}
> > +
> >  static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
> >  {
> >  	struct au0828_dev *dev =
> >  		container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
> >  
> > +	au0828_usb_v4l2_media_release(dev);
> >  	v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
> >  	v4l2_device_unregister(&dev->v4l2_dev);
> >  	au0828_usb_release(dev);
> > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > index 4511e2893282..806b8d320bae 100644
> > --- a/drivers/media/usb/au0828/au0828-video.c
> > +++ b/drivers/media/usb/au0828/au0828-video.c
> > @@ -1793,6 +1793,69 @@ static int au0828_vb2_setup(struct au0828_dev *dev)
> >  	return 0;
> >  }
> >  
> > +static void au0828_analog_create_entities(struct au0828_dev *dev)
> > +{
> > +#if defined(CONFIG_MEDIA_CONTROLLER)
> > +	static const char *inames[] = {
> > +		[AU0828_VMUX_COMPOSITE] = "Composite",
> > +		[AU0828_VMUX_SVIDEO] = "S-Video",
> > +		[AU0828_VMUX_CABLE] = "Cable TV",
> > +		[AU0828_VMUX_TELEVISION] = "Television",
> > +		[AU0828_VMUX_DVB] = "DVB",
> > +		[AU0828_VMUX_DEBUG] = "tv debug"
> > +	};
> > +	int ret, i;
> > +
> > +	/* Initialize Video and VBI pads */
> > +	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
> > +	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
> > +	if (ret < 0)
> > +		pr_err("failed to initialize video media entity!\n");
> > +
> > +	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
> > +	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
> > +	if (ret < 0)
> > +		pr_err("failed to initialize vbi media entity!\n");
> > +
> > +	/* Create entities for each input connector */
> > +	for (i = 0; i < AU0828_MAX_INPUT; i++) {
> > +		struct media_entity *ent = &dev->input_ent[i];
> > +
> > +		if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
> > +			break;
> > +
> > +		ent->name = inames[AUVI_INPUT(i).type];
> > +		ent->flags = MEDIA_ENT_FL_CONNECTOR;
> > +		dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
> > +
> > +		switch(AUVI_INPUT(i).type) {
> > +		case AU0828_VMUX_COMPOSITE:
> > +			ent->type = MEDIA_ENT_T_CONN_COMPOSITE;
> > +			break;
> > +		case AU0828_VMUX_SVIDEO:
> > +			ent->type = MEDIA_ENT_T_CONN_SVIDEO;
> > +			break;
> > +		case AU0828_VMUX_CABLE:
> > +		case AU0828_VMUX_TELEVISION:
> > +		case AU0828_VMUX_DVB:
> > +			ent->type = MEDIA_ENT_T_CONN_RF;
> > +			break;
> > +		default: /* AU0828_VMUX_DEBUG */
> > +			ent->type = MEDIA_ENT_T_CONN_TEST;
> > +			break;
> > +		}
> > +
> > +		ret = media_entity_init(ent, 1, &dev->input_pad[i]);
> > +		if (ret < 0)
> > +			pr_err("failed to initialize input pad[%d]!\n", i);
> > +
> > +		ret = media_device_register_entity(dev->media_dev, ent);
> > +		if (ret < 0)
> > +			pr_err("failed to register input entity %d!\n", i);
> > +	}
> > +#endif
> > +}
> > +
> >  /**************************************************************************/
> >  
> >  int au0828_analog_register(struct au0828_dev *dev,
> > @@ -1881,17 +1944,8 @@ int au0828_analog_register(struct au0828_dev *dev,
> >  	dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock;
> >  	strcpy(dev->vbi_dev.name, "au0828a vbi");
> >  
> > -#if defined(CONFIG_MEDIA_CONTROLLER)
> > -	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
> > -	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
> > -	if (ret < 0)
> > -		pr_err("failed to initialize video media entity!\n");
> > -
> > -	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
> > -	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
> > -	if (ret < 0)
> > -		pr_err("failed to initialize vbi media entity!\n");
> > -#endif
> > +	/* Init entities at the Media Controller */
> > +	au0828_analog_create_entities(dev);
> >  
> >  	/* initialize videobuf2 stuff */
> >  	retval = au0828_vb2_setup(dev);
> > diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
> > index d3644b3fe6fa..b7940c54d006 100644
> > --- a/drivers/media/usb/au0828/au0828.h
> > +++ b/drivers/media/usb/au0828/au0828.h
> > @@ -93,7 +93,6 @@ struct au0828_board {
> >  	unsigned char has_ir_i2c:1;
> >  	unsigned char has_analog:1;
> >  	struct au0828_input input[AU0828_MAX_INPUT];
> > -
> >  };
> >  
> >  struct au0828_dvb {
> > @@ -281,6 +280,8 @@ struct au0828_dev {
> >  	struct media_device *media_dev;
> >  	struct media_pad video_pad, vbi_pad;
> >  	struct media_entity *decoder;
> > +	struct media_entity input_ent[AU0828_MAX_INPUT];
> > +	struct media_pad input_pad[AU0828_MAX_INPUT];
> >  #endif
> >  };
> >  
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
  2015-11-23 18:09     ` Laurent Pinchart
@ 2015-12-10 18:43       ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 18:43 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List, linux-api

Em Mon, 23 Nov 2015 20:09:02 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:49 Mauro Carvalho Chehab wrote:
> > Add entities to represent the connectors that exists inside a
> > hybrid TV device.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index b17f6763aff4..69433405aec2 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -61,6 +61,7 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DVB_BASE		0x00000000
> >  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
> >  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> > +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> > 
> >  /*
> >   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> > @@ -105,6 +106,13 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> >  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> > 
> > +/* Connectors */
> > +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> > +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> > +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> > +	/* For internal test signal generators and other debug connectors */
> 
> No need to a \t at the beginning of the line.

Removed.

> 
> > +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> 
> I'd like to see more information about this.

Some hardware have internally a simple signal generator on the
chipset that generate test sequences. They're part of the input
selection switch. In the case of au0828, the demodulator (actually au8522)
has the follow inputs:
	- TV connector;
	- S-Video input connector;
	- Composite input connector;
	- TV signal test generator.

The input can be controlled via V4L2 VIDIOC_*_INPUT ioctls. The
Media Controller should be able to reflect the topology, as keeping
this input not visible would be inconsistent.

> When later renaming types to functions you rename this type as well, and I'm 
> still not convinced that we shouldn't have both types and functions.

Not sure what you're meaning here.

> Let's discuss these topics and the one below on the documentation patches.

Ok.

> 
> >  #ifndef __KERNEL__
> >  /* Legacy symbols used to avoid userspace compilation breakages */
> >  #define MEDIA_ENT_TYPE_SHIFT		16
> > @@ -121,9 +129,9 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> >  #endif
> > 
> > -/* Entity types */
> > -
> > +/* Entity flags */
> >  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> > +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)
> 
> Ditto, I'm not sure about the use cases.

The distinction between connectors and "normal" entities was largely
discussed during the MC workshop. See the workshop notes.

During the discussions of the Hans RFC sent just after the workshop, we 
decided that, instead of adding yet another graph type, it would be
easier to just add a flag for the connectors.

Regards,
Mauro

> 
> >  struct media_entity_desc {
> >  	__u32 id;
> 

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

* Re: [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices
@ 2015-12-10 18:43       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 18:43 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Linux Media Mailing List, linux-api-u79uwXL29TY76Z2rM5mHXA

Em Mon, 23 Nov 2015 20:09:02 +0200
Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:49 Mauro Carvalho Chehab wrote:
> > Add entities to represent the connectors that exists inside a
> > hybrid TV device.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
> > 
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index b17f6763aff4..69433405aec2 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -61,6 +61,7 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DVB_BASE		0x00000000
> >  #define MEDIA_ENT_T_V4L2_BASE		0x00010000
> >  #define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> > +#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> > 
> >  /*
> >   * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> > @@ -105,6 +106,13 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> >  #define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> > 
> > +/* Connectors */
> > +#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> > +#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> > +#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> > +	/* For internal test signal generators and other debug connectors */
> 
> No need to a \t at the beginning of the line.

Removed.

> 
> > +#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> 
> I'd like to see more information about this.

Some hardware have internally a simple signal generator on the
chipset that generate test sequences. They're part of the input
selection switch. In the case of au0828, the demodulator (actually au8522)
has the follow inputs:
	- TV connector;
	- S-Video input connector;
	- Composite input connector;
	- TV signal test generator.

The input can be controlled via V4L2 VIDIOC_*_INPUT ioctls. The
Media Controller should be able to reflect the topology, as keeping
this input not visible would be inconsistent.

> When later renaming types to functions you rename this type as well, and I'm 
> still not convinced that we shouldn't have both types and functions.

Not sure what you're meaning here.

> Let's discuss these topics and the one below on the documentation patches.

Ok.

> 
> >  #ifndef __KERNEL__
> >  /* Legacy symbols used to avoid userspace compilation breakages */
> >  #define MEDIA_ENT_TYPE_SHIFT		16
> > @@ -121,9 +129,9 @@ struct media_device_info {
> >  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> >  #endif
> > 
> > -/* Entity types */
> > -
> > +/* Entity flags */
> >  #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
> > +#define MEDIA_ENT_FL_CONNECTOR		(1 << 1)
> 
> Ditto, I'm not sure about the use cases.

The distinction between connectors and "normal" entities was largely
discussed during the MC workshop. See the workshop notes.

During the discussions of the Hans RFC sent just after the workshop, we 
decided that, instead of adding yet another graph type, it would be
easier to just add a flag for the connectors.

Regards,
Mauro

> 
> >  struct media_entity_desc {
> >  	__u32 id;
> 

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

* Re: [PATCH 12/18] [media] media-entity: must check media_create_pad_link()
  2015-11-23 17:54   ` Laurent Pinchart
@ 2015-12-10 19:13     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 19:13 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

Em Mon, 23 Nov 2015 19:54:17 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 06 September 2015 14:30:55 Mauro Carvalho Chehab wrote:
> > Drivers should check if media_create_pad_link() actually
> > worked.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index 62f882d872b1..8bdc10dcc5e7 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -348,8 +348,9 @@ int media_entity_init(struct media_entity *entity, u16
> > num_pads, struct media_pad *pads);
> >  void media_entity_cleanup(struct media_entity *entity);
> > 
> > -int media_create_pad_link(struct media_entity *source, u16 source_pad,
> > -		struct media_entity *sink, u16 sink_pad, u32 flags);
> > +__must_check int media_create_pad_link(struct media_entity *source,
> > +			u16 source_pad,	struct media_entity *sink,
> 
> s/,\t/, /

Fixed.

> 
> > +			u16 sink_pad, u32 flags);
> 
> And it would make sense to squash this with the patch that introduces 
> media_create_pad_link().

Maybe, but it is too late for that ;) Also, not sure about this 
specific case, but on the other patches adding __must_check, some
things needed to be fixed before actually adding the change.

> 
> >  void __media_entity_remove_links(struct media_entity *entity);
> >  void media_entity_remove_links(struct media_entity *entity);
> 

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

* Re: [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
  2015-09-11 15:36     ` Hans Verkuil
  (?)
@ 2015-12-10 19:54       ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 19:54 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Sakari Ailus, Lars-Peter Clausen,
	Laurent Pinchart, Kyungmin Park, Heungjun Kim, Lad, Prabhakar,
	Andrzej Hajda, Hyun Kwon, Michal Simek, Sören Brinkmann,
	Hans Verkuil, Rafael Lourenço de Lima Chehab,
	Krzysztof Kozlowski, Boris BREZILLON, Joe Perches,
	Sylwester Nawrocki, Ricardo Ribalda Delgado,
	Guennadi Liakhovetski, Axel Lin, Shuah Khan, Julia Lawall,
	Markus Elfring, Matthias Schwarzott, Antti Palosaari,
	Olli Salonen, Tommi Rantala, Scott Jiang, Bryan Wu,
	Jacek Anaszewski, linux-arm-kernel, linux-api, Shuah Khan

Em Fri, 11 Sep 2015 17:36:42 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> > Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> > and add the backward compatibility bits.
> > 
> > The changes at the .c files was generated by the following
> > coccinelle script:
> > 
> 
> 
> > @@
> > -MEDIA_ENT_T_DVB_DEMUX
> > +MEDIA_ENT_F_MPEG_TS_DEMUX
> 
> I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
> can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

Changed.

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_TSOUT
> > +MEDIA_ENT_F_DTV_TSOUT
> 
> Shouldn't this be MEDIA_ENT_F_IO?

As we've discussed on IRC, per Shuah's request, I ended by keeping
one different I/O entity per API type:

#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_CA
> > +MEDIA_ENT_F_DTV_CA
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_NET_DECAP
> > +MEDIA_ENT_F_DTV_NET_DECAP
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> > index e925909bc99e..8527fc40e6a0 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
> >  		if (!entity->name)
> >  			return ret;
> >  
> > -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> > +		entity->function = MEDIA_ENT_F_IO;
> >  		pads->flags = MEDIA_PAD_FL_SINK;
> >  
> >  		ret = media_entity_init(entity, 1, pads);
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index d232cc680c67..90e90a6e62bf 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -46,87 +46,86 @@ struct media_device_info {
> >   * Initial value to be used when a new entity is created
> >   * Drivers should change it to something useful
> >   */
> > -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> > +#define MEDIA_ENT_F_UNKNOWN	0x00000000
> >  
> >  /*
> > - * Base numbers for entity types
> > + * Base number ranges for entity functions
> >   *
> > - * Please notice that the huge gap of 16 bits for each base is overkill!
> > - * 8 bits is more than enough to avoid starving entity types for each
> > - * subsystem.
> > - *
> > - * However, It is kept this way just to avoid binary breakages with the
> > - * namespace provided on legacy versions of this header.
> > + * NOTE: those ranges and entity function number are spased just to
> 
> s/spased/phased/
> 
> > + * make easier to maintain this file. Userspace should not rely on
> 
> s/make/make it/
> 
> > + * the ranges to identify a group of function types, as newer
> > + * functions can be added with any name within the full u32 range.
> >   */
> > -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> > -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> > -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> > +#define MEDIA_ENT_F_BASE		0x00000000
> > +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> > +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
> >  
> >  /*
> > - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> > - *	read()/write() data I/O associated with the V4L2 devnodes.
> > + * DVB entities
> >   */
> > -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> > -	/*
> > -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> > -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> > -	 * to be declared for FB, ALSA and DVB entities.
> > -	 * As those values were never actually used in practice, we're just
> > -	 * adding them as backward compatibility macros and keeping the
> > -	 * numberspace clean here. This way, we avoid breaking compilation,
> > -	 * in the case of having some userspace application using the old
> > -	 * symbols.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> > -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> > -
> > -/* V4L2 Sub-device entities */
> > -
> > -	/*
> > -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > -	 * in order to preserve backward compatibility.
> > -	 * Drivers should change to the proper subdev type before
> > -	 * registering the entity.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> > -	/* A converter of analogue video to its digital representation. */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> > -	/* Tuner entity is actually both V4L2 and DVB subdev */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> > +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> > +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> > +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> > +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
> >  
> > -/* DVB entities */
> > -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> > -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> > -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> > -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> > -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> > -
> > -/* Connectors */
> > -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> > -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> > -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> > +/*
> > + * Connectors
> > + */
> > +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> > +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> > +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
> >  	/* For internal test signal generators and other debug connectors */
> > -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> > +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> > +
> > +/*
> > + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> > + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> > + * with the legacy v1 API.The number range is out of range by purpose:
> > + * several previously reserved numbers got excluded from this range.
> > + *
> > + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > + * in order to preserve backward compatibility.
> > + * Drivers should change to the proper subdev type before
> > + * registering the entity.
> > + */
> > +
> > +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> > +
> > +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> > +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> > +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> > +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> > +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> > +
> > +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
> >  
> >  #ifndef __KERNEL__
> > -/* Legacy symbols used to avoid userspace compilation breakages */
> > +
> > +/*
> > + * Legacy symbols used to avoid userspace compilation breakages
> > + *
> > + * Those symbols map the entity function into types and should be
> > + * used only on legacy programs for legacy hardware. Don't rely
> > + * on those for MEDIA_IOC_G_TOPOLOGY.
> > + */
> >  #define MEDIA_ENT_TYPE_SHIFT		16
> >  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
> >  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
> >  
> > -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> > -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> > -
> > +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> > +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
> >  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
> >  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
> >  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> > +
> > +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> > +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
> >  #endif
> >  
> >  /* Entity flags */
> > 
> 
> Overall I really like this.

Fixes applied.

The actual patch merged follows.

---


[media] uapi/media.h: Rename entities types to functions

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO_V4L
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_IO_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_IO_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_IO_DTV
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index f6fc95d1345b..f64e8b3fb687 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -242,7 +242,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return -ENOMEM;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO_DTV;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -315,18 +315,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -556,16 +556,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -594,7 +594,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -639,7 +639,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 9d99182cd165..7150f35d5935 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 0fca8677014c..2ebe9efdfc1b 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index f45108c84f4d..b1bc4d0f76f2 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index e84e042610fa..f2f0992c7e54 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index aa8b4832a1bc..98266f707ea0 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index a52cc3a6fb55..ba5ee0d7a78e 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index ae5645fe3a6e..bec5cea23b65 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 0226fc668529..47ea3f79eacc 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 8a2efe2a24c4..cf8e71610248 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 27c4def7e4fc..adb4aab45c10 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index dd48e35ede28..3d578f2ce7b2 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	oif_sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 026d08740537..bacec84e773f 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 1d47b30953a4..564938ab2abd 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index d7244234473e..d71d104441bd 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index ef325b653697..3eaa69ee341b 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11e426dbe891..455dd4e6a1da 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 a5ee2b8df429..216a07956fe9 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 83525ac29328..f177d50c7a44 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -611,8 +611,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 1a28e17474c9..06eb74344507 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO_V4L)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 865d68dc4dc8..1b207fa16a55 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -266,10 +266,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 642a6a658a20..150824fe382a 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1836,18 +1836,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch (AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 5062c42a694c..0e1efc59ff58 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index e85ef4729333..86c9cbd02016 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 965449958e97..ed96642c27bf 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -735,20 +735,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO_V4L;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO_VBI;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -766,7 +766,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -793,7 +793,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d63083803144 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO_V4L,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 70ccd6cf14c1..df84e8eeb24b 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -274,9 +274,9 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO_V4L:
+	case MEDIA_ENT_F_IO_VBI:
+	case MEDIA_ENT_F_IO_SWRADIO:
 		return true;
 	default:
 		return false;
@@ -289,12 +289,12 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN:
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 290dd5585dc8..ff6a8010c520 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,93 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are phased just to
+ * make it easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_TS_DEMUX		(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
 /*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
+	/* For internal test signal generators and other debug connectors */
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * I/O entities
+ */
+#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
+#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
+#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
  * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
  * in order to preserve backward compatibility.
  * Drivers should change to the proper subdev type before
  * registering the entity.
  */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
-
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 2)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 3)
-/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 4)
+
+#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO_V4L
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */

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

* Re: [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-12-10 19:54       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 19:54 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Sakari Ailus, Lars-Peter Clausen,
	Laurent Pinchart, Kyungmin Park, Heungjun Kim, Lad, Prabhakar,
	Andrzej Hajda, Hyun Kwon, Michal Simek, Sören Brinkmann,
	Hans Verkuil, Rafael Lourenço de Lima Chehab,
	Krzysztof Kozlowski, Boris BREZILLON, Joe Perches,
	Sylwester Nawrocki, Ricardo Ribalda Delgado,
	Guennadi Liakhovetski

Em Fri, 11 Sep 2015 17:36:42 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> > Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> > and add the backward compatibility bits.
> > 
> > The changes at the .c files was generated by the following
> > coccinelle script:
> > 
> 
> 
> > @@
> > -MEDIA_ENT_T_DVB_DEMUX
> > +MEDIA_ENT_F_MPEG_TS_DEMUX
> 
> I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
> can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

Changed.

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_TSOUT
> > +MEDIA_ENT_F_DTV_TSOUT
> 
> Shouldn't this be MEDIA_ENT_F_IO?

As we've discussed on IRC, per Shuah's request, I ended by keeping
one different I/O entity per API type:

#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_CA
> > +MEDIA_ENT_F_DTV_CA
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_NET_DECAP
> > +MEDIA_ENT_F_DTV_NET_DECAP
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> > index e925909bc99e..8527fc40e6a0 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
> >  		if (!entity->name)
> >  			return ret;
> >  
> > -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> > +		entity->function = MEDIA_ENT_F_IO;
> >  		pads->flags = MEDIA_PAD_FL_SINK;
> >  
> >  		ret = media_entity_init(entity, 1, pads);
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index d232cc680c67..90e90a6e62bf 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -46,87 +46,86 @@ struct media_device_info {
> >   * Initial value to be used when a new entity is created
> >   * Drivers should change it to something useful
> >   */
> > -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> > +#define MEDIA_ENT_F_UNKNOWN	0x00000000
> >  
> >  /*
> > - * Base numbers for entity types
> > + * Base number ranges for entity functions
> >   *
> > - * Please notice that the huge gap of 16 bits for each base is overkill!
> > - * 8 bits is more than enough to avoid starving entity types for each
> > - * subsystem.
> > - *
> > - * However, It is kept this way just to avoid binary breakages with the
> > - * namespace provided on legacy versions of this header.
> > + * NOTE: those ranges and entity function number are spased just to
> 
> s/spased/phased/
> 
> > + * make easier to maintain this file. Userspace should not rely on
> 
> s/make/make it/
> 
> > + * the ranges to identify a group of function types, as newer
> > + * functions can be added with any name within the full u32 range.
> >   */
> > -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> > -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> > -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> > +#define MEDIA_ENT_F_BASE		0x00000000
> > +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> > +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
> >  
> >  /*
> > - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> > - *	read()/write() data I/O associated with the V4L2 devnodes.
> > + * DVB entities
> >   */
> > -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> > -	/*
> > -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> > -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> > -	 * to be declared for FB, ALSA and DVB entities.
> > -	 * As those values were never actually used in practice, we're just
> > -	 * adding them as backward compatibility macros and keeping the
> > -	 * numberspace clean here. This way, we avoid breaking compilation,
> > -	 * in the case of having some userspace application using the old
> > -	 * symbols.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> > -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> > -
> > -/* V4L2 Sub-device entities */
> > -
> > -	/*
> > -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > -	 * in order to preserve backward compatibility.
> > -	 * Drivers should change to the proper subdev type before
> > -	 * registering the entity.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> > -	/* A converter of analogue video to its digital representation. */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> > -	/* Tuner entity is actually both V4L2 and DVB subdev */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> > +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> > +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> > +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> > +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
> >  
> > -/* DVB entities */
> > -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> > -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> > -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> > -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> > -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> > -
> > -/* Connectors */
> > -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> > -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> > -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> > +/*
> > + * Connectors
> > + */
> > +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> > +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> > +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
> >  	/* For internal test signal generators and other debug connectors */
> > -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> > +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> > +
> > +/*
> > + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> > + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> > + * with the legacy v1 API.The number range is out of range by purpose:
> > + * several previously reserved numbers got excluded from this range.
> > + *
> > + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > + * in order to preserve backward compatibility.
> > + * Drivers should change to the proper subdev type before
> > + * registering the entity.
> > + */
> > +
> > +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> > +
> > +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> > +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> > +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> > +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> > +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> > +
> > +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
> >  
> >  #ifndef __KERNEL__
> > -/* Legacy symbols used to avoid userspace compilation breakages */
> > +
> > +/*
> > + * Legacy symbols used to avoid userspace compilation breakages
> > + *
> > + * Those symbols map the entity function into types and should be
> > + * used only on legacy programs for legacy hardware. Don't rely
> > + * on those for MEDIA_IOC_G_TOPOLOGY.
> > + */
> >  #define MEDIA_ENT_TYPE_SHIFT		16
> >  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
> >  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
> >  
> > -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> > -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> > -
> > +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> > +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
> >  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
> >  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
> >  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> > +
> > +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> > +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
> >  #endif
> >  
> >  /* Entity flags */
> > 
> 
> Overall I really like this.

Fixes applied.

The actual patch merged follows.

---


[media] uapi/media.h: Rename entities types to functions

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO_V4L
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_IO_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_IO_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_IO_DTV
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index f6fc95d1345b..f64e8b3fb687 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -242,7 +242,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return -ENOMEM;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO_DTV;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -315,18 +315,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -556,16 +556,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -594,7 +594,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -639,7 +639,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 9d99182cd165..7150f35d5935 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 0fca8677014c..2ebe9efdfc1b 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index f45108c84f4d..b1bc4d0f76f2 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index e84e042610fa..f2f0992c7e54 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index aa8b4832a1bc..98266f707ea0 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index a52cc3a6fb55..ba5ee0d7a78e 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index ae5645fe3a6e..bec5cea23b65 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 0226fc668529..47ea3f79eacc 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 8a2efe2a24c4..cf8e71610248 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 27c4def7e4fc..adb4aab45c10 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index dd48e35ede28..3d578f2ce7b2 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	oif_sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 026d08740537..bacec84e773f 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 1d47b30953a4..564938ab2abd 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index d7244234473e..d71d104441bd 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index ef325b653697..3eaa69ee341b 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11e426dbe891..455dd4e6a1da 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 a5ee2b8df429..216a07956fe9 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 83525ac29328..f177d50c7a44 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -611,8 +611,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 1a28e17474c9..06eb74344507 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO_V4L)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 865d68dc4dc8..1b207fa16a55 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -266,10 +266,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 642a6a658a20..150824fe382a 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1836,18 +1836,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch (AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 5062c42a694c..0e1efc59ff58 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index e85ef4729333..86c9cbd02016 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 965449958e97..ed96642c27bf 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -735,20 +735,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO_V4L;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO_VBI;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -766,7 +766,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -793,7 +793,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d63083803144 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO_V4L,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 70ccd6cf14c1..df84e8eeb24b 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -274,9 +274,9 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO_V4L:
+	case MEDIA_ENT_F_IO_VBI:
+	case MEDIA_ENT_F_IO_SWRADIO:
 		return true;
 	default:
 		return false;
@@ -289,12 +289,12 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN:
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 290dd5585dc8..ff6a8010c520 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,93 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are phased just to
+ * make it easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_TS_DEMUX		(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
 /*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
+	/* For internal test signal generators and other debug connectors */
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * I/O entities
+ */
+#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
+#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
+#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
  * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
  * in order to preserve backward compatibility.
  * Drivers should change to the proper subdev type before
  * registering the entity.
  */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
-
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 2)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 3)
-/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 4)
+
+#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO_V4L
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */

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

* [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions
@ 2015-12-10 19:54       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 19:54 UTC (permalink / raw)
  To: linux-arm-kernel

Em Fri, 11 Sep 2015 17:36:42 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:30 PM, Mauro Carvalho Chehab wrote:
> > Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
> > and add the backward compatibility bits.
> > 
> > The changes at the .c files was generated by the following
> > coccinelle script:
> > 
> 
> 
> > @@
> > -MEDIA_ENT_T_DVB_DEMUX
> > +MEDIA_ENT_F_MPEG_TS_DEMUX
> 
> I'm not sure about the 'MPEG_' part here. I think that in general a transport stream
> can contain non-MPEG streams as well. Why not just say _F_TS_DEMUX?

Changed.

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_TSOUT
> > +MEDIA_ENT_F_DTV_TSOUT
> 
> Shouldn't this be MEDIA_ENT_F_IO?

As we've discussed on IRC, per Shuah's request, I ended by keeping
one different I/O entity per API type:

#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)

> 
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_CA
> > +MEDIA_ENT_F_DTV_CA
> > @@
> > @@
> > -MEDIA_ENT_T_DVB_NET_DECAP
> > +MEDIA_ENT_F_DTV_NET_DECAP
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> > index e925909bc99e..8527fc40e6a0 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -229,7 +229,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
> >  		if (!entity->name)
> >  			return ret;
> >  
> > -		entity->function = MEDIA_ENT_T_DVB_TSOUT;
> > +		entity->function = MEDIA_ENT_F_IO;
> >  		pads->flags = MEDIA_PAD_FL_SINK;
> >  
> >  		ret = media_entity_init(entity, 1, pads);
> > diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
> > index d232cc680c67..90e90a6e62bf 100644
> > --- a/include/uapi/linux/media.h
> > +++ b/include/uapi/linux/media.h
> > @@ -46,87 +46,86 @@ struct media_device_info {
> >   * Initial value to be used when a new entity is created
> >   * Drivers should change it to something useful
> >   */
> > -#define MEDIA_ENT_T_UNKNOWN	0x00000000
> > +#define MEDIA_ENT_F_UNKNOWN	0x00000000
> >  
> >  /*
> > - * Base numbers for entity types
> > + * Base number ranges for entity functions
> >   *
> > - * Please notice that the huge gap of 16 bits for each base is overkill!
> > - * 8 bits is more than enough to avoid starving entity types for each
> > - * subsystem.
> > - *
> > - * However, It is kept this way just to avoid binary breakages with the
> > - * namespace provided on legacy versions of this header.
> > + * NOTE: those ranges and entity function number are spased just to
> 
> s/spased/phased/
> 
> > + * make easier to maintain this file. Userspace should not rely on
> 
> s/make/make it/
> 
> > + * the ranges to identify a group of function types, as newer
> > + * functions can be added with any name within the full u32 range.
> >   */
> > -#define MEDIA_ENT_T_DVB_BASE		0x00000000
> > -#define MEDIA_ENT_T_V4L2_BASE		0x00010000
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
> > -#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
> > +#define MEDIA_ENT_F_BASE		0x00000000
> > +#define MEDIA_ENT_F_OLD_BASE		0x00010000
> > +#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
> >  
> >  /*
> > - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
> > - *	read()/write() data I/O associated with the V4L2 devnodes.
> > + * DVB entities
> >   */
> > -#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
> > -	/*
> > -	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
> > -	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
> > -	 * to be declared for FB, ALSA and DVB entities.
> > -	 * As those values were never actually used in practice, we're just
> > -	 * adding them as backward compatibility macros and keeping the
> > -	 * numberspace clean here. This way, we avoid breaking compilation,
> > -	 * in the case of having some userspace application using the old
> > -	 * symbols.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
> > -#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
> > -
> > -/* V4L2 Sub-device entities */
> > -
> > -	/*
> > -	 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > -	 * in order to preserve backward compatibility.
> > -	 * Drivers should change to the proper subdev type before
> > -	 * registering the entity.
> > -	 */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
> > -	/* A converter of analogue video to its digital representation. */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
> > -	/* Tuner entity is actually both V4L2 and DVB subdev */
> > -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
> > +#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
> > +#define MEDIA_ENT_F_MPEG_TS_DEMUX	(MEDIA_ENT_F_BASE + 2)
> > +#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
> > +#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
> >  
> > -/* DVB entities */
> > -#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
> > -#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
> > -#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
> > -#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
> > -#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
> > -
> > -/* Connectors */
> > -#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE)
> > -#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
> > -#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 2)
> > +/*
> > + * Connectors
> > + */
> > +#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
> > +#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
> > +#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
> >  	/* For internal test signal generators and other debug connectors */
> > -#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 3)
> > +#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
> > +
> > +/*
> > + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
> > + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
> > + * with the legacy v1 API.The number range is out of range by purpose:
> > + * several previously reserved numbers got excluded from this range.
> > + *
> > + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
> > + * in order to preserve backward compatibility.
> > + * Drivers should change to the proper subdev type before
> > + * registering the entity.
> > + */
> > +
> > +#define MEDIA_ENT_F_IO  		(MEDIA_ENT_F_OLD_BASE + 1)
> > +
> > +#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
> > +#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
> > +#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
> > +#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
> > +#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
> > +
> > +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
> >  
> >  #ifndef __KERNEL__
> > -/* Legacy symbols used to avoid userspace compilation breakages */
> > +
> > +/*
> > + * Legacy symbols used to avoid userspace compilation breakages
> > + *
> > + * Those symbols map the entity function into types and should be
> > + * used only on legacy programs for legacy hardware. Don't rely
> > + * on those for MEDIA_IOC_G_TOPOLOGY.
> > + */
> >  #define MEDIA_ENT_TYPE_SHIFT		16
> >  #define MEDIA_ENT_TYPE_MASK		0x00ff0000
> >  #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
> >  
> > -#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
> > -#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
> > -
> > -#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
> > -
> > +#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
> > +#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO
> >  #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
> >  #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
> >  #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
> > +
> > +#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO
> > +#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
> > +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
> >  #endif
> >  
> >  /* Entity flags */
> > 
> 
> Overall I really like this.

Fixes applied.

The actual patch merged follows.

---


[media] uapi/media.h: Rename entities types to functions

Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_
and add the backward compatibility bits.

The changes at the .c files was generated by the following
coccinelle script:

@@
@@
-MEDIA_ENT_T_UNKNOWN
+MEDIA_ENT_F_UNKNOWN
@@
@@
-MEDIA_ENT_T_DVB_BASE
+MEDIA_ENT_F_DVB_BASE
@@
@@
-MEDIA_ENT_T_V4L2_BASE
+MEDIA_ENT_F_V4L2_BASE
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_BASE
+MEDIA_ENT_F_V4L2_SUBDEV_BASE
@@
@@
-MEDIA_ENT_T_CONNECTOR_BASE
+MEDIA_ENT_F_CONNECTOR_BASE
@@
@@
-MEDIA_ENT_T_V4L2_VIDEO
+MEDIA_ENT_F_IO_V4L
@@
@@
-MEDIA_ENT_T_V4L2_VBI
+MEDIA_ENT_F_IO_VBI
@@
@@
-MEDIA_ENT_T_V4L2_SWRADIO
+MEDIA_ENT_F_IO_SWRADIO
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN
+MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
@@
@@
-MEDIA_ENT_T_CONN_RF
+MEDIA_ENT_F_CONN_RF
@@
@@
-MEDIA_ENT_T_CONN_SVIDEO
+MEDIA_ENT_F_CONN_SVIDEO
@@
@@
-MEDIA_ENT_T_CONN_COMPOSITE
+MEDIA_ENT_F_CONN_COMPOSITE
@@
@@
-MEDIA_ENT_T_CONN_TEST
+MEDIA_ENT_F_CONN_TEST
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
+MEDIA_ENT_F_CAM_SENSOR
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_FLASH
+MEDIA_ENT_F_FLASH
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_LENS
+MEDIA_ENT_F_LENS
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_DECODER
+MEDIA_ENT_F_ATV_DECODER
@@
@@
-MEDIA_ENT_T_V4L2_SUBDEV_TUNER
+MEDIA_ENT_F_TUNER
@@
@@
-MEDIA_ENT_T_DVB_DEMOD
+MEDIA_ENT_F_DTV_DEMOD
@@
@@
-MEDIA_ENT_T_DVB_DEMUX
+MEDIA_ENT_F_TS_DEMUX
@@
@@
-MEDIA_ENT_T_DVB_TSOUT
+MEDIA_ENT_F_IO_DTV
@@
@@
-MEDIA_ENT_T_DVB_CA
+MEDIA_ENT_F_DTV_CA
@@
@@
-MEDIA_ENT_T_DVB_NET_DECAP
+MEDIA_ENT_F_DTV_NET_DECAP

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index f6fc95d1345b..f64e8b3fb687 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -242,7 +242,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 		if (!entity->name)
 			return -ENOMEM;
 
-		entity->function = MEDIA_ENT_T_DVB_TSOUT;
+		entity->function = MEDIA_ENT_F_IO_DTV;
 		pads->flags = MEDIA_PAD_FL_SINK;
 
 		ret = media_entity_init(entity, 1, pads);
@@ -315,18 +315,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
 
 	switch (type) {
 	case DVB_DEVICE_FRONTEND:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_DEMUX:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX;
+		dvbdev->entity->function = MEDIA_ENT_F_TS_DEMUX;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		for (i = 1; i < npads; i++)
 			dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE;
 		break;
 	case DVB_DEVICE_CA:
-		dvbdev->entity->function = MEDIA_ENT_T_DVB_CA;
+		dvbdev->entity->function = MEDIA_ENT_F_DTV_CA;
 		dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK;
 		dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE;
 		break;
@@ -556,16 +556,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMOD:
+		case MEDIA_ENT_F_DTV_DEMOD:
 			demod = entity;
 			break;
-		case MEDIA_ENT_T_DVB_DEMUX:
+		case MEDIA_ENT_F_TS_DEMUX:
 			demux = entity;
 			break;
-		case MEDIA_ENT_T_DVB_CA:
+		case MEDIA_ENT_F_DTV_CA:
 			ca = entity;
 			break;
 		}
@@ -594,7 +594,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 	/* Create demux links for each ringbuffer/pad */
 	if (demux) {
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strncmp(entity->name, DVR_TSOUT,
 				    strlen(DVR_TSOUT))) {
 					ret = media_create_pad_link(demux,
@@ -639,7 +639,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
 		}
 
 		media_device_for_each_entity(entity, mdev) {
-			if (entity->function == MEDIA_ENT_T_DVB_TSOUT) {
+			if (entity->function == MEDIA_ENT_F_IO_DTV) {
 				if (!strcmp(entity->name, DVR_TSOUT)) {
 					link = media_create_intf_link(entity,
 							intf,
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c
index a6fbe78a70e3..39fab1ab921c 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,7 +775,7 @@ static int au8522_probe(struct i2c_client *client,
 	state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 9d99182cd165..7150f35d5935 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto free_and_quit;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	return 0;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 0fca8677014c..2ebe9efdfc1b 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1213,7 +1213,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_T_V4L2_SUBDEV_DECODER;
+	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c
index f45108c84f4d..b1bc4d0f76f2 100644
--- a/drivers/media/i2c/as3645a.c
+++ b/drivers/media/i2c/as3645a.c
@@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev.entity.function = MEDIA_ENT_F_FLASH;
 
 	mutex_init(&flash->power_lock);
 
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index e84e042610fa..f2f0992c7e54 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5208,7 +5208,7 @@ static int cx25840_probe(struct i2c_client *client,
 	state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
 				state->pads);
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index aa8b4832a1bc..98266f707ea0 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH;
 
 	return rval;
 
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
index a52cc3a6fb55..ba5ee0d7a78e 100644
--- a/drivers/media/i2c/lm3646.c
+++ b/drivers/media/i2c/lm3646.c
@@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
-	flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH;
 	return rval;
 
 err_out:
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index ae5645fe3a6e..bec5cea23b65 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client,
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	init_waitqueue_head(&info->irq_waitq);
 	mutex_init(&info->lock);
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 0226fc668529..47ea3f79eacc 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client,
 		goto np_err;
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 8a2efe2a24c4..cf8e71610248 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client,
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 27c4def7e4fc..adb4aab45c10 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client,
 		return ret;
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index dd48e35ede28..3d578f2ce7b2 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 
 	state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE;
 	state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
 							state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK;
 	state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE;
-	oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	oif_sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
 							state->oif_pads);
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 026d08740537..bacec84e773f 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 1d47b30953a4..564938ab2abd 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
 
 static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd)
 {
-	return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR;
 }
 
 static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd)
@@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index d7244234473e..d71d104441bd 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index ef325b653697..3eaa69ee341b 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor)
 
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
-	sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
+	sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	/* final steps */
 	smiapp_read_frame_fmt(sensor);
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 11e426dbe891..455dd4e6a1da 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1095,7 +1095,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_T_V4L2_SUBDEV_DECODER;
+	decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	ret = media_entity_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 a5ee2b8df429..216a07956fe9 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1012,7 +1012,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_T_V4L2_SUBDEV_DECODER;
+	device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER;
 
 	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 83525ac29328..f177d50c7a44 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -611,8 +611,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 {
 	int i;
 
-	if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN ||
-	    entity->function == MEDIA_ENT_T_UNKNOWN)
+	if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
+	    entity->function == MEDIA_ENT_F_UNKNOWN)
 		dev_warn(mdev->dev,
 			 "Entity type for entity %s was not initialized!\n",
 			 entity->name);
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 1a28e17474c9..06eb74344507 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		struct xvip_dma *dma;
 
-		if (entity->function != MEDIA_ENT_T_V4L2_VIDEO)
+		if (entity->function != MEDIA_ENT_F_IO_V4L)
 			continue;
 
 		dma = to_xvip_dma(media_entity_to_video_device(entity));
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 865d68dc4dc8..1b207fa16a55 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -266,10 +266,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 642a6a658a20..150824fe382a 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1836,18 +1836,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
 
 		switch (AUVI_INPUT(i).type) {
 		case AU0828_VMUX_COMPOSITE:
-			ent->function = MEDIA_ENT_T_CONN_COMPOSITE;
+			ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
 			break;
 		case AU0828_VMUX_SVIDEO:
-			ent->function = MEDIA_ENT_T_CONN_SVIDEO;
+			ent->function = MEDIA_ENT_F_CONN_SVIDEO;
 			break;
 		case AU0828_VMUX_CABLE:
 		case AU0828_VMUX_TELEVISION:
 		case AU0828_VMUX_DVB:
-			ent->function = MEDIA_ENT_T_CONN_RF;
+			ent->function = MEDIA_ENT_F_CONN_RF;
 			break;
 		default: /* AU0828_VMUX_DEBUG */
-			ent->function = MEDIA_ENT_T_CONN_TEST;
+			ent->function = MEDIA_ENT_F_CONN_TEST;
 			break;
 		}
 
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 5062c42a694c..0e1efc59ff58 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev)
 
 	media_device_for_each_entity(entity, mdev) {
 		switch (entity->function) {
-		case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+		case MEDIA_ENT_F_TUNER:
 			tuner = entity;
 			break;
-		case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+		case MEDIA_ENT_F_ATV_DECODER:
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index e85ef4729333..86c9cbd02016 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	 * this should be enough for the actual needs.
 	 */
 	media_device_for_each_entity(entity, mdev) {
-		if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) {
+		if (entity->function == MEDIA_ENT_F_ATV_DECODER) {
 			decoder = entity;
 			break;
 		}
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index e8fc5ec8fc35..05fc4df61b85 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -698,7 +698,7 @@ register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
 	t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-	t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+	t->sd.entity.function = MEDIA_ENT_F_TUNER;
 	t->sd.entity.name = t->name;
 
 	ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 965449958e97..ed96642c27bf 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd)
 	if (v4l2_dev->mdev) {
 		/* Remove interfaces and interface links */
 		media_devnode_remove(vdev->intf_devnode);
-		if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN)
+		if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN)
 			media_device_unregister_entity(&vdev->entity);
 	}
 #endif
@@ -735,20 +735,20 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
-	vdev->entity.function = MEDIA_ENT_T_UNKNOWN;
+	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
 	case VFL_TYPE_GRABBER:
 		intf_type = MEDIA_INTF_T_V4L_VIDEO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO;
+		vdev->entity.function = MEDIA_ENT_F_IO_V4L;
 		break;
 	case VFL_TYPE_VBI:
 		intf_type = MEDIA_INTF_T_V4L_VBI;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_VBI;
+		vdev->entity.function = MEDIA_ENT_F_IO_VBI;
 		break;
 	case VFL_TYPE_SDR:
 		intf_type = MEDIA_INTF_T_V4L_SWRADIO;
-		vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO;
+		vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO;
 		break;
 	case VFL_TYPE_RADIO:
 		intf_type = MEDIA_INTF_T_V4L_RADIO;
@@ -766,7 +766,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return 0;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		vdev->entity.name = vdev->name;
 
 		/* Needed just for backward compatibility with legacy MC API */
@@ -793,7 +793,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 		return -ENOMEM;
 	}
 
-	if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) {
+	if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) {
 		struct media_link *link;
 
 		link = media_create_intf_link(&vdev->entity,
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index cf7b3cb9a373..5c686a24712b 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
+	sd->entity.function = MEDIA_ENT_F_FLASH;
 
 	ret = v4l2_flash_init_controls(v4l2_flash, config);
 	if (ret < 0)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b440cb66669c..d63083803144 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,
 		return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
 	}
 
-	WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO,
+	WARN(pad->entity->function != MEDIA_ENT_F_IO_V4L,
 	     "Driver bug! Wrong media entity type 0x%08x, entity %s\n",
 	     pad->entity->function, pad->entity->name);
 
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
-	sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN;
+	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 70ccd6cf14c1..df84e8eeb24b 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -274,9 +274,9 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_VIDEO:
-	case MEDIA_ENT_T_V4L2_VBI:
-	case MEDIA_ENT_T_V4L2_SWRADIO:
+	case MEDIA_ENT_F_IO_V4L:
+	case MEDIA_ENT_F_IO_VBI:
+	case MEDIA_ENT_F_IO_SWRADIO:
 		return true;
 	default:
 		return false;
@@ -289,12 +289,12 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 		return false;
 
 	switch (entity->function) {
-	case MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN:
-	case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR:
-	case MEDIA_ENT_T_V4L2_SUBDEV_FLASH:
-	case MEDIA_ENT_T_V4L2_SUBDEV_LENS:
-	case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
-	case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
+	case MEDIA_ENT_F_CAM_SENSOR:
+	case MEDIA_ENT_F_FLASH:
+	case MEDIA_ENT_F_LENS:
+	case MEDIA_ENT_F_ATV_DECODER:
+	case MEDIA_ENT_F_TUNER:
 		return true;
 
 	default:
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 290dd5585dc8..ff6a8010c520 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -46,87 +46,93 @@ struct media_device_info {
  * Initial value to be used when a new entity is created
  * Drivers should change it to something useful
  */
-#define MEDIA_ENT_T_UNKNOWN	0x00000000
+#define MEDIA_ENT_F_UNKNOWN	0x00000000
 
 /*
- * Base numbers for entity types
+ * Base number ranges for entity functions
  *
- * Please notice that the huge gap of 16 bits for each base is overkill!
- * 8 bits is more than enough to avoid starving entity types for each
- * subsystem.
- *
- * However, It is kept this way just to avoid binary breakages with the
- * namespace provided on legacy versions of this header.
+ * NOTE: those ranges and entity function number are phased just to
+ * make it easier to maintain this file. Userspace should not rely on
+ * the ranges to identify a group of function types, as newer
+ * functions can be added with any name within the full u32 range.
  */
-#define MEDIA_ENT_T_DVB_BASE		0x00000000
-#define MEDIA_ENT_T_V4L2_BASE		0x00010000
-#define MEDIA_ENT_T_V4L2_SUBDEV_BASE	0x00020000
-#define MEDIA_ENT_T_CONNECTOR_BASE	0x00030000
+#define MEDIA_ENT_F_BASE		0x00000000
+#define MEDIA_ENT_F_OLD_BASE		0x00010000
+#define MEDIA_ENT_F_OLD_SUBDEV_BASE	0x00020000
 
 /*
- * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
- *	read()/write() data I/O associated with the V4L2 devnodes.
+ * DVB entities
  */
-#define MEDIA_ENT_T_V4L2_VIDEO		(MEDIA_ENT_T_V4L2_BASE + 1)
-	/*
-	 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
-	 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
-	 * to be declared for FB, ALSA and DVB entities.
-	 * As those values were never actually used in practice, we're just
-	 * adding them as backward compatibility macros and keeping the
-	 * numberspace clean here. This way, we avoid breaking compilation,
-	 * in the case of having some userspace application using the old
-	 * symbols.
-	 */
-#define MEDIA_ENT_T_V4L2_VBI		(MEDIA_ENT_T_V4L2_BASE + 5)
-#define MEDIA_ENT_T_V4L2_SWRADIO	(MEDIA_ENT_T_V4L2_BASE + 6)
-
-/* V4L2 Sub-device entities */
+#define MEDIA_ENT_F_DTV_DEMOD		(MEDIA_ENT_F_BASE + 1)
+#define MEDIA_ENT_F_TS_DEMUX		(MEDIA_ENT_F_BASE + 2)
+#define MEDIA_ENT_F_DTV_CA		(MEDIA_ENT_F_BASE + 3)
+#define MEDIA_ENT_F_DTV_NET_DECAP	(MEDIA_ENT_F_BASE + 4)
 
 /*
+ * Connectors
+ */
+#define MEDIA_ENT_F_CONN_RF		(MEDIA_ENT_F_BASE + 21)
+#define MEDIA_ENT_F_CONN_SVIDEO		(MEDIA_ENT_F_BASE + 22)
+#define MEDIA_ENT_F_CONN_COMPOSITE	(MEDIA_ENT_F_BASE + 23)
+	/* For internal test signal generators and other debug connectors */
+#define MEDIA_ENT_F_CONN_TEST		(MEDIA_ENT_F_BASE + 24)
+
+/*
+ * I/O entities
+ */
+#define MEDIA_ENT_F_IO_DTV  		(MEDIA_ENT_F_BASE + 31)
+#define MEDIA_ENT_F_IO_VBI  		(MEDIA_ENT_F_BASE + 32)
+#define MEDIA_ENT_F_IO_SWRADIO		(MEDIA_ENT_F_BASE + 33)
+
+/*
+ * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
+ * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
+ * with the legacy v1 API.The number range is out of range by purpose:
+ * several previously reserved numbers got excluded from this range.
+ *
  * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
  * in order to preserve backward compatibility.
  * Drivers should change to the proper subdev type before
  * registering the entity.
  */
-#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
-#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
-	/* A converter of analogue video to its digital representation. */
-#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
-	/* Tuner entity is actually both V4L2 and DVB subdev */
-#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	(MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
-
-/* DVB entities */
-#define MEDIA_ENT_T_DVB_DEMOD		(MEDIA_ENT_T_DVB_BASE + 1)
-#define MEDIA_ENT_T_DVB_DEMUX		(MEDIA_ENT_T_DVB_BASE + 2)
-#define MEDIA_ENT_T_DVB_TSOUT		(MEDIA_ENT_T_DVB_BASE + 3)
-#define MEDIA_ENT_T_DVB_CA		(MEDIA_ENT_T_DVB_BASE + 4)
-#define MEDIA_ENT_T_DVB_NET_DECAP	(MEDIA_ENT_T_DVB_BASE + 5)
-
-/* Connectors */
-#define MEDIA_ENT_T_CONN_RF		(MEDIA_ENT_T_CONNECTOR_BASE + 1)
-#define MEDIA_ENT_T_CONN_SVIDEO		(MEDIA_ENT_T_CONNECTOR_BASE + 2)
-#define MEDIA_ENT_T_CONN_COMPOSITE	(MEDIA_ENT_T_CONNECTOR_BASE + 3)
-/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_T_CONN_TEST		(MEDIA_ENT_T_CONNECTOR_BASE + 4)
+
+#define MEDIA_ENT_F_IO_V4L  		(MEDIA_ENT_F_OLD_BASE + 1)
+
+#define MEDIA_ENT_F_CAM_SENSOR		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
+#define MEDIA_ENT_F_FLASH		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
+#define MEDIA_ENT_F_LENS		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
+#define MEDIA_ENT_F_ATV_DECODER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
+#define MEDIA_ENT_F_TUNER		(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
+
+#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN	MEDIA_ENT_F_OLD_SUBDEV_BASE
 
 #ifndef __KERNEL__
-/* Legacy symbols used to avoid userspace compilation breakages */
+
+/*
+ * Legacy symbols used to avoid userspace compilation breakages
+ *
+ * Those symbols map the entity function into types and should be
+ * used only on legacy programs for legacy hardware. Don't rely
+ * on those for MEDIA_IOC_G_TOPOLOGY.
+ */
 #define MEDIA_ENT_TYPE_SHIFT		16
 #define MEDIA_ENT_TYPE_MASK		0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
 
-#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_T_V4L2_BASE
-#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_T_V4L2_SUBDEV_BASE
-
-#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_T_V4L2_VIDEO
-
+#define MEDIA_ENT_T_DEVNODE		MEDIA_ENT_F_OLD_BASE
+#define MEDIA_ENT_T_DEVNODE_V4L		MEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB		(MEDIA_ENT_T_DEVNODE + 4)
+
+#define MEDIA_ENT_T_UNKNOWN		MEDIA_ENT_F_UNKNOWN
+#define MEDIA_ENT_T_V4L2_VIDEO		MEDIA_ENT_F_IO_V4L
+#define MEDIA_ENT_T_V4L2_SUBDEV		MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
+#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	MEDIA_ENT_F_CAM_SENSOR
+#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	MEDIA_ENT_F_FLASH
+#define MEDIA_ENT_T_V4L2_SUBDEV_LENS	MEDIA_ENT_F_LENS
+#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	MEDIA_ENT_F_ATV_DECODER
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER	MEDIA_ENT_F_TUNER
 #endif
 
 /* Entity flags */

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

* Re: [PATCH 18/18] [media] dvbdev: Don't create indirect links
  2015-09-11 15:48   ` Hans Verkuil
@ 2015-12-10 20:20     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 69+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-10 20:20 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Hans Verkuil

Em Fri, 11 Sep 2015 17:48:19 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/06/2015 07:31 PM, Mauro Carvalho Chehab wrote:
> > Indirect links are those whose the interface indirectly controls
> 
> s/the//
> 
> > other functions.
> > 
> > There are two interfaces that have indirect controls at the DVB
> > side:
> > - the network interface, with also controls the demux;
> 
> s/with/which/
> 
> > - the DVR interface with also controls the demux.
> 
> ditto
> 
> > 
> > One could argue that the frontend control to the tuner is indirect.
> > Well, that's debateable. There's no way to create subdef interfaces
> 
> s/debateable/debatable/
> s/subdef/subdev/
> 
> > for tuner and demod, as those devices are tightly coupled. So, it
> > was decided that just one interface is the best to control both
> > entities, and there's no plan (or easy way) to decouple both. So,
> > the DVB frontend interface should link to both entities.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> With the typos fixed:
> 
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Fixed, thanks.

> 
> Note: I am not convinced that the dvr->demux indirect link isn't needed, but
> it can be enabled later, so it's OK for me to keep it under #if 0 for now.

Yeah, I'm also not convinced if it would be worth to represent 
indirect links. That's why I opted to comment, instead of striping them.

> 
> Regards,
> 
> 	Hans
> 
> > 
> > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> > index ea76fe54e0e4..e9f24c1479dd 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -619,7 +619,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
> >  		}
> >  	}
> >  
> > -	/* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */
> > +	/* Create interface links for FE->tuner, DVR->demux and CA->ca */
> >  	media_device_for_each_intf(intf, mdev) {
> >  		if (intf->type == MEDIA_INTF_T_DVB_CA && ca) {
> >  			link = media_create_intf_link(ca, intf,
> > @@ -634,13 +634,19 @@ int dvb_create_media_graph(struct dvb_adapter *adap)
> >  			if (!link)
> >  				return -ENOMEM;
> >  		}
> > -
> > +#if 0
> > +		/*
> > +		 * Indirect link - let's not create yet, as we don't know how
> > +		 *		   to handle indirect links, nor if this will
> > +		 *		   actually be needed.
> > +		 */
> >  		if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) {
> >  			link = media_create_intf_link(demux, intf,
> >  						      MEDIA_LNK_FL_ENABLED);
> >  			if (!link)
> >  				return -ENOMEM;
> >  		}
> > +#endif
> >  		if (intf->type == MEDIA_INTF_T_DVB_DVR) {
> >  			ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT);
> >  			if (ret)
> > 
> 
> 

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

end of thread, other threads:[~2015-12-10 20:20 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-06 17:30 [PATCH 00/18] MC fixes, improvements and cleanups Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 01/18] [media] tuner-core: add an input pad Mauro Carvalho Chehab
2015-09-11 14:48   ` Hans Verkuil
2015-11-23 20:01   ` Laurent Pinchart
2015-11-24 11:00     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 02/18] [media] au0828: add support for the connectors Mauro Carvalho Chehab
2015-09-11 14:57   ` Hans Verkuil
2015-12-10 18:24     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 03/18] [media] au0828: Create connector links Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 04/18] [media] media-device: supress backlinks at G_TOPOLOGY ioctl Mauro Carvalho Chehab
2015-09-11 14:58   ` Hans Verkuil
2015-11-23 19:56   ` Laurent Pinchart
2015-11-24 10:57     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 05/18] [media] media-controller: enable all interface links at init Mauro Carvalho Chehab
2015-09-11 15:18   ` Hans Verkuil
2015-11-23 19:46   ` Laurent Pinchart
2015-12-10 11:37     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 06/18] [media] media.h: create connector entities for hybrid TV devices Mauro Carvalho Chehab
2015-09-11 15:19   ` Hans Verkuil
2015-09-11 15:19     ` Hans Verkuil
2015-11-23 18:09   ` Laurent Pinchart
2015-11-23 18:09     ` Laurent Pinchart
2015-12-10 18:43     ` Mauro Carvalho Chehab
2015-12-10 18:43       ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 07/18] [media] dvbdev: returns error if graph object creation fails Mauro Carvalho Chehab
2015-09-11 15:20   ` Hans Verkuil
2015-12-10 17:33     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 08/18] [media] dvb core: must check dvb_create_media_graph() Mauro Carvalho Chehab
2015-09-11 15:22   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 09/18] [media] media-entity: enforce check of interface and links creation Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 10/18] [media] cx231xx: enforce check for graph creation Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 11/18] [media] au0828:: " Mauro Carvalho Chehab
2015-09-11 15:23   ` Hans Verkuil
2015-09-06 17:30 ` [PATCH 12/18] [media] media-entity: must check media_create_pad_link() Mauro Carvalho Chehab
2015-09-11 15:24   ` Hans Verkuil
2015-11-23 17:54   ` Laurent Pinchart
2015-12-10 19:13     ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 13/18] [media] media-entity.h: rename entity.type to entity.function Mauro Carvalho Chehab
2015-09-06 17:30   ` Mauro Carvalho Chehab
2015-09-11 15:25   ` Hans Verkuil
2015-09-11 15:25     ` Hans Verkuil
2015-11-23 17:51   ` Laurent Pinchart
2015-11-23 17:51     ` Laurent Pinchart
2015-11-24 10:32     ` Mauro Carvalho Chehab
2015-11-24 10:32       ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 14/18] [media] media-device: export the entity function via new ioctl Mauro Carvalho Chehab
2015-09-06 17:30   ` Mauro Carvalho Chehab
2015-09-11 15:26   ` Hans Verkuil
2015-11-23 17:46   ` Laurent Pinchart
2015-11-23 17:46     ` Laurent Pinchart
2015-11-24 10:27     ` Mauro Carvalho Chehab
2015-11-24 10:27       ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 15/18] [media] uapi/media.h: Rename entities types to functions Mauro Carvalho Chehab
2015-09-06 17:30   ` Mauro Carvalho Chehab
2015-09-06 17:30   ` Mauro Carvalho Chehab
2015-09-11 15:36   ` Hans Verkuil
2015-09-11 15:36     ` Hans Verkuil
2015-09-11 15:36     ` Hans Verkuil
2015-12-10 19:54     ` Mauro Carvalho Chehab
2015-12-10 19:54       ` Mauro Carvalho Chehab
2015-12-10 19:54       ` Mauro Carvalho Chehab
2015-09-06 17:30 ` [PATCH 16/18] [media] DocBook: update entities documentation Mauro Carvalho Chehab
2015-09-06 17:31 ` [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Mauro Carvalho Chehab
2015-09-11 15:38   ` Hans Verkuil
2015-09-06 17:31 ` [PATCH 18/18] [media] dvbdev: Don't create indirect links Mauro Carvalho Chehab
2015-09-11 15:48   ` Hans Verkuil
2015-12-10 20:20     ` 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.