aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/imx (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-12-07media: staging: media: imx: Use of_node_name_eq for node name comparisonsRob Herring1-1/+1
Convert string compares of DT node names to use of_node_name_eq helper instead. This removes direct access to the node name pointer. For instances using of_node_cmp, this has the side effect of now using case sensitive comparisons. This should not matter for any FDT based system which this is. Cc: Steve Longerbeam <slongerbeam@gmail.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: devel@driverdev.osuosl.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-31Merge tag 'media/v4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-mediaLinus Torvalds2-2/+2
Pull new experimental media request API from Mauro Carvalho Chehab: "A new media request API This API is needed to support device drivers that can dynamically change their parameters for each new frame. The latest versions of Google camera and codec HAL depends on such feature. At this stage, it supports only stateless codecs. It has been discussed for a long time (at least over the last 3-4 years), and we finally reached to something that seem to work. This series contain both the API and core changes required to support it and a new m2m decoder driver (cedrus). As the current API is still experimental, the only real driver using it (cedrus) was added at staging[1]. We intend to keep it there for a while, in order to test the API. Only when we're sure that this API works for other cases (like encoders), we'll move this driver out of staging and set the API into a stone. [1] We added support for the vivid virtual driver (used only for testing) to it too, as it makes easier to test the API for the ones that don't have the cedrus hardware" * tag 'media/v4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (53 commits) media: dt-bindings: Document the Rockchip VPU bindings media: platform: Add Cedrus VPU decoder driver media: dt-bindings: media: Document bindings for the Cedrus VPU driver media: v4l: Add definition for the Sunxi tiled NV12 format media: v4l: Add definitions for MPEG-2 slice format and metadata media: videobuf2-core: Rework and rename helper for request buffer count media: v4l2-ctrls.c: initialize an error return code with zero media: v4l2-compat-ioctl32.c: add missing documentation for a field media: media-request: update documentation media: media-request: EPERM -> EACCES/EBUSY media: v4l2-ctrls: improve media_request_(un)lock_for_update media: v4l2-ctrls: use media_request_(un)lock_for_access media: media-request: add media_request_(un)lock_for_access media: vb2: set reqbufs/create_bufs capabilities media: videodev2.h: add new capabilities for buffer types media: buffer.rst: only set V4L2_BUF_FLAG_REQUEST_FD for QBUF media: v4l2-ctrls: return -EACCES if request wasn't completed media: media-request: return -EINVAL for invalid request_fds media: vivid: add request support media: vivid: add mc ...
2018-10-29Merge tag 'media/v4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-mediaLinus Torvalds9-264/+156
Pull media updates from Mauro Carvalho Chehab: - new dvb frontend driver: lnbh29 - new sensor drivers: imx319 and imx 355 - some old soc_camera driver renames to avoid conflict with new drivers - new i.MX Pixel Pipeline (PXP) mem-to-mem platform driver - a new V4L2 frontend for the FWHT codec - several other improvements, bug fixes, code cleanups, etc * tag 'media/v4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (289 commits) media: rename soc_camera I2C drivers media: cec: forgot to cancel delayed work media: vivid: Support 480p for webcam capture media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD media: vivid: Add 16-bit bayer to format list media: v4l2-tpg-core: Add 16-bit bayer media: pvrusb2: replace `printk` with `pr_*` media: venus: vdec: fix decoded data size media: cx231xx: fix potential sign-extension overflow on large shift media: dt-bindings: media: rcar_vin: add device tree support for r8a7744 media: isif: fix a NULL pointer dereference bug media: exynos4-is: make const array config_ids static media: cx23885: make const array addr_list static media: ivtv: make const array addr_list static media: bttv-input: make const array addr_list static media: cx18: Don't check for address of video_dev media: dw9807-vcm: Fix probe error handling media: dw9714: Remove useless error message media: dw9714: Fix error handling in probe function media: cec: name for RC passthrough device does not need 'RC for' ...
2018-10-04media: v4l: fwnode: Initialise the V4L2 fwnode endpoints to zeroSakari Ailus1-4/+4
Initialise the V4L2 fwnode endpoints to zero in all drivers using v4l2_fwnode_endpoint_parse(). This prepares for setting default endpoint flags as well as the bus type. Setting bus type to zero will continue to guess the bus among the guessable set (parallel, Bt.656 and CSI-2 D-PHY). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: v4l: mediabus: Recognise CSI-2 D-PHY and C-PHYSakari Ailus2-2/+2
The CSI-2 bus may use either D-PHY or C-PHY. Make this visible in media bus enum. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: staging/imx: TODO: Remove one assumption about OF graph parsingSteve Longerbeam1-22/+7
The move to subdev notifiers fixes one assumption of OF graph parsing. If a subdevice has non-video related ports, the subdev driver knows not to follow those ports when adding remote devices to its subdev notifier. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: staging/imx: Switch to v4l2_async_notifier_add_*_subdevSteve Longerbeam3-94/+36
Switch to v4l2_async_notifier_add_*_subdev() when adding async subdevs to the imx-media root notifier. This removes the need to check for an already added asd, since v4l2_async_notifier_add_*_subdev() does this check. Also no need to allocate a subdevs array when registering the root notifier, or keeping an internal master asd_list, since this is moved to the notifier's asd_list. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: staging/imx: Rename root notifierSteve Longerbeam2-8/+8
Rename the imx-media root async notifier from "subdev_notifier" to simply "notifier", so as not to confuse it with true subdev notifiers. No functional changes. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: staging/imx: Loop through all registered subdevs for media linksSteve Longerbeam1-10/+6
The root imx-media notifier no longer sees all bound subdevices because some of them will be bound to subdev notifiers. So imx_media_create_links() now needs to loop through all subdevices registered with the v4l2-device, not just the ones in the root notifier's done list. This should be safe because imx_media_create_of_links() checks if a fwnode link already exists before creating. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: staging/imx: of: Remove recursive graph walkSteve Longerbeam1-98/+8
After moving to subdev notifiers, it's no longer necessary to recursively walk the OF graph, because the subdev notifiers will discover and add devices from the graph for us. So the recursive of_parse_subdev() function is gone, replaced with of_add_csi() which adds only the CSI port fwnodes to the imx-media root notifier. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: imx: mipi csi-2: Register a subdev notifierSteve Longerbeam1-17/+14
Parse neighbor remote devices on the MIPI CSI-2 input port, add them to a subdev notifier, and register the subdev notifier for the MIPI CSI-2 receiver, by calling v4l2_async_register_fwnode_subdev(). csi2_parse_endpoints() is modified to be the parse_endpoint callback. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: imx: csi: Register a subdev notifierSteve Longerbeam1-1/+56
Parse neighbor remote devices on the CSI port, and add them to a subdev notifier, by calling v4l2_async_notifier_parse_fwnode_endpoints_by_port() using the CSI's port id. And register the subdev notifier for the CSI. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: imx: use well defined 32-bit RGB pixel formatPhilipp Zabel1-2/+2
The documentation in Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst tells us that the V4L2_PIX_FMT_RGB32 format is deprecated and must not be used by new drivers. Replace it with V4L2_PIX_FMT_XRGB32. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-24media: imx: work around false-positive warning, againArnd Bergmann1-1/+4
A warning that I thought to be solved by a previous patch of mine has resurfaced with gcc-8: media/imx/imx-media-csi.c: In function 'csi_link_validate': media/imx/imx-media-csi.c:1025:20: error: 'upstream_ep' may be used uninitialized in this function [-Werror=maybe-uninitialized] media/imx/imx-media-csi.c:1026:24: error: 'upstream_ep.bus_type' may be used uninitialized in this function [-Werror=maybe-uninitialized] media/imx/imx-media-csi.c:127:19: error: 'upstream_ep.bus.parallel.bus_width' may be used uninitialized in this function [-Werror=maybe-uninitialized] media/imx/imx-media-csi.c: In function 'csi_enum_mbus_code': media/imx/imx-media-csi.c:132:9: error: '*((void *)&upstream_ep+12)' may be used uninitialized in this function [-Werror=maybe-uninitialized] media/imx/imx-media-csi.c:132:48: error: 'upstream_ep.bus.parallel.bus_width' may be used uninitialized in this function [-Werror=maybe-uninitialized] I spent some more time digging in this time, and think I have a better fix, bailing out of the function that either initializes or errors out here, which simplifies the code enough for gcc to figure out what is going on. The earlier partial workaround can be removed now, as the new workaround is better. Fixes: 890f27693f2a ("media: imx: work around false-positive warning") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-11media: replace strcpy() by strscpy()Mauro Carvalho Chehab1-1/+1
The strcpy() function is being deprecated upstream. Replace it by the safer strscpy(). Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-11media: use strscpy() instead of strlcpy()Mauro Carvalho Chehab2-4/+4
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-10staging: Convert to using %pOFn instead of device_node.nameRob Herring2-7/+12
In preparation to remove the node name pointer from struct device_node, convert printf users to use the %pOFn format specifier. Cc: Steve Longerbeam <slongerbeam@gmail.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-media@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-31media: v4l2-ctrls: v4l2_ctrl_add_handler: add from_other_devHans Verkuil2-2/+2
Add a 'bool from_other_dev' argument: set to true if the two handlers refer to different devices (e.g. it is true when inheriting controls from a subdev into a main v4l2 bridge driver). This will be used later when implementing support for the request API since we need to skip such controls. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-08media: cleanup fall-through commentsMauro Carvalho Chehab1-2/+1
As Ian pointed out, adding a '-' to the fallthrough seems to meet the regex requirements at level 3 of the warning, at least when the comment fits into a single line. So, replace by a single line the comments that were broken into multiple lines just to make gcc -Wimplicit-fallthrough=3 happy. Suggested-by: Ian Arkver <ian.arkver.dev@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-07media: imx: shut up a false positive warningMauro Carvalho Chehab1-1/+2
With imx, gcc produces a false positive warning: drivers/staging/media/imx/imx-media-csi.c: In function 'csi_idmac_setup_channel': drivers/staging/media/imx/imx-media-csi.c:457:6: warning: this statement may fall through [-Wimplicit-fallthrough=] if (passthrough) { ^ drivers/staging/media/imx/imx-media-csi.c:464:2: note: here default: ^~~~~~~ That's because the regex it uses for fall trough is not good enough. So, rearrange the fall through comment in a way that gcc will recognize. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-04media: imx: add support for RGB565_2X8 on parallel busJan Luebbe3-33/+71
The IPU can only capture RGB565 with two 8-bit cycles in bayer/generic mode on the parallel bus, compared to a specific mode on MIPI CSI-2. To handle this, we extend imx_media_pixfmt with a cycles per pixel field, which is used for generic formats on the parallel bus. Based on the selected format and bus, we then update the width to account for the multiple cycles per pixel. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-04media: imx: capture: refactor enum_/try_fmtJan Luebbe1-20/+18
By checking and handling the internal IPU formats (ARGB or AYUV) first, we don't need to check whether it's a bayer format, as we can default to passing the input format on in all other cases. This simplifies handling the different configurations for RGB565 between parallel and MIPI CSI-2, as we don't need to check the details of the format anymore. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-04media: staging/imx: fill vb2_v4l2_buffer sequence entryPeter Seiderer2-0/+8
- enables gstreamer v4l2src lost frame detection, e.g: 0:00:08.685185668 348 0x54f520 WARN v4l2src gstv4l2src.c:970:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 141 - ts: 0:00:08.330177332 - fixes v4l2-compliance test failure: Streaming ioctls: test read/write: OK (Not Supported) Video Capture: Buffer: 0 Sequence: 0 Field: None Timestamp: 92.991450s Buffer: 1 Sequence: 0 Field: None Timestamp: 93.008135s fail: v4l2-test-buffers.cpp(294): (int)g_sequence() < seq.last_seq + 1 fail: v4l2-test-buffers.cpp(707): buf.check(q, last_seq) Signed-off-by: Peter Seiderer <ps.report@gmx.net> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-04media: staging/imx: fill vb2_v4l2_buffer field entryPeter Seiderer2-0/+2
- fixes gstreamer v4l2src warning: 0:00:00.716640334 349 0x164f720 WARN v4l2bufferpool gstv4l2bufferpool.c:1195:gst_v4l2_buffer_pool_dqbuf:<v4l2src0:pool:src> Driver should never set v4l2_buffer.field to ANY - fixes v4l2-compliance test failure: Streaming ioctls: test read/write: OK (Not Supported) Video Capture: Buffer: 0 Sequence: 0 Field: Any Timestamp: 58.383658s fail: v4l2-test-buffers.cpp(297): g_field() == V4L2_FIELD_ANY Signed-off-by: Peter Seiderer <ps.report@gmx.net> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-28media: Staging:media:imx Fix multiple assignments in a lineJanani Sankara Babu1-2/+4
This patch solves multiple assignments warning shown by checkpatch script. Signed-off-by: Janani Sankara Babu <jananis37@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-12treewide: devm_kzalloc() -> devm_kcalloc()Kees Cook1-3/+3
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc(). This patch replaces cases of: devm_kzalloc(handle, a * b, gfp) with: devm_kcalloc(handle, a * b, gfp) as well as handling cases of: devm_kzalloc(handle, a * b * c, gfp) with: devm_kzalloc(handle, array3_size(a, b, c), gfp) as it's slightly less ugly than: devm_kcalloc(handle, array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: devm_kzalloc(handle, 4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. Some manual whitespace fixes were needed in this patch, as Coccinelle really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...". The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ expression HANDLE; type TYPE; expression THING, E; @@ ( devm_kzalloc(HANDLE, - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | devm_kzalloc(HANDLE, - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression HANDLE; expression COUNT; typedef u8; typedef __u8; @@ ( devm_kzalloc(HANDLE, - sizeof(u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ expression HANDLE; type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ expression HANDLE; identifier SIZE, COUNT; @@ - devm_kzalloc + devm_kcalloc (HANDLE, - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression HANDLE; expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression HANDLE; expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ expression HANDLE; identifier STRIDE, SIZE, COUNT; @@ ( devm_kzalloc(HANDLE, - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression HANDLE; expression E1, E2, E3; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression HANDLE; expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, sizeof(THING) * C2, ...) | devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...) | devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, C1 * C2, ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * E2 + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * (E2) + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2018-05-25media: imx: fix compiler warningHans Verkuil1-2/+2
drivers/staging/media/imx/imx-media-capture.c: In function 'vidioc_querycap': drivers/staging/media/imx/imx-media-capture.c:76:2: warning: 'strncpy' output truncated copying 15 bytes from a string of length 17 [-Wstringop-truncation] strncpy(cap->driver, "imx-media-capture", sizeof(cap->driver) - 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-10Merge tag 'v4.17-rc4' into patchworkMauro Carvalho Chehab1-1/+1
Linux 4.17-rc4 * tag 'v4.17-rc4': (920 commits) Linux 4.17-rc4 KVM: x86: remove APIC Timer periodic/oneshot spikes genksyms: fix typo in parse.tab.{c,h} generation rules kbuild: replace hardcoded bison in cmd_bison_h with $(YACC) gcc-plugins: fix build condition of SANCOV plugin MAINTAINERS: Update Kbuild entry with a few paths Revert "usb: host: ehci: Use dma_pool_zalloc()" platform/x86: Kconfig: Fix dell-laptop dependency chain. platform/x86: asus-wireless: Fix NULL pointer dereference arm64: vgic-v2: Fix proxying of cpuif access KVM: arm/arm64: vgic_init: Cleanup reference to process_maintenance KVM: arm64: Fix order of vcpu_write_sys_reg() arguments MAINTAINERS & files: Canonize the e-mails I use at files media: imx-media-csi: Fix inconsistent IS_ERR and PTR_ERR tools: power/acpi, revert to LD = gcc bdi: Fix oops in wb_workfn() RDMA/cma: Do not query GID during QP state transition to RTR IB/mlx4: Fix integer overflow when calculating optimal MTT size IB/hfi1: Fix memory leak in exception path in get_irq_affinity() IB/{hfi1, rdmavt}: Fix memory leak in hfi1_alloc_devdata() upon failure ...
2018-05-09media: imx-csi: fix burst size for 16 bitJan Luebbe1-1/+1
A burst_size of 4 does not work for the 16 bit passthrough formats, so we use 8 instead. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-09media: imx: add 16-bit grayscale supportPhilipp Zabel2-0/+10
Since commit 50b0f0aee839 ("gpu: ipu-csi: add 10/12-bit grayscale support to mbus_code_to_bus_cfg") the IPU CSI can be configured to capture 10-bit and 12-bit grayscale formats, expanded to 16-bit grayscale, in bayer/generic data mode. This patch adds support for V4L2_PIX_FMT_Y16 captured from sensors that provide MEDIA_BUS_FMT_Y10_1X10 or MEDIA_BUS_FMT_Y12_1X12 data. Cc: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04media: imx-media-csi: Fix inconsistent IS_ERR and PTR_ERRFrom: Gustavo A. R. Silva1-1/+1
Fix inconsistent IS_ERR and PTR_ERR in imx_csi_probe. The proper pointer to be passed as argument is pinctrl instead of priv->vdev. This issue was detected with the help of Coccinelle. Fixes: 52e17089d185 ("media: imx: Don't initialize vars that won't be used") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-04-04media: imx-media-csi: Do not propagate the error when pinctrl is not foundFabio Estevam1-1/+4
Since commit 52e17089d185 ("media: imx: Don't initialize vars that won't be used") imx_csi_probe() fails to probe after propagating the devm_pinctrl_get_select_default() error. devm_pinctrl_get_select_default() may return -ENODEV when the CSI pinctrl entry is not found, so better not to propagate the error in the -ENODEV case to avoid a regression. Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-04-04media: imx: work around false-positive warningArnd Bergmann1-1/+1
The IS_ERR()/PTR_ERR() combination confuses gcc to the point that it cannot prove the upstream_ep variable to be initialized: drivers/staging/media/imx/imx-media-csi.c: In function 'csi_link_validate': drivers/staging/media/imx/imx-media-csi.c:1025:20: error: 'upstream_ep' may be used uninitialized in this function [-Werror=maybe-uninitialized] priv->upstream_ep = upstream_ep; ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ drivers/staging/media/imx/imx-media-csi.c:1026:24: error: 'upstream_ep.bus_type' may be used uninitialized in this function [-Werror=maybe-uninitialized] is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2); ~~~~~~~~~~~^~~~~~~~~ drivers/staging/media/imx/imx-media-csi.c:127:19: error: 'upstream_ep.bus.parallel.bus_width' may be used uninitialized in this function [-Werror=maybe-uninitialized] I could come up with no good way to rewrite this function, as a last resort, this adds an explicit zero-intialization of the structure. Fixes: 52e17089d185 ("media: imx: Don't initialize vars that won't be used") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-22media: imx-media-utils: fix a warningMauro Carvalho Chehab1-38/+43
The logic at find_format() is a little bit confusing even for humans, and it tricks static code analyzers: drivers/staging/media/imx/imx-media-utils.c:259 find_format() error: buffer overflow 'array' 14 <= 20 Rewrite the logic in a way that it makes it clearer to understand, while prevent static analyzers to produce false positives. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21media: imx: add 8-bit grayscale supportPhilipp Zabel2-1/+8
The IPUv3 code has 8-bit grayscale capture support. Enable imx-media to use it. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx/Kconfig: add depends on HAS_DMAHans Verkuil1-0/+1
Add missing dependency. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx: capture: reformat line to 80 chars or lessParthiban Nallathambi1-1/+2
This is a cleanup patch to fix line length issue found by checkpatch.pl script. In this patch, line 144 have been wrapped. Signed-off-by: Parthiban Nallathambi <pn@denx.de> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx: mipi csi-2: Fix set_fmt trySteve Longerbeam1-9/+15
csi2_set_fmt() was setting the try_fmt only on the first pad, and pad index was ignored. Fix by introducing __csi2_get_fmt(). Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: staging/imx: Implement init_cfg subdev pad opSteve Longerbeam7-0/+36
Implement the init_cfg pad op in all imx-media subdevices. The try formats are initialized to the current active formats on all pads. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx-ic-prpencvf: Use empty initializer to clear all struct membersFabio Estevam1-1/+1
{0} only cleans the first member of the structure. Use {} instead, which cleans all the members of the structure. Reported-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx-media-internal-sd: Use empty initializerFabio Estevam1-1/+1
When building with W=1 the following warning shows up: drivers/staging/media/imx/imx-media-internal-sd.c:274:49: warning: Using plain integer as NULL pointer Fix this problem by using an empty initializer, which guarantees that all struct members are zero-cleared. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx: Don't initialize vars that won't be usedMauro Carvalho Chehab1-2/+5
As reported by gcc: + drivers/staging/media/imx/imx-media-csi.c: warning: variable 'input_fi' set but not used [-Wunused-but-set-variable]: => 671:33 + drivers/staging/media/imx/imx-media-csi.c: warning: variable 'pinctrl' set but not used [-Wunused-but-set-variable]: => 1742:18 input_fi is not used, so just remove it. However, pinctrl should be used, as it devm_pinctrl_get_select_default() is declared with attribute warn_unused_result. What's missing there is an error handling code, in case it fails. Add it. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: staging: imx-media-vdic: fix inconsistent IS_ERR and PTR_ERRGustavo A. R. Silva1-1/+1
Fix inconsistent IS_ERR and PTR_ERR in vdic_get_ipu_resources. The proper pointer to be passed as argument is ch. This issue was detected with the help of Coccinelle. Fixes: 0b2e9e7947e7 ("media: staging/imx: remove confusing IS_ERR_OR_NULL usage") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-26media: imx: allow to build with COMPILE_TESTPhilipp Zabel1-1/+2
Allow building this driver for other platforms under COMPILE_TEST. Suggested-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-29media: imx: fix breakages when compiling for armMauro Carvalho Chehab1-2/+2
As reported: drivers/staging/media/imx/imx-media-dev.c: In function 'find_async_subdev': >> drivers/staging/media/imx/imx-media-dev.c:55:49: error: request for member 'name' in something not a structure or union if (devname && !strcmp(asd->match.device_name.name, ^ drivers/staging/media/imx/imx-media-dev.c: In function 'imx_media_add_async_subdev': drivers/staging/media/imx/imx-media-dev.c:110:25: error: request for member 'name' in something not a structure or union asd->match.device_name.name = devname; ^ Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-29media: v4l2-async: simplify v4l2_async_subdev structureMauro Carvalho Chehab1-2/+2
The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME match criteria requires just a device name. So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union. That makes easier to document it, as we don't need to document weird senseless structs. At drivers, this makes even clearer about the match criteria. Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Benoit Parrot <bparrot@ti.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Hyun Kwon <hyun.kwon@xilinx.com> Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-15media: staging/imx: update TODOSteve Longerbeam1-12/+51
Update TODO file: - Remove TODO info about the OV564x driver, while this still needs to be done (add a OV5642 driver or merge with OV5640 driver), it is not relevant here. - Update TODO about methods for retrieving CSI bus config. - Add some TODO's about OF graph parsing restrictions. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-15media: staging/imx: reorder function prototypesSteve Longerbeam1-9/+12
Re-order some of the function prototypes in imx-media.h to group them correctly by source file. No functional changes. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-15media: staging/imx: convert static vdev lists to list_headSteve Longerbeam4-66/+68
Although not technically necessary because imx-media has only a maximum of 8 video devices, and once setup the video device lists are static, in anticipation of moving control ineritance to v4l2-core, make the vdev lists more generic by converting to dynamic list_head's. After doing that, 'struct imx_media_pad' is now just a list_head of video devices reachable from a pad. Allocate an array of list_head's, one list_head for each pad, and attach that array to sd->host_priv. An entry in the pad lists is of type 'struct imx_media_pad_vdev', and points to a video device from the master list. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-15media: staging/imx: remove static subdev arraysSteve Longerbeam7-218/+216
For more complex OF graphs, there will be more async subdevices registered. Remove the static subdev[IMX_MEDIA_MAX_SUBDEVS] array, so that imx-media places no limits on the number of async subdevs that can be added and registered. There were two uses for 'struct imx_media_subdev'. First was to act as the async subdev list to be passed to v4l2_async_notifier_register(). Second was to aid in inheriting subdev controls to the capture devices, and this is done by creating a list of capture devices that can be reached from a subdev's source pad. So 'struct imx_media_subdev' also contained a static array of 'struct imx_media_pad' for placing the capture device lists at each pad. 'struct imx_media_subdev' has been completely removed. Instead, at async completion, allocate an array of 'struct imx_media_pad' and attach it to the subdev's host_priv pointer, in order to support subdev controls inheritance. Likewise, remove static async_ptrs[IMX_MEDIA_MAX_SUBDEVS] array. Instead, allocate a 'struct imx_media_async_subdev' when forming the async list, and add it to an asd_list list_head in imx_media_add_async_subdev(). At async completion, allocate the asd pointer list and pull the asd's off asd_list for v4l2_async_notifier_register(). Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>