Changes on MC core due to MC workshop discussion
Subsystems (23)
v2 cover Changes on MC core due to MC workshop discussion
This is the second version of an initial set of patches showing the approach I'm taking in order to fulfill all the MC needs that was discussed on the 3 day MC summit in Helsinki.
The goal of this patchset is:
1) to create a common struct that will be embedded on all internal structs that represents the comon data that will be used by all kinds of objects;
2) to have an unique object ID for each object in the graph. The object ID will be needed by the userspace API in the future, as discussed during the MC workshop;
3) to create objects to represent Kernel->userspace interfaces;
4) to extend the link support to allow linking interfaces to entities.
On version 2, I removed the kref, as some people at the #v4l channel are not convinced about its need. So, let's postpone such discussion when we start introducing patches that will actually do dynamic object removal in runtime.
As suggested, I'll be sending incremental patches and avoiding to do a large set of changes into one changeset series. That basically means that those patches aren't tested yet (except for compilation tests).
Along this patch series, I'll be calling "object" as any "symbol" that belongs to a media graph, like processing entities, connectors, links, pads, interfaces.
As said on the goals of this RFC, on version 2 of this patch series, we're coming with the new concept: interfaces.
An interface is a graph object that does the interaction between Kernelspace <===> Userspace. While the code written for interface creation and interface<==>entity link is generic, currently I added support only for the type of interface currently used at the existing MC graphs: device node interfaces. We should add other types of interfaces in a future patchset. For example, we need to add support for network interfaces in order to fulfill the needs of the DVB subsystem. We'll also need to add support for sysfs interfaces in order to support IIO and remote controllers.
Those API changes are aligned with the RFC for the userspace API proposed by Hans Verkuil:
http://www.spinics.net/lists/linux-media/msg92166.html
The only difference is that I'm using a single counter to generate an unique object ID, while Hans proposal is to use one per object type. As explained on my comments on the last patch series, the rationale is to simply simplify the code, helping to make the internal API changes clearer. We can change this latter before adding support for the userspace API.
I suspect that we'll also need another type to represent groups of objects, but this will be covered on future patches if/when needed.
No userspace API changes here, just changes at the internal structs that contains the media graph objects and some new helper functions.
===========
Future work
===========
I think that, after changing the MC core to support the new proposed API, a next step would be to simplify the internal representation of the media objects, in order to make it easier to be reused on other subsystems like IIO and to spend less memory. With that regards, I think that we can get rid of some fields at the existing structures:
struct media_link.reverse - Currently we create two copies of the same link, in order to use at the graph traversal. I think we can remove it and use just one copy;
struct media_entity - well, there are several things that we can get hid there:
- parent - we're already storing it at the objects;
- id - we have already an unique ID at the objects;
- type - this should be replaced by properties;
- revision - not used, afaikt;
- group_id - groups should really be a new object type that will have the list of object IDs that belong to the group.
- num_links/num_backlinks - those are used only at the userspace interface, but we need to track link creation/removal just to feed those things. I would remove those and add a logic at media_device.c to count;
- num_pads - if we convert pads to lists (with seems to be the best thing, as not all entities need pads), then we can get rid of this too;
- union info - this should be retrieved via the interface, and not via the entity.
Yet, the above are suggestions for some future next steps. I won't probably address the above, except if needed in order to support the DVB or ALSA needs.
Mauro Carvalho Chehab (16):
media: Add some fields to store graph objects
media: Add a common embeed struct for all media graph objects
media: add functions to inialize media_graph_obj
media: ensure that entities will have an object ID
media: initialize PAD objects
media: initialize the graph object inside the media links
media: get rid of unused "extra_links" param on media_entity_init()
media: convert links from array to list
media: use media_graph_obj for link endpoints
media: rename the function that create pad links
FIXUP: source link removal on failure
media: move __media_entity_remove_link to avoid prototype
media: make the internal function to create links more generic
media: add a generic function to remove a link
media: rename media_entity_remove_foo functions
media: add functions to allow creating interfaces
Documentation/media-framework.txt | 2 +- Documentation/video4linux/v4l2-framework.txt | 4 +- Documentation/zh_CN/video4linux/v4l2-framework.txt | 4 +- drivers/media/dvb-core/dvb_frontend.c | 10 +- drivers/media/dvb-core/dvbdev.c | 10 +- drivers/media/i2c/ad9389b.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/adv7511.c | 2 +- drivers/media/i2c/adv7604.c | 2 +- drivers/media/i2c/adv7842.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/mt9m032.c | 2 +- drivers/media/i2c/mt9p031.c | 2 +- drivers/media/i2c/mt9t001.c | 2 +- drivers/media/i2c/mt9v032.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 8 +- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 6 +- drivers/media/i2c/s5k6a3.c | 2 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 8 +- drivers/media/i2c/tc358743.c | 2 +- drivers/media/i2c/tvp514x.c | 2 +- drivers/media/i2c/tvp7002.c | 2 +- drivers/media/media-device.c | 48 ++- drivers/media/media-entity.c | 367 ++++++++++++++------- drivers/media/platform/exynos4-is/fimc-capture.c | 4 +- drivers/media/platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-isp.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 4 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 2 +- drivers/media/platform/exynos4-is/media-dev.c | 18 +- drivers/media/platform/exynos4-is/mipi-csis.c | 2 +- drivers/media/platform/omap3isp/isp.c | 22 +- drivers/media/platform/omap3isp/ispccdc.c | 6 +- drivers/media/platform/omap3isp/ispccp2.c | 4 +- drivers/media/platform/omap3isp/ispcsi2.c | 4 +- drivers/media/platform/omap3isp/isppreview.c | 6 +- drivers/media/platform/omap3isp/ispresizer.c | 6 +- drivers/media/platform/omap3isp/ispstat.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 2 +- drivers/media/platform/s3c-camif/camif-capture.c | 4 +- drivers/media/platform/s3c-camif/camif-core.c | 4 +- drivers/media/platform/vsp1/vsp1_drv.c | 4 +- drivers/media/platform/vsp1/vsp1_entity.c | 2 +- drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +- drivers/media/usb/cx231xx/cx231xx-video.c | 18 +- drivers/media/usb/uvc/uvc_entity.c | 6 +- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-device.c | 2 +- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 6 +- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 4 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 4 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 14 +- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- drivers/staging/media/omap4iss/iss.c | 18 +- drivers/staging/media/omap4iss/iss_csi2.c | 6 +- drivers/staging/media/omap4iss/iss_ipipe.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 4 +- drivers/staging/media/omap4iss/iss_resizer.c | 4 +- drivers/staging/media/omap4iss/iss_video.c | 2 +- include/media/media-device.h | 4 + include/media/media-entity.h | 130 +++++++- 80 files changed, 575 insertions(+), 302 deletions(-)
Signature · 1 line
2.4.3
RFC PATCH v2 1/16 media: Add some fields to store graph objects
We'll need unique IDs for graph objects and a way to associate them with the media interface.
So, add an atomic var to be used to create unique IDs and a list to store such objects.
drivers/media/media-device.c +4 -0
@@ -396,6 +396,10 @@ int __must_check __media_device_register(struct media_device *mdev,return ret; } +/* Initialize media graph object list and ID */ +atomic_set (&mdev->last_obj_id,0 ); +INIT_LIST_HEAD (&mdev->object_list); +return 0 ; }EXPORT_SYMBOL_GPL (__media_device_register);
include/media/media-device.h +4 -0
@@ -78,6 +78,10 @@ struct media_device {int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); + +/* Used by media_graph stuff */ +atomic_t last_obj_id; +struct list_head object_list; };/* Supported link_notify @notification values. */
Signature · 1 line
2.4.3
Sakari Ailus
maintainerRe: [PATCH RFC v2 01/16] media: Add some fields to store graph objects
Hi Mauro,
Quoted 28 lines · Mauro Carvalho Chehab
We'll need unique IDs for graph objects and a way to associate them with the media interface.
So, add an atomic var to be used to create unique IDs and a list to store such objects.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +4
-0@@ -396,6 +396,10 @@ int __must_check __media_device_register(struct media_device *mdev,return ret; } +/* Initialize media graph object list and ID */ +atomic_set (&mdev->last_obj_id,0 ); +INIT_LIST_HEAD (&mdev->object_list); +return 0 ; }EXPORT_SYMBOL_GPL (__media_device_register);include/media/media-device.h +0
-0
include/media/media-device.h struct media_device { · line 87
Quoted 10 lines
include/media/media-device.h +4
-0@@ -78,6 +78,10 @@ struct media_device {int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); + +/* Used by media_graph stuff */ +atomic_t last_obj_id; +struct list_head object_list; };/* Supported link_notify @notification values. */
Instead of starting with rework of the MC internals, what would you think of separating interfaces from entities first, and see how that would be used by a driver (e.g. DVB)? I think a simple linked list would do per entity, no links would be needed at this point in the internal representation.
I'll review this better during the next week.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH RFC v2 01/16] media: Add some fields to store graph objects
Em Sat, 8 Aug 2015 02:14:46 +0300
Sakari Ailus <[email protected]> escreveu:
Quoted 40 lines
Hi Mauro,
Quoted 37 lines · Mauro Carvalho Chehab
We'll need unique IDs for graph objects and a way to associate them with the media interface.
So, add an atomic var to be used to create unique IDs and a list to store such objects.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +4
-0@@ -396,6 +396,10 @@ int __must_check __media_device_register(struct media_device *mdev,return ret; } +/* Initialize media graph object list and ID */ +atomic_set (&mdev->last_obj_id,0 ); +INIT_LIST_HEAD (&mdev->object_list); +return 0 ; }EXPORT_SYMBOL_GPL (__media_device_register);include/media/media-device.h +4
-0@@ -78,6 +78,10 @@ struct media_device {int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); + +/* Used by media_graph stuff */ +atomic_t last_obj_id; +struct list_head object_list; };
Quoted 5 lines
include/media/media-device.h struct media_device { · line 87
Quoted 1 line
include/media/media-device.h +0
-0/* Supported link_notify @notification values. */ Instead of starting with rework of the MC internals, what would you think of separating interfaces from entities first, and see how that would be used by a driver (e.g. DVB)?
Because that won't attend the requirements we've mapped during the workshop. We did some radical changes there, and we want to keep the structs more generic, in order to allow MC usage on other subsystems like IIO.
Also, starting the changes at the drivers would just make a way worse and harder to work, as it would use a hacky temporary representation that will need to change as the MC internals change. That would mean more code to be changed latter and more complex patchsets, as we fix the MC internals.
You should remind that one of the most complex goals is that we'll need to support dynamic entity/pad/link/interface creation/removal. That will require changes at the MC internals anyway. So, it is better to do such changes first in a way that it would be easier to latter add support for it, and, once we have a kABI that works, add the needed things at the drivers side.
With this patch series, the MC internals are better, and will easily support the new API that was designed during the meeting.
So, my plan for the next week is to test it, in order to be sure that everything keeps working, and then add interfaces and the new userspace ioctls.
Quoted 2 lines
I think a simple linked list would do per entity, no links would be needed at this point in the internal representation.
The entity/interface links are now represented as linked lists (and so the pad/pad links). By sharing the same struct, no code duplication, making easier to maintain. Also, if we need graph traversal, the code is there.
For now, I opted to use a separate list inside the entity for the entity/interface. This is not really needed, but it would mean a shorter time when checking all entity-interface links. The drawback is that it makes harder for graph traversal. So, eventually, we might want to change it in some future, specially if we need to represent indirect control and do graph traversal for interfaces. I guess we may need graph traversal for the Kernelspace-userspace sinks, like ALSA PCM capture interfaces. So, we may need to revisit that.
Quoted 1 line
I'll review this better during the next week.
Ok.
Regards,
Mauro
RFC PATCH v2 2/16 media: Add a common embeed struct for all 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;
- be able to dynamically create/remove objects;
- be able to group objects;
- keep the object in memory until we stop use it.
Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common.
include/media/media-entity.h +42 -0
@@ -28,10 +28,50 @@#include <linux/list.h> #include <linux/media.h> +/* Enums used internally at the media controller to represent graphs */ + +/** +* enum media_graph_type - type of a graph element +* +* @MEDIA_GRAPH_ENTITY: Identify a media entity +* @MEDIA_GRAPH_PAD: Identify a media PAD +* @MEDIA_GRAPH_LINK: Identify a media link +*/ +enum media_graph_type { +MEDIA_GRAPH_ENTITY , +MEDIA_GRAPH_PAD , +MEDIA_GRAPH_LINK , +}; + + +/* Structs to represent the objects that belong to a media graph */ + +/** +* struct media_graph_obj - Define a graph object. +* +* @list: List of media graph objects +* @obj_id: Non-zero object ID identifier. The ID should be unique +* inside a media_device +* @type: Type of the graph object +* @mdev: Media device that contains the object +* object before stopping using it +* +* All elements on the media graph should have this struct embedded +*/ +struct media_graph_obj { +struct list_head list; +struct list_head group; +u32 obj_id; +enum media_graph_type type; +struct media_device *mdev; +}; + +struct media_pipeline { };struct media_link { +struct media_graph_obj graph_obj;struct media_pad *source;/* Source pad */ struct media_pad *sink;/* Sink pad */ struct media_link *reverse;/* Link in the reverse direction */
@@ -39,6 +79,7 @@ struct media_link { };struct media_pad { +struct media_graph_obj 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_*) */
@@ -61,6 +102,7 @@ struct media_entity_operations { };struct media_entity { +struct media_graph_obj 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
Signature · 1 line
2.4.3
RFC PATCH v2 3/16 media: add functions to inialize media_graph_obj
In reply to Mauro Carvalho ChehabWe need to initialize the common media_graph_obj that it is now embedded inside each media controller object.
Latter patches will use those functions to ensure that the object will be properly initialized.
drivers/media/media-entity.c +38 -0
@@ -27,6 +27,44 @@#include <media/media-device.h> /** +* graph_obj_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_graph_obj 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 graph_obj_init (struct media_device *mdev, +enum media_graph_type type, +struct media_graph_obj *gobj) +{ +INIT_LIST_HEAD (&gobj->list); + +list_add_tail (&gobj->list, &mdev->object_list); + gobj->obj_id =atomic_inc_return (&mdev->last_obj_id); + gobj->type = type; + gobj->mdev = mdev; +} + +/** +* graph_obj_remove - Stop using a graph object on a media device +* +* @graph_obj: Pointer to the object +* +* This is called at media_device_unregister_*() routines, and removes a +* graph object from the mdev object lists. +*/ +void graph_obj_remove (struct media_graph_obj *gobj) +{ +list_del (&gobj->list); +} + +/** * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads.
include/media/media-entity.h +8 -0
@@ -168,6 +168,14 @@ struct media_entity_graph {int top; }; +#define gobj_to_entity (gobj) \ + container_of(gobj, struct media_entity, graph_obj) + +void graph_obj_init (struct media_device *mdev, +enum media_graph_type type, +struct media_graph_obj *gobj); +void graph_obj_remove (struct media_graph_obj *gobj); +int media_entity_init (struct media_entity *entity,u16 num_pads,struct media_pad *pads,u16 extra_links);void media_entity_cleanup (struct media_entity *entity);
Signature · 1 line
2.4.3
RFC PATCH v2 4/16 media: ensure that entities will have an object ID
In reply to Mauro Carvalho ChehabAll objects need an object ID. However, as v4l2 subdevs embeed entities internally, the code needs to manually check if the entity objects were not properly initialized and do it at entity register time.
drivers/media/media-device.c +8 -0
@@ -435,6 +435,13 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity->parent = mdev;spin_lock (&mdev->lock); +/* Initialize media_graph_obj embedded at the entity */ +graph_obj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj); + +/* +* FIXME: should it use the unique object ID or would it +* break support on the legacy MC API? +*/ if (entity->id ==0 ) entity->id = mdev->entity_id++;else
@@ -461,6 +468,7 @@ void media_device_unregister_entity(struct media_entity *entity)return ;spin_lock (&mdev->lock); +graph_obj_remove (&entity->graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock); entity->parent =NULL ;
Signature · 1 line
2.4.3
RFC PATCH v2 5/16 media: initialize PAD objects
In reply to Mauro Carvalho ChehabPAD embedded objects also need to be initialized. Those are currently created via media_entity_init() and, once created, never change.
While this will likely change in the future, for now we can just initialize those objects once, when registering the entity.
drivers/media/media-device.c +10 -0
@@ -430,6 +430,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;
@@ -438,6 +440,11 @@ int __must_check media_device_register_entity(struct media_device *mdev,/* Initialize media_graph_obj embedded at the entity */ graph_obj_init (mdev,MEDIA_GRAPH_ENTITY , &entity->graph_obj); +/* Initialize objects at the pads */ +for (i =0 ; entity->num_pads; i++) +graph_obj_init (mdev,MEDIA_GRAPH_PAD , + &entity->pads[i].graph_obj); +/* * FIXME: should it use the unique object ID or would it * break support on the legacy MC API?
@@ -462,6 +469,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;if (mdev ==NULL )
@@ -469,6 +477,8 @@ void media_device_unregister_entity(struct media_entity *entity)spin_lock (&mdev->lock);graph_obj_remove (&entity->graph_obj); +for (i =0 ; entity->num_pads; i++) +graph_obj_remove (&entity->pads[i].graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock); entity->parent =NULL ;
Signature · 1 line
2.4.3
RFC PATCH v2 6/16 media: initialize the graph object inside the media links
In reply to Mauro Carvalho ChehabWhen a new link is created, we need to initialize the object inside it.
drivers/media/media-device.c +2 -0
@@ -479,6 +479,8 @@ void media_device_unregister_entity(struct media_entity *entity)graph_obj_remove (&entity->graph_obj);for (i =0 ; entity->num_pads; i++)graph_obj_remove (&entity->pads[i].graph_obj); +for (i =0 ; entity->num_links; i++) +graph_obj_remove (&entity->links[i].graph_obj);list_del (&entity->list);spin_unlock (&mdev->lock); entity->parent =NULL ;
drivers/media/media-entity.c +4 -0
@@ -469,6 +469,10 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) entity->links = links; } +/* Initialize graph object embedded at the new link */ +graph_obj_init (entity->parent,MEDIA_GRAPH_LINK , + &entity->links[entity->num_links].graph_obj); +return &entity->links[entity->num_links++]; }
Signature · 1 line
2.4.3
RFC PATCH v2 7/16 media: get rid of unused "extra_links" param on media_entity_init()
In reply to Mauro Carvalho ChehabCurrently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver.
As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first.
Documentation/media-framework.txt +1 -1
@@ -104,7 +104,7 @@ although drivers can allocate entities directly. Drivers initialize entities by calling media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads, u16 extra_links); + struct media_pad *pads); The media_entity name, type, flags, revision and group_id fields can be initialized before or after calling media_entity_init. Entities embedded in
Documentation/video4linux/v4l2-framework.txt +2 -2
@@ -300,7 +300,7 @@ calling media_entity_init(): struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads, 0); + err = media_entity_init(&sd->entity, npads, pads); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields, but the revision
@@ -700,7 +700,7 @@ calling media_entity_init(): struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad, 0); + err = media_entity_init(&vdev->entity, 1, pad); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields.
Documentation/zh_CN/video4linux/v4l2-framework.txt +2 -2
@@ -295,7 +295,7 @@ owner ??????????????? i2c ????????????????????????????????????????????? struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads, 0); + err = media_entity_init(&sd->entity, npads, pads); pads ???????????????????????????????????????????????? media_entity ??? type ??? name ????????????????????????revision ?????????????????????
@@ -602,7 +602,7 @@ v4l2_file_operations ???????????? file_operations ??????????????????????????? struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad, 0); + err = media_entity_init(&vdev->entity, 1, pad); pads ?????????????????????????????????????????????????????? media_entity ??? type ??? name ??????
drivers/media/dvb-core/dvbdev.c +1 -1
@@ -249,7 +249,7 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, }if (npads) - ret =media_entity_init (dvbdev->entity, npads, dvbdev->pads,0 ); + ret =media_entity_init (dvbdev->entity, npads, dvbdev->pads);if (!ret) ret =media_device_register_entity (dvbdev->adapter->mdev, dvbdev->entity);
drivers/media/i2c/ad9389b.c +1 -1
@@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags =MEDIA_PAD_FL_SINK ; - err =media_entity_init (&sd->entity,1 , &state->pad,0 ); + err =media_entity_init (&sd->entity,1 , &state->pad);if (err) goto err_hdl;
drivers/media/i2c/adp1653.c +1 -1
@@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client,if (ret) goto free_and_quit; - ret =media_entity_init (&flash->subdev.entity,0 ,NULL ,0 ); + ret =media_entity_init (&flash->subdev.entity,0 ,NULL );if (ret <0 ) goto free_and_quit;
drivers/media/i2c/adv7180.c +1 -1
@@ -1214,7 +1214,7 @@ static int adv7180_probe(struct i2c_client *client, state->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.flags |=MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; - ret =media_entity_init (&sd->entity,1 , &state->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &state->pad);if (ret) goto err_free_ctrl;
drivers/media/i2c/adv7511.c +1 -1
@@ -1482,7 +1482,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags =MEDIA_PAD_FL_SINK ; - err =media_entity_init (&sd->entity,1 , &state->pad,0 ); + err =media_entity_init (&sd->entity,1 , &state->pad);if (err) goto err_hdl;
drivers/media/i2c/adv7604.c +1 -1
@@ -3198,7 +3198,7 @@ static int adv76xx_probe(struct i2c_client *client, state->pads[state->source_pad].flags =MEDIA_PAD_FL_SOURCE ; err =media_entity_init (&sd->entity, state->source_pad +1 , - state->pads,0 ); + state->pads);if (err) goto err_work_queues;
drivers/media/i2c/adv7842.c +1 -1
@@ -3309,7 +3309,7 @@ static int adv7842_probe(struct i2c_client *client, adv7842_delayed_work_enable_hotplug); state->pad.flags =MEDIA_PAD_FL_SOURCE ; - err =media_entity_init (&sd->entity,1 , &state->pad,0 ); + err =media_entity_init (&sd->entity,1 , &state->pad);if (err) goto err_work_queues;
drivers/media/i2c/as3645a.c +1 -1
@@ -827,7 +827,7 @@ static int as3645a_probe(struct i2c_client *client,if (ret <0 ) goto done; - ret =media_entity_init (&flash->subdev.entity,0 ,NULL ,0 ); + ret =media_entity_init (&flash->subdev.entity,0 ,NULL );if (ret <0 ) goto done;
drivers/media/i2c/cx25840/cx25840-core.c +1 -1
@@ -5211,7 +5211,7 @@ static int cx25840_probe(struct i2c_client *client, sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; ret =media_entity_init (&sd->entity,ARRAY_SIZE (state->pads), - state->pads,0 ); + state->pads);if (ret <0 ) {v4l_info (client,"failed to initialize media entity!\n" );return ret;
drivers/media/i2c/lm3560.c +1 -1
@@ -365,7 +365,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash, rval =lm3560_init_controls (flash, led_no);if (rval) goto err_out; - rval =media_entity_init (&flash->subdev_led[led_no].entity,0 ,NULL ,0 ); + rval =media_entity_init (&flash->subdev_led[led_no].entity,0 ,NULL );if (rval <0 ) goto err_out; flash->subdev_led[led_no].entity.type =MEDIA_ENT_T_V4L2_SUBDEV_FLASH ;
drivers/media/i2c/lm3646.c +1 -1
@@ -282,7 +282,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash) rval =lm3646_init_controls (flash);if (rval) goto err_out; - rval =media_entity_init (&flash->subdev_led.entity,0 ,NULL ,0 ); + rval =media_entity_init (&flash->subdev_led.entity,0 ,NULL );if (rval <0 ) goto err_out; flash->subdev_led.entity.type =MEDIA_ENT_T_V4L2_SUBDEV_FLASH ;
drivers/media/i2c/m5mols/m5mols_core.c +1 -1
@@ -975,7 +975,7 @@ static int m5mols_probe(struct i2c_client *client, sd->internal_ops = &m5mols_subdev_internal_ops; info->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&sd->entity,1 , &info->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &info->pad);if (ret <0 )return ret; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ;
drivers/media/i2c/mt9m032.c +1 -1
@@ -799,7 +799,7 @@ static int mt9m032_probe(struct i2c_client *client, sensor->subdev.ctrl_handler = &sensor->ctrls; sensor->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&sensor->subdev.entity,1 , &sensor->pad,0 ); + ret =media_entity_init (&sensor->subdev.entity,1 , &sensor->pad);if (ret <0 ) goto error_ctrl;
drivers/media/i2c/mt9p031.c +1 -1
@@ -1112,7 +1112,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops; mt9p031->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&mt9p031->subdev.entity,1 , &mt9p031->pad,0 ); + ret =media_entity_init (&mt9p031->subdev.entity,1 , &mt9p031->pad);if (ret <0 ) goto done;
drivers/media/i2c/mt9t001.c +1 -1
@@ -933,7 +933,7 @@ static int mt9t001_probe(struct i2c_client *client, mt9t001->subdev.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; mt9t001->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&mt9t001->subdev.entity,1 , &mt9t001->pad,0 ); + ret =media_entity_init (&mt9t001->subdev.entity,1 , &mt9t001->pad); done:if (ret <0 ) {
drivers/media/i2c/mt9v032.c +1 -1
@@ -1046,7 +1046,7 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->subdev.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; mt9v032->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&mt9v032->subdev.entity,1 , &mt9v032->pad,0 ); + ret =media_entity_init (&mt9v032->subdev.entity,1 , &mt9v032->pad);if (ret <0 ) goto err;
drivers/media/i2c/noon010pc30.c +1 -1
@@ -780,7 +780,7 @@ static int noon010_probe(struct i2c_client *client, info->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,1 , &info->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &info->pad);if (ret <0 ) goto np_err;
drivers/media/i2c/ov2659.c +1 -1
@@ -1450,7 +1450,7 @@ static int ov2659_probe(struct i2c_client *client,#if defined(CONFIG_MEDIA_CONTROLLER ) ov2659->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,1 , &ov2659->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &ov2659->pad);if (ret <0 ) {v4l2_ctrl_handler_free (&ov2659->ctrls);return ret;
drivers/media/i2c/ov9650.c +1 -1
@@ -1501,7 +1501,7 @@ static int ov965x_probe(struct i2c_client *client, ov965x->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,1 , &ov965x->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &ov965x->pad);if (ret <0 )return ret;
drivers/media/i2c/s5c73m3/s5c73m3-core.c +2 -2
@@ -1691,7 +1691,7 @@ static int s5c73m3_probe(struct i2c_client *client, sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; ret =media_entity_init (&sd->entity,S5C73M3_NUM_PADS , - state->sensor_pads,0 ); + state->sensor_pads);if (ret <0 )return ret;
@@ -1707,7 +1707,7 @@ static int s5c73m3_probe(struct i2c_client *client, oif_sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV ; ret =media_entity_init (&oif_sd->entity,OIF_NUM_PADS , - state->oif_pads,0 ); + state->oif_pads);if (ret <0 )return ret;
drivers/media/i2c/s5k4ecgx.c +1 -1
@@ -962,7 +962,7 @@ static int s5k4ecgx_probe(struct i2c_client *client, priv->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,1 , &priv->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &priv->pad);if (ret)return ret;
drivers/media/i2c/s5k5baf.c +2 -2
@@ -1905,7 +1905,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->cis_pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,NUM_CIS_PADS , &state->cis_pad,0 ); + ret =media_entity_init (&sd->entity,NUM_CIS_PADS , &state->cis_pad);if (ret <0 ) goto err;
@@ -1920,7 +1920,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 ; - ret =media_entity_init (&sd->entity,NUM_ISP_PADS , state->pads,0 ); + ret =media_entity_init (&sd->entity,NUM_ISP_PADS , state->pads);if (!ret)return 0 ;
drivers/media/i2c/s5k6a3.c +1 -1
@@ -333,7 +333,7 @@ static int s5k6a3_probe(struct i2c_client *client, sensor->format.height =S5K6A3_DEFAULT_HEIGHT ; sensor->pad.flags =MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&sd->entity,1 , &sensor->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &sensor->pad);if (ret <0 )return ret;
drivers/media/i2c/s5k6aa.c +1 -1
@@ -1578,7 +1578,7 @@ static int s5k6aa_probe(struct i2c_client *client, s5k6aa->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.type =MEDIA_ENT_T_V4L2_SUBDEV_SENSOR ; - ret =media_entity_init (&sd->entity,1 , &s5k6aa->pad,0 ); + ret =media_entity_init (&sd->entity,1 , &s5k6aa->pad);if (ret)return ret;
drivers/media/i2c/smiapp/smiapp-core.c +2 -2
@@ -2488,7 +2488,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)continue ; rval =media_entity_init (&this->sd.entity, - this->npads, this->pads,0 ); + this->npads, this->pads);if (rval) {dev_err (&client->dev,"media_entity_init failed\n" );
@@ -3078,7 +3078,7 @@ static int smiapp_probe(struct i2c_client *client, sensor->src->pads[0 ].flags =MEDIA_PAD_FL_SOURCE ; rval =media_entity_init (&sensor->src->sd.entity,2 , - sensor->src->pads,0 ); + sensor->src->pads);if (rval <0 )return rval;
drivers/media/i2c/tc358743.c +1 -1
@@ -1880,7 +1880,7 @@ static int tc358743_probe(struct i2c_client *client, } state->pad.flags =MEDIA_PAD_FL_SOURCE ; - err =media_entity_init (&sd->entity,1 , &state->pad,0 ); + err =media_entity_init (&sd->entity,1 , &state->pad);if (err <0 ) goto err_hdl;
drivers/media/i2c/tvp514x.c +1 -1
@@ -1097,7 +1097,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) decoder->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; decoder->sd.entity.flags |=MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; - ret =media_entity_init (&decoder->sd.entity,1 , &decoder->pad,0 ); + ret =media_entity_init (&decoder->sd.entity,1 , &decoder->pad);if (ret <0 ) {v4l2_err (sd,"%s decoder driver failed to register !!\n" , sd->name);
drivers/media/i2c/tvp7002.c +1 -1
@@ -1014,7 +1014,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) device->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; device->sd.entity.flags |=MEDIA_ENT_T_V4L2_SUBDEV_DECODER ; - error =media_entity_init (&device->sd.entity,1 , &device->pad,0 ); + error =media_entity_init (&device->sd.entity,1 , &device->pad);if (error <0 )return error;#endif
drivers/media/media-entity.c +2 -3
@@ -68,7 +68,6 @@ void graph_obj_remove(struct media_graph_obj *gobj)* media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. -* @extra_links: Initial estimate of the number of extra links. * @pads: Array of 'num_pads' pads. * * The total number of pads is an intrinsic property of entities known by the
@@ -90,10 +89,10 @@ void graph_obj_remove(struct media_graph_obj *gobj)*/ int media_entity_init (struct media_entity *entity,u16 num_pads, -struct media_pad *pads,u16 extra_links) +struct media_pad *pads) {struct media_link *links; -unsigned int max_links = num_pads + extra_links; +unsigned int max_links = num_pads;unsigned int i; links =kzalloc (max_links *sizeof (links[0 ]),GFP_KERNEL );
drivers/media/platform/exynos4-is/fimc-capture.c +2 -2
@@ -1804,7 +1804,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, vid_cap->wb_fmt.code = fmt->mbus_code; vid_cap->vd_pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&vfd->entity,1 , &vid_cap->vd_pad,0 ); + ret =media_entity_init (&vfd->entity,1 , &vid_cap->vd_pad);if (ret) goto err_free_ctx;
@@ -1897,7 +1897,7 @@ int fimc_initialize_capture_subdev(struct fimc_dev *fimc) fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_FIFO ].flags =MEDIA_PAD_FL_SINK ; fimc->vid_cap.sd_pads[FIMC_SD_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_init (&sd->entity,FIMC_SD_PADS_NUM , - fimc->vid_cap.sd_pads,0 ); + fimc->vid_cap.sd_pads);if (ret)return ret;
drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -1
@@ -618,7 +618,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp, vdev->lock = &isp->video_lock; iv->pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&vdev->entity,1 , &iv->pad,0 ); + ret =media_entity_init (&vdev->entity,1 , &iv->pad);if (ret <0 )return ret;
drivers/media/platform/exynos4-is/fimc-isp.c +1 -1
@@ -709,7 +709,7 @@ int fimc_isp_subdev_create(struct fimc_isp *isp) isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_FIFO ].flags =MEDIA_PAD_FL_SOURCE ; isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_DMA ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_init (&sd->entity,FIMC_ISP_SD_PADS_NUM , - isp->subdev_pads,0 ); + isp->subdev_pads);if (ret)return ret;
drivers/media/platform/exynos4-is/fimc-lite.c +2 -2
@@ -1322,7 +1322,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)return ret; fimc->vd_pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&vfd->entity,1 , &fimc->vd_pad,0 ); + ret =media_entity_init (&vfd->entity,1 , &fimc->vd_pad);if (ret <0 )return ret;
@@ -1437,7 +1437,7 @@ static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc) fimc->subdev_pads[FLITE_SD_PAD_SOURCE_DMA ].flags =MEDIA_PAD_FL_SOURCE ; fimc->subdev_pads[FLITE_SD_PAD_SOURCE_ISP ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_init (&sd->entity,FLITE_SD_PADS_NUM , - fimc->subdev_pads,0 ); + fimc->subdev_pads);if (ret)return ret;
drivers/media/platform/exynos4-is/fimc-m2m.c +1 -1
@@ -738,7 +738,7 @@ int fimc_register_m2m_device(struct fimc_dev *fimc,return PTR_ERR (fimc->m2m.m2m_dev); } - ret =media_entity_init (&vfd->entity,0 ,NULL ,0 ); + ret =media_entity_init (&vfd->entity,0 ,NULL );if (ret) goto err_me;
drivers/media/platform/exynos4-is/mipi-csis.c +1 -1
@@ -866,7 +866,7 @@ static int s5pcsis_probe(struct platform_device *pdev) state->pads[CSIS_PAD_SINK ].flags =MEDIA_PAD_FL_SINK ; state->pads[CSIS_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_init (&state->sd.entity, -CSIS_PADS_NUM , state->pads,0 ); +CSIS_PADS_NUM , state->pads);if (ret <0 ) goto e_clkdis;
drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -2650,7 +2650,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) pads[CCDC_PAD_SOURCE_OF ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &ccdc_media_ops; - ret =media_entity_init (me,CCDC_PADS_NUM , pads,0 ); + ret =media_entity_init (me,CCDC_PADS_NUM , pads);if (ret <0 )return ret;
drivers/media/platform/omap3isp/ispccp2.c +1 -1
@@ -1071,7 +1071,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) pads[CCP2_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &ccp2_media_ops; - ret =media_entity_init (me,CCP2_PADS_NUM , pads,0 ); + ret =media_entity_init (me,CCP2_PADS_NUM , pads);if (ret <0 )return ret;
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -1245,7 +1245,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) | MEDIA_PAD_FL_MUST_CONNECT; me->ops = &csi2_media_ops; - ret =media_entity_init (me,CSI2_PADS_NUM , pads,0 ); + ret =media_entity_init (me,CSI2_PADS_NUM , pads);if (ret <0 )return ret;
drivers/media/platform/omap3isp/isppreview.c +1 -1
@@ -2282,7 +2282,7 @@ static int preview_init_entities(struct isp_prev_device *prev) pads[PREV_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &preview_media_ops; - ret =media_entity_init (me,PREV_PADS_NUM , pads,0 ); + ret =media_entity_init (me,PREV_PADS_NUM , pads);if (ret <0 )return ret;
drivers/media/platform/omap3isp/ispresizer.c +1 -1
@@ -1728,7 +1728,7 @@ static int resizer_init_entities(struct isp_res_device *res) pads[RESZ_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &resizer_media_ops; - ret =media_entity_init (me,RESZ_PADS_NUM , pads,0 ); + ret =media_entity_init (me,RESZ_PADS_NUM , pads);if (ret <0 )return ret;
drivers/media/platform/omap3isp/ispstat.c +1 -1
@@ -1029,7 +1029,7 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name, stat->pad.flags =MEDIA_PAD_FL_SINK |MEDIA_PAD_FL_MUST_CONNECT ; me->ops =NULL ; -return media_entity_init (me,1 , &stat->pad,0 ); +return media_entity_init (me,1 , &stat->pad); } int omap3isp_stat_init(struct ispstat *stat, const char *name,
drivers/media/platform/omap3isp/ispvideo.c +1 -1
@@ -1368,7 +1368,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name)if (IS_ERR (video->alloc_ctx))return PTR_ERR (video->alloc_ctx); - ret =media_entity_init (&video->video.entity,1 , &video->pad,0 ); + ret =media_entity_init (&video->video.entity,1 , &video->pad);if (ret <0 ) {vb2_dma_contig_cleanup_ctx (video->alloc_ctx);return ret;
drivers/media/platform/s3c-camif/camif-capture.c +2 -2
@@ -1159,7 +1159,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx) goto err_vd_rel; vp->pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&vfd->entity,1 , &vp->pad,0 ); + ret =media_entity_init (&vfd->entity,1 , &vp->pad);if (ret) goto err_vd_rel;
@@ -1575,7 +1575,7 @@ int s3c_camif_create_subdev(struct camif_dev *camif) camif->pads[CAMIF_SD_PAD_SOURCE_P ].flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_init (&sd->entity,CAMIF_SD_PADS_NUM , - camif->pads,0 ); + camif->pads);if (ret)return ret;
drivers/media/platform/vsp1/vsp1_entity.c +1 -1
@@ -220,7 +220,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,/* Initialize the media entity. */ return media_entity_init (&entity->subdev.entity, num_pads, - entity->pads,0 ); + entity->pads); }void vsp1_entity_destroy (struct vsp1_entity *entity)
drivers/media/platform/vsp1/vsp1_video.c +1 -1
@@ -1221,7 +1221,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) video->pipe.state =VSP1_PIPELINE_STOPPED ;/* Initialize the media entity... */ - ret =media_entity_init (&video->video.entity,1 , &video->pad,0 ); + ret =media_entity_init (&video->video.entity,1 , &video->pad);if (ret <0 )return ret;
drivers/media/platform/xilinx/xilinx-dma.c +1 -1
@@ -676,7 +676,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, dma->pad.flags = type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ?MEDIA_PAD_FL_SINK :MEDIA_PAD_FL_SOURCE ; - ret =media_entity_init (&dma->video.entity,1 , &dma->pad,0 ); + ret =media_entity_init (&dma->video.entity,1 , &dma->pad);if (ret <0 ) goto error;
drivers/media/platform/xilinx/xilinx-tpg.c +1 -1
@@ -836,7 +836,7 @@ static int xtpg_probe(struct platform_device *pdev) subdev->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; subdev->entity.ops = &xtpg_media_ops; - ret =media_entity_init (&subdev->entity, xtpg->npads, xtpg->pads,0 ); + ret =media_entity_init (&subdev->entity, xtpg->npads, xtpg->pads);if (ret <0 ) goto error;
drivers/media/usb/cx231xx/cx231xx-video.c +2 -2
@@ -2175,7 +2175,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)cx231xx_vdev_init (dev, &dev->vdev, &cx231xx_video_template,"video" );#if defined(CONFIG_MEDIA_CONTROLLER ) dev->video_pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&dev->vdev.entity,1 , &dev->video_pad,0 ); + ret =media_entity_init (&dev->vdev.entity,1 , &dev->video_pad);if (ret <0 )dev_err (dev->dev,"failed to initialize video media entity!\n" );#endif
@@ -2202,7 +2202,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)#if defined(CONFIG_MEDIA_CONTROLLER ) dev->vbi_pad.flags =MEDIA_PAD_FL_SINK ; - ret =media_entity_init (&dev->vbi_dev.entity,1 , &dev->vbi_pad,0 ); + ret =media_entity_init (&dev->vbi_dev.entity,1 , &dev->vbi_pad);if (ret <0 )dev_err (dev->dev,"failed to initialize vbi media entity!\n" );#endif
drivers/media/usb/uvc/uvc_entity.c +2 -2
@@ -89,10 +89,10 @@ static int uvc_mc_init_entity(struct uvc_entity *entity) sizeof(entity->subdev.name)); ret =media_entity_init (&entity->subdev.entity, - entity->num_pads, entity->pads,0 ); + entity->num_pads, entity->pads); }else if (entity->vdev !=NULL ) { ret =media_entity_init (&entity->vdev->entity, - entity->num_pads, entity->pads,0 ); + entity->num_pads, entity->pads);if (entity->flags &UVC_ENTITY_FLAG_DEFAULT ) entity->vdev->entity.flags |=MEDIA_ENT_FL_DEFAULT ; }else
drivers/media/v4l2-core/tuner-core.c +1 -1
@@ -699,7 +699,7 @@ register_client: t->sd.entity.type =MEDIA_ENT_T_V4L2_SUBDEV_TUNER ; t->sd.entity.name = t->name; - ret =media_entity_init (&t->sd.entity,1 , &t->pad,0 ); + ret =media_entity_init (&t->sd.entity,1 , &t->pad);if (ret <0 ) {tuner_err ("failed to initialize media entity!\n" );kfree (t);
drivers/media/v4l2-core/v4l2-flash-led-class.c +1 -1
@@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init( sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;strlcpy (sd->name, config->dev_name,sizeof (sd->name)); - ret =media_entity_init (&sd->entity,0 ,NULL ,0 ); + ret =media_entity_init (&sd->entity,0 ,NULL );if (ret <0 )return ERR_PTR (ret);
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +1 -1
@@ -1839,7 +1839,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)v4l2_ctrl_handler_setup (&ipipe->ctrls); sd->ctrl_handler = &ipipe->ctrls; -return media_entity_init (me,IPIPE_PADS_NUM , pads,0 ); +return media_entity_init (me,IPIPE_PADS_NUM , pads); }/*
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +1 -1
@@ -1026,7 +1026,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif, ipipeif->output =IPIPEIF_OUTPUT_NONE ; me->ops = &ipipeif_media_ops; - ret =media_entity_init (me,IPIPEIF_NUM_PADS , pads,0 ); + ret =media_entity_init (me,IPIPEIF_NUM_PADS , pads);if (ret) goto fail;
drivers/staging/media/davinci_vpfe/dm365_isif.c +1 -1
@@ -2052,7 +2052,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev) isif->input =ISIF_INPUT_NONE ; isif->output =ISIF_OUTPUT_NONE ; me->ops = &isif_media_ops; - status =media_entity_init (me,ISIF_PADS_NUM , pads,0 ); + status =media_entity_init (me,ISIF_PADS_NUM , pads);if (status) goto isif_fail; isif->video_out.type =V4L2_BUF_TYPE_VIDEO_CAPTURE ;
drivers/staging/media/davinci_vpfe/dm365_resizer.c +3 -3
@@ -1915,7 +1915,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->crop_resizer.output2 =RESIZER_CROP_OUTPUT_NONE ; vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret =media_entity_init (me,RESIZER_CROP_PADS_NUM , pads,0 ); + ret =media_entity_init (me,RESIZER_CROP_PADS_NUM , pads);if (ret)return ret;
@@ -1937,7 +1937,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_a.output =RESIZER_OUTPUT_NONE ; vpfe_rsz->resizer_a.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret =media_entity_init (me,RESIZER_PADS_NUM , pads,0 ); + ret =media_entity_init (me,RESIZER_PADS_NUM , pads);if (ret)return ret;
@@ -1959,7 +1959,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_b.output =RESIZER_OUTPUT_NONE ; vpfe_rsz->resizer_b.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret =media_entity_init (me,RESIZER_PADS_NUM , pads,0 ); + ret =media_entity_init (me,RESIZER_PADS_NUM , pads);if (ret)return ret;
drivers/staging/media/davinci_vpfe/vpfe_video.c +1 -1
@@ -1594,7 +1594,7 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name)spin_lock_init (&video->dma_queue_lock);mutex_init (&video->lock); ret =media_entity_init (&video->video_dev.entity, -1 , &video->pad,0 ); +1 , &video->pad);if (ret <0 )return ret;
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
@@ -1271,7 +1271,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) pads[CSI2_PAD_SINK ].flags =MEDIA_PAD_FL_SINK ; me->ops = &csi2_media_ops; - ret =media_entity_init (me,CSI2_PADS_NUM , pads,0 ); + ret =media_entity_init (me,CSI2_PADS_NUM , pads);if (ret <0 )return ret;
drivers/staging/media/omap4iss/iss_ipipe.c +1 -1
@@ -513,7 +513,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe) pads[IPIPE_PAD_SOURCE_VP ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &ipipe_media_ops; - ret =media_entity_init (me,IPIPE_PADS_NUM , pads,0 ); + ret =media_entity_init (me,IPIPE_PADS_NUM , pads);if (ret <0 )return ret;
drivers/staging/media/omap4iss/iss_ipipeif.c +1 -1
@@ -743,7 +743,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) pads[IPIPEIF_PAD_SOURCE_VP ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &ipipeif_media_ops; - ret =media_entity_init (me,IPIPEIF_PADS_NUM , pads,0 ); + ret =media_entity_init (me,IPIPEIF_PADS_NUM , pads);if (ret <0 )return ret;
drivers/staging/media/omap4iss/iss_resizer.c +1 -1
@@ -787,7 +787,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) pads[RESIZER_PAD_SOURCE_MEM ].flags =MEDIA_PAD_FL_SOURCE ; me->ops = &resizer_media_ops; - ret =media_entity_init (me,RESIZER_PADS_NUM , pads,0 ); + ret =media_entity_init (me,RESIZER_PADS_NUM , pads);if (ret <0 )return ret;
drivers/staging/media/omap4iss/iss_video.c +1 -1
@@ -1104,7 +1104,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name)return -EINVAL ; } - ret =media_entity_init (&video->video.entity,1 , &video->pad,0 ); + ret =media_entity_init (&video->video.entity,1 , &video->pad);if (ret <0 )return ret;
include/media/media-entity.h +1 -1
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,void graph_obj_remove (struct media_graph_obj *gobj);int media_entity_init (struct media_entity *entity,u16 num_pads, -struct media_pad *pads,u16 extra_links); +struct media_pad *pads);void media_entity_cleanup (struct media_entity *entity); int media_entity_create_link(struct media_entity *source, u16 source_pad,
Signature · 1 line
2.4.3
RFC PATCH v2 8/16 media: convert links from array to list
In reply to Mauro Carvalho ChehabUsing memory realloc to increase the size of an array is complex and makes harder to remove links. Also, by embedding the link inside an array at the entity makes harder to change the code to add interfaces, as interfaces will also need to use links.
So, convert the links from arrays to lists.
drivers/media/media-device.c +14 -9
@@ -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>
@@ -148,22 +149,22 @@ 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++;
@@ -471,6 +472,7 @@ void media_device_unregister_entity(struct media_entity *entity) {int i;struct media_device *mdev = entity->parent; +struct media_link *link, *tmp;if (mdev ==NULL )return ;
@@ -479,8 +481,11 @@ void media_device_unregister_entity(struct media_entity *entity)graph_obj_remove (&entity->graph_obj);for (i =0 ; entity->num_pads; i++)graph_obj_remove (&entity->pads[i].graph_obj); -for (i =0 ; entity->num_links; i++) -graph_obj_remove (&entity->links[i].graph_obj); +list_for_each_entry_safe (link, tmp, &entity->links, list) { +graph_obj_remove (&link->graph_obj); +list_del (&link->list); +kfree (link); + }list_del (&entity->list);spin_unlock (&mdev->lock); entity->parent =NULL ;
drivers/media/media-entity.c +62 -74
251 lines not on this page · raw message
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 +4 -4
@@ -71,6 +71,7 @@ struct media_pipeline { };struct media_link { +struct list_head list;struct media_graph_obj graph_obj;struct media_pad *source;/* Source pad */ struct media_pad *sink;/* Sink pad */
@@ -117,10 +118,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 list_head links;/* Links list */ const struct media_entity_operations *ops;/* Entity operations */
@@ -161,7 +161,7 @@ static inline u32 media_entity_subtype(struct media_entity *entity)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);
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,void graph_obj_remove (struct media_graph_obj *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_entity_create_link(struct media_entity *source, u16 source_pad,
Signature · 1 line
2.4.3
Re: [PATCH RFC v2 08/16] media: convert links from array to list
Quoted 14 lines · Mauro Carvalho Chehab
Using memory realloc to increase the size of an array is complex and makes harder to remove links. Also, by embedding the link inside an array at the entity makes harder to change the code to add interfaces, as interfaces will also need to use links.
So, convert the links from arrays to lists.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +0
-0
<snip>
Quoted 14 lines
drivers/media/media-device.c +2
-7@@ -452,27 +445,21 @@ EXPORT_SYMBOL_GPL(media_entity_put);static struct media_link *media_entity_add_link (struct media_entity *entity) { -if (entity->num_links >= entity->max_links) { -struct media_link *links = entity->links; -unsigned int max_links = entity->max_links +2 ; -unsigned int i; +struct media_link *link; - links =krealloc (links, max_links *sizeof (*links),GFP_KERNEL ); -if (links ==NULL ) -return NULL ; + link =kzalloc (sizeof (*link),GFP_KERNEL );
drivers/media/media-device.c EXPORT_SYMBOL_GPL(media_entity_put); · line 454
Quoted 10 lines
drivers/media/media-device.c +3
-6+if (link ==NULL ) +return NULL ; -for (i =0 ; i < entity->num_links; i++) - links[i].reverse->reverse = &links[i]; - - entity->max_links = max_links; - entity->links = links; - } + link->reverse->reverse = link;
Huh? link points to a zeroed struct, so link->reverse will be NULL. This can't work.
Are you sure this line should be here? The original code doesn't set it either for the new link, it just updates the reverse links for the realloced links.
drivers/media/media-device.c EXPORT_SYMBOL_GPL(media_entity_put); · line 465
Quoted 13 lines
drivers/media/media-device.c +4
-2+INIT_LIST_HEAD (&link->list); +list_add (&entity->links, &link->list);/* Initialize graph object embedded at the new link */ graph_obj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); + &link->graph_obj); -return &entity->links[entity->num_links++]; +return link; }int
Regards,
Hans
Re: [PATCH RFC v2 08/16] media: convert links from array to list
Em Tue, 11 Aug 2015 12:49:40 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 46 lines · Mauro Carvalho Chehab
Quoted 14 lines
Using memory realloc to increase the size of an array is complex and makes harder to remove links. Also, by embedding the link inside an array at the entity makes harder to change the code to add interfaces, as interfaces will also need to use links.
So, convert the links from arrays to lists.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-device.c +0
-0<snip>
Quoted 14 lines
drivers/media/media-device.c +2
-7@@ -452,27 +445,21 @@ EXPORT_SYMBOL_GPL(media_entity_put);static struct media_link *media_entity_add_link (struct media_entity *entity) { -if (entity->num_links >= entity->max_links) { -struct media_link *links = entity->links; -unsigned int max_links = entity->max_links +2 ; -unsigned int i; +struct media_link *link; - links =krealloc (links, max_links *sizeof (*links),GFP_KERNEL ); -if (links ==NULL ) -return NULL ; + link =kzalloc (sizeof (*link),GFP_KERNEL );drivers/media/media-device.c EXPORT_SYMBOL_GPL(media_entity_put); · line 454
Quoted 10 lines
drivers/media/media-device.c +3
-6+if (link ==NULL ) +return NULL ; -for (i =0 ; i < entity->num_links; i++) - links[i].reverse->reverse = &links[i]; - - entity->max_links = max_links; - entity->links = links; - } + link->reverse->reverse = link;Huh? link points to a zeroed struct, so
link->reversewill be NULL. This can't work.
Quoted 3 lines
Are you sure this line should be here? The original code doesn't set it either for the new link, it just updates the reverse links for the realloced links.
You're right. I think I can just remove that line.
I had to confess that I didn't understand well that the reverse links stuff. I mean, IMHO, the entire concept of storing a second copy of the link, calling it as "reverse" on some places and as "backlink" on others is messy, and I guess we should get rid of duplicating the number of links for no good reason.
It is easy to just add the same link to a list at the other entity, and keep the link just once in the memory.
Quoted 18 lines
Quoted 4 lines
drivers/media/media-device.c +2
-0+INIT_LIST_HEAD (&link->list); +list_add (&entity->links, &link->list);drivers/media/media-device.c EXPORT_SYMBOL_GPL(media_entity_put); · line 465
Quoted 10 lines
drivers/media/media-device.c +2
-2/* Initialize graph object embedded at the new link */ graph_obj_init (entity->parent,MEDIA_GRAPH_LINK , - &entity->links[entity->num_links].graph_obj); + &link->graph_obj); -return &entity->links[entity->num_links++]; +return link; }int Regards,
Hans
RFC PATCH v2 9/16 media: use media_graph_obj for link endpoints
In reply to Mauro Carvalho ChehabAs we'll need to create links between entities and interfaces, we need to identify the link endpoints by the media_graph_obj.
Most of the changes here was done by this small script:
for i in find drivers/media -type f find drivers/staging/media -type f; do
perl -ne 's,([\w]+)\-\>(source|sink)\-\>entity,gobj_to_pad($1->$2)->entity,; print $_;' <$i >a && mv a $i
done
Please note that, while we're now using graph_obj to reference the link endpoints, we're still assuming that all endpoints are pads. This is true for all existing links, so no problems are expected so far.
Yet, as we introduce links between entities and interfaces, we may need to change some existing code to work with links that aren't pad to pad.
drivers/media/dvb-core/dvb_frontend.c +7 -3
@@ -635,7 +635,9 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)for (i =0 ; i < entity->num_links; i++) { link = &entity->links[i]; -if (link->sink->entity == entity) { +if (link->sink.type !=MEDIA_GRAPH_PAD ) +continue ; +if (gobj_to_pad (link->sink)->entity == entity) { found_link = link; n_links++;if (link->flags &MEDIA_LNK_FL_ENABLED )
@@ -658,14 +660,16 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)return -EINVAL ; } - source = found_link->source->entity; + source =gobj_to_pad (found_link->source)->entity; fepriv->pipe_start_entity = source;for (i =0 ; i < source->num_links; i++) {struct media_entity *sink;int flags =0 ; link = &source->links[i]; - sink = link->sink->entity; +if (link->sink.type !=MEDIA_GRAPH_PAD ) +continue ; + sink =gobj_to_pad (link->sink)->entity;if (sink == entity) flags =MEDIA_LNK_FL_ENABLED ;
drivers/media/media-device.c +8 -3
@@ -155,14 +155,19 @@ static long __media_device_enum_links(struct media_device *mdev,list_for_each_entry (ent_link, &entity->links, list) {struct media_link_desc link; +/* Only PAD to PAD links should be enumerated with legacy API */ +if (ent_link->source->type !=MEDIA_GRAPH_PAD || + ent_link->sink->type !=MEDIA_GRAPH_PAD ) +continue ; +/* Ignore backlinks. */ -if (ent_link->source->entity != entity) +if (gobj_to_pad (ent_link->source)->entity != entity)continue ;memset (&link,0 ,sizeof (link)); -media_device_kpad_to_upad (ent_link->source, +media_device_kpad_to_upad (gobj_to_pad (ent_link->source), &link.source); -media_device_kpad_to_upad (ent_link->sink, +media_device_kpad_to_upad (gobj_to_pad (ent_link->sink), &link.sink); link.flags = ent_link->flags;if (copy_to_user (ulink, &link,sizeof (*ulink)))
drivers/media/media-entity.c +55 -34
182 lines not on this page · raw message
drivers/media/platform/exynos4-is/media-dev.c +1 -1
@@ -1091,7 +1091,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)static int fimc_md_link_notify (struct media_link *link,unsigned int flags,unsigned int notification) { -struct media_entity *sink = link->sink->entity; +struct media_entity *sink =gobj_to_pad (link->sink)->entity;int ret =0 ;/* Before link disconnection */
drivers/media/platform/omap3isp/isp.c +2 -2
@@ -822,8 +822,8 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)static int isp_pipeline_link_notify (struct media_link *link,u32 flags,unsigned int notification) { -struct media_entity *source = link->source->entity; -struct media_entity *sink = link->sink->entity; +struct media_entity *source =gobj_to_pad (link->source)->entity; +struct media_entity *sink =gobj_to_pad (link->sink)->entity;int source_use =isp_pipeline_pm_use_count (source);int sink_use =isp_pipeline_pm_use_count (sink);int ret;
drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -2419,7 +2419,7 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,if (ccdc->input ==CCDC_INPUT_PARALLEL ) {struct isp_parallel_cfg *parcfg = &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) +media_entity_to_v4l2_subdev (gobj_to_pad (link->source)->entity) ->host_priv)->bus.parallel; parallel_shift = parcfg->data_lane_shift *2 ; }else {
drivers/media/usb/cx231xx/cx231xx-video.c +3 -3
@@ -128,7 +128,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)return 0 ;list_for_each_entry (link, &decoder->links, list) { -if (link->sink->entity == decoder) { +if (gobj_to_pad (link->sink)->entity == decoder) { found_link = link;if (link->flags &MEDIA_LNK_FL_ENABLED ) active_links++;
@@ -139,12 +139,12 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)if (active_links ==1 || !found_link)return 0 ; - source = found_link->source->entity; + source =gobj_to_pad (found_link->source)->entity;list_for_each_entry (link, &source->links, list) {struct media_entity *sink;int flags =0 ; - sink = link->sink->entity; + sink =gobj_to_pad (link->sink)->entity;if (sink == entity) flags =MEDIA_LNK_FL_ENABLED ;
drivers/media/v4l2-core/v4l2-subdev.c +4 -2
@@ -523,9 +523,11 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,EXPORT_SYMBOL_GPL (v4l2_subdev_link_validate_default);static int -v4l2_subdev_link_validate_get_format (struct media_pad *pad, +v4l2_subdev_link_validate_get_format (struct media_graph_obj *gobj,struct v4l2_subdev_format *fmt) { +struct media_pad *pad =gobj_to_pad (gobj); +if (media_entity_type (pad->entity) ==MEDIA_ENT_T_V4L2_SUBDEV ) {struct v4l2_subdev *sd =media_entity_to_v4l2_subdev (pad->entity);
@@ -558,7 +560,7 @@ int v4l2_subdev_link_validate(struct media_link *link)if (rval <0 )return 0 ; - sink =media_entity_to_v4l2_subdev (link->sink->entity); + sink =media_entity_to_v4l2_subdev (gobj_to_pad (link->sink)->entity); rval =v4l2_subdev_call (sink, pad, link_validate, link, &source_fmt, &sink_fmt);
drivers/staging/media/omap4iss/iss.c +3 -3
@@ -142,7 +142,7 @@ int omap4iss_get_external_info(struct iss_pipeline *pipe, fmt.pad = link->source->index; fmt.which =V4L2_SUBDEV_FORMAT_ACTIVE ; - ret =v4l2_subdev_call (media_entity_to_v4l2_subdev (link->sink->entity), + ret =v4l2_subdev_call (media_entity_to_v4l2_subdev (gobj_to_pad (link->sink)->entity), pad, get_fmt,NULL , &fmt);if (ret <0 )return -EPIPE ;
@@ -526,8 +526,8 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)static int iss_pipeline_link_notify (struct media_link *link,u32 flags,unsigned int notification) { -struct media_entity *source = link->source->entity; -struct media_entity *sink = link->sink->entity; +struct media_entity *source =gobj_to_pad (link->source)->entity; +struct media_entity *sink =gobj_to_pad (link->sink)->entity;int source_use =iss_pipeline_pm_use_count (source);int sink_use =iss_pipeline_pm_use_count (sink);int ret;
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
@@ -1026,7 +1026,7 @@ static int csi2_link_validate(struct v4l2_subdev *sd, struct media_link *link,struct iss_pipeline *pipe =to_iss_pipeline (&csi2->subdev.entity);int rval; - pipe->external =media_entity_to_v4l2_subdev (link->source->entity); + pipe->external =media_entity_to_v4l2_subdev (gobj_to_pad (link->source)->entity); rval =omap4iss_get_external_info (pipe, link);if (rval <0 )return rval;
include/media/media-entity.h +25 -3
@@ -43,6 +43,17 @@ enum media_graph_type { MEDIA_GRAPH_LINK, }; +/** +* enum media_graph_link_dir - direction of a link +* +* @MEDIA_LINK_DIR_BIDIRECTIONAL Link is bidirectional +* @MEDIA_LINK_DIR_PAD_0_TO_1 Link is unidirectional, +* from port 0 (source) to port 1 (sink) +*/ +enum media_graph_link_dir { +MEDIA_LINK_DIR_BIDIRECTIONAL , +MEDIA_LINK_DIR_PORT0_TO_PORT1 , +};/* Structs to represent the objects that belong to a media graph */
@@ -72,9 +83,9 @@ struct media_pipeline {struct media_link {struct list_head list; -struct media_graph_obj graph_obj; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +struct media_graph_obj graph_obj; +enum media_graph_link_dir dir; +struct media_graph_obj *source, *sink;struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };
@@ -115,6 +126,11 @@ struct media_entity {u32 group_id;/* Entity group ID */ u16 num_pads;/* Number of sink and source pads */ + +/* +* Both num_links and num_backlinks are used only to report +* the number of links via MEDIA_IOC_ENUM_ENTITIES@media_device.c +*/ u16 num_links;/* Number of existing links, both * enabled and disabled */ u16 num_backlinks;/* Number of backlinks */
@@ -171,6 +187,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, 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) +void graph_obj_init (struct media_device *mdev,enum media_graph_type type,struct media_graph_obj *gobj);
Signature · 1 line
2.4.3
RFC PATCH v2 10/16 media: rename the function that create pad links
Now that a link can be either between two different graph objects, we'll need to add more functions to create links. So, rename the existing one that create links only between two pads as media_create_pad_link().
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
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
@@ -481,7 +481,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;
@@ -519,7 +519,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);static void __media_entity_remove_link (struct media_entity *entity,struct media_link *link)
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
@@ -1905,7 +1905,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)
@@ -2077,51 +2077,51 @@ static int isp_initialize_modules(struct isp_device *isp) }/* Connect the submodules. */ - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_csi2a.subdev.entity,CSI2_PAD_SOURCE , &isp->isp_ccdc.subdev.entity,CCDC_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccp2.subdev.entity,CCP2_PAD_SOURCE , &isp->isp_ccdc.subdev.entity,CCDC_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_prev.subdev.entity,PREV_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_OF , &isp->isp_res.subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_prev.subdev.entity,PREV_PAD_SOURCE , &isp->isp_res.subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_aewb.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_af.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &isp->isp_ccdc.subdev.entity,CCDC_PAD_SOURCE_VP , &isp->isp_hist.subdev.entity,0 ,MEDIA_LNK_FL_ENABLED |MEDIA_LNK_FL_IMMUTABLE );
drivers/media/platform/omap3isp/ispccdc.c +1 -1
@@ -2667,7 +2667,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) goto error_video;/* Connect the CCDC subdev to the video node. */ - ret =media_entity_create_link (&ccdc->subdev.entity,CCDC_PAD_SOURCE_OF , + ret =media_create_pad_link (&ccdc->subdev.entity,CCDC_PAD_SOURCE_OF , &ccdc->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispccp2.c +1 -1
@@ -1100,7 +1100,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) goto error_video;/* Connect the video node to the ccp2 subdev. */ - ret =media_entity_create_link (&ccp2->video_in.video.entity,0 , + ret =media_create_pad_link (&ccp2->video_in.video.entity,0 , &ccp2->subdev.entity,CCP2_PAD_SINK ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -1265,7 +1265,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) goto error_video;/* Connect the CSI2 subdev to the video node. */ - ret =media_entity_create_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , + ret =media_create_pad_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , &csi2->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/isppreview.c +2 -2
@@ -2312,12 +2312,12 @@ static int preview_init_entities(struct isp_prev_device *prev) goto error_video_out;/* Connect the video nodes to the previewer subdev. */ - ret =media_entity_create_link (&prev->video_in.video.entity,0 , + ret =media_create_pad_link (&prev->video_in.video.entity,0 , &prev->subdev.entity,PREV_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link (&prev->subdev.entity,PREV_PAD_SOURCE , + ret =media_create_pad_link (&prev->subdev.entity,PREV_PAD_SOURCE , &prev->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/omap3isp/ispresizer.c +2 -2
@@ -1756,12 +1756,12 @@ static int resizer_init_entities(struct isp_res_device *res) res->video_out.video.entity.flags |=MEDIA_ENT_FL_DEFAULT ;/* Connect the video nodes to the resizer subdev. */ - ret =media_entity_create_link (&res->video_in.video.entity,0 , + ret =media_create_pad_link (&res->video_in.video.entity,0 , &res->subdev.entity,RESZ_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link (&res->subdev.entity,RESZ_PAD_SOURCE , + ret =media_create_pad_link (&res->subdev.entity,RESZ_PAD_SOURCE , &res->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/media/platform/s3c-camif/camif-core.c +2 -2
@@ -263,7 +263,7 @@ static int camif_create_media_links(struct camif_dev *camif) {int i, ret; - ret =media_entity_create_link (&camif->sensor.sd->entity,0 , + ret =media_create_pad_link (&camif->sensor.sd->entity,0 , &camif->subdev.entity,CAMIF_SD_PAD_SINK ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
@@ -271,7 +271,7 @@ static int camif_create_media_links(struct camif_dev *camif)return ret;for (i =1 ; i <CAMIF_SD_PADS_NUM && !ret; i++) { - ret =media_entity_create_link (&camif->subdev.entity, i, + ret =media_create_pad_link (&camif->subdev.entity, i, &camif->vp[i -1 ].vdev.entity,0 ,MEDIA_LNK_FL_IMMUTABLE |MEDIA_LNK_FL_ENABLED );
drivers/media/platform/vsp1/vsp1_drv.c +2 -2
@@ -101,7 +101,7 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)if (!(entity->pads[pad].flags &MEDIA_PAD_FL_SINK ))continue ; - ret =media_entity_create_link (&source->subdev.entity, + ret =media_create_pad_link (&source->subdev.entity, source->source_pad, entity, pad, flags);if (ret <0 )
@@ -262,7 +262,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) }if (vsp1->pdata.features &VSP1_HAS_LIF ) { - ret =media_entity_create_link ( + ret =media_create_pad_link ( &vsp1->wpf[0 ]->entity.subdev.entity,RWPF_PAD_SOURCE , &vsp1->lif->entity.subdev.entity,LIF_PAD_SINK ,0 );if (ret <0 )
drivers/media/platform/vsp1/vsp1_rpf.c +1 -1
@@ -278,7 +278,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) rpf->entity.video = video;/* Connect the video device to the RPF. */ - ret = media_entity_create_link(&rpf->video.video.entity, 0, + ret = media_create_pad_link(&rpf->video.video.entity, 0, &rpf->entity.subdev.entity, RWPF_PAD_SINK, MEDIA_LNK_FL_ENABLED |
drivers/media/platform/vsp1/vsp1_wpf.c +1 -1
@@ -284,7 +284,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)if (!(vsp1->pdata.features &VSP1_HAS_LIF ) || index !=0 ) flags |=MEDIA_LNK_FL_IMMUTABLE ; - ret =media_entity_create_link (&wpf->entity.subdev.entity, + ret =media_create_pad_link (&wpf->entity.subdev.entity,RWPF_PAD_SOURCE , &wpf->video.video.entity,0 , flags);if (ret <0 )
drivers/media/platform/xilinx/xilinx-vipp.c +2 -2
@@ -156,7 +156,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, local->name, local_pad->index, remote->name, remote_pad->index); - ret =media_entity_create_link (local, local_pad->index, + ret =media_create_pad_link (local, local_pad->index, remote, remote_pad->index, link_flags);if (ret <0 ) {
@@ -270,7 +270,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) source->name, source_pad->index, sink->name, sink_pad->index); - ret =media_entity_create_link (source, source_pad->index, + ret =media_create_pad_link (source, source_pad->index, sink, sink_pad->index, link_flags);if (ret <0 ) {
drivers/media/usb/cx231xx/cx231xx-cards.c +3 -3
@@ -1264,11 +1264,11 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)return ;if (tuner) -media_entity_create_link (tuner,0 , decoder,0 , +media_create_pad_link (tuner,0 , decoder,0 ,MEDIA_LNK_FL_ENABLED ); -media_entity_create_link (decoder,1 , &dev->vdev.entity,0 , +media_create_pad_link (decoder,1 , &dev->vdev.entity,0 ,MEDIA_LNK_FL_ENABLED ); -media_entity_create_link (decoder,2 , &dev->vbi_dev.entity,0 , +media_create_pad_link (decoder,2 , &dev->vbi_dev.entity,0 ,MEDIA_LNK_FL_ENABLED );#endif }
drivers/media/usb/uvc/uvc_entity.c +1 -1
@@ -56,7 +56,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain,continue ; remote_pad = remote->num_pads -1 ; - ret =media_entity_create_link (source, remote_pad, + ret =media_create_pad_link (source, remote_pad, sink, i, flags);if (ret <0 )return ret;
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +1 -1
@@ -971,7 +971,7 @@ vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif, ipipeif->video_in.vpfe_dev = vpfe_dev; flags =0 ; - ret =media_entity_create_link (&ipipeif->video_in.video_dev.entity,0 , + ret =media_create_pad_link (&ipipeif->video_in.video_dev.entity,0 , &ipipeif->subdev.entity,0 , flags);if (ret <0 ) goto fail;
drivers/staging/media/davinci_vpfe/dm365_isif.c +1 -1
@@ -1817,7 +1817,7 @@ int vpfe_isif_register_entities(struct vpfe_isif_device *isif, isif->video_out.vpfe_dev = vpfe_dev; flags =0 ;/* connect isif to video node */ - ret =media_entity_create_link (&isif->subdev.entity,1 , + ret =media_create_pad_link (&isif->subdev.entity,1 , &isif->video_out.video_dev.entity,0 , flags);if (ret <0 )
drivers/staging/media/davinci_vpfe/dm365_resizer.c +4 -4
@@ -1831,27 +1831,27 @@ int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer, resizer->resizer_b.video_out.vpfe_dev = vpfe_dev;/* create link between Resizer Crop----> Resizer A*/ - ret =media_entity_create_link (&resizer->crop_resizer.subdev.entity,1 , + ret =media_create_pad_link (&resizer->crop_resizer.subdev.entity,1 , &resizer->resizer_a.subdev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer Crop----> Resizer B*/ - ret =media_entity_create_link (&resizer->crop_resizer.subdev.entity,2 , + ret =media_create_pad_link (&resizer->crop_resizer.subdev.entity,2 , &resizer->resizer_b.subdev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer A ----> video out */ - ret =media_entity_create_link (&resizer->resizer_a.subdev.entity,1 , + ret =media_create_pad_link (&resizer->resizer_a.subdev.entity,1 , &resizer->resizer_a.video_out.video_dev.entity,0 , flags);if (ret <0 ) goto out_create_link;/* create link between Resizer B ----> video out */ - ret =media_entity_create_link (&resizer->resizer_b.subdev.entity,1 , + ret =media_create_pad_link (&resizer->resizer_b.subdev.entity,1 , &resizer->resizer_b.video_out.video_dev.entity,0 , flags);if (ret <0 ) goto out_create_link;
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +5 -5
@@ -445,32 +445,32 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev)/* if entity has no pads (ex: amplifier), cant establish link */ if (vpfe_dev->sd[i]->entity.num_pads) { - ret =media_entity_create_link (&vpfe_dev->sd[i]->entity, + ret =media_create_pad_link (&vpfe_dev->sd[i]->entity,0 , &vpfe_dev->vpfe_isif.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; } - ret =media_entity_create_link (&vpfe_dev->vpfe_isif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_isif.subdev.entity,1 , &vpfe_dev->vpfe_ipipeif.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , &vpfe_dev->vpfe_ipipe.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipe.subdev.entity, + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipe.subdev.entity,1 , &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,0 , flags);if (ret <0 ) goto out_resizer_register; - ret =media_entity_create_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , + ret =media_create_pad_link (&vpfe_dev->vpfe_ipipeif.subdev.entity,1 , &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,0 , flags);if (ret <0 )
drivers/staging/media/omap4iss/iss.c +6 -6
@@ -1259,7 +1259,7 @@ static int iss_register_entities(struct iss_device *iss) goto done; } - ret =media_entity_create_link (&sensor->entity,0 , input, pad, + ret =media_create_pad_link (&sensor->entity,0 , input, pad, flags);if (ret <0 ) goto done;
@@ -1317,31 +1317,31 @@ static int iss_initialize_modules(struct iss_device *iss) }/* Connect the submodules. */ - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->csi2a.subdev.entity,CSI2_PAD_SOURCE , &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->csi2b.subdev.entity,CSI2_PAD_SOURCE , &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SOURCE_VP , &iss->resizer.subdev.entity,RESIZER_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipeif.subdev.entity,IPIPEIF_PAD_SOURCE_VP , &iss->ipipe.subdev.entity,IPIPE_PAD_SINK ,0 );if (ret <0 ) goto error_link; - ret =media_entity_create_link ( + ret =media_create_pad_link ( &iss->ipipe.subdev.entity,IPIPE_PAD_SOURCE_VP , &iss->resizer.subdev.entity,RESIZER_PAD_SINK ,0 );if (ret <0 )
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
@@ -1291,7 +1291,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) goto error_video;/* Connect the CSI2 subdev to the video node. */ - ret =media_entity_create_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , + ret =media_create_pad_link (&csi2->subdev.entity,CSI2_PAD_SOURCE , &csi2->video_out.video.entity,0 ,0 );if (ret <0 ) goto error_link;
drivers/staging/media/omap4iss/iss_ipipeif.c +1 -1
@@ -762,7 +762,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)return ret;/* Connect the IPIPEIF subdev to the video node. */ - ret =media_entity_create_link (&ipipeif->subdev.entity, + ret =media_create_pad_link (&ipipeif->subdev.entity,IPIPEIF_PAD_SOURCE_ISIF_SF , &ipipeif->video_out.video.entity,0 ,0 );if (ret <0 )
drivers/staging/media/omap4iss/iss_resizer.c +1 -1
@@ -806,7 +806,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)return ret;/* Connect the RESIZER subdev to the video node. */ - ret =media_entity_create_link (&resizer->subdev.entity, + ret =media_create_pad_link (&resizer->subdev.entity,RESIZER_PAD_SOURCE_MEM , &resizer->video_out.video.entity,0 ,0 );if (ret <0 )
include/media/media-entity.h +1 -1
@@ -202,7 +202,7 @@ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads);void media_entity_cleanup (struct media_entity *entity); -int media_entity_create_link (struct media_entity *source,u16 source_pad, +int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags);void __media_entity_remove_links (struct media_entity *entity);void media_entity_remove_links (struct media_entity *entity);
Signature · 1 line
2.4.3
RFC PATCH v2 9/16 media: use media_graph_obj for link endpoints
In reply to Mauro Carvalho ChehabHi Mauro,
Thanks for posting the missing patches.
Quoted 20 lines · Mauro Carvalho Chehab
As we'll need to create links between entities and interfaces, we need to identify the link endpoints by the
media_graph_obj.Most of the changes here was done by this small script:
for i in
find drivers/media -type ffind drivers/staging/media -type f; doperl -ne 's,([\w]+)\-\>(source|sink)\-\>entity,gobj_to_pad($1->$2)->entity,; print $_;' <$i >a && mv a $idone
Please note that, while we're now using
graph_objto reference the link endpoints, we're still assuming that all endpoints are pads. This is true for all existing links, so no problems are expected so far.Yet, as we introduce links between entities and interfaces, we may need to change some existing code to work with links that aren't pad to pad.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
<snip>
Quoted 9 lines
include/media/media-entity.h +1
-0@@ -43,6 +43,17 @@ enum media_graph_type { MEDIA_GRAPH_LINK, }; +/**
include/media/media-entity.h enum media_graph_type { · line 56
Quoted 10 lines
include/media/media-entity.h +10
-0+* enum media_graph_link_dir - direction of a link +* +* @MEDIA_LINK_DIR_BIDIRECTIONAL Link is bidirectional +* @MEDIA_LINK_DIR_PAD_0_TO_1 Link is unidirectional, +* from port 0 (source) to port 1 (sink) +*/ +enum media_graph_link_dir { +MEDIA_LINK_DIR_BIDIRECTIONAL , +MEDIA_LINK_DIR_PORT0_TO_PORT1 , +};
1) the comment and the actual enum are out-of-sync
2) why not just make a 'BIRECTIONAL' link flag instead of inventing a new enum? Adding yet another field seems overkill to me. Have a 'BIDIRECTIONAL' flag seems perfectly OK to me (and useful for the application as well).
include/media/media-entity.h struct media_pipeline { · line 88
Quoted 13 lines
include/media/media-entity.h +3
-3/* Structs to represent the objects that belong to a media graph */ @@ -72,9 +83,9 @@ struct media_pipeline {struct media_link {struct list_head list; -struct media_graph_obj graph_obj; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +struct media_graph_obj graph_obj; +enum media_graph_link_dir dir; +struct media_graph_obj *source, *sink;
I'm not too keen about all the gobj_to_foo(obj) macros that this requires. It is rather ugly code.
What about this:
union {
struct media_graph_obj *source;
struct media_pad *source_pad;
struct media_interface *source_intf;
};
union {
struct media_graph_obj *sink;
struct media_pad *sink_pad;
struct media_entity *sink_ent;
};Now the code can just use ->source_pad etc.
Quoted 16 lines
include/media/media-entity.h +5
-0struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };@@ -115,6 +126,11 @@ struct media_entity {u32 group_id;/* Entity group ID */ u16 num_pads;/* Number of sink and source pads */ + +/* +* Both num_links and num_backlinks are used only to report +* the number of links via MEDIA_IOC_ENUM_ENTITIES at media_device.c +*/ u16 num_links;/* Number of existing links, both * enabled and disabled */ u16 num_backlinks;/* Number of backlinks */
include/media/media-entity.h struct media_entity_graph { · line 195
Quoted 9 lines
include/media/media-entity.h +6
-0@@ -171,6 +187,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, 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) +
I saw a lot of type checks (if (link->sink.type != MEDIA_GRAPH_PAD)) that I think would look cleaner if there was a simple static inline helper:
static inline bool is_pad(const struct media_graph_obj *obj)
{
return obj->type == MEDIA_GRAPH_PAD;
}media_is_pad() will work as well, but I think brevity is more useful in this case. Personal opinion, though.
include/media/media-entity.h struct media_entity_graph { · line 198
Quoted 4 lines
include/media/media-entity.h +0
-0void graph_obj_init (struct media_device *mdev,enum media_graph_type type,struct media_graph_obj *gobj);
Regards,
Hans
RFC PATCH v2 9/16 media: use media_graph_obj for link endpoints
Em Tue, 11 Aug 2015 14:25:18 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 3 lines
Hi Mauro,
Thanks for posting the missing patches.
Thanks for reviewing this patch series!
Quoted 33 lines · Mauro Carvalho Chehab
Quoted 20 lines
As we'll need to create links between entities and interfaces, we need to identify the link endpoints by the
media_graph_obj.Most of the changes here was done by this small script:
for i in
find drivers/media -type ffind drivers/staging/media -type f; doperl -ne 's,([\w]+)\-\>(source|sink)\-\>entity,gobj_to_pad($1->$2)->entity,; print $_;' <$i >a && mv a $idone
Please note that, while we're now using
graph_objto reference the link endpoints, we're still assuming that all endpoints are pads. This is true for all existing links, so no problems are expected so far.Yet, as we introduce links between entities and interfaces, we may need to change some existing code to work with links that aren't pad to pad.
Signed-off-by Mauro Carvalho Chehab <[email protected]><snip>
Quoted 8 lines
include/media/media-entity.h +0
-0@@ -43,6 +43,17 @@ enum media_graph_type { MEDIA_GRAPH_LINK, };
Quoted 13 lines
include/media/media-entity.h enum media_graph_type { · line 56
Quoted 11 lines
include/media/media-entity.h +11
-0+/** +* enum media_graph_link_dir - direction of a link +* +* @MEDIA_LINK_DIR_BIDIRECTIONAL Link is bidirectional +* @MEDIA_LINK_DIR_PAD_0_TO_1 Link is unidirectional, +* from port 0 (source) to port 1 (sink) +*/ +enum media_graph_link_dir { +MEDIA_LINK_DIR_BIDIRECTIONAL , +MEDIA_LINK_DIR_PORT0_TO_PORT1 , +};1) the comment and the actual enum are out-of-sync
Ah, yes. I was in doubt about using PAD or PORT here. I ended by using port at the links, as the endpoints can either be an interface/entity or a pad. So, I decided to use port.
Quoted 4 lines
2) why not just make a 'BIRECTIONAL' link flag instead of inventing a new enum? Adding yet another field seems overkill to me. Have a 'BIDIRECTIONAL' flag seems perfectly OK to me (and useful for the application as well).
Yeah, we can use flags, instead. I decided to use an enum here just to make it clearer about the two possible options.
I was actually considering to rename media_link source/sink to port0/port1, as using "source"/"sink" names on a bidirection link doesn't make sense. I'm still in doubt about such rename, though, as it would make harder to inspect the graph traversal routines.
Also, I want to force all places that create a link to choose between either BIRECTIONAL or PORT0_TO_PORT1, as this makes easier to review if the code is doing the right thing when inspecting it.
In summary, I would prefer to keep this internally as a separate
enum, at least for now. We can latter simplify it and use a flag
for that (or maybe two flags?).
Quoted 31 lines
Quoted 5 lines
include/media/media-entity.h +0
-0/* Structs to represent the objects that belong to a media graph */ include/media/media-entity.h struct media_pipeline { · line 88
Quoted 9 lines
include/media/media-entity.h +3
-3@@ -72,9 +83,9 @@ struct media_pipeline {struct media_link {struct list_head list; -struct media_graph_obj graph_obj; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +struct media_graph_obj graph_obj; +enum media_graph_link_dir dir; +struct media_graph_obj *source, *sink;I'm not too keen about all the
gobj_to_foo(obj)macros that this requires. It is rather ugly code.What about this:
union { struct media_graph_obj *source; struct media_pad *source_pad; struct media_interface *source_intf; }; union { struct media_graph_obj *sink; struct media_pad *sink_pad; struct media_entity *sink_ent; };
Quoted 1 line
Now the code can just use ->source_pad etc.
good idea. Will do that on a version 3. I think that, in this case, the best is to write a note that the first element at pad/entity/interface should be the graph_obj.
I would actually call port0_intf and port1_ent on the above structs, as it makes no sense to call sink/source for interface->entity links.
Quoted 30 lines
Quoted 16 lines
include/media/media-entity.h +5
-0struct media_link *reverse;/* Link in the reverse direction */ unsigned long flags;/* Link flags (MEDIA_LNK_FL_*) */ };@@ -115,6 +126,11 @@ struct media_entity {u32 group_id;/* Entity group ID */ u16 num_pads;/* Number of sink and source pads */ + +/* +* Both num_links and num_backlinks are used only to report +* the number of links via MEDIA_IOC_ENUM_ENTITIES at media_device.c +*/ u16 num_links;/* Number of existing links, both * enabled and disabled */ u16 num_backlinks;/* Number of backlinks */ include/media/media-entity.h struct media_entity_graph { · line 195
Quoted 9 lines
include/media/media-entity.h +6
-0@@ -171,6 +187,12 @@ struct media_entity_graph {#define gobj_to_entity (gobj) \ container_of(gobj, struct media_entity, 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) +I saw a lot of type checks (if (
link->sink.type!=MEDIA_GRAPH_PAD)) that I think would look cleaner if there was a simple static inline helper:
Quoted 7 lines
static inline bool
is_pad(const struct media_graph_obj *obj){ return obj->type == MEDIA_GRAPH_PAD; }
media_is_pad()will work as well, but I think brevity is more useful in this case. Personal opinion, though.
I would use media_is_pad() instead, to avoid namespace conflicts. We may eventually need other inline functions for other types in the future.
Quoted 9 lines
include/media/media-entity.h struct media_entity_graph { · line 198
Quoted 5 lines
include/media/media-entity.h +0
-0void graph_obj_init (struct media_device *mdev,enum media_graph_type type,struct media_graph_obj *gobj);Regards,
Hans
RFC PATCH v2 9/16 media: use media_graph_obj for link endpoints
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
include/media/media-entity.h +0
-0@@ -43,6 +43,17 @@ enum media_graph_type { MEDIA_GRAPH_LINK, };Quoted 13 lines
include/media/media-entity.h enum media_graph_type { · line 56
Quoted 11 lines
include/media/media-entity.h +11
-0+/** +* enum media_graph_link_dir - direction of a link +* +* @MEDIA_LINK_DIR_BIDIRECTIONAL Link is bidirectional +* @MEDIA_LINK_DIR_PAD_0_TO_1 Link is unidirectional, +* from port 0 (source) to port 1 (sink) +*/ +enum media_graph_link_dir { +MEDIA_LINK_DIR_BIDIRECTIONAL , +MEDIA_LINK_DIR_PORT0_TO_PORT1 , +};1) the comment and the actual enum are out-of-sync
Quoted 3 lines
Ah, yes. I was in doubt about using PAD or PORT here. I ended by using port at the links, as the endpoints can either be an interface/entity or a pad. So, I decided to use port.
It's either bi-directional (between interface and entity) or directional (between two pads), so I think PAD is better here. We don't use the term port anywhere else in the MC, so I think it is a bit confusing to introduce a new name here.
Quoted 6 lines
Quoted 5 lines
2) why not just make a 'BIRECTIONAL' link flag instead of inventing a new enum? Adding yet another field seems overkill to me. Have a 'BIDIRECTIONAL' flag seems perfectly OK to me (and useful for the application as well).
Quoted 7 lines
Yeah, we can use flags, instead. I decided to use an enum here just to make it clearer about the two possible options.
I was actually considering to rename
media_linksource/sink to port0/port1, as using "source"/"sink" names on a bidirection link doesn't make sense. I'm still in doubt about such rename, though, as it would make harder to inspect the graph traversal routines.
Right. I really wouldn't rename it. As suggested below using an anonymous union would allow you to create proper names.
Quoted 3 lines
Also, I want to force all places that create a link to choose between either BIRECTIONAL or
PORT0_TO_PORT1, as this makes easier to review if the code is doing the right thing when inspecting it.
By creating two different functions? I think that would be very useful. E.g. make_pad_link() and make_intf_to_ent_link() or something like that. That would also hide the link direction. I still prefer a flag, though :-) That's mostly personal preference, though.
Quoted 36 lines
In summary, I would prefer to keep this internally as a separate
enum, at least for now. We can latter simplify it and use a flag
for that (or maybe two flags?).Quoted 31 lines
Quoted 5 lines
include/media/media-entity.h +0
-0/* Structs to represent the objects that belong to a media graph */ include/media/media-entity.h struct media_pipeline { · line 88
Quoted 9 lines
include/media/media-entity.h +3
-3@@ -72,9 +83,9 @@ struct media_pipeline {struct media_link {struct list_head list; -struct media_graph_obj graph_obj; -struct media_pad *source;/* Source pad */ -struct media_pad *sink;/* Sink pad */ +struct media_graph_obj graph_obj; +enum media_graph_link_dir dir; +struct media_graph_obj *source, *sink;I'm not too keen about all the
gobj_to_foo(obj)macros that this requires. It is rather ugly code.What about this:
union { struct media_graph_obj *source; struct media_pad *source_pad; struct media_interface *source_intf; }; union { struct media_graph_obj *sink; struct media_pad *sink_pad; struct media_entity *sink_ent; };
Quoted 8 lines
Quoted 1 line
Now the code can just use ->source_pad etc.
good idea. Will do that on a version 3. I think that, in this case, the best is to write a note that the first element at pad/entity/interface should be the
graph_obj.I would actually call
port0_intfandport1_enton the above structs, as it makes no sense to call sink/source forinterface->entitylinks.
How about this:
union {
struct media_graph_obj *port0;
struct media_interface *port0_intf; // perhaps just intf or interface?
struct media_pad *source;
};
union {
struct media_graph_obj *port1;
struct media_entity *port1_ent; // perhaps just ent or entity?
struct media_pad *sink;
};
This has the advantage that the source/sink pads are still called source and sink and you don't have to rename the existing code.
Regards,
Hans
RFC PATCH v2 11/16 FIXUP: source link removal on failure
In reply to Mauro Carvalho Chehabdrivers/media/media-entity.c +4 -1
@@ -480,6 +480,9 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)return link; } +static void __media_entity_remove_link (struct media_entity *entity, +struct media_link *link); +int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags)
@@ -504,7 +507,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,*/ backlink =media_entity_add_link (sink);if (backlink ==NULL ) { - source->num_links--; +__media_entity_remove_link (source, link);return -ENOMEM ; }
Signature · 1 line
2.4.3
RFC PATCH v2 12/16 media: move __media_entity_remove_link to avoid prototype
In reply to Mauro Carvalho ChehabAs we need __media_entity_remove_link() earlier, move it to happen earlier, to avoid needing to have a function prototype.
No functional changes.
drivers/media/media-entity.c +30 -33
@@ -481,7 +481,36 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) }static void __media_entity_remove_link (struct media_entity *entity, -struct media_link *link); +struct media_link *link) +{ +struct media_link *rlink, *tmp; +struct media_entity *remote; +unsigned int r =0 ; + +if (gobj_to_pad (link->source)->entity == entity) + remote =gobj_to_pad (link->sink)->entity; +else + remote =gobj_to_pad (link->source)->entity; + +list_for_each_entry_safe (rlink, tmp, &remote->links, list) { +if (rlink != link->reverse) { + r++; +continue ; + } + +if (gobj_to_pad (link->source)->entity == entity) + remote->num_backlinks--; + +if (--remote->num_links ==0 ) +break ; + +/* Remove the remote link */ +list_del (&rlink->list); +kfree (rlink); + } +list_del (&link->list); +kfree (link); +} int media_create_pad_link(struct media_entity *source, u16 source_pad,
@@ -524,38 +553,6 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, }EXPORT_SYMBOL_GPL (media_create_pad_link); -static void __media_entity_remove_link (struct media_entity *entity, -struct media_link *link) -{ -struct media_link *rlink, *tmp; -struct media_entity *remote; -unsigned int r =0 ; - -if (gobj_to_pad (link->source)->entity == entity) - remote =gobj_to_pad (link->sink)->entity; -else - remote =gobj_to_pad (link->source)->entity; - -list_for_each_entry_safe (rlink, tmp, &remote->links, list) { -if (rlink != link->reverse) { - r++; -continue ; - } - -if (gobj_to_pad (link->source)->entity == entity) - remote->num_backlinks--; - -if (--remote->num_links ==0 ) -break ; - -/* Remove the remote link */ -list_del (&rlink->list); -kfree (rlink); - } -list_del (&link->list); -kfree (link); -} -void __media_entity_remove_links (struct media_entity *entity) {struct media_link *link, *tmp;
Signature · 1 line
2.4.3
RFC PATCH v2 13/16 media: make the internal function to create links more generic
In reply to Mauro Carvalho ChehabIn preparation to add a public function to add links, let's make the internal function that creates link more generic.
drivers/media/media-entity.c +24 -15
@@ -461,7 +461,12 @@ 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_create_link (struct media_device *mdev, +enum media_graph_link_dir dir, +struct media_graph_obj *port0, +struct media_graph_obj *port1, +u32 flags, +struct list_head *list) {struct media_link *link;
@@ -469,13 +474,17 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)if (link ==NULL )return NULL ; + link->dir = dir; + link->source = port0; + link->sink = port1; + link->flags = flags; + link->reverse->reverse = link;INIT_LIST_HEAD (&link->list); -list_add (&entity->links, &link->list); +list_add (list, &link->list);/* Initialize graph object embedded at the new link */ -graph_obj_init (entity->parent,MEDIA_GRAPH_LINK , - &link->graph_obj); +graph_obj_init (mdev,MEDIA_GRAPH_LINK , &link->graph_obj);return link; }
@@ -514,7 +523,7 @@ static void __media_entity_remove_link(struct media_entity *entity,int media_create_pad_link (struct media_entity *source,u16 source_pad, -struct media_entity *sink,u16 sink_pad,u32 flags) +struct media_entity *sink,u16 sink_pad,u32 flags) {struct media_link *link;struct media_link *backlink;
@@ -523,27 +532,27 @@ 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_create_link (source->parent, +MEDIA_LINK_DIR_PORT0_TO_PORT1 , + &source->pads[source_pad].graph_obj, + &sink->pads[sink_pad].graph_obj, + flags, &source->links);if (link ==NULL )return -ENOMEM ; - link->source = &source->pads[source_pad].graph_obj; - link->sink = &sink->pads[sink_pad].graph_obj; - link->flags = flags; -/* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ - backlink =media_entity_add_link (sink); + backlink =__media_create_link (sink->parent, +MEDIA_LINK_DIR_PORT0_TO_PORT1 , + &source->pads[source_pad].graph_obj, + &sink->pads[sink_pad].graph_obj, + flags, &sink->links);if (backlink ==NULL ) {__media_entity_remove_link (source, link);return -ENOMEM ; } - backlink->source = &source->pads[source_pad].graph_obj; - backlink->sink = &sink->pads[sink_pad].graph_obj; - backlink->flags = flags; - link->reverse = backlink; backlink->reverse = link;
Signature · 1 line
2.4.3
Re: [PATCH RFC v2 13/16] media: make the internal function to create links more generic
Quoted 10 lines · Mauro Carvalho Chehab
In preparation to add a public function to add links, let's make the internal function that creates link more generic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +0
-0
drivers/media/media-entity.c EXPORT_SYMBOL_GPL(media_entity_put); · line 465
Quoted 6 lines
drivers/media/media-entity.c +2
-1@@ -461,7 +461,12 @@ 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_create_link(struct media_device *mdev, + enum media_graph_link_dir dir,
Am I blind? I can't find the media_graph_link_dir enum definition anywhere in this patch series...
Regards,
Hans
Re: [PATCH RFC v2 13/16] media: make the internal function to create links more generic
Em Tue, 11 Aug 2015 12:57:04 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 14 lines · Mauro Carvalho Chehab
Quoted 13 lines
In preparation to add a public function to add links, let's make the internal function that creates link more generic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +0
-0@@ -461,7 +461,12 @@ EXPORT_SYMBOL_GPL(media_entity_put);* Links management */
Quoted 6 lines
drivers/media/media-entity.c EXPORT_SYMBOL_GPL(media_entity_put); · line 465
Quoted 3 lines
drivers/media/media-entity.c +2
-1-static struct media_link *media_entity_add_link (struct media_entity *entity) +static struct media_link *__media_create_link(struct media_device *mdev, + enum media_graph_link_dir dir,Am I blind? I can't find the
media_graph_link_direnum definition anywhere in this patch series...
There were a few patches that vger didn't seem to get. This one was added by patch 9:
0009-media-use-media_graph_obj-for-link-endpoints.patch
I'll try to resend the missing patches.
Regards,
Mauro
RFC PATCH v2 14/16 media: add a generic function to remove a link
In reply to Mauro Carvalho ChehabRemoving a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call.
drivers/media/media-entity.c +8 -4
@@ -489,6 +489,12 @@ static struct media_link *__media_create_link(struct media_device *mdev,return link; } +static void __media_remove_link (struct media_link *link) +{ +list_del (&link->list); +kfree (link); +} +static void __media_entity_remove_link (struct media_entity *entity,struct media_link *link) {
@@ -514,11 +520,9 @@ static void __media_entity_remove_link(struct media_entity *entity,break ;/* Remove the remote link */ -list_del (&rlink->list); -kfree (rlink); +__media_remove_link (rlink); } -list_del (&link->list); -kfree (link); +__media_remove_link (link); }int
Signature · 1 line
2.4.3
RFC PATCH v2 15/16 media: rename media_entity_remove_foo functions
In reply to Mauro Carvalho ChehabAs entities will also have links to interfaces, we need to rename the existing functions that remove links, to avoid namespace collision and confusion.
No functional changes.
The rename was made by this 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_remove,media_remove_pad,g <$i >a && mv a $i; done
drivers/media/media-entity.c +8 -8
@@ -495,7 +495,7 @@ static void __media_remove_link(struct media_link *link)kfree (link); } -static void __media_entity_remove_link (struct media_entity *entity, +static void __media_remove_pad_link (struct media_entity *entity,struct media_link *link) {struct media_link *rlink, *tmp;
@@ -553,7 +553,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, &sink->pads[sink_pad].graph_obj, flags, &sink->links);if (backlink ==NULL ) { -__media_entity_remove_link (source, link); +__media_remove_pad_link (source, link);return -ENOMEM ; }
@@ -566,29 +566,29 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, }EXPORT_SYMBOL_GPL (media_create_pad_link); -void __media_entity_remove_links (struct media_entity *entity) +void __media_remove_pad_links (struct media_entity *entity) {struct media_link *link, *tmp;list_for_each_entry_safe (link, tmp, &entity->links, list) -__media_entity_remove_link (entity, link); +__media_remove_pad_link (entity, link); entity->num_links =0 ; entity->num_backlinks =0 ; } -EXPORT_SYMBOL_GPL (__media_entity_remove_links); +EXPORT_SYMBOL_GPL (__media_remove_pad_links); -void media_entity_remove_links (struct media_entity *entity) +void media_remove_pad_links (struct media_entity *entity) {/* Do nothing if the entity is not registered. */ if (entity->parent ==NULL )return ;mutex_lock (&entity->parent->graph_mutex); -__media_entity_remove_links (entity); +__media_remove_pad_links (entity);mutex_unlock (&entity->parent->graph_mutex); } -EXPORT_SYMBOL_GPL (media_entity_remove_links); +EXPORT_SYMBOL_GPL (media_remove_pad_links);static int __media_entity_setup_link_notify (struct media_link *link,u32 flags) {
drivers/media/v4l2-core/v4l2-device.c +1 -1
@@ -285,7 +285,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)#if defined(CONFIG_MEDIA_CONTROLLER )if (v4l2_dev->mdev) { -media_entity_remove_links (&sd->entity); +media_remove_pad_links (&sd->entity);media_device_unregister_entity (&sd->entity); }#endif
include/media/media-entity.h +2 -2
@@ -204,8 +204,8 @@ void media_entity_cleanup(struct media_entity *entity);int media_create_pad_link (struct media_entity *source,u16 source_pad,struct media_entity *sink,u16 sink_pad,u32 flags); -void __media_entity_remove_links (struct media_entity *entity); -void media_entity_remove_links (struct media_entity *entity); +void __media_remove_pad_links (struct media_entity *entity); +void media_remove_pad_links (struct media_entity *entity);int __media_entity_setup_link (struct media_link *link,u32 flags);int media_entity_setup_link (struct media_link *link,u32 flags);
Signature · 1 line
2.4.3
Em Fri, 7 Aug 2015 11:19:58 -0300
Mauro Carvalho Chehab <[email protected]> escreveu:
Quoted 3 lines
This is the second version of an initial set of patches showing the approach I'm taking in order to fulfill all the MC needs that was discussed on the 3 day MC summit in Helsinki.
Weird, two patches of this series seem to have been rejected by vger...
In any case, the patches are at:
http://git.linuxtv.org/cgit.cgi/mchehab/experimental.git/log/?h=mc_next_gen
PS.: patch 11/16 should actually be merged with an earlier patch. I'll do the merge next time I'll need to resend this.
Quoted 195 lines
The goal of this patchset is:
1) to create a common struct that will be embedded on all internal structs that represents the comon data that will be used by all kinds of objects;
2) to have an unique object ID for each object in the graph. The object ID will be needed by the userspace API in the future, as discussed during the MC workshop;
3) to create objects to represent
Kernel->userspaceinterfaces;4) to extend the link support to allow linking interfaces to entities.
On version 2, I removed the kref, as some people at the #v4l channel are not convinced about its need. So, let's postpone such discussion when we start introducing patches that will actually do dynamic object removal in runtime.
As suggested, I'll be sending incremental patches and avoiding to do a large set of changes into one changeset series. That basically means that those patches aren't tested yet (except for compilation tests).
Along this patch series, I'll be calling "object" as any "symbol" that belongs to a media graph, like processing entities, connectors, links, pads, interfaces.
As said on the goals of this RFC, on version 2 of this patch series, we're coming with the new concept: interfaces.
An interface is a graph object that does the interaction between Kernelspace <===> Userspace. While the code written for interface creation and interface<==>entity link is generic, currently I added support only for the type of interface currently used at the existing MC graphs: device node interfaces. We should add other types of interfaces in a future patchset. For example, we need to add support for network interfaces in order to fulfill the needs of the DVB subsystem. We'll also need to add support for sysfs interfaces in order to support IIO and remote controllers.
Those API changes are aligned with the RFC for the userspace API proposed by Hans Verkuil:
http://www.spinics.net/lists/linux-media/msg92166.htmlThe only difference is that I'm using a single counter to generate an unique object ID, while Hans proposal is to use one per object type. As explained on my comments on the last patch series, the rationale is to simply simplify the code, helping to make the internal API changes clearer. We can change this latter before adding support for the userspace API.
I suspect that we'll also need another type to represent groups of objects, but this will be covered on future patches if/when needed.
No userspace API changes here, just changes at the internal structs that contains the media graph objects and some new helper functions.
===========
Future work
===========I think that, after changing the MC core to support the new proposed API, a next step would be to simplify the internal representation of the media objects, in order to make it easier to be reused on other subsystems like IIO and to spend less memory. With that regards, I think that we can get rid of some fields at the existing structures:
struct media_link.reverse - Currently we create two copies of the same link, in order to use at the graph traversal. I think we can remove it and use just one copy;
struct
media_entity- well, there are several things that we can get hid there:
- parent - we're already storing it at the objects;
- id - we have already an unique ID at the objects;
- type - this should be replaced by properties;
- revision - not used, afaikt;
-group_id- groups should really be a new object type that will have the list of object IDs that belong to the group.
- num_links/num_backlinks - those are used only at the userspace interface, but we need to track link creation/removal just to feed those things. I would remove those and add a logic atmedia_device.cto count;
-num_pads- if we convert pads to lists (with seems to be the best thing, as not all entities need pads), then we can get rid of this too;
- union info - this should be retrieved via the interface, and not via the entity.Yet, the above are suggestions for some future next steps. I won't probably address the above, except if needed in order to support the DVB or ALSA needs.
Mauro Carvalho Chehab (16):
media: Add some fields to store graph objects
media: Add a common embeed struct for all media graph objects
media: add functions to inializemedia_graph_obj
media: ensure that entities will have an object ID
media: initialize PAD objects
media: initialize the graph object inside the media links
media: get rid of unused "extra_links" param onmedia_entity_init()
media: convert links from array to list
media: usemedia_graph_objfor link endpoints
media: rename the function that create pad links
FIXUP: source link removal on failure
media: move__media_entity_remove_linkto avoid prototype
media: make the internal function to create links more generic
media: add a generic function to remove a link
media: renamemedia_entity_remove_foofunctions
media: add functions to allow creating interfacesDocumentation/media-framework.txt | 2 +- Documentation/video4linux/v4l2-framework.txt | 4 +- Documentation/zh_CN/video4linux/v4l2-framework.txt | 4 +- drivers/media/dvb-core/dvb_frontend.c | 10 +- drivers/media/dvb-core/dvbdev.c | 10 +- drivers/media/i2c/ad9389b.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/adv7511.c | 2 +- drivers/media/i2c/adv7604.c | 2 +- drivers/media/i2c/adv7842.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/mt9m032.c | 2 +- drivers/media/i2c/mt9p031.c | 2 +- drivers/media/i2c/mt9t001.c | 2 +- drivers/media/i2c/mt9v032.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 8 +- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 6 +- drivers/media/i2c/s5k6a3.c | 2 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 8 +- drivers/media/i2c/tc358743.c | 2 +- drivers/media/i2c/tvp514x.c | 2 +- drivers/media/i2c/tvp7002.c | 2 +- drivers/media/media-device.c | 48 ++- drivers/media/media-entity.c | 367 ++++++++++++++------- drivers/media/platform/exynos4-is/fimc-capture.c | 4 +- drivers/media/platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-isp.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 4 +- drivers/media/platform/exynos4-is/fimc-m2m.c | 2 +- drivers/media/platform/exynos4-is/media-dev.c | 18 +- drivers/media/platform/exynos4-is/mipi-csis.c | 2 +- drivers/media/platform/omap3isp/isp.c | 22 +- drivers/media/platform/omap3isp/ispccdc.c | 6 +- drivers/media/platform/omap3isp/ispccp2.c | 4 +- drivers/media/platform/omap3isp/ispcsi2.c | 4 +- drivers/media/platform/omap3isp/isppreview.c | 6 +- drivers/media/platform/omap3isp/ispresizer.c | 6 +- drivers/media/platform/omap3isp/ispstat.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 2 +- drivers/media/platform/s3c-camif/camif-capture.c | 4 +- drivers/media/platform/s3c-camif/camif-core.c | 4 +- drivers/media/platform/vsp1/vsp1_drv.c | 4 +- drivers/media/platform/vsp1/vsp1_entity.c | 2 +- drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +- drivers/media/usb/cx231xx/cx231xx-video.c | 18 +- drivers/media/usb/uvc/uvc_entity.c | 6 +- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-device.c | 2 +- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 6 +- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 4 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 4 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 14 +- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- drivers/staging/media/omap4iss/iss.c | 18 +- drivers/staging/media/omap4iss/iss_csi2.c | 6 +- drivers/staging/media/omap4iss/iss_ipipe.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 4 +- drivers/staging/media/omap4iss/iss_resizer.c | 4 +- drivers/staging/media/omap4iss/iss_video.c | 2 +- include/media/media-device.h | 4 + include/media/media-entity.h | 130 +++++++- 80 files changed, 575 insertions(+), 302 deletions(-)
RFC PATCH v2 16/16 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 +56 -0
@@ -741,3 +741,59 @@ 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 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + devnode->major = major; + devnode->minor = minor; +INIT_LIST_HEAD (&devnode->intf.entity_links); + +graph_obj_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) +{ +graph_obj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); + +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_graph_obj *gobj, +u32 flags) +{ +struct media_link *link; + +/* Only accept links between entity<==>interface */ +if (gobj->type !=MEDIA_GRAPH_INTF_DEVNODE ) +return NULL ; + + link =__media_create_link (entity->parent, +MEDIA_LINK_DIR_BIDIRECTIONAL , + &entity->graph_obj, + gobj, + flags, &entity->intf_links); +if (link ==NULL ) +return NULL ; + +/* Create the link at the interface */ +list_add (&gobj_to_interface (gobj)->entity_links, &link->list); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link);
include/media/media-entity.h +41 -1
77 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [PATCH RFC v2 16/16] media: add functions to allow creating interfaces
Quoted 10 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.
So, to be clear, the plan is to replace the embedded media_entity struct in struct video_device by a struct media_intf_devnode pointer that is allocated with media_devnode_create()?
Can we keep struct media_intf_devnode embedded in struct video_device? Or is that impossible since all media_graph_obj structs are expected to be allocated?
I do have a preference for keeping structs embedded, unless there is a good reason not to. I just want to make sure there is a good reason.
Regards,
Hans
Quoted 154 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +56
-0@@ -741,3 +741,59 @@ 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 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + devnode->major = major; + devnode->minor = minor; +INIT_LIST_HEAD (&devnode->intf.entity_links); + +graph_obj_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) +{ +graph_obj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); + +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_graph_obj *gobj, +u32 flags) +{ +struct media_link *link; + +/* Only accept links between entity<==>interface */ +if (gobj->type !=MEDIA_GRAPH_INTF_DEVNODE ) +return NULL ; + + link =__media_create_link (entity->parent, +MEDIA_LINK_DIR_BIDIRECTIONAL , + &entity->graph_obj, + gobj, + flags, &entity->intf_links); +if (link ==NULL ) +return NULL ; + +/* Create the link at the interface */ +list_add (&gobj_to_interface (gobj)->entity_links, &link->list); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link);include/media/media-entity.h +41
-1@@ -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_graph_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };/** @@ -136,7 +139,9 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads elements) */ -struct list_head links;/* Links list */ +struct list_head links;/* PAD links list */ + +struct list_head intf_links;/* Interface links list */ const struct media_entity_operations *ops;/* Entity operations */ @@ -161,6 +166,30 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @ent_links: List of links pointing to graph entities +*/ +struct media_interface { +struct media_graph_obj graph_obj; +struct list_head entity_links; +}; + +/** +* 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 ;@@ -193,6 +222,9 @@ struct media_entity_graph {#define gobj_to_pad (gobj) \ container_of(gobj, struct media_pad, graph_obj) +#define gobj_to_interface (gobj) \ + container_of(gobj, struct media_interface, graph_obj) +void graph_obj_init (struct media_device *mdev,enum media_graph_type type,struct media_graph_obj *gobj);@@ -224,6 +256,14 @@ __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 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_graph_obj *gobj, +u32 flags); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Re: [PATCH RFC v2 16/16] media: add functions to allow creating interfaces
Em Tue, 11 Aug 2015 13:14:41 +0200
Hans Verkuil <[email protected]> escreveu:
Quoted 8 lines · Mauro Carvalho Chehab
Quoted 7 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.
Quoted 7 lines
Quoted 3 lines
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.
So, to be clear, the plan is to replace the embedded
media_entitystruct in structvideo_deviceby a structmedia_intf_devnodepointer that is allocated withmedia_devnode_create()?
Yes.
Quoted 7 lines
Can we keep struct
media_intf_devnodeembedded in structvideo_device? Or is that impossible since allmedia_graph_objstructs are expected to be allocated?I do have a preference for keeping structs embedded, unless there is a good reason not to. I just want to make sure there is a good reason.
My plan is to always allocate the structs, as we'll very likely need to have kref for all those structs, in order to be sure that they'll be freed only after having all their usages stopped.
The thing is that it is really complex when we have lots of objects linked to know when an object is not used anymore.
Let's assume, for example, this simple graph:
entity 0 pad 0 entity 1 pad 0 pad 1 entity 2 pad 0 link 0 entity 0:pad 0 -> entity 1: pad 0 link 1 entity 1:pad 1 -> entity 2: pad 0
If we need to keep back references for the links, we'll end by having both links 0 and 1 used twice.
We can't free neither the entities or the pads while link 0 is not freed, but it is used twice: as a link and as a backlink.
Assuming that we want to free all those objects from the memory, It can be really tricky to find the right order to free them, as we need first to go into the 3 entities and free the links there, then we can free the pads and entities.
If, on the other hand, we use kref, we can simply do a for on all objects and call kref_put(). The object memory will be freed in an order that will be safe, e. g. when all kref counts are zero for that specific object.
I actually postponed the usage of kref because it is a little hard to de-embed the entities on subdevices, but IMHO, using kref is the best and safest way to be sure that the Kernel won't be accessing a freed memory as the graph dynamically changes.
Regards,
Mauro
Quoted 159 lines
Regards,
Hans
Quoted 154 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>drivers/media/media-entity.c +56
-0@@ -741,3 +741,59 @@ 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 major,u32 minor, +gfp_t gfp_flags) +{ +struct media_intf_devnode *devnode; + + devnode =kzalloc (sizeof (*devnode), gfp_flags); +if (!devnode) +return NULL ; + + devnode->major = major; + devnode->minor = minor; +INIT_LIST_HEAD (&devnode->intf.entity_links); + +graph_obj_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) +{ +graph_obj_remove (&devnode->intf.graph_obj); +kfree (devnode); +} +EXPORT_SYMBOL_GPL (media_devnode_remove); + +struct media_link *media_create_intf_link (struct media_entity *entity, +struct media_graph_obj *gobj, +u32 flags) +{ +struct media_link *link; + +/* Only accept links between entity<==>interface */ +if (gobj->type !=MEDIA_GRAPH_INTF_DEVNODE ) +return NULL ; + + link =__media_create_link (entity->parent, +MEDIA_LINK_DIR_BIDIRECTIONAL , + &entity->graph_obj, + gobj, + flags, &entity->intf_links); +if (link ==NULL ) +return NULL ; + +/* Create the link at the interface */ +list_add (&gobj_to_interface (gobj)->entity_links, &link->list); + +return link; +} +EXPORT_SYMBOL_GPL (media_create_intf_link);include/media/media-entity.h +41
-1@@ -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_graph_type {MEDIA_GRAPH_ENTITY ,MEDIA_GRAPH_PAD ,MEDIA_GRAPH_LINK , +MEDIA_GRAPH_INTF_DEVNODE , };/** @@ -136,7 +139,9 @@ struct media_entity {u16 num_backlinks;/* Number of backlinks */ struct media_pad *pads;/* Pads array (num_pads elements) */ -struct list_head links;/* Links list */ +struct list_head links;/* PAD links list */ + +struct list_head intf_links;/* Interface links list */ const struct media_entity_operations *ops;/* Entity operations */ @@ -161,6 +166,30 @@ struct media_entity { } info; }; +/** +* struct media_intf_devnode - Define a Kernel API interface +* +* @graph_obj: embedded graph object +* @ent_links: List of links pointing to graph entities +*/ +struct media_interface { +struct media_graph_obj graph_obj; +struct list_head entity_links; +}; + +/** +* 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 ;@@ -193,6 +222,9 @@ struct media_entity_graph {#define gobj_to_pad (gobj) \ container_of(gobj, struct media_pad, graph_obj) +#define gobj_to_interface (gobj) \ + container_of(gobj, struct media_interface, graph_obj) +void graph_obj_init (struct media_device *mdev,enum media_graph_type type,struct media_graph_obj *gobj);@@ -224,6 +256,14 @@ __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 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_graph_obj *gobj, +u32 flags); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
Re: [PATCH RFC v2 16/16] media: add functions to allow creating interfaces
Quoted 66 lines · Mauro Carvalho Chehab
Em Tue, 11 Aug 2015 13:14:41 +0200
Hans Verkuil <[email protected]> escreveu:Quoted 8 lines · Mauro Carvalho Chehab
Quoted 7 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.
Quoted 7 lines
Quoted 3 lines
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.
So, to be clear, the plan is to replace the embedded
media_entitystruct in structvideo_deviceby a structmedia_intf_devnodepointer that is allocated withmedia_devnode_create()?Yes.
Quoted 7 lines
Can we keep struct
media_intf_devnodeembedded in structvideo_device? Or is that impossible since allmedia_graph_objstructs are expected to be allocated?I do have a preference for keeping structs embedded, unless there is a good reason not to. I just want to make sure there is a good reason.
My plan is to always allocate the structs, as we'll very likely need to have kref for all those structs, in order to be sure that they'll be freed only after having all their usages stopped.
The thing is that it is really complex when we have lots of objects linked to know when an object is not used anymore.
Let's assume, for example, this simple graph:
entity 0 pad 0 entity 1 pad 0 pad 1 entity 2 pad 0 link 0 entity 0:pad 0 -> entity 1: pad 0 link 1 entity 1:pad 1 -> entity 2: pad 0If we need to keep back references for the links, we'll end by having both links 0 and 1 used twice.
We can't free neither the entities or the pads while link 0 is not freed, but it is used twice: as a link and as a backlink.
Assuming that we want to free all those objects from the memory, It can be really tricky to find the right order to free them, as we need first to go into the 3 entities and free the links there, then we can free the pads and entities.
If, on the other hand, we use kref, we can simply do a for on all objects and call
kref_put(). The object memory will be freed in an order that will be safe, e. g. when all kref counts are zero for that specific object.
Quoted 4 lines
I actually postponed the usage of kref because it is a little hard to de-embed the entities on subdevices, but IMHO, using kref is the best and safest way to be sure that the Kernel won't be accessing a freed memory as the graph dynamically changes.
OK, I agree. I just wanted to make sure I understood the reason for this change.
Regards,
Hans