MC next generation patches
Subsystems (15)
v7 cover MC next generation patches
The latest version of this patch series is at:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental.git/log/?h=mc_next_gen
The latest version of the userspace tool to test it is at:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/log/?h=mc-next-gen
The initial patches of this series are the same as the ones at the
"[PATCH v6 0/8] MC preparation patches"
plus Javier patch series:
"[PATCH 0/4] [media] Media entity cleanups and build fixes"
Addressing some of the concerns from Laurent:
Javier media_entity_id() patches got reordered; all "elements" occurrences were replaced by "objects"
The patches of this part are:
media: create a macro to get entity ID
staging: omap4iss: get entity ID using media_entity_id()
omap3isp: get entity ID using media_entity_id()
media: add a common struct to be embed on media graph objects
media: use media_gobj inside entities
media: use media_gobj inside pads
media: use media_gobj inside links
media: add messages when media device gets (un)registered
media: add a debug message to warn about gobj creation/removal
media: rename the function that create pad links
media: use entity.graph_obj.mdev instead of .parent
media: remove media entity .parent field
The next set of patches add the interface types as defined by Hans Verkuil "[RFC] Media Controller, the next generation" proposal:
uapi/media.h: Declare interface types
media: add functions to allow creating interfaces
media: get rid of an unused code
media: convert links from array to list
media: make add link more generic
media: make media_link more generic to handle interace links
media: make link debug printk more generic
media: add support to link interfaces and entities
dvbdev: add support for interfaces
media: add a linked list to track interfaces by mdev
dvbdev: add support for indirect interface links
The next part in this series fix the API namespace, making them to match what it was defined by Hans Verkuil's:
"[RFC] Media Controller, the next generation"
It basically contains most of the changes that was done on my
RFC patch series:
"[PATCH 00/18] Remove media controller entity subtypes and rename types"
And constitutes on the following patches:
uapi/media.h: Fix entity namespace
replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L replace all occurrences of MEDIA_ENT_T_DEVNODE_DVB
media: add macros to check if subdev or V4L2 DMA
media: use macros to check for V4L2 subdev entities omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse
s5c73m3: fix subdev type
s5k5baf: fix subdev type
davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse
omap4iss: stop MEDIA_ENT_T_V4L2_SUBDEV abuse
v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs media controller: get rid of entity subtype on Kernel
DocBook: update descriptions for the media controller entities
dvb: modify core to implement interfaces/entities at MC new gen
media: report if a pad is sink or source at debug msg
It is basically renaming stuff, plus some fixups for some driver abuses of the legacy namespace.
Finally, the final series introduce the MEDIA_IOC_G_TOPOLOGY ioctl at the media.h header, and do the needed changes at the drivers side to implement support for it:
uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
media: Use a macro to interate between all interfaces
media: move mdev list init to gobj
media-device: add pads and links to media_device
media_device: add a topology version field
The new API can be tested using the 3 patch series I made for v4l-utils.
TODO:
- Add interfaces for V4L2 capture and output;
- Add interfaces for subdevs;
- Remove lots of fields from media_entity that will become obsolete with the new API addition
(major, minor, group_id, num_links, num_pads, num_backlinks)
- Address dynamic support for entities/interfaces/links. I suspect that not much is needed here, but locks need to be checked.
- Add dynamic support for PADs. This should be the harder pending item, I think.
Javier Martinez Canillas (4):
[media] staging: omap4iss: get entity ID using media_entity_id() [media] omap3isp: get entity ID using media_entity_id() [media] media: use entity.graph_obj.mdev instead of .parent [media] media: remove media entity .parent field
Mauro Carvalho Chehab (40):
[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 [media] uapi/media.h: Declare interface types
[media] media: add functions to allow creating interfaces [media] media: get rid of an unused code
[media] media: convert links from array to list
[media] media: make add link more generic
[media] media: make media_link more generic to handle interace links [media] media: make link debug printk more generic
[media] media: add support to link interfaces and entities [media] dvbdev: add support for interfaces
[media] media: add a linked list to track interfaces by mdev [media] dvbdev: add support for indirect interface links [media] uapi/media.h: Fix entity namespace
[media] replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L [media] replace all occurrences of MEDIA_ENT_T_DEVNODE_DVB [media] media: add macros to check if subdev or V4L2 DMA [media] media: use macros to check for V4L2 subdev entities [media] omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse [media] s5c73m3: fix subdev type
[media] s5k5baf: fix subdev type
[media] davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse [media] omap4iss: stop MEDIA_ENT_T_V4L2_SUBDEV abuse [media] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs [media] media controller: get rid of entity subtype on Kernel [media] DocBook: update descriptions for the media controller entities [media] dvb: modify core to implement interfaces/entities at MC new
gen
[media] media: report if a pad is sink or source at debug msg [media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl [media] media: Use a macro to interate between all interfaces [media] media: move mdev list init to gobj
[media] media-device: add pads and links to media_device [media] media_device: add a topology version field
[media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl
.../DocBook/media/v4l/media-ioc-enum-entities.xml | 57 ++- Documentation/media-framework.txt | 2 +- drivers/media/dvb-core/dmxdev.c | 4 +- drivers/media/dvb-core/dvb_ca_en50221.c | 2 +- drivers/media/dvb-core/dvb_frontend.c | 11 +- drivers/media/dvb-core/dvb_net.c | 2 +- drivers/media/dvb-core/dvbdev.c | 274 ++++++++++--- drivers/media/dvb-core/dvbdev.h | 10 +- drivers/media/firewire/firedtv-ci.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 8 +- drivers/media/i2c/s5k5baf.c | 4 +- drivers/media/i2c/smiapp/smiapp-core.c | 4 +- drivers/media/media-device.c | 207 ++++++++-- drivers/media/media-entity.c | 439 ++++++++++++++++----- drivers/media/pci/bt8xx/dst_ca.c | 3 +- drivers/media/pci/ddbridge/ddbridge-core.c | 2 +- drivers/media/pci/ngene/ngene-core.c | 2 +- drivers/media/pci/ttpci/av7110.c | 2 +- drivers/media/pci/ttpci/av7110_av.c | 4 +- drivers/media/pci/ttpci/av7110_ca.c | 2 +- drivers/media/platform/exynos4-is/common.c | 3 +- drivers/media/platform/exynos4-is/fimc-capture.c | 5 +- drivers/media/platform/exynos4-is/fimc-isp-video.c | 9 +- drivers/media/platform/exynos4-is/fimc-lite.c | 18 +- drivers/media/platform/exynos4-is/media-dev.c | 25 +- drivers/media/platform/exynos4-is/media-dev.h | 8 +- drivers/media/platform/omap3isp/isp.c | 43 +- drivers/media/platform/omap3isp/ispccdc.c | 19 +- drivers/media/platform/omap3isp/ispccp2.c | 15 +- drivers/media/platform/omap3isp/ispcsi2.c | 13 +- drivers/media/platform/omap3isp/isppreview.c | 19 +- drivers/media/platform/omap3isp/ispresizer.c | 17 +- drivers/media/platform/omap3isp/ispvideo.c | 17 +- drivers/media/platform/s3c-camif/camif-capture.c | 2 +- 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 | 15 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 10 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 +- drivers/media/usb/au0828/au0828-core.c | 14 +- drivers/media/usb/au0828/au0828-video.c | 8 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +- drivers/media/usb/cx231xx/cx231xx-video.c | 8 +- drivers/media/usb/uvc/uvc_entity.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 6 +- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 9 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 15 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 15 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 30 +- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 17 +- drivers/staging/media/omap4iss/iss.c | 32 +- drivers/staging/media/omap4iss/iss_csi2.c | 13 +- drivers/staging/media/omap4iss/iss_ipipe.c | 7 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 15 +- drivers/staging/media/omap4iss/iss_resizer.c | 13 +- drivers/staging/media/omap4iss/iss_video.c | 9 +- include/media/media-device.h | 34 +- include/media/media-entity.h | 199 +++++++++- include/uapi/linux/media.h | 192 ++++++++- 63 files changed, 1466 insertions(+), 485 deletions(-)
Signature · 1 line
2.4.3
PATCH v7 1/44 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
@@ -77,8 +77,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; }
@@ -104,7 +104,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;
@@ -122,7 +122,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
Re: [PATCH v7 01/44] [media] media: create a macro to get entity ID
Quoted 94 lines · Mauro Carvalho Chehab
Instead of accessing directly entity.id, let's create a macro, as this field will be moved into a common struct later on.
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +4
-4@@ -77,8 +77,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; }@@ -104,7 +104,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;@@ -122,7 +122,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 +0
-0@@ -113,6 +113,11 @@ static inline u32 media_entity_subtype(struct media_entity *entity)return entity->type &MEDIA_ENT_SUBTYPE_MASK ;
include/media/media-entity.h static inline u32 media_entity_subtype(struct media_entity *entity) · line 123
Quoted 10 lines
include/media/media-entity.h +5
-0} +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
Could you please enclose the code in this file in CONFIG_MEDIA_CONTROLLER ifdef similar to what is done in media-device.h based on your comments.
It will help avoid using CONFIG_MEDIA_CONTROLLER in places where this code is used. We could create a task around cleaning up all the places that enclose the entity calls in CONFIG_MEDIA_CONTROLLER ifdef as a cleanup.
thanks,
-- Shuah
Re: [PATCH v7 01/44] [media] media: create a macro to get entity ID
Em Mon, 24 Aug 2015 11:24:58 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 110 lines
Quoted 94 lines · Mauro Carvalho Chehab
Instead of accessing directly entity.id, let's create a macro, as this field will be moved into a common struct later on.
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +4
-4@@ -77,8 +77,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; }@@ -104,7 +104,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;@@ -122,7 +122,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 +0
-0@@ -113,6 +113,11 @@ static inline u32 media_entity_subtype(struct media_entity *entity)return entity->type &MEDIA_ENT_SUBTYPE_MASK ;include/media/media-entity.h static inline u32 media_entity_subtype(struct media_entity *entity) · line 123
Quoted 10 lines
include/media/media-entity.h +5
-0} +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 64Could you please enclose the code in this file in
CONFIG_MEDIA_CONTROLLERifdef similar to what is done inmedia-device.hbased on your comments.
Quoted 3 lines
It will help avoid using
CONFIG_MEDIA_CONTROLLERin places where this code is used. We could create a task around cleaning up all the places that enclose the entity calls inCONFIG_MEDIA_CONTROLLERifdef as a cleanup.
Hi Shuah,
Good point, but, IMHO, we should do such change on a separate patch.
In the specific case of the inline functions, tough, I don't see much gain on putting them inside an #ifdef.
The better would do that for the function prototypes, but I would postpone such changes to happen after we finished with the MC next generation patches.
One related discussion is if we'll end by making the media controller mandatory for hybrid TV drivers. If we do that, there's no need to spend time on it.
So, let's revisit this issue latter.
Regards,
Mauro
PATCH v7 2/44 staging: omap4iss: get entity ID using media_entity_id()
In reply to Mauro Carvalho ChehabFrom: Javier Martinez Canillas <[email protected]>
The struct media_entity does not have an .id field anymore since now the entity ID is stored in the embedded struct media_gobj.
This caused the omap4iss driver fail to build. Fix by using the media_entity_id() macro to obtain the entity ID.
drivers/staging/media/omap4iss/iss.c +1 -1
@@ -607,7 +607,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,* crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |=1U << subdev->entity.id; + iss->crashed |=1U <<media_entity_id (&subdev->entity); failure = -ETIMEDOUT ; } }
drivers/staging/media/omap4iss/iss_video.c +1 -1
@@ -784,7 +784,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) entity = &video->video.entity;media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);/* Verify that the currently configured format matches the output of * the connected subdev.
Signature · 1 line
2.4.3
Re: [PATCH v7 02/44] [media] staging: omap4iss: get entity ID using media_entity_id()
Quoted 29 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
The struct
media_entitydoes not have an .id field anymore since now the entity ID is stored in the embedded structmedia_gobj.This caused the omap4iss driver fail to build. Fix by using the
media_entity_id()macro to obtain the entity ID.Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/staging/media/omap4iss/iss.c +1
-1@@ -607,7 +607,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,* crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |=1U << subdev->entity.id; + iss->crashed |=1U <<media_entity_id (&subdev->entity); failure = -ETIMEDOUT ; } }drivers/staging/media/omap4iss/iss_video.c +0
-0
drivers/staging/media/omap4iss/iss_video.c iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) · line 788
Quoted 6 lines
drivers/staging/media/omap4iss/iss_video.c +1
-1@@ -784,7 +784,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) entity = &video->video.entity;media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);
Looks good to me.
thanks,
-- Shuah
Re: [PATCH v7 02/44] [media] staging: omap4iss: get entity ID using media_entity_id()
In reply to Mauro Carvalho ChehabQuoted 7 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
The struct
media_entitydoes not have an .id field anymore since now the entity ID is stored in the embedded structmedia_gobj.This caused the omap4iss driver fail to build. Fix by using the
media_entity_id()macro to obtain the entity ID.
This commit log is now a bit misleading since with the new position in this patch series this change is here to *prevent* a build failure once the id field is removed, and not to fix a build failure.
After fixing this:
Regards,
Hans
Quoted 31 lines
Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/staging/media/omap4iss/iss.c +1
-1@@ -607,7 +607,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,* crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |=1U << subdev->entity.id; + iss->crashed |=1U <<media_entity_id (&subdev->entity); failure = -ETIMEDOUT ; } }drivers/staging/media/omap4iss/iss_video.c +1
-1@@ -784,7 +784,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) entity = &video->video.entity;media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);/* Verify that the currently configured format matches the output of * the connected subdev.
PATCH v7 3/44 omap3isp: get entity ID using media_entity_id()
In reply to Mauro Carvalho ChehabFrom: Javier Martinez Canillas <[email protected]>
X-Patchwork-Delegate: [email protected] The struct media_entity does not have an .id field anymore since now the entity ID is stored in the embedded struct media_gobj.
This caused the omap3isp driver fail to build. Fix by using the media_entity_id() macro to obtain the entity ID.
drivers/media/platform/omap3isp/isp.c +5 -2
@@ -975,6 +975,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)struct v4l2_subdev *subdev;int failure =0 ;int ret; +u32 id;/* * We need to stop all the modules after CCDC first or they'll
@@ -1027,8 +1028,10 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)if (ret) {dev_info (isp->dev,"Unable to stop %s\n" , subdev->name); isp->stop_failure = true; -if (subdev == &isp->isp_prev.subdev) - isp->crashed |=1U << subdev->entity.id; +if (subdev == &isp->isp_prev.subdev) { + id =media_entity_id (&subdev->entity); + isp->crashed |=1U << id; + } failure = -ETIMEDOUT ; } }
drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)/* Wait for the CCDC to become idle. */ if (ccdc_sbl_wait_idle (ccdc,1000 )) {dev_info (isp->dev,"CCDC won't become idle!\n" ); - isp->crashed |=1U << ccdc->subdev.entity.id; + isp->crashed |=1U <<media_entity_id (&ccdc->subdev.entity);omap3isp_pipeline_cancel_stream (pipe);return 0 ; }
drivers/media/platform/omap3isp/ispvideo.c +5 -3
@@ -235,7 +235,7 @@ static int isp_video_get_graph_data(struct isp_video *video,while ((entity =media_entity_graph_walk_next (&graph))) {struct isp_video *__video; - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);if (far_end !=NULL )continue ;
@@ -891,6 +891,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,struct v4l2_ext_control ctrl;unsigned int i;int ret; +u32 id;/* Memory-to-memory pipelines have no external subdev. */ if (pipe->input !=NULL )
@@ -898,7 +899,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,for (i =0 ; i <ARRAY_SIZE (ents); i++) {/* Is the entity part of the pipeline? */ -if (!(pipe->entities & (1 << ents[i]->id))) +if (!(pipe->entities & (1 <<media_entity_id (ents[i]))))continue ;/* ISP entities have always sink pad == 0. Find source. */
@@ -950,7 +951,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video, pipe->external_rate = ctrl.value64; -if (pipe->entities & (1 << isp->isp_ccdc.subdev.entity.id)) { + id =media_entity_id (&isp->isp_ccdc.subdev.entity); +if (pipe->entities & (1 << id)) {unsigned int rate =UINT_MAX ;/* * Check that maximum allowed CCDC pixel rate isn't
Signature · 1 line
2.4.3
Re: [PATCH v7 03/44] [media] omap3isp: get entity ID using media_entity_id()
Quoted 25 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
X-Patchwork-Delegate: [email protected] The struct
media_entitydoes not have an .id field anymore since now the entity ID is stored in the embedded structmedia_gobj.This caused the omap3isp driver fail to build. Fix by using the
media_entity_id()macro to obtain the entity ID.Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/platform/omap3isp/isp.c +1
-0@@ -975,6 +975,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)struct v4l2_subdev *subdev;int failure =0 ;int ret; +u32 id;/* * We need to stop all the modules after CCDC first or they'll
drivers/media/platform/omap3isp/isp.c static int isp_pipeline_disable(struct isp_pipeline *pipe) · line 1033
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +3
-2@@ -1027,8 +1028,10 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)if (ret) {dev_info (isp->dev,"Unable to stop %s\n" , subdev->name); isp->stop_failure = true; -if (subdev == &isp->isp_prev.subdev) - isp->crashed |=1U << subdev->entity.id; +if (subdev == &isp->isp_prev.subdev) { + id =media_entity_id (&subdev->entity); + isp->crashed |=1U << id;
Is there a reason why you need id defined here, unlike the cases below. Can you do
isp->crashed |= 1U << media_entity_id(&subdev->entity);
Quoted 58 lines
drivers/media/platform/omap3isp/isp.c +1
-0+ } failure = -ETIMEDOUT ; } }drivers/media/platform/omap3isp/ispccdc.c +1
-1@@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)/* Wait for the CCDC to become idle. */ if (ccdc_sbl_wait_idle (ccdc,1000 )) {dev_info (isp->dev,"CCDC won't become idle!\n" ); - isp->crashed |=1U << ccdc->subdev.entity.id; + isp->crashed |=1U <<media_entity_id (&ccdc->subdev.entity);omap3isp_pipeline_cancel_stream (pipe);return 0 ; }drivers/media/platform/omap3isp/ispvideo.c +5
-4@@ -235,7 +235,7 @@ static int isp_video_get_graph_data(struct isp_video *video,while ((entity =media_entity_graph_walk_next (&graph))) {struct isp_video *__video; - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);if (far_end !=NULL )continue ;@@ -891,6 +891,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,struct v4l2_ext_control ctrl;unsigned int i;int ret; +u32 id;/* Memory-to-memory pipelines have no external subdev. */ if (pipe->input !=NULL )@@ -898,7 +899,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,for (i =0 ; i <ARRAY_SIZE (ents); i++) {/* Is the entity part of the pipeline? */ -if (!(pipe->entities & (1 << ents[i]->id))) +if (!(pipe->entities & (1 <<media_entity_id (ents[i]))))continue ;/* ISP entities have always sink pad == 0. Find source. */ @@ -950,7 +951,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video, pipe->external_rate = ctrl.value64; -if (pipe->entities & (1 << isp->isp_ccdc.subdev.entity.id)) { + id =media_entity_id (&isp->isp_ccdc.subdev.entity); +if (pipe->entities & (1 << id)) {unsigned int rate =UINT_MAX ;/* * Check that maximum allowed CCDC pixel rate isn't --
Quoted 2 lines
2.4.3
thanks,
-- Shuah
Re: [PATCH v7 03/44] [media] omap3isp: get entity ID using media_entity_id()
Hello Shuah,
Thanks for your feedback.
Quoted 39 lines · Shuah Khan
Quoted 25 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
X-Patchwork-Delegate: [email protected] The struct
media_entitydoes not have an .id field anymore since now the entity ID is stored in the embedded structmedia_gobj.This caused the omap3isp driver fail to build. Fix by using the
media_entity_id()macro to obtain the entity ID.Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/platform/omap3isp/isp.c +1
-0@@ -975,6 +975,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)struct v4l2_subdev *subdev;int failure =0 ;int ret; +u32 id;/* * We need to stop all the modules after CCDC first or they'll drivers/media/platform/omap3isp/isp.c static int isp_pipeline_disable(struct isp_pipeline *pipe) · line 1033
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +3
-2@@ -1027,8 +1028,10 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)if (ret) {dev_info (isp->dev,"Unable to stop %s\n" , subdev->name); isp->stop_failure = true; -if (subdev == &isp->isp_prev.subdev) - isp->crashed |=1U << subdev->entity.id; +if (subdev == &isp->isp_prev.subdev) { + id =media_entity_id (&subdev->entity); + isp->crashed |=1U << id;Is there a reason why you need id defined here, unlike the cases below. Can you do
Quoted 3 lines
isp->crashed|= 1U <<media_entity_id(&subdev->entity);
Yes I could but due the indentation levels, that line length would be way over the 80 columns convention. An alternative would had been to break down in two lines but that would make it even less readable IMHO.
So I added that variable for readability and to make checkpatch.pl happy.
Quoted 4 lines
thanks,
-- Shuah
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
Re: [PATCH v7 03/44] [media] omap3isp: get entity ID using media_entity_id()
In reply to Mauro Carvalho ChehabQuoted 8 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
X-Patchwork-Delegate: [email protected] The struct
media_entitydoes not have an .id field anymore since now the entity ID is stored in the embedded structmedia_gobj.This caused the omap3isp driver fail to build. Fix by using the
media_entity_id()macro to obtain the entity ID.
Same issue with the commit log as in the previous patch.
After fixing you can add my:
Regards,
Hans
Quoted 83 lines
Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/platform/omap3isp/isp.c +5
-2@@ -975,6 +975,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)struct v4l2_subdev *subdev;int failure =0 ;int ret; +u32 id;/* * We need to stop all the modules after CCDC first or they'll @@ -1027,8 +1028,10 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)if (ret) {dev_info (isp->dev,"Unable to stop %s\n" , subdev->name); isp->stop_failure = true; -if (subdev == &isp->isp_prev.subdev) - isp->crashed |=1U << subdev->entity.id; +if (subdev == &isp->isp_prev.subdev) { + id =media_entity_id (&subdev->entity); + isp->crashed |=1U << id; + } failure = -ETIMEDOUT ; } }drivers/media/platform/omap3isp/ispccdc.c +1
-1@@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)/* Wait for the CCDC to become idle. */ if (ccdc_sbl_wait_idle (ccdc,1000 )) {dev_info (isp->dev,"CCDC won't become idle!\n" ); - isp->crashed |=1U << ccdc->subdev.entity.id; + isp->crashed |=1U <<media_entity_id (&ccdc->subdev.entity);omap3isp_pipeline_cancel_stream (pipe);return 0 ; }drivers/media/platform/omap3isp/ispvideo.c +5
-3@@ -235,7 +235,7 @@ static int isp_video_get_graph_data(struct isp_video *video,while ((entity =media_entity_graph_walk_next (&graph))) {struct isp_video *__video; - pipe->entities |=1 << entity->id; + pipe->entities |=1 <<media_entity_id (entity);if (far_end !=NULL )continue ;@@ -891,6 +891,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,struct v4l2_ext_control ctrl;unsigned int i;int ret; +u32 id;/* Memory-to-memory pipelines have no external subdev. */ if (pipe->input !=NULL )@@ -898,7 +899,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,for (i =0 ; i <ARRAY_SIZE (ents); i++) {/* Is the entity part of the pipeline? */ -if (!(pipe->entities & (1 << ents[i]->id))) +if (!(pipe->entities & (1 <<media_entity_id (ents[i]))))continue ;/* ISP entities have always sink pad == 0. Find source. */ @@ -950,7 +951,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video, pipe->external_rate = ctrl.value64; -if (pipe->entities & (1 << isp->isp_ccdc.subdev.entity.id)) { + id =media_entity_id (&isp->isp_ccdc.subdev.entity); +if (pipe->entities & (1 << id)) {unsigned int rate =UINT_MAX ;/* * Check that maximum allowed CCDC pixel rate isn't
A message that is not in the archive (sent off-list or not yet received): cover.1440359643.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org
PATCH v7 13/44 uapi/media.h: Declare interface types
Declare the interface types that will be used by the new G_TOPOLOGY ioctl that will be defined latter on.
For now, we need those types, as they'll be used on the internal structs associated with the new media_interface graph object defined on the next patch.
include/uapi/linux/media.h +29 -0
@@ -167,6 +167,35 @@ struct media_links_enum {__u32 reserved[4 ]; }; +/* Interface type ranges */ + +#define MEDIA_INTF_T_DVB_BASE 0x00000000 +#define MEDIA_INTF_T_V4L_BASE 0x00000100 +#define MEDIA_INTF_T_ALSA_BASE 0x00000200 + +/* Interface types */ + +#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) +#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) +#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) +#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) +#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) + +#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) +#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) +#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) +#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) +#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) + +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) +#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) + +/* TBD: declare the structs needed for the new G_TOPOLOGY ioctl */ +#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
Signature · 1 line
2.4.3
Re: [PATCH v7 13/44] [media] uapi/media.h: Declare interface types
Quoted 14 lines · Mauro Carvalho Chehab
Declare the interface types that will be used by the new
G_TOPOLOGYioctl that will be defined latter on.For now, we need those types, as they'll be used on the internal structs associated with the new
media_interfacegraph object defined on the next patch.Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +0
-0
include/uapi/linux/media.h struct media_links_enum { · line 174
Quoted 8 lines
include/uapi/linux/media.h +5
-0@@ -167,6 +167,35 @@ struct media_links_enum {__u32 reserved[4 ]; }; +/* Interface type ranges */ + +#define MEDIA_INTF_T_DVB_BASE 0x00000000 +#define MEDIA_INTF_T_V4L_BASE 0x00000100 +#define MEDIA_INTF_T_ALSA_BASE 0x00000200
I would avoid BASE 0 and start with 0x100 for DVB (so ALSA gets 0x300).
This ensures that type is never 0 which is often useful since it catches cases where userspace just memsets to 0 and never fills in the type. Or it can be used in the future as an ERROR or UNKNOWN type or something.
Since there is nothing that requires type to be 0 I would avoid it altogether.
After making this small change:
Regards,
Hans
Quoted 28 lines
include/uapi/linux/media.h +24
-0+ +/* Interface types */ + +#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) +#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) +#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) +#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) +#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) + +#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) +#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) +#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) +#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) +#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) + +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) +#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) + +/* TBD: declare the structs needed for the new G_TOPOLOGY ioctl */ +#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
A message that is not in the archive (sent off-list or not yet received): 55df3b23389e68b19354011babf0da1d26d0a91a.1440359643.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org
Re: [PATCH v7 13/44] [media] uapi/media.h: Declare interface types
Quoted 33 lines · Mauro Carvalho Chehab
Declare the interface types that will be used by the new
G_TOPOLOGYioctl that will be defined latter on.For now, we need those types, as they'll be used on the internal structs associated with the new
media_interfacegraph object defined on the next patch.Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +16
-0@@ -167,6 +167,35 @@ struct media_links_enum {__u32 reserved[4 ]; }; +/* Interface type ranges */ + +#define MEDIA_INTF_T_DVB_BASE 0x00000000 +#define MEDIA_INTF_T_V4L_BASE 0x00000100 +#define MEDIA_INTF_T_ALSA_BASE 0x00000200 + +/* Interface types */ + +#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) +#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) +#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) +#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) +#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) + +#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) +#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
include/uapi/linux/media.h struct media_links_enum { · line 195
Quoted 10 lines
include/uapi/linux/media.h +10
-0+#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) +#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) +#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) + +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) +#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
Is it necessary to add ALSA types at this time without ALSA media controller work?
Can these be added later when ALSA work is done.
thanks,
-- Shuah
Re: [PATCH v7 13/44] [media] uapi/media.h: Declare interface types
Em Tue, 25 Aug 2015 14:34:46 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 41 lines
Quoted 39 lines · Mauro Carvalho Chehab
Declare the interface types that will be used by the new
G_TOPOLOGYioctl that will be defined latter on.For now, we need those types, as they'll be used on the internal structs associated with the new
media_interfacegraph object defined on the next patch.Signed-off-by Mauro Carvalho Chehab <[email protected]>include/uapi/linux/media.h +22
-0@@ -167,6 +167,35 @@ struct media_links_enum {__u32 reserved[4 ]; }; +/* Interface type ranges */ + +#define MEDIA_INTF_T_DVB_BASE 0x00000000 +#define MEDIA_INTF_T_V4L_BASE 0x00000100 +#define MEDIA_INTF_T_ALSA_BASE 0x00000200 + +/* Interface types */ + +#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) +#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) +#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) +#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) +#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) + +#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) +#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) +#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) +#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) +#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) + +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
Quoted 8 lines
include/uapi/linux/media.h struct media_links_enum { · line 195
Quoted 4 lines
include/uapi/linux/media.h +4
-0+#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)Is it necessary to add ALSA types at this time without ALSA media controller work?
Can these be added later when ALSA work is done.
Sure. I'll remove those on the next spin.
Quoted 3 lines
thanks,
-- Shuah
PATCH v7 24/44 uapi/media.h: Fix entity namespace
In reply to a message not in the archiveNow that interfaces got created, we need to fix the entity namespace.
So, let's create a consistent new namespace and add backward compatibility macros to keep the old namespace preserved.
drivers/media/dvb-core/dvbdev.c +13 -13
@@ -229,17 +229,17 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,switch (type) {case DVB_DEVICE_FRONTEND : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_FE ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMOD ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_DEMUX : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DEMUX ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMUX ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_CA : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;
@@ -438,7 +438,7 @@ EXPORT_SYMBOL(dvb_unregister_device);void dvb_create_media_graph (struct dvb_adapter *adap) {struct media_device *mdev = adap->mdev; -struct media_entity *entity, *tuner =NULL , *fe =NULL ; +struct media_entity *entity, *tuner =NULL , *demod =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ;struct media_interface *intf;
@@ -450,26 +450,26 @@ void dvb_create_media_graph(struct dvb_adapter *adap)case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : tuner = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_FE : - fe = entity; +case MEDIA_ENT_T_DVB_DEMOD : + demod = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DEMUX : +case MEDIA_ENT_T_DVB_DEMUX : demux = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DVR : +case MEDIA_ENT_T_DVB_TSOUT : dvr = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_CA : +case MEDIA_ENT_T_DVB_CA : ca = entity;break ; } } -if (tuner && fe) -media_create_pad_link (tuner,0 , fe,0 ,0 ); +if (tuner && demod) +media_create_pad_link (tuner,0 , demod,0 ,0 ); -if (fe && demux) -media_create_pad_link (fe,1 , demux,0 ,MEDIA_LNK_FL_ENABLED ); +if (demod && demux) +media_create_pad_link (demod,1 , demux,0 ,MEDIA_LNK_FL_ENABLED );if (demux && dvr)media_create_pad_link (demux,1 , dvr,0 ,MEDIA_LNK_FL_ENABLED );
include/uapi/linux/media.h +54 -18
85 lines not on this page · raw message
Signature · 1 line
2.4.3
A message that is not in the archive (sent off-list or not yet received): 5cf25be2d0508e02f6ffe469509fa12c45ddcb8d.1440359643.git.mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org
Re: [PATCH v7 24/44] [media] uapi/media.h: Fix entity namespace
Quoted 97 lines · Mauro Carvalho Chehab
Now that interfaces got created, we need to fix the entity namespace.
So, let's create a consistent new namespace and add backward compatibility macros to keep the old namespace preserved.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +13
-13@@ -229,17 +229,17 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,switch (type) {case DVB_DEVICE_FRONTEND : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_FE ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMOD ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_DEMUX : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DEMUX ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMUX ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_CA : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;@@ -438,7 +438,7 @@ EXPORT_SYMBOL(dvb_unregister_device);void dvb_create_media_graph (struct dvb_adapter *adap) {struct media_device *mdev = adap->mdev; -struct media_entity *entity, *tuner =NULL , *fe =NULL ; +struct media_entity *entity, *tuner =NULL , *demod =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ;struct media_interface *intf;@@ -450,26 +450,26 @@ void dvb_create_media_graph(struct dvb_adapter *adap)case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : tuner = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_FE : - fe = entity; +case MEDIA_ENT_T_DVB_DEMOD : + demod = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DEMUX : +case MEDIA_ENT_T_DVB_DEMUX : demux = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DVR : +case MEDIA_ENT_T_DVB_TSOUT : dvr = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_CA : +case MEDIA_ENT_T_DVB_CA : ca = entity;break ; } } -if (tuner && fe) -media_create_pad_link (tuner,0 , fe,0 ,0 ); +if (tuner && demod) +media_create_pad_link (tuner,0 , demod,0 ,0 ); -if (fe && demux) -media_create_pad_link (fe,1 , demux,0 ,MEDIA_LNK_FL_ENABLED ); +if (demod && demux) +media_create_pad_link (demod,1 , demux,0 ,MEDIA_LNK_FL_ENABLED );if (demux && dvr)media_create_pad_link (demux,1 , dvr,0 ,MEDIA_LNK_FL_ENABLED );include/uapi/linux/media.h +11
-0@@ -42,31 +42,67 @@ struct media_device_info {#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) +/* +* Base numbers for entity types +* +* Please notice that the huge gap of 16 bits for each base is overkill! +* 8 bits is more than enough to avoid starving entity types for each +* subsystem. +* +* However, It is kept this way just to avoid binary breakages with the +* namespace provided on legacy versions of this header. +*/ +#define MEDIA_ENT_T_DVB_BASE 0x00000000
include/uapi/linux/media.h struct media_device_info { · line 65
Quoted 10 lines
include/uapi/linux/media.h +10
-0+#define MEDIA_ENT_T_V4L2_BASE 0x00010000 +#define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000 + +/* V4L2 entities */ +#define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1) +/* +* Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and +* MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used +* to be declared for FB, ALSA and DVB entities. +* As those values were never atually used in practice, we're just
s/atually/actually/
include/uapi/linux/media.h struct media_device_info { · line 66
Quoted 1 line
include/uapi/linux/media.h +1
-0+* adding them as backward compatibily macros and keeping the
s/compatibily/compatibility/
include/uapi/linux/media.h struct media_device_info { · line 67
Quoted 1 line
include/uapi/linux/media.h +1
-0+* numberspace cleaned here. This way, we avoid breaking compilation,
s/cleaned/clean/
include/uapi/linux/media.h struct media_device_info { · line 73
Quoted 6 lines
include/uapi/linux/media.h +6
-0+* in the case of having some userspace application using the old +* symbols. +*/ +#define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5) +#define MEDIA_ENT_T_V4L2_RADIO (MEDIA_ENT_T_V4L2_BASE + 6) +#define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 7)
Why are these entities? Aren't these interface types?
Quoted 44 lines
include/uapi/linux/media.h +24
-12+ +/* V4L2 Sub-device entities */ +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2) +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3) +/* A converter of analogue video to its digital representation. */ +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4) +/* Tuner entity is actually both V4L2 and DVB subdev */ +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5) + +/* DVB entities */ +#define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 4) +#define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 5) +#define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 6) +#define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 7) +#define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 8) + +/* Legacy symbols used to avoid userspace compilation breakages */ #define MEDIA_ENT_TYPE_SHIFT 16#define MEDIA_ENT_TYPE_MASK 0x00ff0000#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff -#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) +#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE +#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE + +#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO +#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) -#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4) -#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX (MEDIA_ENT_T_DEVNODE + 5) -#define MEDIA_ENT_T_DEVNODE_DVB_DVR (MEDIA_ENT_T_DEVNODE + 6) -#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7) -#define MEDIA_ENT_T_DEVNODE_DVB_NET (MEDIA_ENT_T_DEVNODE + 8) +#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) -/* Legacy symbol. Use it to avoid userspace compilation breakages */ -#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_ENT_T_DEVNODE_DVB_FE - -#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
include/uapi/linux/media.h struct media_device_info { · line 108
Quoted 10 lines
include/uapi/linux/media.h +1
-6-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) -/* A converter of analogue video to its digital representation. */ -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4) - -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV + 5) +/* Entity types */ #define MEDIA_ENT_FL_DEFAULT (1 << 0)
Hmm, I'm postponing further review. It might become clearer after reviewing more of this patch series.
One reason why this is a bit difficult to review is that it is not immediately obvious which defines are here for backwards compat (and shouldn't be used in the kernel anymore) and which defines are new.
May I suggest that either in this or in a later patch the defines that shouldn't be used in the kernel should be placed under #ifndef __KERNEL__?
Regards,
Hans
A message that is not in the archive (sent off-list or not yet received): 55DC2E2D.4090000-qWit8jRvyhVmR6Xm/[email protected]
Re: [PATCH v7 24/44] [media] uapi/media.h: Fix entity namespace
Em Tue, 25 Aug 2015 10:58:21 +0200
Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]> escreveu:
Quoted 119 lines · Mauro Carvalho Chehab
Quoted 97 lines
Now that interfaces got created, we need to fix the entity namespace.
So, let's create a consistent new namespace and add backward compatibility macros to keep the old namespace preserved.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +13
-13@@ -229,17 +229,17 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev,switch (type) {case DVB_DEVICE_FRONTEND : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_FE ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMOD ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_DEMUX : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DEMUX ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_DEMUX ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;case DVB_DEVICE_CA : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; + dvbdev->entity->type =MEDIA_ENT_T_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ;@@ -438,7 +438,7 @@ EXPORT_SYMBOL(dvb_unregister_device);void dvb_create_media_graph (struct dvb_adapter *adap) {struct media_device *mdev = adap->mdev; -struct media_entity *entity, *tuner =NULL , *fe =NULL ; +struct media_entity *entity, *tuner =NULL , *demod =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ;struct media_interface *intf;@@ -450,26 +450,26 @@ void dvb_create_media_graph(struct dvb_adapter *adap)case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : tuner = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_FE : - fe = entity; +case MEDIA_ENT_T_DVB_DEMOD : + demod = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DEMUX : +case MEDIA_ENT_T_DVB_DEMUX : demux = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_DVR : +case MEDIA_ENT_T_DVB_TSOUT : dvr = entity;break ; -case MEDIA_ENT_T_DEVNODE_DVB_CA : +case MEDIA_ENT_T_DVB_CA : ca = entity;break ; } } -if (tuner && fe) -media_create_pad_link (tuner,0 , fe,0 ,0 ); +if (tuner && demod) +media_create_pad_link (tuner,0 , demod,0 ,0 ); -if (fe && demux) -media_create_pad_link (fe,1 , demux,0 ,MEDIA_LNK_FL_ENABLED ); +if (demod && demux) +media_create_pad_link (demod,1 , demux,0 ,MEDIA_LNK_FL_ENABLED );if (demux && dvr)media_create_pad_link (demux,1 , dvr,0 ,MEDIA_LNK_FL_ENABLED );include/uapi/linux/media.h +11
-0@@ -42,31 +42,67 @@ struct media_device_info {#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) +/* +* Base numbers for entity types +* +* Please notice that the huge gap of 16 bits for each base is overkill! +* 8 bits is more than enough to avoid starving entity types for each +* subsystem. +* +* However, It is kept this way just to avoid binary breakages with the +* namespace provided on legacy versions of this header. +*/ +#define MEDIA_ENT_T_DVB_BASE 0x00000000include/uapi/linux/media.h struct media_device_info { · line 65
Quoted 10 lines
include/uapi/linux/media.h +10
-0+#define MEDIA_ENT_T_V4L2_BASE 0x00010000 +#define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000 + +/* V4L2 entities */ +#define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1) +/* +* Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and +* MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used +* to be declared for FB, ALSA and DVB entities. +* As those values were never atually used in practice, we're just s/atually/actually/
include/uapi/linux/media.h struct media_device_info { · line 66
Quoted 1 line
include/uapi/linux/media.h +1
-0+* adding them as backward compatibily macros and keeping the s/compatibily/compatibility/
include/uapi/linux/media.h struct media_device_info { · line 67
Quoted 1 line
include/uapi/linux/media.h +1
-0+* numberspace cleaned here. This way, we avoid breaking compilation, s/cleaned/clean/
Quoted 8 lines
include/uapi/linux/media.h struct media_device_info { · line 73
Quoted 6 lines
include/uapi/linux/media.h +6
-0+* in the case of having some userspace application using the old +* symbols. +*/ +#define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5) +#define MEDIA_ENT_T_V4L2_RADIO (MEDIA_ENT_T_V4L2_BASE + 6) +#define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 7)Why are these entities? Aren't these interface types?
We need both:
The entity represents the data sinks (or sources), and the interface the control interfaces.
I'm actually in doubt about MEDIA_ENT_T_V4L2_RADIO. Maybe we'll need a MEDIA_ENT_T_V4L2_RADIO_RDS too.
Of course, MEDIA_ENT_T_V4L2_RADIO is not needed for receivers, but I guess it is needed for TX.
Quoted 59 lines
Quoted 45 lines
include/uapi/linux/media.h +24
-12+ +/* V4L2 Sub-device entities */ +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2) +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3) +/* A converter of analogue video to its digital representation. */ +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4) +/* Tuner entity is actually both V4L2 and DVB subdev */ +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5) + +/* DVB entities */ +#define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 4) +#define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 5) +#define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 6) +#define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 7) +#define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 8) + +/* Legacy symbols used to avoid userspace compilation breakages */ #define MEDIA_ENT_TYPE_SHIFT 16#define MEDIA_ENT_TYPE_MASK 0x00ff0000#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff -#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) +#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE +#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE + +#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO +#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) -#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4) -#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX (MEDIA_ENT_T_DEVNODE + 5) -#define MEDIA_ENT_T_DEVNODE_DVB_DVR (MEDIA_ENT_T_DEVNODE + 6) -#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7) -#define MEDIA_ENT_T_DEVNODE_DVB_NET (MEDIA_ENT_T_DEVNODE + 8) +#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) -/* Legacy symbol. Use it to avoid userspace compilation breakages */ -#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_ENT_T_DEVNODE_DVB_FE - -#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)include/uapi/linux/media.h struct media_device_info { · line 108
Quoted 10 lines
include/uapi/linux/media.h +1
-6-#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) -/* A converter of analogue video to its digital representation. */ -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4) - -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV + 5) +/* Entity types */ #define MEDIA_ENT_FL_DEFAULT (1 << 0)Hmm, I'm postponing further review. It might become clearer after reviewing more of this patch series.
Quoted 3 lines
One reason why this is a bit difficult to review is that it is not immediately obvious which defines are here for backwards compat (and shouldn't be used in the kernel anymore) and which defines are new.
The ones under /* Legacy symbols used to avoid userspace compilation breakages */ comment should not be used anymore.
Quoted 2 lines
May I suggest that either in this or in a later patch the defines that shouldn't be used in the kernel should be placed under #ifndef
__KERNEL__?
They'll be under a #ifndef __KERNEL__, but this will happen latter at the patch series. We need first to remove their usage internally before adding the ifndef.
Regards,
Mauro
PATCH v7 34/44 v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs
In reply to a message not in the archiveInstead of abusing MEDIA_ENT_T_V4L2_SUBDEV, initialize new subdev entities as MEDIA_ENT_T_UNKNOWN.
drivers/media/v4l2-core/v4l2-subdev.c +1 -1
@@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->host_priv =NULL ;#if defined(CONFIG_MEDIA_CONTROLLER ) sd->entity.name = sd->name; - sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; + sd->entity.type =MEDIA_ENT_T_UNKNOWN ;#endif }EXPORT_SYMBOL (v4l2_subdev_init);
include/uapi/linux/media.h +9 -1
@@ -42,6 +42,14 @@ struct media_device_info {#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) +/* Used values for media_entity_desc::type */ + +/* +* Initial value when an entity is created +* Drivers should change it to something useful +*/ +#define MEDIA_ENT_T_UNKNOWN 0x00000000 +/* * Base numbers for entity types *
@@ -52,7 +60,7 @@ struct media_device_info {* However, It is kept this way just to avoid binary breakages with the * namespace provided on legacy versions of this header. */ -#define MEDIA_ENT_T_DVB_BASE 0x00000000 +#define MEDIA_ENT_T_DVB_BASE 0x00000001#define MEDIA_ENT_T_V4L2_BASE 0x00010000#define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000
Signature · 1 line
2.4.3
PATCH v7 4/44 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 +61 -0
79 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH v7 04/44] [media] media: add a common struct to be embed on media graph objects
Quoted 28 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +9
-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)
drivers/media/media-entity.c line 48
Quoted 10 lines
drivers/media/media-entity.c +10
-0+* 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 */ +} +
This patch is mainly adding skeleton framework. Does this patch series implement the media_gobj_init() and media_gobj_remove()?
If so, would it make sense to combine the implementation and the stubs?
thanks,
-- Shuah
Quoted 109 lines
drivers/media/media-entity.c +13
-0+/** +* 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 +61
-1@@ -28,6 +28,39 @@#include <linux/list.h> #include <linux/media.h> +/* Enums used internally at the media controller to represent graphs */ + +/** +* enum media_gobj_type - type of a graph object +* +*/ +enum media_gobj_type { +/* FIXME: add the types here, as we embed media_gobj */ +MEDIA_GRAPH_NONE +}; + +#define MEDIA_BITS_PER_TYPE 8 +#define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE) +#define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 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 +* MEDIA_BITS_PER_TYPE to store the type plus +* MEDIA_BITS_PER_LOCAL_ID to store a per-type ID +* (called as "local ID"). +* +* All objects on the media graph should have this struct embedded +*/ +struct media_gobj { +u32 id; +}; + +struct media_pipeline { };@@ -118,6 +151,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 >>MEDIA_BITS_PER_LOCAL_ID ; +} + +static inline u32 media_localid (struct media_gobj *gobj) +{ +return gobj->id &MEDIA_LOCAL_ID_MASK ; +} + +static inline u32 media_gobj_gen_id (enum media_gobj_type type,u32 local_id) +{ +u32 id; + + id = type <<MEDIA_BITS_PER_LOCAL_ID ; + id |= local_id &MEDIA_LOCAL_ID_MASK ; + +return id; +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64@@ -131,6 +184,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); --2.4.3
--
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
Re: [PATCH v7 04/44] [media] media: add a common struct to be embed on media graph objects
Em Mon, 24 Aug 2015 14:07:07 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 35 lines
Quoted 33 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +14
-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,
Quoted 8 lines
drivers/media/media-entity.c line 48
Quoted 5 lines
drivers/media/media-entity.c +5
-0+ struct media_gobj *gobj) +{ +/* For now, nothing to do */ +} +This patch is mainly adding skeleton framework. Does this patch series implement the
media_gobj_init()andmedia_gobj_remove()?
Yes, on next patches as the usage is needed. One logical change per patch.
Quoted 2 lines
If so, would it make sense to combine the implementation and the stubs?
Keeping separate makes easier to review for most people, as it is easier to check that this patch won't cause regressions, as it only adds stub functions.
Quoted 117 lines
thanks,
-- ShuahQuoted 105 lines
drivers/media/media-entity.c +13
-0+/** +* 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 +61
-1@@ -28,6 +28,39 @@#include <linux/list.h> #include <linux/media.h> +/* Enums used internally at the media controller to represent graphs */ + +/** +* enum media_gobj_type - type of a graph object +* +*/ +enum media_gobj_type { +/* FIXME: add the types here, as we embed media_gobj */ +MEDIA_GRAPH_NONE +}; + +#define MEDIA_BITS_PER_TYPE 8 +#define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE) +#define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 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 +* MEDIA_BITS_PER_TYPE to store the type plus +* MEDIA_BITS_PER_LOCAL_ID to store a per-type ID +* (called as "local ID"). +* +* All objects on the media graph should have this struct embedded +*/ +struct media_gobj { +u32 id; +}; + +struct media_pipeline { };@@ -118,6 +151,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 >>MEDIA_BITS_PER_LOCAL_ID ; +} + +static inline u32 media_localid (struct media_gobj *gobj) +{ +return gobj->id &MEDIA_LOCAL_ID_MASK ; +} + +static inline u32 media_gobj_gen_id (enum media_gobj_type type,u32 local_id) +{ +u32 id; + + id = type <<MEDIA_BITS_PER_LOCAL_ID ; + id |= local_id &MEDIA_LOCAL_ID_MASK ; + +return id; +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64@@ -131,6 +184,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); --2.4.3
Quoted 4 lines
--
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--
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
PATCH v7 5/44 media: use media_gobj inside entities
In reply to Mauro Carvalho ChehabAs entities are graph objects, 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
@@ -379,7 +379,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);
@@ -433,10 +432,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);
@@ -459,6 +456,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 object * +* @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 MEDIA_BITS_PER_TYPE 8
@@ -94,10 +94,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 */
@@ -148,7 +147,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
Re: [PATCH v7 05/44] [media] media: use media_gobj inside entities
Quoted 52 lines · Mauro Carvalho Chehab
As entities are graph objects, let's embed
media_gobjon 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.
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +3
-5@@ -379,7 +379,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);@@ -433,10 +432,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);@@ -459,6 +456,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 +0
-0@@ -43,7 +43,12 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type,
drivers/media/media-entity.c void media_gobj_init(struct media_device *mdev, · line 52
Quoted 10 lines
drivers/media/media-entity.c +6
-1struct 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 ; + } }
Unless there is a reason to split patches 4 and 5, it would make it lot easier to review if these two patches are combined. I had to go back to review media_gobj_gen_id(type, ++mdev->entity_id) for me to get a feel for what is done here.
If combined, there is no need for skeleton media_gobj_init() and then followed by a second patch that fills it in. It will be easier to follow the new interface and its use.
thanks,
-- Shuah
Re: [PATCH v7 05/44] [media] media: use media_gobj inside entities
Em Mon, 24 Aug 2015 16:13:10 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 70 lines
Quoted 52 lines · Mauro Carvalho Chehab
As entities are graph objects, let's embed
media_gobjon 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.
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +3
-5@@ -379,7 +379,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);@@ -433,10 +432,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);@@ -459,6 +456,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 +0
-0@@ -43,7 +43,12 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type,drivers/media/media-entity.c void media_gobj_init(struct media_device *mdev, · line 52
Quoted 10 lines
drivers/media/media-entity.c +6
-1struct 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 ; + } }Unless there is a reason to split patches 4 and 5, it would make it lot easier to review if these two patches are combined. I had to go back to review
media_gobj_gen_id(type, ++mdev->entity_id)for me to get a feel for what is done here.
Quoted 3 lines
If combined, there is no need for skeleton
media_gobj_init()and then followed by a second patch that fills it in. It will be easier to follow the new interface and its use.
I find easier to review when the interfaces (headers) are added first, as diffs generally put them in the end ;)
This is actually a matter of personal taste, i guess.
Quoted 7 lines
thanks,
-- Shuah
--
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
PATCH v7 6/44 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
@@ -427,6 +427,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;
@@ -435,6 +437,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 ;
@@ -450,12 +458,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 object * * @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 MEDIA_BITS_PER_TYPE 8
@@ -72,6 +74,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
PATCH v7 7/44 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
@@ -438,6 +438,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,
@@ -465,6 +472,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 +9 -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 ; } }
@@ -491,6 +494,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +/* Initialize graph object embedded at the new link */ +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. */
@@ -504,6 +510,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +/* Initialize graph object embedded at the new link */ +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); + link->reverse = backlink; backlink->reverse = link;
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 MEDIA_BITS_PER_TYPE 8
@@ -67,6 +69,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 v7 07/44] [media] media: use media_gobj inside links
Quoted 42 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +9
-0@@ -438,6 +438,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,@@ -465,6 +472,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 +0
-0
drivers/media/media-entity.c void media_gobj_init(struct media_device *mdev, · line 59
Quoted 9 lines
drivers/media/media-entity.c +3
-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 ; } }
I think collapsing patches 4,5,6, and 7 will make this code so much easier to review.
Can we simplify media_gobj_init()? If it takes mdev->*_id as a inout/output value, there is no need to have this switch. You can simply range check type.
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 498
Quoted 6 lines
drivers/media/media-entity.c +2
-0@@ -491,6 +494,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; +/* Initialize graph object embedded at the new link */ +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj);
So far calls to media_gobj_init() are made holding mdev->lock. This is the first
case without mdev->lock hold. This could lead race conditions as this routine is changes fields in mdev.
thanks,
-- Shuah
Quoted 66 lines
drivers/media/media-entity.c +4
-0+/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -504,6 +510,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +/* Initialize graph object embedded at the new link */ +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); + link->reverse = backlink; backlink->reverse = link;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
-1@@ -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 MEDIA_BITS_PER_TYPE 8@@ -67,6 +69,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 */ --2.4.3
--
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
Re: [PATCH v7 07/44] [media] media: use media_gobj inside links
Em Mon, 24 Aug 2015 18:13:13 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 48 lines
Quoted 46 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +9
-0@@ -438,6 +438,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,@@ -465,6 +472,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 +1
-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 :
Quoted 8 lines
drivers/media/media-entity.c void media_gobj_init(struct media_device *mdev, · line 59
Quoted 5 lines
drivers/media/media-entity.c +2
-0+ gobj->id =media_gobj_gen_id (type, ++mdev->link_id); +break ; } }I think collapsing patches 4,5,6, and 7 will make this code so much easier to review.
One logical change per patch.
Quoted 2 lines
Can we simplify
media_gobj_init()? If it takes mdev->*_id as a inout/output value, there is no need to have this switch. You can simply range check type.
The switch is needed here, in order to generate the ID, and will be needed latter, when we add the object at the media device (a requirement for the new API to work. See patches 41 and 42 for the additions here, and 43/44 for its usage at the new API).
Quoted 6 lines
Quoted 6 lines
drivers/media/media-entity.c +0
-0@@ -491,6 +494,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags;
Quoted 7 lines
drivers/media/media-entity.c media_entity_create_link(struct media_entity *source, u16 source_pad, · line 498
Quoted 2 lines
drivers/media/media-entity.c +2
-0+/* Initialize graph object embedded at the new link */ +media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj);So far calls to
media_gobj_init()are made holdingmdev->lock. This is the first
case withoutmdev->lockhold. This could lead race conditions as this routine is changes fields in mdev.
True, but we'll need to review the locks anyway due to dynamic support. I was asked by Laurent to not bother with anything related to dynamic support right now. My first approach were to use atomic vars for the object IDs.
We could add a mutex_lock here, but then we need to double check on all drivers if they're not locking themselves.
So, yeah, proper lock is at our TODO list.
Quoted 70 lines
thanks,
-- ShuahQuoted 66 lines
drivers/media/media-entity.c +4
-0+/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -504,6 +510,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; +/* Initialize graph object embedded at the new link */ +media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); + link->reverse = backlink; backlink->reverse = link;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
-1@@ -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 MEDIA_BITS_PER_TYPE 8@@ -67,6 +69,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 */ --2.4.3
--
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
PATCH v7 8/44 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
@@ -359,6 +359,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" ); }/**
@@ -397,6 +398,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);
@@ -416,6 +419,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
PATCH v7 9/44 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 +67 -1
@@ -27,6 +27,69 @@#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 inline const char *gobj_type (enum media_gobj_type type) +{ +switch (type) { +case MEDIA_GRAPH_ENTITY : +return "entity" ; +case MEDIA_GRAPH_PAD : +return "pad" ; +case MEDIA_GRAPH_LINK : +return "link" ; +default : +return "unknown" ; + } +} + +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x entity#%d: '%s'\n" , + event_name, gobj->id,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 link#%d: '%s' %s#%d ==> '%s' %s#%d\n" , + event_name, gobj->id,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 pad#%d: '%s':%d\n" , + event_name, gobj->id,media_localid (gobj), + pad->entity->name, pad->index); + } + } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object
@@ -43,6 +106,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 +120,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 +132,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); }/**
include/media/media-entity.h +7 -0
@@ -61,6 +61,7 @@ enum media_gobj_type {* All objects on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;u32 id; };
@@ -192,6 +193,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 v7 09/44] [media] media: add a debug message to warn about gobj creation/removal
Quoted 30 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +12
-0@@ -27,6 +27,69 @@#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 inline const char *gobj_type (enum media_gobj_type type) +{ +switch (type) { +case MEDIA_GRAPH_ENTITY :
drivers/media/media-entity.c line 51
Quoted 10 lines
drivers/media/media-entity.c +10
-0+return "entity" ; +case MEDIA_GRAPH_PAD : +return "pad" ; +case MEDIA_GRAPH_LINK : +return "link" ; +default : +return "unknown" ; + } +} +
Shouldn't the above gobj_type be defined in if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) scope? Unless gobj_type() is used from other places, you will see defined, but not used warning when DEBUG and CONFIG_DYNAMIC_DEBUG are undefined.
Kind of related, maybe we should be looking into adding trace event support for media as opposed to dynamic and debug.
thanks,
-- Shuah
Quoted 102 lines
drivers/media/media-entity.c +45
-1+static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) +{ +#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG ) +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x entity#%d: '%s'\n" , + event_name, gobj->id,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 link#%d: '%s' %s#%d ==> '%s' %s#%d\n" , + event_name, gobj->id,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 pad#%d: '%s':%d\n" , + event_name, gobj->id,media_localid (gobj), + pad->entity->name, pad->index); + } + } +#endif +} + +/** * media_gobj_init - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object @@ -43,6 +106,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 +120,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 +132,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); }/** include/media/media-entity.h +7
-1@@ -61,6 +61,7 @@ enum media_gobj_type {* All objects on the media graph should have this struct embedded */ struct media_gobj { +struct media_device *mdev;u32 id; };@@ -192,6 +193,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); --2.4.3
--
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
Re: [PATCH v7 09/44] [media] media: add a debug message to warn about gobj creation/removal
Em Tue, 25 Aug 2015 11:51:35 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 39 lines
Quoted 37 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]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +19
-0@@ -27,6 +27,69 @@#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 inline const char *gobj_type (enum media_gobj_type type) +{ +switch (type) { +case MEDIA_GRAPH_ENTITY : +return "entity" ; +case MEDIA_GRAPH_PAD : +return "pad" ; +case MEDIA_GRAPH_LINK : +return "link" ; +default : +return "unknown" ;
Quoted 8 lines
drivers/media/media-entity.c line 51
Quoted 3 lines
drivers/media/media-entity.c +3
-0+ } +} +Shouldn't the above
gobj_typebe defined in if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) scope? Unlessgobj_type()is used from other places, you will see defined, but not used warning when DEBUG andCONFIG_DYNAMIC_DEBUGare undefined.
No need. The function was declared as inline. it won't be at the text segment if not used.
Quoted 2 lines
Kind of related, maybe we should be looking into adding trace event support for media as opposed to dynamic and debug.
I already explained why we need debug here. See the discussions of patch 7/8 on the previous series.
Regards,
Mauro
PATCH v7 10/44 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
@@ -542,7 +542,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;
@@ -586,7 +586,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
@@ -1865,7 +1865,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)
@@ -2004,51 +2004,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/au0828/au0828-core.c +3 -3
@@ -260,13 +260,13 @@ static void au0828_create_media_graph(struct au0828_dev *dev)return ;if (tuner) -media_entity_create_link (tuner,0 , decoder,0 , +media_create_pad_link (tuner,0 , decoder,0 ,MEDIA_LNK_FL_ENABLED );if (dev->vdev.entity.links) -media_entity_create_link (decoder,1 , &dev->vdev.entity,0 , +media_create_pad_link (decoder,1 , &dev->vdev.entity,0 ,MEDIA_LNK_FL_ENABLED );if (dev->vbi_dev.entity.links) -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/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
@@ -208,7 +208,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
PATCH v7 10/44 media: rename the function that create pad links
Quoted 2 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.
Is this an incomplete sentence. Should it read: "either between two different graph objects or two pads" ?
Quoted 9 lines
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
Didn't want to experiment with Coccinelle?? :)
Quoted 4 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>
Changes look good to me. After fixing the commit log:
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh at osg.samsung.com | (970) 217-8978
PATCH v7 10/44 media: rename the function that create pad links
Em Tue, 25 Aug 2015 12:55:41 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 6 lines · Mauro Carvalho Chehab
Quoted 2 lines
Now that a link can be either between two different graph objects, we'll need to add more functions to create links.
Is this an incomplete sentence. Should it read: "either between two different graph objects or two pads" ?
That would be redundant, as pad is a graph object ;)
Quoted 5 lines
Quoted 5 lines
So, rename the existing one that create links only between two pads as
media_create_pad_link().
Quoted 7 lines
Quoted 5 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; doneDidn't want to experiment with Coccinelle?? :)
I use Coccinelle, but only when I need more complex changes, as Coccinelle may mangle with comments.
Quoted 14 lines
Quoted 5 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Changes look good to me. After fixing the commit log:
Acked-by Shuah Khan <[email protected]>thanks,
-- Shuah
PATCH v7 10/44 media: rename the function that create pad links
Em Wed, 26 Aug 2015 11:54:03 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 11 lines
Em Tue, 25 Aug 2015 12:55:41 -0600
Shuah Khan <[email protected]> escreveu:Quoted 6 lines · Mauro Carvalho Chehab
Quoted 2 lines
Now that a link can be either between two different graph objects, we'll need to add more functions to create links.
Is this an incomplete sentence. Should it read: "either between two different graph objects or two pads" ?
That would be redundant, as pad is a graph object ;)
Renamed the patch description to:
With the new API, a link can be either between two PADs or between an interface and an entity. So, we need to use a better name for the function that create links between two pads.
So, rename the such function to 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
Regards,
Mauro
Quoted 35 lines
Quoted 6 lines
Quoted 6 lines
So, rename the existing one that create links only between two pads as
media_create_pad_link().Quoted 7 lines
Quoted 5 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; doneDidn't want to experiment with Coccinelle?? :)
I use Coccinelle, but only when I need more complex changes, as Coccinelle may mangle with comments.
Quoted 6 lines
Quoted 5 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Quoted 8 lines
Changes look good to me. After fixing the commit log:
Acked-by Shuah Khan <[email protected]>thanks,
-- Shuah--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v7 11/44 media: use entity.graph_obj.mdev instead of .parent
In reply to Mauro Carvalho ChehabFrom: Javier Martinez Canillas <[email protected]>
The struct media_entity has a .parent field that stores a pointer to the parent struct media_device. But recently a media_gobj was embedded into the entities and since struct media_gojb already has a pointer to a struct media_device in the .mdev field, the .parent field becomes redundant and can be removed.
This patch replaces all the usage of .parent by .graph_obj.mdev so that field will become unused and can be removed on a later patch.
No functional changes.
The transformation was made using the following coccinelle spatch:
@@
struct media_entity *me;
@@
- me->parent
+ me->graph_obj.mdev
@@
struct media_entity *link;
@@
- link->source->entity->parent
+ link->source->entity->graph_obj.mdev
@@
struct exynos_video_entity *ve;
@@
- ve->vdev.entity.parent
+ ve->vdev.entity.graph_obj.mdev
drivers/media/media-device.c +4 -4
@@ -435,8 +435,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,int i;/* Warn if we apparently re-register an entity */ -WARN_ON (entity->parent !=NULL ); - entity->parent = mdev; +WARN_ON (entity->graph_obj.mdev !=NULL ); + entity->graph_obj.mdev = mdev;spin_lock (&mdev->lock);/* Initialize media_gobj embedded at the entity */
@@ -471,7 +471,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);void media_device_unregister_entity (struct media_entity *entity) {int i; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;if (mdev ==NULL )return ;
@@ -484,7 +484,7 @@ void media_device_unregister_entity(struct media_entity *entity)media_gobj_remove (&entity->graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock); - entity->parent =NULL ; + entity->graph_obj.mdev =NULL ; }EXPORT_SYMBOL_GPL (media_device_unregister_entity);
drivers/media/media-entity.c +18 -16
@@ -332,7 +332,7 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);__must_check int media_entity_pipeline_start (struct media_entity *entity,struct media_pipeline *pipe) { -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;struct media_entity_graph graph;struct media_entity *entity_err = entity;int ret;
@@ -387,7 +387,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ret = entity->ops->link_validate (link);if (ret <0 && ret != -ENOIOCTLCMD ) { - dev_dbg(entity->parent->dev, + dev_dbg(entity->graph_obj.mdev->dev, "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", link->source->entity->name, link->source->index,
@@ -401,7 +401,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, if (!bitmap_full(active, entity->num_pads)) { ret = -EPIPE; - dev_dbg(entity->parent->dev, + dev_dbg(entity->graph_obj.mdev->dev, "\"%s\":%u must be connected by an enabled link\n", entity->name, (unsigned)find_first_zero_bit(
@@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start);*/ void media_entity_pipeline_stop (struct media_entity *entity) { -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;struct media_entity_graph graph;mutex_lock (&mdev->graph_mutex);
@@ -490,8 +490,8 @@ struct media_entity *media_entity_get(struct media_entity *entity)if (entity ==NULL )return NULL ; -if (entity->parent->dev && - !try_module_get (entity->parent->dev->driver->owner)) +if (entity->graph_obj.mdev->dev && + !try_module_get (entity->graph_obj.mdev->dev->driver->owner))return NULL ;return entity;
@@ -511,8 +511,8 @@ void media_entity_put(struct media_entity *entity)if (entity ==NULL )return ; -if (entity->parent->dev) -module_put (entity->parent->dev->driver->owner); +if (entity->graph_obj.mdev->dev) +module_put (entity->graph_obj.mdev->dev->driver->owner); }EXPORT_SYMBOL_GPL (media_entity_put);
@@ -561,7 +561,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, link->flags = flags;/* Initialize graph object embedded at the new link */ -media_gobj_init (source->parent,MEDIA_GRAPH_LINK , &link->graph_obj); +media_gobj_init (source->graph_obj.mdev,MEDIA_GRAPH_LINK , + &link->graph_obj);/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace.
@@ -577,7 +578,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, backlink->flags = flags;/* Initialize graph object embedded at the new link */ -media_gobj_init (sink->parent,MEDIA_GRAPH_LINK , &backlink->graph_obj); +media_gobj_init (sink->graph_obj.mdev,MEDIA_GRAPH_LINK , + &backlink->graph_obj); link->reverse = backlink; backlink->reverse = link;
@@ -629,12 +631,12 @@ EXPORT_SYMBOL_GPL(__media_entity_remove_links);void media_entity_remove_links (struct media_entity *entity) {/* Do nothing if the entity is not registered. */ -if (entity->parent ==NULL ) +if (entity->graph_obj.mdev ==NULL )return ; -mutex_lock (&entity->parent->graph_mutex); +mutex_lock (&entity->graph_obj.mdev->graph_mutex);__media_entity_remove_links (entity); -mutex_unlock (&entity->parent->graph_mutex); +mutex_unlock (&entity->graph_obj.mdev->graph_mutex); }EXPORT_SYMBOL_GPL (media_entity_remove_links);
@@ -703,7 +705,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags) (source->stream_count || sink->stream_count))return -EBUSY ; - mdev = source->parent; + mdev = source->graph_obj.mdev;if (mdev->link_notify) { ret = mdev->link_notify(link, flags,
@@ -724,9 +726,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags) {int ret; -mutex_lock (&link->source->entity->parent->graph_mutex); +mutex_lock (&link->source->entity->graph_obj.mdev->graph_mutex); ret =__media_entity_setup_link (link, flags); -mutex_unlock (&link->source->entity->parent->graph_mutex); +mutex_unlock (&link->source->entity->graph_obj.mdev->graph_mutex);return ret; }
drivers/media/platform/exynos4-is/fimc-isp-video.c +3 -3
@@ -288,7 +288,7 @@ static int isp_video_open(struct file *file) goto rel_fh;if (v4l2_fh_is_singular_file (file)) { -mutex_lock (&me->parent->graph_mutex); +mutex_lock (&me->graph_obj.mdev->graph_mutex); ret =fimc_pipeline_call (ve, open, me, true);
@@ -296,7 +296,7 @@ static int isp_video_open(struct file *file)if (ret ==0 ) me->use_count++; -mutex_unlock (&me->parent->graph_mutex); +mutex_unlock (&me->graph_obj.mdev->graph_mutex); }if (!ret) goto unlock;
@@ -312,7 +312,7 @@ static int isp_video_release(struct file *file)struct fimc_isp *isp =video_drvdata (file);struct fimc_is_video *ivc = &isp->video_capture;struct media_entity *entity = &ivc->ve.vdev.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;mutex_lock (&isp->video_lock);
drivers/media/platform/exynos4-is/fimc-lite.c +4 -4
@@ -500,7 +500,7 @@ static int fimc_lite_open(struct file *file) atomic_read(&fimc->out_path) != FIMC_IO_DMA) goto unlock; -mutex_lock (&me->parent->graph_mutex); +mutex_lock (&me->graph_obj.mdev->graph_mutex); ret =fimc_pipeline_call (&fimc->ve, open, me, true);
@@ -508,7 +508,7 @@ static int fimc_lite_open(struct file *file)if (ret ==0 ) me->use_count++; -mutex_unlock (&me->parent->graph_mutex); +mutex_unlock (&me->graph_obj.mdev->graph_mutex);if (!ret) {fimc_lite_clear_event_counters (fimc);
@@ -541,9 +541,9 @@ static int fimc_lite_release(struct file *file)fimc_pipeline_call (&fimc->ve, close);clear_bit (ST_FLITE_IN_USE , &fimc->state); -mutex_lock (&entity->parent->graph_mutex); +mutex_lock (&entity->graph_obj.mdev->graph_mutex); entity->use_count--; -mutex_unlock (&entity->parent->graph_mutex); +mutex_unlock (&entity->graph_obj.mdev->graph_mutex); }_vb2_fop_release (file,NULL );
drivers/media/platform/exynos4-is/media-dev.c +1 -1
@@ -1046,7 +1046,7 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable)return ret; } -/* Locking: called with entity->parent->graph_mutex mutex held. */ +/* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */ static int __fimc_md_modify_pipelines (struct media_entity *entity,bool enable) {struct media_entity *entity_err = entity;
drivers/media/platform/exynos4-is/media-dev.h +4 -4
@@ -164,8 +164,8 @@ struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si)static inline struct fimc_md *entity_to_fimc_mdev (struct media_entity *me) { -return me->parent ==NULL ?NULL : - container_of(me->parent, struct fimc_md, media_dev); +return me->graph_obj.mdev ==NULL ?NULL : + container_of(me->graph_obj.mdev, struct fimc_md, media_dev); }static inline struct fimc_md *notifier_to_fimc_md (struct v4l2_async_notifier *n)
@@ -175,12 +175,12 @@ static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n)static inline void fimc_md_graph_lock (struct exynos_video_entity *ve) { -mutex_lock (&ve->vdev.entity.parent->graph_mutex); +mutex_lock (&ve->vdev.entity.graph_obj.mdev->graph_mutex); }static inline void fimc_md_graph_unlock (struct exynos_video_entity *ve) { -mutex_unlock (&ve->vdev.entity.parent->graph_mutex); +mutex_unlock (&ve->vdev.entity.graph_obj.mdev->graph_mutex); }int fimc_md_set_camclk (struct v4l2_subdev *sd,bool on);
drivers/media/platform/omap3isp/isp.c +2 -2
@@ -787,7 +787,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)int change = use ?1 :-1 ;int ret; -mutex_lock (&entity->parent->graph_mutex); +mutex_lock (&entity->graph_obj.mdev->graph_mutex);/* Apply use count to node. */ entity->use_count += change;
@@ -798,7 +798,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)if (ret <0 ) entity->use_count -= change; -mutex_unlock (&entity->parent->graph_mutex); +mutex_unlock (&entity->graph_obj.mdev->graph_mutex);return ret; }
drivers/media/platform/omap3isp/ispvideo.c +1 -1
@@ -226,7 +226,7 @@ static int isp_video_get_graph_data(struct isp_video *video, {struct media_entity_graph graph;struct media_entity *entity = &video->video.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;struct isp_video *far_end =NULL ;mutex_lock (&mdev->graph_mutex);
drivers/media/platform/vsp1/vsp1_video.c +1 -1
@@ -409,7 +409,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, {struct media_entity_graph graph;struct media_entity *entity = &video->video.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;unsigned int i;int ret;
drivers/media/platform/xilinx/xilinx-dma.c +1 -1
@@ -181,7 +181,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, {struct media_entity_graph graph;struct media_entity *entity = &start->video.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;unsigned int num_inputs =0 ;unsigned int num_outputs =0 ;
drivers/staging/media/davinci_vpfe/vpfe_video.c +3 -3
@@ -130,7 +130,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video,static void vpfe_prepare_pipeline (struct vpfe_video_device *video) {struct media_entity *entity = &video->video_dev.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;struct vpfe_pipeline *pipe = &video->pipe;struct vpfe_video_device *far_end =NULL ;struct media_entity_graph graph;
@@ -288,7 +288,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)else entity = &pipe->inputs[0 ]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev;mutex_lock (&mdev->graph_mutex);media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) {
@@ -328,7 +328,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)else entity = &pipe->inputs[0 ]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev;mutex_lock (&mdev->graph_mutex);media_entity_graph_walk_start (&graph, entity);
drivers/staging/media/omap4iss/iss.c +2 -2
@@ -494,7 +494,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)int change = use ?1 :-1 ;int ret; -mutex_lock (&entity->parent->graph_mutex); +mutex_lock (&entity->graph_obj.mdev->graph_mutex);/* Apply use count to node. */ entity->use_count += change;
@@ -505,7 +505,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)if (ret <0 ) entity->use_count -= change; -mutex_unlock (&entity->parent->graph_mutex); +mutex_unlock (&entity->graph_obj.mdev->graph_mutex);return ret; }
drivers/staging/media/omap4iss/iss_video.c +1 -1
@@ -207,7 +207,7 @@ iss_video_far_end(struct iss_video *video) {struct media_entity_graph graph;struct media_entity *entity = &video->video.entity; -struct media_device *mdev = entity->parent; +struct media_device *mdev = entity->graph_obj.mdev;struct iss_video *far_end =NULL ;mutex_lock (&mdev->graph_mutex);
Signature · 1 line
2.4.3
PATCH v7 11/44 media: use entity.graph_obj.mdev instead of .parent
Quoted 33 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
The struct
media_entityhas a .parent field that stores a pointer to the parent structmedia_device. But recently amedia_gobjwas embedded into the entities and since structmedia_gojbalready has a pointer to a structmedia_devicein the .mdev field, the .parent field becomes redundant and can be removed.This patch replaces all the usage of .parent by .graph_obj.mdev so that field will become unused and can be removed on a later patch.
No functional changes.
The transformation was made using the following coccinelle spatch:
@@
structmedia_entity*me;
@@-
me->parent
+me->graph_obj.mdev@@
structmedia_entity*link;
@@-
link->source->entity->parent
+link->source->entity->graph_obj.mdev@@
structexynos_video_entity*ve;
@@
Quoted 7 lines
-
ve->vdev.entity.parent
+ve->vdev.entity.graph_obj.mdevSuggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>
PATCH v7 11/44 media: use entity.graph_obj.mdev instead of .parent
Quoted 37 lines · Hans Verkuil
Quoted 36 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
The struct
media_entityhas a .parent field that stores a pointer to the parent structmedia_device. But recently amedia_gobjwas embedded into the entities and since structmedia_gojbalready has a pointer to a structmedia_devicein the .mdev field, the .parent field becomes redundant and can be removed.This patch replaces all the usage of .parent by .graph_obj.mdev so that field will become unused and can be removed on a later patch.
No functional changes.
The transformation was made using the following coccinelle spatch:
@@
structmedia_entity*me;
@@-
me->parent
+me->graph_obj.mdev@@
structmedia_entity*link;
@@-
link->source->entity->parent
+link->source->entity->graph_obj.mdev@@
structexynos_video_entity*ve;
@@-
ve->vdev.entity.parent
+ve->vdev.entity.graph_obj.mdev
Quoted 6 lines
Quoted 4 lines
Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>
The change looks good to me. I would really like to see a before and after media graph with these changes, this patch and series in general.
thanks,
-- Shuah
PATCH v7 11/44 media: use entity.graph_obj.mdev instead of .parent
Em Tue, 25 Aug 2015 13:25:15 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 40 lines · Hans Verkuil
Quoted 39 lines · Mauro Carvalho Chehab
Quoted 38 lines
From: Javier Martinez Canillas <[email protected]>
The struct
media_entityhas a .parent field that stores a pointer to the parent structmedia_device. But recently amedia_gobjwas embedded into the entities and since structmedia_gojbalready has a pointer to a structmedia_devicein the .mdev field, the .parent field becomes redundant and can be removed.This patch replaces all the usage of .parent by .graph_obj.mdev so that field will become unused and can be removed on a later patch.
No functional changes.
The transformation was made using the following coccinelle spatch:
@@
structmedia_entity*me;
@@-
me->parent
+me->graph_obj.mdev@@
structmedia_entity*link;
@@-
link->source->entity->parent
+link->source->entity->graph_obj.mdev@@
structexynos_video_entity*ve;
@@-
ve->vdev.entity.parent
+ve->vdev.entity.graph_obj.mdevSuggested-by Mauro Carvalho Chehab <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Acked-by Hans Verkuil <[email protected]>The change looks good to me. I would really like to see a before and after media graph with these changes, this patch and series in general.
Well, it shouldn't change. If something changes, things would be wrong :)
Btw, Javier is doing a before/after tests on OMAP3. There are a few fixup things to be added/adjusted (unfortunately, OMAP3 doesn't compile on x86 COMPILE_TEST), but on his tests, the differences between before and after, with media-ctl are zero.
As media-ctl is using the legacy API, it shouldn't have any changes there, otherwise something is broken and should be fixed ;)
I'll spin this patch series with Javier fixes for OMAP at the next version of this patch series.
Quoted 3 lines
thanks,
-- Shuah
PATCH v7 12/44 media: remove media entity .parent field
In reply to Mauro Carvalho ChehabFrom: Javier Martinez Canillas <[email protected]>
Now that the struct media_entity .parent field is unused, it can be safely removed. Since all the previous users were converted to use the .mdev field from the embedded struct media_gobj instead.
include/media/media-entity.h +0 -1
@@ -103,7 +103,6 @@ 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*/ const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ u32 revision;/* Entity revision, driver specific */
Signature · 1 line
2.4.3
Re: [PATCH v7 12/44] [media] media: remove media entity .parent field
Quoted 10 lines · Mauro Carvalho Chehab
From: Javier Martinez Canillas <[email protected]>
Now that the struct
media_entity.parent field is unused, it can be safely removed. Since all the previous users were converted to use the .mdev field from the embedded structmedia_gobjinstead.Suggested-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>
Quoted 14 lines
include/media/media-entity.h +0
-1@@ -103,7 +103,6 @@ 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*/ const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ u32 revision;/* Entity revision, driver specific */
PATCH v7 14/44 media: add functions to allow creating interfaces
In reply to Mauro Carvalho ChehabInterfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
drivers/media/media-entity.c +96 -0
@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )
@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif
@@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }
@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +
include/media/media-device.h +2 -0
@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock
@@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;
include/media/media-entity.h +48 -0
77 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Quoted 8 lines · Mauro Carvalho Chehab
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic
s/Latter/later/
Quoted 10 lines
to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +0
-0
drivers/media/media-entity.c static inline const char *gobj_type(enum media_gobj_type type) · line 48
Quoted 5 lines
drivers/media/media-entity.c +2
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;
Does this mean that you are planning different types for non-devnode interfaces like a network interface?
I'm not necessarily opposed, but I would like to know your reasoning for making this a type in the media object ID instead of part of the media_interface type field.
It might become clearer to me as I work my way through this patch series.
Quoted 24 lines
drivers/media/media-entity.c +19
-0default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ;
drivers/media/media-entity.c static inline const char *gobj_type(enum media_gobj_type type) · line 82
Quoted 10 lines
drivers/media/media-entity.c +10
-0+case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ;
I prefer - over _, but that's a personal preference.
Quoted 182 lines
drivers/media/media-entity.c +65
-0+case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +43
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node +* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +}; +static inline u32 media_entity_type (struct media_entity *entity) {return entity->type &MEDIA_ENT_TYPE_MASK ;@@ -198,6 +229,18 @@ struct media_entity_graph {#define gobj_to_link (gobj) \ container_of(gobj, struct media_link, graph_obj) +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) + +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_intf (gobj) \ + container_of(gobj, struct media_interface, graph_obj) + +#define intf_to_devnode (intf) \ + container_of(intf, struct media_intf_devnode, intf) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);@@ -229,6 +272,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe);
include/media/media-entity.h __must_check int media_entity_pipeline_start(struct media_entity *entity, · line 282
Quoted 10 lines
include/media/media-entity.h +5
-0void media_entity_pipeline_stop (struct media_entity *entity); +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags); +void media_devnode_remove (struct media_intf_devnode *devnode); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Regards,
Hans
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Em Tue, 25 Aug 2015 09:09:18 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 17 lines · Mauro Carvalho Chehab
Quoted 8 lines
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic
s/Latter/later/
Quoted 5 lines
to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
Quoted 13 lines
drivers/media/media-entity.c static inline const char *gobj_type(enum media_gobj_type type) · line 48
Quoted 10 lines
drivers/media/media-entity.c +2
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;Does this mean that you are planning different types for non-devnode interfaces like a network interface?
Yes.
Quoted 5 lines
I'm not necessarily opposed, but I would like to know your reasoning for making this a type in the media object ID instead of part of the
media_interfacetype field.It might become clearer to me as I work my way through this patch series.
That would allow saving space when allocating the objects at Kernelspace, as each type of interface will have its own type. That could make some difference when we add sysfs types.
Also, by having its own structure, typecast is enforced, with is a good thing.
Quoted 29 lines
Quoted 29 lines
drivers/media/media-entity.c +23
-0default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ;
Quoted 8 lines
drivers/media/media-entity.c static inline const char *gobj_type(enum media_gobj_type type) · line 82
Quoted 6 lines
drivers/media/media-entity.c +6
-0+case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ;I prefer - over _, but that's a personal preference.
Well, not a good reason to use '_' instead of '-', just my personal preference ;)
I'm happy with either ways.
Quoted 197 lines
Quoted 183 lines
drivers/media/media-entity.c +65
-0+case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +43
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node +* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +}; +static inline u32 media_entity_type (struct media_entity *entity) {return entity->type &MEDIA_ENT_TYPE_MASK ;@@ -198,6 +229,18 @@ struct media_entity_graph {#define gobj_to_link (gobj) \ container_of(gobj, struct media_link, graph_obj) +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) + +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_intf (gobj) \ + container_of(gobj, struct media_interface, graph_obj) + +#define intf_to_devnode (intf) \ + container_of(intf, struct media_intf_devnode, intf) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);@@ -229,6 +272,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe);include/media/media-entity.h __must_check int media_entity_pipeline_start(struct media_entity *entity, · line 282
Quoted 10 lines
include/media/media-entity.h +5
-0void media_entity_pipeline_stop (struct media_entity *entity); +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags); +void media_devnode_remove (struct media_intf_devnode *devnode); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)Regards,
Hans
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Quoted 11 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:09:18 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 4 lines
drivers/media/media-entity.c static inline const char *gobj_type(enum media_gobj_type type) · line 82
Quoted 2 lines
drivers/media/media-entity.c +2
-0+case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ;I prefer - over _, but that's a personal preference.
Well, not a good reason to use '_' instead of '-', just my personal preference ;)
I'm happy with either ways.
FYI: two practical reasons why I prefer '-' over '_':
1) to type '_' I need to use the Shift key, which I don't need to use for '-'. I'm lazy, so sue me :-)
2) '_' is sometimes hard to read if it gets close to the next line, e.g.:
alsa_control
try Testing
You don't have this problem with '-':
alsa-control
try Testing
Regards,
Hans
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
In reply to Mauro Carvalho ChehabQuoted 115 lines · Mauro Carvalho Chehab
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +68
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode;
drivers/media/media-entity.c struct media_pad *media_entity_remote_pad(struct media_pad *pad) · line 873
Quoted 10 lines
drivers/media/media-entity.c +10
-0+struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags;
After looking at patch 20 I think you want to create a media_interface_init() helper function to set type and flags and later (in patch 20) init the 'links' list.
This initialization will be shared with e.g. network or sysfs interfaces, so doing this in a helper function would make sense.
Regards,
Hans
Quoted 124 lines
drivers/media/media-entity.c +18
-0+ + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +48
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node +* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +}; +static inline u32 media_entity_type (struct media_entity *entity) {return entity->type &MEDIA_ENT_TYPE_MASK ;@@ -198,6 +229,18 @@ struct media_entity_graph {#define gobj_to_link (gobj) \ container_of(gobj, struct media_link, graph_obj) +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) + +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_intf (gobj) \ + container_of(gobj, struct media_interface, graph_obj) + +#define intf_to_devnode (intf) \ + container_of(intf, struct media_intf_devnode, intf) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);@@ -229,6 +272,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe);void media_entity_pipeline_stop (struct media_entity *entity); +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags); +void media_devnode_remove (struct media_intf_devnode *devnode); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Em Tue, 25 Aug 2015 09:42:25 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 131 lines · Mauro Carvalho Chehab
Quoted 115 lines
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +68
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode;drivers/media/media-entity.c struct media_pad *media_entity_remote_pad(struct media_pad *pad) · line 873
Quoted 10 lines
drivers/media/media-entity.c +10
-0+struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags;After looking at patch 20 I think you want to create a
media_interface_init()helper function to set type and flags and later (in patch 20) init the 'links' list.
Quoted 2 lines
This initialization will be shared with e.g. network or sysfs interfaces, so doing this in a helper function would make sense.
We could move the common stuff to a helper function, but I actually prefer to do that when we add other interface types. It will take some time until we get there, and the logic may change until then. See the comment I'm writing for patch 20.
Regards,
Mauro
Quoted 130 lines
Regards,
Hans
Quoted 124 lines
drivers/media/media-entity.c +18
-0+ + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +48
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node +* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +}; +static inline u32 media_entity_type (struct media_entity *entity) {return entity->type &MEDIA_ENT_TYPE_MASK ;@@ -198,6 +229,18 @@ struct media_entity_graph {#define gobj_to_link (gobj) \ container_of(gobj, struct media_link, graph_obj) +#define gobj_to_link (gobj) \ + container_of(gobj, struct media_link, graph_obj) + +#define gobj_to_pad (gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_intf (gobj) \ + container_of(gobj, struct media_interface, graph_obj) + +#define intf_to_devnode (intf) \ + container_of(intf, struct media_intf_devnode, intf) +void media_gobj_init (struct media_device *mdev,enum media_gobj_type type,struct media_gobj *gobj);@@ -229,6 +272,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe);void media_entity_pipeline_stop (struct media_entity *entity); +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags); +void media_devnode_remove (struct media_intf_devnode *devnode); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Em Tue, 25 Aug 2015 06:57:42 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 137 lines
Em Tue, 25 Aug 2015 09:42:25 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 131 lines · Mauro Carvalho Chehab
Quoted 115 lines
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +68
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode;drivers/media/media-entity.c struct media_pad *media_entity_remote_pad(struct media_pad *pad) · line 873
Quoted 10 lines
drivers/media/media-entity.c +10
-0+struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags;After looking at patch 20 I think you want to create a
media_interface_init()helper function to set type and flags and later (in patch 20) init the 'links' list.Quoted 2 lines
This initialization will be shared with e.g. network or sysfs interfaces, so doing this in a helper function would make sense.
Quoted 6 lines
We could move the common stuff to a helper function, but I actually prefer to do that when we add other interface types. It will take some time until we get there, and the logic may change until then.
See the comment
I'm writing for patch 20.
Please ignore this. I misread your comment there.
I'll write a patch at the end of the series moving the common interface init to a media_interface_init() helper function.
Regards,
Mauro
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
In reply to Mauro Carvalho ChehabQuoted 203 lines · Mauro Carvalho Chehab
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +96
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +20
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node
include/media/media-entity.h struct media_entity { · line 173
Quoted 10 lines
include/media/media-entity.h +10
-0+* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +};
What about the substream identifier for alsa?
May I suggest to move all alsa changes/additions out of this patch series and into an independent series on top of this one? Everything alsa related needs an Ack from the alsa devs, so let's keep it separate to avoid alsa from blocking the DVB/V4L work.
Regards,
Hans
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Em Tue, 25 Aug 2015 10:29:14 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 217 lines · Mauro Carvalho Chehab
Quoted 203 lines
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +96
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +20
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node include/media/media-entity.h struct media_entity { · line 173
Quoted 10 lines
include/media/media-entity.h +10
-0+* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node +*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +};What about the substream identifier for alsa?
Quoted 1 line
From what I understood from our discussions with Lars, we don't need a
substream identifier for ALSA.
Quoted 4 lines
May I suggest to move all alsa changes/additions out of this patch series and into an independent series on top of this one? Everything alsa related needs an Ack from the alsa devs, so let's keep it separate to avoid alsa from blocking the DVB/V4L work.
OK.
Quoted 4 lines
Regards,
Hans
Re: [PATCH v7 14/44] [media] media: add functions to allow creating interfaces
Quoted 223 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 10:29:14 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 208 lines · Mauro Carvalho Chehab
Quoted 207 lines
Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.
Let's distinguish them by creating a separate structure to store the interfaces.
Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +96
-0@@ -44,11 +44,53 @@ static inline const char *gobj_type(enum media_gobj_type type)return "pad" ;case MEDIA_GRAPH_LINK :return "link" ; +case MEDIA_GRAPH_INTF_DEVNODE : +return "intf_devnode" ;default :return "unknown" ; } } +static inline const char *intf_type (struct media_interface *intf) +{ +switch (intf->type) { +case MEDIA_INTF_T_DVB_FE : +return "frontend" ; +case MEDIA_INTF_T_DVB_DEMUX : +return "demux" ; +case MEDIA_INTF_T_DVB_DVR : +return "DVR" ; +case MEDIA_INTF_T_DVB_CA : +return "CA" ; +case MEDIA_INTF_T_DVB_NET : +return "dvbnet" ; +case MEDIA_INTF_T_V4L_VIDEO : +return "video" ; +case MEDIA_INTF_T_V4L_VBI : +return "vbi" ; +case MEDIA_INTF_T_V4L_RADIO : +return "radio" ; +case MEDIA_INTF_T_V4L_SUBDEV : +return "v4l2_subdev" ; +case MEDIA_INTF_T_V4L_SWRADIO : +return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm_capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm_playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa_control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +default : +return "unknown_intf" ; + } +}; +static void dev_dbg_obj (const char *event_name,struct media_gobj *gobj) {#if defined(DEBUG ) || defined (CONFIG_DYNAMIC_DEBUG )@@ -84,6 +126,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)"%s: id 0x%08x pad#%d: '%s':%d\n" , event_name, gobj->id,media_localid (gobj), pad->entity->name, pad->index); + break; + } +case MEDIA_GRAPH_INTF_DEVNODE : + { +struct media_interface *intf =gobj_to_intf (gobj); +struct media_intf_devnode *devnode =intf_to_devnode (intf); + +dev_dbg (gobj->mdev->dev, +"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n" , + event_name, gobj->id,media_localid (gobj), +intf_type (intf), + devnode->major, devnode->minor); +break ; } }#endif @@ -119,6 +174,9 @@ void media_gobj_init(struct media_device *mdev,case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ; +case MEDIA_GRAPH_INTF_DEVNODE : + gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id); +break ; }dev_dbg_obj (__func__, gobj); }@@ -793,3 +851,41 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) }EXPORT_SYMBOL_GPL (media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create (struct media_device *mdev, +u32 type,u32 flags, +u32 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; +struct media_interface *intf; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + +media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , + &devnode->intf.graph_obj); + +return devnode; +} +EXPORT_SYMBOL_GPL (media_devnode_create); + +void media_devnode_remove (struct media_intf_devnode *devnode) +{ +media_gobj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); +include/media/media-device.h +2
-0@@ -44,6 +44,7 @@ struct device;* @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 +* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device {u32 entity_id;u32 pad_id;u32 link_id; +u32 intf_devnode_id;struct list_head entities;include/media/media-entity.h +24
-0@@ -36,11 +36,14 @@* @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link +* @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via +* a device node */ enum media_gobj_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };#define MEDIA_BITS_PER_TYPE 8@@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @type: Type of the interface as defined at the +* uapi/media/media.h header, e. g. +* MEDIA_INTF_T_* +* @flags: Interface flags as defined at uapi/media/media.h +*/ +struct media_interface { +struct media_gobj graph_obj; +u32 type; +u32 flags; +}; + +/** +* struct media_intf_devnode - Define a Kernel API interface via a device node +* +* @intf: embedded interface object +* @major: Major number of a device node +* @minor: Minor number of a device node Quoted 8 lines
include/media/media-entity.h struct media_entity { · line 173
Quoted 6 lines
include/media/media-entity.h +6
-0+*/ +struct media_intf_devnode { +struct media_interface intf; +u32 major; +u32 minor; +};What about the substream identifier for alsa?
From what I understood from our discussions with Lars, we don't need a substream identifier for ALSA.
Quoted 7 lines
Quoted 4 lines
May I suggest to move all alsa changes/additions out of this patch series and into an independent series on top of this one? Everything alsa related needs an Ack from the alsa devs, so let's keep it separate to avoid alsa from blocking the DVB/V4L work.
OK.
Good to see agreement on keeping ALSA related stuff out of this patch series. It makes lot more sense to add them when ALSA work is done. I am finding there is always a need to cleanup and tweak with this type of support added in anticipation future work without having a reference implementation to support it.
This is the same comment I made on
13/44] [media] uapi/media.h: Declare interface types
thanks,
Shuah
PATCH v7 15/44 media: get rid of an unused code
In reply to Mauro Carvalho ChehabThis code is not used in practice. Get rid of it before start converting links to lists.
drivers/media/media-device.c +0 -7
@@ -443,13 +443,6 @@ 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,
Signature · 1 line
2.4.3
Re: [PATCH v7 15/44] [media] media: get rid of an unused code
Quoted 2 lines · Mauro Carvalho Chehab
This code is not used in practice. Get rid of it before start converting links to lists.
I assume the reason is that links are always created *after* entities are registered?
Can you add that to this commit log?
With that change:
Quoted 22 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +0
-7@@ -443,13 +443,6 @@ 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,
Re: [PATCH v7 15/44] [media] media: get rid of an unused code
Em Tue, 25 Aug 2015 09:10:57 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 6 lines · Mauro Carvalho Chehab
Quoted 2 lines
This code is not used in practice. Get rid of it before start converting links to lists.
I assume the reason is that links are always created *after* entities are registered?
That was the assumption. However, Javier found some cases where drivers are creating links before.
So, we should either drop this patch and add some additional logic on the next one to handle late graph object init or to fix the drivers before.
I'll work on the delayed graph object init, as it sounds the easiest way, but let's see how such change will actually work.
Quoted 30 lines
Can you add that to this commit log?
With that change:
Acked-by Hans Verkuil <[email protected]>Quoted 22 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +0
-7@@ -443,13 +443,6 @@ 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,
Re: [PATCH v7 15/44] [media] media: get rid of an unused code
Quoted 13 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:10:57 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 6 lines · Mauro Carvalho Chehab
Quoted 2 lines
This code is not used in practice. Get rid of it before start converting links to lists.
I assume the reason is that links are always created *after* entities are registered?
That was the assumption. However, Javier found some cases where drivers are creating links before.
Quoted 7 lines
So, we should either drop this patch and add some additional logic on the next one to handle late graph object init or to fix the drivers before.
I'll work on the delayed graph object init, as it sounds the easiest way, but let's see how such change will actually work.
I think we should drop this patch for now. I also would like to see this new code
in action on a driver that has DVB and V4L modules and creates entities during probe and maybe even links during probe with no specific probe ordering between individual module probes. This way we are sure we need this code and know that it is correct.
thanks,
-- Shuah
Re: [PATCH v7 15/44] [media] media: get rid of an unused code
Em Tue, 25 Aug 2015 16:32:19 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 19 lines
Quoted 17 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:10:57 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 6 lines · Mauro Carvalho Chehab
Quoted 2 lines
This code is not used in practice. Get rid of it before start converting links to lists.
I assume the reason is that links are always created *after* entities are registered?
That was the assumption. However, Javier found some cases where drivers are creating links before.
So, we should either drop this patch and add some additional logic on the next one to handle late graph object init or to fix the drivers before.
Quoted 5 lines
Quoted 3 lines
I'll work on the delayed graph object init, as it sounds the easiest way, but let's see how such change will actually work.
I think we should drop this patch for now.
We can't, as otherwise it will break compilation on patch 16/44.
What we need to do is to ensure that all drivers will be doing the right thing before this one.
Quoted 6 lines
I also would like to see
this new code
in action on a driver that has DVB and V4L modules and creates entities during probe and maybe even links during probe with no specific probe ordering between individual module probes. This way we are sure we need this code and know that it is correct.
See media-ctl --print-t output:
http://pastebin.com/ckxafiJB
Please notice that the media-ctl version I'm using doesn't know the DVB entity types yet, as it needs to be patched to be aware of the new API. So, it reports the DVB stuff as "unknow entities".
And that's the output of the new tool that uses the new API:
http://pastebin.com/fRhMcTue
Regards,
Mauro
PATCH v7 16/44 media: convert links from array to list
In reply to Mauro Carvalho ChehabThe entire logic that represent graph links were developed on a time where there were no needs to dynamic remove links. So, although links are created/removed one by one via some functions, they're stored as an array inside the entity struct.
As the array may grow, there's a logic inside the code that checks if the amount of space is not enough to store the needed links. If it isn't the core uses krealloc() to change the size of the link, with is bad, as it leaves the memory fragmented.
So, convert links into a list.
Also, currently, both source and sink entities need the link at the graph traversal logic inside media_entity. So there's a logic duplicating all links. That makes it to spend twice the memory needed. This is not a big deal for today's usage, where the number of links are not big.
Yet, if during the MC workshop discussions, it was said that IIO graphs could have up to 4,000 entities. So, we may want to remove the duplication on some future. The problem is that it would require a separate linked list to store the backlinks inside the entity, or to use a more complex algorithm to do graph backlink traversal, with is something that the current graph traversal inside the core can't cope with. So, let's postpone a such change if/when it is actually needed.
drivers/media/dvb-core/dvb_frontend.c +3 -6
@@ -623,7 +623,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)struct media_device *mdev = adapter->mdev;struct media_entity *entity, *source;struct media_link *link, *found_link =NULL ; -int i, ret, n_links =0 , active_links =0 ; +int ret, n_links =0 , active_links =0 ; fepriv->pipe_start_entity =NULL ;
@@ -633,8 +633,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) entity = fepriv->dvbdev->entity; fepriv->pipe_start_entity = entity; -for (i =0 ; i < entity->num_links; i++) { - link = &entity->links[i]; +list_for_each_entry (link, &entity->links, list) {if (link->sink->entity == entity) { found_link = link; n_links++;
@@ -660,13 +659,11 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) source = found_link->source->entity; fepriv->pipe_start_entity = source; -for (i =0 ; i < source->num_links; i++) { +list_for_each_entry (link, &source->links, list) {struct media_entity *sink;int flags =0 ; - link = &source->links[i]; sink = link->sink->entity; -if (sink == entity) flags =MEDIA_LNK_FL_ENABLED ;
drivers/media/media-device.c +15 -10
@@ -25,6 +25,7 @@#include <linux/ioctl.h> #include <linux/media.h> #include <linux/types.h> +#include <linux/slab.h> #include <media/media-device.h> #include <media/media-devnode.h>
@@ -150,22 +151,21 @@ static long __media_device_enum_links(struct media_device *mdev, }if (links->links) { -struct media_link_desc __user *ulink; -unsigned int l; +struct media_link *ent_link; +struct media_link_desc __user *ulink = links->links; -for (l =0 , ulink = links->links; l < entity->num_links; l++) { +list_for_each_entry (ent_link, &entity->links, list) {struct media_link_desc link;/* Ignore backlinks. */ -if (entity->links[l].source->entity != entity) +if (ent_link->source->entity != entity)continue ; -memset (&link,0 ,sizeof (link)); -media_device_kpad_to_upad (entity->links[l].source, +media_device_kpad_to_upad (ent_link->source, &link.source); -media_device_kpad_to_upad (entity->links[l].sink, +media_device_kpad_to_upad (ent_link->sink, &link.sink); - link.flags = entity->links[l].flags; + link.flags = ent_link->flags;if (copy_to_user (ulink, &link,sizeof (*ulink)))return -EFAULT ; ulink++;
@@ -437,6 +437,7 @@ int __must_check media_device_register_entity(struct media_device *mdev,/* Warn if we apparently re-register an entity */ WARN_ON (entity->graph_obj.mdev !=NULL ); entity->graph_obj.mdev = mdev; +INIT_LIST_HEAD (&entity->links);spin_lock (&mdev->lock);/* Initialize media_gobj embedded at the entity */
@@ -465,13 +466,17 @@ void media_device_unregister_entity(struct media_entity *entity) {int i;struct media_device *mdev = entity->graph_obj.mdev; +struct media_link *link, *tmp;if (mdev ==NULL )return ;spin_lock (&mdev->lock); -for (i =0 ; i < entity->num_links; i++) -media_gobj_remove (&entity->links[i].graph_obj); +list_for_each_entry_safe (link, tmp, &entity->links, list) { +media_gobj_remove (&link->graph_obj); +list_del (&link->list); +kfree (link); + }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 +64 -66
249 lines not on this page · raw message
drivers/media/usb/au0828/au0828-core.c +5 -7
@@ -261,13 +261,11 @@ static void au0828_create_media_graph(struct au0828_dev *dev)if (tuner)media_create_pad_link (tuner,0 , decoder,0 , -MEDIA_LNK_FL_ENABLED ); -if (dev->vdev.entity.links) -media_create_pad_link (decoder,1 , &dev->vdev.entity,0 , -MEDIA_LNK_FL_ENABLED ); -if (dev->vbi_dev.entity.links) -media_create_pad_link (decoder,2 , &dev->vbi_dev.entity,0 , -MEDIA_LNK_FL_ENABLED ); +MEDIA_LNK_FL_ENABLED ); +media_create_pad_link (decoder,1 , &dev->vdev.entity,0 , +MEDIA_LNK_FL_ENABLED ); +media_create_pad_link (decoder,2 , &dev->vbi_dev.entity,0 , +MEDIA_LNK_FL_ENABLED );#endif }
drivers/media/usb/au0828/au0828-video.c +3 -5
@@ -643,7 +643,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev)struct media_device *mdev = dev->media_dev;struct media_entity *source;struct media_link *link, *found_link =NULL ; -int i, ret, active_links =0 ; +int ret, active_links =0 ;if (!mdev || !dev->decoder)return 0 ;
@@ -655,8 +655,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev)* do DVB streaming while the DMA engine is being used for V4L2, * this should be enough for the actual needs. */ -for (i =0 ; i < dev->decoder->num_links; i++) { - link = &dev->decoder->links[i]; +list_for_each_entry (link, &dev->decoder->links, list) {if (link->sink->entity == dev->decoder) { found_link = link;if (link->flags &MEDIA_LNK_FL_ENABLED )
@@ -669,11 +668,10 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev)return 0 ; source = found_link->source->entity; -for (i =0 ; i < source->num_links; i++) { +list_for_each_entry (link, &source->links, list) {struct media_entity *sink;int flags =0 ; - link = &source->links[i]; sink = link->sink->entity;if (sink == dev->decoder)
drivers/media/usb/cx231xx/cx231xx-video.c +3 -5
@@ -106,7 +106,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)struct media_device *mdev = dev->media_dev;struct media_entity *entity, *decoder =NULL , *source;struct media_link *link, *found_link =NULL ; -int i, ret, active_links =0 ; +int ret, active_links =0 ;if (!mdev)return 0 ;
@@ -127,8 +127,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)if (!decoder)return 0 ; -for (i =0 ; i < decoder->num_links; i++) { - link = &decoder->links[i]; +list_for_each_entry (link, &decoder->links, list) {if (link->sink->entity == decoder) { found_link = link;if (link->flags &MEDIA_LNK_FL_ENABLED )
@@ -141,11 +140,10 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)return 0 ; source = found_link->source->entity; -for (i =0 ; i < source->num_links; i++) { +list_for_each_entry (link, &source->links, list) {struct media_entity *sink;int flags =0 ; - link = &source->links[i]; sink = link->sink->entity;if (sink == entity)
include/media/media-entity.h +5 -5
@@ -74,6 +74,7 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj; +struct list_head list;struct media_pad *source;/* Source pad */ struct media_pad *sink;/* Sink pad */ struct media_link *reverse;/* Link in the reverse direction */
@@ -116,10 +117,9 @@ struct media_entity {u16 num_links;/* Number of existing links, both * enabled and disabled */ u16 num_backlinks;/* Number of backlinks */ -u16 max_links;/* Maximum number of links */ -struct media_pad *pads;/* Pads array (num_pads elements) */ -struct media_link *links;/* Links array (max_links elements)*/ +struct media_pad *pads;/* Pads array (num_pads objects) */ +struct list_head links;/* Links list */ const struct media_entity_operations *ops;/* Entity operations */
@@ -213,7 +213,7 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)struct media_entity_graph {struct {struct media_entity *entity; -int link; +struct list_head link; } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH ]; DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
@@ -247,7 +247,7 @@ void media_gobj_init(struct media_device *mdev,void media_gobj_remove (struct media_gobj *gobj);int media_entity_init (struct media_entity *entity,u16 num_pads, -struct media_pad *pads); +struct media_pad *pads);void media_entity_cleanup (struct media_entity *entity); int media_create_pad_link(struct media_entity *source, u16 source_pad,
Signature · 1 line
2.4.3
Re: [PATCH v7 16/44] [media] media: convert links from array to list
Quoted 29 lines · Mauro Carvalho Chehab
The entire logic that represent graph links were developed on a time where there were no needs to dynamic remove links. So, although links are created/removed one by one via some functions, they're stored as an array inside the entity struct.
As the array may grow, there's a logic inside the code that checks if the amount of space is not enough to store the needed links. If it isn't the core uses
krealloc()to change the size of the link, with is bad, as it leaves the memory fragmented.So, convert links into a list.
Also, currently, both source and sink entities need the link at the graph traversal logic inside
media_entity. So there's a logic duplicating all links. That makes it to spend twice the memory needed. This is not a big deal for today's usage, where the number of links are not big.Yet, if during the MC workshop discussions, it was said that IIO graphs could have up to 4,000 entities. So, we may want to remove the duplication on some future. The problem is that it would require a separate linked list to store the backlinks inside the entity, or to use a more complex algorithm to do graph backlink traversal, with is something that the current graph traversal inside the core can't cope with. So, let's postpone a such change if/when it is actually needed.
Quoted 2 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>
I think it makes sense to add remove support in phase2 after the patches 1-15 in this
series that add the graph object and the API changes that go with it through some
use-cases before adding support for remove.
That way we have confidence in the patch set 1-15 and then we can build on top with
solid foundation.
thanks,
-- Shuah
Re: [PATCH v7 16/44] [media] media: convert links from array to list
Em Tue, 25 Aug 2015 16:48:56 -0600
Shuah Khan <[email protected]> escreveu:
Quoted 31 lines
Quoted 29 lines · Mauro Carvalho Chehab
The entire logic that represent graph links were developed on a time where there were no needs to dynamic remove links. So, although links are created/removed one by one via some functions, they're stored as an array inside the entity struct.
As the array may grow, there's a logic inside the code that checks if the amount of space is not enough to store the needed links. If it isn't the core uses
krealloc()to change the size of the link, with is bad, as it leaves the memory fragmented.So, convert links into a list.
Also, currently, both source and sink entities need the link at the graph traversal logic inside
media_entity. So there's a logic duplicating all links. That makes it to spend twice the memory needed. This is not a big deal for today's usage, where the number of links are not big.Yet, if during the MC workshop discussions, it was said that IIO graphs could have up to 4,000 entities. So, we may want to remove the duplication on some future. The problem is that it would require a separate linked list to store the backlinks inside the entity, or to use a more complex algorithm to do graph backlink traversal, with is something that the current graph traversal inside the core can't cope with. So, let's postpone a such change if/when it is actually needed.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>I think it makes sense to add remove support in phase2 after the patches 1-15 in this
series that add the graph object and the API changes that go with it through some
use-cases before adding support for remove.
Sorry, I'm totally lost with the above comment.
This patch series is a "pre-phase 1"[1]. It is the minimal amount of stuff for us to start playing with the new API and testing/debugging the graph creation.
We can only work on userspace cases after having the foundation provided by this patchset (plus the 3 additional patches I sent on Sunday), e. g. after implementing the MEDIA_IOC_G_TOPOLOGY ioctl.
[1] For a "phase 1", we also need the 3 additional patches I sent on Sunday, plus a patch that will create the indirect interface->entities links at the V4L2 side.
Quoted 3 lines
That way we have confidence in the patch set 1-15 and then we can build on top with
solid foundation.
Regards,
Mauro
PATCH v7 17/44 media: make add link more generic
In reply to Mauro Carvalho ChehabThe media_entity_add_link() function takes an entity as an argument just to get the list head.
Make it more generic by changing the function argument to list_head.
No functional changes.
drivers/media/media-entity.c +4 -4
@@ -578,7 +578,7 @@ EXPORT_SYMBOL_GPL(media_entity_put);* Links management */ -static struct media_link *media_entity_add_link (struct media_entity *entity) +static struct media_link *media_add_link (struct list_head *head) {struct media_link *link;
@@ -586,7 +586,7 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)if (link ==NULL )return NULL ; -list_add_tail (&link->list, &entity->links); +list_add_tail (&link->list, head);return link; }
@@ -605,7 +605,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,BUG_ON (source_pad >= source->num_pads);BUG_ON (sink_pad >= sink->num_pads); - link =media_entity_add_link (source); + link =media_add_link (&source->links);if (link ==NULL )return -ENOMEM ;
@@ -620,7 +620,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ - backlink =media_entity_add_link (sink); + backlink =media_add_link (&sink->links);if (backlink ==NULL ) {__media_entity_remove_link (source, link);return -ENOMEM ;
Signature · 1 line
2.4.3
PATCH v7 18/44 media: make media_link more generic to handle interace links
In reply to Mauro Carvalho ChehabBy adding an union at media_link, we get for free a way to represent interface->entity links.
No need to change anything at the code, just at the internal header file.
include/media/media-entity.h +11 -5
@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union { +struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1; +struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */
@@ -105,7 +111,7 @@ struct media_entity_operations { };struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */
@@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */
Signature · 1 line
2.4.3
Re: [PATCH v7 18/44] [media] media: make media_link more generic to handle interace links
Quoted 37 lines · Mauro Carvalho Chehab
By adding an union at
media_link, we get for free a way to representinterface->entitylinks.No need to change anything at the code, just at the internal header file.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +9
-3@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union { +struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1; +struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */
include/media/media-entity.h struct media_entity_operations { · line 114
Quoted 5 lines
include/media/media-entity.h +1
-1@@ -105,7 +111,7 @@ struct media_entity_operations { };struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */
Does adding these "/* should be the first object */" comments in media_entity and media_pad belong to this patch? It doesn't seem to be related to the union change.
I would also suggest that "/* must be first field in struct */" is a better phrase.
Regards,
Hans
Quoted 13 lines
include/media/media-entity.h +1
-1struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ @@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */
Re: [PATCH v7 18/44] [media] media: make media_link more generic to handle interace links
Em Tue, 25 Aug 2015 09:28:55 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 40 lines · Mauro Carvalho Chehab
Quoted 39 lines
By adding an union at
media_link, we get for free a way to representinterface->entitylinks.No need to change anything at the code, just at the internal header file.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +9
-3@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union { +struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1; +struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */ @@ -105,7 +111,7 @@ struct media_entity_operations { };
Quoted 7 lines
include/media/media-entity.h struct media_entity_operations { · line 114
Quoted 3 lines
include/media/media-entity.h +1
-1struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ Does adding these "/* should be the first object */" comments in
media_entityandmedia_padbelong to this patch? It doesn't seem to be related to the union change.
It is related. See:
union {
struct media_gobj *port0;
struct media_pad *source;
};If we keep the graph_obj as the first part of media_pad, the pad object can be accessed as either:
link->port0 or link->source->graph_obj.
In practice, it means that, if one wants to know the type of the object, it could do:
type = media_type(link->port0)
Technically, we don't need yet to put the comment at the media_entity, as the patch that will create interface->entity links is patch 20. But I opted to do the comments change altogether.
Quoted 3 lines
I would also suggest that "/* must be first field in struct */" is a better phrase.
OK.
Quoted 19 lines
Regards,
Hans
Quoted 13 lines
include/media/media-entity.h +1
-1struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ @@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */
Re: [PATCH v7 18/44] [media] media: make media_link more generic to handle interace links
In reply to Mauro Carvalho ChehabQuoted 14 lines · Mauro Carvalho Chehab
By adding an union at
media_link, we get for free a way to representinterface->entitylinks.No need to change anything at the code, just at the internal header file.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +0
-0@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {
include/media/media-entity.h struct media_pipeline { · line 83
Quoted 10 lines
include/media/media-entity.h +6
-2struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union { +struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1;
Why add port0 and port1 here instead of intf and entity (now added in patch 20)? port0/port1 isn't used, so I'd postpone adding that until it is needed.
Part of the reason is also that I am not convinced about the 'port' name, so let's not add this yet.
Regards,
Hans
Quoted 31 lines
include/media/media-entity.h +5
-3+struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */ @@ -105,7 +111,7 @@ struct media_entity_operations { };struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ @@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */
Re: [PATCH v7 18/44] [media] media: make media_link more generic to handle interace links
Em Tue, 25 Aug 2015 09:38:57 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 20 lines · Mauro Carvalho Chehab
Quoted 19 lines
By adding an union at
media_link, we get for free a way to representinterface->entitylinks.No need to change anything at the code, just at the internal header file.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +1
-2@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union {
Quoted 8 lines
include/media/media-entity.h struct media_pipeline { · line 83
Quoted 5 lines
include/media/media-entity.h +5
-0+struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1;Why add port0 and port1 here instead of intf and entity (now added in patch 20)? port0/port1 isn't used, so I'd postpone adding that until it is needed.
Because we need to use it to be able to identify the object type. This is used (actually, it should be used - see my comments for 19/44) on the next patch.
Quoted 2 lines
Part of the reason is also that I am not convinced about the 'port' name, so let's not add this yet.
I'm not bound to "port" name. If you have a better suggestion, this could easily be fixed.
However, we can't use here source/sink, as this means something directional, but the interface<->entity link is bidirectional.
I chose "port" because it is the ITU-T name for the graph element that represents the connection points at the entities.
Quoted 37 lines
Regards,
Hans
Quoted 31 lines
include/media/media-entity.h +5
-3+struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */ @@ -105,7 +111,7 @@ struct media_entity_operations { };struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ @@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */
Re: [PATCH v7 18/44] [media] media: make media_link more generic to handle interace links
Quoted 32 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:38:57 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 20 lines · Mauro Carvalho Chehab
Quoted 19 lines
By adding an union at
media_link, we get for free a way to representinterface->entitylinks.No need to change anything at the code, just at the internal header file.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +1
-2@@ -75,14 +75,20 @@ struct media_pipeline {struct media_link {struct media_gobj graph_obj;struct list_head list; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +union {Quoted 8 lines
include/media/media-entity.h struct media_pipeline { · line 83
Quoted 5 lines
include/media/media-entity.h +5
-0+struct media_gobj *port0; +struct media_pad *source; + }; +union { +struct media_gobj *port1;Why add port0 and port1 here instead of intf and entity (now added in patch 20)? port0/port1 isn't used, so I'd postpone adding that until it is needed.
Quoted 3 lines
Because we need to use it to be able to identify the object type. This is used (actually, it should be used - see my comments for 19/44) on the next patch.
Ah, right. It makes much more sense when the debug function uses it. The fact that it didn't confused me.
Quoted 4 lines
Quoted 3 lines
Part of the reason is also that I am not convinced about the 'port' name, so let's not add this yet.
Quoted 8 lines
I'm not bound to "port" name. If you have a better suggestion, this could easily be fixed.
However, we can't use here source/sink, as this means something directional, but the interface<->entity link is bidirectional.
I chose "port" because it is the ITU-T name for the graph element that represents the connection points at the entities.
Since it is a media_gobj pointer, I would think 'gobj0/1' would be more sensible since that doesn't introduce a new name ('port').
Regards,
Hans
Quoted 43 lines
Quoted 30 lines
Regards,
Hans
Quoted 24 lines
include/media/media-entity.h +4
-2+struct media_pad *sink; + };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };struct media_pad { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ 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_*) */ @@ -105,7 +111,7 @@ struct media_entity_operations { };struct media_entity { -struct media_gobj graph_obj; +struct media_gobj graph_obj;/* should be the first object */ struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ @@ -119,7 +125,7 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ Quoted 8 lines
include/media/media-entity.h struct media_entity { · line 131
Quoted 7 lines
include/media/media-entity.h +1
-1struct media_pad *pads;/* Pads array (num_pads objects) */ -struct list_head links;/* Links list */ +struct list_head links;/* Pad-to-pad links list */ const struct media_entity_operations *ops;/* Entity operations */ --
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
PATCH v7 19/44 media: make link debug printk more generic
In reply to Mauro Carvalho ChehabRemove entity name from the link as this exists only if the object type is PAD on both link ends.
drivers/media/media-entity.c +1 -3
@@ -106,14 +106,12 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)struct media_link *link =gobj_to_link (gobj);dev_dbg (gobj->mdev->dev, -"%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n" , +"%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n" , event_name, gobj->id,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 ;
Signature · 1 line
2.4.3
Re: [PATCH v7 19/44] [media] media: make link debug printk more generic
Quoted 4 lines · Mauro Carvalho Chehab
Remove entity name from the link as this exists only if the object type is PAD on both link ends.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
I am wondering whether it should detect if this is a pad-to-pad link or an interface-to-entity link and log this accordingly.
But I think that is better done as a follow-up patch if we think this is useful. So for this patch:
Quoted 22 lines
drivers/media/media-entity.c +1
-3@@ -106,14 +106,12 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)struct media_link *link =gobj_to_link (gobj);dev_dbg (gobj->mdev->dev, -"%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n" , +"%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n" , event_name, gobj->id,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 ;
Re: [PATCH v7 19/44] [media] media: make link debug printk more generic
Em Tue, 25 Aug 2015 09:33:15 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 11 lines · Mauro Carvalho Chehab
Quoted 4 lines
Remove entity name from the link as this exists only if the object type is PAD on both link ends.
Signed-off-by Mauro Carvalho Chehab <[email protected]>I am wondering whether it should detect if this is a pad-to-pad link or an interface-to-entity link and log this accordingly.
But I think that is better done as a follow-up patch if we think this is useful.
I actually opted to keep the function more generic. We may latter add a per-type specific log here, if needed, but we can always grep at the logs to get the entity or interface name.
Quoted 27 lines
So for this patch:
Acked-by Hans Verkuil <[email protected]>Quoted 22 lines
drivers/media/media-entity.c +1
-3@@ -106,14 +106,12 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)struct media_link *link =gobj_to_link (gobj);dev_dbg (gobj->mdev->dev, -"%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n" , +"%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n" , event_name, gobj->id,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 ;
Re: [PATCH v7 19/44] [media] media: make link debug printk more generic
In reply to Hans VerkuilEm Tue, 25 Aug 2015 09:33:15 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 22 lines · Mauro Carvalho Chehab
Quoted 4 lines
Remove entity name from the link as this exists only if the object type is PAD on both link ends.
Signed-off-by Mauro Carvalho Chehab <[email protected]>I am wondering whether it should detect if this is a pad-to-pad link or an interface-to-entity link and log this accordingly.
But I think that is better done as a follow-up patch if we think this is useful. So for this patch:
Acked-by Hans Verkuil <[email protected]>Quoted 8 lines
drivers/media/media-entity.c +0
-0@@ -106,14 +106,12 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)struct media_link *link =gobj_to_link (gobj);
Quoted 7 lines
drivers/media/media-entity.c static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) · line 112
Quoted 7 lines
drivers/media/media-entity.c +1
-2dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n", + "%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n", event_name, gobj->id, media_localid(gobj), - link->source->entity->name, gobj_type(media_type(&link->source->graph_obj)),
Actually, here it should be, instead:
&link->port0;
Quoted 4 lines
drivers/media/media-entity.c static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) · line 115
Quoted 4 lines
drivers/media/media-entity.c +0
-1media_localid (&link->source->graph_obj), - link->sink->entity->name, gobj_type(media_type(&link->sink->graph_obj)),
And here it should be, instead:
&link->port1;
Quoted 4 lines
Quoted 3 lines
drivers/media/media-entity.c +0
-0media_localid(&link->sink->graph_obj));break ;
PATCH v7 20/44 media: add support to link interfaces and entities
In reply to Mauro Carvalho ChehabNow that we have a new graph object called "interfaces", we need to be able to link them to the entities.
Add a linked list to the interfaces to allow them to be linked to the entities.
drivers/media/media-entity.c +37 -0
@@ -867,6 +867,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, intf->type = type; intf->flags = flags; +INIT_LIST_HEAD (&intf->links); devnode->major = major; devnode->minor = minor;
@@ -885,3 +886,39 @@ void media_devnode_remove(struct media_intf_devnode *devnode) }EXPORT_SYMBOL_GPL (media_devnode_remove); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags) +{ +struct media_link *link; + + link =media_add_link (&intf->links); +if (link ==NULL ) +return NULL ; + + link->intf = intf; + link->entity = entity; + link->flags = flags; + +/* Initialize graph object embedded at the new link */ +media_gobj_init (intf->graph_obj.mdev,MEDIA_GRAPH_LINK , + &link->graph_obj); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link); + + +static void __media_remove_intf_link (struct media_link *link) +{ +list_del (&link->list); +kfree (link); +} + +void media_remove_intf_link (struct media_link *link) +{ +mutex_lock (&link->graph_obj.mdev->graph_mutex); +__media_remove_intf_link (link); +mutex_unlock (&link->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL (media_remove_intf_link);
include/media/media-entity.h +9 -0
@@ -78,10 +78,12 @@ struct media_link {union {struct media_gobj *port0;struct media_pad *source; +struct media_interface *intf; };union {struct media_gobj *port1;struct media_pad *sink; +struct media_entity *entity; };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */
@@ -154,6 +156,7 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. * MEDIA_INTF_T_*
@@ -161,6 +164,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head links;u32 type;u32 flags; };
@@ -283,6 +287,11 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 major, u32 minor, gfp_t gfp_flags);void media_devnode_remove (struct media_intf_devnode *devnode); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags); +void media_remove_intf_link (struct media_link *link); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Signature · 1 line
2.4.3
Re: [PATCH v7 20/44] [media] media: add support to link interfaces and entities
Quoted 13 lines · Mauro Carvalho Chehab
Now that we have a new graph object called "interfaces", we need to be able to link them to the entities.
Add a linked list to the interfaces to allow them to be linked to the entities.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +0
-0
drivers/media/media-entity.c struct media_intf_devnode *media_devnode_create(struct media_device *mdev, · line 870
Quoted 4 lines
drivers/media/media-entity.c +1
-0@@ -867,6 +867,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, intf->type = type; intf->flags = flags; +INIT_LIST_HEAD (&intf->links);
See my comment in patch 14: this should be part of a media_interface_init helper function.
Quoted 61 lines
drivers/media/media-entity.c +36
-0devnode->major = major; devnode->minor = minor;@@ -885,3 +886,39 @@ void media_devnode_remove(struct media_intf_devnode *devnode) }EXPORT_SYMBOL_GPL (media_devnode_remove); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags) +{ +struct media_link *link; + + link =media_add_link (&intf->links); +if (link ==NULL ) +return NULL ; + + link->intf = intf; + link->entity = entity; + link->flags = flags; + +/* Initialize graph object embedded at the new link */ +media_gobj_init (intf->graph_obj.mdev,MEDIA_GRAPH_LINK , + &link->graph_obj); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link); + + +static void __media_remove_intf_link (struct media_link *link) +{ +list_del (&link->list); +kfree (link); +} + +void media_remove_intf_link (struct media_link *link) +{ +mutex_lock (&link->graph_obj.mdev->graph_mutex); +__media_remove_intf_link (link); +mutex_unlock (&link->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL (media_remove_intf_link);include/media/media-entity.h +2
-0@@ -78,10 +78,12 @@ struct media_link {union {struct media_gobj *port0;struct media_pad *source; +struct media_interface *intf; };union {struct media_gobj *port1;struct media_pad *sink; +struct media_entity *entity; };struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */
include/media/media-entity.h struct media_entity { · line 159
Quoted 4 lines
include/media/media-entity.h +1
-0@@ -154,6 +156,7 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @links: List of links pointing to graph entities
Nitpick: s/graph/media/
Quoted 14 lines
include/media/media-entity.h +1
-0* @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. * MEDIA_INTF_T_* @@ -161,6 +164,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head links;u32 type;u32 flags; };@@ -283,6 +287,11 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 major, u32 minor,
include/media/media-entity.h struct media_intf_devnode *media_devnode_create(struct media_device *mdev, · line 297
Quoted 10 lines
include/media/media-entity.h +5
-0gfp_t gfp_flags);void media_devnode_remove (struct media_intf_devnode *devnode); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags); +void media_remove_intf_link (struct media_link *link); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Regards,
Hans
Re: [PATCH v7 20/44] [media] media: add support to link interfaces and entities
Em Tue, 25 Aug 2015 09:44:09 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 15 lines · Mauro Carvalho Chehab
Quoted 14 lines
Now that we have a new graph object called "interfaces", we need to be able to link them to the entities.
Add a linked list to the interfaces to allow them to be linked to the entities.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +0
-0@@ -867,6 +867,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
Quoted 6 lines
drivers/media/media-entity.c struct media_intf_devnode *media_devnode_create(struct media_device *mdev, · line 870
Quoted 3 lines
drivers/media/media-entity.c +1
-0intf->type = type; intf->flags = flags; +INIT_LIST_HEAD (&intf->links);See my comment in patch 14: this should be part of a
media_interface_inithelper function.
Ok. I'll add such patch at the end of the series.
Quoted 59 lines
Quoted 59 lines
drivers/media/media-entity.c +36
-0devnode->major = major; devnode->minor = minor;@@ -885,3 +886,39 @@ void media_devnode_remove(struct media_intf_devnode *devnode) }EXPORT_SYMBOL_GPL (media_devnode_remove); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags) +{ +struct media_link *link; + + link =media_add_link (&intf->links); +if (link ==NULL ) +return NULL ; + + link->intf = intf; + link->entity = entity; + link->flags = flags; + +/* Initialize graph object embedded at the new link */ +media_gobj_init (intf->graph_obj.mdev,MEDIA_GRAPH_LINK , + &link->graph_obj); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link); + + +static void __media_remove_intf_link (struct media_link *link) +{ +list_del (&link->list); +kfree (link); +} + +void media_remove_intf_link (struct media_link *link) +{ +mutex_lock (&link->graph_obj.mdev->graph_mutex); +__media_remove_intf_link (link); +mutex_unlock (&link->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL (media_remove_intf_link);include/media/media-entity.h +2
-0@@ -78,10 +78,12 @@ struct media_link {union {struct media_gobj *port0;struct media_pad *source; +struct media_interface *intf; };union {struct media_gobj *port1;struct media_pad *sink; +struct media_entity *entity; };struct media_link *reverse;/* Link in the reverse direction */
Quoted 8 lines
include/media/media-entity.h struct media_entity { · line 159
Quoted 6 lines
include/media/media-entity.h +1
-0unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ @@ -154,6 +156,7 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @links: List of links pointing to graph entities Nitpick: s/graph/media/
OK.
Quoted 29 lines
Quoted 15 lines
include/media/media-entity.h +1
-0* @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. * MEDIA_INTF_T_* @@ -161,6 +164,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head links;u32 type;u32 flags; };@@ -283,6 +287,11 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 major, u32 minor,include/media/media-entity.h struct media_intf_devnode *media_devnode_create(struct media_device *mdev, · line 297
Quoted 10 lines
include/media/media-entity.h +5
-0gfp_t gfp_flags);void media_devnode_remove (struct media_intf_devnode *devnode); +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_interface *intf, +u32 flags); +void media_remove_intf_link (struct media_link *link); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)Regards,
Hans
PATCH v7 21/44 dvbdev: add support for interfaces
In reply to Mauro Carvalho ChehabNow that the infrastruct for that is set, add support for interfaces.
Please notice that we're missing two links:
DVB FE intf -> tuner DVB demux intf -> dvr
Those should be added latter, after having the entire graph set. With the current infrastructure, those should be added at dvb_create_media_graph(), but it would also require some extra core changes, to allow the function to enumerate the interfaces.
drivers/media/dvb-core/dvbdev.c +77 -24
@@ -180,14 +180,35 @@ skip:return -ENFILE ; } -static void dvb_register_media_device (struct dvb_device *dvbdev, -int type,int minor) +static void dvb_create_media_entity (struct dvb_device *dvbdev, +int type,int minor) {#if defined(CONFIG_MEDIA_CONTROLLER_DVB )int ret =0 , npads; -if (!dvbdev->adapter->mdev) +switch (type) { +case DVB_DEVICE_FRONTEND : + npads =2 ; +break ; +case DVB_DEVICE_DEMUX : + npads =2 ; +break ; +case DVB_DEVICE_CA : + npads =2 ; +break ; +case DVB_DEVICE_NET : +/* +* We should be creating entities for the MPE/ULE +* decapsulation hardware (or software implementation). +* +* However, as the number of for the MPE/ULE may not be fixed, +* and we don't have yet dynamic support for PADs at the +* Media Controller. +*/ return ; +default : +return ; + } dvbdev->entity =kzalloc (sizeof (*dvbdev->entity),GFP_KERNEL );if (!dvbdev->entity)
@@ -197,19 +218,6 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->entity->info.dev.minor = minor; dvbdev->entity->name = dvbdev->name; -switch (type) { -case DVB_DEVICE_CA : -case DVB_DEVICE_DEMUX : -case DVB_DEVICE_FRONTEND : - npads =2 ; -break ; -case DVB_DEVICE_NET : - npads =0 ; -break ; -default : - npads =1 ; - } -if (npads) { dvbdev->pads =kcalloc (npads,sizeof (*dvbdev->pads),GFP_KERNEL );
@@ -230,18 +238,11 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_DVR : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DVR ; - dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; -break ;case DVB_DEVICE_CA : dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_NET : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_NET ; -break ;default :kfree (dvbdev->entity); dvbdev->entity =NULL ;
@@ -263,11 +264,63 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,return ; } -printk (KERN_DEBUG "%s: media device '%s' registered.\n" , +printk (KERN_DEBUG "%s: media entity '%s' registered.\n" , __func__, dvbdev->entity->name);#endif } +static void dvb_register_media_device (struct dvb_device *dvbdev, +int type,int minor) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB ) +u32 intf_type; + +if (!dvbdev->adapter->mdev) +return ; + +dvb_create_media_entity (dvbdev, type, minor); + +switch (type) { +case DVB_DEVICE_FRONTEND : + intf_type =MEDIA_INTF_T_DVB_FE ; +break ; +case DVB_DEVICE_DEMUX : + intf_type =MEDIA_INTF_T_DVB_DEMUX ; +break ; +case DVB_DEVICE_DVR : + intf_type =MEDIA_INTF_T_DVB_DVR ; +break ; +case DVB_DEVICE_CA : + intf_type =MEDIA_INTF_T_DVB_CA ; +break ; +case DVB_DEVICE_NET : + intf_type =MEDIA_INTF_T_DVB_NET ; +break ; +default : +return ; + } + + dvbdev->intf_devnode =media_devnode_create (dvbdev->adapter->mdev, + intf_type,0 , +DVB_MAJOR , minor, +GFP_KERNEL ); + +/* +* Create the "obvious" link, e. g. the ones that represent +* a direct association between an interface and an entity. +* Other links should be created elsewhere, like: +* DVB FE intf -> tuner +* DVB demux intf -> dvr +*/ + +if (!dvbdev->entity || !dvbdev->intf_devnode) +return ; + +media_create_intf_link (dvbdev->entity, &dvbdev->intf_devnode->intf,0 ); + +#endif +} +int dvb_register_device (struct dvb_adapter *adap,struct dvb_device **pdvbdev,const struct dvb_device *template,void *priv,int type) {
drivers/media/dvb-core/dvbdev.h +1 -0
@@ -103,6 +103,7 @@ struct dvb_device {/* Allocated and filled inside dvbdev.c */ struct media_entity *entity; +struct media_intf_devnode *intf_devnode;struct media_pad *pads;#endif
Signature · 1 line
2.4.3
Re: [PATCH v7 21/44] [media] dvbdev: add support for interfaces
Quoted 8 lines · Mauro Carvalho Chehab
Now that the infrastruct for that is set, add support for interfaces.
Please notice that we're missing two links:
DVB FE intf -> tuner DVB demux intf -> dvrThose should be added latter, after having the entire graph
s/latter/later/
Quoted 32 lines
set. With the current infrastructure, those should be added at
dvb_create_media_graph(), but it would also require some extra core changes, to allow the function to enumerate the interfaces.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +10
-3@@ -180,14 +180,35 @@ skip:return -ENFILE ; } -static void dvb_register_media_device (struct dvb_device *dvbdev, -int type,int minor) +static void dvb_create_media_entity (struct dvb_device *dvbdev, +int type,int minor) {#if defined(CONFIG_MEDIA_CONTROLLER_DVB )int ret =0 , npads; -if (!dvbdev->adapter->mdev) +switch (type) { +case DVB_DEVICE_FRONTEND : + npads =2 ; +break ; +case DVB_DEVICE_DEMUX : + npads =2 ; +break ; +case DVB_DEVICE_CA :
drivers/media/dvb-core/dvbdev.c skip: · line 206
Quoted 10 lines
drivers/media/dvb-core/dvbdev.c +10
-0+ npads =2 ; +break ; +case DVB_DEVICE_NET : +/* +* We should be creating entities for the MPE/ULE +* decapsulation hardware (or software implementation). +* +* However, as the number of for the MPE/ULE may not be fixed, +* and we don't have yet dynamic support for PADs at the +* Media Controller.
However what? You probably want to add something like:
However, ... at the Media Controller, we don't make this entity yet.
Regards,
Hans
Quoted 125 lines
drivers/media/dvb-core/dvbdev.c +57
-21+*/ return ; +default : +return ; + } dvbdev->entity =kzalloc (sizeof (*dvbdev->entity),GFP_KERNEL );if (!dvbdev->entity)@@ -197,19 +218,6 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->entity->info.dev.minor = minor; dvbdev->entity->name = dvbdev->name; -switch (type) { -case DVB_DEVICE_CA : -case DVB_DEVICE_DEMUX : -case DVB_DEVICE_FRONTEND : - npads =2 ; -break ; -case DVB_DEVICE_NET : - npads =0 ; -break ; -default : - npads =1 ; - } -if (npads) { dvbdev->pads =kcalloc (npads,sizeof (*dvbdev->pads),GFP_KERNEL );@@ -230,18 +238,11 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_DVR : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DVR ; - dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; -break ;case DVB_DEVICE_CA : dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_NET : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_NET ; -break ;default :kfree (dvbdev->entity); dvbdev->entity =NULL ;@@ -263,11 +264,63 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,return ; } -printk (KERN_DEBUG "%s: media device '%s' registered.\n" , +printk (KERN_DEBUG "%s: media entity '%s' registered.\n" , __func__, dvbdev->entity->name);#endif } +static void dvb_register_media_device (struct dvb_device *dvbdev, +int type,int minor) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB ) +u32 intf_type; + +if (!dvbdev->adapter->mdev) +return ; + +dvb_create_media_entity (dvbdev, type, minor); + +switch (type) { +case DVB_DEVICE_FRONTEND : + intf_type =MEDIA_INTF_T_DVB_FE ; +break ; +case DVB_DEVICE_DEMUX : + intf_type =MEDIA_INTF_T_DVB_DEMUX ; +break ; +case DVB_DEVICE_DVR : + intf_type =MEDIA_INTF_T_DVB_DVR ; +break ; +case DVB_DEVICE_CA : + intf_type =MEDIA_INTF_T_DVB_CA ; +break ; +case DVB_DEVICE_NET : + intf_type =MEDIA_INTF_T_DVB_NET ; +break ; +default : +return ; + } + + dvbdev->intf_devnode =media_devnode_create (dvbdev->adapter->mdev, + intf_type,0 , +DVB_MAJOR , minor, +GFP_KERNEL ); + +/* +* Create the "obvious" link, e. g. the ones that represent +* a direct association between an interface and an entity. +* Other links should be created elsewhere, like: +* DVB FE intf -> tuner +* DVB demux intf -> dvr +*/ + +if (!dvbdev->entity || !dvbdev->intf_devnode) +return ; + +media_create_intf_link (dvbdev->entity, &dvbdev->intf_devnode->intf,0 ); + +#endif +} +int dvb_register_device (struct dvb_adapter *adap,struct dvb_device **pdvbdev,const struct dvb_device *template,void *priv,int type) {drivers/media/dvb-core/dvbdev.h +1
-0@@ -103,6 +103,7 @@ struct dvb_device {/* Allocated and filled inside dvbdev.c */ struct media_entity *entity; +struct media_intf_devnode *intf_devnode;struct media_pad *pads;#endif
Re: [PATCH v7 21/44] [media] dvbdev: add support for interfaces
Em Tue, 25 Aug 2015 09:50:25 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 57 lines · Mauro Carvalho Chehab
Quoted 8 lines
Now that the infrastruct for that is set, add support for interfaces.
Please notice that we're missing two links:
DVB FE intf -> tuner DVB demux intf -> dvrThose should be added latter, after having the entire graph
s/latter/later/
Quoted 32 lines
set. With the current infrastructure, those should be added at
dvb_create_media_graph(), but it would also require some extra core changes, to allow the function to enumerate the interfaces.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +10
-3@@ -180,14 +180,35 @@ skip:return -ENFILE ; } -static void dvb_register_media_device (struct dvb_device *dvbdev, -int type,int minor) +static void dvb_create_media_entity (struct dvb_device *dvbdev, +int type,int minor) {#if defined(CONFIG_MEDIA_CONTROLLER_DVB )int ret =0 , npads; -if (!dvbdev->adapter->mdev) +switch (type) { +case DVB_DEVICE_FRONTEND : + npads =2 ; +break ; +case DVB_DEVICE_DEMUX : + npads =2 ; +break ; +case DVB_DEVICE_CA :drivers/media/dvb-core/dvbdev.c skip: · line 206
Quoted 10 lines
drivers/media/dvb-core/dvbdev.c +10
-0+ npads =2 ; +break ; +case DVB_DEVICE_NET : +/* +* We should be creating entities for the MPE/ULE +* decapsulation hardware (or software implementation). +* +* However, as the number of for the MPE/ULE may not be fixed, +* and we don't have yet dynamic support for PADs at the +* Media Controller. However what? You probably want to add something like:
Quoted 1 line
However, ... at the Media Controller, we don't make this entity yet.
What about this:
* However, the number of for the MPE/ULE decaps may not be
* fixed. As we don't have yet dynamic support for PADs at
* the Media Controller, let's not create those yet.
Quoted 131 lines
Regards,
Hans
Quoted 125 lines
drivers/media/dvb-core/dvbdev.c +57
-21+*/ return ; +default : +return ; + } dvbdev->entity =kzalloc (sizeof (*dvbdev->entity),GFP_KERNEL );if (!dvbdev->entity)@@ -197,19 +218,6 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->entity->info.dev.minor = minor; dvbdev->entity->name = dvbdev->name; -switch (type) { -case DVB_DEVICE_CA : -case DVB_DEVICE_DEMUX : -case DVB_DEVICE_FRONTEND : - npads =2 ; -break ; -case DVB_DEVICE_NET : - npads =0 ; -break ; -default : - npads =1 ; - } -if (npads) { dvbdev->pads =kcalloc (npads,sizeof (*dvbdev->pads),GFP_KERNEL );@@ -230,18 +238,11 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_DVR : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_DVR ; - dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; -break ;case DVB_DEVICE_CA : dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_CA ; dvbdev->pads[0 ].flags =MEDIA_PAD_FL_SINK ; dvbdev->pads[1 ].flags =MEDIA_PAD_FL_SOURCE ;break ; -case DVB_DEVICE_NET : - dvbdev->entity->type =MEDIA_ENT_T_DEVNODE_DVB_NET ; -break ;default :kfree (dvbdev->entity); dvbdev->entity =NULL ;@@ -263,11 +264,63 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,return ; } -printk (KERN_DEBUG "%s: media device '%s' registered.\n" , +printk (KERN_DEBUG "%s: media entity '%s' registered.\n" , __func__, dvbdev->entity->name);#endif } +static void dvb_register_media_device (struct dvb_device *dvbdev, +int type,int minor) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB ) +u32 intf_type; + +if (!dvbdev->adapter->mdev) +return ; + +dvb_create_media_entity (dvbdev, type, minor); + +switch (type) { +case DVB_DEVICE_FRONTEND : + intf_type =MEDIA_INTF_T_DVB_FE ; +break ; +case DVB_DEVICE_DEMUX : + intf_type =MEDIA_INTF_T_DVB_DEMUX ; +break ; +case DVB_DEVICE_DVR : + intf_type =MEDIA_INTF_T_DVB_DVR ; +break ; +case DVB_DEVICE_CA : + intf_type =MEDIA_INTF_T_DVB_CA ; +break ; +case DVB_DEVICE_NET : + intf_type =MEDIA_INTF_T_DVB_NET ; +break ; +default : +return ; + } + + dvbdev->intf_devnode =media_devnode_create (dvbdev->adapter->mdev, + intf_type,0 , +DVB_MAJOR , minor, +GFP_KERNEL ); + +/* +* Create the "obvious" link, e. g. the ones that represent +* a direct association between an interface and an entity. +* Other links should be created elsewhere, like: +* DVB FE intf -> tuner +* DVB demux intf -> dvr +*/ + +if (!dvbdev->entity || !dvbdev->intf_devnode) +return ; + +media_create_intf_link (dvbdev->entity, &dvbdev->intf_devnode->intf,0 ); + +#endif +} +int dvb_register_device (struct dvb_adapter *adap,struct dvb_device **pdvbdev,const struct dvb_device *template,void *priv,int type) {drivers/media/dvb-core/dvbdev.h +1
-0@@ -103,6 +103,7 @@ struct dvb_device {/* Allocated and filled inside dvbdev.c */ struct media_entity *entity; +struct media_intf_devnode *intf_devnode;struct media_pad *pads;#endif
Re: [PATCH v7 21/44] [media] dvbdev: add support for interfaces
Quoted 60 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:50:25 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 57 lines · Mauro Carvalho Chehab
Quoted 8 lines
Now that the infrastruct for that is set, add support for interfaces.
Please notice that we're missing two links:
DVB FE intf -> tuner DVB demux intf -> dvrThose should be added latter, after having the entire graph
s/latter/later/
Quoted 32 lines
set. With the current infrastructure, those should be added at
dvb_create_media_graph(), but it would also require some extra core changes, to allow the function to enumerate the interfaces.Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +10
-3@@ -180,14 +180,35 @@ skip:return -ENFILE ; } -static void dvb_register_media_device (struct dvb_device *dvbdev, -int type,int minor) +static void dvb_create_media_entity (struct dvb_device *dvbdev, +int type,int minor) {#if defined(CONFIG_MEDIA_CONTROLLER_DVB )int ret =0 , npads; -if (!dvbdev->adapter->mdev) +switch (type) { +case DVB_DEVICE_FRONTEND : + npads =2 ; +break ; +case DVB_DEVICE_DEMUX : + npads =2 ; +break ; +case DVB_DEVICE_CA :drivers/media/dvb-core/dvbdev.c skip: · line 206
Quoted 10 lines
drivers/media/dvb-core/dvbdev.c +10
-0+ npads =2 ; +break ; +case DVB_DEVICE_NET : +/* +* We should be creating entities for the MPE/ULE +* decapsulation hardware (or software implementation). +* +* However, as the number of for the MPE/ULE may not be fixed, +* and we don't have yet dynamic support for PADs at the +* Media Controller. However what? You probably want to add something like:
Quoted 6 lines
Quoted 1 line
However, ... at the Media Controller, we don't make this entity yet.
What about this:
* However, the number of for the MPE/ULE decaps may not be
* fixed. As we don't have yet dynamic support for PADs at
* the Media Controller, let's not create those yet.
I'd be explicit:
s/those/decap entities/
Other than that this is OK.
Regards,
Hans
PATCH v7 22/44 media: add a linked list to track interfaces by mdev
In reply to Mauro Carvalho ChehabWe need to be able to navigate at the interfaces that belong to a given media device, in to indirect interface links.
So, add a linked list to track them.
drivers/media/media-device.c +1 -0
@@ -381,6 +381,7 @@ int __must_check __media_device_register(struct media_device *mdev,return -EINVAL ;INIT_LIST_HEAD (&mdev->entities); +INIT_LIST_HEAD (&mdev->interfaces);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);
drivers/media/media-entity.c +3 -0
@@ -875,6 +875,8 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); +list_add_tail (&intf->list, &mdev->interfaces); +return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);
@@ -882,6 +884,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); +list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);
include/media/media-device.h +2 -0
@@ -46,6 +46,7 @@ struct device;* @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities +* @interfaces: List of registered interfaces * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback
@@ -77,6 +78,7 @@ struct media_device {u32 intf_devnode_id;struct list_head entities; +struct list_head interfaces;/* Protects the entities list */ spinlock_t lock;
include/media/media-entity.h +3 -0
@@ -156,6 +156,8 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @list: Linked list used to find other interfaces that belong +* to the same media controller * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g.
@@ -164,6 +166,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head list;struct list_head links;u32 type;u32 flags;
Signature · 1 line
2.4.3
Re: [PATCH v7 22/44] [media] media: add a linked list to track interfaces by mdev
Quoted 3 lines · Mauro Carvalho Chehab
We need to be able to navigate at the interfaces that belong to a given media device, in to indirect interface links.
The part after the comma is not clear. Did you perhaps mean 'into'? Although that still doesn't really clarify the sentence.
Quoted 73 lines
So, add a linked list to track them.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +1
-0@@ -381,6 +381,7 @@ int __must_check __media_device_register(struct media_device *mdev,return -EINVAL ;INIT_LIST_HEAD (&mdev->entities); +INIT_LIST_HEAD (&mdev->interfaces);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);drivers/media/media-entity.c +3
-0@@ -875,6 +875,8 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); +list_add_tail (&intf->list, &mdev->interfaces); +return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);@@ -882,6 +884,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); +list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);include/media/media-device.h +2
-0@@ -46,6 +46,7 @@ struct device;* @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities +* @interfaces: List of registered interfaces * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback @@ -77,6 +78,7 @@ struct media_device {u32 intf_devnode_id;struct list_head entities; +struct list_head interfaces;/* Protects the entities list */ spinlock_t lock;include/media/media-entity.h +2
-0@@ -156,6 +156,8 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @list: Linked list used to find other interfaces that belong +* to the same media controller * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g.
include/media/media-entity.h struct media_entity { · line 172
Quoted 7 lines
include/media/media-entity.h +1
-0@@ -164,6 +166,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head list;struct list_head links;u32 type;u32 flags;
Regards,
Hans
Re: [PATCH v7 22/44] [media] media: add a linked list to track interfaces by mdev
Em Tue, 25 Aug 2015 09:54:21 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 7 lines · Mauro Carvalho Chehab
Quoted 3 lines
We need to be able to navigate at the interfaces that belong to a given media device, in to indirect interface links.
The part after the comma is not clear. Did you perhaps mean 'into'? Although that still doesn't really clarify the sentence.
What about:
It should be possible to navigate at the interface objects from the media controller. So, add a linked list there.
Quoted 85 lines
Quoted 74 lines
So, add a linked list to track them.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +1
-0@@ -381,6 +381,7 @@ int __must_check __media_device_register(struct media_device *mdev,return -EINVAL ;INIT_LIST_HEAD (&mdev->entities); +INIT_LIST_HEAD (&mdev->interfaces);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);drivers/media/media-entity.c +3
-0@@ -875,6 +875,8 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); +list_add_tail (&intf->list, &mdev->interfaces); +return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);@@ -882,6 +884,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); +list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);include/media/media-device.h +2
-0@@ -46,6 +46,7 @@ struct device;* @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities +* @interfaces: List of registered interfaces * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback @@ -77,6 +78,7 @@ struct media_device {u32 intf_devnode_id;struct list_head entities; +struct list_head interfaces;/* Protects the entities list */ spinlock_t lock;include/media/media-entity.h +2
-0@@ -156,6 +156,8 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @list: Linked list used to find other interfaces that belong +* to the same media controller * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. include/media/media-entity.h struct media_entity { · line 172
Quoted 7 lines
include/media/media-entity.h +1
-0@@ -164,6 +166,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head list;struct list_head links;u32 type;u32 flags;Regards,
Hans
Re: [PATCH v7 22/44] [media] media: add a linked list to track interfaces by mdev
Quoted 8 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 09:54:21 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 5 lines · Mauro Carvalho Chehab
Quoted 3 lines
We need to be able to navigate at the interfaces that belong to a given media device, in to indirect interface links.
Quoted 7 lines
Quoted 2 lines
The part after the comma is not clear. Did you perhaps mean 'into'? Although that still doesn't really clarify the sentence.
What about:
It should be possible to navigate at the interface objects from the media controller. So, add a linked list there.
Sorry, still unclear.
How about this:
"The media device should list the interface objects, so add a linked list for those interfaces in struct media_device."
Regards,
Hans
Quoted 91 lines
Quoted 85 lines
Quoted 75 lines
So, add a linked list to track them.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +1
-0@@ -381,6 +381,7 @@ int __must_check __media_device_register(struct media_device *mdev,return -EINVAL ;INIT_LIST_HEAD (&mdev->entities); +INIT_LIST_HEAD (&mdev->interfaces);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);drivers/media/media-entity.c +3
-0@@ -875,6 +875,8 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); +list_add_tail (&intf->list, &mdev->interfaces); +return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);@@ -882,6 +884,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); +list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);include/media/media-device.h +2
-0@@ -46,6 +46,7 @@ struct device;* @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities +* @interfaces: List of registered interfaces * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback @@ -77,6 +78,7 @@ struct media_device {u32 intf_devnode_id;struct list_head entities; +struct list_head interfaces;/* Protects the entities list */ spinlock_t lock;include/media/media-entity.h +2
-0@@ -156,6 +156,8 @@ struct media_entity {* struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object +* @list: Linked list used to find other interfaces that belong +* to the same media controller * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. include/media/media-entity.h struct media_entity { · line 172
Quoted 7 lines
include/media/media-entity.h +1
-0@@ -164,6 +166,7 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; +struct list_head list;struct list_head links;u32 type;u32 flags;Regards,
Quoted 1 line
Hans
--
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
PATCH v7 23/44 dvbdev: add support for indirect interface links
In reply to Mauro Carvalho ChehabSome interfaces indirectly control multiple entities. Add support for those.
drivers/media/dvb-core/dvbdev.c +12 -0
@@ -440,6 +440,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)struct media_device *mdev = adap->mdev;struct media_entity *entity, *tuner =NULL , *fe =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ; +struct media_interface *intf;if (!mdev)return ;
@@ -475,6 +476,17 @@ void dvb_create_media_graph(struct dvb_adapter *adap)if (demux && ca)media_create_pad_link (demux,1 , ca,0 ,MEDIA_LNK_FL_ENABLED ); + +/* Create indirect interface links for DVR and tuner */ + +list_for_each_entry (intf, &mdev->interfaces, list) { +if (intf->type ==MEDIA_INTF_T_DVB_FE && tuner) +media_create_intf_link (tuner, intf,0 ); +if (intf->type ==MEDIA_INTF_T_DVB_DVR && demux) +media_create_intf_link (demux, intf,0 ); + } + + }EXPORT_SYMBOL_GPL (dvb_create_media_graph);#endif
Signature · 1 line
2.4.3
Re: [PATCH v7 23/44] [media] dvbdev: add support for indirect interface links
Quoted 20 lines · Mauro Carvalho Chehab
Some interfaces indirectly control multiple entities. Add support for those.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +1
-0@@ -440,6 +440,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)struct media_device *mdev = adap->mdev;struct media_entity *entity, *tuner =NULL , *fe =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ; +struct media_interface *intf;if (!mdev)return ;@@ -475,6 +476,17 @@ void dvb_create_media_graph(struct dvb_adapter *adap)if (demux && ca)
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 487
Quoted 10 lines
drivers/media/dvb-core/dvbdev.c +9
-0media_create_pad_link (demux,1 , ca,0 ,MEDIA_LNK_FL_ENABLED ); + +/* Create indirect interface links for DVR and tuner */ + +list_for_each_entry (intf, &mdev->interfaces, list) { +if (intf->type ==MEDIA_INTF_T_DVB_FE && tuner) +media_create_intf_link (tuner, intf,0 ); +if (intf->type ==MEDIA_INTF_T_DVB_DVR && demux) +media_create_intf_link (demux, intf,0 ); + }
Shouldn't there also be a link between the CA entity and CA interface?
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 489
Quoted 2 lines
drivers/media/dvb-core/dvbdev.c +2
-0+ +
Spurious newlines at the end of the function.
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 492
Quoted 4 lines
drivers/media/dvb-core/dvbdev.c +0
-0}EXPORT_SYMBOL_GPL (dvb_create_media_graph);#endif
Regards,
Hans
Re: [PATCH v7 23/44] [media] dvbdev: add support for indirect interface links
Em Tue, 25 Aug 2015 10:39:10 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 20 lines · Mauro Carvalho Chehab
Quoted 19 lines
Some interfaces indirectly control multiple entities. Add support for those.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/dvb-core/dvbdev.c +1
-0@@ -440,6 +440,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap)struct media_device *mdev = adap->mdev;struct media_entity *entity, *tuner =NULL , *fe =NULL ;struct media_entity *demux =NULL , *dvr =NULL , *ca =NULL ; +struct media_interface *intf;if (!mdev)return ;@@ -475,6 +476,17 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
Quoted 13 lines
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 487
Quoted 11 lines
drivers/media/dvb-core/dvbdev.c +9
-0if (demux && ca)media_create_pad_link (demux,1 , ca,0 ,MEDIA_LNK_FL_ENABLED ); + +/* Create indirect interface links for DVR and tuner */ + +list_for_each_entry (intf, &mdev->interfaces, list) { +if (intf->type ==MEDIA_INTF_T_DVB_FE && tuner) +media_create_intf_link (tuner, intf,0 ); +if (intf->type ==MEDIA_INTF_T_DVB_DVR && demux) +media_create_intf_link (demux, intf,0 ); + }Shouldn't there also be a link between the CA entity and CA interface?
Good catch!
I forgot it, because the hardware I'm using to test doesn't have it.
Quoted 14 lines
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 489
Quoted 3 lines
drivers/media/dvb-core/dvbdev.c +2
-0+ +Spurious newlines at the end of the function.
drivers/media/dvb-core/dvbdev.c void dvb_create_media_graph(struct dvb_adapter *adap) · line 492
Quoted 4 lines
drivers/media/dvb-core/dvbdev.c +0
-0}EXPORT_SYMBOL_GPL (dvb_create_media_graph);#endif Regards,
Hans
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
In reply to Mauro Carvalho ChehabNow that interfaces and entities are distinct, it makes no sense of keeping something named as MEDIA_ENT_T_DEVNODE.
This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; done
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1 -1
@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row> <row>
drivers/media/platform/xilinx/xilinx-dma.c +1 -1
@@ -193,7 +193,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,while ((entity =media_entity_graph_walk_next (&graph))) {struct xvip_dma *dma; -if (entity->type !=MEDIA_ENT_T_DEVNODE_V4L ) +if (entity->type !=MEDIA_ENT_T_V4L2_VIDEO )continue ; dma =to_xvip_dma (media_entity_to_video_device (entity));
drivers/media/v4l2-core/v4l2-dev.c +1 -1
@@ -912,7 +912,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr,/* Part 5: Register the entity. */ if (vdev->v4l2_dev->mdev && vdev->vfl_type !=VFL_TYPE_SUBDEV ) { - vdev->entity.type =MEDIA_ENT_T_DEVNODE_V4L ; + vdev->entity.type =MEDIA_ENT_T_V4L2_VIDEO ; vdev->entity.name = vdev->name; vdev->entity.info.dev.major =VIDEO_MAJOR ; vdev->entity.info.dev.minor = vdev->minor;
drivers/media/v4l2-core/v4l2-subdev.c +1 -1
@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,return v4l2_subdev_call (sd, pad, get_fmt,NULL , fmt); } -WARN (pad->entity->type !=MEDIA_ENT_T_DEVNODE_V4L , +WARN (pad->entity->type !=MEDIA_ENT_T_V4L2_VIDEO ,"Driver bug! Wrong media entity type 0x%08x, entity %s\n" , pad->entity->type, pad->entity->name);
Signature · 1 line
2.4.3
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Quoted 14 lines · Mauro Carvalho Chehab
Now that interfaces and entities are distinct, it makes no sense of keeping something named as
MEDIA_ENT_T_DEVNODE.This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml line 188
Quoted 7 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1
-1@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row>
OK, this makes no sense and that ties in with my confusion of the previous patch.
These are not device nodes, in the new scheme these are DMA entities (I know, naming TDB) that have an associated interface.
I think a much better approach would be to add entity type(s) for such DMA engines in patch 24, then use that new name in existing drivers and split up the existing DEVNODE_V4L media_entity into a media_entity and a media_intf_devnode:
The current media_entity defined in struct video_device has to be replaced by media_intf_devnode, and the DMA entity has to be added as a new entity to these drivers.
This reflects these two action items from our meeting:
Migration: add v4l-subdev media_interface: Laurent
Migration: add explicit DMA Engine entity: Laurent
Unless Laurent says differently I think this is something you'll have to do given Laurent's workload.
I think doing this at this stage of the patch series is crucial, otherwise the remaining patches really make no sense.
I'll skip reviewing patches 26-38 for now.
Regards,
Hans
Quoted 41 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0<row>drivers/media/platform/xilinx/xilinx-dma.c +1
-1@@ -193,7 +193,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,while ((entity =media_entity_graph_walk_next (&graph))) {struct xvip_dma *dma; -if (entity->type !=MEDIA_ENT_T_DEVNODE_V4L ) +if (entity->type !=MEDIA_ENT_T_V4L2_VIDEO )continue ; dma =to_xvip_dma (media_entity_to_video_device (entity));drivers/media/v4l2-core/v4l2-dev.c +1
-1@@ -912,7 +912,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr,/* Part 5: Register the entity. */ if (vdev->v4l2_dev->mdev && vdev->vfl_type !=VFL_TYPE_SUBDEV ) { - vdev->entity.type =MEDIA_ENT_T_DEVNODE_V4L ; + vdev->entity.type =MEDIA_ENT_T_V4L2_VIDEO ; vdev->entity.name = vdev->name; vdev->entity.info.dev.major =VIDEO_MAJOR ; vdev->entity.info.dev.minor = vdev->minor;drivers/media/v4l2-core/v4l2-subdev.c +1
-1@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,return v4l2_subdev_call (sd, pad, get_fmt,NULL , fmt); } -WARN (pad->entity->type !=MEDIA_ENT_T_DEVNODE_V4L , +WARN (pad->entity->type !=MEDIA_ENT_T_V4L2_VIDEO ,"Driver bug! Wrong media entity type 0x%08x, entity %s\n" , pad->entity->type, pad->entity->name);
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Em Tue, 25 Aug 2015 11:23:24 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 25 lines · Mauro Carvalho Chehab
Quoted 14 lines
Now that interfaces and entities are distinct, it makes no sense of keeping something named as
MEDIA_ENT_T_DEVNODE.This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml line 188
Quoted 7 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1
-1@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row>OK, this makes no sense and that ties in with my confusion of the previous patch.
Quoted 2 lines
These are not device nodes, in the new scheme these are DMA entities (I know, naming TDB) that have an associated interface.
Yes. Well, DMA is a bad name. It won't cover USB devices, where the DMA engine is outside the V4L2 drivers, nor it would work for RDS radio data, with may not need any DMA at all on no-USB devices, as the data flows via the I2C bus.
Quoted 4 lines
I think a much better approach would be to add entity type(s) for such DMA engines in patch 24, then use that new name in existing drivers and split up the existing
DEVNODE_V4Lmedia_entityinto amedia_entityand amedia_intf_devnode:
Sorry, but I didn't get. That's precisely what I did ;)
Quoted 3 lines
The current
media_entitydefined in structvideo_devicehas to be replaced bymedia_intf_devnode, and the DMA entity has to be added as a new entity to these drivers.
If I do this way, it would break bisectability. I need first to replace the names, but keep them as entities, and then add the interfaces.
Quoted 8 lines
This reflects these two action items from our meeting:
Migration: add v4l-subdev
media_interface: Laurent
Migration: add explicit DMA Engine entity: LaurentUnless Laurent says differently I think this is something you'll have to do given Laurent's workload.
Yes. The above action items are covered on this series.
What patch 24 does is to define the new namespace, moving the legacy symbols kept due to backward compatibility on a separate part of the header.
Then, patches 25-38 replace the occurrences of the deprecated names by the new ones.
Nothing is touched at the interfaces yet, to avoid breaking bisectability.
Then, the next patches add interfaces support at the V4L side.
Quoted 50 lines
I think doing this at this stage of the patch series is crucial, otherwise the remaining patches really make no sense.
I'll skip reviewing patches 26-38 for now.
Regards,
Hans
Quoted 41 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0<row>drivers/media/platform/xilinx/xilinx-dma.c +1
-1@@ -193,7 +193,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,while ((entity =media_entity_graph_walk_next (&graph))) {struct xvip_dma *dma; -if (entity->type !=MEDIA_ENT_T_DEVNODE_V4L ) +if (entity->type !=MEDIA_ENT_T_V4L2_VIDEO )continue ; dma =to_xvip_dma (media_entity_to_video_device (entity));drivers/media/v4l2-core/v4l2-dev.c +1
-1@@ -912,7 +912,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr,/* Part 5: Register the entity. */ if (vdev->v4l2_dev->mdev && vdev->vfl_type !=VFL_TYPE_SUBDEV ) { - vdev->entity.type =MEDIA_ENT_T_DEVNODE_V4L ; + vdev->entity.type =MEDIA_ENT_T_V4L2_VIDEO ; vdev->entity.name = vdev->name; vdev->entity.info.dev.major =VIDEO_MAJOR ; vdev->entity.info.dev.minor = vdev->minor;drivers/media/v4l2-core/v4l2-subdev.c +1
-1@@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad,return v4l2_subdev_call (sd, pad, get_fmt,NULL , fmt); } -WARN (pad->entity->type !=MEDIA_ENT_T_DEVNODE_V4L , +WARN (pad->entity->type !=MEDIA_ENT_T_V4L2_VIDEO ,"Driver bug! Wrong media entity type 0x%08x, entity %s\n" , pad->entity->type, pad->entity->name);
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Quoted 61 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 11:23:24 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 25 lines · Mauro Carvalho Chehab
Quoted 14 lines
Now that interfaces and entities are distinct, it makes no sense of keeping something named as
MEDIA_ENT_T_DEVNODE.This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml line 188
Quoted 7 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1
-1@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row>OK, this makes no sense and that ties in with my confusion of the previous patch.
Quoted 2 lines
These are not device nodes, in the new scheme these are DMA entities (I know, naming TDB) that have an associated interface.
Yes. Well, DMA is a bad name. It won't cover USB devices, where the DMA engine is outside the V4L2 drivers, nor it would work for RDS radio data, with may not need any DMA at all on no-USB devices, as the data flows via the I2C bus.
Quoted 4 lines
I think a much better approach would be to add entity type(s) for such DMA engines in patch 24, then use that new name in existing drivers and split up the existing
DEVNODE_V4Lmedia_entityinto amedia_entityand amedia_intf_devnode:Sorry, but I didn't get. That's precisely what I did ;)
Quoted 3 lines
The current
media_entitydefined in structvideo_devicehas to be replaced bymedia_intf_devnode, and the DMA entity has to be added as a new entity to these drivers.If I do this way, it would break bisectability. I need first to replace the names, but keep them as entities, and then add the interfaces.
Quoted 8 lines
This reflects these two action items from our meeting:
Migration: add v4l-subdev
media_interface: Laurent
Migration: add explicit DMA Engine entity: LaurentUnless Laurent says differently I think this is something you'll have to do given Laurent's workload.
Yes. The above action items are covered on this series.
Quoted 8 lines
What patch 24 does is to define the new namespace, moving the legacy symbols kept due to backward compatibility on a separate part of the header.
Then, patches 25-38 replace the occurrences of the deprecated names by the new ones.
Nothing is touched at the interfaces yet, to avoid breaking bisectability.
I don't follow why that would break bisect.
Quoted 1 line
Then, the next patches add interfaces support at the V4L side.
So this is not yet included in this patch series? That would explain my confusion. If it is, then I need to take another look on Friday.
Regards,
Hans
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Em Tue, 25 Aug 2015 15:54:09 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 66 lines · Mauro Carvalho Chehab
Quoted 65 lines
Em Tue, 25 Aug 2015 11:23:24 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 25 lines · Mauro Carvalho Chehab
Quoted 14 lines
Now that interfaces and entities are distinct, it makes no sense of keeping something named as
MEDIA_ENT_T_DEVNODE.This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml line 188
Quoted 7 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1
-1@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row>OK, this makes no sense and that ties in with my confusion of the previous patch.
Quoted 2 lines
These are not device nodes, in the new scheme these are DMA entities (I know, naming TDB) that have an associated interface.
Yes. Well, DMA is a bad name. It won't cover USB devices, where the DMA engine is outside the V4L2 drivers, nor it would work for RDS radio data, with may not need any DMA at all on no-USB devices, as the data flows via the I2C bus.
Quoted 4 lines
I think a much better approach would be to add entity type(s) for such DMA engines in patch 24, then use that new name in existing drivers and split up the existing
DEVNODE_V4Lmedia_entityinto amedia_entityand amedia_intf_devnode:Sorry, but I didn't get. That's precisely what I did ;)
Quoted 3 lines
The current
media_entitydefined in structvideo_devicehas to be replaced bymedia_intf_devnode, and the DMA entity has to be added as a new entity to these drivers.If I do this way, it would break bisectability. I need first to replace the names, but keep them as entities, and then add the interfaces.
Quoted 8 lines
This reflects these two action items from our meeting:
Migration: add v4l-subdev
media_interface: Laurent
Migration: add explicit DMA Engine entity: LaurentUnless Laurent says differently I think this is something you'll have to do given Laurent's workload.
Yes. The above action items are covered on this series.
What patch 24 does is to define the new namespace, moving the legacy symbols kept due to backward compatibility on a separate part of the header.
Quoted 6 lines
Quoted 4 lines
Then, patches 25-38 replace the occurrences of the deprecated names by the new ones.
Nothing is touched at the interfaces yet, to avoid breaking bisectability.
I don't follow why that would break bisect.
It won't break compilation, but it will break runtime.
I mean: if we replace the current occurrences of the
"video output data entities" [1] any userspace app that would be used to test somethingwill stop working.
Ok, that means that it would break bisectability for us ;) Still, better to avoid.
[1] I don't like the "DMA" entities term, as it is too broken. I prefer to refer to them with some other name, like I/O entities. However, even this name is not perfect. Those are, in reality, a "data interface", while what we call interface is actually a "control interface", but calling like that would be confusing, I think. So, I'll simply call it as "video/vbi/... output data entities".
Quoted 5 lines
Quoted 2 lines
Then, the next patches add interfaces support at the V4L side.
So this is not yet included in this patch series? That would explain my confusion. If it is, then I need to take another look on Friday.
It is on the 3 patches I sent yesterday, after this patch series:
https://patchwork.linuxtv.org/patch/31081/ https://patchwork.linuxtv.org/patch/31082/ https://patchwork.linuxtv.org/patch/31083/
Please notice that the above patch series is not complete, as there's something non-trivial to be addressed on non-subdev V4L2 interfaces: how to create the indirect links.
By indirect links, I meant to refer to the interface links that don't control an entity directly, but via the internal hardware control/I2C bus(es).
So, a video interface, on a PC customer's hardware controls not only the video output data entity, but it also indirectly controls the tuner and the analog demod. Or, on a webcam hardware, it will also controls the sensor.
However, on platform drivers, it controls just the "video output data entity" that is directly associated with it via its device node.
We need to add some support to automatically create those links, once available, but only if the device is a PC customer's hardware.
Btw, that's another reason to postpone it: creating the interfaces offer this additional challenge, while creating the entities are easy, as nothing changes there.
Regards,
Mauro
PATCH v7 25/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Quoted 95 lines · Mauro Carvalho Chehab
Em Tue, 25 Aug 2015 15:54:09 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 66 lines · Mauro Carvalho Chehab
Quoted 65 lines
Em Tue, 25 Aug 2015 11:23:24 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 25 lines · Mauro Carvalho Chehab
Quoted 14 lines
Now that interfaces and entities are distinct, it makes no sense of keeping something named as
MEDIA_ENT_T_DEVNODE.This change was done with this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; doneSigned-off-by Mauro Carvalho Chehab <[email protected]>Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +0
-0Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml line 188
Quoted 7 lines
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +1
-1@@ -183,7 +183,7 @@ <entry>Unknown device node</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_V4L</constant></entry> + <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> <entry>V4L video, radio or vbi device node</entry> </row>OK, this makes no sense and that ties in with my confusion of the previous patch.
Quoted 2 lines
These are not device nodes, in the new scheme these are DMA entities (I know, naming TDB) that have an associated interface.
Yes. Well, DMA is a bad name. It won't cover USB devices, where the DMA engine is outside the V4L2 drivers, nor it would work for RDS radio data, with may not need any DMA at all on no-USB devices, as the data flows via the I2C bus.
Quoted 4 lines
I think a much better approach would be to add entity type(s) for such DMA engines in patch 24, then use that new name in existing drivers and split up the existing
DEVNODE_V4Lmedia_entityinto amedia_entityand amedia_intf_devnode:Sorry, but I didn't get. That's precisely what I did ;)
Quoted 3 lines
The current
media_entitydefined in structvideo_devicehas to be replaced bymedia_intf_devnode, and the DMA entity has to be added as a new entity to these drivers.If I do this way, it would break bisectability. I need first to replace the names, but keep them as entities, and then add the interfaces.
Quoted 8 lines
This reflects these two action items from our meeting:
Migration: add v4l-subdev
media_interface: Laurent
Migration: add explicit DMA Engine entity: LaurentUnless Laurent says differently I think this is something you'll have to do given Laurent's workload.
Yes. The above action items are covered on this series.
What patch 24 does is to define the new namespace, moving the legacy symbols kept due to backward compatibility on a separate part of the header.
Quoted 6 lines
Quoted 4 lines
Then, patches 25-38 replace the occurrences of the deprecated names by the new ones.
Nothing is touched at the interfaces yet, to avoid breaking bisectability.
I don't follow why that would break bisect.
It won't break compilation, but it will break runtime.
I mean: if we replace the current occurrences of the
"video output data entities" [1] any userspace app that would be used to test somethingwill stop working.Ok, that means that it would break bisectability for us ;) Still, better to avoid.
[1] I don't like the "DMA" entities term, as it is too broken. I prefer to refer to them with some other name, like I/O entities. However, even this name is not perfect. Those are, in reality, a "data interface", while what we call interface is actually a "control interface", but calling like that would be confusing, I think. So, I'll simply call it as "video/vbi/... output data entities".
Quoted 3 lines
Quoted 2 lines
Then, the next patches add interfaces support at the V4L side.
Quoted 8 lines
Quoted 2 lines
So this is not yet included in this patch series? That would explain my confusion. If it is, then I need to take another look on Friday.
It is on the 3 patches I sent yesterday, after this patch series:
https://patchwork.linuxtv.org/patch/31081/ https://patchwork.linuxtv.org/patch/31082/ https://patchwork.linuxtv.org/patch/31083/
Ah, OK. These are not part of this patch series, so that explains it. I hadn't gotten around to reviewing these 3.
I'll plan reviewing these on Friday and I'll revisit the patches I skipped in the 44 part-series with this in mind.
Regards,
Hans
Quoted 31 lines
Please notice that the above patch series is not complete, as there's something non-trivial to be addressed on non-subdev V4L2 interfaces: how to create the indirect links.
By indirect links, I meant to refer to the interface links that don't control an entity directly, but via the internal hardware control/I2C bus(es).
So, a video interface, on a PC customer's hardware controls not only the video output data entity, but it also indirectly controls the tuner and the analog demod. Or, on a webcam hardware, it will also controls the sensor.
However, on platform drivers, it controls just the "video output data entity" that is directly associated with it via its device node.
We need to add some support to automatically create those links, once available, but only if the device is a PC customer's hardware.
Btw, that's another reason to postpone it: creating the interfaces offer this additional challenge, while creating the entities are easy, as nothing changes there.
Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v7 26/44 replace all occurrences of MEDIA_ENT_T_DEVNODE_DVB
In reply to Mauro Carvalho ChehabNow that interfaces and entities are distinct, it makes no sense of keeping something named as MEDIA_ENT_T_DEVNODE_DVB_foo.
Made via this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_DVB_,MEDIA_ENT_T_DVB_, <$i >a && mv a $i; done for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_DVR,MEDIA_ENT_T_DVB_TSOUT, <$i >a && mv a $i; done for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_FE,MEDIA_ENT_T_DVB_DEMOD, <$i >a && mv a $i; done for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_NET,MEDIA_ENT_T_DVB_DEMOD_NET_DECAP, <$i >a && mv a $i; done
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +5 -5
@@ -195,23 +195,23 @@ <entry>ALSA card</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_DVB_FE</constant></entry> + <entry><constant>MEDIA_ENT_T_DVB_DEMOD</constant></entry> <entry>DVB frontend devnode</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_DVB_DEMUX</constant></entry> + <entry><constant>MEDIA_ENT_T_DVB_DEMUX</constant></entry> <entry>DVB demux devnode</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_DVB_DVR</constant></entry> + <entry><constant>MEDIA_ENT_T_DVB_TSOUT</constant></entry> <entry>DVB DVR devnode</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_DVB_CA</constant></entry> + <entry><constant>MEDIA_ENT_T_DVB_CA</constant></entry> <entry>DVB CAM devnode</entry> </row> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_DVB_NET</constant></entry> + <entry><constant>MEDIA_ENT_T_DVB_DEMOD_NET_DECAP</constant></entry> <entry>DVB network devnode</entry> </row> <row>
Signature · 1 line
2.4.3
PATCH v7 27/44 media: add macros to check if subdev or V4L2 DMA
In reply to Mauro Carvalho ChehabAs we'll be removing entity subtypes from the Kernel, we need to provide a way for drivers and core to check if a given entity is represented by a V4L2 subdev or if it is an V4L2 I/O entity (typically with DMA).
include/media/media-entity.h +33 -0
@@ -220,6 +220,39 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)return id; } +static inline bool is_media_entity_v4l2_io (struct media_entity *entity) +{ +if (!entity) +return false; + +switch (entity->type) { +case MEDIA_ENT_T_V4L2_VIDEO : +case MEDIA_ENT_T_V4L2_VBI : +case MEDIA_ENT_T_V4L2_SWRADIO : +return true; +default : +return false; + } +} + +static inline bool is_media_entity_v4l2_subdev (struct media_entity *entity) +{ +if (!entity) +return false; + +switch (entity->type) { +case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR : +case MEDIA_ENT_T_V4L2_SUBDEV_FLASH : +case MEDIA_ENT_T_V4L2_SUBDEV_LENS : +case MEDIA_ENT_T_V4L2_SUBDEV_DECODER : +case MEDIA_ENT_T_V4L2_SUBDEV_TUNER : +return true; + +default : +return false; + } +} +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16#define MEDIA_ENTITY_ENUM_MAX_ID 64
Signature · 1 line
2.4.3
PATCH v7 28/44 media: use macros to check for V4L2 subdev entities
In reply to Mauro Carvalho ChehabInstead of relying on media subtype, use the new macros to detect if an entity is a subdev or an A/V DMA entity.
Please note that most drivers assume that there's just AV_DMA or V4L2 subdevs. This is not true anymore, as we've added MC support for DVB, and there are plans to add support for ALSA and FB/DRM too.
Ok, on the current pipelines supported by those drivers, just V4L stuff are there, but, assuming that some day a pipeline that also works with other subsystems will ever added, it is better to add explicit checks for the AV_DMA stuff.
drivers/media/platform/exynos4-is/common.c +1 -2
@@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity)while (pad->flags &MEDIA_PAD_FL_SINK ) {/* source pad */ pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; sd =media_entity_to_v4l2_subdev (pad->entity);
drivers/media/platform/exynos4-is/fimc-capture.c +2 -3
@@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc) } } -if (src_pad ==NULL || -media_entity_type (src_pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (src_pad->entity))break ;/* Don't call FIMC subdev operation to avoid nested locking */
@@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity *entity,struct fimc_vid_cap *vc = &fimc->vid_cap;struct v4l2_subdev *sensor; -if (media_entity_type (remote->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (remote->entity))return -EINVAL ;if (WARN_ON (fimc ==NULL ))
drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -2
@@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct fimc_isp *isp)/* Retrieve format at the source pad */ pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; sd =media_entity_to_v4l2_subdev (pad->entity);
drivers/media/platform/exynos4-is/fimc-lite.c +4 -6
@@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite *fimc) }/* Retrieve format at the source pad */ pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; sd =media_entity_to_v4l2_subdev (pad->entity);
@@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity *entity, {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct fimc_lite *fimc =v4l2_get_subdevdata (sd); -unsigned int remote_ent_type =media_entity_type (remote->entity);int ret =0 ;if (WARN_ON (fimc ==NULL ))
@@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity *entity,switch (local->index) {case FLITE_SD_PAD_SINK : -if (remote_ent_type !=MEDIA_ENT_T_V4L2_SUBDEV ) { +if (!is_media_entity_v4l2_subdev (remote->entity)) { ret = -EINVAL ;break ; }
@@ -1018,7 +1016,7 @@ static int fimc_lite_link_setup(struct media_entity *entity,case FLITE_SD_PAD_SOURCE_DMA :if (!(flags &MEDIA_LNK_FL_ENABLED ))atomic_set (&fimc->out_path,FIMC_IO_NONE ); -else if (remote_ent_type ==MEDIA_ENT_T_DEVNODE ) +else if (is_media_v4l2_io (remote->entity))atomic_set (&fimc->out_path,FIMC_IO_DMA );else ret = -EINVAL ;
@@ -1027,7 +1025,7 @@ static int fimc_lite_link_setup(struct media_entity *entity,case FLITE_SD_PAD_SOURCE_ISP :if (!(flags &MEDIA_LNK_FL_ENABLED ))atomic_set (&fimc->out_path,FIMC_IO_NONE ); -else if (remote_ent_type ==MEDIA_ENT_T_V4L2_SUBDEV ) + else if (is_media_entity_v4l2_subdev(remote->entity)))atomic_set (&fimc->out_path,FIMC_IO_ISP );else ret = -EINVAL ;
drivers/media/platform/exynos4-is/media-dev.c +3 -4
@@ -88,8 +88,7 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,break ; } -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; sd =media_entity_to_v4l2_subdev (pad->entity);
@@ -1062,7 +1061,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) +if (!is_media_entity_v4l2_io (entity))continue ; ret =__fimc_md_modify_pipeline (entity, enable);
@@ -1076,7 +1075,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)media_entity_graph_walk_start (&graph, entity_err);while ((entity_err =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity_err) !=MEDIA_ENT_T_DEVNODE ) +if (!is_media_entity_v4l2_io (entity_err))continue ;__fimc_md_modify_pipeline (entity_err, !enable);
drivers/media/platform/omap3isp/isp.c +6 -8
@@ -691,7 +691,7 @@ static int isp_pipeline_pm_use_count(struct media_entity *entity)media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity) ==MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_io (entity)) use += entity->use_count; }
@@ -714,7 +714,7 @@ static int isp_pipeline_pm_power_one(struct media_entity *entity, int change)struct v4l2_subdev *subdev;int ret; - subdev =media_entity_type (entity) ==MEDIA_ENT_T_V4L2_SUBDEV + subdev = is_media_entity_v4l2_subdev(entity)) ?media_entity_to_v4l2_subdev (entity) :NULL ;if (entity->use_count ==0 && change >0 && subdev !=NULL ) {
@@ -754,7 +754,7 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change)media_entity_graph_walk_start (&graph, entity);while (!ret && (entity =media_entity_graph_walk_next (&graph))) -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_subdev (entity)) ret =isp_pipeline_pm_power_one (entity, change);if (!ret)
@@ -764,7 +764,7 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change)while ((first =media_entity_graph_walk_next (&graph)) && first != entity) -if (media_entity_type (first) !=MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_subdev (first))isp_pipeline_pm_power_one (first, -change);return ret;
@@ -897,8 +897,7 @@ static int isp_pipeline_enable(struct isp_pipeline *pipe,break ; pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; entity = pad->entity;
@@ -988,8 +987,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)break ; pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; entity = pad->entity;
drivers/media/platform/omap3isp/ispvideo.c +3 -4
@@ -210,8 +210,7 @@ isp_video_remote_subdev(struct isp_video *video, u32 *pad) remote =media_entity_remote_pad (&video->pad); -if (remote ==NULL || -media_entity_type (remote->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (remote->entity))return NULL ;if (pad)
@@ -243,7 +242,7 @@ static int isp_video_get_graph_data(struct isp_video *video,if (entity == &video->video.entity)continue ; -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) +if (!is_media_entity_v4l2_io (entity))continue ; __video =to_isp_video (media_entity_to_video_device (entity));
@@ -917,7 +916,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,return -EINVAL ; } -if (media_entity_type (source) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (source->entity))return 0 ; pipe->external =media_entity_to_v4l2_subdev (source);
drivers/media/platform/s3c-camif/camif-capture.c +1 -1
@@ -837,7 +837,7 @@ static int camif_pipeline_validate(struct camif_dev *camif)/* Retrieve format at the sensor subdev source pad */ pad =media_entity_remote_pad (&camif->pads[0 ]); -if (!pad ||media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))return -EPIPE ; src_fmt.pad = pad->index;
drivers/media/platform/vsp1/vsp1_video.c +4 -5
@@ -160,8 +160,7 @@ vsp1_video_remote_subdev(struct media_pad *local, u32 *pad)struct media_pad *remote; remote =media_entity_remote_pad (local); -if (remote ==NULL || -media_entity_type (remote->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (remote->entity))return NULL ;if (pad)
@@ -326,7 +325,7 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,return -EPIPE ;/* We've reached a video node, that shouldn't have happened. */ -if (media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))return -EPIPE ; entity =to_vsp1_entity (media_entity_to_v4l2_subdev (pad->entity));
@@ -423,7 +422,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,struct vsp1_rwpf *rwpf;struct vsp1_entity *e; -if (media_entity_type (entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) { +if (is_media_entity_v4l2_io (entity)) { pipe->num_video++;continue ; }
@@ -692,7 +691,7 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, pad =media_entity_remote_pad (&input->pads[RWPF_PAD_SOURCE ]);while (pad) { -if (media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; entity =to_vsp1_entity (media_entity_to_v4l2_subdev (pad->entity));
drivers/media/platform/xilinx/xilinx-dma.c +2 -4
@@ -49,8 +49,7 @@ xvip_dma_remote_subdev(struct media_pad *local, u32 *pad)struct media_pad *remote; remote =media_entity_remote_pad (local); -if (remote ==NULL || -media_entity_type (remote->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (remote->entity))return NULL ;if (pad)
@@ -113,8 +112,7 @@ static int xvip_pipeline_start_stop(struct xvip_pipeline *pipe, bool start)break ; pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; entity = pad->entity;
drivers/media/v4l2-core/v4l2-subdev.c +1 -1
@@ -526,7 +526,7 @@ static int v4l2_subdev_link_validate_get_format(struct media_pad *pad, struct v4l2_subdev_format *fmt) { - if (media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV) { + if (is_media_entity_v4l2_subdev(pad->entity)) { struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (pad->entity);
drivers/staging/media/davinci_vpfe/vpfe_video.c +3 -3
@@ -148,7 +148,7 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)while ((entity =media_entity_graph_walk_next (&graph))) {if (entity == &video->video_dev.entity)continue ; -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) + if ((!is_media_entity_v4l2_io(remote->entity))continue ; far_end =to_vpfe_video (media_entity_to_video_device (entity));if (far_end->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT )
@@ -293,7 +293,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity) ==MEDIA_ENT_T_DEVNODE ) + if !is_media_entity_v4l2_subdev(entity))continue ; subdev =media_entity_to_v4l2_subdev (entity); ret =v4l2_subdev_call (subdev, video, s_stream,1 );
@@ -334,7 +334,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)while ((entity =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity) ==MEDIA_ENT_T_DEVNODE ) +if (!is_media_entity_v4l2_subdev (entity))continue ; subdev =media_entity_to_v4l2_subdev (entity); ret =v4l2_subdev_call (subdev, video, s_stream,0 );
drivers/staging/media/omap4iss/iss.c +6 -8
@@ -397,7 +397,7 @@ static int iss_pipeline_pm_use_count(struct media_entity *entity)media_entity_graph_walk_start (&graph, entity);while ((entity =media_entity_graph_walk_next (&graph))) { -if (media_entity_type (entity) ==MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_io (entity)) use += entity->use_count; }
@@ -419,7 +419,7 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) {struct v4l2_subdev *subdev; - subdev =media_entity_type (entity) ==MEDIA_ENT_T_V4L2_SUBDEV + subdev = is_media_entity_v4l2_subdev(entity)) ?media_entity_to_v4l2_subdev (entity) :NULL ;if (entity->use_count ==0 && change >0 && subdev !=NULL ) {
@@ -461,7 +461,7 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change)media_entity_graph_walk_start (&graph, entity);while (!ret && (entity =media_entity_graph_walk_next (&graph))) -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_subdev (entity)) ret =iss_pipeline_pm_power_one (entity, change);if (!ret)
@@ -471,7 +471,7 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change)while ((first =media_entity_graph_walk_next (&graph)) && first != entity) -if (media_entity_type (first) !=MEDIA_ENT_T_DEVNODE ) +if (is_media_entity_v4l2_subdev (first))iss_pipeline_pm_power_one (first, -change);return ret;
@@ -590,8 +590,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,break ; pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) + if !is_media_entity_v4l2_subdev(pad->entity))break ; entity = pad->entity;
@@ -658,8 +657,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe,break ; pad =media_entity_remote_pad (pad); -if (pad ==NULL || -media_entity_type (pad->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; entity = pad->entity;
drivers/staging/media/omap4iss/iss_video.c +2 -3
@@ -191,8 +191,7 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad) remote =media_entity_remote_pad (&video->pad); -if (remote ==NULL || -media_entity_type (remote->entity) !=MEDIA_ENT_T_V4L2_SUBDEV ) + if ((!is_media_entity_v4l2_subdev(remote->entity))return NULL ;if (pad)
@@ -217,7 +216,7 @@ iss_video_far_end(struct iss_video *video)if (entity == &video->video.entity)continue ; -if (media_entity_type (entity) !=MEDIA_ENT_T_DEVNODE ) +if (!is_media_entity_v4l2_io (entity))continue ; far_end =to_iss_video (media_entity_to_video_device (entity));
Signature · 1 line
2.4.3
PATCH v7 29/44 omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse
In reply to Mauro Carvalho ChehabOn omap3/omap4/davinci drivers, MEDIA_ENT_T_V4L2_SUBDEV macro is abused in order to "simplify" the pad checks.
Basically, it does a logical or of this macro, in order to check for a local index and if the entity is either a subdev or not.
As we'll get rid of MEDIA_ENT_T_V4L2_SUBDEV macro, replace it by 2 << 16 where it occurs, and add a note saying that the code there is actually a hack.
drivers/media/platform/omap3isp/ispccdc.c +10 -5
@@ -2513,9 +2513,14 @@ static int ccdc_link_setup(struct media_entity *entity,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct isp_ccdc_device *ccdc =v4l2_get_subdevdata (sd);struct isp_device *isp =to_isp_device (ccdc); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case CCDC_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case CCDC_PAD_SINK |2 <<16 :/* Read from the sensor (parallel interface), CCP2, CSI2a or * CSI2c. */
@@ -2543,7 +2548,7 @@ static int ccdc_link_setup(struct media_entity *entity,* Revisit this when it will be implemented, and return -EBUSY for now. */ -case CCDC_PAD_SOURCE_VP |MEDIA_ENT_T_V4L2_SUBDEV : +case CCDC_PAD_SOURCE_VP |2 <<16 :/* Write to preview engine, histogram and H3A. When none of * those links are active, the video port can be disabled. */
@@ -2556,7 +2561,7 @@ static int ccdc_link_setup(struct media_entity *entity, }break ; -case CCDC_PAD_SOURCE_OF |MEDIA_ENT_T_DEVNODE : +case CCDC_PAD_SOURCE_OF :/* Write to memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ccdc->output & ~CCDC_OUTPUT_MEMORY )
@@ -2567,7 +2572,7 @@ static int ccdc_link_setup(struct media_entity *entity, }break ; -case CCDC_PAD_SOURCE_OF |MEDIA_ENT_T_V4L2_SUBDEV : +case CCDC_PAD_SOURCE_OF |2 <<16 :/* Write to resizer */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ccdc->output & ~CCDC_OUTPUT_RESIZER )
drivers/media/platform/omap3isp/ispccp2.c +9 -4
@@ -956,9 +956,14 @@ static int ccp2_link_setup(struct media_entity *entity, {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct isp_ccp2_device *ccp2 =v4l2_get_subdevdata (sd); +int index = local_index; -switch (local->index |media_entity_type (remote->entity)) { -case CCP2_PAD_SINK |MEDIA_ENT_T_DEVNODE : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case CCP2_PAD_SINK :/* read from memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ccp2->input ==CCP2_INPUT_SENSOR )
@@ -970,7 +975,7 @@ static int ccp2_link_setup(struct media_entity *entity, }break ; -case CCP2_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case CCP2_PAD_SINK |2 <<16 :/* read from sensor/phy */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ccp2->input ==CCP2_INPUT_MEMORY )
@@ -981,7 +986,7 @@ static int ccp2_link_setup(struct media_entity *entity, ccp2->input =CCP2_INPUT_NONE ; }break ; -case CCP2_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case CCP2_PAD_SOURCE |2 <<16 :/* write to video port/ccdc */ if (flags &MEDIA_LNK_FL_ENABLED ) ccp2->output =CCP2_OUTPUT_CCDC ;
drivers/media/platform/omap3isp/ispcsi2.c +8 -3
@@ -1144,14 +1144,19 @@ static int csi2_link_setup(struct media_entity *entity,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct isp_csi2_device *csi2 =v4l2_get_subdevdata (sd);struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl; +int index = local->index;/* * The ISP core doesn't support pipelines with multiple video outputs. * Revisit this when it will be implemented, and return -EBUSY for now. */ -switch (local->index |media_entity_type (remote->entity)) { -case CSI2_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case CSI2_PAD_SOURCE :if (flags &MEDIA_LNK_FL_ENABLED ) {if (csi2->output & ~CSI2_OUTPUT_MEMORY )return -EBUSY ;
@@ -1161,7 +1166,7 @@ static int csi2_link_setup(struct media_entity *entity, }break ; -case CSI2_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case CSI2_PAD_SOURCE |2 <<16 :if (flags &MEDIA_LNK_FL_ENABLED ) {if (csi2->output & ~CSI2_OUTPUT_CCDC )return -EBUSY ;
drivers/media/platform/omap3isp/isppreview.c +10 -5
@@ -2144,9 +2144,14 @@ static int preview_link_setup(struct media_entity *entity, {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct isp_prev_device *prev =v4l2_get_subdevdata (sd); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case PREV_PAD_SINK |MEDIA_ENT_T_DEVNODE : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case PREV_PAD_SINK :/* read from memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (prev->input ==PREVIEW_INPUT_CCDC )
@@ -2158,7 +2163,7 @@ static int preview_link_setup(struct media_entity *entity, }break ; -case PREV_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case PREV_PAD_SINK |2 <<16 :/* read from ccdc */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (prev->input ==PREVIEW_INPUT_MEMORY )
@@ -2175,7 +2180,7 @@ static int preview_link_setup(struct media_entity *entity,* Revisit this when it will be implemented, and return -EBUSY for now. */ -case PREV_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +case PREV_PAD_SOURCE :/* write to memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (prev->output & ~PREVIEW_OUTPUT_MEMORY )
@@ -2186,7 +2191,7 @@ static int preview_link_setup(struct media_entity *entity, }break ; -case PREV_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case PREV_PAD_SOURCE |2 <<16 :/* write to resizer */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (prev->output & ~PREVIEW_OUTPUT_RESIZER )
drivers/media/platform/omap3isp/ispresizer.c +9 -4
@@ -1623,9 +1623,14 @@ static int resizer_link_setup(struct media_entity *entity, {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct isp_res_device *res =v4l2_get_subdevdata (sd); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case RESZ_PAD_SINK |MEDIA_ENT_T_DEVNODE : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case RESZ_PAD_SINK :/* read from memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (res->input ==RESIZER_INPUT_VP )
@@ -1637,7 +1642,7 @@ static int resizer_link_setup(struct media_entity *entity, }break ; -case RESZ_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case RESZ_PAD_SINK |2 <<16 :/* read from ccdc or previewer */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (res->input ==RESIZER_INPUT_MEMORY )
@@ -1649,7 +1654,7 @@ static int resizer_link_setup(struct media_entity *entity, }break ; -case RESZ_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +case RESZ_PAD_SOURCE :/* resizer always write to memory */ break ;
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +9 -4
@@ -885,9 +885,14 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct vpfe_ipipeif_device *ipipeif =v4l2_get_subdevdata (sd);struct vpfe_device *vpfe =to_vpfe_device (ipipeif); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case IPIPEIF_PAD_SINK |MEDIA_ENT_T_DEVNODE : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case IPIPEIF_PAD_SINK :/* Single shot mode */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipeif->input =IPIPEIF_INPUT_NONE ;
@@ -896,7 +901,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input =IPIPEIF_INPUT_MEMORY ;break ; -case IPIPEIF_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPEIF_PAD_SINK |2 <<16 :/* read from isif */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipeif->input =IPIPEIF_INPUT_NONE ;
@@ -908,7 +913,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input =IPIPEIF_INPUT_ISIF ;break ; -case IPIPEIF_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPEIF_PAD_SOURCE |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipeif->output =IPIPEIF_OUTPUT_NONE ;break ;
drivers/staging/media/davinci_vpfe/dm365_isif.c +9 -4
@@ -1707,9 +1707,14 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct vpfe_isif_device *isif =v4l2_get_subdevdata (sd); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case ISIF_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case ISIF_PAD_SINK |2 <<16 :/* read from decoder/sensor */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { isif->input =ISIF_INPUT_NONE ;
@@ -1720,7 +1725,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->input =ISIF_INPUT_PARALLEL ;break ; -case ISIF_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +case ISIF_PAD_SOURCE :/* write to memory */ if (flags &MEDIA_LNK_FL_ENABLED ) isif->output =ISIF_OUTPUT_MEMORY ;
@@ -1728,7 +1733,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->output =ISIF_OUTPUT_NONE ;break ; -case ISIF_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case ISIF_PAD_SOURCE |2 <<16 :if (flags &MEDIA_LNK_FL_ENABLED ) isif->output =ISIF_OUTPUT_IPIPEIF ;else
drivers/staging/media/davinci_vpfe/dm365_resizer.c +14 -8
@@ -1655,8 +1655,14 @@ static int resizer_link_setup(struct media_entity *entity,u16 ipipe_source = vpfe_dev->vpfe_ipipe.output;if (&resizer->crop_resizer.subdev == sd) { -switch (local->index |media_entity_type (remote->entity)) { -case RESIZER_CROP_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +int index = local->index; + +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case RESIZER_CROP_PAD_SINK |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->crop_resizer.input =RESIZER_CROP_INPUT_NONE ;
@@ -1676,7 +1682,7 @@ static int resizer_link_setup(struct media_entity *entity,return -EINVAL ;break ; -case RESIZER_CROP_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case RESIZER_CROP_PAD_SOURCE |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->crop_resizer.output =RESIZER_CROP_OUTPUT_NONE ;
@@ -1688,7 +1694,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->crop_resizer.output =RESIZER_A ;break ; -case RESIZER_CROP_PAD_SOURCE2 |MEDIA_ENT_T_V4L2_SUBDEV : +case RESIZER_CROP_PAD_SOURCE2 |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->crop_resizer.output2 =RESIZER_CROP_OUTPUT_NONE ;
@@ -1705,7 +1711,7 @@ static int resizer_link_setup(struct media_entity *entity, } }else if (&resizer->resizer_a.subdev == sd) {switch (local->index |media_entity_type (remote->entity)) { -case RESIZER_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case RESIZER_PAD_SINK |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->resizer_a.input =RESIZER_INPUT_NONE ;break ;
@@ -1715,7 +1721,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_a.input =RESIZER_INPUT_CROP_RESIZER ;break ; -case RESIZER_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +case RESIZER_PAD_SOURCE :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->resizer_a.output =RESIZER_OUTPUT_NONE ;break ;
@@ -1730,7 +1736,7 @@ static int resizer_link_setup(struct media_entity *entity, } }else if (&resizer->resizer_b.subdev == sd) {switch (local->index |media_entity_type (remote->entity)) { -case RESIZER_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case RESIZER_PAD_SINK |2 <<16 :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->resizer_b.input =RESIZER_INPUT_NONE ;break ;
@@ -1740,7 +1746,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_b.input =RESIZER_INPUT_CROP_RESIZER ;break ; -case RESIZER_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +case RESIZER_PAD_SOURCE :if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->resizer_b.output =RESIZER_OUTPUT_NONE ;break ;
drivers/staging/media/omap4iss/iss_csi2.c +8 -3
@@ -1170,14 +1170,19 @@ static int csi2_link_setup(struct media_entity *entity,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct iss_csi2_device *csi2 =v4l2_get_subdevdata (sd);struct iss_csi2_ctrl_cfg *ctrl = &csi2->ctrl; +int index = local->index; + +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ;/* * The ISS core doesn't support pipelines with multiple video outputs. * Revisit this when it will be implemented, and return -EBUSY for now. */ -switch (local->index |media_entity_type (remote->entity)) { -case CSI2_PAD_SOURCE |MEDIA_ENT_T_DEVNODE : +switch (index) { +case CSI2_PAD_SOURCE :if (flags &MEDIA_LNK_FL_ENABLED ) {if (csi2->output & ~CSI2_OUTPUT_MEMORY )return -EBUSY ;
@@ -1187,7 +1192,7 @@ static int csi2_link_setup(struct media_entity *entity, }break ; -case CSI2_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case CSI2_PAD_SOURCE |2 <<16 :if (flags &MEDIA_LNK_FL_ENABLED ) {if (csi2->output & ~CSI2_OUTPUT_IPIPEIF )return -EBUSY ;
drivers/staging/media/omap4iss/iss_ipipeif.c +9 -4
@@ -662,9 +662,14 @@ static int ipipeif_link_setup(struct media_entity *entity,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct iss_ipipeif_device *ipipeif =v4l2_get_subdevdata (sd);struct iss_device *iss =to_iss_device (ipipeif); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case IPIPEIF_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case IPIPEIF_PAD_SINK |2 <<16 :/* Read from the sensor CSI2a or CSI2b. */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipeif->input =IPIPEIF_INPUT_NONE ;
@@ -681,7 +686,7 @@ static int ipipeif_link_setup(struct media_entity *entity,break ; -case IPIPEIF_PAD_SOURCE_ISIF_SF |MEDIA_ENT_T_DEVNODE : +case IPIPEIF_PAD_SOURCE_ISIF_SF :/* Write to memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ipipeif->output & ~IPIPEIF_OUTPUT_MEMORY )
@@ -692,7 +697,7 @@ static int ipipeif_link_setup(struct media_entity *entity, }break ; -case IPIPEIF_PAD_SOURCE_VP |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPEIF_PAD_SOURCE_VP |2 <<16 :/* Send to IPIPE/RESIZER */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ipipeif->output & ~IPIPEIF_OUTPUT_VP )
drivers/staging/media/omap4iss/iss_resizer.c +8 -3
@@ -717,9 +717,14 @@ static int resizer_link_setup(struct media_entity *entity,struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (entity);struct iss_resizer_device *resizer =v4l2_get_subdevdata (sd);struct iss_device *iss =to_iss_device (resizer); +int index = local->index; -switch (local->index |media_entity_type (remote->entity)) { -case RESIZER_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +/* FIXME: this is actually a hack! */ +if (is_media_entity_v4l2_subdev (remote->entity)) + index |=2 <<16 ; + +switch (index) { +case RESIZER_PAD_SINK |2 <<16 :/* Read from IPIPE or IPIPEIF. */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { resizer->input =RESIZER_INPUT_NONE ;
@@ -737,7 +742,7 @@ static int resizer_link_setup(struct media_entity *entity,break ; -case RESIZER_PAD_SOURCE_MEM |MEDIA_ENT_T_DEVNODE : +case RESIZER_PAD_SOURCE_MEM :/* Write to memory */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (resizer->output & ~RESIZER_OUTPUT_MEMORY )
Signature · 1 line
2.4.3
PATCH v7 30/44 s5c73m3: fix subdev type
In reply to Mauro Carvalho ChehabThis sensor driver is abusing MEDIA_ENT_T_V4L2_SUBDEV, creating some subdevs with a non-existing type.
As this is a sensor driver, the proper type is likely MEDIA_ENT_T_CAM_SENSOR.
drivers/media/i2c/s5c73m3/s5c73m3-core.c +2 -2
@@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->sensor_pads[S5C73M3_JPEG_PAD ].flags =MEDIA_PAD_FL_SOURCE ; state->sensor_pads[S5C73M3_ISP_PAD ].flags =MEDIA_PAD_FL_SOURCE ; - sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; + sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; ret =media_entity_init (&sd->entity,S5C73M3_NUM_PADS , state->sensor_pads);
@@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->oif_pads[OIF_ISP_PAD ].flags =MEDIA_PAD_FL_SINK ; state->oif_pads[OIF_JPEG_PAD ].flags =MEDIA_PAD_FL_SINK ; state->oif_pads[OIF_SOURCE_PAD ].flags =MEDIA_PAD_FL_SOURCE ; - oif_sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; + oif_sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; ret =media_entity_init (&oif_sd->entity,OIF_NUM_PADS , state->oif_pads);
Signature · 1 line
2.4.3
PATCH v7 31/44 s5k5baf: fix subdev type
In reply to Mauro Carvalho ChehabX-Patchwork-Delegate: [email protected]
This sensor driver is abusing MEDIA_ENT_T_V4L2_SUBDEV, creating some subdevs with a non-existing type.
As this is a sensor driver, the proper type is likely MEDIA_ENT_T_V4L2_SUBDEV_SENSOR.
drivers/media/i2c/s5k5baf.c +1 -1
@@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS ].flags =MEDIA_PAD_FL_SINK ; state->pads[PAD_OUT ].flags =MEDIA_PAD_FL_SOURCE ; - sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; + sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; ret =media_entity_init (&sd->entity,NUM_ISP_PADS , state->pads);if (!ret)
Signature · 1 line
2.4.3
PATCH v7 32/44 davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse
In reply to Mauro Carvalho ChehabThis driver is abusing MEDIA_ENT_T_V4L2_SUBDEV:
- it uses a hack to check if the remote entity is a subdev;
- it still uses the legacy entity subtype check macro, that will be removed soon.
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +6 -3
@@ -1711,8 +1711,11 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local,struct vpfe_device *vpfe_dev =to_vpfe_device (ipipe);u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input; -switch (local->index |media_entity_type (remote->entity)) { -case IPIPE_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +if (!is_media_entity_v4l2_subdev (remote->entity)) +return -EINVAL ; + +switch (local->index) { +case IPIPE_PAD_SINK :if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipe->input =IPIPE_INPUT_NONE ;break ;
@@ -1725,7 +1728,7 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, ipipe->input =IPIPE_INPUT_CCDC ;break ; -case IPIPE_PAD_SOURCE |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPE_PAD_SOURCE :/* out to RESIZER */ if (flags &MEDIA_LNK_FL_ENABLED ) ipipe->output =IPIPE_OUTPUT_RESIZER ;
drivers/staging/media/davinci_vpfe/vpfe_video.c +2 -3
@@ -88,7 +88,7 @@ vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad) {struct media_pad *remote =media_entity_remote_pad (&video->pad); -if (remote ==NULL || remote->entity->type !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (remote->entity))return NULL ;if (pad) *pad = remote->index;
@@ -243,8 +243,7 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe)/* Retrieve the source format */ pad =media_entity_remote_pad (pad); -if (pad ==NULL || - pad->entity->type !=MEDIA_ENT_T_V4L2_SUBDEV ) +if (!is_media_entity_v4l2_subdev (pad->entity))break ; subdev =media_entity_to_v4l2_subdev (pad->entity);
Signature · 1 line
2.4.3
PATCH v7 33/44 omap4iss: stop MEDIA_ENT_T_V4L2_SUBDEV abuse
In reply to Mauro Carvalho ChehabThis driver is abusing MEDIA_ENT_T_V4L2_SUBDEV, as it uses a hack to check if the remote entity is a subdev. Get rid of it.
drivers/staging/media/omap4iss/iss_ipipe.c +5 -2
@@ -447,8 +447,11 @@ static int ipipe_link_setup(struct media_entity *entity,struct iss_ipipe_device *ipipe =v4l2_get_subdevdata (sd);struct iss_device *iss =to_iss_device (ipipe); +if (!is_media_entity_v4l2_subdev (remote->entity)) +return -EINVAL ; +switch (local->index |media_entity_type (remote->entity)) { -case IPIPE_PAD_SINK |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPE_PAD_SINK :/* Read from IPIPEIF. */ if (!(flags &MEDIA_LNK_FL_ENABLED )) { ipipe->input =IPIPE_INPUT_NONE ;
@@ -463,7 +466,7 @@ static int ipipe_link_setup(struct media_entity *entity,break ; -case IPIPE_PAD_SOURCE_VP |MEDIA_ENT_T_V4L2_SUBDEV : +case IPIPE_PAD_SOURCE_VP :/* Send to RESIZER */ if (flags &MEDIA_LNK_FL_ENABLED ) {if (ipipe->output & ~IPIPE_OUTPUT_VP )
Signature · 1 line
2.4.3
PATCH v7 35/44 media controller: get rid of entity subtype on Kernel
In reply to Mauro Carvalho ChehabDon't use anymore the type/subtype entity data/macros inside the Kernel.
include/media/media-entity.h +0 -10
@@ -185,16 +185,6 @@ struct media_intf_devnode {u32 minor; }; -static inline u32 media_entity_type (struct media_entity *entity) -{ -return entity->type &MEDIA_ENT_TYPE_MASK ; -} - -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->graph_obj.id;
include/uapi/linux/media.h +3 -3
@@ -42,10 +42,8 @@ struct media_device_info {#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) -/* Used values for media_entity_desc::type */ -/* -* Initial value when an entity is created +* Initial value to be used when a new entity is created * Drivers should change it to something useful */ #define MEDIA_ENT_T_UNKNOWN 0x00000000
@@ -96,6 +94,7 @@ struct media_device_info {#define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 7)#define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 8) +#ifndef __KERNEL__/* Legacy symbols used to avoid userspace compilation breakages */ #define MEDIA_ENT_TYPE_SHIFT 16#define MEDIA_ENT_TYPE_MASK 0x00ff0000
@@ -109,6 +108,7 @@ struct media_device_info {#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) +#endif /* Entity types */
Signature · 1 line
2.4.3
PATCH v7 36/44 DocBook: update descriptions for the media controller entities
In reply to Mauro Carvalho ChehabCleanup the media controller entities description:
- remove MEDIA_ENT_T_DEVNODE and MEDIA_ENT_T_V4L2_SUBDEV entity types, as they don't mean anything;
- add MEDIA_ENT_T_UNKNOWN with a proper description;
- remove ALSA and FB entity types. Those should not be used, as the types are deprecated. We'll soon be adidng ALSA, but with a different entity namespace;
- improve the description of some entities.
Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +17 -28
@@ -179,70 +179,59 @@ <colspec colname="c2"/> <tbody valign="top"> <row> - <entry><constant>MEDIA_ENT_T_DEVNODE</constant></entry> - <entry>Unknown device node</entry> + <entry><constant>MEDIA_ENT_T_UNKNOWN</constant></entry> + <entry>Unknown entity. That generally indicates that + a driver didn't initialize properly the entity, with is a Kernel bug</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_VIDEO</constant></entry> - <entry>V4L video, radio or vbi device node</entry> - </row> - <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_FB</constant></entry> - <entry>Frame buffer device node</entry> - </row> - <row> - <entry><constant>MEDIA_ENT_T_DEVNODE_ALSA</constant></entry> - <entry>ALSA card</entry> + <entry>V4L video streaming input or output entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_DVB_DEMOD</constant></entry> - <entry>DVB frontend devnode</entry> + <entry>DVB demodulator entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_DVB_DEMUX</constant></entry> - <entry>DVB demux devnode</entry> + <entry>DVB demux entity. Could be implemented on hardware or in Kernelspace</entry> </row> <row> <entry><constant>MEDIA_ENT_T_DVB_TSOUT</constant></entry> - <entry>DVB DVR devnode</entry> + <entry>DVB Transport Stream output entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_DVB_CA</constant></entry> - <entry>DVB CAM devnode</entry> + <entry>DVB Conditional Access module (CAM) entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_DVB_DEMOD_NET_DECAP</constant></entry> - <entry>DVB network devnode</entry> - </row> - <row> - <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV</constant></entry> - <entry>Unknown V4L sub-device</entry> + <entry>DVB network ULE/MLE desencapsulation entity. Could be implemented on hardware or in Kernelspace</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_SENSOR</constant></entry> - <entry>Video sensor</entry> + <entry>Camera video sensor entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_FLASH</constant></entry> - <entry>Flash controller</entry> + <entry>Flash controller entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_LENS</constant></entry> - <entry>Lens controller</entry> + <entry>Lens controller entity</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_DECODER</constant></entry> - <entry>Video decoder, the basic function of the video decoder is to - accept analogue video from a wide variety of sources such as + <entry>Analog video decoder, the basic function of the video decoder + is to accept analogue video from a wide variety of sources such as broadcast, DVD players, cameras and video cassette recorders, in - either NTSC, PAL or HD format and still occasionally SECAM, separate - it into its component parts, luminance and chrominance, and output + either NTSC, PAL, SECAM or HD format, separating the stream + into its component parts, luminance and chrominance, and output it in some digital video standard, with appropriate embedded timing signals.</entry> </row> <row> <entry><constant>MEDIA_ENT_T_V4L2_SUBDEV_TUNER</constant></entry> - <entry>TV and/or radio tuner</entry> + <entry>Digital TV, analog TV, radio and/or software radio tuner</entry> </row> </tbody> </tgroup>
Signature · 1 line
2.4.3
PATCH v7 37/44 dvb: modify core to implement interfaces/entities at MC new gen
In reply to Mauro Carvalho ChehabThe Media Controller New Generation redefines the types for both interfaces and entities to be used on DVB. Make the needed changes at the DVB core for all interfaces, entities and data and interface links to appear in the graph.
drivers/media/dvb-core/dmxdev.c +2 -2
@@ -1242,9 +1242,9 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter) }dvb_register_device (dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev, -DVB_DEVICE_DEMUX ); +DVB_DEVICE_DEMUX , dmxdev->filternum);dvb_register_device (dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, - dmxdev,DVB_DEVICE_DVR ); + dmxdev,DVB_DEVICE_DVR , dmxdev->filternum);dvb_ringbuffer_init (&dmxdev->dvr_buffer,NULL ,8192 );
drivers/media/dvb-core/dvb_ca_en50221.c +1 -1
@@ -1694,7 +1694,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, pubca->private = ca;/* register the DVB device */ - ret =dvb_register_device (dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,DVB_DEVICE_CA ); + ret =dvb_register_device (dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,DVB_DEVICE_CA ,0 );if (ret) goto free_slot_info;
drivers/media/dvb-core/dvb_frontend.c +1 -1
@@ -2755,7 +2755,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb, fe->dvb->num, fe->id, fe->ops.info.name);dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, - fe,DVB_DEVICE_FRONTEND ); + fe,DVB_DEVICE_FRONTEND ,0 );/* * Initialize the cache to the proper values according with the
drivers/media/dvb-core/dvb_net.c +1 -1
@@ -1503,6 +1503,6 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet, dvbnet->state[i] =0 ;return dvb_register_device (adap, &dvbnet->dvbdev, &dvbdev_net, - dvbnet,DVB_DEVICE_NET ); + dvbnet,DVB_DEVICE_NET ,0 ); }EXPORT_SYMBOL (dvb_net_init);
drivers/media/dvb-core/dvbdev.c +124 -21
242 lines not on this page · raw message
drivers/media/dvb-core/dvbdev.h +6 -3
@@ -102,9 +102,11 @@ struct dvb_device {const char *name;/* Allocated and filled inside dvbdev.c */ -struct media_entity *entity;struct media_intf_devnode *intf_devnode; -struct media_pad *pads; + +unsigned tsout_num_entities; +struct media_entity *entity, *tsout_entity; +struct media_pad *pads, *tsout_pads;#endif void *priv;
@@ -120,7 +122,8 @@ extern int dvb_register_device (struct dvb_adapter *adap,struct dvb_device **pdvbdev, const struct dvb_device *template, void *priv, - int type); + int type, + int demux_sink_pads);extern void dvb_unregister_device (struct dvb_device *dvbdev);
drivers/media/firewire/firedtv-ci.c +1 -1
@@ -241,7 +241,7 @@ int fdtv_ca_register(struct firedtv *fdtv)return -EFAULT ; err =dvb_register_device (&fdtv->adapter, &fdtv->cadev, - &fdtv_ca, fdtv,DVB_DEVICE_CA ); + &fdtv_ca, fdtv,DVB_DEVICE_CA ,0 );if (stat.ca_application_info ==0 )dev_err (fdtv->device,"CaApplicationInfo is not set\n" );
drivers/media/pci/bt8xx/dst_ca.c +2 -1
@@ -705,7 +705,8 @@ struct dvb_device *dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_struct dvb_device *dvbdev;dprintk (verbose,DST_CA_ERROR ,1 ,"registering DST-CA device" ); -if (dvb_register_device (dvb_adapter, &dvbdev, &dvbdev_ca, dst,DVB_DEVICE_CA ) ==0 ) { +if (dvb_register_device (dvb_adapter, &dvbdev, &dvbdev_ca, dst, +DVB_DEVICE_CA ,0 ) ==0 ) { dst->dst_ca = dvbdev;return dst->dst_ca; }
drivers/media/pci/ddbridge/ddbridge-core.c +1 -1
@@ -1065,7 +1065,7 @@ static int ddb_ci_attach(struct ddb_port *port) port->en, 0, 1); ret =dvb_register_device (&port->output->adap, &port->output->dev, &dvbdev_ci, (void *) port->output, -DVB_DEVICE_SEC ); +DVB_DEVICE_SEC ,0 );return ret; }
drivers/media/pci/ngene/ngene-core.c +1 -1
@@ -1513,7 +1513,7 @@ static int init_channel(struct ngene_channel *chan)set_transfer (&chan->dev->channel[2 ],1 );dvb_register_device (adapter, &chan->ci_dev, &ngene_dvbdev_ci, (void *) chan, -DVB_DEVICE_SEC ); +DVB_DEVICE_SEC ,0 );if (!chan->ci_dev) goto err; }
drivers/media/pci/ttpci/av7110.c +1 -1
@@ -1361,7 +1361,7 @@ static int av7110_register(struct av7110 *av7110)#ifdef CONFIG_DVB_AV7110_OSD dvb_register_device (&av7110->dvb_adapter, &av7110->osd_dev, - &dvbdev_osd, av7110,DVB_DEVICE_OSD ); + &dvbdev_osd, av7110,DVB_DEVICE_OSD ,0 );#endif dvb_net_init (&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
drivers/media/pci/ttpci/av7110_av.c +2 -2
@@ -1589,10 +1589,10 @@ int av7110_av_register(struct av7110 *av7110)memset (&av7110->video_size,0 ,sizeof (video_size_t));dvb_register_device (&av7110->dvb_adapter, &av7110->video_dev, - &dvbdev_video, av7110,DVB_DEVICE_VIDEO ); + &dvbdev_video, av7110,DVB_DEVICE_VIDEO ,0 );dvb_register_device (&av7110->dvb_adapter, &av7110->audio_dev, - &dvbdev_audio, av7110,DVB_DEVICE_AUDIO ); + &dvbdev_audio, av7110,DVB_DEVICE_AUDIO ,0 );return 0 ; }
drivers/media/pci/ttpci/av7110_ca.c +1 -1
@@ -378,7 +378,7 @@ static struct dvb_device dvbdev_ca = {int av7110_ca_register (struct av7110 *av7110) {return dvb_register_device (&av7110->dvb_adapter, &av7110->ca_dev, - &dvbdev_ca, av7110,DVB_DEVICE_CA ); + &dvbdev_ca, av7110,DVB_DEVICE_CA ,0 ); }void av7110_ca_unregister (struct av7110 *av7110)
Signature · 1 line
2.4.3
PATCH v7 38/44 media: report if a pad is sink or source at debug msg
In reply to Mauro Carvalho ChehabSometimes, it is important to see if the created pad is sink or source. Add info to track that.
drivers/media/dvb-core/dvbdev.c +15 -11
@@ -527,8 +527,8 @@ void dvb_create_media_graph(struct dvb_adapter *adap)struct media_entity *entity, *tuner =NULL , *demod =NULL ;struct media_entity *demux =NULL , *ca =NULL ;struct media_interface *intf; -unsigned demux_pad =1 ; -unsigned dvr_pad =1 ; +unsigned demux_pad =0 ; +unsigned dvr_pad =0 ;if (!mdev)return ;
@@ -560,15 +560,19 @@ void dvb_create_media_graph(struct dvb_adapter *adap)/* Create demux links for each ringbuffer/pad */ if (demux) { -if (entity->type ==MEDIA_ENT_T_DVB_TSOUT ) { -if (!strncmp (entity->name,DVR_TSOUT , -sizeof (DVR_TSOUT ))) -media_create_pad_link (demux, ++dvr_pad, - entity,0 ,0 ); -if (!strncmp (entity->name,DEMUX_TSOUT , -sizeof (DEMUX_TSOUT ))) -media_create_pad_link (demux, ++demux_pad, - entity,0 ,0 ); +media_device_for_each_entity (entity, mdev) { +if (entity->type ==MEDIA_ENT_T_DVB_TSOUT ) { +if (!strncmp (entity->name,DVR_TSOUT , +strlen (DVR_TSOUT ))) +media_create_pad_link (demux, + ++dvr_pad, + entity,0 ,0 ); +if (!strncmp (entity->name,DEMUX_TSOUT , +strlen (DEMUX_TSOUT ))) +media_create_pad_link (demux, + ++demux_pad, + entity,0 ,0 ); + } } }
drivers/media/media-entity.c +5 -2
@@ -121,8 +121,11 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj)struct media_pad *pad =gobj_to_pad (gobj);dev_dbg (gobj->mdev->dev, -"%s: id 0x%08x pad#%d: '%s':%d\n" , - event_name, gobj->id,media_localid (gobj), +"%s: id 0x%08x %s%spad#%d: '%s':%d\n" , + event_name, gobj->id, + pad->flags &MEDIA_PAD_FL_SINK ?" sink " :"" , + pad->flags &MEDIA_PAD_FL_SOURCE ?"source " :"" , +media_localid (gobj), pad->entity->name, pad->index);break ; }
Signature · 1 line
2.4.3
PATCH v7 39/44 uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
In reply to Mauro Carvalho ChehabAdd a new ioctl that will report the entire topology on one go.
include/media/media-entity.h +2 -0
@@ -181,6 +181,8 @@ struct media_interface {*/ struct media_intf_devnode {struct media_interface intf; + +/* Should match the fields at media_v2_intf_devnode */ u32 major;u32 minor; };
include/uapi/linux/media.h +84 -1
95 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH v7 39/44] [media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
Quoted 97 lines · Mauro Carvalho Chehab
Add a new ioctl that will report the entire topology on one go.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +2
-0@@ -181,6 +181,8 @@ struct media_interface {*/ struct media_intf_devnode {struct media_interface intf; + +/* Should match the fields at media_v2_intf_devnode */ u32 major;u32 minor; };include/uapi/linux/media.h +70
-1@@ -238,11 +238,94 @@ struct media_links_enum {#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) -/* TBD: declare the structs needed for the new G_TOPOLOGY ioctl */ +/* +* MC next gen API definitions +* +* NOTE: The declarations below are close to the MC RFC for the Media +* Controller, the next generation. Yet, there are a few adjustments +* to do, as we want to be able to have a functional API before +* the MC properties change. Those will be properly marked below. +* Please also notice that I removed "num_pads", "num_links", +* from the proposal, as a proper userspace application will likely +* use lists for pads/links, just as we intend todo in Kernelspace. +* The API definition should be freed from fields that are bound to +* some specific data structure. +* +* FIXME: Currently, I opted to name the new types as "media_v2", as this +* won't cause any conflict with the Kernelspace namespace, nor with +* the previous kAPI media_*_desc namespace. This can be changed +* latter, before the adding this API upstream. +*/ + + +#define MEDIA_NEW_LNK_FL_ENABLED MEDIA_LNK_FL_ENABLED +#define MEDIA_NEW_LNK_FL_IMMUTABLE MEDIA_LNK_FL_IMMUTABLE +#define MEDIA_NEW_LNK_FL_DYNAMIC MEDIA_NEW_FL_DYNAMIC +#define MEDIA_NEW_LNK_FL_INTERFACE_LINK (1 << 3) + +struct media_v2_entity { +__u32 id; +char name[64 ];/* FIXME: move to a property? (RFC says so) */ +__u16 reserved[14 ]; +}; + +/* Should match the specific fields at media_intf_devnode */ +struct media_v2_intf_devnode { +__u32 major; +__u32 minor; +}; + +struct media_v2_interface { +__u32 id; +__u32 intf_type; +__u32 flags; +__u32 reserved[9 ]; + +union { +struct media_v2_intf_devnode devnode; +__u32 raw[16 ]; + }; +}; + +struct media_v2_pad { +__u32 id; +__u32 entity_id; +__u32 flags; +__u16 reserved[9 ]; +}; + +struct media_v2_link { +__u32 id; +__u32 source_id; +__u32 sink_id; +__u32 flags; +__u32 reserved[5 ]; +}; + +struct media_v2_topology { +__u32 topology_version; + +__u32 num_entities; +struct media_v2_entity *entities; +
include/uapi/linux/media.h struct media_links_enum { · line 320
Quoted 10 lines
include/uapi/linux/media.h +10
-0+__u32 num_interfaces; +struct media_v2_interface *interfaces; + +__u32 num_pads; +struct media_v2_pad *pads; + +__u32 num_links; +struct media_v2_link *links; + +__u32 reserved[64 ];
As I suggested elsewhere, replace this by:
struct {
__u32 num_reserved;
void *ptr_reserved;
} reserved_ptrs[8];This will keep the number of reserved num/pointer pairs identical between 32 and 64 bit architectures. Without that doing compat32 handling will be very difficult indeed.
We might want a separate __u32 reserved[] array so we're able to add non-pointer fields in the future.
Regards,
Hans
Quoted 12 lines
include/uapi/linux/media.h +4
-0+}; + +/* ioctls */ #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) +#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)#endif /* __LINUX_MEDIA_H */
A message that is not in the archive (sent off-list or not yet received): 55DC366C.5050509-qWit8jRvyhVmR6Xm/[email protected]
Re: [PATCH v7 39/44] [media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
Em Tue, 25 Aug 2015 11:33:32 +0200
Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]> escreveu:
Quoted 116 lines · Mauro Carvalho Chehab
Quoted 97 lines
Add a new ioctl that will report the entire topology on one go.
Signed-off-by Mauro Carvalho Chehab <[email protected]>include/media/media-entity.h +2
-0@@ -181,6 +181,8 @@ struct media_interface {*/ struct media_intf_devnode {struct media_interface intf; + +/* Should match the fields at media_v2_intf_devnode */ u32 major;u32 minor; };include/uapi/linux/media.h +70
-1@@ -238,11 +238,94 @@ struct media_links_enum {#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) -/* TBD: declare the structs needed for the new G_TOPOLOGY ioctl */ +/* +* MC next gen API definitions +* +* NOTE: The declarations below are close to the MC RFC for the Media +* Controller, the next generation. Yet, there are a few adjustments +* to do, as we want to be able to have a functional API before +* the MC properties change. Those will be properly marked below. +* Please also notice that I removed "num_pads", "num_links", +* from the proposal, as a proper userspace application will likely +* use lists for pads/links, just as we intend todo in Kernelspace. +* The API definition should be freed from fields that are bound to +* some specific data structure. +* +* FIXME: Currently, I opted to name the new types as "media_v2", as this +* won't cause any conflict with the Kernelspace namespace, nor with +* the previous kAPI media_*_desc namespace. This can be changed +* latter, before the adding this API upstream. +*/ + + +#define MEDIA_NEW_LNK_FL_ENABLED MEDIA_LNK_FL_ENABLED +#define MEDIA_NEW_LNK_FL_IMMUTABLE MEDIA_LNK_FL_IMMUTABLE +#define MEDIA_NEW_LNK_FL_DYNAMIC MEDIA_NEW_FL_DYNAMIC +#define MEDIA_NEW_LNK_FL_INTERFACE_LINK (1 << 3) + +struct media_v2_entity { +__u32 id; +char name[64 ];/* FIXME: move to a property? (RFC says so) */ +__u16 reserved[14 ]; +}; + +/* Should match the specific fields at media_intf_devnode */ +struct media_v2_intf_devnode { +__u32 major; +__u32 minor; +}; + +struct media_v2_interface { +__u32 id; +__u32 intf_type; +__u32 flags; +__u32 reserved[9 ]; + +union { +struct media_v2_intf_devnode devnode; +__u32 raw[16 ]; + }; +}; + +struct media_v2_pad { +__u32 id; +__u32 entity_id; +__u32 flags; +__u16 reserved[9 ]; +}; + +struct media_v2_link { +__u32 id; +__u32 source_id; +__u32 sink_id; +__u32 flags; +__u32 reserved[5 ]; +}; + +struct media_v2_topology { +__u32 topology_version; + +__u32 num_entities; +struct media_v2_entity *entities; +include/uapi/linux/media.h struct media_links_enum { · line 320
Quoted 10 lines
include/uapi/linux/media.h +10
-0+__u32 num_interfaces; +struct media_v2_interface *interfaces; + +__u32 num_pads; +struct media_v2_pad *pads; + +__u32 num_links; +struct media_v2_link *links; + +__u32 reserved[64 ];As I suggested elsewhere, replace this by:
struct { __u32 num_reserved; void *ptr_reserved; } reserved_ptrs[8];
Quoted 6 lines
This will keep the number of reserved num/pointer pairs identical between 32 and 64 bit architectures. Without that doing compat32 handling will be very difficult indeed.
We might want a separate
__u32reserved[] array so we're able to add non-pointer fields in the future.
OK.
Quoted 17 lines
Regards,
Hans
Quoted 12 lines
include/uapi/linux/media.h +4
-0+}; + +/* ioctls */ #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) +#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)#endif /* __LINUX_MEDIA_H */
PATCH v7 40/44 media: Use a macro to interate between all interfaces
In reply to Mauro Carvalho ChehabJust like we do with entities, use a similar macro for the interfaces loop.
drivers/media/dvb-core/dvbdev.c +1 -1
@@ -577,7 +577,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap) }/* Create indirect interface links for tuner and TS out entities */ -list_for_each_entry (intf, &mdev->interfaces, list) { +media_device_for_each_intf (intf, mdev) {if (intf->type ==MEDIA_INTF_T_DVB_FE && tuner)media_create_intf_link (tuner, intf,0 );
include/media/media-device.h +5 -0
@@ -113,6 +113,11 @@ struct media_device *media_device_find_devres(struct device *dev);#define media_device_for_each_entity (entity, mdev) \ list_for_each_entry(entity, &(mdev)->entities, list) +/* Iterate over all interfaces. */ +#define media_device_for_each_intf (intf, mdev) \ + list_for_each_entry(intf, &(mdev)->interfaces, list) + +#else static inline int media_device_register (struct media_device *mdev) {
Signature · 1 line
2.4.3
Re: [PATCH v7 40/44] [media] media: Use a macro to interate between all interfaces
Quoted 4 lines · Mauro Carvalho Chehab
Just like we do with entities, use a similar macro for the interfaces loop.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
I think this patch can be moved to an earlier place in this patch series.
Regards,
Hans
Quoted 31 lines
drivers/media/dvb-core/dvbdev.c +1
-1@@ -577,7 +577,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap) }/* Create indirect interface links for tuner and TS out entities */ -list_for_each_entry (intf, &mdev->interfaces, list) { +media_device_for_each_intf (intf, mdev) {if (intf->type ==MEDIA_INTF_T_DVB_FE && tuner)media_create_intf_link (tuner, intf,0 );include/media/media-device.h +5
-0@@ -113,6 +113,11 @@ struct media_device *media_device_find_devres(struct device *dev);#define media_device_for_each_entity (entity, mdev) \ list_for_each_entry(entity, &(mdev)->entities, list) +/* Iterate over all interfaces. */ +#define media_device_for_each_intf (intf, mdev) \ + list_for_each_entry(intf, &(mdev)->interfaces, list) + +#else static inline int media_device_register (struct media_device *mdev) {
PATCH v7 41/44 media: move mdev list init to gobj
In reply to Mauro Carvalho ChehabLet's control the topology changes inside the graph_object. So, move the removal of interfaces/entitis from the mdev lists to media_gobj_init() and media_gobj_remove().
The main reason is that mdev should have lists for all object types, as the new MC api will require to store objects on separate places.
drivers/media/media-device.c +2 -4
@@ -415,7 +415,7 @@ void media_device_unregister(struct media_device *mdev)struct media_entity *entity;struct media_entity *next; -list_for_each_entry_safe (entity, next, &mdev->entities, list) +list_for_each_entry_safe (entity, next, &mdev->entities, graph_obj.list)media_device_unregister_entity (entity);device_remove_file (&mdev->devnode.dev, &dev_attr_model);
@@ -443,7 +443,6 @@ int __must_check media_device_register_entity(struct media_device *mdev,spin_lock (&mdev->lock);/* 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++)
@@ -473,7 +472,7 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); -list_for_each_entry_safe (link, tmp, &entity->links, list) { +list_for_each_entry_safe (link, tmp, &entity->links, graph_obj.list) {media_gobj_remove (&link->graph_obj);list_del (&link->list);kfree (link);
@@ -481,7 +480,6 @@ void media_device_unregister_entity(struct media_entity *entity)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); entity->graph_obj.mdev =NULL ; }
drivers/media/media-entity.c +11 -3
@@ -168,6 +168,7 @@ void media_gobj_init(struct media_device *mdev,switch (type) {case MEDIA_GRAPH_ENTITY : gobj->id =media_gobj_gen_id (type, ++mdev->entity_id); +list_add_tail (&gobj->list, &mdev->entities);break ;case MEDIA_GRAPH_PAD : gobj->id =media_gobj_gen_id (type, ++mdev->pad_id);
@@ -176,6 +177,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ;case MEDIA_GRAPH_INTF_DEVNODE : +list_add_tail (&gobj->list, &mdev->interfaces); gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id);break ; }
@@ -191,6 +193,15 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { +/* Remove the object from mdev list */ +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : +case MEDIA_GRAPH_INTF_DEVNODE : +list_del (&gobj->list); +default : +break ; + } +dev_dbg_obj (__func__, gobj); }
@@ -878,8 +889,6 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); -list_add_tail (&intf->list, &mdev->interfaces); -return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);
@@ -887,7 +896,6 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); -list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);
include/media/media-device.h +2 -2
@@ -111,11 +111,11 @@ struct media_device *media_device_find_devres(struct device *dev);/* Iterate over all entities. */ #define media_device_for_each_entity (entity, mdev) \ - list_for_each_entry(entity, &(mdev)->entities, list) + list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)/* Iterate over all interfaces. */ #define media_device_for_each_intf (intf, mdev) \ - list_for_each_entry(intf, &(mdev)->interfaces, list) + list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)#else
include/media/media-entity.h +1 -2
@@ -66,6 +66,7 @@ enum media_gobj_type {struct media_gobj {struct media_device *mdev;u32 id; +struct list_head list; };
@@ -114,7 +115,6 @@ struct media_entity_operations {struct media_entity {struct media_gobj graph_obj;/* should be the first object */ -struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ u32 revision;/* Entity revision, driver specific */
@@ -166,7 +166,6 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; -struct list_head list;struct list_head links;u32 type;u32 flags;
Signature · 1 line
2.4.3
Re: [PATCH v7 41/44] [media] media: move mdev list init to gobj
Quoted 2 lines · Mauro Carvalho Chehab
Let's control the topology changes inside the
graph_object. So, move the removal of interfaces/entitis from the mdev
s/entitis/entities/
Quoted 5 lines
lists to
media_gobj_init()andmedia_gobj_remove().The main reason is that mdev should have lists for all object types, as the new MC api will require to store objects on separate places.
s/on/in/
Quoted 62 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +2
-4@@ -415,7 +415,7 @@ void media_device_unregister(struct media_device *mdev)struct media_entity *entity;struct media_entity *next; -list_for_each_entry_safe (entity, next, &mdev->entities, list) +list_for_each_entry_safe (entity, next, &mdev->entities, graph_obj.list)media_device_unregister_entity (entity);device_remove_file (&mdev->devnode.dev, &dev_attr_model);@@ -443,7 +443,6 @@ int __must_check media_device_register_entity(struct media_device *mdev,spin_lock (&mdev->lock);/* 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++)@@ -473,7 +472,7 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); -list_for_each_entry_safe (link, tmp, &entity->links, list) { +list_for_each_entry_safe (link, tmp, &entity->links, graph_obj.list) {media_gobj_remove (&link->graph_obj);list_del (&link->list);kfree (link);@@ -481,7 +480,6 @@ void media_device_unregister_entity(struct media_entity *entity)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); entity->graph_obj.mdev =NULL ; }drivers/media/media-entity.c +2
-0@@ -168,6 +168,7 @@ void media_gobj_init(struct media_device *mdev,switch (type) {case MEDIA_GRAPH_ENTITY : gobj->id =media_gobj_gen_id (type, ++mdev->entity_id); +list_add_tail (&gobj->list, &mdev->entities);break ;case MEDIA_GRAPH_PAD : gobj->id =media_gobj_gen_id (type, ++mdev->pad_id);@@ -176,6 +177,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id =media_gobj_gen_id (type, ++mdev->link_id);break ;case MEDIA_GRAPH_INTF_DEVNODE : +list_add_tail (&gobj->list, &mdev->interfaces); gobj->id =media_gobj_gen_id (type, ++mdev->intf_devnode_id);break ; }
drivers/media/media-entity.c void media_gobj_init(struct media_device *mdev, · line 200
Quoted 8 lines
drivers/media/media-entity.c +5
-0@@ -191,6 +193,15 @@ void media_gobj_init(struct media_device *mdev,*/ void media_gobj_remove (struct media_gobj *gobj) { +/* Remove the object from mdev list */ +switch (media_type (gobj)) { +case MEDIA_GRAPH_ENTITY : +case MEDIA_GRAPH_INTF_DEVNODE : +list_del (&gobj->list);
Missing break!
Quoted 64 lines
drivers/media/media-entity.c +4
-3+default : +break ; + } +dev_dbg_obj (__func__, gobj); }@@ -878,8 +889,6 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,media_gobj_init (mdev,MEDIA_GRAPH_INTF_DEVNODE , &devnode->intf.graph_obj); -list_add_tail (&intf->list, &mdev->interfaces); -return devnode; }EXPORT_SYMBOL_GPL (media_devnode_create);@@ -887,7 +896,6 @@ EXPORT_SYMBOL_GPL(media_devnode_create);void media_devnode_remove (struct media_intf_devnode *devnode) {media_gobj_remove (&devnode->intf.graph_obj); -list_del (&devnode->intf.list);kfree (devnode); }EXPORT_SYMBOL_GPL (media_devnode_remove);include/media/media-device.h +2
-2@@ -111,11 +111,11 @@ struct media_device *media_device_find_devres(struct device *dev);/* Iterate over all entities. */ #define media_device_for_each_entity (entity, mdev) \ - list_for_each_entry(entity, &(mdev)->entities, list) + list_for_each_entry(entity, &(mdev)->entities, graph_obj.list)/* Iterate over all interfaces. */ #define media_device_for_each_intf (intf, mdev) \ - list_for_each_entry(intf, &(mdev)->interfaces, list) + list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list)#else include/media/media-entity.h +1
-1@@ -66,6 +66,7 @@ enum media_gobj_type {struct media_gobj {struct media_device *mdev;u32 id; +struct list_head list; };@@ -114,7 +115,6 @@ struct media_entity_operations {struct media_entity {struct media_gobj graph_obj;/* should be the first object */ -struct list_head list;const char *name;/* Entity name */ u32 type;/* Entity type (MEDIA_ENT_T_*) */ u32 revision;/* Entity revision, driver specific */
include/media/media-entity.h struct media_entity { · line 171
Quoted 7 lines
include/media/media-entity.h +0
-1@@ -166,7 +166,6 @@ struct media_entity {*/ struct media_interface {struct media_gobj graph_obj; -struct list_head list;struct list_head links;u32 type;u32 flags;
Regards,
Hans
PATCH v7 42/44 media-device: add pads and links to media_device
In reply to Mauro Carvalho ChehabThe MC next gen API sends objects to userspace grouped by their types.
In the case of pads and links, in order to improve performance and have a simpler code, the best is to store them also on separate linked lists at MC.
If we don't do that, we would need this kind of interaction to send data to userspace (code is in structured english):
for each entity:
for each pad:
store pads
for each entity:
for each link:
store link
for each interface:
for each link:
store link
With would require one nexted loop for pads and two nested loops for links. By using separate linked lists for them, just one loop would be enough.
drivers/media/media-device.c +2 -1
@@ -382,6 +382,8 @@ int __must_check __media_device_register(struct media_device *mdev,INIT_LIST_HEAD (&mdev->entities);INIT_LIST_HEAD (&mdev->interfaces); +INIT_LIST_HEAD (&mdev->pads); +INIT_LIST_HEAD (&mdev->links);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);
@@ -474,7 +476,6 @@ void media_device_unregister_entity(struct media_entity *entity)spin_lock (&mdev->lock);list_for_each_entry_safe (link, tmp, &entity->links, graph_obj.list) {media_gobj_remove (&link->graph_obj); -list_del (&link->list);kfree (link); }for (i =0 ; i < entity->num_pads; i++)
drivers/media/media-entity.c +3 -7
@@ -172,9 +172,11 @@ void media_gobj_init(struct media_device *mdev,break ;case MEDIA_GRAPH_PAD : gobj->id =media_gobj_gen_id (type, ++mdev->pad_id); +list_add_tail (&gobj->list, &mdev->pads);break ;case MEDIA_GRAPH_LINK : gobj->id =media_gobj_gen_id (type, ++mdev->link_id); +list_add_tail (&gobj->list, &mdev->links);break ;case MEDIA_GRAPH_INTF_DEVNODE :list_add_tail (&gobj->list, &mdev->interfaces);
@@ -194,13 +196,7 @@ void media_gobj_init(struct media_device *mdev,void media_gobj_remove (struct media_gobj *gobj) {/* Remove the object from mdev list */ -switch (media_type (gobj)) { -case MEDIA_GRAPH_ENTITY : -case MEDIA_GRAPH_INTF_DEVNODE : -list_del (&gobj->list); -default : -break ; - } +list_del (&gobj->list);dev_dbg_obj (__func__, gobj); }
include/media/media-device.h +12 -0
@@ -47,6 +47,8 @@ struct device;* @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @interfaces: List of registered interfaces +* @pads: List of registered pads +* @links: List of registered links * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback
@@ -79,6 +81,8 @@ struct media_device {struct list_head entities;struct list_head interfaces; +struct list_head pads; +struct list_head links;/* Protects the entities list */ spinlock_t lock;
@@ -117,6 +121,14 @@ struct media_device *media_device_find_devres(struct device *dev);#define media_device_for_each_intf (intf, mdev) \ list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list) +/* Iterate over all pads. */ +#define media_device_for_each_pad (pad, mdev) \ + list_for_each_entry(pad, &(mdev)->pads, graph_obj.list) + +/* Iterate over all links. */ +#define media_device_for_each_link (link, mdev) \ + list_for_each_entry(link, &(mdev)->links, graph_obj.list) +#else static inline int media_device_register (struct media_device *mdev)
Signature · 1 line
2.4.3