summaryrefslogtreecommitdiffstats
path: root/drivers/media
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'media/v4.5-2' of ↵Linus Torvalds2016-01-1397-1013/+2604
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull second batch of media updates from Mauro Carvalho Chehab: "This is the second part of the media patches. It contains the media controller next generation patches, with is the result of one year of discussions and development. It also contains patches to enable media controller support at the DVB subsystem. The goal is to improve the media controller to allow proper support for other types of Video4Linux devices (radio and TV ones) and to extend the media controller functionality to allow it to be used by other subsystems like DVB, ALSA and IIO. In order to use the new functionality, a new ioctl is needed (MEDIA_IOC_G_TOPOLOGY). As we're still discussing how to pack the struct fields of this ioctl in order to avoid compat32 issues, I decided to add a patch at the end of this series commenting out the new ioctl, in order to postpone the addition of the new ioctl to the next Kernel version (4.6). With that, no userspace visible changes should happen at the media controller API, as the existing ioctls are untouched. Yet, it helps DVB, ALSA and IIO developers to develop and test the patches adding media controller support there, as the core will contain all required internal changes to allow adding support for devices that belong to those subsystems" * tag 'media/v4.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (177 commits) [media] Postpone the addition of MEDIA_IOC_G_TOPOLOGY [media] mxl111sf: Add a tuner entity [media] dvbdev: create links on devices with multiple frontends [media] media-entitiy: add a function to create multiple links [media] dvb-usb-v2: postpone removal of media_device [media] dvbdev: Add RF connector if needed [media] dvbdev: remove two dead functions if !CONFIG_MEDIA_CONTROLLER_DVB [media] call media_device_init() before registering the V4L2 device [media] uapi/media.h: Use u32 for the number of graph objects [media] media-entity: don't sleep at media_device_register_entity() [media] media-entity: increase max number of PADs [media] media-entity.h: document the remaining functions [media] media-device.h: use just one u32 counter for object ID [media] media-entity.h fix documentation for several parameters [media] DocBook: document media_entity_graph_walk_cleanup() [media] move documentation to the header files [media] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c [media] media: Remove pre-allocated entity enumeration bitmap [media] staging: v4l: davinci_vpbe: Use the new media graph walk interface [media] staging: v4l: omap4iss: Use the new media graph walk interface ...
| * [media] Postpone the addition of MEDIA_IOC_G_TOPOLOGYMauro Carvalho Chehab2016-01-111-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | There are a few discussions left with regards to this ioctl: 1) the name of the new structs will contain _v2_ on it? 2) what's the best alternative to avoid compat32 issues? Due to that, let's postpone the addition of this new ioctl to the next Kernel version, to give people more time to discuss it. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] mxl111sf: Add a tuner entityMauro Carvalho Chehab2016-01-113-0/+31
| | | | | | | | | | | | | | While mxl111sf may have multiple frontends, it has just one tuner. Reflect that on the media graph. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] dvbdev: create links on devices with multiple frontendsMauro Carvalho Chehab2016-01-112-13/+51
| | | | | | | | | | | | | | | | | | Devices like mxl111sf-based WinTV Aero-m have multiple frontends, all linked on the same demod. Currently, the dvb_create_graph() function is not smart enough to create multiple links. Fix it. 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] dvb-usb-v2: postpone removal of media_deviceMauro Carvalho Chehab2016-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | We should not remove the media_device until its last usage, or we may have use after free troubles. So, move the per-adapter media_device removal to happen at the end of the adapter removal code. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] dvbdev: Add RF connector if neededMauro Carvalho Chehab2016-01-117-9/+70
| | | | | | | | | | | | | | | | | | | | Several pure digital TV devices have a frontend with the tuner integrated on it. Add the RF connector when dvb_create_media_graph() is called on such devices. Tested with siano and dvb_usb_mxl111sf drivers. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] dvbdev: remove two dead functions if !CONFIG_MEDIA_CONTROLLER_DVBMauro Carvalho Chehab2016-01-111-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Those functions are used only if CONFIG_MEDIA_CONTROLLER_DVB. Without that, if !CONFIG_MEDIA_CONTROLLER_DVB, it would produce two warnings: drivers/media/dvb-core/dvbdev.c:219:12: warning: 'dvb_create_tsout_entity' defined but not used [-Wunused-function] static int dvb_create_tsout_entity(struct dvb_device *dvbdev, ^ drivers/media/dvb-core/dvbdev.c:264:12: warning: 'dvb_create_media_entity' defined but not used [-Wunused-function] static int dvb_create_media_entity(struct dvb_device *dvbdev, ^ Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] call media_device_init() before registering the V4L2 deviceMauro Carvalho Chehab2016-01-112-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, v4l2_device_register() doesn't use the media_device struct. So, calling media_device_init() could be called either before or after v4l2_device_register(). Yet, it is a good practice to initialize everything before calling the register functions. Also, the other drivers call media_device_init() before registering the V4L2 device. So, move the call for media_device_init() to happen earlier on exynos4-is and s3c-camif. This is just a cleanup patch. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] media-entity: don't sleep at media_device_register_entity()Mauro Carvalho Chehab2016-01-111-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | media_device_register_entity() is protected by a spin_lock. Calling ida_pre_get() with GFP_KERNEL may put it to sleep, with is a bad idea and causes this warning: [ 8812.397195] BUG: sleeping function called from invalid context at mm/slub.c:1287 [ 8812.397203] in_atomic(): 1, irqs_disabled(): 0, pid: 15179, name: modprobe [ 8812.397207] INFO: lockdep is turned off. [ 8812.397213] CPU: 2 PID: 15179 Comm: modprobe Tainted: G B 4.4.0-rc2+ #41 [ 8812.397218] Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015 [ 8812.397222] 0000000000000000 ffff880314c77268 ffffffff818f8ba7 ffff8803b17dde00 [ 8812.397232] ffff880314c77290 ffffffff811c2ee5 ffff8803b17dde00 ffffffff8284dbc9 [ 8812.397241] 0000000000000507 ffff880314c772d0 ffffffff811c30d5 0000000041b58ab3 [ 8812.397250] Call Trace: [ 8812.397258] [<ffffffff818f8ba7>] dump_stack+0x4b/0x64 [ 8812.397265] [<ffffffff811c2ee5>] ___might_sleep+0x245/0x3a0 [ 8812.397270] [<ffffffff811c30d5>] __might_sleep+0x95/0x1a0 [ 8812.397276] [<ffffffff818fd083>] ? ida_pre_get+0x113/0x250 [ 8812.397282] [<ffffffff8153bb77>] kmem_cache_alloc+0x197/0x250 [ 8812.397288] [<ffffffff818fd083>] ida_pre_get+0x113/0x250 [ 8812.397293] [<ffffffff818fd265>] ida_simple_get+0xa5/0x170 [ 8812.397298] [<ffffffff818fd1c0>] ? ida_pre_get+0x250/0x250 [ 8812.397306] [<ffffffffa07382d1>] media_device_register_entity+0x171/0x420 [media] [ 8812.397318] [<ffffffffa129e76f>] v4l2_device_register_subdev+0x34f/0x640 [videodev] [ 8812.397324] [<ffffffffa0768dea>] v4l2_i2c_new_subdev_board+0x12a/0x250 [v4l2_common] [ 8812.397330] [<ffffffffa0768fe7>] v4l2_i2c_new_subdev+0xd7/0x110 [v4l2_common] [ 8812.397337] [<ffffffffa0768f10>] ? v4l2_i2c_new_subdev_board+0x250/0x250 [v4l2_common] [ 8812.397347] [<ffffffffa13d2f76>] au0828_card_analog_fe_setup+0x2e6/0x3f0 [au0828] [ 8812.397352] [<ffffffff814450cc>] ? power_down+0xc4/0xc4 [ 8812.397361] [<ffffffffa13d2c90>] ? au0828_tuner_callback+0x160/0x160 [au0828] [ 8812.397370] [<ffffffffa13d319f>] au0828_card_setup+0x11f/0x340 [au0828] [ 8812.397378] [<ffffffffa13d3080>] ? au0828_card_analog_fe_setup+0x3f0/0x3f0 [au0828] [ 8812.397384] [<ffffffff812a575b>] ? msleep+0x7b/0xc0 [ 8812.397393] [<ffffffffa13d0d79>] au0828_usb_probe+0x679/0xcf0 [au0828] [ 8812.397399] [<ffffffff81d7619d>] usb_probe_interface+0x45d/0x940 [ 8812.397406] [<ffffffff81ca7004>] driver_probe_device+0x454/0xd90 [ 8812.397411] [<ffffffff81ca7940>] ? driver_probe_device+0xd90/0xd90 [ 8812.397417] [<ffffffff81ca7940>] ? driver_probe_device+0xd90/0xd90 [ 8812.397422] [<ffffffff81ca7a61>] __driver_attach+0x121/0x160 [ 8812.397427] [<ffffffff81ca141f>] bus_for_each_dev+0x11f/0x1a0 [ 8812.397433] [<ffffffff81ca1300>] ? subsys_dev_iter_exit+0x10/0x10 [ 8812.397439] [<ffffffff822917d7>] ? _raw_spin_unlock+0x27/0x40 [ 8812.397445] [<ffffffff81ca5d4d>] driver_attach+0x3d/0x50 [ 8812.397450] [<ffffffff81ca5039>] bus_add_driver+0x4c9/0x770 [ 8812.397456] [<ffffffff81ca944c>] driver_register+0x18c/0x3b0 [ 8812.397462] [<ffffffff8124c952>] ? __raw_spin_lock_init+0x32/0x100 [ 8812.397468] [<ffffffff81d71e58>] usb_register_driver+0x1f8/0x440 [ 8812.397473] [<ffffffffa0208000>] ? 0xffffffffa0208000 [ 8812.397481] [<ffffffffa02080b7>] au0828_init+0xb7/0x1000 [au0828] [ 8812.397486] [<ffffffff810021b1>] do_one_initcall+0x141/0x300 [ 8812.397492] [<ffffffff81002070>] ? try_to_run_init_process+0x40/0x40 [ 8812.397497] [<ffffffff8123bbf6>] ? trace_hardirqs_on_caller+0x16/0x590 [ 8812.397502] [<ffffffff815406e6>] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397507] [<ffffffff815406e6>] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397512] [<ffffffff815406e6>] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397517] [<ffffffff815407f7>] ? __asan_register_globals+0x87/0xa0 [ 8812.397524] [<ffffffff814454e5>] do_init_module+0x1d0/0x5a4 [ 8812.397530] [<ffffffff812ed7e8>] load_module+0x6648/0x9d70 [ 8812.397535] [<ffffffff812e4b70>] ? symbol_put_addr+0x50/0x50 [ 8812.397546] [<ffffffff812e71a0>] ? module_frob_arch_sections+0x20/0x20 [ 8812.397552] [<ffffffff8158e950>] ? open_exec+0x50/0x50 [ 8812.397559] [<ffffffff811648db>] ? ns_capable+0x5b/0xd0 [ 8812.397565] [<ffffffff812f1208>] SyS_finit_module+0x108/0x130 [ 8812.397571] [<ffffffff812f1100>] ? SyS_init_module+0x1f0/0x1f0 [ 8812.397576] [<ffffffff81004044>] ? lockdep_sys_exit_thunk+0x12/0x14 [ 8812.397582] [<ffffffff82292236>] entry_SYSCALL_64_fastpath+0x16/0x7a 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-112-40/+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] v4l: vsp1: Use media entity enumeration interfaceSakari Ailus2016-01-111-14/+31
| | | | | | | | | | | | | | | | Instead of using a bitmap directly in a driver, use the new media entity enumeration interface to perform the same. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] v4l: omap3isp: Use media entity enumeration interfaceSakari Ailus2016-01-115-19/+33
| | | | | | | | | | | | | | | | Instead of using a bitmap directly in a driver, use the new media entity enumeration interface to perform the same. 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] v4l: vsp1: Use the new media graph walk interfaceSakari Ailus2016-01-111-0/+8
| | | | | | | | | | | | | | | | 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] v4l: xilinx: Use the new media graph walk interfaceSakari Ailus2016-01-111-0/+9
| | | | | | | | | | | | | | | | | | 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> Cc: Hyun Kwon <hyun.kwon@xilinx.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] v4l: exynos4-is: Use the new media graph walk interfaceSakari Ailus2016-01-112-11/+21
| | | | | | | | | | | | | | | | | | | | | | 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> Cc: Javier Martinez Canillas <javier@osg.samsung.com> Cc: Kamil Debski <k.debski@samsung.com> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] v4l: omap3isp: Use the new media graph walk interfaceSakari Ailus2016-01-114-27/+61
| | | | | | | | | | | | | | | | 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: 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: Introduce internal index for media entitiesSakari Ailus2016-01-111-0/+17
| | | | | | | | | | | | | | | | | | | | 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 <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] v4l2-device: fix a missing error codeDan Carpenter2016-01-111-1/+3
| | | | | | | | | | | | | | | | | | We need to set "err = -ENOMEM" here. Fixes: 38b11f19667a ('[media] v4l2-core: create MC interfaces for devnodes') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] media-device: copy_to/from_user() returns positiveDan Carpenter2016-01-111-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 <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] media-device: set topology version 0 at media registrationJavier Martinez Canillas2016-01-111-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 <laurent.pinchart@ideasonboard.com> Suggested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] v4l2-device: Register entity before calling subdev's registered opsSakari Ailus2016-01-111-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 <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] usb: check media device errorsMauro Carvalho Chehab2016-01-114-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 <mchehab@osg.samsung.com>
| * [media] media-device: split media initialization and registrationJavier Martinez Canillas2016-01-1113-99/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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(). [mchehab@osg.samsung.com: Fix compilation if !CONFIG_MEDIA_CONTROLLER and remove two warnings added by this changeset] Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] media-device: better lock media_device_unregister()Mauro Carvalho Chehab2016-01-111-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 <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| * [media] media-device: move media entity register/unregister functionsMauro Carvalho Chehab2016-01-111-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 <mchehab@osg.samsung.com>
| * [media] media-device: check before unregister if mdev was registeredJavier Martinez Canillas2016-01-111-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 <sakari.ailus@linux.intel.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Acked-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-devnode: move kernel-doc documentation to the headerMauro Carvalho Chehab2016-01-111-24/+0
| | | | | | | | | | | | | | | | 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 <mchehab@osg.samsung.com>
| * [media] media-device.h: document the last functionsMauro Carvalho Chehab2016-01-111-7/+0
| | | | | | | | | | | | | | Add kernel-doc documentation for media_device_get_devres and media_device_find_devres. 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] dvbdev: Document the new MC-related fieldsMauro Carvalho Chehab2016-01-111-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 <mchehab@osg.samsung.com>
| * [media] media: move MEDIA_LNK_FL_INTERFACE_LINK logic to link creationMauro Carvalho Chehab2016-01-112-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. [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] uvcvideo: register entity subdev on initJavier Martinez Canillas2016-01-111-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 <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] uvcvideo: remove pads prefix from uvc_mc_create_pads_links()Javier Martinez Canillas2016-01-111-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 <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] v4l: vsp1: use else if instead of continue when creating linksJavier Martinez Canillas2016-01-111-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 <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] v4l: vsp1: remove pads prefix from *_create_pads_links()Javier Martinez Canillas2016-01-114-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 <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] omap3isp: consistently use v4l2_dev var in complete notifierJavier Martinez Canillas2016-01-111-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 <sakari.ailus@linux.intel.com> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
OpenPOWER on IntegriCloud