MC preparation patches
Subsystems (12)
v5 cover MC preparation patches
Those are the initial patches from my RFCv3 series of MC changes, plus one additional renaming patch and two debug ones. They address the comments received on PATCH v4 series.
The first 5 patches on this series ensures that all existing object types (entities, pads and links) will have an unique ID, as agreed at the MC workshop.
The next two patches add two debug functions, that helps with the tests of the MC changes. Both are enabled only if DEBUG or dynamic debug is enabled.
The first one just help to identify when the media_device register, remove and unregister functions are called. It helps to identify if those events happen before or after object creation.
The second one is more interesting: it hooks at the object init and remove functions and dump what's there at the new object when it got created. This is very useful to test the future patches, as we'll be able to track any topology changes.
Also, it demonstates the capability of the functions media_gobj_init() and media_gobj_remove() to track topology changes. Tracking topology changes is fundamental for the new API, in order to implement G_TOPOLOGY ioctl. They should contain, in the future, a callback to warn the several drivers envolved at the MC topology build about topology changes.
The last patch on this preparation series is just a renaming patch, that will avoid mess when future patches introduce the entity->interface links.
They're tested using the cx231xx V4L2 support.
Those are the new debug messages when the device is probed:
[ 2684.265619] cx231xx 3-2.4:1.1: Media device registered [ 2684.357670] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000001 entity#1 'cx25840 19-0044' [ 2684.359191] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000001 cx25840 19-0044 pad#1 [ 2684.360693] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000002 cx25840 19-0044 pad#2 [ 2684.362208] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000003 cx25840 19-0044 pad#3
[ 2686.437870] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000002 entity#2 '(tuner unset)' [ 2686.439474] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000004 (tuner unset) pad#4
[ 2688.450710] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000003 entity#3 'cx231xx #0 video' [ 2688.452395] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000005 cx231xx #0 video pad#5
[ 2688.455892] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000004 entity#4 'cx231xx #0 vbi' [ 2688.457632] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000006 cx231xx #0 vbi pad#6
[ 2688.500233] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000001 link#1: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2688.501830] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000002 link#2: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2688.503415] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000003 link#3: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2688.504977] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000004 link#4: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2688.506505] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000005 link#5: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2688.508074] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000006 link#6: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6
Those are the new debug messages when the device is removed:
[ 2953.872780] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000002 link#2: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2953.874470] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000003 link#3: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2953.876199] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000005 link#5: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2953.877830] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000001 cx25840 19-0044 pad#1 [ 2953.879454] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000002 cx25840 19-0044 pad#2 [ 2953.881020] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000003 cx25840 19-0044 pad#3 [ 2953.882569] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000001 entity#1 'cx25840 19-0044'
[ 2953.884093] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000001 link#1: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2953.885611] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000004 NXP TDA18271HD pad#4 [ 2953.887200] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000002 entity#2 'NXP TDA18271HD'
[ 2953.888638] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000004 link#4: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2953.890093] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000005 cx231xx #0 video pad#5 [ 2953.891549] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000003 entity#3 'cx231xx #0 video'
[ 2953.893006] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000006 link#6: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2953.894471] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000006 cx231xx #0 vbi pad#6 [ 2953.895955] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000004 entity#4 'cx231xx #0 vbi' [ 2953.897505] cx231xx 3-2.4:1.1: Media device released [ 2953.898924] cx231xx 3-2.4:1.1: Media device unregistered
It should be noticed that both links and backlinks are reported on the above. That's because now they're implemented as two separate links right now.
Mauro Carvalho Chehab (8):
[media] media: create a macro to get entity ID
[media] media: add a common struct to be embed on media graph objects [media] media: use media_gobj inside entities
[media] media: use media_gobj inside pads
[media] media: use media_gobj inside links
[media] media: add messages when media device gets (un)registered [media] media: add a debug message to warn about gobj creation/removal [media] media: rename the function that create pad links
Documentation/media-framework.txt | 2 +- drivers/media/dvb-core/dvbdev.c | 8 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 +- drivers/media/i2c/s5k5baf.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 4 +- drivers/media/media-device.c | 41 +++++-- drivers/media/media-entity.c | 123 ++++++++++++++++++++- drivers/media/platform/exynos4-is/media-dev.c | 16 +-- drivers/media/platform/omap3isp/isp.c | 18 +-- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 4 +- drivers/media/platform/omap3isp/ispresizer.c | 4 +- drivers/media/platform/s3c-camif/camif-core.c | 4 +- drivers/media/platform/vsp1/vsp1_drv.c | 4 +- drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 4 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +- drivers/media/usb/uvc/uvc_entity.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 8 +- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +- drivers/staging/media/omap4iss/iss.c | 12 +- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- include/media/media-device.h | 7 +- include/media/media-entity.h | 82 +++++++++++++- 32 files changed, 302 insertions(+), 87 deletions(-)
Signature · 1 line
2.4.3
RFC PATCH v5 1/8 media: create a macro to get entity ID
Instead of accessing directly entity.id, let's create a macro, as this field will be moved into a common struct later on.
drivers/media/media-device.c +4 -4
@@ -75,8 +75,8 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id)spin_lock (&mdev->lock);media_device_for_each_entity (entity, mdev) { -if ((entity->id = id && !next) || - (entity->id > id && next)) { +if (((media_entity_id (entity) = id) && !next) || + ((media_entity_id (entity) > id) && next)) {spin_unlock (&mdev->lock);return entity; }
@@ -102,7 +102,7 @@ static long media_device_enum_entities(struct media_device *mdev,if (ent =NULL )return -EINVAL ; - u_ent.id = ent->id; + 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;
@@ -120,7 +120,7 @@ static long media_device_enum_entities(struct media_device *mdev,static void media_device_kpad_to_upad (const struct media_pad *kpad,struct media_pad_desc *upad) { - upad->entity = kpad->entity->id; + upad->entity =media_entity_id (kpad->entity); upad->index = kpad->index; upad->flags = kpad->flags; }
drivers/media/media-entity.c +4 -4
@@ -140,10 +140,10 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph, graph->stack[graph->top].entity =NULL ;bitmap_zero (graph->entities,MEDIA_ENTITY_ENUM_MAX_ID ); -if (WARN_ON (entity->id >=MEDIA_ENTITY_ENUM_MAX_ID )) +if (WARN_ON (media_entity_id (entity) >=MEDIA_ENTITY_ENUM_MAX_ID ))return ; -__set_bit (entity->id, graph->entities); +__set_bit (media_entity_id (entity), graph->entities);stack_push (graph, entity); }EXPORT_SYMBOL_GPL (media_entity_graph_walk_start);
@@ -184,11 +184,11 @@ media_entity_graph_walk_next(struct media_entity_graph *graph)/* Get the entity in the other end of the link . */ next =media_entity_other (entity, link); -if (WARN_ON (next->id >=MEDIA_ENTITY_ENUM_MAX_ID )) +if (WARN_ON (media_entity_id (next) >=MEDIA_ENTITY_ENUM_MAX_ID ))return NULL ;/* Has the entity already been visited? */ -if (__test_and_set_bit (next->id, graph->entities)) { +if (__test_and_set_bit (media_entity_id (next), graph->entities)) {link_top (graph)++;continue ; }
drivers/media/platform/vsp1/vsp1_video.c +2 -2
@@ -352,10 +352,10 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,break ;/* Ensure the branch has no loop. */ -if (entities & (1 << entity->subdev.entity.id)) +if (entities & (1 <<media_entity_id (&entity->subdev.entity)))return -EPIPE ; - entities |=1 << entity->subdev.entity.id; + entities |=1 <<media_entity_id (&entity->subdev.entity);/* UDS can't be chained. */ if (entity->type =VSP1_ENTITY_UDS ) {
include/media/media-entity.h +5 -0
@@ -113,6 +113,11 @@ static inline u32 media_entity_subtype(struct media_entity *entity)return entity->type &MEDIA_ENT_SUBTYPE_MASK ; } +static inline u32 media_entity_id (struct media_entity *entity) +{ +return entity->id; +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64
Signature · 1 line
2.4.3
RFC PATCH v5 2/8 media: add a common struct to be embed on media graph objects
In reply to Mauro Carvalho ChehabDue to the MC API proposed changes, we'll need to have an unique object ID for all graph objects, and have some shared fields that will be common on all media graph objects.
Right now, the only common object is the object ID, but other fields will be added later on.
drivers/media/media-entity.c +32 -0
@@ -27,6 +27,38 @@#include <media/media-device.h> /** +* media_gobj_init - Initialize a graph object +* +* @mdev: Pointer to the media_device that contains the object +* @type: Type of the object +* @gobj: Pointer to the object +* +* This routine initializes the embedded struct media_gobj inside a +* media graph object. It is called automatically if media_*_create() +* calls are used. However, if the object (entity, link, pad, interface) +* is embedded on some other object, this function should be called before +* registering the object at the media controller. +*/ +void media_gobj_init (struct media_device *mdev, +enum media_gobj_type type, +struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** +* media_gobj_remove - Stop using a graph object on a media device +* +* @graph_obj: Pointer to the object +* +* This should be called at media_device_unregister_*() routines +*/ +void media_gobj_remove (struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads.
include/media/media-entity.h +59 -0
77 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH RFC v5 2/8] [media] media: add a common struct to be embed on media graph objects
Quoted 63 lines · Mauro Carvalho Chehab
Due to the MC API proposed changes, we'll need to have an unique object ID for all graph objects, and have some shared fields that will be common on all media graph objects.
Right now, the only common object is the object ID, but other fields will be added later on.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +32
-0@@ -27,6 +27,38 @@#include <media/media-device.h> /** +* media_gobj_init - Initialize a graph object +* +* @mdev: Pointer to the media_device that contains the object +* @type: Type of the object +* @gobj: Pointer to the object +* +* This routine initializes the embedded struct media_gobj inside a +* media graph object. It is called automatically if media_*_create() +* calls are used. However, if the object (entity, link, pad, interface) +* is embedded on some other object, this function should be called before +* registering the object at the media controller. +*/ +void media_gobj_init (struct media_device *mdev, +enum media_gobj_type type, +struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** +* media_gobj_remove - Stop using a graph object on a media device +* +* @graph_obj: Pointer to the object +* +* This should be called at media_device_unregister_*() routines +*/ +void media_gobj_remove (struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. include/media/media-entity.h +3
-0@@ -28,6 +28,37 @@#include <linux/list.h> #include <linux/media.h> +/* Enums used internally at the media controller to represent graphs */ + +/**
include/media/media-entity.h line 43
Quoted 10 lines
include/media/media-entity.h +10
-0+* enum media_gobj_type - type of a graph element +* +*/ +enum media_gobj_type { +/* FIXME: add the types here, as we embed media_gobj */ +MEDIA_GRAPH_NONE +}; + +#define BITS_PER_TYPE 8 +#define BITS_PER_LOCAL_ID (32 - BITS_PER_TYPE)
I think that these two defines should be prefixed with MEDIA_. They are a bit too generic for a header that's going to be used in lots of drivers.
I also think that the local ID mask should be a define as well:
#define MEDIA_LOCAL_ID_MASK GENMASK(BITS_PER_LOCAL_ID - 1, 0)
That will make the code where this mask is used a bit more readable.
Quoted 31 lines
include/media/media-entity.h +24
-0+ +/* Structs to represent the objects that belong to a media graph */ + +/** +* struct media_gobj - Define a graph object. +* +* @id: Non-zero object ID identifier. The ID should be unique +* inside a media_device, as it is composed by +* BITS_PER_TYPE to store the type plus BITS_PER_LOCAL_ID +* to store a per-type ID (called as "local ID"). +* +* All elements on the media graph should have this struct embedded +*/ +struct media_gobj { +u32 id; +}; + +struct media_pipeline { };@@ -118,6 +149,26 @@ static inline u32 media_entity_id(struct media_entity *entity)return entity->id; } +static inline enum media_gobj_type media_type (struct media_gobj *gobj) +{ +return gobj->id >>BITS_PER_LOCAL_ID ; +} + +static inline u32 media_localid (struct media_gobj *gobj)
include/media/media-entity.h static inline u32 media_entity_id(struct media_entity *entity) · line 167
Quoted 10 lines
include/media/media-entity.h +10
-0+{ +return gobj->id &GENMASK (BITS_PER_LOCAL_ID -1 ,0 ); +} + +static inline u32 media_gobj_gen_id (enum media_gobj_type type,u32 local_id) +{ +u32 id; + + id = type <<BITS_PER_LOCAL_ID ; + id |=GENMASK (BITS_PER_LOCAL_ID -1 ,0 ) & local_id;
I'd swap this: id |= local_id & MEDIA_LOCAL_ID_MASK;
It feels more natural that way and it is consistent with media_localid() above.
Regards,
Hans
Quoted 23 lines
include/media/media-entity.h +12
-0+ +return id; +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64@@ -131,6 +182,14 @@ struct media_entity_graph {int top; }; +#define gobj_to_entity (gobj) \ + container_of(gobj, struct media_entity, graph_obj) + +void media_gobj_init (struct media_device *mdev, +enum media_gobj_type type, +struct media_gobj *gobj); +void media_gobj_remove (struct media_gobj *gobj); +int media_entity_init (struct media_entity *entity,u16 num_pads,struct media_pad *pads);void media_entity_cleanup (struct media_entity *entity);
Re: [PATCH RFC v5 2/8] [media] media: add a common struct to be embed on media graph objects
Em Wed, 19 Aug 2015 10:17:46 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 80 lines · Mauro Carvalho Chehab
Quoted 63 lines
Due to the MC API proposed changes, we'll need to have an unique object ID for all graph objects, and have some shared fields that will be common on all media graph objects.
Right now, the only common object is the object ID, but other fields will be added later on.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +32
-0@@ -27,6 +27,38 @@#include <media/media-device.h> /** +* media_gobj_init - Initialize a graph object +* +* @mdev: Pointer to the media_device that contains the object +* @type: Type of the object +* @gobj: Pointer to the object +* +* This routine initializes the embedded struct media_gobj inside a +* media graph object. It is called automatically if media_*_create() +* calls are used. However, if the object (entity, link, pad, interface) +* is embedded on some other object, this function should be called before +* registering the object at the media controller. +*/ +void media_gobj_init (struct media_device *mdev, +enum media_gobj_type type, +struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** +* media_gobj_remove - Stop using a graph object on a media device +* +* @graph_obj: Pointer to the object +* +* This should be called at media_device_unregister_*() routines +*/ +void media_gobj_remove (struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} + +/** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. include/media/media-entity.h +3
-0@@ -28,6 +28,37 @@#include <linux/list.h> #include <linux/media.h> +/* Enums used internally at the media controller to represent graphs */ + +/** include/media/media-entity.h line 43
Quoted 10 lines
include/media/media-entity.h +10
-0+* enum media_gobj_type - type of a graph element +* +*/ +enum media_gobj_type { +/* FIXME: add the types here, as we embed media_gobj */ +MEDIA_GRAPH_NONE +}; + +#define BITS_PER_TYPE 8 +#define BITS_PER_LOCAL_ID (32 - BITS_PER_TYPE)I think that these two defines should be prefixed with
MEDIA_. They are a bit too generic for a header that's going to be used in lots of drivers.
I also think that the local ID mask should be a define as well:
Quoted 3 lines
#define
MEDIA_LOCAL_ID_MASKGENMASK(BITS_PER_LOCAL_ID - 1, 0)That will make the code where this mask is used a bit more readable.
Ok, I'll change them.
Quoted 45 lines
Quoted 32 lines
include/media/media-entity.h +24
-0+ +/* Structs to represent the objects that belong to a media graph */ + +/** +* struct media_gobj - Define a graph object. +* +* @id: Non-zero object ID identifier. The ID should be unique +* inside a media_device, as it is composed by +* BITS_PER_TYPE to store the type plus BITS_PER_LOCAL_ID +* to store a per-type ID (called as "local ID"). +* +* All elements on the media graph should have this struct embedded +*/ +struct media_gobj { +u32 id; +}; + +struct media_pipeline { };@@ -118,6 +149,26 @@ static inline u32 media_entity_id(struct media_entity *entity)return entity->id; } +static inline enum media_gobj_type media_type (struct media_gobj *gobj) +{ +return gobj->id >>BITS_PER_LOCAL_ID ; +} + +static inline u32 media_localid (struct media_gobj *gobj)include/media/media-entity.h static inline u32 media_entity_id(struct media_entity *entity) · line 167
Quoted 10 lines
include/media/media-entity.h +10
-0+{ +return gobj->id &GENMASK (BITS_PER_LOCAL_ID -1 ,0 ); +} + +static inline u32 media_gobj_gen_id (enum media_gobj_type type,u32 local_id) +{ +u32 id; + + id = type <<BITS_PER_LOCAL_ID ; + id |=GENMASK (BITS_PER_LOCAL_ID -1 ,0 ) & local_id;I'd swap this: id |=
local_id&MEDIA_LOCAL_ID_MASK;
Quoted 1 line
It feels more natural that way and it is consistent with
media_localid()above.
Ok.
Quoted 29 lines
Regards,
Hans
Quoted 23 lines
include/media/media-entity.h +12
-0+ +return id; +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64@@ -131,6 +182,14 @@ struct media_entity_graph {int top; }; +#define gobj_to_entity (gobj) \ + container_of(gobj, struct media_entity, graph_obj) + +void media_gobj_init (struct media_device *mdev, +enum media_gobj_type type, +struct media_gobj *gobj); +void media_gobj_remove (struct media_gobj *gobj); +int media_entity_init (struct media_entity *entity,u16 num_pads,struct media_pad *pads);void media_entity_cleanup (struct media_entity *entity);
RFC PATCH v5 3/8 media: use media_gobj inside entities
In reply to Mauro Carvalho ChehabAs entities are graph elements, let's embed media_gobj on it. That ensures an unique ID for entities that can be global along the entire media controller.
For now, we'll keep the already existing entity ID. Such field need to be dropped at some point, but for now, let's not do this, to avoid needing to review all drivers and the userspace apps.
drivers/media/media-device.c +3 -5
@@ -377,7 +377,6 @@ int __must_check __media_device_register(struct media_device *mdev,if (WARN_ON (mdev->dev ==NULL || mdev->model[0 ] ==0 ))return -EINVAL ; - mdev->entity_id =1 ;INIT_LIST_HEAD (&mdev->entities);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);
@@ -431,10 +430,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity->parent = mdev;spin_lock (&mdev->lock); -if (entity->id ==0 ) - entity->id = mdev->entity_id++; -else - mdev->entity_id =max (entity->id +1 , mdev->entity_id); +/* Initialize media_gobj embedded at the entity */ +media_gobj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj);list_add_tail (&entity->list, &mdev->entities);spin_unlock (&mdev->lock);
@@ -457,6 +454,7 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); +media_gobj_remove (&entity->graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock); entity->parent =NULL ;
drivers/media/media-entity.c +6 -1
@@ -43,7 +43,12 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) { - /* For now, nothing to do */ +/* Create a per-type unique object ID */ +switch (type) { +case MEDIA_GRAPH_ENTITY : + gobj->id =media_gobj_gen_id (type, ++mdev->entity_id); +break ; + } }/**
include/media/media-device.h +2 -1
@@ -41,7 +41,7 @@ struct device;* @bus_info: Unique and stable device location identifier * @hw_revision: Hardware device revision * @driver_version: Device driver version -* @entity_id: ID of the next entity to be registered +* @entity_id: Unique ID used on the last entity registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock
@@ -69,6 +69,7 @@ struct media_device {u32 driver_version;u32 entity_id; +struct list_head entities;/* Protects the entities list */
include/media/media-entity.h +4 -5
@@ -33,10 +33,10 @@/** * enum media_gobj_type - type of a graph element * +* @MEDIA_GRAPH_ENTITY: Identify a media entity */ enum media_gobj_type { -/* FIXME: add the types here, as we embed media_gobj */ -MEDIA_GRAPH_NONE +MEDIA_GRAPH_ENTITY , };#define BITS_PER_TYPE 8
@@ -92,10 +92,9 @@ struct media_entity_operations { };struct media_entity { +struct media_gobj graph_obj;struct list_head list;struct media_device *parent;/* Media device this entity belongs to*/ -u32 id;/* Entity ID, unique in the parent media -* device context */ const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ u32 revision;/* Entity revision, driver specific */
@@ -146,7 +145,7 @@ static inline u32 media_entity_subtype(struct media_entity *entity)static inline u32 media_entity_id (struct media_entity *entity) { -return entity->id; +return entity->graph_obj.id; }static inline enum media_gobj_type media_type (struct media_gobj *gobj)
Signature · 1 line
2.4.3
RFC PATCH v5 4/8 media: use media_gobj inside pads
In reply to Mauro Carvalho ChehabPADs also need unique object IDs that won't conflict with the entity object IDs.
The pad objects are currently created via media_entity_init() and, once created, never change.
While this will likely change in the future in order to support dynamic changes, for now we'll keep PADs as arrays and initialize the media_gobj embedded structs when registering the entity.
drivers/media/media-device.c +11 -0
@@ -425,6 +425,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister);int __must_check media_device_register_entity (struct media_device *mdev,struct media_entity *entity) { +int i; +/* Warn if we apparently re-register an entity */ WARN_ON (entity->parent !=NULL ); entity->parent = mdev;
@@ -433,6 +435,12 @@ int __must_check media_device_register_entity(struct media_device *mdev,/* Initialize media_gobj embedded at the entity */ media_gobj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj);list_add_tail (&entity->list, &mdev->entities); + +/* Initialize objects at the pads */ +for (i =0 ; i < entity->num_pads; i++) +media_gobj_init (mdev,MEDIA_GRAPH_PAD , + &entity->pads[i].graph_obj); +spin_unlock (&mdev->lock);return 0 ;
@@ -448,12 +456,15 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);*/ void media_device_unregister_entity (struct media_entity *entity) { +int i;struct media_device *mdev = entity->parent;if (mdev ==NULL )return ;spin_lock (&mdev->lock); +for (i =0 ; i < entity->num_pads; i++) +media_gobj_remove (&entity->pads[i].graph_obj);media_gobj_remove (&entity->graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock);
drivers/media/media-entity.c +3 -0
@@ -48,6 +48,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_ENTITY : gobj->id =media_gobj_gen_id (type, ++mdev->entity_id);break ; +case MEDIA_GRAPH_PAD : + gobj->id =media_gobj_gen_id (type, ++mdev->pad_id); +break ; } }
include/media/media-device.h +2 -0
@@ -42,6 +42,7 @@ struct device;* @hw_revision: Hardware device revision * @driver_version: Device driver version * @entity_id: Unique ID used on the last entity registered +* @pad_id: Unique ID used on the last pad registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock
@@ -69,6 +70,7 @@ struct media_device {u32 driver_version;u32 entity_id; +u32 pad_id;struct list_head entities;
include/media/media-entity.h +3 -0
@@ -34,9 +34,11 @@* enum media_gobj_type - type of a graph element * * @MEDIA_GRAPH_ENTITY: Identify a media entity +* @MEDIA_GRAPH_PAD: Identify a media pad */ enum media_gobj_type {MEDIA_GRAPH_ENTITY , +MEDIA_GRAPH_PAD , };#define BITS_PER_TYPE 8
@@ -70,6 +72,7 @@ struct media_link { };struct media_pad { +struct media_gobj graph_obj;struct media_entity *entity;/* Entity this pad belongs to */ u16 index;/* Pad index in the entity pads array */ unsigned long flags;/* Pad flags (MEDIA_PAD_FL_*) */
Signature · 1 line
2.4.3
RFC PATCH v5 5/8 media: use media_gobj inside links
In reply to Mauro Carvalho ChehabJust like entities and pads, links also need to have unique Object IDs along a given media controller.
So, let's add a media_gobj inside it and initialize the object then a new link is created.
drivers/media/media-device.c +9 -0
@@ -436,6 +436,13 @@ int __must_check media_device_register_entity(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj);list_add_tail (&entity->list, &mdev->entities); +/* +* Initialize objects at the links +* in the case where links got created before entity register +*/ +for (i =0 ; i < entity->num_links; i++) +media_gobj_init (mdev,MEDIA_GRAPH_LINK , + &entity->links[i].graph_obj);/* Initialize objects at the pads */ for (i =0 ; i < entity->num_pads; i++) media_gobj_init(mdev, MEDIA_GRAPH_PAD,
@@ -463,6 +470,8 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); +for (i =0 ; i < entity->num_links; i++) +media_gobj_remove (&entity->links[i].graph_obj);for (i =0 ; i < entity->num_pads; i++)media_gobj_remove (&entity->pads[i].graph_obj);media_gobj_remove (&entity->graph_obj);
drivers/media/media-entity.c +10 -0
@@ -51,6 +51,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_PAD : gobj->id =media_gobj_gen_id (type, ++mdev->pad_id);break ; +case MEDIA_GRAPH_LINK : + gobj->id =media_gobj_gen_id (type, ++mdev->link_id); +break ; } }
@@ -469,6 +472,13 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; } +/* Initialize graph object embedded at the new link */ +if (entity->parent) +media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , + &entity->links[entity->num_links].graph_obj); +else +pr_warn ("Link created before entity register!\n" ); +return &entity->links[entity->num_links++]; }
include/media/media-device.h +2 -0
@@ -43,6 +43,7 @@ struct device;* @driver_version: Device driver version * @entity_id: Unique ID used on the last entity registered * @pad_id: Unique ID used on the last pad registered +* @link_id: Unique ID used on the last link registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock
@@ -71,6 +72,7 @@ struct media_device {u32 entity_id;u32 pad_id; +u32 link_id;struct list_head entities;
include/media/media-entity.h +3 -0
@@ -35,10 +35,12 @@* * @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad +* @MEDIA_GRAPH_LINK: Identify a media link */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD , +MEDIA_GRAPH_LINK , };#define BITS_PER_TYPE 8
@@ -65,6 +67,7 @@ struct media_pipeline { };struct media_link { +struct media_gobj graph_obj;struct media_pad *source;/* Source pad */ struct media_pad *sink;/* Sink pad */ struct media_link *reverse;/* Link in the reverse direction */
Signature · 1 line
2.4.3
Re: [PATCH RFC v5 5/8] [media] media: use media_gobj inside links
Quoted 7 lines · Mauro Carvalho Chehab
Just like entities and pads, links also need to have unique Object IDs along a given media controller.
So, let's add a
media_gobjinside it and initialize the object then a new link is created.Signed-off-by Mauro Carvalho Chehab <[email protected]>
Thanks!
Hans
Quoted 102 lines
drivers/media/media-device.c +9
-0@@ -436,6 +436,13 @@ int __must_check media_device_register_entity(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj);list_add_tail (&entity->list, &mdev->entities); +/* +* Initialize objects at the links +* in the case where links got created before entity register +*/ +for (i =0 ; i < entity->num_links; i++) +media_gobj_init (mdev,MEDIA_GRAPH_LINK , + &entity->links[i].graph_obj);/* Initialize objects at the pads */ for (i =0 ; i < entity->num_pads; i++) media_gobj_init(mdev, MEDIA_GRAPH_PAD,@@ -463,6 +470,8 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); +for (i =0 ; i < entity->num_links; i++) +media_gobj_remove (&entity->links[i].graph_obj);for (i =0 ; i < entity->num_pads; i++)media_gobj_remove (&entity->pads[i].graph_obj);media_gobj_remove (&entity->graph_obj);drivers/media/media-entity.c +10
-0@@ -51,6 +51,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_PAD : gobj->id =media_gobj_gen_id (type, ++mdev->pad_id);break ; +case MEDIA_GRAPH_LINK : + gobj->id =media_gobj_gen_id (type, ++mdev->link_id); +break ; } }@@ -469,6 +472,13 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; } +/* Initialize graph object embedded at the new link */ +if (entity->parent) +media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , + &entity->links[entity->num_links].graph_obj); +else +pr_warn ("Link created before entity register!\n" ); +return &entity->links[entity->num_links++]; }include/media/media-device.h +2
-0@@ -43,6 +43,7 @@ struct device;* @driver_version: Device driver version * @entity_id: Unique ID used on the last entity registered * @pad_id: Unique ID used on the last pad registered +* @link_id: Unique ID used on the last link registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -71,6 +72,7 @@ struct media_device {u32 entity_id;u32 pad_id; +u32 link_id;struct list_head entities;include/media/media-entity.h +3
-0@@ -35,10 +35,12 @@* * @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad +* @MEDIA_GRAPH_LINK: Identify a media link */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD , +MEDIA_GRAPH_LINK , };#define BITS_PER_TYPE 8@@ -65,6 +67,7 @@ struct media_pipeline { };struct media_link { +struct media_gobj graph_obj;struct media_pad *source;/* Source pad */ struct media_pad *sink;/* Sink pad */ struct media_link *reverse;/* Link in the reverse direction */
RFC PATCH v5 6/8 media: add messages when media device gets (un)registered
In reply to Mauro Carvalho ChehabWe can only free the media device after being sure that no graph object is used.
In order to help tracking it, let's add debug messages that will print when the media controller gets registered or unregistered.
drivers/media/media-device.c +5 -0
@@ -357,6 +357,7 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);static void media_device_release (struct media_devnode *mdev) { +dev_dbg (mdev->parent,"Media device released\n" ); }/**
@@ -395,6 +396,8 @@ int __must_check __media_device_register(struct media_device *mdev,return ret; } +dev_dbg (mdev->dev,"Media device registered\n" ); +return 0 ; }EXPORT_SYMBOL_GPL (__media_device_register);
@@ -414,6 +417,8 @@ void media_device_unregister(struct media_device *mdev)device_remove_file (&mdev->devnode.dev, &dev_attr_model);media_devnode_unregister (&mdev->devnode); + +dev_dbg (mdev->dev,"Media device unregistered\n" ); }EXPORT_SYMBOL_GPL (media_device_unregister);
Signature · 1 line
2.4.3
RFC PATCH v5 7/8 media: add a debug message to warn about gobj creation/removal
In reply to Mauro Carvalho ChehabIt helps to check if the media controller is doing the right thing with the object creation and removal.
No extra code/data will be produced if DEBUG orCONFIG_DYNAMIC_DEBUG is not enabled.
drivers/media/media-entity.c +69 -8
@@ -27,6 +27,67 @@#include <media/media-device.h> /** +* dev_dbg_obj - Prints in debug mode a change on some object +* +* @event_name: Name of the event to report. Could be __func__ +* @gobj: Pointer to the object +* +* Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it +* won't produce any code. +*/ +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +static const char *gobj_type[] = { + [MEDIA_GRAPH_ENTITY ] ="entity" , + [MEDIA_GRAPH_PAD ] ="pad" , + [MEDIA_GRAPH_LINK ] ="link" , + }; + +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x %s#%d '%s'\n" , + event_name, gobj->id, + gobj_type[media_type (gobj)], +media_localid (gobj), +gobj_to_entity (gobj)->name); +break ; +case MEDIA_GRAPH_LINK : + { +struct media_link *link =gobj_to_link (gobj); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x %s#%d: '%s' %s#%d ==> '%s' %s#%d\n" , + event_name, gobj->id, + gobj_type[media_type (gobj)], +media_localid (gobj), + + link->source->entity->name, + gobj_type[media_type (&link->source->graph_obj)], +media_localid (&link->source->graph_obj), + + link->sink->entity->name, + gobj_type[media_type (&link->sink->graph_obj)], +media_localid (&link->sink->graph_obj)); +break ; + } +case MEDIA_GRAPH_PAD : + { +struct media_pad *pad =gobj_to_pad (gobj); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x %s %s#%d\n" , + event_name, gobj->id, + pad->entity->name, + gobj_type[media_type (gobj)], +media_localid (gobj)); + } + } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object
@@ -43,6 +104,8 @@ void media_gobj_init(struct media_device *mdev,enum media_gobj_type type, struct media_gobj *gobj) { + gobj->mdev = mdev; +/* Create a per-type unique object ID */ switch (type) {case MEDIA_GRAPH_ENTITY :
@@ -55,6 +118,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; } +dev_dbg_obj (__func__, gobj); }/**
@@ -66,7 +130,7 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { -/* For now, nothing to do */ +dev_dbg_obj (__func__, gobj); }/**
@@ -472,13 +536,6 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; } -/* Initialize graph object embedded at the new link */ -if (entity->parent) -media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); -else -pr_warn ("Link created before entity register!\n" ); -return &entity->links[entity->num_links++]; }
@@ -501,6 +558,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj); +/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */
@@ -514,6 +573,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); + link->reverse = backlink; backlink->reverse = link;
include/media/media-entity.h +7 -0
@@ -59,6 +59,7 @@ enum media_gobj_type {* All elements on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;u32 id; };
@@ -190,6 +191,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, graph_obj) +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);
Signature · 1 line
2.4.3
Re: [PATCH RFC v5 7/8] [media] media: add a debug message to warn about gobj creation/removal
Quoted 29 lines · Mauro Carvalho Chehab
It helps to check if the media controller is doing the right thing with the object creation and removal.
No extra code/data will be produced if DEBUG or
CONFIG_DYNAMIC_DEBUGis not enabled.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +13
-0@@ -27,6 +27,67 @@#include <media/media-device.h> /** +* dev_dbg_obj - Prints in debug mode a change on some object +* +* @event_name: Name of the event to report. Could be __func__ +* @gobj: Pointer to the object +* +* Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it +* won't produce any code. +*/ +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +static const char *gobj_type[] = { + [MEDIA_GRAPH_ENTITY] = "entity",
drivers/media/media-entity.c line 52
Quoted 10 lines
drivers/media/media-entity.c +10
-0+ [MEDIA_GRAPH_PAD] = "pad", + [MEDIA_GRAPH_LINK] = "link", + }; + +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d '%s'\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],
You can just fill in "entity" in the string since this is always an entity in this case.
drivers/media/media-entity.c line 63
Quoted 11 lines
drivers/media/media-entity.c +11
-0+media_localid (gobj), + gobj_to_entity(gobj)->name); +break ; +case MEDIA_GRAPH_LINK : + { +struct media_link *link =gobj_to_link (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d: '%s' %s#%d ==> '%s' %s#%d\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],
Ditto.
Quoted 10 lines
drivers/media/media-entity.c +10
-0+media_localid (gobj), + + link->source->entity->name, + gobj_type[media_type (&link->source->graph_obj)], +media_localid (&link->source->graph_obj), + + link->sink->entity->name, + gobj_type[media_type (&link->sink->graph_obj)], + media_localid(&link->sink->graph_obj)); +break ;
drivers/media/media-entity.c line 83
Quoted 10 lines
drivers/media/media-entity.c +10
-0+ } +case MEDIA_GRAPH_PAD : + { +struct media_pad *pad =gobj_to_pad (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s %s#%d\n", + event_name, gobj->id, + pad->entity->name, + gobj_type[media_type(gobj)],
Ditto.
drivers/media/media-entity.c line 85
Quoted 2 lines
drivers/media/media-entity.c +2
-0+ media_localid(gobj)); + }
I would add a default case here with a WARN(1) or something like that to make it very clear that someone forgot to extend this switch after adding a new object type.
In the LINK case there is no check for unknown object types in the gobj_type[] lookups. I think it is overkill to add a check for that since the objects that are linked are going to be created first, so they would trigger the WARN(1) in the default case first if they are using unhandled types. That should give enough information for the developer.
Quoted 35 lines
drivers/media/media-entity.c +9
-1+ } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object @@ -43,6 +104,8 @@ void media_gobj_init(struct media_device *mdev,enum media_gobj_type type, struct media_gobj *gobj) { + gobj->mdev = mdev; +/* Create a per-type unique object ID */ switch (type) {case MEDIA_GRAPH_ENTITY :@@ -55,6 +118,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; } +dev_dbg_obj (__func__, gobj); }/** @@ -66,7 +130,7 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { -/* For now, nothing to do */ +dev_dbg_obj (__func__, gobj); }/**
drivers/media/media-entity.c static struct media_link *media_entity_add_link(struct media_entity *entity) · line 481
Quoted 10 lines
drivers/media/media-entity.c +0
-7@@ -472,13 +536,6 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; } -/* Initialize graph object embedded at the new link */ -if (entity->parent) -media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); -else -pr_warn ("Link created before entity register!\n" ); -
This is confusing: this was added in patch 5 and now it is removed again. This doesn't seem to have anything to do with adding this debugging facility.
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 562
Quoted 9 lines
drivers/media/media-entity.c +2
-0return &entity->links[entity->num_links++]; }@@ -501,6 +558,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj); +
Same for this,
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 577
Quoted 9 lines
drivers/media/media-entity.c +2
-0/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -514,6 +573,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); +
and this.
Shouldn't these three changes be moved to patch 5?
include/media/media-entity.h enum media_gobj_type { · line 62
Quoted 12 lines
drivers/media/media-entity.c +0
-0link->reverse = backlink; backlink->reverse = link;include/media/media-entity.h +1
-0@@ -59,6 +59,7 @@ enum media_gobj_type {* All elements on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;
If you add this here, then the parent pointer in struct media_entity should be removed to avoid having duplicate fields.
I understand why you add this and I don't object, but I would split this change off into a separate patch that also includes removing the media_entity parent field.
Regards,
Hans
Quoted 17 lines
include/media/media-entity.h +6
-0u32 id; };@@ -190,6 +191,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, graph_obj) +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);
Re: [PATCH RFC v5 7/8] [media] media: add a debug message to warn about gobj creation/removal
Em Wed, 19 Aug 2015 10:36:51 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 35 lines · Mauro Carvalho Chehab
Quoted 34 lines
It helps to check if the media controller is doing the right thing with the object creation and removal.
No extra code/data will be produced if DEBUG or
CONFIG_DYNAMIC_DEBUGis not enabled.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +18
-0@@ -27,6 +27,67 @@#include <media/media-device.h> /** +* dev_dbg_obj - Prints in debug mode a change on some object +* +* @event_name: Name of the event to report. Could be __func__ +* @gobj: Pointer to the object +* +* Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it +* won't produce any code. +*/ +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +static const char *gobj_type[] = { + [MEDIA_GRAPH_ENTITY ] ="entity" , + [MEDIA_GRAPH_PAD ] ="pad" , + [MEDIA_GRAPH_LINK ] ="link" , + }; + +switch (media_type (gobj)) {
Quoted 8 lines
drivers/media/media-entity.c line 52
Quoted 5 lines
drivers/media/media-entity.c +5
-0+case MEDIA_GRAPH_ENTITY : + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d '%s'\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],You can just fill in "entity" in the string since this is always an entity in this case.
Yes, I know that we actually don't need to use gobj_type[] on the macros anymore. On my first version, there was no switch(), and just a generic function. I would prefer this way, though. We'll end by using the arrays for the links.
So, I'll do such cleanup when adding interfaces and interface links.
Quoted 38 lines
drivers/media/media-entity.c line 63
Quoted 12 lines
drivers/media/media-entity.c +11
-0+media_localid (gobj), + gobj_to_entity(gobj)->name); +break ; +case MEDIA_GRAPH_LINK : + { +struct media_link *link =gobj_to_link (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d: '%s' %s#%d ==> '%s' %s#%d\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],Ditto.
Quoted 10 lines
drivers/media/media-entity.c +10
-0+media_localid (gobj), + + link->source->entity->name, + gobj_type[media_type (&link->source->graph_obj)], +media_localid (&link->source->graph_obj), + + link->sink->entity->name, + gobj_type[media_type (&link->sink->graph_obj)], + media_localid(&link->sink->graph_obj)); +break ;drivers/media/media-entity.c line 83
Quoted 10 lines
drivers/media/media-entity.c +10
-0+ } +case MEDIA_GRAPH_PAD : + { +struct media_pad *pad =gobj_to_pad (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s %s#%d\n", + event_name, gobj->id, + pad->entity->name, + gobj_type[media_type(gobj)],Ditto.
Quoted 6 lines
drivers/media/media-entity.c line 85
Quoted 2 lines
drivers/media/media-entity.c +2
-0+ media_localid(gobj)); + }I would add a default case here with a WARN(1) or something like that to make it very clear that someone forgot to extend this switch after adding a new object type.
Well, newer gcc versions will print a warning if we add a new type at the enum and we forget to add here. So, I guess a default case is an overkill, and will just add extra code that will never be used.
Quoted 5 lines
In the LINK case there is no check for unknown object types in the gobj_type[] lookups. I think it is overkill to add a check for that since the objects that are linked are going to be created first, so they would trigger the WARN(1) in the default case first if they are using unhandled types. That should give enough information for the developer.
Well, I can convert gobj_type into a function and add a default case there, as going past the array is something that makes sense to avoid.
I'll do such change when writing the support for interface links.
Quoted 39 lines
Quoted 39 lines
drivers/media/media-entity.c +9
-1+ } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object @@ -43,6 +104,8 @@ void media_gobj_init(struct media_device *mdev,enum media_gobj_type type, struct media_gobj *gobj) { + gobj->mdev = mdev; +/* Create a per-type unique object ID */ switch (type) {case MEDIA_GRAPH_ENTITY :@@ -55,6 +118,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; } +dev_dbg_obj (__func__, gobj); }/** @@ -66,7 +130,7 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { -/* For now, nothing to do */ +dev_dbg_obj (__func__, gobj); }/** @@ -472,13 +536,6 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; }
Quoted 10 lines
drivers/media/media-entity.c static struct media_link *media_entity_add_link(struct media_entity *entity) · line 481
Quoted 7 lines
drivers/media/media-entity.c +0
-7-/* Initialize graph object embedded at the new link */ -if (entity->parent) -media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); -else -pr_warn ("Link created before entity register!\n" ); -This is confusing: this was added in patch 5 and now it is removed again. This doesn't seem to have anything to do with adding this debugging facility.
The warning is a left over from the test phase. I was afraid that such condition might be happening.
With regards to media_gobj_init(), we can't call it here anymore, as it is too early to call dev_dbg_obj(), as the link data is not filled. So, this got moved to media_entity_create_link(), to happen after filling link->source and link->sink.
Quoted 20 lines
drivers/media/media-entity.c )struct media_entity *source, u16 source_pad, · line 562
Quoted 10 lines
drivers/media/media-entity.c +2
-0return &entity->links[entity->num_links++]; }@@ -501,6 +558,8 @@ )struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj); +Same for this,
Quoted 7 lines
drivers/media/media-entity.c +0
-0/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -514,6 +573,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags;
Quoted 6 lines
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 577
Quoted 2 lines
drivers/media/media-entity.c +2
-0+media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); +and this.
Shouldn't these three changes be moved to patch 5?
Well, I can move this hunk to patch 5, but that will just be hiding the reason why they should be here in the first place: due to the new debug function.
Quoted 4 lines
Quoted 4 lines
drivers/media/media-entity.c +0
-0link->reverse = backlink; backlink->reverse = link;
Quoted 12 lines
include/media/media-entity.h enum media_gobj_type { · line 62
Quoted 9 lines
include/media/media-entity.h +1
-0@@ -59,6 +59,7 @@ enum media_gobj_type {* All elements on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;If you add this here, then the parent pointer in struct
media_entityshould be removed to avoid having duplicate fields.
Yes, I know, but I don't want to do it on just one patch. I'm trying to do the minimal amount of changes to introduce interface and interface links. My plan is to actually remove entity->parent latter, as such change will touch inside the drivers. It could be a big patch that won't cause any real gain, except for 4 bytes saved. So, I really prefer to postpone this to a cleanup series. I'm also hoping to merge vimc driver before that, as this would mean one less thing to be rebased on it ;)
Quoted 4 lines
I understand why you add this and I don't object, but I would split this change off into a separate patch that also includes removing the
media_entityparent field.
Well, you didn't complain about that on the previous versions (and mdev were on all other patches) :-)
I actually think that this way is easier to review, as one of the usages of mdev is explicit on this patch, and, as I said, the removal of the entity->parent is just a cleanup that can be done latter.
Let's focus on adding the new functionality first.
Quoted 23 lines
Regards,
Hans
Quoted 17 lines
include/media/media-entity.h +6
-0u32 id; };@@ -190,6 +191,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, graph_obj) +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);
Re: [PATCH RFC v5 7/8] [media] media: add a debug message to warn about gobj creation/removal
Quoted 47 lines · Mauro Carvalho Chehab
Em Wed, 19 Aug 2015 10:36:51 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 35 lines · Mauro Carvalho Chehab
Quoted 34 lines
It helps to check if the media controller is doing the right thing with the object creation and removal.
No extra code/data will be produced if DEBUG or
CONFIG_DYNAMIC_DEBUGis not enabled.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +18
-0@@ -27,6 +27,67 @@#include <media/media-device.h> /** +* dev_dbg_obj - Prints in debug mode a change on some object +* +* @event_name: Name of the event to report. Could be __func__ +* @gobj: Pointer to the object +* +* Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it +* won't produce any code. +*/ +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +static const char *gobj_type[] = { + [MEDIA_GRAPH_ENTITY ] ="entity" , + [MEDIA_GRAPH_PAD ] ="pad" , + [MEDIA_GRAPH_LINK ] ="link" , + }; + +switch (media_type (gobj)) {Quoted 8 lines
drivers/media/media-entity.c line 52
Quoted 5 lines
drivers/media/media-entity.c +5
-0+case MEDIA_GRAPH_ENTITY : + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d '%s'\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],You can just fill in "entity" in the string since this is always an entity in this case.
Quoted 6 lines
Yes, I know that we actually don't need to use gobj_type[] on the macros anymore. On my first version, there was no
switch(), and just a generic function. I would prefer this way, though. We'll end by using the arrays for the links.So, I'll do such cleanup when adding interfaces and interface links.
OK.
Quoted 46 lines
Quoted 39 lines
drivers/media/media-entity.c line 63
Quoted 13 lines
drivers/media/media-entity.c +11
-0+media_localid (gobj), + gobj_to_entity(gobj)->name); +break ; +case MEDIA_GRAPH_LINK : + { +struct media_link *link =gobj_to_link (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s#%d: '%s' %s#%d ==> '%s' %s#%d\n", + event_name, gobj->id, + gobj_type[media_type(gobj)],Ditto.
Quoted 10 lines
drivers/media/media-entity.c +10
-0+media_localid (gobj), + + link->source->entity->name, + gobj_type[media_type (&link->source->graph_obj)], +media_localid (&link->source->graph_obj), + + link->sink->entity->name, + gobj_type[media_type (&link->sink->graph_obj)], + media_localid(&link->sink->graph_obj)); +break ;drivers/media/media-entity.c line 83
Quoted 10 lines
drivers/media/media-entity.c +10
-0+ } +case MEDIA_GRAPH_PAD : + { +struct media_pad *pad =gobj_to_pad (gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x %s %s#%d\n", + event_name, gobj->id, + pad->entity->name, + gobj_type[media_type(gobj)],Ditto.
Quoted 6 lines
drivers/media/media-entity.c line 85
Quoted 2 lines
drivers/media/media-entity.c +2
-0+ media_localid(gobj)); + }I would add a default case here with a WARN(1) or something like that to make it very clear that someone forgot to extend this switch after adding a new object type.
Quoted 3 lines
Well, newer gcc versions will print a warning if we add a new type at the enum and we forget to add here. So, I guess a default case is an overkill, and will just add extra code that will never be used.
Ah, that's true.
Quoted 11 lines
Quoted 6 lines
In the LINK case there is no check for unknown object types in the gobj_type[] lookups. I think it is overkill to add a check for that since the objects that are linked are going to be created first, so they would trigger the WARN(1) in the default case first if they are using unhandled types. That should give enough information for the developer.
Well, I can convert
gobj_typeinto a function and add a default case there, as going past the array is something that makes sense to avoid.I'll do such change when writing the support for interface links.
OK.
Quoted 84 lines
Quoted 40 lines
Quoted 40 lines
drivers/media/media-entity.c +9
-1+ } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object @@ -43,6 +104,8 @@ void media_gobj_init(struct media_device *mdev,enum media_gobj_type type, struct media_gobj *gobj) { + gobj->mdev = mdev; +/* Create a per-type unique object ID */ switch (type) {case MEDIA_GRAPH_ENTITY :@@ -55,6 +118,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; } +dev_dbg_obj (__func__, gobj); }/** @@ -66,7 +130,7 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { -/* For now, nothing to do */ +dev_dbg_obj (__func__, gobj); }/** @@ -472,13 +536,6 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; }Quoted 10 lines
drivers/media/media-entity.c static struct media_link *media_entity_add_link(struct media_entity *entity) · line 481
Quoted 7 lines
drivers/media/media-entity.c +0
-7-/* Initialize graph object embedded at the new link */ -if (entity->parent) -media_gobj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); -else -pr_warn ("Link created before entity register!\n" ); -This is confusing: this was added in patch 5 and now it is removed again. This doesn't seem to have anything to do with adding this debugging facility.
The warning is a left over from the test phase. I was afraid that such condition might be happening.
With regards to
media_gobj_init(), we can't call it here anymore, as it is too early to calldev_dbg_obj(), as the link data is not filled. So, this got moved tomedia_entity_create_link(), to happen after fillinglink->sourceandlink->sink.Quoted 25 lines
drivers/media/media-entity.c )struct media_entity *source, u16 source_pad, · line 562
Quoted 10 lines
drivers/media/media-entity.c +2
-0return &entity->links[entity->num_links++]; }@@ -501,6 +558,8 @@ )struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj); +Same for this,
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 577
Quoted 9 lines
drivers/media/media-entity.c +2
-0/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -514,6 +573,8 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); +and this.
Quoted 5 lines
Quoted 1 line
Shouldn't these three changes be moved to patch 5?
Well, I can move this hunk to patch 5, but that will just be hiding the reason why they should be here in the first place: due to the new debug function.
As a reviewer it is confusing when something is added in one patch and promptly removed again in the next. Just saying...
Quoted 18 lines
Quoted 5 lines
Quoted 5 lines
drivers/media/media-entity.c +0
-0link->reverse = backlink; backlink->reverse = link;Quoted 12 lines
include/media/media-entity.h enum media_gobj_type { · line 62
Quoted 9 lines
include/media/media-entity.h +1
-0@@ -59,6 +59,7 @@ enum media_gobj_type {* All elements on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;If you add this here, then the parent pointer in struct
media_entityshould be removed to avoid having duplicate fields.
Quoted 7 lines
Yes, I know, but I don't want to do it on just one patch. I'm trying to do the minimal amount of changes to introduce interface and interface links. My plan is to actually remove
entity->parentlatter, as such change will touch inside the drivers. It could be a big patch that won't cause any real gain, except for 4 bytes saved. So, I really prefer to postpone this to a cleanup series. I'm also hoping to merge vimc driver before that, as this would mean one less thing to be rebased on it ;)
OK, but then please add a comment before the parent field that mentions that it is now a duplicate of mdev and will be removed in a future patch (or something along those lines).
Regards,
Hans
Quoted 43 lines
Quoted 5 lines
I understand why you add this and I don't object, but I would split this change off into a separate patch that also includes removing the
media_entityparent field.Well, you didn't complain about that on the previous versions (and mdev were on all other patches) :-)
I actually think that this way is easier to review, as one of the usages of mdev is explicit on this patch, and, as I said, the removal of the
entity->parentis just a cleanup that can be done latter.Let's focus on adding the new functionality first.
Quoted 12 lines
Regards,
Hans
Quoted 7 lines
include/media/media-entity.h +0
-0u32 id; };@@ -190,6 +191,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, graph_obj)Quoted 11 lines
include/media/media-entity.h struct media_entity_graph { · line 202
Quoted 10 lines
include/media/media-entity.h +6
-0+#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v5 8/8 media: rename the function that create pad links
In reply to Mauro Carvalho ChehabNow that a link can be either between two different graph objects, we'll need to add more functions to create links. So, rename the existing one that create links only between two pads as media_create_pad_link().
No functional changes.
This patch was created via this shell script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a $i; done
Documentation/media-framework.txt +1 -1
@@ -199,7 +199,7 @@ pre-allocated and grows dynamically as needed. Drivers create links by calling - media_entity_create_link(struct media_entity *source, u16 source_pad, + media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags);
drivers/media/dvb-core/dvbdev.c +4 -4
@@ -412,16 +412,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap) }if (tuner && fe) -media_entity_create_link (tuner,0 , fe,0 ,0 ); +media_create_pad_link (tuner,0 , fe,0 ,0 );if (fe && demux) -media_entity_create_link (fe,1 , demux,0 ,MEDIA_LNK_FL_ENABLED ); +media_create_pad_link (fe,1 , demux,0 ,MEDIA_LNK_FL_ENABLED );if (demux && dvr) -media_entity_create_link (demux,1 , dvr,0 ,MEDIA_LNK_FL_ENABLED ); +media_create_pad_link (demux,1 , dvr,0 ,MEDIA_LNK_FL_ENABLED );if (demux && ca) -media_entity_create_link (demux,1 , ca,0 ,MEDIA_LNK_FL_ENABLED ); +media_create_pad_link (demux,1 , ca,0 ,MEDIA_LNK_FL_ENABLED ); }EXPORT_SYMBOL_GPL (dvb_create_media_graph);#endif
drivers/media/i2c/s5c73m3/s5c73m3-core.c +2 -2
@@ -1482,11 +1482,11 @@ static int s5c73m3_oif_registered(struct v4l2_subdev *sd)return ret; } - ret =media_entity_create_link (&state->sensor_sd.entity, + ret =media_create_pad_link (&state->sensor_sd.entity,S5C73M3_ISP_PAD , &state->oif_sd.entity,OIF_ISP_PAD ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED ); - ret =media_entity_create_link (&state->sensor_sd.entity, + ret =media_create_pad_link (&state->sensor_sd.entity,S5C73M3_JPEG_PAD , &state->oif_sd.entity,OIF_JPEG_PAD ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
drivers/media/i2c/s5k5baf.c +1 -1
@@ -1756,7 +1756,7 @@ static int s5k5baf_registered(struct v4l2_subdev *sd)v4l2_err (sd,"failed to register subdev %s\n" , state->cis_sd.name); else - ret =media_entity_create_link (&state->cis_sd.entity,PAD_CIS , + ret =media_create_pad_link (&state->cis_sd.entity,PAD_CIS , &state->sd.entity,PAD_CIS ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
drivers/media/i2c/smiapp/smiapp-core.c +2 -2
@@ -2495,7 +2495,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)return rval; } - rval = media_entity_create_link(&this->sd.entity, + rval = media_create_pad_link(&this->sd.entity, this->source_pad, &last->sd.entity, last->sink_pad,
@@ -2503,7 +2503,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) MEDIA_LNK_FL_IMMUTABLE);if (rval) {dev_err (&client->dev, -"media_entity_create_link failed\n" ); +"media_create_pad_link failed\n" );return rval; }
drivers/media/media-entity.c +2 -2
@@ -540,7 +540,7 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) }int -media_entity_create_link (struct media_entity *source,u16 source_pad, +media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags) {struct media_link *link;
@@ -582,7 +582,7 @@ media_entity_create_link(struct media_entity *source, u16 source_pad,return 0 ; } -EXPORT_SYMBOL_GPL (media_entity_create_link); +EXPORT_SYMBOL_GPL (media_create_pad_link);void __media_entity_remove_links (struct media_entity *entity) {
drivers/media/platform/exynos4-is/media-dev.c +8 -8
@@ -729,7 +729,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, flags = ((1 << i) & link_mask) ?MEDIA_LNK_FL_ENABLED :0 ; sink = &fmd->fimc[i]->vid_cap.subdev.entity; - ret =media_entity_create_link (source, pad, sink, + ret =media_create_pad_link (source, pad, sink,FIMC_SD_PAD_SINK_CAM , flags);if (ret)return ret;
@@ -749,7 +749,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,continue ; sink = &fmd->fimc_lite[i]->subdev.entity; - ret =media_entity_create_link (source, pad, sink, + ret =media_create_pad_link (source, pad, sink,FLITE_SD_PAD_SINK ,0 );if (ret)return ret;
@@ -781,13 +781,13 @@ static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) source = &fimc->subdev.entity; sink = &fimc->ve.vdev.entity;/* FIMC-LITE's subdev and video node */ - ret =media_entity_create_link (source,FLITE_SD_PAD_SOURCE_DMA , + ret =media_create_pad_link (source,FLITE_SD_PAD_SOURCE_DMA , sink,0 ,0 );if (ret)break ;/* Link from FIMC-LITE to IS-ISP subdev */ sink = &fmd->fimc_is->isp.subdev.entity; - ret =media_entity_create_link (source,FLITE_SD_PAD_SOURCE_ISP , + ret =media_create_pad_link (source,FLITE_SD_PAD_SOURCE_ISP , sink,0 ,0 );if (ret)break ;
@@ -811,7 +811,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)/* Link from FIMC-IS-ISP subdev to FIMC */ sink = &fmd->fimc[i]->vid_cap.subdev.entity; - ret =media_entity_create_link (source,FIMC_ISP_SD_PAD_SRC_FIFO , + ret =media_create_pad_link (source,FIMC_ISP_SD_PAD_SRC_FIFO , sink,FIMC_SD_PAD_SINK_FIFO ,0 );if (ret)return ret;
@@ -824,7 +824,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)if (sink->num_pads ==0 )return 0 ; -return media_entity_create_link (source,FIMC_ISP_SD_PAD_SRC_DMA , +return media_create_pad_link (source,FIMC_ISP_SD_PAD_SRC_DMA , sink,0 ,0 ); }
@@ -873,7 +873,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)return -EINVAL ; pad = sensor->entity.num_pads -1 ; - ret =media_entity_create_link (&sensor->entity, pad, + ret =media_create_pad_link (&sensor->entity, pad, &csis->entity,CSIS_PAD_SINK ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
@@ -927,7 +927,7 @@ static int fimc_md_create_links(struct fimc_md *fmd) source = &fmd->fimc[i]->vid_cap.subdev.entity; sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; - ret =media_entity_create_link (source,FIMC_SD_PAD_SOURCE , + ret =media_create_pad_link (source,FIMC_SD_PAD_SOURCE , sink,0 , flags);if (ret)break ;
drivers/media/platform/omap3isp/isp.c +9 -9
@@ -1862,7 +1862,7 @@ static int isp_link_entity(return -EINVAL ; } -return media_entity_create_link (entity, i, input, pad, flags); +return media_create_pad_link (entity, i, input, pad, flags); }static int isp_register_entities (struct isp_device *isp)
@@ -2001,51 +2001,51 @@ static int isp_initialize_modules(struct isp_device *isp) }/* Connect the submodules. */ - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_csi2a.subdev.entity,CSI2_PAD_SOURCE , &isp->isp_ccdc.subdev.entity,CCDC_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccp2.subdev.entity,CCP2_PAD_SOURCE , &isp->isp_ccdc.subdev.entity,CCDC_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_prev.subdev.entity,PREV_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_OF , &isp->isp_res.subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_prev.subdev.entity,PREV_PAD_SOURCE , &isp->isp_res.subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_aewb.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_af.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_hist.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );
drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -2667,7 +2667,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) goto error_video;/* Connect the CCDC subdev to the video node. */ - ret =media_entity_create_link (&ccdc->subdev.entity,CCDC_PAD_SOURCE_OF , + ret =media_create_pad_link (&ccdc->subdev.entity,CCDC_PAD_SOURCE_OF , &ccdc->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispccp2.c +1 -1
@@ -1100,7 +1100,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) goto error_video;/* Connect the video node to the ccp2 subdev. */ - ret =media_entity_create_link (&ccp2->video_in.video.entity,0 , + ret =media_create_pad_link (&ccp2->video_in.video.entity,0 , &ccp2->subdev.entity,CCP2_PAD_SINK ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -1265,7 +1265,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) goto error_video;/* Connect the CSI2 subdev to the video node. */ - ret =media_entity_create_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , + ret =media_create_pad_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , &csi2->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/isppreview.c +2 -2
@@ -2312,12 +2312,12 @@ static int preview_init_entities(struct isp_prev_device *prev) goto error_video_out;/* Connect the video nodes to the previewer subdev. */ - ret =media_entity_create_link (&prev->video_in.video.entity,0 , + ret =media_create_pad_link (&prev->video_in.video.entity,0 , &prev->subdev.entity,PREV_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link (&prev->subdev.entity,PREV_PAD_SOURCE , + ret =media_create_pad_link (&prev->subdev.entity,PREV_PAD_SOURCE , &prev->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispresizer.c +2 -2
@@ -1756,12 +1756,12 @@ static int resizer_init_entities(struct isp_res_device *res) res->video_out.video.entity.flags |=MEDIA_ENT_FL_DEFAULT ;/* Connect the video nodes to the resizer subdev. */ - ret =media_entity_create_link (&res->video_in.video.entity,0 , + ret =media_create_pad_link (&res->video_in.video.entity,0 , &res->subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link (&res->subdev.entity,RESZ_PAD_SOURCE , + ret =media_create_pad_link (&res->subdev.entity,RESZ_PAD_SOURCE , &res->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/s3c-camif/camif-core.c +2 -2
@@ -263,7 +263,7 @@ static int camif_create_media_links(struct camif_dev *camif) {int i, ret; - ret =media_entity_create_link (&camif->sensor.sd->entity,0 , + ret =media_create_pad_link (&camif->sensor.sd->entity,0 , &camif->subdev.entity,CAMIF_SD_PAD_SINK ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
@@ -271,7 +271,7 @@ static int camif_create_media_links(struct camif_dev *camif)return ret;for (i =1 ; i <CAMIF_SD_PADS_NUM && !ret; i++) { - ret =media_entity_create_link (&camif->subdev.entity, i, + ret =media_create_pad_link (&camif->subdev.entity, i, &camif->vp[i -1 ].vdev.entity,0 ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
drivers/media/platform/vsp1/vsp1_drv.c +2 -2
@@ -101,7 +101,7 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)if (!(entity->pads[pad].flags &MEDIA_PAD_FL_SINK ))continue ; - ret =media_entity_create_link (&source->subdev.entity, + ret =media_create_pad_link (&source->subdev.entity, source->source_pad, entity, pad, flags);if (ret <0 )
@@ -262,7 +262,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) }if (vsp1->pdata.features &VSP1_HAS_LIF ) { - ret =media_entity_create_link ( + ret =media_create_pad_link ( &vsp1->wpf[0 ]->entity.subdev.entity,RWPF_PAD_SOURCE , &vsp1->lif->entity.subdev.entity,LIF_PAD_SINK ,0 );if (ret <0 )
drivers/media/platform/vsp1/vsp1_rpf.c +1 -1
@@ -278,7 +278,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) rpf->entity.video = video;/* Connect the video device to the RPF. */ - ret = media_entity_create_link(&rpf->video.video.entity, 0, + ret = media_create_pad_link(&rpf->video.video.entity, 0, &rpf->entity.subdev.entity, RWPF_PAD_SINK, MEDIA_LNK_FL_ENABLED |
drivers/media/platform/vsp1/vsp1_wpf.c +1 -1
@@ -284,7 +284,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)if (!(vsp1->pdata.features &VSP1_HAS_LIF ) || index !=0 ) flags |=MEDIA_LNK_FL_IMMUTABLE ; - ret =media_entity_create_link (&wpf->entity.subdev.entity, + ret =media_create_pad_link (&wpf->entity.subdev.entity,RWPF_PAD_SOURCE , &wpf->video.video.entity,0 , flags);if (ret <0 )
drivers/media/platform/xilinx/xilinx-vipp.c +2 -2
@@ -156,7 +156,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, local->name, local_pad->index, remote->name, remote_pad->index); - ret =media_entity_create_link (local, local_pad->index, + ret =media_create_pad_link (local, local_pad->index, remote, remote_pad->index, link_flags);if (ret <0 ) {
@@ -270,7 +270,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) source->name, source_pad->index, sink->name, sink_pad->index); - ret =media_entity_create_link (source, source_pad->index, + ret =media_create_pad_link (source, source_pad->index, sink, sink_pad->index, link_flags);if (ret <0 ) {
drivers/media/usb/cx231xx/cx231xx-cards.c +3 -3
@@ -1264,11 +1264,11 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)return ;if (tuner) -media_entity_create_link (tuner,0 , decoder,0 , +media_create_pad_link (tuner,0 , decoder,0 ,MEDIA_LNK_FL_ENABLED ); -media_entity_create_link (decoder,1 , &dev->vdev.entity,0 , +media_create_pad_link (decoder,1 , &dev->vdev.entity,0 ,MEDIA_LNK_FL_ENABLED ); -media_entity_create_link (decoder,2 , &dev->vbi_dev.entity,0 , +media_create_pad_link (decoder,2 , &dev->vbi_dev.entity,0 ,MEDIA_LNK_FL_ENABLED );#endif }
drivers/media/usb/uvc/uvc_entity.c +1 -1
@@ -56,7 +56,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain,continue ; remote_pad = remote->num_pads -1 ; - ret =media_entity_create_link (source, remote_pad, + ret =media_create_pad_link (source, remote_pad, sink, i, flags);if (ret <0 )return ret;
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +1 -1
@@ -971,7 +971,7 @@ vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif, ipipeif->video_in.vpfe_dev = vpfe_dev; flags =0 ; - ret =media_entity_create_link (&ipipeif->video_in.video_dev.entity,0 , + ret =media_create_pad_link (&ipipeif->video_in.video_dev.entity,0 , &ipipeif->subdev.entity,0 , flags);if (ret <0 ) goto fail;
drivers/staging/media/davinci_vpfe/dm365_isif.c +1 -1
@@ -1817,7 +1817,7 @@ int vpfe_isif_register_entities(struct vpfe_isif_device *isif, isif->video_out.vpfe_dev = vpfe_dev; flags =0 ;/* connect isif to video node */ - ret =media_entity_create_link (&isif->subdev.entity,1 , + ret =media_create_pad_link (&isif->subdev.entity,1 , &isif->video_out.video_dev.entity,0 , flags);if (ret <0 )
drivers/staging/media/davinci_vpfe/dm365_resizer.c +4 -4
@@ -1831,27 +1831,27 @@ int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer, resizer->resizer_b.video_out.vpfe_dev = vpfe_dev;/* create link between Resizer Crop----> Resizer A*/ - ret =media_entity_create_link (&resizer->crop_resizer.subdev.entity,1 , + ret =media_create_pad_link (&resizer->crop_resizer.subdev.entity,1 , &resizer->resizer_a.subdev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer Crop----> Resizer B*/ - ret =media_entity_create_link (&resizer->crop_resizer.subdev.entity,2 , + ret =media_create_pad_link (&resizer->crop_resizer.subdev.entity,2 , &resizer->resizer_b.subdev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer A ----> video out */ - ret =media_entity_create_link (&resizer->resizer_a.subdev.entity,1 , + ret =media_create_pad_link (&resizer->resizer_a.subdev.entity,1 , &resizer->resizer_a.video_out.video_dev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer B ----> video out */ - ret =media_entity_create_link (&resizer->resizer_b.subdev.entity,1 , + ret =media_create_pad_link (&resizer->resizer_b.subdev.entity,1 , &resizer->resizer_b.video_out.video_dev.entity,0 , flags);if (ret <0 ) goto out_create_link;
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +5 -5
@@ -445,32 +445,32 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev)/* if entity has no pads (ex: amplifier), cant establish link */ if (vpfe_dev->sd[i]->entity.num_pads) { - ret =media_entity_create_link (&vpfe_dev->sd[i]->entity, + ret =media_create_pad_link (&vpfe_dev->sd[i]->entity,0 , &vpfe_dev->vpfe_isif.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; } - ret =media_entity_create_link (&vpfe_dev->vpfe_isif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_isif.subdev.entity,1 , &vpfe_dev->vpfe_ipipeif.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , &vpfe_dev->vpfe_ipipe.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipe.subdev.entity, + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipe.subdev.entity,1 , &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,0 , flags);if (ret <0 )
drivers/staging/media/omap4iss/iss.c +6 -6
@@ -1259,7 +1259,7 @@ static int iss_register_entities(struct iss_device *iss) goto done; } - ret =media_entity_create_link (&sensor->entity,0 , input, pad, + ret =media_create_pad_link (&sensor->entity,0 , input, pad, flags);if (ret <0 ) goto done;
@@ -1317,31 +1317,31 @@ static int iss_initialize_modules(struct iss_device *iss) }/* Connect the submodules. */ - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->csi2a.subdev.entity,CSI2_PAD_SOURCE , &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->csi2b.subdev.entity,CSI2_PAD_SOURCE , &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SOURCE_VP , &iss->resizer.subdev.entity,RESIZER_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SOURCE_VP , &iss->ipipe.subdev.entity,IPIPE_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipe.subdev.entity,IPIPE_PAD_SOURCE_VP , &iss->resizer.subdev.entity,RESIZER_PAD_SINK ,0 );if (ret <0 )
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
@@ -1291,7 +1291,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) goto error_video;/* Connect the CSI2 subdev to the video node. */ - ret =media_entity_create_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , + ret =media_create_pad_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , &csi2->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/staging/media/omap4iss/iss_ipipeif.c +1 -1
@@ -762,7 +762,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)return ret;/* Connect the IPIPEIF subdev to the video node. */ - ret =media_entity_create_link (&ipipeif->subdev.entity, + ret =media_create_pad_link (&ipipeif->subdev.entity,IPIPEIF_PAD_SOURCE_ISIF_SF , &ipipeif->video_out.video.entity,0 ,0 );if (ret <0 )
drivers/staging/media/omap4iss/iss_resizer.c +1 -1
@@ -806,7 +806,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)return ret;/* Connect the RESIZER subdev to the video node. */ - ret =media_entity_create_link (&resizer->subdev.entity, + ret =media_create_pad_link (&resizer->subdev.entity,RESIZER_PAD_SOURCE_MEM , &resizer->video_out.video.entity,0 ,0 );if (ret <0 )
include/media/media-entity.h +1 -1
@@ -206,7 +206,7 @@ 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_entity_create_link (struct media_entity *source,u16 source_pad, +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);
Signature · 1 line
2.4.3
RFC PATCH v5 8/8 media: rename the function that create pad links
Quoted 5 lines · Mauro Carvalho Chehab
Now that a link can be either between two different graph objects, we'll need to add more functions to create links. So, rename the existing one that create links only between two pads as
media_create_pad_link().
Quoted 7 lines
No functional changes.
This patch was created via this shell script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>
Thanks!
Hans
Em Tue, 18 Aug 2015 17:04:13 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Hmm... I forgot to remove the "RFC" prefix. For me, this patch series is OK to be merged at the media-controller topic branch.
Quoted 130 lines
Those are the initial patches from my RFCv3 series of MC changes, plus one additional renaming patch and two debug ones. They address the comments received on PATCH v4 series.
The first 5 patches on this series ensures that all existing object types (entities, pads and links) will have an unique ID, as agreed at the MC workshop.
The next two patches add two debug functions, that helps with the tests of the MC changes. Both are enabled only if DEBUG or dynamic debug is enabled.
The first one just help to identify when the
media_deviceregister, remove and unregister functions are called. It helps to identify if those events happen before or after object creation.The second one is more interesting: it hooks at the object init and remove functions and dump what's there at the new object when it got created. This is very useful to test the future patches, as we'll be able to track any topology changes.
Also, it demonstates the capability of the functions
media_gobj_init()andmedia_gobj_remove()to track topology changes. Tracking topology changes is fundamental for the new API, in order to implementG_TOPOLOGYioctl. They should contain, in the future, a callback to warn the several drivers envolved at the MC topology build about topology changes.The last patch on this preparation series is just a renaming patch, that will avoid mess when future patches introduce the
entity->interfacelinks.They're tested using the cx231xx V4L2 support.
Those are the new debug messages when the device is probed:
[ 2684.265619] cx231xx 3-2.4:1.1: Media device registered [ 2684.357670] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000001 entity#1 'cx25840 19-0044' [ 2684.359191] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000001 cx25840 19-0044 pad#1 [ 2684.360693] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000002 cx25840 19-0044 pad#2 [ 2684.362208] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000003 cx25840 19-0044 pad#3[ 2686.437870] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000002 entity#2 '(tuner unset)' [ 2686.439474] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000004 (tuner unset) pad#4[ 2688.450710] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000003 entity#3 'cx231xx #0 video' [ 2688.452395] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000005 cx231xx #0 video pad#5[ 2688.455892] cx231xx 3-2.4:1.1: media_gobj_init: id 0x00000004 entity#4 'cx231xx #0 vbi' [ 2688.457632] cx231xx 3-2.4:1.1: media_gobj_init: id 0x01000006 cx231xx #0 vbi pad#6[ 2688.500233] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000001 link#1: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2688.501830] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000002 link#2: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2688.503415] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000003 link#3: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2688.504977] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000004 link#4: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2688.506505] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000005 link#5: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2688.508074] cx231xx 3-2.4:1.1: media_gobj_init: id 0x02000006 link#6: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6Those are the new debug messages when the device is removed:
[ 2953.872780] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000002 link#2: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2953.874470] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000003 link#3: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2953.876199] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000005 link#5: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2953.877830] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000001 cx25840 19-0044 pad#1 [ 2953.879454] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000002 cx25840 19-0044 pad#2 [ 2953.881020] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000003 cx25840 19-0044 pad#3 [ 2953.882569] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000001 entity#1 'cx25840 19-0044'[ 2953.884093] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000001 link#1: 'NXP TDA18271HD' pad#4 ==> 'cx25840 19-0044' pad#1 [ 2953.885611] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000004 NXP TDA18271HD pad#4 [ 2953.887200] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000002 entity#2 'NXP TDA18271HD'[ 2953.888638] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000004 link#4: 'cx25840 19-0044' pad#2 ==> 'cx231xx #0 video' pad#5 [ 2953.890093] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000005 cx231xx #0 video pad#5 [ 2953.891549] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000003 entity#3 'cx231xx #0 video'[ 2953.893006] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x02000006 link#6: 'cx25840 19-0044' pad#3 ==> 'cx231xx #0 vbi' pad#6 [ 2953.894471] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x01000006 cx231xx #0 vbi pad#6 [ 2953.895955] cx231xx 3-2.4:1.1: media_gobj_remove: id 0x00000004 entity#4 'cx231xx #0 vbi' [ 2953.897505] cx231xx 3-2.4:1.1: Media device released [ 2953.898924] cx231xx 3-2.4:1.1: Media device unregisteredIt should be noticed that both links and backlinks are reported on the above. That's because now they're implemented as two separate links right now.
Mauro Carvalho Chehab (8):
[media] media: create a macro to get entity ID
[media] media: add a common struct to be embed on media graph objects [media] media: usemedia_gobjinside entities
[media] media: usemedia_gobjinside pads
[media] media: usemedia_gobjinside links
[media] media: add messages when media device gets (un)registered [media] media: add a debug message to warn about gobj creation/removal [media] media: rename the function that create pad linksDocumentation/media-framework.txt | 2 +- drivers/media/dvb-core/dvbdev.c | 8 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 +- drivers/media/i2c/s5k5baf.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 4 +- drivers/media/media-device.c | 41 +++++-- drivers/media/media-entity.c | 123 ++++++++++++++++++++- drivers/media/platform/exynos4-is/media-dev.c | 16 +-- drivers/media/platform/omap3isp/isp.c | 18 +-- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 4 +- drivers/media/platform/omap3isp/ispresizer.c | 4 +- drivers/media/platform/s3c-camif/camif-core.c | 4 +- drivers/media/platform/vsp1/vsp1_drv.c | 4 +- drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 4 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +- drivers/media/usb/uvc/uvc_entity.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 8 +- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +- drivers/staging/media/omap4iss/iss.c | 12 +- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- include/media/media-device.h | 7 +- include/media/media-entity.h | 82 +++++++++++++- 32 files changed, 302 insertions(+), 87 deletions(-)