summaryrefslogtreecommitdiffstats
path: root/drivers/media/media-entity.c
Commit message (Collapse)AuthorAgeFilesLines
* media: move drivers/media/media-* to drivers/media/mc/mc-*Hans Verkuil2019-05-281-1036/+0
| | | | | | | | | | | | | | It is really weird that the media controller sources are all top-level in drivers/media. It is a bit of a left-over from long ago when most media sources were all at the top-level. At some point we reorganized the directory structure, but the media-*.c sources where never moved to their own directory. So create a new mc directory and move all sources there. Also rename the prefix from media- to mc-. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: replace WARN_ON in __media_pipeline_start()Shuah Khan2019-03-191-1/+4
| | | | | | | | | | | | __media_pipeline_start() does WARN_ON() when active pipe doesn't match the input arg entity's pipe. Replace WARN_ON with a conditional and error message that includes names of both entities. Signed-off-by: Shuah Khan <shuah@kernel.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-subdev: handle module refcounting hereHans Verkuil2019-03-191-28/+0
| | | | | | | | | | | | | | | | | | | | The module ownership refcounting was done in media_entity_get/put, but that was very confusing and it did not work either in case an application had a v4l-subdevX device open and the module was unbound. When the v4l-subdevX device was closed the media_entity_put was never called and the module refcount was left one too high, making it impossible to unload it. Since v4l2-subdev.c was the only place where media_entity_get/put was called, just move the functionality to v4l2-subdev.c and drop those confusing entity functions. Store the module in subdev_fh so module_put no longer depends on the media_entity struct. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-mc: switch it to use the new approach to setup pipelinesMauro Carvalho Chehab2018-09-171-0/+26
| | | | | | | | | Instead of relying on a static map for pids, use the new sig_type "taint" type to setup the pipelines with the same tipe between different entities. Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: media.h: reorganize header to make it easier to understandHans Verkuil2018-02-261-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The media.h public header is very messy. It mixes legacy and 'new' defines and it is not easy to figure out what should and what shouldn't be used. It also contains confusing comment that are either out of date or completely uninteresting for anyone that needs to use this header. The patch groups all entity functions together, including the 'old' defines based on the old range base. The reader just wants to know about the available functions and doesn't care about what range is used. All legacy defines are moved to the end of the header, so it is easier to locate them and just ignore them. The legacy structs in the struct media_entity_desc are put under also a much more effective signal to the reader that they shouldn't be used compared to the old method of relying on '#if 1' followed by a comment. The unused MEDIA_INTF_T_ALSA_* defines are also moved to the end of the header in the legacy area. They are also dropped from intf_type() in media-entity.c. All defines are also aligned at the same tab making the header easier to read. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> [mchehab@s-opensource.com: removed lots of spaces before tabs; typo changes ->change ] Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Check for active and has_no_links overrunSakari Ailus2017-10-041-5/+8
| | | | | | | | | | | The active and has_no_links arrays will overrun in media_entity_pipeline_start() if there's an entity which has more than MEDIA_ENTITY_MAX_PAD pads. Ensure in media_entity_init() that there are fewer pads than that. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* media: Make parameter of media_entity_remote_pad() constTodor Tomov2017-07-201-1/+1
| | | | | | | | | The local pad parameter in media_entity_remote_pad() is not modified. Make that explicit by adding a const modifier. Signed-off-by: Todor Tomov <todor.tomov@linaro.org> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Catch unbalanced media_pipeline_stop callsKieran Bingham2017-06-231-1/+6
| | | | | | | | | | | | | | | | Drivers must not perform unbalanced calls to stop the entity pipeline, however if they do they will fault in the core media code, as the entity->pipe will be set as NULL. We handle this gracefully in the core with a WARN for the developer. Replace the erroneous check on zero streaming counts, with a check on NULL pipe elements instead, as this is the symptom of unbalanced media_pipeline_stop calls. Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pincharts@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Add media_entity_get_fwnode_pad() functionNiklas Söderlund2017-06-201-0/+36
| | | | | | | | | This is a wrapper around the media entity get_fwnode_pad operation. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media-entity: only call dev_dbg_obj if mdev is not NULLHelen Fornazier2017-04-191-2/+2
| | | | | | | | Fix kernel Oops NULL pointer deference Call dev_dbg_obj only after checking if gobj->mdev is not NULL Signed-off-by: Helen Koike <helen.koike@collabora.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Add debug information to graph walkSakari Ailus2017-01-301-1/+18
| | | | | | | | | Use dev_dbg() to tell about the progress of the graph traversal algorithm. This is intended to make debugging of the algorithm easier. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Use single quotes to quote entity namesSakari Ailus2017-01-301-2/+2
| | | | | | | | | | Instead of double quotes, use single quotes to quote entity names. Using single quotes is consistent with the English language and is also in line with the practices across the kernel. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Split graph walk iteration into two functionsSakari Ailus2017-01-271-26/+30
| | | | | | | | | | With media_entity_graph_walk_next() getting more and more complicated (and especially so with has_routing() support added), split the function into two. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Rename graph and pipeline structs and functionsSakari Ailus2017-01-271-39/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The media_entity_pipeline_start() and media_entity_pipeline_stop() functions are renamed as media_pipeline_start() and media_pipeline_stop(), respectively. The reason is two-fold: the pipeline struct is, rightly, already called media_pipeline (rather than media_entity_pipeline) and what this really is about is a pipeline. A pipeline consists of entities --- and, well, other objects embedded in these entities. As the pipeline object will be in the future moved from entities to pads in order to support multiple pipelines through a single entity, do the renaming now. Similarly, functions operating on struct media_entity_graph as well as the struct itself are renamed by dropping the "entity_" part from the prefix of the function family and the data structure. The graph traversal which is what the functions are about is not specifically about entities only and will operate on pads for the same reason as the media pipeline. The patch has been generated using the following command: git grep -l media_entity |xargs perl -i -pe ' s/media_entity_pipeline/media_pipeline/g; s/media_entity_graph/media_graph/g' And a few manual edits related to line start alignment and line wrapping. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Be vocal about failing sanity checksSakari Ailus2017-01-271-4/+4
| | | | | | | | | | | Commit 3801bc7d1b8d ("[media] media: Media Controller fix to not let stream_count go negative") added a sanity check for negative stream_count, but a failure of the check remained silent. Make sure the failure is noticed. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: entity: Fix stream count checkSakari Ailus2017-01-271-1/+1
| | | | | | | | | | | | There's a sanity check for the stream count remaining positive or zero on error path, but instead of performing the check on the traversed entity it is performed on the entity where traversal ends. Fix this. Fixes: commit 3801bc7d1b8d ("[media] media: Media Controller fix to not let stream_count go negative") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Drop FSF's postal address from the source code filesSakari Ailus2017-01-271-4/+0
| | | | | | | | | | | | | | | | | | | | | Drop the FSF's postal address from the source code files that typically contain mostly the license text. Of the 628 removed instances, 578 are outdated. The patch has been created with the following command without manual edits: git grep -l "675 Mass Ave\|59 Temple Place\|51 Franklin St" -- \ drivers/media/ include/media|while read i; do i=$i perl -e ' open(F,"< $ENV{i}"); $a=join("", <F>); $a =~ s/[ \t]*\*\n.*You should.*\n.*along with.*\n.*(\n.*USA.*$)?\n//m && $a =~ s/(^.*)Or, (point your browser to) /$1To obtain the license, $2\n$1/m; close(F); open(F, "> $ENV{i}"); print F $a; close(F);'; done Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
* [media] media-entity: clear media_gobj.mdev in _destroy()Max Kellermann2016-11-181-0/+6
| | | | | | | | | | | | | media_gobj_destroy() may be called twice on one instance - once by media_device_unregister() and again by dvb_media_device_free(). The function media_remove_intf_links() establishes and documents the convention that mdev==NULL means that the object is not registered, but nobody ever NULLs this variable. So this patch really implements this behavior, and adds another mdev==NULL check to media_gobj_destroy() to protect against double removal. Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: Move media_device link_notify operation to an ops structureLaurent Pinchart2016-09-091-5/+6
| | | | | | | | | | | This will allow adding new operations without increasing the media_device structure size for drivers that don't implement any media device operation. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] v4l2-core: Add support for touch devicesNick Dyer2016-08-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some touch controllers send out touch data in a similar way to a greyscale frame grabber. Add new device type VFL_TYPE_TOUCH: - This uses a new device prefix v4l-touch for these devices, to stop generic capture software from treating them as webcams. Otherwise, touch is treated similarly to video capture. - Add V4L2_INPUT_TYPE_TOUCH - Add MEDIA_INTF_T_V4L_TOUCH - Add V4L2_CAP_TOUCH to indicate device is a touch device Add formats: - V4L2_TCH_FMT_DELTA_TD16 for signed 16-bit touch deltas - V4L2_TCH_FMT_DELTA_TD08 for signed 16-bit touch deltas - V4L2_TCH_FMT_TU16 for unsigned 16-bit touch data - V4L2_TCH_FMT_TU08 for unsigned 8-bit touch data This support will be used by: - Atmel maXTouch (atmel_mxt_ts) - Synaptics RMI4. - sur40 Signed-off-by: Nick Dyer <nick@shmanahar.org> Tested-by: Chris Healy <cphealy@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
* [media] media: change pipeline validation return errorHelen Mae Koike Fornazier2016-04-291-1/+1
| | | | | | | | | | | | | | | | | According to the V4L2 API, the VIDIOC_STREAMON ioctl should return EPIPE if there is a format mismatch in the pipeline configuration. As the .vidioc_streamon in the v4l2_ioctl_ops usually forwards the error caused by the v4l2_subdev_link_validate_default (if it is in use), it should return -EPIPE when it detect the mismatch. When an entity is connected to a non enabled link, media_entity_pipeline_start should return -ENOLINK, as the link does not exist. Signed-off-by: Helen Mae Koike Fornazier <helen.koike@collabora.co.uk> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-device: get rid of the spinlockMauro Carvalho Chehab2016-04-201-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, the lock schema for media_device struct is messy, since sometimes, it is protected via a spin lock, while, for media graph traversal, it is protected by a mutex. Solve this conflict by always using a mutex. As a side effect, this prevents a bug when the media notifiers is called at atomic context, while running the notifier callback: BUG: sleeping function called from invalid context at mm/slub.c:1289 in_atomic(): 1, irqs_disabled(): 0, pid: 3479, name: modprobe 4 locks held by modprobe/3479: #0: (&dev->mutex){......}, at: [<ffffffff81ce8933>] __driver_attach+0xa3/0x160 #1: (&dev->mutex){......}, at: [<ffffffff81ce8941>] __driver_attach+0xb1/0x160 #2: (register_mutex#5){+.+.+.}, at: [<ffffffffa10596c7>] usb_audio_probe+0x257/0x1c90 [snd_usb_audio] #3: (&(&mdev->lock)->rlock){+.+.+.}, at: [<ffffffffa0e6051b>] media_device_register_entity+0x1cb/0x700 [media] CPU: 2 PID: 3479 Comm: modprobe Not tainted 4.5.0-rc3+ #49 Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015 0000000000000000 ffff8803b3f6f288 ffffffff81933901 ffff8803c4bae000 ffff8803c4bae5c8 ffff8803b3f6f2b0 ffffffff811c6af5 ffff8803c4bae000 ffffffff8285d7f6 0000000000000509 ffff8803b3f6f2f0 ffffffff811c6ce5 Call Trace: [<ffffffff81933901>] dump_stack+0x85/0xc4 [<ffffffff811c6af5>] ___might_sleep+0x245/0x3a0 [<ffffffff811c6ce5>] __might_sleep+0x95/0x1a0 [<ffffffff8155aade>] kmem_cache_alloc_trace+0x20e/0x300 [<ffffffffa0e66e3d>] ? media_add_link+0x4d/0x140 [media] [<ffffffffa0e66e3d>] media_add_link+0x4d/0x140 [media] [<ffffffffa0e69931>] media_create_pad_link+0xa1/0x600 [media] [<ffffffffa0fe11b3>] au0828_media_graph_notify+0x173/0x360 [au0828] [<ffffffffa0e68a6a>] ? media_gobj_create+0x1ba/0x480 [media] [<ffffffffa0e606fb>] media_device_register_entity+0x3ab/0x700 [media] Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: add prefixes to interface typesShuah Khan2016-03-051-17/+17
| | | | | | | | Add missing prefixes for DVB, V4L, and ALSA interface types. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Media Controller non-locking __media_entity_pipeline_start/stop()Shuah Khan2016-02-271-10/+24
| | | | | | | | | Add non-locking __media_entity_pipeline_start/stop() interfaces to be called from code paths that hold the graph_mutex. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Media Controller export non locking __media_entity_setup_link()Shuah Khan2016-02-271-0/+1
| | | | | | | | Export __media_entity_setup_link() to be used from code paths that hold the graph_mutex. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] uapi/media.h: Declare interface types for ALSAShuah Khan2016-02-271-0/+16
| | | | | | | | | Declare the interface types to be used on alsa for the new G_TOPOLOGY ioctl. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Acked-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Use all bits of an enumerationSakari Ailus2016-02-191-2/+3
| | | | | | | | The allocation takes place in longs. Assign the size of the enum accordingly. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Media Controller fix to not let stream_count go negativeShuah Khan2016-02-011-6/+12
| | | | | | | | | Change media_entity_pipeline_stop() to not decrement stream_count of an inactive media pipeline. Doing so, results in preventing starting the pipeline. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entitiy: add a function to create multiple linksMauro Carvalho Chehab2016-01-111-0/+65
| | | | | | | | | | | | | | | | Sometimes, it is desired to create 1:n and n:1 or even n:n links between different entities with the same function. This is actually needed to support DVB devices that have multiple frontends. While we could do a function like that internally at the DVB core, such function is generic enough to be at media-entity, and it could be useful on some other places. So, add such function. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity: increase max number of PADsMauro Carvalho Chehab2016-01-111-1/+1
| | | | | | | The DVB drivers may have 257 PADs. Get the next power of two that would accomodate that amount. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-device.h: use just one u32 counter for object IDMauro Carvalho Chehab2016-01-111-20/+15
| | | | | | | | Instead of using one u32 counter per type for object IDs, use just one counter. With such change, it makes sense to simplify the debug logs too. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] move documentation to the header filesMauro Carvalho Chehab2016-01-111-13/+0
| | | | | | | | | | Some exported functions were still documented at the .c file, instead of documenting at the .h one. Move the documentation to the right place, as we only use headers at media device-drivers.xml DocBook. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.cSakari Ailus2016-01-111-0/+5
| | | | | | | | | This isn't really a part of any interface drivers are expected to use. In order to keep drivers from using it, hide it in media-entity.c. This was always an arbitrary number and should be removed in the long run. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Remove pre-allocated entity enumeration bitmapSakari Ailus2016-01-111-11/+5
| | | | | | | | | The bitmaps for entity enumerations used to be statically allocated. Now that the drivers have been converted to use the new interface which explicitly initialises the enum objects, drop the pre-allocated bitmaps. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Keep using the same graph walk object for a given pipelineSakari Ailus2016-01-111-6/+11
| | | | | | | | | Initialise a given graph walk object once, and then keep using it whilst the same pipeline is running. Once the pipeline is stopped, release the graph walk object. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Use entity enums in graph walkSakari Ailus2016-01-111-10/+6
| | | | | | | | This will also mean that the necessary graph related data structures will be allocated dynamically, removing the need for maximum ID checks. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Use the new media graph walk interfaceSakari Ailus2016-01-111-1/+11
| | | | | | | | The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Amend media graph walk API by init and cleanup functionsSakari Ailus2016-01-111-0/+27
| | | | | | | | | | | Add media_entity_graph_walk_init() and media_entity_graph_walk_cleanup() functions in order to dynamically allocate memory for the graph. This is not done in media_entity_graph_walk_start() as there are situations where e.g. correct error handling, that itself may not fail, requires successful graph walk. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Move media graph state for streamon/off to the pipelineSakari Ailus2016-01-111-8/+8
| | | | | | | | | | | | | | | | | 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 <sakari.ailus@linux.intel.com> Reviewed-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: Add an API to manage entity enumerationsSakari Ailus2016-01-111-0/+40
| | | | | | | | | 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 <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity: cache media_device on object removalMauro Carvalho Chehab2016-01-111-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 <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity: use mutes for link setupMauro Carvalho Chehab2016-01-111-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 <mchehab@osg.samsung.com>
* [media] media: Enforce single entity->pipe in a pipelineSakari Ailus2016-01-111-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 <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: move MEDIA_LNK_FL_INTERFACE_LINK logic to link creationMauro Carvalho Chehab2016-01-111-2/+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. [mchehab@osg.samsung.com: folded with a fixup from Dan Carpenter, replacing & by &&] Suggested-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity: remove unneded enclosing parenthesisJavier Martinez Canillas2016-01-111-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 <laurent.pinchart@ideasonboard.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity.h: move kernel-doc tags from media-entity.cMauro Carvalho Chehab2016-01-111-152/+11
| | | | | | | | 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 <mchehab@osg.samsung.com>
* [media] media_entity: rename media_obj functions to *_create *_destroyMauro Carvalho Chehab2016-01-111-13/+13
| | | | | | | | | | | | | | | | 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 <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media_entity: get rid of a unused varMauro Carvalho Chehab2016-01-111-4/+1
| | | | | | | | | | > > > + if (rlink != link->reverse) { > > > + r++; > > > > The variable is incremented here but otherwise never used, you can remove it. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media-entity: get rid of forward __media_entity_remove_link() ↵Mauro Carvalho Chehab2016-01-111-35/+32
| | | | | | | | | | declaration Move this function to happen earlier, in order to avoid a uneeded forward declaration. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: remove extra blank linesMauro Carvalho Chehab2016-01-111-3/+0
| | | | | | | No functional changes. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
OpenPOWER on IntegriCloud