V4L2 fwnode support
Subsystems (17)
v2 cover V4L2 fwnode support
(Resending, got one list address wrong. Apologies for the noise...)
Hello everyone,
This patchset adds support for fwnode to V4L2. Besides OF, also ACPI based systems can be supported this way. By using V4L2 fwnode, the individual drivers do not need to be aware of the underlying firmware implementation. The patchset also removes specific V4L2 OF support and converts the affected drivers to use V4L2 fwnode.
The patchset depends on another patchset here:
<URL:http://www.spinics.net/lists/linux-acpi/msg72973.html>
v1 of the set can be found here:
<URL:http://www.spinics.net/lists/linux-media/msg111073.html>
changes since v1:
- Use existing dev_fwnode() instead of device_fwnode_handle() added by the ACPI graph patchset,
- Fix too long line of ^'s in ReST documentation and
- Drop the patch rearranging the header files. It'd better go in separately, if at all.
Sakari Ailus (8):
v4l: flash led class: Use fwnode_handle instead of device_node in init
v4l: fwnode: Support generic fwnode for parsing standardised
properties
v4l: async: Add fwnode match support
v4l: async: Provide interoperability between OF and fwnode matching
v4l: Switch from V4L2 OF not V4L2 fwnode API
v4l: media/drv-intf/soc_mediabus.h: include dependent header file
docs-rst: media: Switch documentation to V4L2 fwnode API
v4l: Remove V4L2 OF framework in favour of V4L2 fwnode framework
Documentation/media/kapi/v4l2-core.rst | 2 +- Documentation/media/kapi/v4l2-fwnode.rst | 3 + Documentation/media/kapi/v4l2-of.rst | 3 - drivers/leds/leds-aat1290.c | 5 +- drivers/leds/leds-max77693.c | 5 +- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/adv7604.c | 7 +- drivers/media/i2c/mt9v032.c | 7 +- drivers/media/i2c/ov2659.c | 8 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +- drivers/media/i2c/s5k5baf.c | 6 +- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 +- drivers/media/i2c/tc358743.c | 11 +- drivers/media/i2c/tvp514x.c | 6 +- drivers/media/i2c/tvp5150.c | 7 +- drivers/media/i2c/tvp7002.c | 6 +- drivers/media/platform/Kconfig | 3 + drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +- drivers/media/platform/omap3isp/isp.c | 71 ++--- drivers/media/platform/pxa_camera.c | 7 +- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 +- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++-- drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 4 +- drivers/media/v4l2-core/v4l2-async.c | 36 ++- drivers/media/v4l2-core/v4l2-flash-led-class.c | 11 +- drivers/media/v4l2-core/v4l2-fwnode.c | 353 +++++++++++++++++++++++++ drivers/media/v4l2-core/v4l2-of.c | 327 ----------------------- include/media/drv-intf/soc_mediabus.h | 2 + include/media/v4l2-async.h | 7 +- include/media/v4l2-flash-led-class.h | 4 +- include/media/v4l2-fwnode.h | 104 ++++++++ include/media/v4l2-of.h | 128 --------- include/media/v4l2-subdev.h | 3 + 47 files changed, 698 insertions(+), 608 deletions(-) create mode 100644 Documentation/media/kapi/v4l2-fwnode.rst delete mode 100644 Documentation/media/kapi/v4l2-of.rst create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c delete mode 100644 drivers/media/v4l2-core/v4l2-of.c create mode 100644 include/media/v4l2-fwnode.h delete mode 100644 include/media/v4l2-of.h
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sakari Ailus
maintainerPATCH v2 1/8 v4l: flash led class: Use fwnode_handle instead of device_node in init
Pass the more generic fwnode_handle to the init function than the device_node.
--- drivers/leds/leds-aat1290.c | 5 +++-- drivers/leds/leds-max77693.c | 5 +++-- drivers/media/v4l2-core/v4l2-flash-led-class.c | 11 ++++++----- include/media/v4l2-flash-led-class.h | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-)
drivers/leds/leds-aat1290.c +3 -2
@@ -503,8 +503,9 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_v4l2_flash_config (led, &led_cfg, &v4l2_sd_cfg);/* Create V4L2 Flash subdev. */ - led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + led->v4l2_flash =v4l2_flash_init (dev,of_fwnode_handle (sub_node), + fled_cdev,NULL , &v4l2_flash_ops, + &v4l2_sd_cfg);if (IS_ERR (led->v4l2_flash)) { ret =PTR_ERR (led->v4l2_flash); goto error_v4l2_flash_init;
drivers/leds/leds-max77693.c +3 -2
@@ -930,8 +930,9 @@ static int max77693_register_led(struct max77693_sub_led *sub_led,max77693_init_v4l2_flash_config (sub_led, led_cfg, &v4l2_sd_cfg);/* Register in the V4L2 subsystem. */ - sub_led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + sub_led->v4l2_flash =v4l2_flash_init (dev,of_fwnode_handle (sub_node), + fled_cdev,NULL , &v4l2_flash_ops, + &v4l2_sd_cfg);if (IS_ERR (sub_led->v4l2_flash)) { ret =PTR_ERR (sub_led->v4l2_flash); goto err_v4l2_flash_init;
drivers/media/v4l2-core/v4l2-flash-led-class.c +6 -5
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/types.h> #include <media/v4l2-flash-led-class.h>
@@ -612,7 +613,7 @@ static const struct v4l2_subdev_internal_ops v4l2_flash_subdev_internal_ops = {static const struct v4l2_subdev_ops v4l2_flash_subdev_ops; struct v4l2_flash *v4l2_flash_init( - struct device *dev, struct device_node *of_node, + struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, struct led_classdev_flash *iled_cdev, const struct v4l2_flash_ops *ops,
@@ -638,7 +639,7 @@ struct v4l2_flash *v4l2_flash_init( v4l2_flash->iled_cdev = iled_cdev; v4l2_flash->ops = ops; sd->dev = dev; - sd->of_node = of_node ? of_node : led_cdev->dev->of_node; + sd->fwnode = fwn ? fwn :dev_fwnode (led_cdev->dev);v4l2_subdev_init (sd, &v4l2_flash_subdev_ops); sd->internal_ops = &v4l2_flash_subdev_internal_ops; sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;
@@ -654,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(if (ret <0 ) goto err_init_controls; -of_node_get (sd->of_node); +fwnode_handle_get (sd->fwnode); ret =v4l2_async_register_subdev (sd);if (ret <0 )
@@ -663,7 +664,7 @@ struct v4l2_flash *v4l2_flash_init(return v4l2_flash; err_async_register_sd: -of_node_put (sd->of_node); +fwnode_handle_put (sd->fwnode);v4l2_ctrl_handler_free (sd->ctrl_handler); err_init_controls:media_entity_cleanup (&sd->entity);
@@ -683,7 +684,7 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash)v4l2_async_unregister_subdev (sd); -of_node_put (sd->of_node); +fwnode_handle_put (sd->fwnode);v4l2_ctrl_handler_free (sd->ctrl_handler);media_entity_cleanup (&sd->entity);
include/media/v4l2-flash-led-class.h +2 -2
@@ -108,7 +108,7 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)/** * v4l2_flash_init - initialize V4L2 flash led sub-device * @dev: flash device, e.g. an I2C device -* @of_node: of_node of the LED, may be NULL if the same as device's +* @fwn: fwnode_handle of the LED, may be NULL if the same as device's * @fled_cdev: LED flash class device to wrap * @iled_cdev: LED flash class device representing indicator LED associated * with fled_cdev, may be NULL
@@ -122,7 +122,7 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)* PTR_ERR() to obtain the numeric return value. */ struct v4l2_flash *v4l2_flash_init( - struct device *dev, struct device_node *of_node, + struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, struct led_classdev_flash *iled_cdev, const struct v4l2_flash_ops *ops,
Signature · 1 line
2.7.4
PATCH v2 2/8 v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to a message not in the archiveThe fwnode_handle is a more generic way than OF device_node to describe firmware nodes. Instead of the OF API, use more generic fwnode API to obtain the same information.
As the V4L2 fwnode support will be required by a small minority of e.g. ACPI based systems (the same might actually go for OF), make this a module instead of embedding it in the videodev module.
--- drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fwnode.c | 353 ++++++++++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 104 ++++++++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c create mode 100644 include/media/v4l2-fwnode.h
drivers/media/v4l2-core/Kconfig +3 -0
@@ -55,6 +55,9 @@ config V4L2_FLASH_LED_CLASS When in doubt, say N. +config V4L2_FWNODE + tristate + # Used by drivers that need Videobuf modules config VIDEOBUF_GEN tristate
drivers/media/v4l2-core/Makefile +1 -0
@@ -13,6 +13,7 @@ endif ifeq ($(CONFIG_OF),y) videodev-objs += v4l2-of.o endif +obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o endif
drivers/media/v4l2-core/v4l2-fwnode.c new file +353 -0
353 lines not on this page · raw message
include/media/v4l2-fwnode.h new file +104 -0
104 lines not on this page · raw message
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/8 v4l: async: Add fwnode match support
In reply to a message not in the archiveAdd fwnode matching to complement OF node matching. And fwnode may also be an OF node.
--- drivers/media/v4l2-core/v4l2-async.c | 12 ++++++++++++ include/media/v4l2-async.h | 5 +++++ include/media/v4l2-subdev.h | 3 +++ 3 files changed, 20 insertions(+)
drivers/media/v4l2-core/v4l2-async.c +12 -0
@@ -46,6 +46,11 @@ static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) of_node_full_name(asd->match.of.node)); } +static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) +{ +return sd->fwnode == asd->match.fwnode.fwn; +} +static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) {if (!asd->match.custom.match)
@@ -80,6 +85,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier *case V4L2_ASYNC_MATCH_OF : match = match_of;break ; +case V4L2_ASYNC_MATCH_FWNODE : + match = match_fwnode; +break ;default :/* Cannot happen, unless someone breaks us */ WARN_ON (true);
@@ -158,6 +166,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,case V4L2_ASYNC_MATCH_DEVNAME :case V4L2_ASYNC_MATCH_I2C :case V4L2_ASYNC_MATCH_OF : +case V4L2_ASYNC_MATCH_FWNODE :break ;default : dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL,
@@ -282,6 +291,9 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)*/ if (!sd->of_node && sd->dev) sd->of_node = sd->dev->of_node; +if (!sd->fwnode && sd->dev) + sd->fwnode = sd->dev->of_node ? + &sd->dev->of_node->fwnode : sd->dev->fwnode;mutex_lock (&list_lock);
include/media/v4l2-async.h +5 -0
@@ -32,6 +32,7 @@ struct v4l2_async_notifier;* @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address * @V4L2_ASYNC_MATCH_OF: Match will use OF node +* @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node * * This enum is used by the asyncrhronous sub-device logic to define the * algorithm that will be used to match an asynchronous device.
@@ -41,6 +42,7 @@ enum v4l2_async_match_type {V4L2_ASYNC_MATCH_DEVNAME ,V4L2_ASYNC_MATCH_I2C ,V4L2_ASYNC_MATCH_OF , + V4L2_ASYNC_MATCH_FWNODE, };/**
@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn; + } fwnode; +struct {const char *name; } device_name;struct {
include/media/v4l2-subdev.h +3 -0
@@ -788,6 +788,8 @@ struct v4l2_subdev_platform_data {* @devnode: subdev device node * @dev: pointer to the physical device, if any * @of_node: The device_node of the subdev, usually the same as dev->of_node. +* @fwnode: The fwnode_handle of the subdev, usually the same as +* either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL). * @async_list: Links this subdev to a global subdev_list or @notifier->done * list. * @asd: Pointer to respective &struct v4l2_async_subdev.
@@ -819,6 +821,7 @@ struct v4l2_subdev {struct video_device *devnode;struct device *dev;struct device_node *of_node; +struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sakari Ailus
maintainerPATCH v2 4/8 v4l: async: Provide interoperability between OF and fwnode matching
In reply to Sakari AilusOF and fwnode support are separated in V4L2 and individual drivers may implement one of them. Sub-devices do not match with a notifier expecting sub-devices with fwnodes, nor the other way around.
Fix this by checking for sub-device's of_node field in fwnode match and fwnode field in OF match.
--- drivers/media/v4l2-core/v4l2-async.c | 26 +++++++++++++++++++++++--- include/media/v4l2-async.h | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +23 -3
@@ -14,6 +14,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/types.h>
@@ -40,15 +41,34 @@ static bool match_devname(struct v4l2_subdev *sd,return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); } +static bool fwnode_cmp (struct fwnode_handle *one, +struct fwnode_handle *theother) +{ +if (!one || !theother) +return false; + +if (one->type != theother->type) +return false; + +if (is_of_node (one)) +return !of_node_cmp (of_node_full_name (to_of_node (one)), +of_node_full_name (to_of_node (theother))); +else +return one == theother; +} +static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !of_node_cmp (of_node_full_name (sd->of_node), -of_node_full_name (asd->match.of.node)); +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, +of_fwnode_handle (asd->match.of.node)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwn; +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, + asd->match.fwnode.fwn); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)
include/media/v4l2-async.h +1 -1
@@ -57,7 +57,7 @@ struct v4l2_async_subdev {enum v4l2_async_match_type match_type;union {struct { -const struct device_node *node; +struct device_node *node; } of;struct {struct fwnode_handle *fwn;
Signature · 1 line
2.7.4
PATCH v2 5/8 v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to a message not in the archiveSwitch users of the v4l2_of_ APIs to the more generic v4l2_fwnode_ APIs.
Existing OF matching continues to be supported. omap3isp and smiapp drivers are converted to fwnode matching as well.
--- drivers/media/i2c/Kconfig | 9 ++++ drivers/media/i2c/adv7604.c | 7 +-- drivers/media/i2c/mt9v032.c | 7 +-- drivers/media/i2c/ov2659.c | 8 +-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +-- drivers/media/i2c/s5k5baf.c | 6 +-- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 ++++++----- drivers/media/i2c/tc358743.c | 11 ++-- drivers/media/i2c/tvp514x.c | 6 +-- drivers/media/i2c/tvp5150.c | 7 +-- drivers/media/i2c/tvp7002.c | 6 +-- drivers/media/platform/Kconfig | 3 ++ drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +-- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +-- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +-- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +-- drivers/media/platform/omap3isp/isp.c | 71 +++++++++++++------------- drivers/media/platform/pxa_camera.c | 7 +-- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +-- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +-- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 ++-- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++++++++++---------- include/media/v4l2-fwnode.h | 4 +- 31 files changed, 176 insertions(+), 134 deletions(-)
drivers/media/i2c/Kconfig +9 -0
@@ -210,6 +210,7 @@ config VIDEO_ADV7604 depends on GPIOLIB || COMPILE_TEST select HDMI select MEDIA_CEC_EDID + select V4L2_FWNODE ---help--- Support for the Analog Devices ADV7604 video decoder.
@@ -324,6 +325,7 @@ config VIDEO_TC358743 tristate "Toshiba TC358743 decoder" depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API select HDMI + select V4L2_FWNODE ---help--- Support for the Toshiba TC358743 HDMI to MIPI CSI-2 bridge.
@@ -333,6 +335,7 @@ config VIDEO_TC358743 config VIDEO_TVP514X tristate "Texas Instruments TVP514x video decoder" depends on VIDEO_V4L2 && I2C + select V4L2_FWNODE ---help--- This is a Video4Linux2 sensor-level driver for the TI TVP5146/47 decoder. It is currently working with the TI OMAP3 camera
@@ -344,6 +347,7 @@ config VIDEO_TVP514X config VIDEO_TVP5150 tristate "Texas Instruments TVP5150 video decoder" depends on VIDEO_V4L2 && I2C + select V4L2_FWNODE ---help--- Support for the Texas Instruments TVP5150 video decoder.
@@ -353,6 +357,7 @@ config VIDEO_TVP5150 config VIDEO_TVP7002 tristate "Texas Instruments TVP7002 video decoder" depends on VIDEO_V4L2 && I2C + select V4L2_FWNODE ---help--- Support for the Texas Instruments TVP7002 video decoder.
@@ -524,6 +529,7 @@ config VIDEO_OV2659 tristate "OmniVision OV2659 sensor support" depends on VIDEO_V4L2 && I2C depends on MEDIA_CAMERA_SUPPORT + select V4L2_FWNODE ---help--- This is a Video4Linux2 sensor-level driver for the OmniVision OV2659 camera.
@@ -616,6 +622,7 @@ config VIDEO_MT9V032 depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API depends on MEDIA_CAMERA_SUPPORT select REGMAP_I2C + select V4L2_FWNODE ---help--- This is a Video4Linux2 sensor-level driver for the Micron MT9V032 752x480 CMOS sensor.
@@ -663,6 +670,7 @@ config VIDEO_S5K4ECGX config VIDEO_S5K5BAF tristate "Samsung S5K5BAF sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE ---help--- This is a V4L2 sensor-level driver for Samsung S5K5BAF 2M camera sensor with an embedded SoC image signal processor.
@@ -673,6 +681,7 @@ source "drivers/media/i2c/et8ek8/Kconfig" config VIDEO_S5C73M3 tristate "Samsung S5C73M3 sensor support" depends on I2C && SPI && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE ---help--- This is a V4L2 sensor-level driver for Samsung S5C73M3 8 Mpixel camera.
drivers/media/i2c/adv7604.c +4 -3
@@ -33,6 +33,7 @@#include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_graph.h> #include <linux/slab.h> #include <linux/v4l2-dv-timings.h> #include <linux/videodev2.h>
@@ -45,7 +46,7 @@#include <media/v4l2-device.h> #include <media/v4l2-event.h> #include <media/v4l2-dv-timings.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> static int debug;module_param (debug, int,0644 );
@@ -3069,7 +3070,7 @@ MODULE_DEVICE_TABLE(of, adv76xx_of_id);static int adv76xx_parse_dt (struct adv76xx_state *state) { -struct v4l2_of_endpoint bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg;struct device_node *endpoint;struct device_node *np;unsigned int flags;
@@ -3083,7 +3084,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)if (!endpoint)return -EINVAL ; - ret =v4l2_of_parse_endpoint (endpoint, &bus_cfg); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (endpoint), &bus_cfg);if (ret) {of_node_put (endpoint);return ret;
drivers/media/i2c/mt9v032.c +4 -3
@@ -19,6 +19,7 @@#include <linux/log2.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/of_graph.h> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/videodev2.h>
@@ -28,7 +29,7 @@#include <media/i2c/mt9v032.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> /* The first four rows are black rows. The active area spans 753x481 pixels. */
@@ -979,7 +980,7 @@ static struct mt9v032_platform_data * mt9v032_get_pdata(struct i2c_client *client) {struct mt9v032_platform_data *pdata =NULL ; -struct v4l2_of_endpoint endpoint; +struct v4l2_fwnode_endpoint endpoint;struct device_node *np;struct property *prop;
@@ -990,7 +991,7 @@ mt9v032_get_pdata(struct i2c_client *client)if (!np)return NULL ; -if (v4l2_of_parse_endpoint (np, &endpoint) <0 ) +if (v4l2_fwnode_endpoint_parse (of_fwnode_handle (np), &endpoint) <0 ) goto done; pdata =devm_kzalloc (&client->dev,sizeof (*pdata),GFP_KERNEL );
drivers/media/i2c/ov2659.c +4 -4
@@ -42,9 +42,9 @@#include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-event.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -#include <media/v4l2-of.h> #include <media/v4l2-subdev.h> #define DRIVER_NAME "ov2659"
@@ -1346,7 +1346,7 @@ static struct ov2659_platform_data * ov2659_get_pdata(struct i2c_client *client) {struct ov2659_platform_data *pdata; -struct v4l2_of_endpoint *bus_cfg; +struct v4l2_fwnode_endpoint *bus_cfg;struct device_node *endpoint;if (!IS_ENABLED (CONFIG_OF ) || !client->dev.of_node)
@@ -1356,7 +1356,7 @@ ov2659_get_pdata(struct i2c_client *client)if (!endpoint)return NULL ; - bus_cfg =v4l2_of_alloc_parse_endpoint (endpoint); + bus_cfg =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (endpoint));if (IS_ERR (bus_cfg)) { pdata =NULL ; goto done;
@@ -1376,7 +1376,7 @@ ov2659_get_pdata(struct i2c_client *client) pdata->link_frequency = bus_cfg->link_frequencies[0 ]; done: -v4l2_of_free_endpoint (bus_cfg); +v4l2_fwnode_endpoint_free (bus_cfg);of_node_put (endpoint);return pdata; }
drivers/media/i2c/s5c73m3/s5c73m3-core.c +4 -3
@@ -24,6 +24,7 @@#include <linux/media.h> #include <linux/module.h> #include <linux/of_gpio.h> +#include <linux/of_graph.h> #include <linux/regulator/consumer.h> #include <linux/sizes.h> #include <linux/slab.h>
@@ -35,7 +36,7 @@#include <media/v4l2-subdev.h> #include <media/v4l2-mediabus.h> #include <media/i2c/s5c73m3.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include "s5c73m3.h"
@@ -1602,7 +1603,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)const struct s5c73m3_platform_data *pdata = dev->platform_data;struct device_node *node = dev->of_node;struct device_node *node_ep; -struct v4l2_of_endpoint ep; +struct v4l2_fwnode_endpoint ep;int ret;if (!node) {
@@ -1639,7 +1640,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)return 0 ; } - ret =v4l2_of_parse_endpoint (node_ep, &ep); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (node_ep), &ep);of_node_put (node_ep);if (ret)return ret;
drivers/media/i2c/s5k5baf.c +3 -3
@@ -30,7 +30,7 @@#include <media/v4l2-device.h> #include <media/v4l2-subdev.h> #include <media/v4l2-mediabus.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> static int debug;module_param (debug, int,0644 );
@@ -1841,7 +1841,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev) {struct device_node *node = dev->of_node;struct device_node *node_ep; -struct v4l2_of_endpoint ep; +struct v4l2_fwnode_endpoint ep;int ret;if (!node) {
@@ -1868,7 +1868,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)return -EINVAL ; } - ret =v4l2_of_parse_endpoint (node_ep, &ep); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (node_ep), &ep);of_node_put (node_ep);if (ret)return ret;
drivers/media/i2c/smiapp/Kconfig +1 -0
@@ -3,5 +3,6 @@ config VIDEO_SMIAPP depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAVE_CLK depends on MEDIA_CAMERA_SUPPORT select VIDEO_SMIAPP_PLL + select V4L2_FWNODE ---help--- This is a generic driver for SMIA++/SMIA camera modules.
drivers/media/i2c/smiapp/smiapp-core.c +15 -14
@@ -27,12 +27,13 @@#include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/smiapp.h> #include <linux/v4l2-mediabus.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-device.h> -#include <media/v4l2-of.h> #include "smiapp.h"
@@ -2784,19 +2785,20 @@ static int __maybe_unused smiapp_resume(struct device *dev)static struct smiapp_hwconfig *smiapp_get_hwconfig (struct device *dev) {struct smiapp_hwconfig *hwcfg; -struct v4l2_of_endpoint *bus_cfg; -struct device_node *ep; +struct v4l2_fwnode_endpoint *bus_cfg; +struct fwnode_handle *ep; +struct fwnode_handle *fwn =dev_fwnode (dev);int i;int rval; -if (!dev->of_node) +if (!fwn)return dev->platform_data; - ep =of_graph_get_next_endpoint (dev->of_node,NULL ); + ep =fwnode_graph_get_next_endpoint (fwn,NULL );if (!ep)return NULL ; - bus_cfg =v4l2_of_alloc_parse_endpoint (ep); + bus_cfg =v4l2_fwnode_endpoint_alloc_parse (ep);if (IS_ERR (bus_cfg)) goto out_err;
@@ -2817,11 +2819,10 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"lanes %u\n" , hwcfg->lanes);/* NVM size is not mandatory */ -of_property_read_u32 (dev->of_node,"nokia,nvm-size" , - &hwcfg->nvm_size); +fwnode_property_read_u32 (fwn,"nokia,nvm-size" , &hwcfg->nvm_size); - rval =of_property_read_u32 (dev->of_node,"clock-frequency" , - &hwcfg->ext_clk); + rval =fwnode_property_read_u32 (fwn,"clock-frequency" , + &hwcfg->ext_clk);if (rval) {dev_warn (dev,"can't get clock-frequency\n" ); goto out_err;
@@ -2846,13 +2847,13 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)dev_dbg (dev,"freq %d: %lld\n" , i, hwcfg->op_sys_clock[i]); } -v4l2_of_free_endpoint (bus_cfg); -of_node_put (ep); +v4l2_fwnode_endpoint_free (bus_cfg); +fwnode_handle_put (ep);return hwcfg; out_err: -v4l2_of_free_endpoint (bus_cfg); -of_node_put (ep); +v4l2_fwnode_endpoint_free (bus_cfg); +fwnode_handle_put (ep);return NULL ; }
drivers/media/i2c/tc358743.c +6 -5
@@ -33,6 +33,7 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> +#include <linux/of_graph.h> #include <linux/videodev2.h> #include <linux/workqueue.h> #include <linux/v4l2-dv-timings.h>
@@ -41,7 +42,7 @@#include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-event.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/i2c/tc358743.h> #include "tc358743_regs.h"
@@ -76,7 +77,7 @@ static const struct v4l2_dv_timings_cap tc358743_timings_cap = {struct tc358743_state {struct tc358743_platform_data pdata; -struct v4l2_of_bus_mipi_csi2 bus; +struct v4l2_fwnode_bus_mipi_csi2 bus;struct v4l2_subdev sd;struct media_pad pad;struct v4l2_ctrl_handler hdl;
@@ -1695,7 +1696,7 @@ static void tc358743_gpio_reset(struct tc358743_state *state)static int tc358743_probe_of (struct tc358743_state *state) {struct device *dev = &state->i2c_client->dev; -struct v4l2_of_endpoint *endpoint; +struct v4l2_fwnode_endpoint *endpoint;struct device_node *ep;struct clk *refclk;u32 bps_pr_lane;
@@ -1715,7 +1716,7 @@ static int tc358743_probe_of(struct tc358743_state *state)return -EINVAL ; } - endpoint =v4l2_of_alloc_parse_endpoint (ep); + endpoint =v4l2_fwnode_endpoint_alloc_parse (of_fwnode_handle (ep));if (IS_ERR (endpoint)) {dev_err (dev,"failed to parse endpoint\n" );return PTR_ERR (endpoint);
@@ -1803,7 +1804,7 @@ static int tc358743_probe_of(struct tc358743_state *state) disable_clk:clk_disable_unprepare (refclk); free_endpoint: -v4l2_of_free_endpoint (endpoint); +v4l2_fwnode_endpoint_free (endpoint); return ret; }#else
drivers/media/i2c/tvp514x.c +3 -3
@@ -38,7 +38,7 @@#include <media/v4l2-device.h> #include <media/v4l2-common.h> #include <media/v4l2-mediabus.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-ctrls.h> #include <media/i2c/tvp514x.h> #include <media/media-entity.h>
@@ -998,7 +998,7 @@ static struct tvp514x_platform_data * tvp514x_get_pdata(struct i2c_client *client) {struct tvp514x_platform_data *pdata =NULL ; -struct v4l2_of_endpoint bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg;struct device_node *endpoint;unsigned int flags;
@@ -1009,7 +1009,7 @@ tvp514x_get_pdata(struct i2c_client *client)if (!endpoint)return NULL ; -if (v4l2_of_parse_endpoint (endpoint, &bus_cfg)) +if (v4l2_fwnode_endpoint_parse (of_fwnode_handle (endpoint), &bus_cfg)) goto done; pdata =devm_kzalloc (&client->dev,sizeof (*pdata),GFP_KERNEL );
drivers/media/i2c/tvp5150.c +4 -3
@@ -12,10 +12,11 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/of_graph.h> #include <media/v4l2-async.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-mc.h> #include "tvp5150_reg.h"
@@ -1358,7 +1359,7 @@ static int tvp5150_init(struct i2c_client *c)static int tvp5150_parse_dt (struct tvp5150 *decoder,struct device_node *np) { -struct v4l2_of_endpoint bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg;struct device_node *ep;#ifdef CONFIG_MEDIA_CONTROLLER struct device_node *connectors, *child;
@@ -1373,7 +1374,7 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)if (!ep)return -EINVAL ; - ret =v4l2_of_parse_endpoint (ep, &bus_cfg); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (ep), &bus_cfg);if (ret) goto err;
drivers/media/i2c/tvp7002.c +3 -3
@@ -33,7 +33,7 @@#include <media/v4l2-device.h> #include <media/v4l2-common.h> #include <media/v4l2-ctrls.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include "tvp7002_reg.h"
@@ -889,7 +889,7 @@ static const struct v4l2_subdev_ops tvp7002_ops = {static struct tvp7002_config *tvp7002_get_pdata (struct i2c_client *client) { -struct v4l2_of_endpoint bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg;struct tvp7002_config *pdata =NULL ;struct device_node *endpoint;unsigned int flags;
@@ -901,7 +901,7 @@ tvp7002_get_pdata(struct i2c_client *client)if (!endpoint)return NULL ; -if (v4l2_of_parse_endpoint (endpoint, &bus_cfg)) +if (v4l2_fwnode_endpoint_parse (of_fwnode_handle (endpoint), &bus_cfg)) goto done; pdata =devm_kzalloc (&client->dev,sizeof (*pdata),GFP_KERNEL );
drivers/media/platform/Kconfig +3 -0
@@ -82,6 +82,7 @@ config VIDEO_OMAP3 select ARM_DMA_USE_IOMMU select VIDEOBUF2_DMA_CONTIG select MFD_SYSCON + select V4L2_FWNODE ---help--- Driver for an OMAP 3 camera controller.
@@ -97,6 +98,7 @@ config VIDEO_PXA27x depends on PXA27x || COMPILE_TEST select VIDEOBUF2_DMA_SG select SG_SPLIT + select V4L2_FWNODE ---help--- This is a v4l2 driver for the PXA27x Quick Capture Interface
@@ -127,6 +129,7 @@ config VIDEO_TI_CAL depends on SOC_DRA7XX || COMPILE_TEST depends on HAS_DMA select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE default n ---help--- Support for the TI CAL (Camera Adaptation Layer) block
drivers/media/platform/am437x/Kconfig +1 -0
@@ -3,6 +3,7 @@ config VIDEO_AM437X_VPFE depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAS_DMA depends on SOC_AM43XX || COMPILE_TEST select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE help Support for AM437x Video Processing Front End based Video Capture Driver.
drivers/media/platform/am437x/am437x-vpfe.c +5 -3
@@ -26,6 +26,7 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/of_graph.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h>
@@ -36,7 +37,7 @@#include <media/v4l2-common.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-event.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include "am437x-vpfe.h"
@@ -2419,7 +2420,7 @@ static struct vpfe_config * vpfe_get_pdata(struct platform_device *pdev) {struct device_node *endpoint =NULL ; -struct v4l2_of_endpoint bus_cfg; +struct v4l2_fwnode_endpoint bus_cfg;struct vpfe_subdev_info *sdinfo;struct vpfe_config *pdata;unsigned int flags;
@@ -2463,7 +2464,8 @@ vpfe_get_pdata(struct platform_device *pdev) sdinfo->vpfe_param.if_type =VPFE_RAW_BAYER ; } - err =v4l2_of_parse_endpoint (endpoint, &bus_cfg); + err =v4l2_fwnode_endpoint_parse (of_fwnode_handle (endpoint), + &bus_cfg);if (err) {dev_err (&pdev->dev,"Could not parse the endpoint\n" ); goto done;
drivers/media/platform/atmel/Kconfig +1 -0
@@ -4,6 +4,7 @@ config VIDEO_ATMEL_ISC depends on ARCH_AT91 || COMPILE_TEST select VIDEOBUF2_DMA_CONTIG select REGMAP_MMIO + select V4L2_FWNODE help This module makes the ATMEL Image Sensor Controller available as a v4l2 device.
drivers/media/platform/atmel/atmel-isc.c +5 -3
@@ -32,6 +32,7 @@#include <linux/math64.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h>
@@ -42,7 +43,7 @@#include <media/v4l2-event.h> #include <media/v4l2-image-sizes.h> #include <media/v4l2-ioctl.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> #include <media/videobuf2-dma-contig.h>
@@ -1683,7 +1684,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) {struct device_node *np = dev->of_node;struct device_node *epn =NULL , *rem; -struct v4l2_of_endpoint v4l2_epn; +struct v4l2_fwnode_endpoint v4l2_epn;struct isc_subdev_entity *subdev_entity;unsigned int flags;int ret;
@@ -1702,7 +1703,8 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)continue ; } - ret =v4l2_of_parse_endpoint (epn, &v4l2_epn); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (epn), + &v4l2_epn);if (ret) {of_node_put (rem); ret = -EINVAL ;
drivers/media/platform/exynos4-is/Kconfig +2 -0
@@ -4,6 +4,7 @@ config VIDEO_SAMSUNG_EXYNOS4_IS depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST depends on OF && COMMON_CLK + select V4L2_FWNODE help Say Y here to enable camera host interface devices for Samsung S5P and EXYNOS SoC series.
@@ -32,6 +33,7 @@ config VIDEO_S5P_MIPI_CSIS tristate "S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver" depends on REGULATOR select GENERIC_PHY + select V4L2_FWNODE help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 receiver (MIPI-CSIS) devices.
drivers/media/platform/exynos4-is/media-dev.c +3 -3
@@ -29,7 +29,7 @@#include <linux/slab.h> #include <media/v4l2-async.h> #include <media/v4l2-ctrls.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/media-device.h> #include <media/drv-intf/exynos-fimc.h>
@@ -388,7 +388,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, {struct fimc_source_info *pd = &fmd->sensor[index].pdata;struct device_node *rem, *ep, *np; -struct v4l2_of_endpoint endpoint; +struct v4l2_fwnode_endpoint endpoint;int ret;/* Assume here a port node can have only one endpoint node. */
@@ -396,7 +396,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,if (!ep)return 0 ; - ret =v4l2_of_parse_endpoint (ep, &endpoint); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (ep), &endpoint);if (ret) {of_node_put (ep);return ret;
drivers/media/platform/exynos4-is/mipi-csis.c +3 -3
@@ -30,7 +30,7 @@#include <linux/spinlock.h> #include <linux/videodev2.h> #include <media/drv-intf/exynos-fimc.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> #include "mipi-csis.h"
@@ -718,7 +718,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev, struct csis_state *state) {struct device_node *node = pdev->dev.of_node; -struct v4l2_of_endpoint endpoint; +struct v4l2_fwnode_endpoint endpoint;int ret; if (of_property_read_u32(node, "clock-frequency",
@@ -735,7 +735,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,return -EINVAL ; }/* Get port node and validate MIPI-CSI channel id. */ - ret =v4l2_of_parse_endpoint (node, &endpoint); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (node), &endpoint);if (ret) goto err;
drivers/media/platform/omap3isp/isp.c +36 -35
180 lines not on this page · raw message
drivers/media/platform/pxa_camera.c +4 -3
@@ -25,6 +25,7 @@#include <linux/mm.h> #include <linux/moduleparam.h> #include <linux/of.h> +#include <linux/of_graph.h> #include <linux/time.h> #include <linux/platform_device.h> #include <linux/clk.h>
@@ -39,7 +40,7 @@#include <media/v4l2-common.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/videobuf2-dma-sg.h>
@@ -2236,7 +2237,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev, {u32 mclk_rate;struct device_node *remote, *np = dev->of_node; -struct v4l2_of_endpoint ep; +struct v4l2_fwnode_endpoint ep;int err =of_property_read_u32 (np,"clock-frequency" , &mclk_rate);if (!err) {
@@ -2250,7 +2251,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,return -EINVAL ; } - err =v4l2_of_parse_endpoint (np, &ep); + err =v4l2_fwnode_endpoint_parse (of_fwnode_handle (np), &ep);if (err) {dev_err (dev,"could not parse endpoint\n" ); goto out;
drivers/media/platform/rcar-vin/Kconfig +1 -0
@@ -3,6 +3,7 @@ config VIDEO_RCAR_VIN depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && OF && HAS_DMA && MEDIA_CONTROLLER depends on ARCH_RENESAS || COMPILE_TEST select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE ---help--- Support for Renesas R-Car Video Input (VIN) driver. Supports R-Car Gen2 SoCs.
drivers/media/platform/rcar-vin/rcar-core.c +3 -3
@@ -21,7 +21,7 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include "rcar-vin.h"
@@ -118,10 +118,10 @@ static int rvin_digitial_parse_v4l2(struct rvin_dev *vin,struct device_node *ep, struct v4l2_mbus_config *mbus_cfg) { - struct v4l2_of_endpoint v4l2_ep; + struct v4l2_fwnode_endpoint v4l2_ep;int ret; - ret =v4l2_of_parse_endpoint (ep, &v4l2_ep); + ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (ep), &v4l2_ep);if (ret) {vin_err (vin,"Could not parse v4l2 endpoint\n" );return -EINVAL ;
drivers/media/platform/soc_camera/Kconfig +1 -0
@@ -32,6 +32,7 @@ config VIDEO_ATMEL_ISI depends on ARCH_AT91 || COMPILE_TEST depends on HAS_DMA select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE ---help--- This module makes the ATMEL Image Sensor Interface available as a v4l2 device.
drivers/media/platform/soc_camera/atmel-isi.c +4 -3
@@ -19,13 +19,14 @@#include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/slab.h> #include <media/soc_camera.h> #include <media/drv-intf/soc_mediabus.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/videobuf2-dma-contig.h> #include "atmel-isi.h"
@@ -974,7 +975,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi, struct platform_device *pdev) {struct device_node *np= pdev->dev.of_node; -struct v4l2_of_endpoint ep; +struct v4l2_fwnode_endpoint ep;int err;/* Default settings for ISI */
@@ -987,7 +988,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,return -EINVAL ; } - err =v4l2_of_parse_endpoint (np, &ep); + err =v4l2_fwnode_endpoint_parse (of_fwnode_handle (np), &ep);of_node_put (np);if (err) {dev_err (&pdev->dev,"Could not parse the endpoint\n" );
drivers/media/platform/soc_camera/soc_camera.c +2 -1
@@ -23,6 +23,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h>
@@ -36,7 +37,7 @@#include <media/v4l2-common.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-dev.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/videobuf2-v4l2.h> /* Default to VGA resolution */
drivers/media/platform/ti-vpe/cal.c +6 -5
@@ -21,7 +21,7 @@#include <linux/of_device.h> #include <linux/of_graph.h> -#include <media/v4l2-of.h> +#include <media/v4l2-fwnode.h> #include <media/v4l2-async.h> #include <media/v4l2-common.h> #include <media/v4l2-ctrls.h>
@@ -270,7 +270,7 @@ struct cal_ctx {struct video_device vdev;struct v4l2_async_notifier notifier;struct v4l2_subdev *sensor; -struct v4l2_of_endpoint endpoint; +struct v4l2_fwnode_endpoint endpoint;struct v4l2_async_subdev asd;struct v4l2_async_subdev *asd_list[1 ];
@@ -608,7 +608,8 @@ static void csi2_lane_config(struct cal_ctx *ctx)u32 val =reg_read (ctx->dev,CAL_CSI2_COMPLEXIO_CFG (ctx->csi2_port));u32 lane_mask =CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK ;u32 polarity_mask =CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK ; -struct v4l2_of_bus_mipi_csi2 *mipi_csi2 = &ctx->endpoint.bus.mipi_csi2; +struct v4l2_fwnode_bus_mipi_csi2 *mipi_csi2 = + &ctx->endpoint.bus.mipi_csi2;int lane;set_field (&val, mipi_csi2->clock_lane +1 , lane_mask);
@@ -1643,7 +1644,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)struct platform_device *pdev = ctx->dev->pdev;struct device_node *ep_node, *port, *remote_ep, *sensor_node, *parent; -struct v4l2_of_endpoint *endpoint; +struct v4l2_fwnode_endpoint *endpoint;struct v4l2_async_subdev *asd;u32 regval =0 ;int ret, index, found_port =0 , lane;
@@ -1706,7 +1707,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)ctx_dbg (3 , ctx,"can't get remote-endpoint\n" ); goto cleanup_exit; } -v4l2_of_parse_endpoint (remote_ep, endpoint); +v4l2_fwnode_endpoint_parse (of_fwnode_handle (remote_ep), endpoint);if (endpoint->bus_type !=V4L2_MBUS_CSI2 ) { ctx_err(ctx, "Port:%d sub-device %s is not a CSI2 device\n",
drivers/media/platform/xilinx/Kconfig +1 -0
@@ -2,6 +2,7 @@ config VIDEO_XILINX tristate "Xilinx Video IP (EXPERIMENTAL)" depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && OF && HAS_DMA select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE ---help--- Driver for Xilinx Video IP Pipelines
drivers/media/platform/xilinx/xilinx-vipp.c +33 -26
150 lines not on this page · raw message
include/media/v4l2-fwnode.h +2 -2
@@ -17,10 +17,10 @@#ifndef _V4L2_FWNODE_H#define _V4L2_FWNODE_H +#include <linux/errno.h> +#include <linux/fwnode.h> #include <linux/list.h> #include <linux/types.h> -#include <linux/errno.h> -#include <linux/of_graph.h> #include <media/v4l2-mediabus.h>
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sakari Ailus
maintainerPATCH v2 6/8 v4l: media/drv-intf/soc_mediabus.h: include dependent header file
In reply to Sakari Ailusmedia/drv-intf/soc_mediabus.h does depend on struct v4l2_mbus_config which is defined in media/v4l2-mediabus.h. Include it.
--- include/media/drv-intf/soc_mediabus.h | 2 ++ 1 file changed, 2 insertions(+)
include/media/drv-intf/soc_mediabus.h +2 -0
@@ -14,6 +14,8 @@#include <linux/videodev2.h> #include <linux/v4l2-mediabus.h> +#include <media/v4l2-mediabus.h> +/** * enum soc_mbus_packing - data packing types on the media-bus * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
Signature · 1 line
2.7.4
Sakari Ailus
maintainerPATCH v2 7/8 docs-rst: media: Switch documentation to V4L2 fwnode API
In reply to Sakari AilusInstead of including the V4L2 OF header in ReST documentation, use the V4L2 fwnode header instead.
--- Documentation/media/kapi/v4l2-core.rst | 2 +- Documentation/media/kapi/v4l2-fwnode.rst | 3 +++ Documentation/media/kapi/v4l2-of.rst | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Documentation/media/kapi/v4l2-fwnode.rst delete mode 100644 Documentation/media/kapi/v4l2-of.rst
Documentation/media/kapi/v4l2-core.rst +1 -1
@@ -19,7 +19,7 @@ Video2Linux devices v4l2-mc v4l2-mediabus v4l2-mem2mem - v4l2-of + v4l2-fwnode v4l2-rect v4l2-tuner v4l2-common
Documentation/media/kapi/v4l2-fwnode.rst new file +3 -0
@@ -0,0 +1,3 @@ +V4L2 fwnode kAPI +^^^^^^^^^^^^^^^^ +.. kernel-doc:: include/media/v4l2-fwnode.h
Documentation/media/kapi/v4l2-of.rst deleted +0 -3
@@ -1,3 +0,0 @@ -V4L2 Open Firmware kAPI -^^^^^^^^^^^^^^^^^^^^^^^ -.. kernel-doc:: include/media/v4l2-of.h
Signature · 1 line
2.7.4
Sakari Ailus
maintainerPATCH v2 8/8 v4l: Remove V4L2 OF framework in favour of V4L2 fwnode framework
In reply to Sakari AilusAll drivers have been converted from V4L2 OF to V4L2 fwnode. The V4L2 OF framework is now unused. Remove it.
--- drivers/media/v4l2-core/Makefile | 3 - drivers/media/v4l2-core/v4l2-of.c | 327 -------------------------------------- include/media/v4l2-of.h | 128 --------------- 3 files changed, 458 deletions(-) delete mode 100644 drivers/media/v4l2-core/v4l2-of.c delete mode 100644 include/media/v4l2-of.h
drivers/media/v4l2-core/Makefile +0 -3
@@ -10,9 +10,6 @@ videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \ ifeq ($(CONFIG_COMPAT),y) videodev-objs += v4l2-compat-ioctl32.o endif -ifeq ($(CONFIG_OF),y) - videodev-objs += v4l2-of.o -endif obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o
drivers/media/v4l2-core/v4l2-of.c deleted +0 -327
327 lines not on this page · raw message
include/media/v4l2-of.h deleted +0 -128
128 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v2 1/8] v4l: flash led class: Use fwnode_handle instead of device_node in init
In reply to a message not in the archiveHi Sakari,
Thank you for the patch.
Quoted 32 lines · On Thursday 06 Apr 2017 16:12:03 Sakari Ailus wrote:
Pass the more generic
fwnode_handleto the init function than thedevice_node.Signed-off-by Sakari Ailus <[email protected]>--- drivers/leds/leds-aat1290.c | 5 +++-- drivers/leds/leds-max77693.c | 5 +++-- drivers/media/v4l2-core/v4l2-flash-led-class.c | 11 ++++++----- include/media/v4l2-flash-led-class.h | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-)drivers/leds/leds-aat1290.c +3
-2@@ -503,8 +503,9 @@ static int aat1290_led_probe(struct platform_device *pdev) aat1290_init_v4l2_flash_config(led, &led_cfg, &v4l2_sd_cfg);/* Create V4L2 Flash subdev. */ - led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + led->v4l2_flash =v4l2_flash_init (dev,of_fwnode_handle (sub_node), + fled_cdev,NULL , &v4l2_flash_ops, + &v4l2_sd_cfg);if (IS_ERR (led->v4l2_flash)) { ret =PTR_ERR (led->v4l2_flash); goto error_v4l2_flash_init;drivers/leds/leds-max77693.c +0
-0
drivers/leds/leds-max77693.c static int max77693_register_led(struct max77693_sub_led · line 934
Quoted 7 lines
drivers/leds/leds-max77693.c +2
-2@@ -930,8 +930,9 @@ static int max77693_register_led(struct max77693_sub_led *sub_led,max77693_init_v4l2_flash_config (sub_led, led_cfg, &v4l2_sd_cfg);/* Register in the V4L2 subsystem. */ - sub_led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + sub_led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node), + fled_cdev, NULL,
&v4l2_flash_ops,
drivers/media/v4l2-core/v4l2-flash-led-class.c line 15
Quoted 13 lines
drivers/leds/leds-max77693.c +1
-0+ &v4l2_sd_cfg);if (IS_ERR (sub_led->v4l2_flash)) { ret =PTR_ERR (sub_led->v4l2_flash); goto err_v4l2_flash_init;(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-flash-led-class.cindex 794e563..f430c89 100644drivers/media/v4l2-core/v4l2-flash-led-class.c +0
-0@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h>
I think you can drop linux/of.h.
Quoted 15 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c +1
-0+#include <linux/property.h> #include <linux/slab.h> #include <linux/types.h> #include <media/v4l2-flash-led-class.h> @@ -612,7 +613,7 @@ static const struct v4l2_subdev_internal_ops
v4l2_flash_subdev_internal_ops= { static const structv4l2_subdev_opsv4l2_flash_subdev_ops;struct
v4l2_flash*v4l2_flash_init(drivers/media/v4l2-core/v4l2-flash-led-class.c +1
-1- struct device *dev, struct device_node *of_node, + struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, struct led_classdev_flash *iled_cdev, const struct v4l2_flash_ops *ops,
drivers/media/v4l2-core/v4l2-flash-led-class.c struct v4l2_flash *v4l2_flash_init( · line 642
Quoted 5 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c +1
-1@@ -638,7 +639,7 @@ struct v4l2_flash *v4l2_flash_init( v4l2_flash->iled_cdev = iled_cdev; v4l2_flash->ops = ops; sd->dev = dev; - sd->of_node = of_node ? of_node : led_cdev->dev->of_node; + sd->fwnode = fwn ? fwn :dev_fwnode (led_cdev->dev);
v4l2_subdev will only have a fwnode field in patch 3/8.
Quoted 35 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c +3
-3v4l2_subdev_init (sd, &v4l2_flash_subdev_ops); sd->internal_ops = &v4l2_flash_subdev_internal_ops; sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;@@ -654,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init(if (ret <0 ) goto err_init_controls; -of_node_get (sd->of_node); +fwnode_handle_get (sd->fwnode); ret =v4l2_async_register_subdev (sd);if (ret <0 )@@ -663,7 +664,7 @@ struct v4l2_flash *v4l2_flash_init(return v4l2_flash; err_async_register_sd: -of_node_put (sd->of_node); +fwnode_handle_put (sd->fwnode);v4l2_ctrl_handler_free (sd->ctrl_handler); err_init_controls:media_entity_cleanup (&sd->entity);@@ -683,7 +684,7 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash)v4l2_async_unregister_subdev (sd); -of_node_put (sd->of_node); +fwnode_handle_put (sd->fwnode);v4l2_ctrl_handler_free (sd->ctrl_handler);media_entity_cleanup (&sd->entity);(quoted diff) +0
-0
b/include/media/v4l2-flash-led-class.hindex b0fe4d6..5695853 100644
include/media/v4l2-flash-led-class.h static inline struct v4l2_flash · line 113
Quoted 7 lines
include/media/v4l2-flash-led-class.h +1
-1@@ -108,7 +108,7 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) /*** v4l2_flash_init - initialize V4L2 flash led sub-device * @dev: flash device, e.g. an I2C device -* @of_node: of_node of the LED, may be NULL if the same as device's +* @fwn: fwnode_handle of the LED, may be NULL if the same as device's * @fled_cdev: LED flash class device to wrap * @iled_cdev: LED flash class device representing indicator LED
associated
Quoted 11 lines
include/media/v4l2-flash-led-class.h +0
-0* with fled_cdev, may be NULL @@ -122,7 +122,7 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) * PTR_ERR() to obtain thenumeric return value.
*/
structv4l2_flash*v4l2_flash_init(include/media/v4l2-flash-led-class.h +1
-1- struct device *dev, struct device_node *of_node, + struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, struct led_classdev_flash *iled_cdev, const struct v4l2_flash_ops *ops,
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
maintainerRe: [PATCH v2 2/8] v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:04 Sakari Ailus wrote:
The
fwnode_handleis a more generic way than OFdevice_nodeto describe firmware nodes. Instead of the OF API, use more generic fwnode API to obtain the same information.
I would mention that this is a copy of v4l2-of.c with the OF API replaced with the fwnode API.
Quoted 65 lines
As the V4L2 fwnode support will be required by a small minority of e.g. ACPI based systems (the same might actually go for OF), make this a module instead of embedding it in the videodev module.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fwnode.c | 353 +++++++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 104 ++++++++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c create mode 100644 include/media/v4l2-fwnode.h(quoted diff) +0
-0b/drivers/media/v4l2-core/Kconfig index 6b1b78f..a35c336 100644
drivers/media/v4l2-core/Kconfig +3
-0@@ -55,6 +55,9 @@ config V4L2_FLASH_LED_CLASS When in doubt, say N. +config V4L2_FWNODE + tristate + # Used by drivers that need Videobuf modules config VIDEOBUF_GEN tristate(quoted diff) +0
-0b/drivers/media/v4l2-core/Makefile index 795a535..cf77a63 100644
drivers/media/v4l2-core/Makefile +1
-0@@ -13,6 +13,7 @@ endif ifeq ($(CONFIG_OF),y) videodev-objs += v4l2-of.o endif +obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o endif(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-fwnode.cnew file mode 100644 index 0000000..4f69b11drivers/media/v4l2-core/v4l2-fwnode.c new file +19
-0@@ -0,0 +1,353 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#include <linux/acpi.h> +#include <linux/kernel.h> +#include <linux/module.h>
drivers/media/v4l2-core/v4l2-fwnode.c line 29
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+#include <linux/of.h> +#include <linux/property.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/types.h> + +#include <media/v4l2-fwnode.h> + +static int v4l2_fwnode_endpoint_parse_csi_bus (struct fwnode_handle *fwn, + struct v4l2_fwnode_endpoint
*vfwn)
drivers/media/v4l2-core/v4l2-fwnode.c line 36
Quoted 7 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +7
-0+{ +struct v4l2_fwnode_bus_mipi_csi2 *bus = &vfwn->bus.mipi_csi2; +bool have_clk_lane = false; +unsigned int flags =0 , lanes_used =0 ; +unsigned int i; +u32 v; +int rval;
I would have used "ret" instead of "rval" ;-)
drivers/media/v4l2-core/v4l2-fwnode.c line 46
Quoted 9 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +9
-0+ rval =fwnode_property_read_u32_array (fwn,"data-lanes" ,NULL ,0 ); +if (rval >0 ) { +u32 array[ARRAY_SIZE (bus->data_lanes)]; + + bus->num_data_lanes = +min_t (int,ARRAY_SIZE (bus->data_lanes), rval); + +fwnode_property_read_u32_array ( + fwn,"data-lanes" , array, bus->num_data_lanes);
Is there anything wrong with the usual way to wrap code ?
fwnode_property_read_u32_array(fwn, "data-lanes", array, bus->num_data_lanes);
drivers/media/v4l2-core/v4l2-fwnode.c
Quoted 12 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +12
-0+ +for (i =0 ; i < bus->num_data_lanes; i++) { +if (lanes_used &BIT (array[i])) +pr_warn ("duplicated lane %u in data-lanes\n" , + array[i]); + lanes_used |=BIT (array[i]); + + bus->data_lanes[i] = array[i]; + } + } + + rval = fwnode_property_read_u32_array(fwn, "lane-polarities", NULL,
0);
drivers/media/v4l2-core/v4l2-fwnode.c
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+if (rval >0 ) { +u32 array[ARRAY_SIZE (bus->lane_polarities)]; + +if (rval <1 + bus->num_data_lanes/* clock + data */ ) { + pr_warn("too few lane-polarities entries (need %u, got
%u)\n",
Quoted 7 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+ 1 + bus->num_data_lanes, rval); +return -EINVAL ; + } + + fwnode_property_read_u32_array( + fwn, "lane-polarities", array, 1 + bus-
num_data_lanes);
Ditto with
fwnode_property_read_u32_array(fwn, "lane-polarities", array, 1 + bus->num_data_lanes);
Quoted 67 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +67
-0+for (i =0 ; i <1 + bus->num_data_lanes; i++) + bus->lane_polarities[i] = array[i]; + } + +if (!fwnode_property_read_u32 (fwn,"clock-lanes" , &v)) { +if (lanes_used &BIT (v)) +pr_warn ("duplicated lane %u in clock-lanes\n" , v); + lanes_used |=BIT (v); + + bus->clock_lane = v; + have_clk_lane = true; + } + +if (fwnode_property_present (fwn,"clock-noncontinuous" )) + flags |=V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ; +else if (have_clk_lane || bus->num_data_lanes >0 ) + flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + + bus->flags = flags; + vfwn->bus_type =V4L2_MBUS_CSI2 ; + +return 0 ; +} + +static void v4l2_fwnode_endpoint_parse_parallel_bus ( +struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint *vfwn) +{ +struct v4l2_fwnode_bus_parallel *bus = &vfwn->bus.parallel; +unsigned int flags =0 ; +u32 v; + +if (!fwnode_property_read_u32 (fwn,"hsync-active" , &v)) + flags |= v ?V4L2_MBUS_HSYNC_ACTIVE_HIGH : +V4L2_MBUS_HSYNC_ACTIVE_LOW ; + +if (!fwnode_property_read_u32 (fwn,"vsync-active" , &v)) + flags |= v ?V4L2_MBUS_VSYNC_ACTIVE_HIGH : +V4L2_MBUS_VSYNC_ACTIVE_LOW ; + +if (!fwnode_property_read_u32 (fwn,"field-even-active" , &v)) + flags |= v ?V4L2_MBUS_FIELD_EVEN_HIGH : +V4L2_MBUS_FIELD_EVEN_LOW ; +if (flags) + vfwn->bus_type =V4L2_MBUS_PARALLEL ; +else + vfwn->bus_type =V4L2_MBUS_BT656 ; + +if (!fwnode_property_read_u32 (fwn,"pclk-sample" , &v)) + flags |= v ?V4L2_MBUS_PCLK_SAMPLE_RISING : +V4L2_MBUS_PCLK_SAMPLE_FALLING ; + +if (!fwnode_property_read_u32 (fwn,"data-active" , &v)) + flags |= v ?V4L2_MBUS_DATA_ACTIVE_HIGH : +V4L2_MBUS_DATA_ACTIVE_LOW ; + +if (fwnode_property_present (fwn,"slave-mode" )) + flags |=V4L2_MBUS_SLAVE ; +else + flags |=V4L2_MBUS_MASTER ; + +if (!fwnode_property_read_u32 (fwn,"bus-width" , &v)) + bus->bus_width = v; + +if (!fwnode_property_read_u32 (fwn,"data-shift" , &v)) + bus->data_shift = v; + +if (!fwnode_property_read_u32 (fwn,"sync-on-green-active" , &v))
drivers/media/v4l2-core/v4l2-fwnode.c line 147
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ flags |= v ?V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH : +V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW ; + + bus->flags = flags; + +} + +/** +* v4l2_fwnode_endpoint_parse() - parse all fwnode node properties +* @fwn: pointer to fwnode_handle
I would say "the endpoint's fwnode handle", or "pointer to the endpoint's fwnode handle". Otherwise which fwnode handle should be passed won't be clear.
Quoted 11 lines
+ * @vfwn: pointer to the V4L2 fwnode data structure
+ *
+ * All properties are optional. If none are found, we don't set any flags.
+ * This means the port has a static configuration and no properties have
+ * to be specified explicitly.
+ * If any properties that identify the bus as parallel are found and
+ * slave-mode isn't set, we setV4L2_MBUS_MASTER. Similarly, if we recognise
+ * the bus as serial CSI-2 and clock-noncontinuous isn't set, we set the
+ *V4L2_MBUS_CSI2_CONTINUOUS_CLOCKflag.
+ * The caller should hold a reference to @node.
s/@node/@fwn/
By the way, have you tried to compile the documentation ?
drivers/media/v4l2-core/v4l2-fwnode.c line 166
Quoted 9 lines
+ *
+ * NOTE: This function does not parse properties the size of which is
+ * variable without a low fixed limit. Please use
+ *v4l2_fwnode_endpoint_alloc_parse()in new drivers instead.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */drivers/media/v4l2-core/v4l2-fwnode.c new file +2
-0+int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwn, +struct v4l2_fwnode_endpoint *vfwn)
Is there a specific reason not to keep the original parameter name "endpoint" ? vfwn seems to stand for v4l2_fwnode, not v4l2_fwnode_endpoint. Same comment for all other locations in this patch.
Quoted 12 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +12
-0+{ +int rval; + +fwnode_graph_parse_endpoint (fwn, &vfwn->base); + +/* Zero fields from bus_type to until the end */ +memset (&vfwn->bus_type,0 ,sizeof (*vfwn) - + offsetof(typeof(*vfwn), bus_type)); + + rval =v4l2_fwnode_endpoint_parse_csi_bus (fwn, vfwn); +if (rval) +return rval;
drivers/media/v4l2-core/v4l2-fwnode.c line 188
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+/* +* Parse the parallel video bus properties only if none +* of the MIPI CSI-2 specific properties were found. +*/ +if (vfwn->bus.mipi_csi2.flags ==0 ) +v4l2_fwnode_endpoint_parse_parallel_bus (fwn, vfwn); + +return 0 ; +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_parse);
According to Mauro in http://www.mail-archive.com/[email protected]/msg110809.html you should use EXPORT_SYMBOL_GPL.
drivers/media/v4l2-core/v4l2-fwnode.c line 193
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+ +/* +* v4l2_fwnode_endpoint_free() - free the V4L2 fwnode acquired by +* v4l2_fwnode_endpoint_alloc_parse() +* @fwn - the V4L2 fwnode the resources of which are to be released
Mayeb "the V4L2 fwnode whose resources are to be released" ?
Quoted 2 lines
+ *
+ * It is safe to call this function with NULL argument or on an
s/on an/on a/
Quoted 1 line
+ * V4L2 fwnode the parsing of which failed.
"whose parsing failed" ?
Quoted 4 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +3
-0+void v4l2_fwnode_endpoint_free (struct v4l2_fwnode_endpoint *vfwn) +{ +if (IS_ERR_OR_NULL (vfwn))
drivers/media/v4l2-core/v4l2-fwnode.c line 210
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+return ; + +kfree (vfwn->link_frequencies); +kfree (vfwn); +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_free); + +/** +* v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties +* @node: pointer to fwnode_handle
s/@node/@fwn/
Here too, I would say "the endpoint's fwnode handle", or "pointer to the endpoint's fwnode handle".
Quoted 10 lines
+ *
+ * All properties are optional. If none are found, we don't set any flags.
+ * This means the port has a static configuration and no properties have
+ * to be specified explicitly.
+ * If any properties that identify the bus as parallel are found and
+ * slave-mode isn't set, we setV4L2_MBUS_MASTER. Similarly, if we recognise
+ * the bus as serial CSI-2 and clock-noncontinuous isn't set, we set the
+ *V4L2_MBUS_CSI2_CONTINUOUS_CLOCKflag.
+ * The caller should hold a reference to @node.
s/@node/@fwn/
Quoted 5 lines
+ *
+ *v4l2_fwnode_endpoint_alloc_parse()has two important differences to
+ *v4l2_fwnode_endpoint_parse():
+ *
+ * 1. It also parses variable size data and
Nitpicking, a valid sentence doesn't end with "and$". You could write
1. It also parses variable size data.
2. The memory it has allocated to store the variable size data must be freed using v4l2_fwnode_endpoint_free() when no longer needed.
or
1. it also parses variable size data; and
2. the memory it has allocated to store the variable size data must be freed using v4l2_fwnode_endpoint_free() when no longer needed.
Quoted 6 lines
+ *
+ * 2. The memory it has allocated to store the variable size data must
+ * be freed usingv4l2_fwnode_endpoint_free()when no longer needed.
+ *
+ * Return: Pointer tov4l2_fwnode_endpointif successful, on error a
+ * negative error code.
The function returns an error pointer on error.
drivers/media/v4l2-core/v4l2-fwnode.c line 236
Quoted 6 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse ( +struct fwnode_handle *fwn) +{ +struct v4l2_fwnode_endpoint *vfwn; +int rval;
ret ? :-)
drivers/media/v4l2-core/v4l2-fwnode.c line 248
Quoted 12 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +12
-0+ + vfwn =kzalloc (sizeof (*vfwn),GFP_KERNEL ); +if (!vfwn) +return ERR_PTR (-ENOMEM ); + + rval =v4l2_fwnode_endpoint_parse (fwn, vfwn); +if (rval <0 ) + goto out_err; + + rval =fwnode_property_read_u64_array (fwn,"link-frequencies" , +NULL ,0 ); +
No need for a blank line.
Quoted 6 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+if (rval <0 ) + goto out_err; + + vfwn->link_frequencies = +kmalloc_array (rval,sizeof (*vfwn->link_frequencies), +GFP_KERNEL );
drivers/media/v4l2-core/v4l2-fwnode.c line 264
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+if (!vfwn->link_frequencies) { + rval = -ENOMEM ; + goto out_err; + } + + vfwn->nr_of_link_frequencies = rval; + + rval =fwnode_property_read_u64_array ( + fwn,"link-frequencies" , vfwn->link_frequencies, + vfwn->nr_of_link_frequencies);
rval = fwnode_property_read_u64_array(fwn, "link-frequencies", vfwn->link_frequencies, vfwn->nr_of_link_frequencies);
Quoted 4 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +4
-0+if (rval <0 ) + goto out_err; + +return vfwn;
drivers/media/v4l2-core/v4l2-fwnode.c line 278
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ +out_err: +v4l2_fwnode_endpoint_free (vfwn); +return ERR_PTR (rval); +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_alloc_parse); + +/** +* v4l2_fwnode_endpoint_parse_link() - parse a link between two endpoints +* @node: pointer to the fwnode at the local end of the link
The parameter is called __fwn. I believe you should rename it to fwn, otherwise the documentation will look weird.
As explained before, you should mention that this is an endpoint fwnode handle.
Quoted 4 lines
+ * @link: pointer to the V4L2 fwnode link data structure
+ *
+ * Fill the link structure with the local and remote nodes and port numbers.
Quoted 8 lines
+ * The
local_nodeandremote_nodefields are set to point to the local and
+ * remote port's parent nodes respectively (the port parent node being the
+ * parent node of the port node if that node isn't a 'ports' node, or the
+ * grand-parent node of the port node otherwise).
+ *
+ * A reference is taken to both the local and remote nodes, the caller
+ * must usev4l2_fwnode_endpoint_put_link()to drop the references
+ * when done with the link.
Just curious, is there a reason to wrap earlier than the 80 columns limit ?
* A reference is taken to both the local and remote nodes, the caller must
use
* v4l2_fwnode_endpoint_put_link() to drop the references when done with the
* link.
would work.
Quoted 1 line
+ * Return: 0 on success, or
-ENOLINKif the remote fwnode can't be found.
Here too you should mention remote endpoint.
Quoted 9 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +8
-0+int v4l2_fwnode_parse_link (struct fwnode_handle *__fwn, +struct v4l2_fwnode_link *link) +{ +struct fwnode_handle *fwn; +const char *port_prop =is_of_node (__fwn) ?"reg" :"port" ; + +memset (link,0 ,sizeof (*link)); +
drivers/media/v4l2-core/v4l2-fwnode.c line 310
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ fwn =fwnode_get_parent (__fwn); +fwnode_property_read_u32 (fwn, port_prop, &link->local_port); + fwn =fwnode_get_next_parent (fwn); +if (is_of_node (fwn)) { +if (of_node_cmp (to_of_node (fwn)->name,"ports" ) ==0 ) + fwn =fwnode_get_next_parent (fwn); + }else { +/* The "ports" node is always there in ACPI. */ + fwn =fwnode_get_next_parent (fwn); + }
To avoid duplicating the fwnode_get_next_parent(fwn) call, you could write
if (!is_of_node(fwn) ||
of_node_cmp(to_of_node(fwn)->name, "ports") == 0) {
/* The "ports" node is always there in ACPI. */
fwn = fwnode_get_next_parent(fwn);
}Quoted 8 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +8
-0+ link->local_node = fwn; + + fwn =fwnode_graph_get_remote_endpoint (fwn); +if (!fwn) { +fwnode_handle_put (fwn); +return -ENOLINK ; + } +
drivers/media/v4l2-core/v4l2-fwnode.c line 328
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ fwn =fwnode_get_parent (fwn); +fwnode_property_read_u32 (fwn, port_prop, &link->remote_port); + fwn =fwnode_get_next_parent (fwn); +if (is_of_node (fwn)) { +if (of_node_cmp (to_of_node (fwn)->name,"ports" ) ==0 ) + fwn =fwnode_get_next_parent (fwn); + }else { +/* The "ports" node is always there in ACPI. */ + fwn =fwnode_get_next_parent (fwn); + }
Same comment here.
Quoted 44 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +25
-0+ link->remote_node = fwn; + +return 0 ; +} +EXPORT_SYMBOL (v4l2_fwnode_parse_link); + +/** +* v4l2_fwnode_put_link() - drop references to nodes in a link +* @link: pointer to the V4L2 fwnode link data structure +* +* Drop references to the local and remote nodes in the link. This +* function must be called on every link parsed with +* v4l2_fwnode_parse_link(). +*/ +void v4l2_fwnode_put_link (struct v4l2_fwnode_link *link) +{ +fwnode_handle_put (link->local_node); +fwnode_handle_put (link->remote_node); +} +EXPORT_SYMBOL (v4l2_fwnode_put_link); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Sakari Ailus <[email protected]>" ); +MODULE_AUTHOR ("Sylwester Nawrocki <[email protected]>" ); +MODULE_AUTHOR ("Guennadi Liakhovetski <[email protected]>" );include/media/v4l2-fwnode.h new file +13
-0@@ -0,0 +1,104 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify
include/media/v4l2-fwnode.h line 23
Quoted 10 lines
include/media/v4l2-fwnode.h new file +10
-0+* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#ifndef _V4L2_FWNODE_H +#define _V4L2_FWNODE_H + +#include <linux/list.h> +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/of_graph.h>
Alphabetical order please.
Quoted 80 lines
include/media/v4l2-fwnode.h new file +80
-0+#include <media/v4l2-mediabus.h> + +struct fwnode_handle ; + +/** +* struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure +* @flags: media bus (V4L2_MBUS_*) flags +* @data_lanes: an array of physical data lane indexes +* @clock_lane: physical lane index of the clock lane +* @num_data_lanes: number of data lanes +* @lane_polarities: polarity of the lanes. The order is the same of +* the physical lanes. +*/ +struct v4l2_fwnode_bus_mipi_csi2 { +unsigned int flags; +unsigned char data_lanes[4 ]; +unsigned char clock_lane; +unsigned short num_data_lanes; +bool lane_polarities[5 ]; +}; + +/** +* struct v4l2_fwnode_bus_parallel - parallel data bus data structure +* @flags: media bus (V4L2_MBUS_*) flags +* @bus_width: bus width in bits +* @data_shift: data shift in bits +*/ +struct v4l2_fwnode_bus_parallel { +unsigned int flags; +unsigned char bus_width; +unsigned char data_shift; +}; + +/** +* struct v4l2_fwnode_endpoint - the endpoint data structure +* @base: fwnode endpoint of the v4l2_fwnode +* @bus_type: bus type +* @bus: bus configuration data structure +* @link_frequencies: array of supported link frequencies +* @nr_of_link_frequencies: number of elements in link_frequenccies array +*/ +struct v4l2_fwnode_endpoint { +struct fwnode_endpoint base; +/* +* Fields below this line will be zeroed by +* v4l2_fwnode_parse_endpoint() +*/ +enum v4l2_mbus_type bus_type; +union { +struct v4l2_fwnode_bus_parallel parallel; +struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2; + } bus; +u64 *link_frequencies; +unsigned int nr_of_link_frequencies; +}; + +/** +* struct v4l2_fwnode_link - a link between two endpoints +* @local_node: pointer to device_node of this endpoint +* @local_port: identifier of the port this endpoint belongs to +* @remote_node: pointer to device_node of the remote endpoint +* @remote_port: identifier of the port the remote endpoint belongs to +*/ +struct v4l2_fwnode_link { +struct fwnode_handle *local_node; +unsigned int local_port; +struct fwnode_handle *remote_node; +unsigned int remote_port; +}; + +int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwn, +struct v4l2_fwnode_endpoint *vfwn); +struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse ( +struct fwnode_handle *fwn); +void v4l2_fwnode_endpoint_free (struct v4l2_fwnode_endpoint *vfwn); +int v4l2_fwnode_parse_link (struct fwnode_handle *fwn, +struct v4l2_fwnode_link *link); +void v4l2_fwnode_put_link (struct v4l2_fwnode_link *link); + +#endif /* _V4L2_FWNODE_H */
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 3/8] v4l: async: Add fwnode match support
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 38 lines · On Thursday 06 Apr 2017 16:12:05 Sakari Ailus wrote:
Add fwnode matching to complement OF node matching. And fwnode may also be an OF node.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 12 ++++++++++++ include/media/v4l2-async.h | 5 +++++ include/media/v4l2-subdev.h | 3 +++ 3 files changed, 20 insertions(+)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-async.cindex 96cc733..384ad5e 100644drivers/media/v4l2-core/v4l2-async.c +5
-0@@ -46,6 +46,11 @@ static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) of_node_full_name(asd->match.of.node)); } +static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) +{ +return sd->fwnode == asd->match.fwnode.fwn; +} +static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) {drivers/media/v4l2-core/v4l2-async.c +0
-0if (!asd->match.custom.match)@@ -80,6 +85,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct
v4l2_async_notifier* caseV4L2_ASYNC_MATCH_OF:drivers/media/v4l2-core/v4l2-async.c +3
-0match = match_of;break ; +case V4L2_ASYNC_MATCH_FWNODE : + match = match_fwnode; +break ;default :/* Cannot happen, unless someone breaks us */ WARN_ON (true);
drivers/media/v4l2-core/v4l2-async.c int v4l2_async_notifier_register(struct v4l2_device · line 172
Quoted 7 lines
drivers/media/v4l2-core/v4l2-async.c +1
-0@@ -158,6 +166,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, case V4L2_ASYNC_MATCH_DEVNAME:case V4L2_ASYNC_MATCH_I2C :case V4L2_ASYNC_MATCH_OF : +case V4L2_ASYNC_MATCH_FWNODE :break ;default : dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev :
NULL,
Quoted 31 lines
drivers/media/v4l2-core/v4l2-async.c +3
-0@@ -282,6 +291,9 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)*/ if (!sd->of_node && sd->dev) sd->of_node = sd->dev->of_node; +if (!sd->fwnode && sd->dev) + sd->fwnode = sd->dev->of_node ? + &sd->dev->of_node->fwnode : sd->dev->fwnode;mutex_lock (&list_lock);include/media/v4l2-async.h +2
-0@@ -32,6 +32,7 @@ struct v4l2_async_notifier;* @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address * @V4L2_ASYNC_MATCH_OF: Match will use OF node +* @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node * * This enum is used by the asyncrhronous sub-device logic to define the * algorithm that will be used to match an asynchronous device. @@ -41,6 +42,7 @@ enum v4l2_async_match_type {V4L2_ASYNC_MATCH_DEVNAME ,V4L2_ASYNC_MATCH_I2C ,V4L2_ASYNC_MATCH_OF , + V4L2_ASYNC_MATCH_FWNODE, };/**
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 4 lines
include/media/v4l2-async.h +1
-0@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;
I'd name this "node". The rationale is that code should be as independent as possible of whether we use device_node or fwnode_handle. Naming both variable "node" helps in that regard, and is in my opinion easier to read. This applies to the other patches in the series too.
Apart from that,
Quoted 13 lines
include/media/v4l2-async.h +2
-0+ } fwnode; +struct {const char *name; } device_name;struct {include/media/v4l2-subdev.h +0
-0@@ -788,6 +788,8 @@ struct v4l2_subdev_platform_data {* @devnode: subdev device node * @dev: pointer to the physical device, if any * @of_node: The device_node of the subdev, usually the same as
Quoted 3 lines
dev->of_node. + * @fwnode: Thefwnode_handleof the subdev, usually the same as
+ * eitherdev->of_node->fwnodeordev->fwnode(whichever is non-
NULL).
Quoted 11 lines
* @async_list: Links this subdev to a global
subdev_listor
@notifier->done * list.
* @asd: Pointer to respective &structv4l2_async_subdev.include/media/v4l2-subdev.h +1
-0@@ -819,6 +821,7 @@ struct v4l2_subdev {struct video_device *devnode;struct device *dev;struct device_node *of_node; +struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 8/8] v4l: Remove V4L2 OF framework in favour of V4L2 fwnode framework
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 4 lines · On Thursday 06 Apr 2017 16:12:10 Sakari Ailus wrote:
All drivers have been converted from V4L2 OF to V4L2 fwnode. The V4L2 OF framework is now unused. Remove it.
Signed-off-by Sakari Ailus <[email protected]>
Quoted 7 lines
--- drivers/media/v4l2-core/Makefile | 3 - drivers/media/v4l2-core/v4l2-of.c | 327 ----------------------------------- include/media/v4l2-of.h | 128 --------------- 3 files changed, 458 deletions(-) delete mode 100644 drivers/media/v4l2-core/v4l2-of.c delete mode 100644 include/media/v4l2-of.h
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
Reviewed-byRe: [PATCH v2 7/8] docs-rst: media: Switch documentation to V4L2 fwnode API
In reply to a message not in the archiveHi Sakari,
Thank you for the patch.
Quoted 17 lines · On Thursday 06 Apr 2017 16:12:09 Sakari Ailus wrote:
Instead of including the V4L2 OF header in ReST documentation, use the V4L2 fwnode header instead.
Signed-off-by Sakari Ailus <[email protected]>--- Documentation/media/kapi/v4l2-core.rst | 2 +- Documentation/media/kapi/v4l2-fwnode.rst | 3 +++ Documentation/media/kapi/v4l2-of.rst | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Documentation/media/kapi/v4l2-fwnode.rst delete mode 100644 Documentation/media/kapi/v4l2-of.rst(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-core.rstindex e967715..1bc8a14 100644
Documentation/media/kapi/v4l2-core.rst Video2Linux devices · line 22
Quoted 5 lines
Documentation/media/kapi/v4l2-core.rst +1
-1@@ -19,7 +19,7 @@ Video2Linux devices v4l2-mc v4l2-mediabus v4l2-mem2mem - v4l2-of + v4l2-fwnode
I wonder whether we should keep this alphabetically sorted.
Apart from that,
Quoted 21 lines
Documentation/media/kapi/v4l2-core.rst +0
-0v4l2-rect v4l2-tuner v4l2-common(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-fwnode.rstnew file mode 100644 index 0000000..6c8bccdDocumentation/media/kapi/v4l2-fwnode.rst new file +3
-0@@ -0,0 +1,3 @@ +V4L2 fwnode kAPI +^^^^^^^^^^^^^^^^ +.. kernel-doc:: include/media/v4l2-fwnode.h(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-of.rstdeleted file mode 100644 index 1ddf76b..0000000Documentation/media/kapi/v4l2-of.rst deleted +0
-3@@ -1,3 +0,0 @@ -V4L2 Open Firmware kAPI -^^^^^^^^^^^^^^^^^^^^^^^ -.. kernel-doc:: include/media/v4l2-of.h
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
Reviewed-byRe: [PATCH v2 6/8] v4l: media/drv-intf/soc_mediabus.h: include dependent header file
In reply to a message not in the archiveHi Sakari,
Thank you for the patch.
Quoted 4 lines · On Thursday 06 Apr 2017 16:12:08 Sakari Ailus wrote:
media/drv-intf/soc_mediabus.hdoes depend on structv4l2_mbus_configwhich is defined inmedia/v4l2-mediabus.h. Include it.Signed-off-by Sakari Ailus <[email protected]>
Was this provided indirectly before, through v4l2-of.h perhaps ? If so, shouldn't this patch be moved before 5/8 ? Apart from that,
Quoted 17 lines
--- include/media/drv-intf/soc_mediabus.h | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/include/media/drv-intf/soc_mediabus.hindex 2ff7737..0449788 100644include/media/drv-intf/soc_mediabus.h +2
-0@@ -14,6 +14,8 @@#include <linux/videodev2.h> #include <linux/v4l2-mediabus.h> +#include <media/v4l2-mediabus.h> +/** * enum soc_mbus_packing - data packing types on the media-bus * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
maintainerRe: [PATCH v2 3/8] v4l: async: Add fwnode match support
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
One more small comment below.
Quoted 38 lines · On Thursday 06 Apr 2017 16:12:05 Sakari Ailus wrote:
Add fwnode matching to complement OF node matching. And fwnode may also be an OF node.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 12 ++++++++++++ include/media/v4l2-async.h | 5 +++++ include/media/v4l2-subdev.h | 3 +++ 3 files changed, 20 insertions(+)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-async.cindex 96cc733..384ad5e 100644drivers/media/v4l2-core/v4l2-async.c +5
-0@@ -46,6 +46,11 @@ static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) of_node_full_name(asd->match.of.node)); } +static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) +{ +return sd->fwnode == asd->match.fwnode.fwn; +} +static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) {drivers/media/v4l2-core/v4l2-async.c +0
-0if (!asd->match.custom.match)@@ -80,6 +85,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct
v4l2_async_notifier* caseV4L2_ASYNC_MATCH_OF:drivers/media/v4l2-core/v4l2-async.c +3
-0match = match_of;break ; +case V4L2_ASYNC_MATCH_FWNODE : + match = match_fwnode; +break ;default :/* Cannot happen, unless someone breaks us */ WARN_ON (true);
drivers/media/v4l2-core/v4l2-async.c int v4l2_async_notifier_register(struct v4l2_device · line 172
Quoted 7 lines
drivers/media/v4l2-core/v4l2-async.c +1
-0@@ -158,6 +166,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, case V4L2_ASYNC_MATCH_DEVNAME:case V4L2_ASYNC_MATCH_I2C :case V4L2_ASYNC_MATCH_OF : +case V4L2_ASYNC_MATCH_FWNODE :break ;default : dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev :
NULL,
Quoted 31 lines
drivers/media/v4l2-core/v4l2-async.c +3
-0@@ -282,6 +291,9 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)*/ if (!sd->of_node && sd->dev) sd->of_node = sd->dev->of_node; +if (!sd->fwnode && sd->dev) + sd->fwnode = sd->dev->of_node ? + &sd->dev->of_node->fwnode : sd->dev->fwnode;mutex_lock (&list_lock);include/media/v4l2-async.h +2
-0@@ -32,6 +32,7 @@ struct v4l2_async_notifier;* @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address * @V4L2_ASYNC_MATCH_OF: Match will use OF node +* @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node * * This enum is used by the asyncrhronous sub-device logic to define the * algorithm that will be used to match an asynchronous device. @@ -41,6 +42,7 @@ enum v4l2_async_match_type {V4L2_ASYNC_MATCH_DEVNAME ,V4L2_ASYNC_MATCH_I2C ,V4L2_ASYNC_MATCH_OF , + V4L2_ASYNC_MATCH_FWNODE, };/**
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 4 lines
include/media/v4l2-async.h +1
-0@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;
Shouldn't this be const ?
Quoted 13 lines
include/media/v4l2-async.h +2
-0+ } fwnode; +struct {const char *name; } device_name;struct {include/media/v4l2-subdev.h +0
-0@@ -788,6 +788,8 @@ struct v4l2_subdev_platform_data {* @devnode: subdev device node * @dev: pointer to the physical device, if any * @of_node: The device_node of the subdev, usually the same as
Quoted 3 lines
dev->of_node.
+ * @fwnode: Thefwnode_handleof the subdev, usually the same as
+ * eitherdev->of_node->fwnodeordev->fwnode(whichever is non-
NULL).
Quoted 11 lines
* @async_list: Links this subdev to a global
subdev_listor
@notifier->done * list.
* @asd: Pointer to respective &structv4l2_async_subdev.include/media/v4l2-subdev.h +1
-0@@ -819,6 +821,7 @@ struct v4l2_subdev {struct video_device *devnode;struct device *dev;struct device_node *of_node; +struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 4/8] v4l: async: Provide interoperability between OF and fwnode matching
In reply to a message not in the archiveHi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:06 Sakari Ailus wrote:
OF and fwnode support are separated in V4L2 and individual drivers may implement one of them. Sub-devices do not match with a notifier expecting sub-devices with fwnodes, nor the other way around.
Shouldn't we instead convert all drivers to fwnode matching ? What's missing after the mass conversion in patch 5/8 ?
Quoted 65 lines
Fix this by checking for sub-device's
of_nodefield in fwnode match and fwnode field in OF match.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 26 +++++++++++++++++++++++--- include/media/v4l2-async.h | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-async.cindex 384ad5e..7f5d804 100644drivers/media/v4l2-core/v4l2-async.c +23
-3@@ -14,6 +14,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/types.h> @@ -40,15 +41,34 @@ static bool match_devname(struct v4l2_subdev *sd,return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); } +static bool fwnode_cmp (struct fwnode_handle *one, +struct fwnode_handle *theother) +{ +if (!one || !theother) +return false; + +if (one->type != theother->type) +return false; + +if (is_of_node (one)) +return !of_node_cmp (of_node_full_name (to_of_node (one)), +of_node_full_name (to_of_node (theother))); +else +return one == theother; +} +static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !of_node_cmp (of_node_full_name (sd->of_node), -of_node_full_name (asd->match.of.node)); +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, +of_fwnode_handle (asd->match.of.node)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwn; +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, + asd->match.fwnode.fwn); }static bool match_custom(struct
v4l2_subdev*sd, structv4l2_async_subdev
*asd) diff --gita/include/media/v4l2-async.hb/include/media/v4l2-async.hindex 8f552d2..df8b682 100644
include/media/v4l2-async.h struct v4l2_async_subdev { · line 60
Quoted 5 lines
include/media/v4l2-async.h +1
-1@@ -57,7 +57,7 @@ struct v4l2_async_subdev {enum v4l2_async_match_type match_type; union { struct { - const struct device_node *node; + struct device_node *node;
That seems to be a bit of a hack :-( I'd rather make everything const and cast to non-const pointers explicitly where the API requires us to. Or, better, add a to_of_node_const() function.
Quoted 3 lines
include/media/v4l2-async.h +0
-0} of;struct {struct fwnode_handle *fwn;
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 1/8] v4l: flash led class: Use fwnode_handle instead of device_node in init
In reply to Laurent PinchartHi Laurent,
Thank you for the review!
Quoted 45 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 32 lines · On Thursday 06 Apr 2017 16:12:03 Sakari Ailus wrote:
Pass the more generic
fwnode_handleto the init function than thedevice_node.--- drivers/leds/leds-aat1290.c | 5 +++-- drivers/leds/leds-max77693.c | 5 +++-- drivers/media/v4l2-core/v4l2-flash-led-class.c | 11 ++++++----- include/media/v4l2-flash-led-class.h | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-)drivers/leds/leds-aat1290.c +3
-2@@ -503,8 +503,9 @@ static int aat1290_led_probe(struct platform_device *pdev) aat1290_init_v4l2_flash_config(led, &led_cfg, &v4l2_sd_cfg);/* Create V4L2 Flash subdev. */ - led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + led->v4l2_flash =v4l2_flash_init (dev,of_fwnode_handle (sub_node), + fled_cdev,NULL , &v4l2_flash_ops, + &v4l2_sd_cfg);if (IS_ERR (led->v4l2_flash)) { ret =PTR_ERR (led->v4l2_flash); goto error_v4l2_flash_init;drivers/leds/leds-max77693.c +0
-0drivers/leds/leds-max77693.c static int max77693_register_led(struct max77693_sub_led · line 934
Quoted 7 lines
drivers/leds/leds-max77693.c +2
-2@@ -930,8 +930,9 @@ static int max77693_register_led(struct max77693_sub_led *sub_led,max77693_init_v4l2_flash_config (sub_led, led_cfg, &v4l2_sd_cfg);/* Register in the V4L2 subsystem. */ - sub_led->v4l2_flash =v4l2_flash_init (dev, sub_node, fled_cdev,NULL , - &v4l2_flash_ops, &v4l2_sd_cfg); + sub_led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node), + fled_cdev, NULL,
&v4l2_flash_ops,
Quoted 15 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c line 15
Quoted 13 lines
drivers/leds/leds-max77693.c +1
-0+ &v4l2_sd_cfg);if (IS_ERR (sub_led->v4l2_flash)) { ret =PTR_ERR (sub_led->v4l2_flash); goto err_v4l2_flash_init;(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-flash-led-class.cindex 794e563..f430c89 100644drivers/media/v4l2-core/v4l2-flash-led-class.c +0
-0@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> I think you can drop
linux/of.h.
Correct. Will fix.
Quoted 9 lines
Quoted 9 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c +1
-0+#include <linux/property.h> #include <linux/slab.h> #include <linux/types.h> #include <media/v4l2-flash-led-class.h> @@ -612,7 +613,7 @@ static const struct v4l2_subdev_internal_ops
v4l2_flash_subdev_internal_ops= { static const structv4l2_subdev_opsv4l2_flash_subdev_ops;
Quoted 14 lines
drivers/media/v4l2-core/v4l2-flash-led-class.c struct v4l2_flash *v4l2_flash_init( · line 642
Quoted 12 lines
struct
v4l2_flash*v4l2_flash_init(drivers/media/v4l2-core/v4l2-flash-led-class.c +2
-2- struct device *dev, struct device_node *of_node, + struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, struct led_classdev_flash *iled_cdev, const struct v4l2_flash_ops *ops,@@ -638,7 +639,7 @@ struct v4l2_flash *v4l2_flash_init( v4l2_flash->iled_cdev = iled_cdev; v4l2_flash->ops = ops; sd->dev = dev; - sd->of_node = of_node ? of_node : led_cdev->dev->of_node; + sd->fwnode = fwn ? fwn :dev_fwnode (led_cdev->dev);
v4l2_subdevwill only have a fwnode field in patch 3/8.
I think I've rearranged the set after writing the patch and missed the dependency. I'll move it third unless there are other dependencies.
Signature · 8 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Laurent Pinchart
maintainerRe: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to Sakari AilusHi Sakari,
Thank you for the patch.
Quoted 46 lines · On Thursday 06 Apr 2017 16:12:07 Sakari Ailus wrote:
Switch users of the
v4l2_of_APIs to the more genericv4l2_fwnode_APIs.Existing OF matching continues to be supported. omap3isp and smiapp drivers are converted to fwnode matching as well.
Signed-off-by Sakari Ailus <[email protected]>
am437x/am437x-vpfe.candti-vpe/cal.c---drivers/media/i2c/Kconfig | 9 ++++ drivers/media/i2c/adv7604.c | 7 +-- drivers/media/i2c/mt9v032.c | 7 +-- drivers/media/i2c/ov2659.c | 8 +-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +-- drivers/media/i2c/s5k5baf.c | 6 +-- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 ++++++----- drivers/media/i2c/tc358743.c | 11 ++-- drivers/media/i2c/tvp514x.c | 6 +-- drivers/media/i2c/tvp5150.c | 7 +-- drivers/media/i2c/tvp7002.c | 6 +-- drivers/media/platform/Kconfig | 3 ++ drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +-- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +-- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +-- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +-- drivers/media/platform/omap3isp/isp.c | 71 +++++++++++----------- drivers/media/platform/pxa_camera.c | 7 +-- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +-- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +-- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 ++-- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++++++++++---------- include/media/v4l2-fwnode.h | 4 +- 31 files changed, 176 insertions(+), 134 deletions(-)drivers/media/i2c/Kconfig +0
-0
drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 213
Quoted 4 lines
drivers/media/i2c/Kconfig +1
-0@@ -210,6 +210,7 @@ config VIDEO_ADV7604 depends on GPIOLIB || COMPILE_TEST select HDMI select MEDIA_CEC_EDID + select V4L2_FWNODE
What happens when building the driver on a platform that includes neither OF nor ACPI support ?
drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 216
Quoted 3 lines
drivers/media/i2c/Kconfig +0
-0---help--- Support for the Analog Devices ADV7604 video decoder.
[snip]
How have you checked that you haven't missed any entry in the Kconfig files ?
[snip]
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 084ecf4a..95850b9 100644drivers/media/platform/omap3isp/isp.c +0
-0
[snip]
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2032
Quoted 12 lines
drivers/media/platform/omap3isp/isp.c +3
-3@@ -2024,43 +2025,42 @@ enum isp_of_phy { ISP_OF_PHY_CSIPHY2, }; -static int isp_of_parse_node (struct device *dev,struct device_node *node, -struct isp_async_subdev *isd) +static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn, +struct isp_async_subdev *isd) {struct isp_bus_cfg *buscfg = &isd->bus; -struct v4l2_of_endpoint vep; +struct v4l2_fwnode_endpoint vfwn;
vfwn is confusing to me, I think the variable name should show that it refers to an endpoint.
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2040
Quoted 11 lines
drivers/media/platform/omap3isp/isp.c +2
-3unsigned int i;int ret; - ret =v4l2_of_parse_endpoint (node, &vep); + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret; -dev_dbg (dev,"parsing endpoint %s, interface %u\n" , node->full_name, - vep.base.port); +dev_dbg (dev,"interface %u\n" , vfwn.base.port);
Is there no way to keep the node name in the error message ?
[snip]
drivers/media/platform/omap3isp/isp.c static int isp_of_parse_node(struct device *dev, · line 2097
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +1
-2@@ -2094,18 +2094,17 @@ static int isp_of_parse_node(struct device *dev,struct device_node *node, break;default : -dev_warn (dev,"%s: invalid interface %u\n" , node->full_name, - vep.base.port); +dev_warn (dev,"invalid interface %u\n" , vfwn.base.port);
Ditto.
drivers/media/platform/omap3isp/isp.c static int isp_of_parse_node(struct device *dev, struct device_node *node, · line 2107
Quoted 13 lines
drivers/media/platform/omap3isp/isp.c +3
-3break ; }return 0 ; } -static int isp_of_parse_nodes (struct device *dev, -struct v4l2_async_notifier *notifier) +static int isp_fwnodes_parse (struct device *dev, +struct v4l2_async_notifier *notifier) { -struct device_node *node =NULL ; +struct fwnode_handle *fwn =NULL ;
As explained in the review of another patch from the same series, I wouldn't rename the variable.
Quoted 2 lines
drivers/media/platform/omap3isp/isp.c +0
-0notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );
[snip]
drivers/media/platform/omap3isp/isp.c static int isp_probe(struct platform_device *pdev) · line 2224
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +2
-2@@ -2219,12 +2220,12 @@ static int isp_probe(struct platform_device *pdev)if (IS_ERR (isp->syscon))return PTR_ERR (isp->syscon); - ret =of_property_read_u32_index (pdev->dev.of_node,"syscon" ,1 , - &isp->syscon_offset); + ret =of_property_read_u32_index (pdev->dev.of_node, +"syscon" ,1 , &isp->syscon_offset);
This change doesn't seem to be needed.
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +1
-1if (ret)return ret; - ret =isp_of_parse_nodes (&pdev->dev, &isp->notifier); + ret =isp_fwnodes_parse (&pdev->dev, &isp->notifier);if (ret <0 )return ret;
[snip]
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/xilinx/xilinx-vipp.cindex feb3b2f..6a2721b 100644drivers/media/platform/xilinx/xilinx-vipp.c +0
-0
[snip]
drivers/media/platform/xilinx/xilinx-vipp.c static int xvip_graph_build_one(struct xvip_composite_device *xdev, · line 108
Quoted 10 lines
drivers/media/platform/xilinx/xilinx-vipp.c +0
-0@@ -103,9 +103,10 @@ static int xvip_graph_build_one(struct
xvip_composite_device*xdev, * the link.drivers/media/platform/xilinx/xilinx-vipp.c +3
-3*/ if (link.local_port >= local->num_pads) { -dev_err (xdev->dev,"invalid port number %u on %s\n" , - link.local_port, link.local_node->full_name); -v4l2_of_put_link (&link); +dev_err (xdev->dev,"invalid port number %u for %s\n" , + link.local_port, +to_of_node (link.local_node)->full_name);
This makes me believe that we're missing a fwnode_full_name() function.
Quoted 4 lines
drivers/media/platform/xilinx/xilinx-vipp.c +1
-0+v4l2_fwnode_put_link (&link); ret = -EINVAL ;break ; }
[snip]
Quoted 6 lines
include/media/v4l2-fwnode.h +0
-0@@ -17,10 +17,10 @@#ifndef _V4L2_FWNODE_H
include/media/v4l2-fwnode.h line 25
Quoted 10 lines
include/media/v4l2-fwnode.h +2
-2#define _V4L2_FWNODE_H +#include <linux/errno.h> +#include <linux/fwnode.h> #include <linux/list.h> #include <linux/types.h> -#include <linux/errno.h> -#include <linux/of_graph.h> #include <media/v4l2-mediabus.h>
This probably belongs to another patch (at least the alphabetical sorting does).
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/8] v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to Laurent PinchartHi Laurent,
Quoted 11 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:04 Sakari Ailus wrote:
The
fwnode_handleis a more generic way than OFdevice_nodeto describe firmware nodes. Instead of the OF API, use more generic fwnode API to obtain the same information.I would mention that this is a copy of
v4l2-of.cwith the OF API replaced with the fwnode API.
I'll add that to the description.
Quoted 77 lines
Quoted 66 lines
As the V4L2 fwnode support will be required by a small minority of e.g. ACPI based systems (the same might actually go for OF), make this a module instead of embedding it in the videodev module.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fwnode.c | 353 +++++++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 104 ++++++++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c create mode 100644 include/media/v4l2-fwnode.h(quoted diff) +0
-0b/drivers/media/v4l2-core/Kconfig index 6b1b78f..a35c336 100644
drivers/media/v4l2-core/Kconfig +3
-0@@ -55,6 +55,9 @@ config V4L2_FLASH_LED_CLASS When in doubt, say N. +config V4L2_FWNODE + tristate + # Used by drivers that need Videobuf modules config VIDEOBUF_GEN tristate(quoted diff) +0
-0b/drivers/media/v4l2-core/Makefile index 795a535..cf77a63 100644
drivers/media/v4l2-core/Makefile +1
-0@@ -13,6 +13,7 @@ endif ifeq ($(CONFIG_OF),y) videodev-objs += v4l2-of.o endif +obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o endif(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-fwnode.cnew file mode 100644 index 0000000..4f69b11drivers/media/v4l2-core/v4l2-fwnode.c new file +19
-0@@ -0,0 +1,353 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#include <linux/acpi.h> +#include <linux/kernel.h> +#include <linux/module.h> drivers/media/v4l2-core/v4l2-fwnode.c line 29
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+#include <linux/of.h> +#include <linux/property.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/types.h> + +#include <media/v4l2-fwnode.h> + +static int v4l2_fwnode_endpoint_parse_csi_bus (struct fwnode_handle *fwn, + struct v4l2_fwnode_endpoint*vfwn)
Quoted 9 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 36
Quoted 7 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +7
-0+{ +struct v4l2_fwnode_bus_mipi_csi2 *bus = &vfwn->bus.mipi_csi2; +bool have_clk_lane = false; +unsigned int flags =0 , lanes_used =0 ; +unsigned int i; +u32 v; +int rval;I would have used "ret" instead of "rval" ;-)
I know. But
1) there's no established convention in the file and
2) "rval" has the benefit is easier to look up; one doesn't find a plethora of "return something". Therefore it is better than "ret" for the purpose.
Quoted 13 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 46
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +9
-0+ rval =fwnode_property_read_u32_array (fwn,"data-lanes" ,NULL ,0 ); +if (rval >0 ) { +u32 array[ARRAY_SIZE (bus->data_lanes)]; + + bus->num_data_lanes = +min_t (int,ARRAY_SIZE (bus->data_lanes), rval); + +fwnode_property_read_u32_array ( + fwn,"data-lanes" , array, bus->num_data_lanes);Is there anything wrong with the usual way to wrap code ?
Quoted 2 lines
fwnode_property_read_u32_array(fwn, "data-lanes", array, bus->num_data_lanes);
I'll change the occurrences of that whenever feasible.
Quoted 105 lines
drivers/media/v4l2-core/v4l2-fwnode.c
Quoted 13 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +12
-0+ +for (i =0 ; i < bus->num_data_lanes; i++) { +if (lanes_used &BIT (array[i])) +pr_warn ("duplicated lane %u in data-lanes\n" , + array[i]); + lanes_used |=BIT (array[i]); + + bus->data_lanes[i] = array[i]; + } + } + + rval = fwnode_property_read_u32_array(fwn, "lane-polarities", NULL,0);
drivers/media/v4l2-core/v4l2-fwnode.c
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+if (rval >0 ) { +u32 array[ARRAY_SIZE (bus->lane_polarities)]; + +if (rval <1 + bus->num_data_lanes/* clock + data */ ) { + pr_warn("too few lane-polarities entries (need %u, got%u)\n",
Quoted 7 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+ 1 + bus->num_data_lanes, rval); +return -EINVAL ; + } + + fwnode_property_read_u32_array( + fwn, "lane-polarities", array, 1 + bus-
num_data_lanes);Ditto with
fwnode_property_read_u32_array(fwn, "lane-polarities", array, 1 + bus->num_data_lanes);Quoted 72 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +72
-0+for (i =0 ; i <1 + bus->num_data_lanes; i++) + bus->lane_polarities[i] = array[i]; + } + +if (!fwnode_property_read_u32 (fwn,"clock-lanes" , &v)) { +if (lanes_used &BIT (v)) +pr_warn ("duplicated lane %u in clock-lanes\n" , v); + lanes_used |=BIT (v); + + bus->clock_lane = v; + have_clk_lane = true; + } + +if (fwnode_property_present (fwn,"clock-noncontinuous" )) + flags |=V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK ; +else if (have_clk_lane || bus->num_data_lanes >0 ) + flags |=V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + + bus->flags = flags; + vfwn->bus_type =V4L2_MBUS_CSI2 ; + +return 0 ; +} + +static void v4l2_fwnode_endpoint_parse_parallel_bus ( +struct fwnode_handle *fwn,struct v4l2_fwnode_endpoint *vfwn) +{ +struct v4l2_fwnode_bus_parallel *bus = &vfwn->bus.parallel; +unsigned int flags =0 ; +u32 v; + +if (!fwnode_property_read_u32 (fwn,"hsync-active" , &v)) + flags |= v ?V4L2_MBUS_HSYNC_ACTIVE_HIGH : +V4L2_MBUS_HSYNC_ACTIVE_LOW ; + +if (!fwnode_property_read_u32 (fwn,"vsync-active" , &v)) + flags |= v ?V4L2_MBUS_VSYNC_ACTIVE_HIGH : +V4L2_MBUS_VSYNC_ACTIVE_LOW ; + +if (!fwnode_property_read_u32 (fwn,"field-even-active" , &v)) + flags |= v ?V4L2_MBUS_FIELD_EVEN_HIGH : +V4L2_MBUS_FIELD_EVEN_LOW ; +if (flags) + vfwn->bus_type =V4L2_MBUS_PARALLEL ; +else + vfwn->bus_type =V4L2_MBUS_BT656 ; + +if (!fwnode_property_read_u32 (fwn,"pclk-sample" , &v)) + flags |= v ?V4L2_MBUS_PCLK_SAMPLE_RISING : +V4L2_MBUS_PCLK_SAMPLE_FALLING ; + +if (!fwnode_property_read_u32 (fwn,"data-active" , &v)) + flags |= v ?V4L2_MBUS_DATA_ACTIVE_HIGH : +V4L2_MBUS_DATA_ACTIVE_LOW ; + +if (fwnode_property_present (fwn,"slave-mode" )) + flags |=V4L2_MBUS_SLAVE ; +else + flags |=V4L2_MBUS_MASTER ; + +if (!fwnode_property_read_u32 (fwn,"bus-width" , &v)) + bus->bus_width = v; + +if (!fwnode_property_read_u32 (fwn,"data-shift" , &v)) + bus->data_shift = v; + +if (!fwnode_property_read_u32 (fwn,"sync-on-green-active" , &v)) + flags |= v ?V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH : +V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW ; + + bus->flags = flags; +
Quoted 8 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 147
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+} + +/** +* v4l2_fwnode_endpoint_parse() - parse all fwnode node properties +* @fwn: pointer to fwnode_handle I would say "the endpoint's fwnode handle", or "pointer to the endpoint's fwnode handle". Otherwise which fwnode handle should be passed won't be clear.
I prefer the latter.
Quoted 13 lines
Quoted 12 lines
+ * @vfwn: pointer to the V4L2 fwnode data structure
+ *
+ * All properties are optional. If none are found, we don't set any flags.
+ * This means the port has a static configuration and no properties have
+ * to be specified explicitly.
+ * If any properties that identify the bus as parallel are found and
+ * slave-mode isn't set, we setV4L2_MBUS_MASTER. Similarly, if we recognise
+ * the bus as serial CSI-2 and clock-noncontinuous isn't set, we set the
+ *V4L2_MBUS_CSI2_CONTINUOUS_CLOCKflag.
+ * The caller should hold a reference to @node.
Quoted 3 lines
s/@node/@fwn/
By the way, have you tried to compile the documentation ?
I have, but I may have made changes since that. I'll test that again before submitting the next version.
Quoted 14 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 166
Quoted 10 lines
+ *
+ * NOTE: This function does not parse properties the size of which is
+ * variable without a low fixed limit. Please use
+ *v4l2_fwnode_endpoint_alloc_parse()in new drivers instead.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */drivers/media/v4l2-core/v4l2-fwnode.c new file +2
-0+int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwn, +struct v4l2_fwnode_endpoint *vfwn)Is there a specific reason not to keep the original parameter name "endpoint" ? vfwn seems to stand for
v4l2_fwnode, notv4l2_fwnode_endpoint. Same comment for all other locations in this patch.
I'm ok with keeping endpoint.
Quoted 17 lines
Quoted 17 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +16
-0+{ +int rval; + +fwnode_graph_parse_endpoint (fwn, &vfwn->base); + +/* Zero fields from bus_type to until the end */ +memset (&vfwn->bus_type,0 ,sizeof (*vfwn) - + offsetof(typeof(*vfwn), bus_type)); + + rval =v4l2_fwnode_endpoint_parse_csi_bus (fwn, vfwn); +if (rval) +return rval; +/* +* Parse the parallel video bus properties only if none +* of the MIPI CSI-2 specific properties were found. +*/
Quoted 8 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 188
Quoted 6 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+if (vfwn->bus.mipi_csi2.flags ==0 ) +v4l2_fwnode_endpoint_parse_parallel_bus (fwn, vfwn); + +return 0 ; +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_parse);According to Mauro in http://www.mail-archive.com/[email protected]/msg110809.html you should use
EXPORT_SYMBOL_GPL.
EXPORT_SYMBOL() was used by v4l2-of.c; I'll switch here.
Quoted 9 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 193
Quoted 6 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+ +/* +* v4l2_fwnode_endpoint_free() - free the V4L2 fwnode acquired by +* v4l2_fwnode_endpoint_alloc_parse() +* @fwn - the V4L2 fwnode the resources of which are to be released Mayeb "the V4L2 fwnode whose resources are to be released" ?
Quoted 4 lines
Quoted 2 lines
+ *
+ * It is safe to call this function with NULL argument or on ans/on an/on a/
Yes.
Quoted 4 lines
Quoted 2 lines
+ * V4L2 fwnode the parsing of which failed.
"whose parsing failed" ?
Any particular reason? Do you like "whose"? :-)
Quoted 18 lines
Quoted 5 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +3
-0+void v4l2_fwnode_endpoint_free (struct v4l2_fwnode_endpoint *vfwn) +{ +if (IS_ERR_OR_NULL (vfwn))drivers/media/v4l2-core/v4l2-fwnode.c line 210
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+return ; + +kfree (vfwn->link_frequencies); +kfree (vfwn); +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_free); + +/** +* v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties +* @node: pointer to fwnode_handle s/@node/@fwn/
Quoted 2 lines
Here too, I would say "the endpoint's fwnode handle", or "pointer to the endpoint's fwnode handle".
I'll use the latter.
Quoted 12 lines
Quoted 11 lines
+ *
+ * All properties are optional. If none are found, we don't set any flags.
+ * This means the port has a static configuration and no properties have
+ * to be specified explicitly.
+ * If any properties that identify the bus as parallel are found and
+ * slave-mode isn't set, we setV4L2_MBUS_MASTER. Similarly, if we recognise
+ * the bus as serial CSI-2 and clock-noncontinuous isn't set, we set the
+ *V4L2_MBUS_CSI2_CONTINUOUS_CLOCKflag.
+ * The caller should hold a reference to @node.
Quoted 1 line
s/@node/@fwn/
Will fix.
Quoted 7 lines
Quoted 6 lines
+ *
+ *v4l2_fwnode_endpoint_alloc_parse()has two important differences to
+ *v4l2_fwnode_endpoint_parse():
+ *
+ * 1. It also parses variable size data and
Quoted 5 lines
Nitpicking, a valid sentence doesn't end with "and$". You could write
1. It also parses variable size data.
2. The memory it has allocated to store the variable size data must be freed usingv4l2_fwnode_endpoint_free()when no longer needed.
I prefer this one, will change.
Quoted 7 lines
or
1. it also parses variable size data; and
2. the memory it has allocated to store the variable size data must be freed usingv4l2_fwnode_endpoint_free()when no longer needed.
Quoted 8 lines
Quoted 6 lines
+ *
+ * 2. The memory it has allocated to store the variable size data must
+ * be freed usingv4l2_fwnode_endpoint_free()when no longer needed.
+ *
+ * Return: Pointer tov4l2_fwnode_endpointif successful, on error a
+ * negative error code.The function returns an error pointer on error.
Yes, I'll improve the documentation.
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 236
Quoted 7 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse ( +struct fwnode_handle *fwn) +{ +struct v4l2_fwnode_endpoint *vfwn; +int rval;ret ? :-)
Quoted 14 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 248
Quoted 12 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +12
-0+ + vfwn =kzalloc (sizeof (*vfwn),GFP_KERNEL ); +if (!vfwn) +return ERR_PTR (-ENOMEM ); + + rval =v4l2_fwnode_endpoint_parse (fwn, vfwn); +if (rval <0 ) + goto out_err; + + rval =fwnode_property_read_u64_array (fwn,"link-frequencies" , +NULL ,0 ); +No need for a blank line.
Indeed.
Quoted 40 lines
Quoted 7 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+if (rval <0 ) + goto out_err; + + vfwn->link_frequencies = +kmalloc_array (rval,sizeof (*vfwn->link_frequencies), +GFP_KERNEL );drivers/media/v4l2-core/v4l2-fwnode.c line 264
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+if (!vfwn->link_frequencies) { + rval = -ENOMEM ; + goto out_err; + } + + vfwn->nr_of_link_frequencies = rval; + + rval =fwnode_property_read_u64_array ( + fwn,"link-frequencies" , vfwn->link_frequencies, + vfwn->nr_of_link_frequencies);rval = fwnode_property_read_u64_array(fwn, "link-frequencies", vfwn->link_frequencies, vfwn->nr_of_link_frequencies);Quoted 4 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +4
-0+if (rval <0 ) + goto out_err; + +return vfwn;drivers/media/v4l2-core/v4l2-fwnode.c line 278
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ +out_err: +v4l2_fwnode_endpoint_free (vfwn); +return ERR_PTR (rval); +} +EXPORT_SYMBOL (v4l2_fwnode_endpoint_alloc_parse); + +/** +* v4l2_fwnode_endpoint_parse_link() - parse a link between two endpoints +* @node: pointer to the fwnode at the local end of the link The parameter is called
__fwn. I believe you should rename it to fwn, otherwise the documentation will look weird.
Quoted 2 lines
As explained before, you should mention that this is an endpoint fwnode handle.
Agreed.
Quoted 14 lines
Quoted 13 lines
+ * @link: pointer to the V4L2 fwnode link data structure
+ *
+ * Fill the link structure with the local and remote nodes and port numbers.
+ * Thelocal_nodeandremote_nodefields are set to point to the local and
+ * remote port's parent nodes respectively (the port parent node being the
+ * parent node of the port node if that node isn't a 'ports' node, or the
+ * grand-parent node of the port node otherwise).
+ *
+ * A reference is taken to both the local and remote nodes, the caller
+ * must usev4l2_fwnode_endpoint_put_link()to drop the references
+ * when done with the link.
Quoted 8 lines
Just curious, is there a reason to wrap earlier than the 80 columns limit ?
* A reference is taken to both the local and remote nodes, the caller must
use
*v4l2_fwnode_endpoint_put_link()to drop the references when done with the
* link.would work.
It is like a speed limit, you can perfectly legally drive slower than 80 characters per line, right? :-)
Albeit the conditions seem pretty good in this file, I can try pushing it closer to the limit.
Quoted 4 lines
Quoted 2 lines
+ * Return: 0 on success, or
-ENOLINKif the remote fwnode can't be found.Here too you should mention remote endpoint.
Oh yes.
Quoted 23 lines
Quoted 10 lines
+ */
drivers/media/v4l2-core/v4l2-fwnode.c new file +8
-0+int v4l2_fwnode_parse_link (struct fwnode_handle *__fwn, +struct v4l2_fwnode_link *link) +{ +struct fwnode_handle *fwn; +const char *port_prop =is_of_node (__fwn) ?"reg" :"port" ; + +memset (link,0 ,sizeof (*link)); +drivers/media/v4l2-core/v4l2-fwnode.c line 310
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ fwn =fwnode_get_parent (__fwn); +fwnode_property_read_u32 (fwn, port_prop, &link->local_port); + fwn =fwnode_get_next_parent (fwn); +if (is_of_node (fwn)) { +if (of_node_cmp (to_of_node (fwn)->name,"ports" ) ==0 ) + fwn =fwnode_get_next_parent (fwn); + }else { +/* The "ports" node is always there in ACPI. */ + fwn =fwnode_get_next_parent (fwn); + }To avoid duplicating the
fwnode_get_next_parent(fwn)call, you could write
Quoted 5 lines
if (!is_of_node(fwn) ||
of_node_cmp(to_of_node(fwn)->name, "ports") == 0) {
/* The "ports" node is always there in ACPI. */
fwn = fwnode_get_next_parent(fwn);
}Will change.
Quoted 70 lines
Quoted 9 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +8
-0+ link->local_node = fwn; + + fwn =fwnode_graph_get_remote_endpoint (fwn); +if (!fwn) { +fwnode_handle_put (fwn); +return -ENOLINK ; + } +drivers/media/v4l2-core/v4l2-fwnode.c line 328
Quoted 10 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +10
-0+ fwn =fwnode_get_parent (fwn); +fwnode_property_read_u32 (fwn, port_prop, &link->remote_port); + fwn =fwnode_get_next_parent (fwn); +if (is_of_node (fwn)) { +if (of_node_cmp (to_of_node (fwn)->name,"ports" ) ==0 ) + fwn =fwnode_get_next_parent (fwn); + }else { +/* The "ports" node is always there in ACPI. */ + fwn =fwnode_get_next_parent (fwn); + }Same comment here.
Quoted 48 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +25
-0+ link->remote_node = fwn; + +return 0 ; +} +EXPORT_SYMBOL (v4l2_fwnode_parse_link); + +/** +* v4l2_fwnode_put_link() - drop references to nodes in a link +* @link: pointer to the V4L2 fwnode link data structure +* +* Drop references to the local and remote nodes in the link. This +* function must be called on every link parsed with +* v4l2_fwnode_parse_link(). +*/ +void v4l2_fwnode_put_link (struct v4l2_fwnode_link *link) +{ +fwnode_handle_put (link->local_node); +fwnode_handle_put (link->remote_node); +} +EXPORT_SYMBOL (v4l2_fwnode_put_link); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Sakari Ailus <[email protected]>" ); +MODULE_AUTHOR ("Sylwester Nawrocki <[email protected]>" ); +MODULE_AUTHOR ("Guennadi Liakhovetski <[email protected]>" );include/media/v4l2-fwnode.h new file +17
-0@@ -0,0 +1,104 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#ifndef _V4L2_FWNODE_H
Quoted 8 lines
include/media/v4l2-fwnode.h line 23
Quoted 6 lines
include/media/v4l2-fwnode.h new file +6
-0+#define _V4L2_FWNODE_H + +#include <linux/list.h> +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/of_graph.h> Alphabetical order please.
Yes.
Quoted 82 lines
Quoted 81 lines
include/media/v4l2-fwnode.h new file +80
-0+#include <media/v4l2-mediabus.h> + +struct fwnode_handle ; + +/** +* struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure +* @flags: media bus (V4L2_MBUS_*) flags +* @data_lanes: an array of physical data lane indexes +* @clock_lane: physical lane index of the clock lane +* @num_data_lanes: number of data lanes +* @lane_polarities: polarity of the lanes. The order is the same of +* the physical lanes. +*/ +struct v4l2_fwnode_bus_mipi_csi2 { +unsigned int flags; +unsigned char data_lanes[4 ]; +unsigned char clock_lane; +unsigned short num_data_lanes; +bool lane_polarities[5 ]; +}; + +/** +* struct v4l2_fwnode_bus_parallel - parallel data bus data structure +* @flags: media bus (V4L2_MBUS_*) flags +* @bus_width: bus width in bits +* @data_shift: data shift in bits +*/ +struct v4l2_fwnode_bus_parallel { +unsigned int flags; +unsigned char bus_width; +unsigned char data_shift; +}; + +/** +* struct v4l2_fwnode_endpoint - the endpoint data structure +* @base: fwnode endpoint of the v4l2_fwnode +* @bus_type: bus type +* @bus: bus configuration data structure +* @link_frequencies: array of supported link frequencies +* @nr_of_link_frequencies: number of elements in link_frequenccies array +*/ +struct v4l2_fwnode_endpoint { +struct fwnode_endpoint base; +/* +* Fields below this line will be zeroed by +* v4l2_fwnode_parse_endpoint() +*/ +enum v4l2_mbus_type bus_type; +union { +struct v4l2_fwnode_bus_parallel parallel; +struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2; + } bus; +u64 *link_frequencies; +unsigned int nr_of_link_frequencies; +}; + +/** +* struct v4l2_fwnode_link - a link between two endpoints +* @local_node: pointer to device_node of this endpoint +* @local_port: identifier of the port this endpoint belongs to +* @remote_node: pointer to device_node of the remote endpoint +* @remote_port: identifier of the port the remote endpoint belongs to +*/ +struct v4l2_fwnode_link { +struct fwnode_handle *local_node; +unsigned int local_port; +struct fwnode_handle *remote_node; +unsigned int remote_port; +}; + +int v4l2_fwnode_endpoint_parse (struct fwnode_handle *fwn, +struct v4l2_fwnode_endpoint *vfwn); +struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse ( +struct fwnode_handle *fwn); +void v4l2_fwnode_endpoint_free (struct v4l2_fwnode_endpoint *vfwn); +int v4l2_fwnode_parse_link (struct fwnode_handle *fwn, +struct v4l2_fwnode_link *link); +void v4l2_fwnode_put_link (struct v4l2_fwnode_link *link); + +#endif /* _V4L2_FWNODE_H */
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 3/8] v4l: async: Add fwnode match support
In reply to Laurent PinchartHi Laurent,
Quoted 80 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 38 lines · On Thursday 06 Apr 2017 16:12:05 Sakari Ailus wrote:
Add fwnode matching to complement OF node matching. And fwnode may also be an OF node.
--- drivers/media/v4l2-core/v4l2-async.c | 12 ++++++++++++ include/media/v4l2-async.h | 5 +++++ include/media/v4l2-subdev.h | 3 +++ 3 files changed, 20 insertions(+)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-async.cindex 96cc733..384ad5e 100644drivers/media/v4l2-core/v4l2-async.c +5
-0@@ -46,6 +46,11 @@ static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) of_node_full_name(asd->match.of.node)); } +static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) +{ +return sd->fwnode == asd->match.fwnode.fwn; +} +static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) {drivers/media/v4l2-core/v4l2-async.c +0
-0if (!asd->match.custom.match)@@ -80,6 +85,9 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct
v4l2_async_notifier* caseV4L2_ASYNC_MATCH_OF:drivers/media/v4l2-core/v4l2-async.c +3
-0match = match_of;break ; +case V4L2_ASYNC_MATCH_FWNODE : + match = match_fwnode; +break ;default :/* Cannot happen, unless someone breaks us */ WARN_ON (true);drivers/media/v4l2-core/v4l2-async.c int v4l2_async_notifier_register(struct v4l2_device · line 172
Quoted 7 lines
drivers/media/v4l2-core/v4l2-async.c +1
-0@@ -158,6 +166,7 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, case V4L2_ASYNC_MATCH_DEVNAME:case V4L2_ASYNC_MATCH_I2C :case V4L2_ASYNC_MATCH_OF : +case V4L2_ASYNC_MATCH_FWNODE :break ;default : dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev :NULL,
Quoted 29 lines
drivers/media/v4l2-core/v4l2-async.c +3
-0@@ -282,6 +291,9 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)*/ if (!sd->of_node && sd->dev) sd->of_node = sd->dev->of_node; +if (!sd->fwnode && sd->dev) + sd->fwnode = sd->dev->of_node ? + &sd->dev->of_node->fwnode : sd->dev->fwnode;mutex_lock (&list_lock);include/media/v4l2-async.h +2
-0@@ -32,6 +32,7 @@ struct v4l2_async_notifier;* @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address * @V4L2_ASYNC_MATCH_OF: Match will use OF node +* @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node * * This enum is used by the asyncrhronous sub-device logic to define the * algorithm that will be used to match an asynchronous device. @@ -41,6 +42,7 @@ enum v4l2_async_match_type {V4L2_ASYNC_MATCH_DEVNAME ,V4L2_ASYNC_MATCH_I2C ,V4L2_ASYNC_MATCH_OF , + V4L2_ASYNC_MATCH_FWNODE, };
Quoted 11 lines
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 6 lines
include/media/v4l2-async.h +1
-0/** @@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;I'd name this "node". The rationale is that code should be as independent as possible of whether we use
device_nodeorfwnode_handle. Naming both variable "node" helps in that regard, and is in my opinion easier to read. This applies to the other patches in the series too.
What you're proposing doesn't really change that: you'll have to be aware of which one you have anyway. Variables pointing to fwnode_handle are often called fwn as well --- as node is used for struct device_node.
In other words, I prefer to keep it as it is.
Quoted 39 lines
Apart from that,
Quoted 13 lines
include/media/v4l2-async.h +2
-0+ } fwnode; +struct {const char *name; } device_name;struct {include/media/v4l2-subdev.h +0
-0@@ -788,6 +788,8 @@ struct v4l2_subdev_platform_data {* @devnode: subdev device node * @dev: pointer to the physical device, if any * @of_node: The device_node of the subdev, usually the same as Quoted 3 lines
dev->of_node. + * @fwnode: Thefwnode_handleof the subdev, usually the same as
+ * eitherdev->of_node->fwnodeordev->fwnode(whichever is non-NULL).
Quoted 11 lines
* @async_list: Links this subdev to a global
subdev_listor
@notifier->done * list.
* @asd: Pointer to respective &structv4l2_async_subdev.include/media/v4l2-subdev.h +1
-0@@ -819,6 +821,7 @@ struct v4l2_subdev {struct video_device *devnode;struct device *dev;struct device_node *of_node; +struct fwnode_handle *fwnode;struct list_head async_list;struct v4l2_async_subdev *asd;struct v4l2_async_notifier *notifier;Signature · 3 lines
Regards, Laurent Pinchart
Signature · 8 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/8] v4l: async: Add fwnode match support
In reply to Laurent PinchartHi Laurent,
Quoted 7 lines · Laurent Pinchart
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 5 lines
include/media/v4l2-async.h +1
-0@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;Shouldn't this be const ?
I thought the same, but a lot of functions that operate on fwnode_handle take a non-const argument. I attempted changing that, but it starts a cascade of unavoidable changes elsewhere. That's not very well suitable for this patchset.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Laurent Pinchart
maintainerRe: [PATCH v2 3/8] v4l: async: Add fwnode match support
Hi Sakari,
Quoted 9 lines · On Friday 07 Apr 2017 13:45:09 Sakari Ailus wrote:
Quoted 7 lines · Laurent Pinchart
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 5 lines
include/media/v4l2-async.h +1
-0@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;Shouldn't this be const ?
Quoted 4 lines
I thought the same, but a lot of functions that operate on
fwnode_handletake a non-const argument. I attempted changing that, but it starts a cascade of unavoidable changes elsewhere. That's not very well suitable for this patchset.
fwnode is young, we should try to fix it instead of propagating issues :-)
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
maintainerRe: [PATCH v2 2/8] v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to Sakari AilusHi Sakari,
Quoted 25 lines · On Friday 07 Apr 2017 13:36:34 Sakari Ailus wrote:
Quoted 7 lines · Laurent Pinchart
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:04 Sakari Ailus wrote:
The
fwnode_handleis a more generic way than OFdevice_nodeto describe firmware nodes. Instead of the OF API, use more generic fwnode API to obtain the same information.I would mention that this is a copy of
v4l2-of.cwith the OF API replaced with the fwnode API.I'll add that to the description.
Quoted 14 lines
Quoted 14 lines
As the V4L2 fwnode support will be required by a small minority of e.g. ACPI based systems (the same might actually go for OF), make this a module instead of embedding it in the videodev module.
Signed-off-by Sakari Ailus <[email protected]>---
drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fwnode.c | 353 +++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 104 ++++++++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c create mode 100644 include/media/v4l2-fwnode.h
[snip]
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-fwnode.cnew file mode 100644 index 0000000..4f69b11drivers/media/v4l2-core/v4l2-fwnode.c new file +28
-0@@ -0,0 +1,353 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#include <linux/acpi.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/property.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/types.h> + +#include <media/v4l2-fwnode.h> + +static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle*fwn,
drivers/media/v4l2-core/v4l2-fwnode.c new file +1
-0+struct v4l2_fwnode_endpoint *vfwn)
+{Quoted 8 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 36
Quoted 6 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+struct v4l2_fwnode_bus_mipi_csi2 *bus = &vfwn->bus.mipi_csi2; +bool have_clk_lane = false; +unsigned int flags =0 , lanes_used =0 ; +unsigned int i; +u32 v; +int rval;I would have used "ret" instead of "rval" ;-)
Quoted 6 lines
I know. But
1) there's no established convention in the file and
2) "rval" has the benefit is easier to look up; one doesn't find a plethora of "return something". Therefore it is better than "ret" for the purpose.
The solution to that is
/ret\>
(and, of course, switching to vim :-D)
[snip]
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
+/*
+ *v4l2_fwnode_endpoint_free()- free the V4L2 fwnode acquired by
+ *v4l2_fwnode_endpoint_alloc_parse()
+ * @fwn - the V4L2 fwnode the resources of which are to be releasedMayeb "the V4L2 fwnode whose resources are to be released" ?
Quoted 2 lines
+ *
+ * It is safe to call this function with NULL argument or on ans/on an/on a/
Quoted 7 lines
Yes.
Quoted 3 lines
Quoted 1 line
+ * V4L2 fwnode the parsing of which failed.
"whose parsing failed" ?
Any particular reason? Do you like "whose"? :-)
"of which" sounds dubious in this context, but please consult a native English speaker in case of doubt.
[snip]
Quoted 38 lines
Quoted 10 lines
Quoted 4 lines
+/**
+ *v4l2_fwnode_endpoint_parse_link()- parse a link between two endpoints
+ * @node: pointer to the fwnode at the local end of the linkThe parameter is called
__fwn. I believe you should rename it to fwn, otherwise the documentation will look weird.As explained before, you should mention that this is an endpoint fwnode handle.
Agreed.
Quoted 25 lines
Quoted 7 lines
+ * @link: pointer to the V4L2 fwnode link data structure
+ *
+ * Fill the link structure with the local and remote nodes and port numbers.
+ * Thelocal_nodeandremote_nodefields are set to point to the local and
+ * remote port's parent nodes respectively (the port parent node beingQuoted 8 lines
the
+ * parent node of the port node if that node isn't a 'ports' node, or the
+ * grand-parent node of the port node otherwise).
+ *
+ * A reference is taken to both the local and remote nodes, the caller
+ * must usev4l2_fwnode_endpoint_put_link()to drop the references
+ * when done with the link.Just curious, is there a reason to wrap earlier than the 80 columns limit ?
* A reference is taken to both the local and remote nodes, the caller must use
*v4l2_fwnode_endpoint_put_link()to drop the references when done with the
* link.
Quoted 4 lines
Quoted 1 line
would work.
It is like a speed limit, you can perfectly legally drive slower than 80 characters per line, right? :-)
That reminds me of a particular road trip in California that should probably not be mentioned here, but whose participants certainly remember :-)
Quoted 11 lines
Albeit the conditions seem pretty good in this file, I can try pushing it closer to the limit.
Quoted 4 lines
Quoted 2 lines
+ * Return: 0 on success, or
-ENOLINKif the remote fwnode can't be found.Here too you should mention remote endpoint.
Oh yes.
Quoted 1 line
Quoted 1 line
+ */
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to Laurent PinchartHi Laurent,
Quoted 46 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 41 lines · On Thursday 06 Apr 2017 16:12:07 Sakari Ailus wrote:
Switch users of the
v4l2_of_APIs to the more genericv4l2_fwnode_APIs.Existing OF matching continues to be supported. omap3isp and smiapp drivers are converted to fwnode matching as well.
Signed-off-by Sakari Ailus <[email protected]>
am437x/am437x-vpfe.candti-vpe/cal.c---drivers/media/i2c/Kconfig | 9 ++++ drivers/media/i2c/adv7604.c | 7 +-- drivers/media/i2c/mt9v032.c | 7 +-- drivers/media/i2c/ov2659.c | 8 +-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +-- drivers/media/i2c/s5k5baf.c | 6 +-- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 ++++++----- drivers/media/i2c/tc358743.c | 11 ++-- drivers/media/i2c/tvp514x.c | 6 +-- drivers/media/i2c/tvp5150.c | 7 +-- drivers/media/i2c/tvp7002.c | 6 +-- drivers/media/platform/Kconfig | 3 ++ drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +-- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +-- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +-- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +-- drivers/media/platform/omap3isp/isp.c | 71 +++++++++++----------- drivers/media/platform/pxa_camera.c | 7 +-- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +-- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +-- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 ++-- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++++++++++---------- include/media/v4l2-fwnode.h | 4 +- 31 files changed, 176 insertions(+), 134 deletions(-)
Quoted 12 lines
drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 213
Quoted 9 lines
drivers/media/i2c/Kconfig +1
-0@@ -210,6 +210,7 @@ config VIDEO_ADV7604 depends on GPIOLIB || COMPILE_TEST select HDMI select MEDIA_CEC_EDID + select V4L2_FWNODEWhat happens when building the driver on a platform that includes neither OF nor ACPI support ?
You need either in practice, also for the V4L2 fwnode to be meaningful.
Do you have something in particular in mind?
Quoted 8 lines
drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 216
Quoted 4 lines
drivers/media/i2c/Kconfig +0
-0---help--- Support for the Analog Devices ADV7604 video decoder.[snip]
How have you checked that you haven't missed any entry in the
Kconfigfiles ?
I made one Kconfig change per driver. :-)
Quoted 14 lines
[snip]
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 084ecf4a..95850b9 100644drivers/media/platform/omap3isp/isp.c +0
-0[snip]
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-0@@ -2024,43 +2025,42 @@ enum isp_of_phy { ISP_OF_PHY_CSIPHY2, };
Quoted 11 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2032
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +3
-3-static int isp_of_parse_node (struct device *dev,struct device_node *node, -struct isp_async_subdev *isd) +static int isp_fwnode_parse (struct device *dev,struct fwnode_handle *fwn, +struct isp_async_subdev *isd) {struct isp_bus_cfg *buscfg = &isd->bus; -struct v4l2_of_endpoint vep; +struct v4l2_fwnode_endpoint vfwn;vfwn is confusing to me, I think the variable name should show that it refers to an endpoint.
How about adding ep to tell it's an endpoint?
Quoted 9 lines
Quoted 9 lines
drivers/media/platform/omap3isp/isp.c +1
-1unsigned int i;int ret; - ret =v4l2_of_parse_endpoint (node, &vep); + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;
Quoted 5 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2040
Quoted 3 lines
drivers/media/platform/omap3isp/isp.c +1
-2-dev_dbg (dev,"parsing endpoint %s, interface %u\n" , node->full_name, - vep.base.port); +dev_dbg (dev,"interface %u\n" , vfwn.base.port);Is there no way to keep the node name in the error message ?
There's no generic fwnode means to do something similar currently, possibly because I understand ACPI doesn't do that. One could check whether the node is an OF node and then use the full_name field but I wonder if it's worth it.
Quoted 20 lines
[snip]
drivers/media/platform/omap3isp/isp.c static int isp_of_parse_node(struct device *dev, · line 2097
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +1
-2@@ -2094,18 +2094,17 @@ static int isp_of_parse_node(struct device *dev,struct device_node *node, break;default : -dev_warn (dev,"%s: invalid interface %u\n" , node->full_name, - vep.base.port); +dev_warn (dev,"invalid interface %u\n" , vfwn.base.port);Ditto.
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c +0
-0break ; }return 0 ; }
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c static int isp_of_parse_node(struct device *dev, struct device_node *node, · line 2107
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +3
-3-static int isp_of_parse_nodes (struct device *dev, -struct v4l2_async_notifier *notifier) +static int isp_fwnodes_parse (struct device *dev, +struct v4l2_async_notifier *notifier) { -struct device_node *node =NULL ; +struct fwnode_handle *fwn =NULL ;As explained in the review of another patch from the same series, I wouldn't rename the variable.
Most pointers to struct fwnode_handle are actually called fwnode and some fw_node. fwn is just shorter. :-)
There are also cases pointers to struct device_node and struct fwnode_handle are needed in the same function.
Quoted 10 lines
Quoted 3 lines
drivers/media/platform/omap3isp/isp.c +0
-0notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );[snip]
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-0@@ -2219,12 +2220,12 @@ static int isp_probe(struct platform_device *pdev)if (IS_ERR (isp->syscon))return PTR_ERR (isp->syscon);
Quoted 6 lines
drivers/media/platform/omap3isp/isp.c static int isp_probe(struct platform_device *pdev) · line 2224
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +2
-2- ret =of_property_read_u32_index (pdev->dev.of_node,"syscon" ,1 , - &isp->syscon_offset); + ret =of_property_read_u32_index (pdev->dev.of_node, +"syscon" ,1 , &isp->syscon_offset);This change doesn't seem to be needed.
Oh, indeed. Will fix.
Quoted 19 lines
Quoted 9 lines
drivers/media/platform/omap3isp/isp.c +1
-1if (ret)return ret; - ret =isp_of_parse_nodes (&pdev->dev, &isp->notifier); + ret =isp_fwnodes_parse (&pdev->dev, &isp->notifier);if (ret <0 )return ret;[snip]
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/xilinx/xilinx-vipp.cindex feb3b2f..6a2721b 100644drivers/media/platform/xilinx/xilinx-vipp.c +0
-0[snip]
Quoted 12 lines
drivers/media/platform/xilinx/xilinx-vipp.c static int xvip_graph_build_one(struct xvip_composite_device *xdev, · line 108
Quoted 10 lines
drivers/media/platform/xilinx/xilinx-vipp.c +0
-0@@ -103,9 +103,10 @@ static int xvip_graph_build_one(struct
xvip_composite_device*xdev, * the link.drivers/media/platform/xilinx/xilinx-vipp.c +3
-3*/ if (link.local_port >= local->num_pads) { -dev_err (xdev->dev,"invalid port number %u on %s\n" , - link.local_port, link.local_node->full_name); -v4l2_of_put_link (&link); +dev_err (xdev->dev,"invalid port number %u for %s\n" , + link.local_port, +to_of_node (link.local_node)->full_name);This makes me believe that we're missing a
fwnode_full_name()function.
It'd be nice to have that, I agree. What should it do on non-OF nodes? Return a pointers to an empty string?
Quoted 23 lines
Quoted 5 lines
drivers/media/platform/xilinx/xilinx-vipp.c +1
-0+v4l2_fwnode_put_link (&link); ret = -EINVAL ;break ; }[snip]
Quoted 15 lines
include/media/v4l2-fwnode.h +2
-2@@ -17,10 +17,10 @@#ifndef _V4L2_FWNODE_H#define _V4L2_FWNODE_H +#include <linux/errno.h> +#include <linux/fwnode.h> #include <linux/list.h> #include <linux/types.h> -#include <linux/errno.h> -#include <linux/of_graph.h>
Quoted 4 lines
include/media/v4l2-fwnode.h line 25
Quoted 1 line
include/media/v4l2-fwnode.h +0
-0#include <media/v4l2-mediabus.h> This probably belongs to another patch (at least the alphabetical sorting does).
Yes, I'll change it.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to a message not in the archiveHi Sakari,
Quoted 54 lines · On Friday 07 Apr 2017 13:58:06 Sakari Ailus wrote:
Quoted 53 lines · Laurent Pinchart
Quoted 52 lines · On Thursday 06 Apr 2017 16:12:07 Sakari Ailus wrote:
Switch users of the
v4l2_of_APIs to the more genericv4l2_fwnode_APIs.Existing OF matching continues to be supported. omap3isp and smiapp drivers are converted to fwnode matching as well.
Signed-off-by Sakari Ailus <[email protected]>
am437x/am437x-vpfe.candti-vpe/cal.c---drivers/media/i2c/Kconfig | 9 ++++ drivers/media/i2c/adv7604.c | 7 +-- drivers/media/i2c/mt9v032.c | 7 +-- drivers/media/i2c/ov2659.c | 8 +-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +-- drivers/media/i2c/s5k5baf.c | 6 +-- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 ++++++----- drivers/media/i2c/tc358743.c | 11 ++-- drivers/media/i2c/tvp514x.c | 6 +-- drivers/media/i2c/tvp5150.c | 7 +-- drivers/media/i2c/tvp7002.c | 6 +-- drivers/media/platform/Kconfig | 3 ++ drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +-- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +-- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +-- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +-- drivers/media/platform/omap3isp/isp.c | 71 +++++++++--------- drivers/media/platform/pxa_camera.c | 7 +-- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +-- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +-- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 ++-- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++++++++--------- include/media/v4l2-fwnode.h | 4 +- 31 files changed, 176 insertions(+), 134 deletions(-)drivers/media/i2c/Kconfig +0
-0@@ -210,6 +210,7 @@ config VIDEO_ADV7604 depends on GPIOLIB || COMPILE_TEST select HDMI select MEDIA_CEC_EDID
Quoted 8 lines
Quoted 4 lines
drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 215
Quoted 1 line
drivers/media/i2c/Kconfig +1
-0+ select V4L2_FWNODEWhat happens when building the driver on a platform that includes neither OF nor ACPI support ?
You need either in practice, also for the V4L2 fwnode to be meaningful.
Do you have something in particular in mind?
I will obviously need either OF or ACPI to use the fwnode API, but some drivers still support platform data (either on non-OF embedded systems, or when the I2C device is part of a PCI card for instance). Compile-testing is also a use case I'm concerned about.
[snip]
Quoted 25 lines
Quoted 11 lines
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 084ecf4a..95850b9 100644drivers/media/platform/omap3isp/isp.c +0
-0[snip]
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-0@@ -2024,43 +2025,42 @@ enum isp_of_phy { ISP_OF_PHY_CSIPHY2, };Quoted 13 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2032
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +3
-3-static int isp_of_parse_node (struct device *dev,struct device_node *node, - struct isp_async_subdev *isd) +static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, +struct isp_async_subdev *isd) {struct isp_bus_cfg *buscfg = &isd->bus; -struct v4l2_of_endpoint vep; +struct v4l2_fwnode_endpoint vfwn;vfwn is confusing to me, I think the variable name should show that it refers to an endpoint.
Quoted 1 line
How about adding ep to tell it's an endpoint?
I'd name is vep or endpoint.
Quoted 14 lines
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +1
-1unsigned int i;int ret; - ret =v4l2_of_parse_endpoint (node, &vep); + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret;Quoted 5 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2040
Quoted 3 lines
drivers/media/platform/omap3isp/isp.c +1
-2-dev_dbg (dev,"parsing endpoint %s, interface %u\n" , node->full_name, - vep.base.port); +dev_dbg (dev,"interface %u\n" , vfwn.base.port);Is there no way to keep the node name in the error message ?
Quoted 4 lines
There's no generic fwnode means to do something similar currently, possibly because I understand ACPI doesn't do that. One could check whether the node is an OF node and then use the
full_namefield but I wonder if it's worth it.
My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
[snip]
Quoted 11 lines
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c static int isp_of_parse_node(struct device *dev, struct device_node *node, · line 2107
Quoted 7 lines
drivers/media/platform/omap3isp/isp.c +3
-3-static int isp_of_parse_nodes (struct device *dev, -struct v4l2_async_notifier *notifier) +static int isp_fwnodes_parse (struct device *dev, +struct v4l2_async_notifier *notifier) { -struct device_node *node =NULL ; +struct fwnode_handle *fwn =NULL ;As explained in the review of another patch from the same series, I wouldn't rename the variable.
Quoted 5 lines
Most pointers to struct
fwnode_handleare actually called fwnode and somefw_node. fwn is just shorter. :-)There are also cases pointers to struct
device_nodeand structfwnode_handleare needed in the same function.
When both are needed in the same function it certainly makes sense to use more detailed names. My point is that, in a function that exclusively processes fw*, I find calling variables fwn or vfwep more confusing that calling them node or endpoint.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/media/platform/omap3isp/isp.c +0
-0notifier->subdevs =devm_kcalloc ( dev,ISP_MAX_SUBDEVS ,sizeof (*notifier->subdevs),GFP_KERNEL );
[snip]
Quoted 23 lines
Quoted 14 lines
Quoted 5 lines
(quoted diff) +0
-0
b/drivers/media/platform/xilinx/xilinx-vipp.cindex feb3b2f..6a2721b 100644drivers/media/platform/xilinx/xilinx-vipp.c +0
-0[snip]
Quoted 6 lines
drivers/media/platform/xilinx/xilinx-vipp.c +0
-0@@ -103,9 +103,10 @@ static int xvip_graph_build_one(struct
xvip_composite_device*xdev, * the link.drivers/media/platform/xilinx/xilinx-vipp.c +0
-0*/ if (link.local_port >= local->num_pads) {Quoted 8 lines
drivers/media/platform/xilinx/xilinx-vipp.c static int xvip_graph_build_one(struct xvip_composite_device *xdev, · line 108
Quoted 6 lines
drivers/media/platform/xilinx/xilinx-vipp.c +3
-3-dev_err (xdev->dev,"invalid port number %u on %s\n" , - link.local_port, link.local_node->full_name); -v4l2_of_put_link (&link); +dev_err (xdev->dev,"invalid port number %u for %s\n" , + link.local_port, +to_of_node (link.local_node)->full_name);This makes me believe that we're missing a
fwnode_full_name()function.
Quoted 2 lines
It'd be nice to have that, I agree. What should it do on non-OF nodes? Return a pointers to an empty string?
See above.
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/media/platform/xilinx/xilinx-vipp.c +1
-0+v4l2_fwnode_put_link (&link); ret = -EINVAL ;break ; }[snip]
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/8] v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to Laurent PinchartHi Laurent,
Quoted 82 lines · Laurent Pinchart
Hi Sakari,
Quoted 25 lines · On Friday 07 Apr 2017 13:36:34 Sakari Ailus wrote:
Quoted 7 lines · Laurent Pinchart
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:04 Sakari Ailus wrote:
The
fwnode_handleis a more generic way than OFdevice_nodeto describe firmware nodes. Instead of the OF API, use more generic fwnode API to obtain the same information.I would mention that this is a copy of
v4l2-of.cwith the OF API replaced with the fwnode API.I'll add that to the description.
Quoted 14 lines
Quoted 14 lines
As the V4L2 fwnode support will be required by a small minority of e.g. ACPI based systems (the same might actually go for OF), make this a module instead of embedding it in the videodev module.
Signed-off-by Sakari Ailus <[email protected]>---
drivers/media/v4l2-core/Kconfig | 3 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fwnode.c | 353 +++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 104 ++++++++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-fwnode.c create mode 100644 include/media/v4l2-fwnode.h[snip]
Quoted 51 lines
Quoted 38 lines
Quoted 38 lines
(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-fwnode.cnew file mode 100644 index 0000000..4f69b11drivers/media/v4l2-core/v4l2-fwnode.c new file +28
-0@@ -0,0 +1,353 @@ +/* +* V4L2 fwnode binding parsing library +* +* Copyright (c) 2016 Intel Corporation. +* Author: Sakari Ailus <[email protected]> +* +* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. +* Author: Sylwester Nawrocki <[email protected]> +* +* Copyright (C) 2012 Renesas Electronics Corp. +* Author: Guennadi Liakhovetski <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +*/ +#include <linux/acpi.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/property.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/types.h> + +#include <media/v4l2-fwnode.h> + +static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle*fwn,
drivers/media/v4l2-core/v4l2-fwnode.c new file +1
-0+struct v4l2_fwnode_endpoint *vfwn)
+{Quoted 8 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 36
Quoted 6 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +6
-0+struct v4l2_fwnode_bus_mipi_csi2 *bus = &vfwn->bus.mipi_csi2; +bool have_clk_lane = false; +unsigned int flags =0 , lanes_used =0 ; +unsigned int i; +u32 v; +int rval;I would have used "ret" instead of "rval" ;-)
I know. But
1) there's no established convention in the file and
Quoted 8 lines
Quoted 2 lines
2) "rval" has the benefit is easier to look up; one doesn't find a plethora of "return something". Therefore it is better than "ret" for the purpose.
The solution to that is
/ret\>
(and, of course, switching to vim :-D)
What's "\>" for?
I don't think you can convince people to switch to vim this way. :-)
Quoted 17 lines
[snip]
Quoted 14 lines
Quoted 11 lines
Quoted 4 lines
+/*
+ *v4l2_fwnode_endpoint_free()- free the V4L2 fwnode acquired by
+ *v4l2_fwnode_endpoint_alloc_parse()
+ * @fwn - the V4L2 fwnode the resources of which are to be releasedMayeb "the V4L2 fwnode whose resources are to be released" ?
Quoted 2 lines
+ *
+ * It is safe to call this function with NULL argument or on ans/on an/on a/
Yes.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+ * V4L2 fwnode the parsing of which failed.
"whose parsing failed" ?
Any particular reason? Do you like "whose"? :-)
"of which" sounds dubious in this context, but please consult a native English speaker in case of doubt.
"Whose" is the possessive form of "who". Albeit nowadays it could probably be used for other purposes as well.
In my opinion "of which" is perfectly appropriate language here.
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 2/8] v4l: fwnode: Support generic fwnode for parsing standardised properties
In reply to Sakari AilusOn Fri, Apr 07, 2017 at 01:36:34PM +0300, Sakari Ailus wrote:
...
Quoted 5 lines
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c line 308
Quoted 5 lines
drivers/media/v4l2-core/v4l2-fwnode.c new file +5
-0+if (is_of_node (fwn)) { +if (of_node_cmp (to_of_node (fwn)->name,"ports" ) ==0 ) + fwn =fwnode_get_next_parent (fwn); + }else { +/* The "ports" node is always there in ACPI. */
This comment is actually wrong and does not reflect the current implementation anymore. I'll fix that as well.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+ fwn = fwnode_get_next_parent(fwn); + }
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 3/8] v4l: async: Add fwnode match support
In reply to Laurent PinchartQuoted 12 lines · Laurent Pinchart
Hi Sakari,
Quoted 9 lines · On Friday 07 Apr 2017 13:45:09 Sakari Ailus wrote:
Quoted 7 lines · Laurent Pinchart
include/media/v4l2-async.h struct v4l2_async_subdev { · line 63
Quoted 5 lines
include/media/v4l2-async.h +1
-0@@ -58,6 +60,9 @@ struct v4l2_async_subdev {const struct device_node *node; } of;struct { +struct fwnode_handle *fwn;Shouldn't this be const ?
Quoted 6 lines
Quoted 4 lines
I thought the same, but a lot of functions that operate on
fwnode_handletake a non-const argument. I attempted changing that, but it starts a cascade of unavoidable changes elsewhere. That's not very well suitable for this patchset.fwnode is young, we should try to fix it instead of propagating issues :-)
I'm not arguing this would be how I'd prefer things to be. Adding a dependency to another kernel framework would mean postponing the set. This can well be fixed later on as well.
Signature · 6 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 4/8] v4l: async: Provide interoperability between OF and fwnode matching
In reply to Laurent PinchartHi Laurent,
Quoted 11 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:06 Sakari Ailus wrote:
OF and fwnode support are separated in V4L2 and individual drivers may implement one of them. Sub-devices do not match with a notifier expecting sub-devices with fwnodes, nor the other way around.
Shouldn't we instead convert all drivers to fwnode matching ? What's missing after the mass conversion in patch 5/8 ?
A lot of drivers use the OF frame work and thus do not deal with fwnodes directly. I haven't entirely converted them to use the fwnode API since making additional, unnecessary changes increases the likelihood of errors.
Quoted 60 lines
Quoted 60 lines
Fix this by checking for sub-device's
of_nodefield in fwnode match and fwnode field in OF match.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/v4l2-core/v4l2-async.c | 26 +++++++++++++++++++++++--- include/media/v4l2-async.h | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-async.cindex 384ad5e..7f5d804 100644drivers/media/v4l2-core/v4l2-async.c +23
-3@@ -14,6 +14,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/types.h> @@ -40,15 +41,34 @@ static bool match_devname(struct v4l2_subdev *sd,return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); } +static bool fwnode_cmp (struct fwnode_handle *one, +struct fwnode_handle *theother) +{ +if (!one || !theother) +return false; + +if (one->type != theother->type) +return false; + +if (is_of_node (one)) +return !of_node_cmp (of_node_full_name (to_of_node (one)), +of_node_full_name (to_of_node (theother))); +else +return one == theother; +} +static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !of_node_cmp (of_node_full_name (sd->of_node), -of_node_full_name (asd->match.of.node)); +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, +of_fwnode_handle (asd->match.of.node)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwn; +return fwnode_cmp (sd->of_node ? +of_fwnode_handle (sd->of_node) : sd->fwnode, + asd->match.fwnode.fwn); }
Quoted 15 lines
include/media/v4l2-async.h struct v4l2_async_subdev { · line 60
Quoted 11 lines
static bool match_custom(struct
v4l2_subdev*sd, structv4l2_async_subdev
*asd) diff --gita/include/media/v4l2-async.hb/include/media/v4l2-async.hindex 8f552d2..df8b682 100644include/media/v4l2-async.h +1
-1@@ -57,7 +57,7 @@ struct v4l2_async_subdev {enum v4l2_async_match_type match_type; union { struct { - const struct device_node *node; + struct device_node *node;That seems to be a bit of a hack :-( I'd rather make everything const and cast to non-const pointers explicitly where the API requires us to. Or, better, add a
to_of_node_const()function.
I'll see what I can do to the matter, but if you don't mind, I'll base it on this patchset.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to Laurent PinchartHi Laurent,
Quoted 62 lines · Laurent Pinchart
Hi Sakari,
Quoted 59 lines · On Friday 07 Apr 2017 13:58:06 Sakari Ailus wrote:
Quoted 57 lines · Laurent Pinchart
Quoted 47 lines · On Thursday 06 Apr 2017 16:12:07 Sakari Ailus wrote:
Switch users of the
v4l2_of_APIs to the more genericv4l2_fwnode_APIs.Existing OF matching continues to be supported. omap3isp and smiapp drivers are converted to fwnode matching as well.
am437x/am437x-vpfe.candti-vpe/cal.c---drivers/media/i2c/Kconfig | 9 ++++ drivers/media/i2c/adv7604.c | 7 +-- drivers/media/i2c/mt9v032.c | 7 +-- drivers/media/i2c/ov2659.c | 8 +-- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 7 +-- drivers/media/i2c/s5k5baf.c | 6 +-- drivers/media/i2c/smiapp/Kconfig | 1 + drivers/media/i2c/smiapp/smiapp-core.c | 29 ++++++----- drivers/media/i2c/tc358743.c | 11 ++-- drivers/media/i2c/tvp514x.c | 6 +-- drivers/media/i2c/tvp5150.c | 7 +-- drivers/media/i2c/tvp7002.c | 6 +-- drivers/media/platform/Kconfig | 3 ++ drivers/media/platform/am437x/Kconfig | 1 + drivers/media/platform/am437x/am437x-vpfe.c | 8 +-- drivers/media/platform/atmel/Kconfig | 1 + drivers/media/platform/atmel/atmel-isc.c | 8 +-- drivers/media/platform/exynos4-is/Kconfig | 2 + drivers/media/platform/exynos4-is/media-dev.c | 6 +-- drivers/media/platform/exynos4-is/mipi-csis.c | 6 +-- drivers/media/platform/omap3isp/isp.c | 71 +++++++++--------- drivers/media/platform/pxa_camera.c | 7 +-- drivers/media/platform/rcar-vin/Kconfig | 1 + drivers/media/platform/rcar-vin/rcar-core.c | 6 +-- drivers/media/platform/soc_camera/Kconfig | 1 + drivers/media/platform/soc_camera/atmel-isi.c | 7 +-- drivers/media/platform/soc_camera/soc_camera.c | 3 +- drivers/media/platform/ti-vpe/cal.c | 11 ++-- drivers/media/platform/xilinx/Kconfig | 1 + drivers/media/platform/xilinx/xilinx-vipp.c | 59 +++++++++--------- include/media/v4l2-fwnode.h | 4 +- 31 files changed, 176 insertions(+), 134 deletions(-)drivers/media/i2c/Kconfig +0
-0drivers/media/i2c/Kconfig config VIDEO_ADV7604 · line 215
Quoted 6 lines
drivers/media/i2c/Kconfig +1
-0@@ -210,6 +210,7 @@ config VIDEO_ADV7604 depends on GPIOLIB || COMPILE_TEST select HDMI select MEDIA_CEC_EDID + select V4L2_FWNODEWhat happens when building the driver on a platform that includes neither OF nor ACPI support ?
Quoted 8 lines
Quoted 3 lines
You need either in practice, also for the V4L2 fwnode to be meaningful.
Do you have something in particular in mind?
I will obviously need either OF or ACPI to use the fwnode API, but some drivers still support platform data (either on non-OF embedded systems, or when the I2C device is part of a PCI card for instance). Compile-testing is also a use case I'm concerned about.
Ah, so essentially compiling a driver using V4L2 fwnode with both ACPI and OF disabled? I don't know if there are such drivers right now but that's a good point in general.
Quoted 28 lines
[snip]
Quoted 25 lines
Quoted 24 lines
Quoted 4 lines
(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex 084ecf4a..95850b9 100644drivers/media/platform/omap3isp/isp.c +0
-0[snip]
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-0@@ -2024,43 +2025,42 @@ enum isp_of_phy { ISP_OF_PHY_CSIPHY2, };drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2034
Quoted 10 lines
drivers/media/platform/omap3isp/isp.c +3
-3-static int isp_of_parse_node (struct device *dev,struct device_node *node, - struct isp_async_subdev *isd) +static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwn, +struct isp_async_subdev *isd) {struct isp_bus_cfg *buscfg = &isd->bus; -struct v4l2_of_endpoint vep; +struct v4l2_fwnode_endpoint vfwn;vfwn is confusing to me, I think the variable name should show that it refers to an endpoint.
Quoted 3 lines
Quoted 1 line
How about adding ep to tell it's an endpoint?
I'd name is vep or endpoint.
I'll use "vep". "fwnode" for struct fwnode_handle pointers, it is an established practice elsewhere.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/media/platform/omap3isp/isp.c enum isp_of_phy { · line 2040
Quoted 12 lines
drivers/media/platform/omap3isp/isp.c +2
-3unsigned int i;int ret; - ret =v4l2_of_parse_endpoint (node, &vep); + ret =v4l2_fwnode_endpoint_parse (fwn, &vfwn);if (ret)return ret; -dev_dbg (dev,"parsing endpoint %s, interface %u\n" , node->full_name, - vep.base.port); +dev_dbg (dev,"interface %u\n" , vfwn.base.port);Is there no way to keep the node name in the error message ?
Quoted 7 lines
Quoted 4 lines
There's no generic fwnode means to do something similar currently, possibly because I understand ACPI doesn't do that. One could check whether the node is an OF node and then use the
full_namefield but I wonder if it's worth it.My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
There is something, yes, but the ACPI framework currently has no such functionality. I believe it could be implemented though. Cc Mika.
Signature · 8 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 6/8] v4l: media/drv-intf/soc_mediabus.h: include dependent header file
In reply to Laurent PinchartHi Laurent,
Quoted 8 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:08 Sakari Ailus wrote:
media/drv-intf/soc_mediabus.hdoes depend on structv4l2_mbus_configwhich is defined inmedia/v4l2-mediabus.h. Include it.
Quoted 6 lines
Quoted 1 line
Signed-off-by Sakari Ailus <[email protected]>Was this provided indirectly before, through
v4l2-of.hperhaps ? If so, shouldn't this patch be moved before 5/8 ? Apart from that,Reviewed-by Laurent Pinchart <[email protected]>
I tried compiling with and without this patch and see no difference. I could miss something but the more likely case is that the reason why I wrote this patch has ceased to exist. I'll drop it from the set, at least for now.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v2 7/8] docs-rst: media: Switch documentation to V4L2 fwnode API
In reply to Laurent PinchartHi Laurent,
Quoted 17 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 12 lines · On Thursday 06 Apr 2017 16:12:09 Sakari Ailus wrote:
Instead of including the V4L2 OF header in ReST documentation, use the V4L2 fwnode header instead.
Signed-off-by Sakari Ailus <[email protected]>--- Documentation/media/kapi/v4l2-core.rst | 2 +- Documentation/media/kapi/v4l2-fwnode.rst | 3 +++ Documentation/media/kapi/v4l2-of.rst | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Documentation/media/kapi/v4l2-fwnode.rst delete mode 100644 Documentation/media/kapi/v4l2-of.rst
Quoted 12 lines
Documentation/media/kapi/v4l2-core.rst Video2Linux devices · line 22
Quoted 10 lines
(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-core.rstindex e967715..1bc8a14 100644Documentation/media/kapi/v4l2-core.rst +1
-1@@ -19,7 +19,7 @@ Video2Linux devices v4l2-mc v4l2-mediabus v4l2-mem2mem - v4l2-of + v4l2-fwnodeI wonder whether we should keep this alphabetically sorted.
It's not fully sorted at the moment --- see tuner / common below. It'd be good if it was though. I'll add a patch for that.
Quoted 4 lines
Apart from that,
Reviewed-by Laurent Pinchart <[email protected]>
Thanks!
Quoted 28 lines
Quoted 22 lines
Documentation/media/kapi/v4l2-core.rst +0
-0v4l2-rect v4l2-tuner v4l2-common(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-fwnode.rstnew file mode 100644 index 0000000..6c8bccdDocumentation/media/kapi/v4l2-fwnode.rst new file +3
-0@@ -0,0 +1,3 @@ +V4L2 fwnode kAPI +^^^^^^^^^^^^^^^^ +.. kernel-doc:: include/media/v4l2-fwnode.h(quoted diff) +0
-0
b/Documentation/media/kapi/v4l2-of.rstdeleted file mode 100644 index 1ddf76b..0000000Documentation/media/kapi/v4l2-of.rst deleted +0
-3@@ -1,3 +0,0 @@ -V4L2 Open Firmware kAPI -^^^^^^^^^^^^^^^^^^^^^^^ -.. kernel-doc:: include/media/v4l2-of.hSignature · 3 lines
Regards, Laurent Pinchart
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
kbuild test robot
build botRe: [PATCH v2 1/8] v4l: flash led class: Use fwnode_handle instead of device_node in init
In reply to Sakari Ailusreproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross…
Hi Sakari,
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.11-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sakari-Ailus/v4l-flash-led-class-Use-fwnode_handle-instead-of-device_node-in-init/20170408-051139 base: git://linuxtv.org/media_tree.git master config: tile-allmodconfig (attached as .config) compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile
Note: the linux-review/Sakari-Ailus/v4l-flash-led-class-Use-fwnode_handle-instead-of-device_node-in-init/20170408-051139 HEAD 86b5e432c352250540fcd89854fa7ad55ba9e749 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/media/v4l2-core/v4l2-flash-led-class.c: In function 'v4l2_flash_init':
>> drivers/media/v4l2-core/v4l2-flash-led-class.c:642:4: error: 'struct v4l2_subdev' has no member named 'fwnode'
drivers/media/v4l2-core/v4l2-flash-led-class.c:642:2: error: implicit declaration of function 'dev_fwnode' drivers/media/v4l2-core/v4l2-flash-led-class.c:642:25: warning: pointer/integer type mismatch in conditional expression [enabled by default] drivers/media/v4l2-core/v4l2-flash-led-class.c:658:2: error: implicit declaration of function 'fwnode_handle_get' drivers/media/v4l2-core/v4l2-flash-led-class.c:658:22: error: 'struct v4l2_subdev' has no member named 'fwnode' drivers/media/v4l2-core/v4l2-flash-led-class.c:667:22: error: 'struct v4l2_subdev' has no member named 'fwnode' drivers/media/v4l2-core/v4l2-flash-led-class.c: In function 'v4l2_flash_release':
drivers/media/v4l2-core/v4l2-flash-led-class.c:687:22: error: 'struct v4l2_subdev' has no member named 'fwnode'
cc1: some warnings being treated as errors
vim +642 drivers/media/v4l2-core/v4l2-flash-led-class.c
636
637 sd = &v4l2_flash->sd;
638 v4l2_flash->fled_cdev = fled_cdev;
639 v4l2_flash->iled_cdev = iled_cdev;
640 v4l2_flash->ops = ops;
641 sd->dev = dev;
> 642 sd->fwnode = fwn ? fwn : dev_fwnode(led_cdev->dev);
643 v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
644 sd->internal_ops = &v4l2_flash_subdev_internal_ops;
645 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
In reply to Sakari AilusQuoted 5 lines · Sakari Ailus
Quoted 2 lines
My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
There is something, yes, but the ACPI framework currently has no such functionality. I believe it could be implemented though. Cc Mika.
All ACPI node names are 32-bit integers and those are combined to form a path, like \_SB.PCI0.I2C0 and so on. A single ACPI node name cannot be larger than 4 chars, though.
Sakari Ailus
maintainerRe: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
Hi Mika and Laurent,
Quoted 10 lines · Mika Westerberg
Quoted 5 lines · Sakari Ailus
Quoted 2 lines
My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
There is something, yes, but the ACPI framework currently has no such functionality. I believe it could be implemented though. Cc Mika.
All ACPI node names are 32-bit integers and those are combined to form a path, like \_SB.PCI0.I2C0 and so on. A single ACPI node name cannot be larger than 4 chars, though.
On OF, each node has a full_node string attached to it. You could produce a similar string on ACPI, it is not currently done. Adding such a string to each fwnode would require some extra memory as well. I wonder if that could be a Kconfig option.
It would help debugging though.
Providing this information to the user space has been proposed as well:
Devicetree spec defines the syntax for such strings. The user can use that information for recognising a particular device in the system.
The ACPI spec does, too, but it is limited to ACPI nodes and does not address hierarchical data extensions. We'd define the syntax for those ourselves.
Mika: what do you think?
On omap3isp and other drivers --- I think the solution for now should be to assume OF instead. These drivers will be used on OF platforms only anyway.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Re: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
Quoted 25 lines · Sakari Ailus
Hi Mika and Laurent,
Quoted 10 lines · Mika Westerberg
Quoted 5 lines · Sakari Ailus
Quoted 2 lines
My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
There is something, yes, but the ACPI framework currently has no such functionality. I believe it could be implemented though. Cc Mika.
All ACPI node names are 32-bit integers and those are combined to form a path, like \_SB.PCI0.I2C0 and so on. A single ACPI node name cannot be larger than 4 chars, though.
On OF, each node has a
full_nodestring attached to it. You could produce a similar string on ACPI, it is not currently done. Adding such a string to each fwnode would require some extra memory as well. I wonder if that could be aKconfigoption.It would help debugging though.
Providing this information to the user space has been proposed as well:
Devicetree spec defines the syntax for such strings. The user can use that information for recognising a particular device in the system.
Quoted 5 lines
The ACPI spec does, too, but it is limited to ACPI nodes and does not address hierarchical data extensions. We'd define the syntax for those ourselves.
Mika: what do you think?
There is a function acpi_get_name() which you can use to extract the full name of the node. Why not investigate how to use that instead of duplicating the name in an ACPI node.
Sakari Ailus
maintainerRe: [PATCH v2 5/8] v4l: Switch from V4L2 OF not V4L2 fwnode API
Moi,
Quoted 30 lines · Mika Westerberg
Quoted 29 lines · Sakari Ailus
Hi Mika and Laurent,
Quoted 10 lines · Mika Westerberg
Quoted 5 lines · Sakari Ailus
Quoted 2 lines
My ACPI knowledge is limited, but don't ACPI nodes have 4 character names that can be combined in a string to create a full path ?
There is something, yes, but the ACPI framework currently has no such functionality. I believe it could be implemented though. Cc Mika.
All ACPI node names are 32-bit integers and those are combined to form a path, like \_SB.PCI0.I2C0 and so on. A single ACPI node name cannot be larger than 4 chars, though.
On OF, each node has a
full_nodestring attached to it. You could produce a similar string on ACPI, it is not currently done. Adding such a string to each fwnode would require some extra memory as well. I wonder if that could be aKconfigoption.It would help debugging though.
Providing this information to the user space has been proposed as well:
Devicetree spec defines the syntax for such strings. The user can use that information for recognising a particular device in the system.The ACPI spec does, too, but it is limited to ACPI nodes and does not address hierarchical data extensions. We'd define the syntax for those ourselves.
Quoted 6 lines
Quoted 1 line
Mika: what do you think?
There is a function
acpi_get_name()which you can use to extract the full name of the node. Why not investigate how to use that instead of duplicating the name in an ACPI node.
acpi_get_name() would obviously be needed to produce such a string in the first place.
acpi_get_name() puts the string to an existing buffer so it cannot be used as such to return a pointer to a string (e.g. to be used for snprintf()). Also, it only contains the device path of the device. The data extension path matters here, too.
Signature · 4 lines
Regards, Sakari Ailus [email protected]
Re: [PATCH v2 4/8] v4l: async: Provide interoperability between OF and fwnode matching
In reply to a message not in the archiveHi Laurent,
Quoted 12 lines · Sakari Ailus
Hi Laurent,
Quoted 9 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 3 lines · On Thursday 06 Apr 2017 16:12:06 Sakari Ailus wrote:
OF and fwnode support are separated in V4L2 and individual drivers may implement one of them. Sub-devices do not match with a notifier expecting sub-devices with fwnodes, nor the other way around.
Quoted 6 lines
Quoted 2 lines
Shouldn't we instead convert all drivers to fwnode matching ? What's missing after the mass conversion in patch 5/8 ?
A lot of drivers use the OF frame work and thus do not deal with fwnodes directly. I haven't entirely converted them to use the fwnode API since making additional, unnecessary changes increases the likelihood of errors.
Doing the rest of the conversion was less work than I originally had anticipated. The changes are obvious and very similar from driver to driver, perhaps unsurprisingly. Nevertheless, additional testing coverage certainly wouldn't hurt.
Signature · 8 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html