aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-01-11[media] media: Move media graph state for streamon/off to the pipelineSakari Ailus2-8/+14
The struct media_entity_graph was allocated in the stack, limiting the number of entities that could be reasonably allocated. Instead, move the struct to struct media_pipeline which is typically allocated using kmalloc() instead. The intent is to keep the enumeration around for later use for the duration of the streaming. As streaming is eventually stopped, an unfortunate memory allocation failure would prevent stopping the streaming. As no memory will need to be allocated, the problem is avoided altogether. Signed-off-by: Sakari Ailus <[email protected]> Reviewed-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: Add KernelDoc documentation for struct media_entity_graphSakari Ailus1-0/+9
KernelDoc doesn't appear to handle anonymous structs defined inside another gracefully. As the struct is internal to the framework graph walk algorithm, detailed documentation isn't seen very important. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: Move struct media_entity_graph definition upSakari Ailus1-10/+10
It will be needed in struct media_pipeline shortly. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: Add an API to manage entity enumerationsSakari Ailus3-8/+188
This is useful in e.g. knowing whether certain operations have already been performed for an entity. The users include the framework itself (for graph walking) and a number of drivers. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: Introduce internal index for media entitiesSakari Ailus3-0/+24
The internal index can be used internally by the framework in order to keep track of entities for a purpose or another. The internal index is constant while it's registered to a media device, but the same index may be re-used once the entity having that index is unregistered. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] v4l2-device: fix a missing error codeDan Carpenter1-1/+3
We need to set "err = -ENOMEM" here. Fixes: 38b11f19667a ('[media] v4l2-core: create MC interfaces for devnodes') Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: copy_to/from_user() returns positiveDan Carpenter1-6/+5
The copy_to/from_user() functions return the number of bytes *not* copied. They don't return error codes. Fixes: 4f6b3f363475 ('media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl') Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: set topology version 0 at media registrationJavier Martinez Canillas1-0/+4
The G_TOPOLOGY ioctl is used to get a graph topology and since in the future a graph can be dynamically updated, there is a way to know the topology version so userspace can be aware that the graph has changed. The version 0 is reserved to indicate that the graph is static (i.e no graphs updates since the media device was registered). So, now that the media device initialization and registration has been split and the media device node is not exposed to user-space until all the entities have been registered and links created, it is safe to set a topology version 0 in media_device_register(). Suggested-by: Laurent Pinchart <[email protected]> Suggested-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] v4l2-device: Register entity before calling subdev's registered opsSakari Ailus1-10/+11
Registering a V4L2 sub-device includes, among other things, registering the related media entity and calling the sub-device's registered op. Since patch "media: convert links from array to list", creating a link between two pads requires registering the entity first. If the registered() op involves link creation, the link list head will not be initialised before it is used. Resolve this by first registering the entity, then calling its registered() op. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] usb: check media device errorsMauro Carvalho Chehab4-20/+54
There are now two new warnings: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_media_device_register': drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:433:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result] media_device_register(adap->dvb_adap.mdev); ^ drivers/media/usb/dvb-usb/dvb-usb-dvb.c: In function 'dvb_usb_media_device_register': drivers/media/usb/dvb-usb/dvb-usb-dvb.c:128:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result] media_device_register(adap->dvb_adap.mdev); ^ Those are because the drivers are not properly checking if the media device init and register were succeeded. Fix it. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: split media initialization and registrationJavier Martinez Canillas14-99/+158
The media device node is registered and so made visible to user-space before entities are registered and links created which means that the media graph obtained by user-space could be only partially enumerated if that happens too early before all the graph has been created. To avoid this race condition, split the media init and registration in separate functions and only register the media device node when all the pending subdevices have been registered, either explicitly by the driver or asynchronously using v4l2_async_register_subdev(). The media_device_register() had a check for drivers not filling dev and model fields but all drivers in mainline set them and not doing it will be a driver bug so change the function return to void and add a BUG_ON() for dev being NULL instead. Also, add a media_device_cleanup() function that will destroy the graph_mutex that is initialized in media_device_init(). [[email protected]: Fix compilation if !CONFIG_MEDIA_CONTROLLER and remove two warnings added by this changeset] Suggested-by: Sakari Ailus <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: better lock media_device_unregister()Mauro Carvalho Chehab1-10/+24
If media_device_unregister() is called by two different drivers, a race condition may happen, as the check if the device is not registered is not protected. Move the spin_lock() to happen earlier in the function, in order to prevent such race condition. Reported-by: Shuah Khan <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: move media entity register/unregister functionsMauro Carvalho Chehab1-80/+80
media entity register and unregister functions are called by media device register/unregister. Move them to occur earlier, as we'll need an unlocked version of media_device_entity_unregister() and we don't want to add a function prototype without needing it. No functional changes. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: check before unregister if mdev was registeredJavier Martinez Canillas1-0/+6
Most media functions that unregister, check if the corresponding register function succeed before. So these functions can safely be called even if a registration was never made or the component as already been unregistered. Add the same check to media_device_unregister() function for consistency. This will also allow to split the media_device_register() function in an initialization and registration functions without the need to change the generic cleanup functions and error code paths for all the media drivers. Suggested-by: Sakari Ailus <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity: cache media_device on object removalMauro Carvalho Chehab1-8/+18
As pointed by Dan, the commit f8fd4c61b5ae ("[media] media-entity: protect object creation/removal using spin lock")' leads to the following static checker warning: drivers/media/media-entity.c:781 media_remove_intf_link() error: dereferencing freed memory 'link' drivers/media/media-entity.c 777 void media_remove_intf_link(struct media_link *link) 778 { 779 spin_lock(&link->graph_obj.mdev->lock); 780 __media_remove_intf_link(link); 781 spin_unlock(&link->graph_obj.mdev->lock); In practice, I didn't see any troubles even with KASAN enabled. I guess gcc optimizer internally cached the mdev reference, instead of getting it twice. Yet, it is a very bad idea to rely on such optimization. So, let's fix the code. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity: use mutes for link setupMauro Carvalho Chehab1-2/+2
Changeset f8fd4c61b5ae ("[media] media-entity: protect object creation/removal using spin lock") changed the object creation/removal protection to spin lock, as this is what's used on media-device, keeping the mutex reserved for graph traversal routines. However, it also changed the link setup, by mistake. This could cause troubles, as the link setup can affect the graph traversal, and this is likely the reason for a mutex there. So, revert media_entity_setup_link() to use mutex. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-devnode.h: document the remaining struct/functionsMauro Carvalho Chehab1-1/+26
There is one struct and two functions that were not documented. Add the corresponding kernel-doc documentation for them. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-devnode: move kernel-doc documentation to the headerMauro Carvalho Chehab2-24/+27
As we're using the headers file only for documentation, move the two kernel-doc macros to the header, and fix it to avoid warnings. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device.h: document the last functionsMauro Carvalho Chehab2-7/+22
Add kernel-doc documentation for media_device_get_devres and media_device_find_devres. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity.h: Document some ancillary functionsMauro Carvalho Chehab1-1/+57
Add a basic documentation for most ancillary functions. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: Enforce single entity->pipe in a pipelineSakari Ailus1-1/+6
If a different entity->pipe in a pipeline was encountered, a warning was issued but the execution continued as if nothing had happened. Return an error instead right there. Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] DocBook: Document MEDIA_IOC_G_TOPOLOGYMauro Carvalho Chehab2-0/+392
Add description for this new media controller ioctl. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] DocBook: add a table for Media Controller interfacesMauro Carvalho Chehab1-0/+61
Document the media controller interfaces at the media uAPI docbook. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] Docbook: media-types.xml: update the existing tablesMauro Carvalho Chehab1-1/+14
There were some changes on the media types that were not reflected on the types tables. Update them to reflect the upstream changes. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] DocBook: move data types to a separate sectionMauro Carvalho Chehab4-160/+169
As MEDIA_IOC_G_TOPOLOGY shares the data types already declared for entities, pads and links, we should move those to a separate part of the document, and use cross-references where needed. So, move the following tables to a separate section at the DocBook: media-entity-type media-entity-flag media-pad-flag media-link-flag Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] DocBook: MC: add the concept of interfacesMauro Carvalho Chehab1-14/+26
The Media Controller next generation patches added a new graph element type: interfaces. It also allows links between interfaces and entities. Update the docbook to reflect that. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] dvbdev: Document the new MC-related fieldsMauro Carvalho Chehab1-2/+10
The Media Controller next gen patchset added several new fields to be used with it. Document them. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media.h: let be clear that tuners need to use connectorsMauro Carvalho Chehab1-1/+6
The V4L2 core won't be adding connectors to the tuners and other entities that need them. Let it be clear. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: move MEDIA_LNK_FL_INTERFACE_LINK logic to link creationMauro Carvalho Chehab2-5/+2
Instead of flagging an interface link as MEDIA_LNK_FL_INTERFACE_LINK only when returning to userspace, do it at link creation time. That would allow using such flag internally, and cleans up a little bit the code for G_TOPOLOGY ioctl. [[email protected]: folded with a fixup from Dan Carpenter, replacing & by &&] Suggested-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity: remove unneded enclosing parenthesisJavier Martinez Canillas1-2/+2
Commit 86ee417578a2 ("[media] media: convert links from array to list") had many changes that were automated using coccinelle but the semantic patch was not smart enough to rely on operators precedence and avoid using unnecessary enclosing parenthesis. This patch removes them since are not needed. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] uvcvideo: register entity subdev on initJavier Martinez Canillas1-24/+9
The uvc_mc_register_entities() function iterated over the entities three times to initialize the entities, register the subdev for the ones whose type was UVC_TT_STREAMING and to create the entities links. But this can be simplied by merging the init and registration logic in a single loop. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] uvcvideo: remove pads prefix from uvc_mc_create_pads_links()Javier Martinez Canillas1-3/+3
The function uvc_mc_create_pads_links() creates entities links but the "pads" prefix is redundant since the driver doesn't handle any other kind of link, so it can be removed. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] v4l: vsp1: use else if instead of continue when creating linksJavier Martinez Canillas1-9/+5
The for loop in the vsp1_create_entities() function that create the links, checks the entity type and call the proper link creation function but then it uses continue to force the next iteration of the loop to take place and skipping code in between that creates links for different entities types. It is more readable and easier to understand if the if else constructs is used instead of the continue statement. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] v4l: vsp1: remove pads prefix from *_create_pads_links()Javier Martinez Canillas4-8/+8
The functions that create entities links are called *_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can be removed. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] staging: omap4iss: remove pads prefix from *_create_pads_links()Javier Martinez Canillas7-15/+15
The functions that create ISS internal and external entities links are called *_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can be removed. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] omap3isp: consistently use v4l2_dev var in complete notifierJavier Martinez Canillas1-1/+1
The isp_subdev_notifier_complete() complete callback defines a struct v4l2_device *v4l2_dev to avoid needing two level of indirections to access the V4L2 subdevs but the var is not always used when possible as when calling v4l2_device_register_subdev_nodes(). So change that to consistently use the defined v4l2_dev pointer var. Suggested-by: Sakari Ailus <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] omap3isp: rename single labels to just errorJavier Martinez Canillas2-4/+4
Commit bc36b30fe06b ("[media] omap3isp: separate links creation from entities init") moved the link creation logic from the entities init functions and so removed the error_link labels from the error paths. But after that, some functions have a single error label so it makes more sense to rename the label to just "error" in thi case. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] omap3isp: remove pads prefix from isp_create_pads_links()Javier Martinez Canillas1-4/+8
The function that creates the links between ISP internal and external entities is called isp_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can just be removed. While being there, fix the function's kernel-doc since is not using a proper format. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] omap3isp: remove per ISP module link creation functionsJavier Martinez Canillas11-108/+35
The entities to video nodes links were created on separate functions for each ISP module but since the only thing that these functions do is to call media_create_pad_link(), there's no need for that indirection level and all link creation logic can be just inlined in the caller function. Also, since the only possible failure for the link creation is a memory allocation, there is no need for error messages since the core already reports a very verbose message in that case. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device: Use u64 ints for pointersMauro Carvalho Chehab2-51/+58
By using u64 integers and pointers, we can get rid of compat32 logic. So, let's do it! Suggested-by: Arnd Bergmann <[email protected]> Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device.h: Let clearer that entity function must be initializedMauro Carvalho Chehab2-1/+5
Improve the documentation to let it clear that the entity function must be initialized. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: use unsigned for pad indexMauro Carvalho Chehab11-11/+11
The pad index is unsigned. Replace the occurences of it where pertinent. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity.h: move kernel-doc tags from media-entity.cMauro Carvalho Chehab2-154/+145
Several additional functions are described at media-entity.c. Moving them to the header file, to make the code cleaner and to have all such macros at the same place. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media_entity: rename media_obj functions to *_create *_destroyMauro Carvalho Chehab3-20/+20
Those media_obj_* functions are actually creating/destroying media graph objects. So, rename them to better represent what they're actually doing. No functional changes. This was created via this small shell script: for i in $(git grep -l media_gobj_init); do sed s,media_gobj_init,media_gobj_create,g <$i >a && mv a $i; done for i in $(git grep -l media_gobj_remove); do sed s,media_gobj_remove,media_gobj_destroy,g <$i >a && mv a $i; done Suggested-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media_entity: get rid of a unused varMauro Carvalho Chehab1-4/+1
> > > + if (rlink != link->reverse) { > > > + r++; > > > > The variable is incremented here but otherwise never used, you can remove it. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity: get rid of forward __media_entity_remove_link() ↵Mauro Carvalho Chehab1-35/+32
declaration Move this function to happen earlier, in order to avoid a uneeded forward declaration. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media: remove extra blank linesMauro Carvalho Chehab2-5/+0
No functional changes. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-device.h: Improve documentation and update itMauro Carvalho Chehab2-238/+339
Now that we moved the content of the media-framework.txt into the kerneldoc documentation, move the per-function specific documentation to the corresponding functions and clean it up. It would be good if we had already the markdown kernel-doc patches merged upstream, but, while we doesn't have it, let's make it less ugly at device-drivers.xml. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] media-entity.h: convert media_entity_cleanup to inlineMauro Carvalho Chehab2-7/+2
This function was used in the past to free the links that were allocated by the media controller core. However, this is not needed anymore. We should likely get rid of the funcion on some function, but, for now, let's just convert into an inlined function and let the compiler to get rid of it. Suggested-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2016-01-11[media] DocBook: Move media-framework.txt contents to media-device.hMauro Carvalho Chehab3-373/+379
Instead of using a text file, let's put it together with the struct documentation for the Media Controller. Signed-off-by: Mauro Carvalho Chehab <[email protected]>