aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/v4l2-fwnode.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-03-01media: v4l2-core: fix several typosMauro Carvalho Chehab1-8/+8
Use codespell to fix lots of typos over frontends. Manually verified to avoid false-positives. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-12media: v4l2-fwnode: Fix setting V4L2_MBUS_DATA_ACTIVE_HIGH/LOW flagOndrej Jirman1-2/+2
When parallel bus is used and data-active is being parsed, incorrect flags are cleared. Clear the correct flag bits. Fixes: e9be1b863e2c2948deb003df8edd9635b4611a8a (media: v4l: fwnode: Use default parallel flags). Cc: stable@vger.kernel.org # for Kernel 4.20 Signed-off-by: Ondrej Jirman <megous@megous.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-07media: Use of_node_name_eq for node name comparisonsRob Herring1-4/+2
Convert string compares of DT node names to use of_node_name_eq helper instead. This removes direct access to the node name pointer. Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Kukjin Kim <kgene@kernel.org> Cc: Krzysztof Kozlowski <krzk@kernel.org> Cc: Hyun Kwon <hyun.kwon@xilinx.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-05media: v4l2-fwnode: Demote warning to debug levelFabio Estevam1-1/+1
On a imx6q-wandboard the following warnings are observed: [ 4.327794] video-mux 20e0000.iomuxc-gpr:ipu1_csi0_mux: bad remote port parent [ 4.336118] video-mux 20e0000.iomuxc-gpr:ipu2_csi1_mux: bad remote port parent As explained by Philipp Zabel: "There are empty endpoint nodes (without remote-endpoint property) labeled ipu1_csi[01]_mux_from_parallel_sensor in the i.MX6 device trees for board DT implementers' convenience. See commit 2539f517acbdc ("ARM: dts: imx6qdl: Add video multiplexers, mipi_csi, and their connections")." So demote the warning to debug level and make the wording a bit less misleading. Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Fabio Estevam <festevam@gmail.com> Reviewed-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-05media: v4l2-fwnode: simplify v4l2_fwnode_reference_parse_int_props() callMauro Carvalho Chehab1-11/+12
The v4l2_fwnode_reference_parse_int_props() has a big name, causing it to cause coding style warnings. Also, it depends on a const struct embedded indide a function. Rearrange the logic in order to move the struct declaration out of such function and use it inside this function. That cleans up some coding style issues. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-05media: v4l2-fwnode: cleanup functions that parse endpointsMauro Carvalho Chehab1-36/+28
There is already a typedef for the parse endpoint function. However, instead of using it, it is redefined at the C file (and on one of the function headers). Replace them by the function typedef, in order to cleanup several related coding style warnings. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-05media: v4l2-core: cleanup coding style at V4L2 async/fwnodeMauro Carvalho Chehab1-79/+106
There are several coding style issues at those definitions, and the previous patchset added even more. Address the trivial ones by first calling: ./scripts/checkpatch.pl --strict --fix-inline include/media/v4l2-async.h include/media/v4l2-fwnode.h include/media/v4l2-mediabus.h drivers/media/v4l2-core/v4l2-async.c drivers/media/v4l2-core/v4l2-fwnode.c and then manually adjusting the style where needed. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: v4l: fwnode: Support parsing of CSI-2 C-PHY endpointsSakari Ailus1-3/+7
The V4L2 fwnode framework only parsed CSI-2 D-PHY endpoints while C-PHY support wasn't there. Also parse endpoints for media bus type V4L2_MBUS_CSI2_CPHY. 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: fwnode: Use V4L2 fwnode endpoint media bus type if setSakari Ailus1-8/+19
Use the given media bus type set by the caller. If none is given (i.e. the mbus type is V4L2_MBUS_UNKNOWN, or 0), fall back to the old behaviour. This is to obtain the information from the DT or try to guess the bus type. -ENXIO is returned if the caller sets the bus type but that does not match with what's in DT. Also return -ENXIO if bus type detection failed to separate this from the rest of the errors. 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: fwnode: Print bus typeSakari Ailus1-0/+38
Print bus type either as set by the driver or as parsed from the bus-type property, as well as the guessed V4L2 media bus type. 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: fwnode: Use default parallel flagsSakari Ailus1-0/+19
The caller may provide default flags for the endpoint. Change the configuration based on what is available through the fwnode property API. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: v4l: fwnode: Use media bus type for bus parser selectionSakari Ailus1-20/+80
Use the media bus types instead of the fwnode bus types internally. This is the interface to the drivers as well, making the use of the fwnode bus types more localised to the V4L2 fwnode framework. 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: fwnode: Only zero the struct if bus type is set to V4L2_MBUS_UNKNOWNSakari Ailus1-4/+6
In order to prepare for allowing drivers to set the defaults for a given bus, make zeroing the struct conditional based on detecting the bus. All callers now set the bus type to zero which allows only zeroing the remaining bus union. 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: fwnode: Parse the graph endpoint as lastSakari Ailus1-1/+7
Parsing the graph endpoint is always successful; therefore parse it as last. 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: fwnode: Support default CSI-2 lane mapping for driversSakari Ailus1-14/+46
Most hardware doesn't support re-mapping of the CSI-2 lanes. Especially sensor drivers have a default number of lanes. Instead of requiring the caller (the driver) to provide such a unit mapping, provide one if no mapping is configured. 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: fwnode: Support driver-defined lane mapping defaultsSakari Ailus1-8/+12
Make use of the default CSI-2 lane mapping from caller-passed configuration. 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: fwnode: Only assign configuration if there is no errorSakari Ailus1-12/+18
Only assign endpoint configuration if the endpoint is parsed successfully. 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: fwnode: Read lane inversion information despite lane numberingSakari Ailus1-30/+35
Read the lane inversion independently of whether the "data-lanes" property exists. This makes sense since the caller may pass the number of lanes as the default configuration while the lane inversion configuration may still be available in firmware. 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: fwnode: Make use of newly specified bus typesSakari Ailus1-10/+38
Add support for parsing CSI-2 D-PHY, parallel or Bt.656 bus explicitly. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: v4l: fwnode: Detect bus type correctlySakari Ailus1-14/+17
In case the device supports multiple video bus types on an endpoint, the V4L2 fwnode framework attempts to detect the type based on the available information. This wasn't working really well, and sometimes could lead to the V4L2 fwnode endpoint struct as being mishandled between the bus types. Default to Bt.656 if no properties suggesting a bus type are found. 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: fwnode: Let the caller provide V4L2 fwnode endpointSakari Ailus1-30/+19
Instead of allocating the V4L2 fwnode endpoint in v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows setting default parameters for the endpoint which is a very common need for drivers. 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 Ailus1-1/+1
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: v4l: fwnode: Add definitions for CSI-2 D-PHY, parallel and Bt.656 bussesSakari Ailus1-0/+3
Add definitions corresponding to DT bindings to the CSI-2 D-PHY, parallel and Bt.656 busses. 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: fwnode: The CSI-2 clock is continuous if it's not non-continuousSakari Ailus1-1/+1
The continuous clock flag was only set if there was a clock or data lanes. This isn't needed as such a configuration is invalid to begin with. Always set the continuous clock flag if the non-continuous property is not found. 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: fwnode: Use fwnode_graph_for_each_endpointSakari Ailus1-2/+1
Use fwnode_graph_for_each_endpoint iterator for better readability. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> 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: fwnode: Add debug prints for V4L2 endpoint property parsingSakari Ailus1-23/+85
Print debug info as standard V4L2 endpoint are parsed. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> 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: v4l2-fwnode: Add a convenience function for registering subdevs with notifiersSteve Longerbeam1-0/+64
Adds v4l2_async_register_fwnode_subdev(), which is a convenience function for parsing a sub-device's fwnode port endpoints for connected remote sub-devices, registering a sub-device notifier, and then registering the sub-device itself. 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: v4l2-fwnode: Switch to v4l2_async_notifier_add_subdevSteve Longerbeam1-104/+28
The fwnode endpoint and reference parsing functions in v4l2-fwnode.c are modified to make use of v4l2_async_notifier_add_subdev(). As a result the notifier->subdevs array is no longer allocated or re-allocated, and by extension the max_subdevs value is also no longer needed. Callers of the fwnode endpoint and reference parsing functions must now first initialize the notifier with a call to v4l2_async_notifier_init(). This includes the function v4l2_async_register_subdev_sensor_common(), and the intel-ipu3, omap3isp, and rcar-vin drivers. Since the notifier->subdevs array is no longer allocated in the fwnode endpoint and reference parsing functions, the callers of those functions must never reference that array, since it is now NULL. Of the drivers that make use of the fwnode/ref parsing, only the intel-ipu3 driver references the ->subdevs[] array, (in the notifier completion callback), so that driver has been modified to iterate through the notifier->asd_list instead. 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: v4l2-fwnode: ignore endpoints that have no remote port parentSteve Longerbeam1-1/+1
Documentation/devicetree/bindings/media/video-interfaces.txt states that the 'remote-endpoint' property is optional. So v4l2_async_notifier_fwnode_parse_endpoint() should not return error if the endpoint has no remote port parent. Just ignore the endpoint, skip adding an asd to the notifier and return 0. __v4l2_async_notifier_parse_fwnode_endpoints() will then continue parsing the remaining port endpoints of the device. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-15Merge tag 'media/v4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-mediaLinus Torvalds1-0/+4
Pull media updates from Mauro Carvalho Chehab: - new Socionext MN88443x ISDB-S/T demodulator driver: mn88443x - new sensor drivers: ak7375, ov2680 and rj54n1cb0c - an old soc-camera sensor driver converted to the V4L2 framework: mt9v111 - a new Voice-Coil Motor (VCM) driver: dw9807-vcm - some cleanups at cx25821, removing legacy unused code - some improvements at ddbridge driver - new platform driver: vicodec - some DVB API cleanups, removing ioctls and compat code for old out-of-tree drivers that were never merged upstream - improvements at DVB core to support frontents that support both Satellite and non-satellite delivery systems - got rid of the unused VIDIOC_RESERVED V4L2 ioctl - some cleanups/improvements at gl861 ISDB driver - several improvements on ov772x, ov7670 and ov5640, imx274, ov5645, and smiapp sensor drivers - fixes at em28xx to support dual TS devices - some cleanups at V4L2/VB2 locking logic - some API improvements at media controller - some cec core and drivers improvements - some uvcvideo improvements - some improvements at platform drivers: stm32-dcmi, rcar-vin, coda, reneseas-ceu, imx, vsp1, venus, camss - lots of other cleanups and fixes * tag 'media/v4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (406 commits) Revert "media: vivid: shut up warnings due to a non-trivial logic" siano: get rid of an unused return code for debugfs register media: isp: fix a warning about a wrong struct initializer media: radio-wl1273: fix return code for the polling routine media: s3c-camif: fix return code for the polling routine media: saa7164: fix return codes for the polling routine media: exynos-gsc: fix return code if mutex was interrupted media: mt9v111: Fix build error with no VIDEO_V4L2_SUBDEV_API media: xc4000: get rid of uneeded casts media: drxj: get rid of uneeded casts media: tuner-xc2028: don't use casts for printing sizes media: cleanup fall-through comments media: vivid: shut up warnings due to a non-trivial logic media: rtl28xxu: be sure that it won't go past the array size media: mt9v111: avoid going past the buffer media: vsp1_dl: add a description for cmdpool field media: sta2x11: add a missing parameter description media: v4l2-mem2mem: add descriptions to MC fields media: i2c: fix warning in Aptina MT9V111 media: imx: shut up a false positive warning ...
2018-07-24media: v4l2-fwnode: parse 'data-enable-active' propJacopo Mondi1-0/+4
Parse the newly defined 'data-enable-active' property in parallel endpoint parsing function. Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-23ACPI: Convert ACPI reference args to generic fwnode reference argsSakari Ailus1-1/+1
Convert all users of struct acpi_reference_args to more generic fwnode_reference_args. This will 1) avoid an ACPI specific references to device nodes with integer arguments as well as 2) allow making references to nodes other than device nodes in ACPI. As a by-product, convert the fwnode interger arguments to u64. The arguments were 64-bit integers on ACPI but the fwnode arguments were just 32-bit. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-04-17media: v4l2-fwnode: simplify v4l2_fwnode_reference_parse_int_props()Mauro Carvalho Chehab1-10/+18
The logic at v4l2_fwnode_reference_parse_int_props() is somewhat complex and violates Linux coding style, as it does multiple statements on a single line. That makes static analyzers to be confused, as warned by smatch: drivers/media/v4l2-core/v4l2-fwnode.c:832 v4l2_fwnode_reference_parse_int_props() warn: passing zero to 'PTR_ERR' Simplify the logic, in order to make clearer about what happens when v4l2_fwnode_reference_get_int_prop() returns an error. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-29media: v4l2-async: simplify v4l2_async_subdev structureMauro Carvalho Chehab1-5/+5
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-11-30media: v4l2-fwnode: Check subdev count after checking portTomasz Figa1-5/+5
Current implementation of __v4l2_async_notifier_parse_fwnode_endpoints() checks first whether subdev_count >= subdev_max and only then whether the port being parsed matches the given port index. This triggers an error in otherwise valid cases of skipping ports that do not match. Fix this by moving the check below the port index check. Fixes: 9ca465312132 ("media: v4l: fwnode: Support generic parsing of graph endpoints in a device") Signed-off-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-01media: v4l2-fwnode: use the cached value instead of getting againMauro Carvalho Chehab1-2/+1
There is a get/put operation in order to get firmware is_available data there at the __v4l2_async_notifier_parse_fwnode_endpoints() function. However, instead of using it, the code just reads again without the lock. That's a bug, as dev_fwnode isn't guaranteed to be there once fwnode_handle_put() has been called on it. This solves this smatch warning: drivers/media/v4l2-core/v4l2-fwnode.c:453:8: warning: variable 'is_available' set but not used [-Wunused-but-set-variable] bool is_available; ^~~~~~~~~~~~ Fixes: 9ca465312132 ("media: v4l: fwnode: Support generic parsing of graph endpoints in a device") Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Add a convenience function for registering sensorsSakari Ailus1-0/+41
Add a convenience function for parsing firmware for information on related devices using v4l2_async_notifier_parse_fwnode_sensor_common() registering the notifier and finally the async sub-device itself. This should be useful for sensor drivers that do not have device specific requirements related to firmware information parsing or the async framework. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Add convenience function for parsing common external refsSakari Ailus1-0/+35
Add v4l2_fwnode_parse_reference_sensor_common for parsing common sensor properties that refer to adjacent devices such as flash or lens driver chips. As this is an association only, there's little a regular driver needs to know about these devices as such. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Add a helper function to obtain device / integer referencesSakari Ailus1-0/+287
v4l2_fwnode_reference_parse_int_prop() will find an fwnode such that under the device's own fwnode, it will follow child fwnodes with the given property-value pair and return the resulting fwnode. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Add a helper function for parsing generic referencesSakari Ailus1-0/+69
Add function v4l2_fwnode_reference_parse() for parsing them as async sub-devices. This can be done on e.g. flash or lens async sub-devices that are not part of but are associated with a sensor. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Move KernelDoc documentation to the headerSakari Ailus1-75/+0
In V4L2 the practice is to have the KernelDoc documentation in the header and not in .c source code files. This consequently makes the V4L2 fwnode function documentation part of the Media documentation build. Also correct the link related function and argument naming in documentation and add an asterisk to v4l2_fwnode_endpoint_free() documentation to make it proper KernelDoc documentation. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: v4l: fwnode: Support generic parsing of graph endpoints in a deviceSakari Ailus1-0/+196
Add two functions for parsing devices graph endpoints: v4l2_async_notifier_parse_fwnode_endpoints and v4l2_async_notifier_parse_fwnode_endpoints_by_port. The former iterates over all endpoints whereas the latter only iterates over the endpoints in a given port. The former is mostly useful for existing drivers that currently implement the iteration over all the endpoints themselves whereas the latter is especially intended for devices with both sinks and sources: async sub-devices for external devices connected to the device's sources will have already been set up, or the external sub-devices are part of the master device. Depends-on: ("device property: preserve usecount for node passed to of_fwnode_graph_get_port_parent()") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26media: v4l: fwnode: Use a less clash-prone name for MAX_DATA_LANES macroSakari Ailus1-2/+3
Avoid using a generic name such as MAX_DATA_LANES in a header file widely included in drivers. Instead, call it V4L2_FWNODE_CSI2_MAX_DATA_LANES. Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26media: v4l: fwnode: The clock lane is the first lane in lane_polaritiesSakari Ailus1-1/+1
The clock lane is the first lane in the lane_polarities array. Reflect this consistently by putting the number of data lanes after the number of clock lanes. Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26media: v4l: fwnode: Fix lane-polarities property parsingSakari Ailus1-3/+7
fwnode_property_read_u32_array() only returns the number of array elements if the array argument is NULL. The assumption that it always did so lead to lane-polarities properties never being read. Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-26media: v4l2-fwnode: link_frequency is an optional propertySakari Ailus1-15/+15
v4l2_fwnode_endpoint_alloc_parse() is intended as a replacement for v4l2_fwnode_endpoint_parse(). It parses the "link-frequency" property and if the property isn't found, it returns an error. However, "link-frequency" is an optional property and if it does not exist is not an error. Instead, the number of link frequencies is simply zero in that case. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20media: v4l2-fwnode: make v4l2_fwnode_endpoint_parse_csi1_bus staticMauro Carvalho Chehab1-3/+4
This function is used only internally. So, make it static. Shuts up this warning: drivers/media/v4l2-core/v4l2-fwnode.c:153:6: warning: no previous prototype for 'v4l2_fwnode_endpoint_parse_csi1_bus' [-Wmissing-prototypes] void v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20media: v4l2-fwnode: suppress a warning at OF parsing logicMauro Carvalho Chehab1-18/+14
smatch produce this warning: drivers/media/v4l2-core/v4l2-fwnode.c:76 v4l2_fwnode_endpoint_parse_csi_bus() error: buffer overflow 'array' 5 <= u16max That's because, in thesis, the routine might have called with some value at bus->num_data_lanes. That's not the current case. Yet, better to shut up this warning, and make the code more reliable if some future changes might cause a bug. While here, simplify the code a little bit by reading only once from lanes-properties array. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-19media: v4l: Add support for CSI-1 and CCP2 bussesSakari Ailus1-11/+47
CCP2 and CSI-1, are older single data lane serial busses. [mchehab@s-opensource.com: don't use spaces for identation] Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-19media: v4l: fwnode: Obtain data bus type from FWSakari Ailus1-0/+11
Just obtain it. It'll actually get used soon with CSI-1/CCP2. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Tested-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>