Some V4L2 documentation pending patches
Subsystems (17)
cover Some V4L2 documentation pending patches
This series contain the patches of a /17 and a /24 series of documentation that required non-trivial changes.
Mauro Carvalho Chehab (8):
media: v4l2-device.h: document helper macros
media: v4l2-ioctl.h: convert debug into an enum of bits
media: v4l2-async: simplify v4l2_async_subdev structure
media: v4l2-async: better describe match union at async match struct
media: v4l2-mediabus: convert flags to enums and document them
media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
media: v4l2-subdev: document remaining undocumented functions
media: v4l2-subdev: use kernel-doc markups to document subdev flags
drivers/media/i2c/adv7180.c | 10 +- drivers/media/i2c/ml86v7667.c | 5 +- drivers/media/i2c/mt9m111.c | 8 +- drivers/media/i2c/ov6650.c | 19 +- drivers/media/i2c/soc_camera/imx074.c | 6 +- drivers/media/i2c/soc_camera/mt9m001.c | 10 +- drivers/media/i2c/soc_camera/mt9t031.c | 11 +- drivers/media/i2c/soc_camera/mt9t112.c | 11 +- drivers/media/i2c/soc_camera/mt9v022.c | 16 +- drivers/media/i2c/soc_camera/ov5642.c | 5 +- drivers/media/i2c/soc_camera/ov772x.c | 10 +- drivers/media/i2c/soc_camera/ov9640.c | 10 +- drivers/media/i2c/soc_camera/ov9740.c | 10 +- drivers/media/i2c/soc_camera/rj54n1cb0c.c | 12 +- drivers/media/i2c/soc_camera/tw9910.c | 13 +- drivers/media/i2c/tc358743.c | 10 +- drivers/media/i2c/tvp5150.c | 6 +- drivers/media/platform/am437x/am437x-vpfe.c | 6 +- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- drivers/media/platform/davinci/vpif_capture.c | 4 +- drivers/media/platform/exynos4-is/media-dev.c | 4 +- drivers/media/platform/pxa_camera.c | 10 +- drivers/media/platform/qcom/camss-8x16/camss.c | 2 +- drivers/media/platform/rcar-vin/rcar-core.c | 6 +- drivers/media/platform/rcar-vin/rcar-dma.c | 4 +- drivers/media/platform/rcar_drif.c | 4 +- .../platform/soc_camera/sh_mobile_ceu_camera.c | 2 +- drivers/media/platform/soc_camera/soc_camera.c | 5 +- .../platform/soc_camera/soc_camera_platform.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 2 +- drivers/media/v4l2-core/v4l2-async.c | 16 +- drivers/media/v4l2-core/v4l2-dev.c | 18 +- drivers/media/v4l2-core/v4l2-fwnode.c | 15 +- drivers/media/v4l2-core/v4l2-ioctl.c | 7 +- drivers/staging/media/imx/imx-media-dev.c | 4 +- include/media/v4l2-async.h | 33 ++- include/media/v4l2-device.h | 246 ++++++++++++++++++--- include/media/v4l2-fwnode.h | 4 +- include/media/v4l2-ioctl.h | 33 +-- include/media/v4l2-mediabus.h | 145 ++++++++---- include/media/v4l2-subdev.h | 143 +++++++++--- 45 files changed, 632 insertions(+), 265 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/8 media: v4l2-device.h: document helper macros
There are several macros that aren't documented using kernel-docs markups.
Document them.
While here, add cross-references to structs on this file.
--- include/media/v4l2-device.h | 246 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 211 insertions(+), 35 deletions(-)
include/media/v4l2-device.h +211 -35
@@ -38,7 +38,7 @@ struct v4l2_ctrl_handler;* @lock: lock this struct; can be used by the driver as well * if this struct is embedded into a larger struct. * @name: unique device name, by default the driver name + bus ID -* @notify: notify callback called by some sub-devices. +* @notify: notify operation called by some sub-devices. * @ctrl_handler: The control handler. May be %NULL. * @prio: Device's priority state * @ref: Keep track of the references to this struct.
@@ -56,7 +56,6 @@ struct v4l2_ctrl_handler;* #) @dev->driver_data points to this struct. * #) @dev might be %NULL if there is no parent device */ -struct v4l2_device {struct device *dev;#if defined(CONFIG_MEDIA_CONTROLLER )
@@ -166,7 +165,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev);* v4l2_device_register_subdev - Registers a subdev with a v4l2 device. * * @v4l2_dev: pointer to struct &v4l2_device -* @sd: pointer to struct &v4l2_subdev +* @sd: pointer to &struct v4l2_subdev * * While registered, the subdev module is marked as in-use. *
@@ -179,7 +178,7 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,/** * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device. * -* @sd: pointer to struct &v4l2_subdev +* @sd: pointer to &struct v4l2_subdev * * .. note :: *
@@ -201,7 +200,7 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);/** * v4l2_subdev_notify - Sends a notification to v4l2_device. * -* @sd: pointer to struct &v4l2_subdev +* @sd: pointer to &struct v4l2_subdev * @notification: type of notification. Please notice that the notification * type is driver-specific. * @arg: arguments for the notification. Those are specific to each
@@ -214,13 +213,43 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, sd->v4l2_dev->notify (sd, notification, arg); } -/* Iterate over all subdevs. */ +/* Helper macros to iterate over all subdevs. */ + +/** +* v4l2_device_for_each_subdev - Helper macro that interates over all +* sub-devices of a given &v4l2_device. +* +* @sd: pointer that will be filled by the macro with all +* &struct v4l2_subdev pointer used as an iterator by the loop. +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* +* This macro iterates over all sub-devices owned by the @v4l2_dev device. +* It acts as a for loop iterator and executes the next statement with +* the @sd variable pointing to each sub-device in turn. +*/ #define v4l2_device_for_each_subdev (sd, v4l2_dev) \ list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) -/* Call the specified callback for all subdevs matching the condition. -Ignore any errors. Note that you cannot add or delete a subdev -while walking the subdevs list. */ +/** +* __v4l2_device_call_subdevs_p - Calls the specified operation for +* all subdevs matching the condition. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @sd: pointer that will be filled by the macro with all +* &struct v4l2_subdev pointer used as an iterator by the loop. +* @cond: condition to be match +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Ignore any errors. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ do { \ list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
@@ -228,6 +257,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, (sd)->ops->o->f((sd) , ##args); \ } while (0) +/** +* __v4l2_device_call_subdevs - Calls the specified operation for +* all subdevs matching the condition. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @cond: condition to be match +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Ignore any errors. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ do { \ struct v4l2_subdev *__sd; \
@@ -236,10 +283,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, f , ##args); \ } while (0) -/* Call the specified callback for all subdevs matching the condition. -If the callback returns an error other than 0 or -ENOIOCTLCMD, then -return with that error code. Note that you cannot add or delete a -subdev while walking the subdevs list. */ +/** +* __v4l2_device_call_subdevs_until_err_p - Calls the specified operation for +* all subdevs matching the condition. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @sd: pointer that will be filled by the macro with all +* &struct v4l2_subdev sub-devices associated with @v4l2_dev. +* @cond: condition to be match +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Return: +* +* If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` +* for any subdevice, then abort and return with that error code, zero +* otherwise. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ ({ \ long __err = 0; \
@@ -253,6 +320,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, (__err == -ENOIOCTLCMD ) ?0 : __err; \ }) +/** +* __v4l2_device_call_subdevs_until_err - Calls the specified operation for +* all subdevs matching the condition. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @cond: condition to be match +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Return: +* +* If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` +* for any subdevice, then abort and return with that error code, +* zero otherwise. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ ({ \ struct v4l2_subdev *__sd; \
@@ -260,9 +349,26 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, f , ##args); \ }) -/* Call the specified callback for all subdevs matching grp_id (if 0, then -match them all). Ignore any errors. Note that you cannot add or delete -a subdev while walking the subdevs list. */ +/** +* v4l2_device_call_all - Calls the specified operation for +* all subdevs matching the &v4l2_subdev.grp_id, as assigned +* by the bridge driver. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpid: &struct v4l2_subdev->grp_id group ID to match. +* Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Ignore any errors. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ do { \ struct v4l2_subdev *__sd; \
@@ -272,10 +378,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ } while (0) -/* Call the specified callback for all subdevs matching grp_id (if 0, then -match them all). If the callback returns an error other than 0 or --ENOIOCTLCMD, then return with that error code. Note that you cannot -add or delete a subdev while walking the subdevs list. */ +/** +* v4l2_device_call_until_err - Calls the specified operation for +* all subdevs matching the &v4l2_subdev.grp_id, as assigned +* by the bridge driver, until an error occurs. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpid: &struct v4l2_subdev->grp_id group ID to match. +* Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Return: +* +* If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` +* for any subdevice, then abort and return with that error code, +* zero otherwise. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. +*/ #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ ({ \ struct v4l2_subdev *__sd; \
@@ -284,10 +410,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ }) -/* -* Call the specified callback for all subdevs where grp_id & grpmsk != 0 -* (if grpmsk == `0, then match them all). Ignore any errors. Note that you -* cannot add or delete a subdev while walking the subdevs list. +/** +* v4l2_device_mask_call_all - Calls the specified operation for +* all subdevices where a group ID matches a specified bitmask. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id +* group ID to be matched. Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Ignore any errors. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. */ #define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \ do { \
@@ -298,11 +438,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ } while (0) -/* -* Call the specified callback for all subdevs where grp_id & grpmsk != 0 -* (if grpmsk == 0, then match them all). If the callback returns an error -* other than 0 or %-ENOIOCTLCMD, then return with that error code. Note that -* you cannot add or delete a subdev while walking the subdevs list. +/** +* v4l2_device_mask_call_until_err - Calls the specified operation for +* all subdevices where a group ID matches a specified bitmask. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id +* group ID to be matched. Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. +* +* Return: +* +* If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` +* for any subdevice, then abort and return with that error code, +* zero otherwise. +* +* Note: subdevs cannot be added or deleted while walking +* the subdevs list. */ #define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \ ({ \
@@ -312,9 +469,19 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ }) -/* -* Does any subdev with matching grpid (or all if grpid == 0) has the given -* op? + +/** +* v4l2_device_has_op - checks if any subdev with matching grpid has a +* given ops. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpid: &struct v4l2_subdev->grp_id group ID to match. +* Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. */ #define v4l2_device_has_op (v4l2_dev, grpid, o, f) \ ({ \
@@ -331,9 +498,18 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, __result; \ }) -/* -* Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given -* op? +/** +* v4l2_device_mask_has_op - checks if any subdev with matching group +* mask has a given ops. +* +* @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. +* @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id +* group ID to be matched. Use 0 to match them all. +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of operations functions. +* @f: operation function that will be called if @cond matches. +* The operation functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. */ #define v4l2_device_mask_has_op (v4l2_dev, grpmsk, o, f) \ ({ \
Signature · 1 line
2.14.3
PATCH 2/8 media: v4l2-ioctl.h: convert debug into an enum of bits
In reply to Mauro Carvalho ChehabThe V4L2_DEV_DEBUG_IOCTL macros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.
So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
In order to avoid possible conflicts, rename them from V4L2_DEV_DEBUG_foo to V4L2_DEBUG_foo.
--- drivers/media/v4l2-core/v4l2-dev.c | 18 +++++++++--------- drivers/media/v4l2-core/v4l2-ioctl.c | 7 ++++--- include/media/v4l2-ioctl.h | 33 +++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 26 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +9 -9
@@ -307,8 +307,8 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,return -EINVAL ;if (video_is_registered (vdev)) ret = vdev->fops->read (filp, buf, sz, off); -if ((vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) && - (vdev->dev_debug &V4L2_DEV_DEBUG_STREAMING )) +if ((vdev->dev_debug &BIT (V4L2_DEBUG_FOP )) && + (vdev->dev_debug &BIT (V4L2_DEBUG_STREAMING )))printk (KERN_DEBUG "%s: read: %zd (%d)\n" ,video_device_node_name (vdev), sz, ret);return ret;
@@ -324,8 +324,8 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,return -EINVAL ;if (video_is_registered (vdev)) ret = vdev->fops->write (filp, buf, sz, off); -if ((vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) && - (vdev->dev_debug &V4L2_DEV_DEBUG_STREAMING )) +if ((vdev->dev_debug &BIT (V4L2_DEBUG_FOP )) && + (vdev->dev_debug &BIT (V4L2_DEBUG_STREAMING )))printk (KERN_DEBUG "%s: write: %zd (%d)\n" ,video_device_node_name (vdev), sz, ret);return ret;
@@ -340,7 +340,7 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)return DEFAULT_POLLMASK ;if (video_is_registered (vdev)) res = vdev->fops->poll (filp, poll); -if (vdev->dev_debug &V4L2_DEV_DEBUG_POLL ) +if (vdev->dev_debug &BIT (V4L2_DEBUG_POLL ))printk (KERN_DEBUG "%s: poll: %08x\n" ,video_device_node_name (vdev), res);return res;
@@ -381,7 +381,7 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp,if (!video_is_registered (vdev))return -ENODEV ; ret = vdev->fops->get_unmapped_area (filp, addr, len, pgoff, flags); -if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) +if (vdev->dev_debug &BIT (V4L2_DEBUG_FOP ))printk (KERN_DEBUG "%s: get_unmapped_area (%d)\n" ,video_device_node_name (vdev), ret);return ret;
@@ -397,7 +397,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)return -ENODEV ;if (video_is_registered (vdev)) ret = vdev->fops->mmap (filp, vm); -if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) +if (vdev->dev_debug &BIT (V4L2_DEBUG_FOP ))printk (KERN_DEBUG "%s: mmap (%d)\n" ,video_device_node_name (vdev), ret);return ret;
@@ -427,7 +427,7 @@ static int v4l2_open(struct inode *inode, struct file *filp) ret = -ENODEV ; } -if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) +if (vdev->dev_debug &BIT (V4L2_DEBUG_FOP ))printk (KERN_DEBUG "%s: open (%d)\n" ,video_device_node_name (vdev), ret);/* decrease the refcount in case of an error */
@@ -444,7 +444,7 @@ static int v4l2_release(struct inode *inode, struct file *filp)if (vdev->fops->release) ret = vdev->fops->release (filp); -if (vdev->dev_debug &V4L2_DEV_DEBUG_FOP ) +if (vdev->dev_debug &BIT (V4L2_DEBUG_FOP ))printk (KERN_DEBUG "%s: release\n" ,video_device_node_name (vdev));
drivers/media/v4l2-core/v4l2-ioctl.c +4 -3
@@ -2760,15 +2760,16 @@ static long __video_do_ioctl(struct file *file, } done: -if (dev_debug & (V4L2_DEV_DEBUG_IOCTL |V4L2_DEV_DEBUG_IOCTL_ARG )) { -if (!(dev_debug &V4L2_DEV_DEBUG_STREAMING ) && +if (dev_debug & (BIT (V4L2_DEBUG_IOCTL ) + |BIT (V4L2_DEBUG_IOCTL_ARG ))) { +if (!(dev_debug &BIT (V4L2_DEBUG_STREAMING )) && (cmd ==VIDIOC_QBUF || cmd ==VIDIOC_DQBUF ))return ret;v4l_printk_ioctl (video_device_node_name (vfd), cmd);if (ret <0 )pr_cont (": error %ld" , ret); -if (!(dev_debug &V4L2_DEV_DEBUG_IOCTL_ARG )) +if (!(dev_debug &BIT (V4L2_DEBUG_IOCTL_ARG )))pr_cont ("\n" );else if (_IOC_DIR (cmd) == _IOC_NONE) info->debug (arg, write_only);
include/media/v4l2-ioctl.h +19 -14
@@ -589,20 +589,25 @@ struct v4l2_ioctl_ops { }; -/* v4l debugging and diagnostics */ - -/* Device debug flags to be used with the video device debug attribute */ - -/* Just log the ioctl name + error code */ -#define V4L2_DEV_DEBUG_IOCTL 0x01 -/* Log the ioctl name arguments + error code */ -#define V4L2_DEV_DEBUG_IOCTL_ARG 0x02 -/* Log the file operations open, release, mmap and get_unmapped_area */ -#define V4L2_DEV_DEBUG_FOP 0x04 -/* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */ -#define V4L2_DEV_DEBUG_STREAMING 0x08 -/* Log poll() */ -#define V4L2_DEV_DEBUG_POLL 0x10 +/** +* enum v4l2_debug_bits - Device debug bits to be used with the video +* device debug attribute +* +* @V4L2_DEBUG_IOCTL: Just log the ioctl name + error code. +* @V4L2_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code. +* @V4L2_DEBUG_FOP: Log the file operations and open, release, +* mmap and get_unmapped_area syscalls. +* @V4L2_DEBUG_STREAMING: Log the read and write syscalls and +* :c:ref:`VIDIOC_[Q|DQ]BUF <VIDIOC_QBUF>` ioctls. +* @V4L2_DEBUG_POLL: Log poll syscalls. +*/ +enum v4l2_debug_bits { +V4L2_DEBUG_IOCTL =0 , +V4L2_DEBUG_IOCTL_ARG =1 , +V4L2_DEBUG_FOP =2 , +V4L2_DEBUG_STREAMING =3 , +V4L2_DEBUG_POLL =4 , +};/* Video standard functions */
Signature · 1 line
2.14.3
Re: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Hi Mauro,
Quoted 6 lines · Mauro Carvalho Chehab
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the BIT() macro. There are no benefits that I can see from here but the approach brings additional
risks: misuse of the flags and mimicing the same risky pattern.
I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
Another point I want to make is that the uAPI definitions cannot be
changed: enums are thus an option in kAPI only. Improved KernelDoc tools would thus also allow improving uAPI macro documentation --- which is more important anyway.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected]
Laurent Pinchart
maintainerRe: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Quoted 15 lines · On Tuesday, 19 December 2017 13:39:27 EET Sakari Ailus wrote:
Hi Mauro,
Quoted 6 lines · Mauro Carvalho Chehab
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the
BIT()macro. There are no benefits that I can see from here but the approach brings additional
risks: misuse of the flags and mimicing the same risky pattern.
Quoted 6 lines
I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
That's my main concern too. We really must not sacrifice code readability or writing ease in order to work around limitations of the documentation system. For this reason I'm strongly opposed to patches 2 and 5 in this series.
Quoted 2 lines
Another point I want to make is that the uAPI definitions cannot be
changed: enums are thus an option in kAPI only.
And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
Quoted 2 lines
Improved KernelDoc tools would thus also allow improving uAPI macro documentation --- which is more important anyway.
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
maintainerRe: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Quoted 20 lines · On Tuesday, 19 December 2017 16:02:02 EET Laurent Pinchart wrote:
Quoted 19 lines · On Tuesday, 19 December 2017 13:39:27 EET Sakari Ailus wrote:
Hi Mauro,
Quoted 6 lines · Mauro Carvalho Chehab
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the
BIT()macro. There are no benefits that I can see from here but the approach brings additional
risks: misuse of the flags and mimicing the same risky pattern.I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
Quoted 8 lines
Quoted 3 lines
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
That's my main concern too. We really must not sacrifice code readability or writing ease in order to work around limitations of the documentation system. For this reason I'm strongly opposed to patches 2 and 5 in this series.
And I forgot to mention patch 8/8. Let's drop those three and improve the documentation system instead.
Quoted 9 lines
Quoted 2 lines
Another point I want to make is that the uAPI definitions cannot be
changed: enums are thus an option in kAPI only.And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
Quoted 2 lines
Improved KernelDoc tools would thus also allow improving uAPI macro documentation --- which is more important anyway.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Em Tue, 19 Dec 2017 16:05:46 +0200
Laurent Pinchart <[email protected]> escreveu:
Quoted 25 lines · On Tuesday, 19 December 2017 16:02:02 EET Laurent Pinchart wrote:
Quoted 24 lines · On Tuesday, 19 December 2017 13:39:27 EET Sakari Ailus wrote:
Quoted 22 lines
Hi Mauro,
Quoted 6 lines · Mauro Carvalho Chehab
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the
BIT()macro. There are no benefits that I can see from here but the approach brings additional
risks: misuse of the flags and mimicing the same risky pattern.I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
Quoted 7 lines
Quoted 4 lines
That's my main concern too. We really must not sacrifice code readability or writing ease in order to work around limitations of the documentation system. For this reason I'm strongly opposed to patches 2 and 5 in this series.
And I forgot to mention patch 8/8. Let's drop those three and improve the documentation system instead.
Are you volunteering yourself to write the kernel-doc patches? :-)
Thanks,
Mauro
Laurent Pinchart
maintainerRe: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Hi Mauro,
Quoted 30 lines · On Tuesday, 19 December 2017 17:34:46 EET Mauro Carvalho Chehab wrote:
Em Tue, 19 Dec 2017 16:05:46 +0200 Laurent Pinchart escreveu:
Quoted 29 lines · On Tuesday, 19 December 2017 16:02:02 EET Laurent Pinchart wrote:
Quoted 27 lines · On Tuesday, 19 December 2017 13:39:27 EET Sakari Ailus wrote:
Quoted 14 lines · Mauro Carvalho Chehab
Quoted 6 lines
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the
BIT()macro. There are no benefits that I can see from here but the approach brings additional risks: misuse of the flags and mimicing the same risky pattern.Quoted 7 lines
I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
That's my main concern too. We really must not sacrifice code readability or writing ease in order to work around limitations of the documentation system. For this reason I'm strongly opposed to patches 2 and 5 in this series.
Quoted 4 lines
Quoted 2 lines
And I forgot to mention patch 8/8. Let's drop those three and improve the documentation system instead.
Are you volunteering yourself to write the kernel-doc patches? :-)
I thought you were the expert in this field, given the number of documentation patches that you have merged in the kernel ? :-)
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Em Wed, 20 Dec 2017 12:47:23 +0200
Laurent Pinchart <[email protected]> escreveu:
Quoted 33 lines
Hi Mauro,
Quoted 30 lines · On Tuesday, 19 December 2017 17:34:46 EET Mauro Carvalho Chehab wrote:
Em Tue, 19 Dec 2017 16:05:46 +0200 Laurent Pinchart escreveu:
Quoted 29 lines · On Tuesday, 19 December 2017 16:02:02 EET Laurent Pinchart wrote:
Quoted 27 lines · On Tuesday, 19 December 2017 13:39:27 EET Sakari Ailus wrote:
Quoted 14 lines · Mauro Carvalho Chehab
Quoted 6 lines
The
V4L2_DEV_DEBUG_IOCTLmacros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward.So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it.
The pattern of using bits for flags is a well established one and I wouldn't deviate from that by requiring the use of the
BIT()macro. There are no benefits that I can see from here but the approach brings additional risks: misuse of the flags and mimicing the same risky pattern.Quoted 7 lines
I'd also like to echo Laurent's concern that code is being changed in odd ways and not for itself, but due to deficiencies in documentation tools.
I believe the tooling has to be improved to address this properly. That only needs to done once, compared to changing all flag definitions to enums.
That's my main concern too. We really must not sacrifice code readability or writing ease in order to work around limitations of the documentation system. For this reason I'm strongly opposed to patches 2 and 5 in this series.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
And I forgot to mention patch 8/8. Let's drop those three and improve the documentation system instead.
Are you volunteering yourself to write the kernel-doc patches? :-)
I thought you were the expert in this field, given the number of documentation patches that you have merged in the kernel ? :-)
c/c linux-doc, as this kind of discussion should be happening there.
Let me recap your proposal here, for the others from linux-doc to understand this reply:
Em Mon, 18 Dec 2017 17:32:11 +0200
Laurent Pinchart <[email protected]> escreveu:
Quoted 75 lines
Hi Mauro,
Quoted 51 lines · On Monday, 18 December 2017 17:13:26 EET Mauro Carvalho Chehab wrote:
Em Fri, 13 Oct 2017 15:38:11 +0300 Laurent Pinchart escreveu:
Quoted 8 lines · On Thursday, 28 September 2017 00:46:51 EEST Mauro Carvalho Chehab wrote:
Quoted 2 lines
Currently, there's no way to document #define foo <value> with kernel-doc. So, convert it to an enum, and document.
The documentation seems fine to me (except for one comment below). However, converting macros to an enum just to work around a defect of the documentation system doesn't seem like a good idea to me. I'd rather find a way to document macros.
I agree that this limitation should be fixed.
Yet, in this specific case where we have an "array" of defines, all associated to the same field (even being a bitmask), and assuming that we would add a way for kernel-doc to parse this kind of defines (not sure how easy/doable would be), then, in order to respect the way kernel-doc markup is, the documentation for those macros would be:
/**
* define: Just log the ioctl name + error code
*/
#defineV4L2_DEV_DEBUG_IOCTL0x01
/**
* define: Log the ioctl name arguments + error code
*/
#defineV4L2_DEV_DEBUG_IOCTL_ARG0x02
/**
* define: Log the file operations open, release, mmap andget_unmapped_area
*/
#defineV4L2_DEV_DEBUG_FOP0x04
/**
* define: Log the read and write file operations and the VIDIOC_(D)QBUF
ioctls */
#defineV4L2_DEV_DEBUG_STREAMING0x08IMHO, this is a way easier to read/understand by humans, and a way more coincise:
/**
* enumv4l2_debug_flags- Device debug flags to be used with the video
* device debug attribute
*
* @V4L2_DEV_DEBUG_IOCTL: Just log the ioctl name + error code.
* @V4L2_DEV_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code.
* @V4L2_DEV_DEBUG_FOP: Log the file operations and open, release,
* mmap andget_unmapped_areasyscalls.
* @V4L2_DEV_DEBUG_STREAMING: Log the read and write syscalls and
* :c:ref:VIDIOC_[Q|DQ]BUFF <VIDIOC_QBUF>ioctls.
*/Quoted 4 lines
It also underlines the aspect that those names are grouped altogether.
So, IMHO, the main reason to place them inside an enum and document as such is that it looks a way better for humans to read.
As we're talking about extending kerneldoc to document macros, we're free to decide on a format that would make it easy and clear. Based on your above example, we could write it
/**
* definev4l2_debug_flags- Device debug flags to be used with the video
* device debug attribute
*
* @V4L2_DEV_DEBUG_IOCTL: Just log the ioctl name + error code.
* @V4L2_DEV_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code.
* @V4L2_DEV_DEBUG_FOP: Log the file operations and open, release,
* mmap andget_unmapped_areasyscalls.
* @V4L2_DEV_DEBUG_STREAMING: Log the read and write syscalls and
* :c:ref:VIDIOC_[Q|DQ]BUFF <VIDIOC_QBUF>ioctls.
*/
Quoted 3 lines
That would be simple, clear, and wouldn't require a code change to workaround a limitation of the documentation system.
I could volunteer myself to write a patch that would just parse a single define when I have some time for that, and after finishing to document other things that don't depend on it.
However, I won't volunteer to add a patch that would artificially group #defines on a single kernel-doc markup, because:
1) I don't believe that this is the right solution. When several name macros should be grouped altogether, C provides an specific syntax for it: enum;
2) the patch will likely be very complex;
3) the define "grouping" logic would be based on hints.
Let me explain (3) a little better. Right now, kernel-doc common logic removes any comments and blank lines when processing a single markup, like struct, enum, function, etc. It should very likely need to do the same for #defines.
Using your proposed, syntax, please assume the following fictional (but based on real code) example:
/** * define v4l2_debug_flags - Device debug flags to be used with the video * device debug attribute * * @V4L2_DEV_DEBUG_IOCTL: Just log the ioctl name + error code. * @V4L2_DEV_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code. * @V4L2_DEV_DEBUG_FOP: Log the file operations and open, release, * mmap and get_unmapped_area syscalls. * @V4L2_DEV_DEBUG_STREAMING: Log the read and write syscalls and * :c:ref:`VIDIOC_[Q|DQ]BUFF <VIDIOC_QBUF>` ioctls. */ /* ioctl debug macros */ #define V4L2_DEV_DEBUG_IOCTL 0x01 #define V4L2_DEV_DEBUG_IOCTL_ARG 0x02 /* streaming debug macros */ #define V4L2_DEV_DEBUG_FOP 0x04 #define V4L2_DEV_DEBUG_STREAMING 0x08 #define CEC_NUM_CORE_EVENTS 2 #define CEC_NUM_EVENTS CEC_EVENT_PIN_CEC_HIGH
The V4L_DEV_DEBUG_* macros will be properly documented using your notation.
However, how the kernel-doc logic will know when to stop grouping defines?
It should be reminded that, if later someone adds a new V4L_DEV_DEBUG_FOO (either after V4L2_DEV_DEBUG_STREAMING or before it), we want a warning to be generated, because something that belongs to this define "group" was added without documentation.
It might be parsing by name, but that would break if someone ever adds a macro like: V4L2_NODEV_DEBUG, it won't work (we do have some "namespaces" like that). It would also fail if someone adds an unrelated macro that would start with V4L2_DEV_DEBUG_.
Now, assume that, sometime in the future, we decide to also document CEC_NUM_CORE_EVENTS, because it is now part of a kAPI, but we don't want to document CEC_NUM_EVENTS, with is just an ancillary macro to be used internally. The "group" define syntax won't fit.
In summary, trying to artificially group #defines for documentation is a very dirty hack. We should really use enums on all kAPI cases where we have different symbols that should be grouped altogether.
Regards,
Mauro
Sakari Ailus
maintainerRe: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
In reply to Laurent PinchartHi Laurent,
Quoted 3 lines · Laurent Pinchart
And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
I guess we have an argeement on that, enums are a no-go for uAPI, for reasons not related to the topic at hand.
Signature · 2 lines
Sakari Ailus [email protected]
Re: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Em Tue, 19 Dec 2017 16:12:35 +0200
Sakari Ailus <[email protected]> escreveu:
Quoted 9 lines
Hi Laurent,
Quoted 3 lines · Laurent Pinchart
And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
I guess we have an argeement on that, enums are a no-go for uAPI, for reasons not related to the topic at hand.
Huh? We're not talking about uAPI. This is kAPI. Using enums there is OK.
Thanks,
Mauro
Laurent Pinchart
maintainerRe: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Hi Mauro,
Quoted 10 lines · On Tuesday, 19 December 2017 17:37:58 EET Mauro Carvalho Chehab wrote:
Em Tue, 19 Dec 2017 16:12:35 +0200 Sakari Ailus escreveu:
Quoted 7 lines · Laurent Pinchart
Quoted 3 lines
And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
I guess we have an argeement on that, enums are a no-go for uAPI, for reasons not related to the topic at hand.
Huh? We're not talking about uAPI. This is kAPI. Using enums there is OK.
Sure, there's no disagreement about that. The point was that, as both uAPI and kAPI should be documented, and we can't use enums for uAPI, we need a way to document non-enum types, which we could then use to document the kAPI the same way.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits
Em Tue, 19 Dec 2017 19:17:12 +0200
Laurent Pinchart <[email protected]> escreveu:
Quoted 9 lines
Hi Mauro,
Quoted 6 lines · On Tuesday, 19 December 2017 17:37:58 EET Mauro Carvalho Chehab wrote:
Em Tue, 19 Dec 2017 16:12:35 +0200 Sakari Ailus escreveu:
Quoted 5 lines · Laurent Pinchart
Quoted 3 lines
And furthermore using enum types in the uAPI is a bad idea as the enum size is architecture-dependent. That's why we use integer types in structures used as ioctl arguments.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I guess we have an argeement on that, enums are a no-go for uAPI, for reasons not related to the topic at hand.
Huh? We're not talking about uAPI. This is kAPI. Using enums there is OK.
Sure, there's no disagreement about that.
The point was that, as both uAPI and kAPI should be documented,
No disagreement here...
Quoted 1 line
and we can't use enums for uAPI,
Err... we actually do use enums on uAPI... videodev2.h is full of it. What we can't do is to use enums on ioctls. So, all such enums are replaced by u32 at the ioctl calls.
Ok, this is not elegant (and it happened for historic reasons - we're now avoiding it at all costs), but that's the way it is.
The fact is - for uAPI - we have enums and defines, and both are documented.
Quoted 1 line
we need a way to document non-enum types,
We have already a way to document all uAPI data structures, including enums and defines.
Quoted 1 line
which we could then use to document the kAPI the same way.
Let's not mix subjects. This patch series is all about kAPI.
Specifically, we're talking about this change:
-/* Just log the ioctl name + error code */
-#define V4L2_DEV_DEBUG_IOCTL 0x01
-/* Log the ioctl name arguments + error code */
-#define V4L2_DEV_DEBUG_IOCTL_ARG 0x02
-/* Log the file operations open, release, mmap and get_unmapped_area */
-#define V4L2_DEV_DEBUG_FOP 0x04
-/* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */
-#define V4L2_DEV_DEBUG_STREAMING 0x08
+/**
+ * enum v4l2_debug_bits - Device debug bits to be used with the video
+ * device debug attribute
+ *
+ * @V4L2_DEBUG_IOCTL: Just log the ioctl name + error code.
+ * @V4L2_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code.
+ * @V4L2_DEBUG_FOP: Log the file operations and open, release,
+ * mmap and get_unmapped_area syscalls.
+ * @V4L2_DEBUG_STREAMING: Log the read and write syscalls and
+ * :c:ref:VIDIOC_[Q|DQ]BUF <VIDIOC_QBUF> ioctls.
+ * @V4L2_DEBUG_POLL: Log poll syscalls.
+ */
+enum v4l2_debug_bits {
+ V4L2_DEBUG_IOCTL = 0,
+ V4L2_DEBUG_IOCTL_ARG = 1,
+ V4L2_DEBUG_FOP = 2,
+ V4L2_DEBUG_STREAMING = 3,
+ V4L2_DEBUG_POLL = 4,
+};
I agree with the principle of having a way to document #defines and static data that belongs to kAPI and drivers. So, from my side, if someone pops up and propose a way to document #defines to linux-doc, manages to get such proposal accepted and submit patches implementing it, I'm fine.
There are things like:
include/media/cec.h:#define CEC_NUM_CORE_EVENTS 2
include/media/cec.h:#define CEC_MAX_MSG_RX_QUEUE_SZ (18 * 3)
include/media/cec.h:#define CEC_MAX_MSG_TX_QUEUE_SZ (18 * 1)
include/media/rc-core.h:#define IR_DEFAULT_TIMEOUT MS_TO_NS(125)
include/media/rc-core.h:#define IR_MAX_DURATION 500000000 /* 500 ms */
include/media/v4l2-clk.h:#define V4L2_CLK_NAME_SIZE 64
...
that currently can't be documented, and do belong to "#define" namespace, as those are true macros that create an alias for a magic number.
Those should *never* be converted to enums. The fact that they can't right now be documented shouldn't be used as an excuse to conver to enums: they're just magic numbers that can be used on a countless number of random places that may or may not be related.
However, I do believe that, grouping namespace for values with the same meaning do belong to enums. After all, those values are bound together for life, as they're meant to be used at the same places. A define is a very poor and lazy way to define, and sometimes induce to mistakes, as, from time to time, I see values on defines that belongs to an specific field being used on some other one.
Quoted 1 line
From documentation PoV, they also play nicer when grouped together,
as a common comment that applies to all such values are grouped together.
In the specific case of this patch, all those V4L2_DEV_DEBUG_* bits (or V4L2_DEV_DEBUG_* values - before this patchset) are meant to be used only when enabling or disabling V4L2 core debug messages.
Grouping them into the same "enum" namespace makes all sense. They should have grouped together since the beginning. That's all my fault, as, when I added this logic[1], I just took the lazy way.
[1] Back on 2006, where there were just 2 debug values
commit 401998fa96fe18b057af3f906527196522dd2d9d
Author: Mauro Carvalho Chehab <[email protected]>
Date: Sun Jun 4 10:06:18 2006 -0300
V4L/DVB (4065): Several improvements at videodev.c
Videodev now is capable of better handling V4L2 api, by processing V4L2 ioctls and using callbacks to the driver. The drivers should be migrated to the newer way and the older one will be obsoleted soon.
Thanks,
Mauro
PATCH 3/8 media: v4l2-async: simplify v4l2_async_subdev structure
In reply to Mauro Carvalho ChehabThe V4L2_ASYNC_MATCH_FWNODE match criteria requires just one struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME match criteria requires just a device name.
So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union.
That makes easier to document it, as we don't need to document weird senseless structs.
At drivers, this makes even clearer about the match criteria.
--- drivers/media/platform/am437x/am437x-vpfe.c | 6 +++--- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- drivers/media/platform/davinci/vpif_capture.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 4 ++-- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/qcom/camss-8x16/camss.c | 2 +- drivers/media/platform/rcar-vin/rcar-core.c | 2 +- drivers/media/platform/rcar_drif.c | 4 ++-- drivers/media/platform/soc_camera/soc_camera.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 2 +- drivers/media/v4l2-core/v4l2-async.c | 16 ++++++++-------- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++----- drivers/staging/media/imx/imx-media-dev.c | 4 ++-- include/media/v4l2-async.h | 8 ++------ 17 files changed, 35 insertions(+), 39 deletions(-)
drivers/media/platform/am437x/am437x-vpfe.c +3 -3
@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,vpfe_dbg (1 , vpfe,"vpfe_async_bound\n" );for (i =0 ; i <ARRAY_SIZE (vpfe->cfg->asd); i++) { -if (vpfe->cfg->asd[i]->match.fwnode.fwnode == - asd[i].match.fwnode.fwnode) { +if (vpfe->cfg->asd[i]->match.fwnode == + asd[i].match.fwnode) { sdinfo = &vpfe->cfg->sub_devs[i]; vpfe->sd[i] = subdev; vpfe->sd[i]->grp_id = sdinfo->grp_id;
@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }
drivers/media/platform/atmel/atmel-isc.c +1 -1
@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity->pfe_cfg0 |=ISC_PFE_CFG0_PPOL_LOW ; subdev_entity->asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - subdev_entity->asd->match.fwnode.fwnode = + subdev_entity->asd->match.fwnode =of_fwnode_handle (rem);list_add_tail (&subdev_entity->list, &isc->subdev_entities); }
drivers/media/platform/atmel/atmel-isi.c +1 -1
@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)/* Remote node to connect */ isi->entity.node = remote; isi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - isi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + isi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }
drivers/media/platform/davinci/vpif_capture.c +2 -2
@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,for (i =0 ; i < vpif_obj.config->asd_sizes[0 ]; i++) {struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i]; -const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode; +const struct fwnode_handle *fwnode = _asd->match.fwnode;if (fwnode == subdev->fwnode) { vpif_obj.sd[i] = subdev;
@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }
drivers/media/platform/exynos4-is/media-dev.c +2 -2
@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, } fmd->sensor[index].asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - fmd->sensor[index].asd.match.fwnode.fwnode =of_fwnode_handle (rem); + fmd->sensor[index].asd.match.fwnode =of_fwnode_handle (rem); fmd->async_subdevs[index] = &fmd->sensor[index].asd; fmd->num_sensors++;
@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd.match.fwnode.fwnode == +if (fmd->sensor[i].asd.match.fwnode ==of_fwnode_handle (subdev->dev->of_node)) si = &fmd->sensor[i];
drivers/media/platform/pxa_camera.c +1 -1
@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev, asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; remote =of_graph_get_remote_port (np);if (remote) { - asd->match.fwnode.fwnode =of_fwnode_handle (remote); + asd->match.fwnode =of_fwnode_handle (remote);of_node_put (remote); }else {dev_notice (dev,"no remote for %pOF\n" , np);
drivers/media/platform/qcom/camss-8x16/camss.c +1 -1
@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev, } csd->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - csd->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + csd->asd.match.fwnode =of_fwnode_handle (remote); }return notifier->num_subdevs;
drivers/media/platform/rcar-vin/rcar-core.c +1 -1
@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)return -ENODEV ;vin_dbg (vin,"Found digital subdevice %pOF\n" , -to_of_node (vin->digital->asd.match.fwnode.fwnode)); +to_of_node (vin->digital->asd.match.fwnode)); vin->notifier.ops = &rvin_digital_notify_ops; ret =v4l2_async_notifier_register (&vin->v4l2_dev, &vin->notifier);
drivers/media/platform/rcar_drif.c +2 -2
@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,struct rcar_drif_sdr *sdr = container_of(notifier, struct rcar_drif_sdr, notifier); -if (sdr->ep.asd.match.fwnode.fwnode != +if (sdr->ep.asd.match.fwnode !=of_fwnode_handle (subdev->dev->of_node)) {rdrif_err (sdr,"subdev %s cannot bind\n" , subdev->name);return -EINVAL ;
@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)return -EINVAL ; } - sdr->ep.asd.match.fwnode.fwnode = fwnode; + sdr->ep.asd.match.fwnode = fwnode; sdr->ep.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++;
drivers/media/platform/soc_camera/soc_camera.c +1 -1
@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,if (!info)return -ENOMEM ; - info->sasd.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + info->sasd.asd.match.fwnode =of_fwnode_handle (remote); info->sasd.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; info->subdev = &info->sasd.asd;
drivers/media/platform/stm32/stm32-dcmi.c +1 -1
@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)/* Remote node to connect */ dcmi->entity.node = remote; dcmi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - dcmi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + dcmi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }
drivers/media/platform/ti-vpe/cal.c +1 -1
@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst) goto cleanup_exit; } asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode =of_fwnode_handle (sensor_node); + asd->match.fwnode =of_fwnode_handle (sensor_node); remote_ep =of_graph_get_remote_endpoint (ep_node);if (!remote_ep) {
drivers/media/platform/xilinx/xilinx-vipp.c +1 -1
@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev, entity->node = remote; entity->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - entity->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + entity->asd.match.fwnode =of_fwnode_handle (remote);list_add_tail (&entity->list, &xdev->entities); xdev->num_subdevs++; }
drivers/media/v4l2-core/v4l2-async.c +8 -8
@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)static bool match_devname (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); +return !strcmp (asd->match.device_name,dev_name (sd->dev)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwnode; +return sd->fwnode == asd->match.fwnode; }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)
@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (asd->match.fwnode.fwnode == fwnode) +if (asd->match.fwnode == fwnode)return true; }
@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (sd->asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (sd->asd->match.fwnode.fwnode == fwnode) +if (sd->asd->match.fwnode == fwnode)return true; }
@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(struct v4l2_async_subdev *other_asd = notifier->subdevs[j];if (other_asd->match_type ==V4L2_ASYNC_MATCH_FWNODE && - asd->match.fwnode.fwnode == - other_asd->match.fwnode.fwnode) + asd->match.fwnode == + other_asd->match.fwnode)return true; }
@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)break ;case V4L2_ASYNC_MATCH_FWNODE :if (v4l2_async_notifier_fwnode_has_async_subdev ( - notifier, asd->match.fwnode.fwnode, i)) { + notifier, asd->match.fwnode, i)) {dev_err (dev,"fwnode has already been registered or in notifier's subdev list\n" ); ret = -EEXIST ;
@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);break ;default :WARN_ON_ONCE (true);
drivers/media/v4l2-core/v4l2-fwnode.c +5 -5
@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return -ENOMEM ; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = + asd->match.fwnode =fwnode_graph_get_remote_port_parent (endpoint); -if (!asd->match.fwnode.fwnode) { +if (!asd->match.fwnode) {dev_warn (dev,"bad remote port parent\n" ); ret = -EINVAL ; goto out_err;
@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return 0 ; out_err: -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);kfree (asd);return ret == -ENOTCONN ?0 : ret;
@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = args.fwnode; + asd->match.fwnode = args.fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }
@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }
drivers/staging/media/imx/imx-media-dev.c +2 -2
@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd, asd = &imxasd->asd;switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -if (fwnode && asd->match.fwnode.fwnode == fwnode) +if (fwnode && asd->match.fwnode == fwnode)return asd;break ;case V4L2_ASYNC_MATCH_DEVNAME :
@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,if (fwnode) { asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; }else { asd->match_type =V4L2_ASYNC_MATCH_DEVNAME ; asd->match.device_name.name = devname;
include/media/v4l2-async.h +2 -6
@@ -58,12 +58,8 @@ enum v4l2_async_match_type { struct v4l2_async_subdev { enum v4l2_async_match_type match_type; union { - struct { - struct fwnode_handle *fwnode; - } fwnode; - struct { - const char *name; - } device_name; + struct fwnode_handle *fwnode; + const char *device_name; struct { int adapter_id; unsigned short address;
Signature · 1 line
2.14.3
PATCH 3/8 media: v4l2-async: simplify v4l2_async_subdev structure
For am437x/am437x-vpfe.c & ti-vpe/cal.c
Mauro Carvalho Chehab <[email protected]> wrote on Mon [2017-Dec-18 17:53:57 -0200]:
Quoted 394 lines
The
V4L2_ASYNC_MATCH_FWNODEmatch criteria requires just one struct to be filled (structfwnode_handle). TheV4L2_ASYNC_MATCH_DEVNAMEmatch criteria requires just a device name.So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union.
That makes easier to document it, as we don't need to document weird senseless structs.
At drivers, this makes even clearer about the match criteria.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/am437x/am437x-vpfe.c | 6 +++--- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- drivers/media/platform/davinci/vpif_capture.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 4 ++-- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/qcom/camss-8x16/camss.c | 2 +- drivers/media/platform/rcar-vin/rcar-core.c | 2 +- drivers/media/platform/rcar_drif.c | 4 ++-- drivers/media/platform/soc_camera/soc_camera.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 2 +- drivers/media/v4l2-core/v4l2-async.c | 16 ++++++++-------- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++----- drivers/staging/media/imx/imx-media-dev.c | 4 ++-- include/media/v4l2-async.h | 8 ++------ 17 files changed, 35 insertions(+), 39 deletions(-)drivers/media/platform/am437x/am437x-vpfe.c +3
-3@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,vpfe_dbg (1 , vpfe,"vpfe_async_bound\n" );for (i =0 ; i <ARRAY_SIZE (vpfe->cfg->asd); i++) { -if (vpfe->cfg->asd[i]->match.fwnode.fwnode == - asd[i].match.fwnode.fwnode) { +if (vpfe->cfg->asd[i]->match.fwnode == + asd[i].match.fwnode) { sdinfo = &vpfe->cfg->sub_devs[i]; vpfe->sd[i] = subdev; vpfe->sd[i]->grp_id = sdinfo->grp_id;@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/atmel/atmel-isc.c +1
-1@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity->pfe_cfg0 |=ISC_PFE_CFG0_PPOL_LOW ; subdev_entity->asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - subdev_entity->asd->match.fwnode.fwnode = + subdev_entity->asd->match.fwnode =of_fwnode_handle (rem);list_add_tail (&subdev_entity->list, &isc->subdev_entities); }drivers/media/platform/atmel/atmel-isi.c +1
-1@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)/* Remote node to connect */ isi->entity.node = remote; isi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - isi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + isi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/davinci/vpif_capture.c +2
-2@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,for (i =0 ; i < vpif_obj.config->asd_sizes[0 ]; i++) {struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i]; -const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode; +const struct fwnode_handle *fwnode = _asd->match.fwnode;if (fwnode == subdev->fwnode) { vpif_obj.sd[i] = subdev;@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/exynos4-is/media-dev.c +2
-2@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, } fmd->sensor[index].asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - fmd->sensor[index].asd.match.fwnode.fwnode =of_fwnode_handle (rem); + fmd->sensor[index].asd.match.fwnode =of_fwnode_handle (rem); fmd->async_subdevs[index] = &fmd->sensor[index].asd; fmd->num_sensors++;@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd.match.fwnode.fwnode == +if (fmd->sensor[i].asd.match.fwnode ==of_fwnode_handle (subdev->dev->of_node)) si = &fmd->sensor[i];drivers/media/platform/pxa_camera.c +1
-1@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev, asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; remote =of_graph_get_remote_port (np);if (remote) { - asd->match.fwnode.fwnode =of_fwnode_handle (remote); + asd->match.fwnode =of_fwnode_handle (remote);of_node_put (remote); }else {dev_notice (dev,"no remote for %pOF\n" , np);drivers/media/platform/qcom/camss-8x16/camss.c +1
-1@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev, } csd->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - csd->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + csd->asd.match.fwnode =of_fwnode_handle (remote); }return notifier->num_subdevs;drivers/media/platform/rcar-vin/rcar-core.c +1
-1@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)return -ENODEV ;vin_dbg (vin,"Found digital subdevice %pOF\n" , -to_of_node (vin->digital->asd.match.fwnode.fwnode)); +to_of_node (vin->digital->asd.match.fwnode)); vin->notifier.ops = &rvin_digital_notify_ops; ret =v4l2_async_notifier_register (&vin->v4l2_dev, &vin->notifier);drivers/media/platform/rcar_drif.c +2
-2@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,struct rcar_drif_sdr *sdr = container_of(notifier, struct rcar_drif_sdr, notifier); -if (sdr->ep.asd.match.fwnode.fwnode != +if (sdr->ep.asd.match.fwnode !=of_fwnode_handle (subdev->dev->of_node)) {rdrif_err (sdr,"subdev %s cannot bind\n" , subdev->name);return -EINVAL ;@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)return -EINVAL ; } - sdr->ep.asd.match.fwnode.fwnode = fwnode; + sdr->ep.asd.match.fwnode = fwnode; sdr->ep.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++;drivers/media/platform/soc_camera/soc_camera.c +1
-1@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,if (!info)return -ENOMEM ; - info->sasd.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + info->sasd.asd.match.fwnode =of_fwnode_handle (remote); info->sasd.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; info->subdev = &info->sasd.asd;drivers/media/platform/stm32/stm32-dcmi.c +1
-1@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)/* Remote node to connect */ dcmi->entity.node = remote; dcmi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - dcmi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + dcmi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/ti-vpe/cal.c +1
-1@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst) goto cleanup_exit; } asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode =of_fwnode_handle (sensor_node); + asd->match.fwnode =of_fwnode_handle (sensor_node); remote_ep =of_graph_get_remote_endpoint (ep_node);if (!remote_ep) {drivers/media/platform/xilinx/xilinx-vipp.c +1
-1@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev, entity->node = remote; entity->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - entity->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + entity->asd.match.fwnode =of_fwnode_handle (remote);list_add_tail (&entity->list, &xdev->entities); xdev->num_subdevs++; }drivers/media/v4l2-core/v4l2-async.c +8
-8@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)static bool match_devname (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); +return !strcmp (asd->match.device_name,dev_name (sd->dev)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwnode; +return sd->fwnode == asd->match.fwnode; }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (asd->match.fwnode.fwnode == fwnode) +if (asd->match.fwnode == fwnode)return true; }@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (sd->asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (sd->asd->match.fwnode.fwnode == fwnode) +if (sd->asd->match.fwnode == fwnode)return true; }@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(struct v4l2_async_subdev *other_asd = notifier->subdevs[j];if (other_asd->match_type ==V4L2_ASYNC_MATCH_FWNODE && - asd->match.fwnode.fwnode == - other_asd->match.fwnode.fwnode) + asd->match.fwnode == + other_asd->match.fwnode)return true; }@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)break ;case V4L2_ASYNC_MATCH_FWNODE :if (v4l2_async_notifier_fwnode_has_async_subdev ( - notifier, asd->match.fwnode.fwnode, i)) { + notifier, asd->match.fwnode, i)) {dev_err (dev,"fwnode has already been registered or in notifier's subdev list\n" ); ret = -EEXIST ;@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);break ;default :WARN_ON_ONCE (true);drivers/media/v4l2-core/v4l2-fwnode.c +5
-5@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return -ENOMEM ; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = + asd->match.fwnode =fwnode_graph_get_remote_port_parent (endpoint); -if (!asd->match.fwnode.fwnode) { +if (!asd->match.fwnode) {dev_warn (dev,"bad remote port parent\n" ); ret = -EINVAL ; goto out_err;@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return 0 ; out_err: -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);kfree (asd);return ret == -ENOTCONN ?0 : ret;@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = args.fwnode; + asd->match.fwnode = args.fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }drivers/staging/media/imx/imx-media-dev.c +2
-2@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd, asd = &imxasd->asd;switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -if (fwnode && asd->match.fwnode.fwnode == fwnode) +if (fwnode && asd->match.fwnode == fwnode)return asd;break ;case V4L2_ASYNC_MATCH_DEVNAME :@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,if (fwnode) { asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; }else { asd->match_type =V4L2_ASYNC_MATCH_DEVNAME ; asd->match.device_name.name = devname;include/media/v4l2-async.h +2
-6@@ -58,12 +58,8 @@ enum v4l2_async_match_type { struct v4l2_async_subdev { enum v4l2_async_match_type match_type; union { - struct { - struct fwnode_handle *fwnode; - } fwnode; - struct { - const char *name; - } device_name; + struct fwnode_handle *fwnode; + const char *device_name; struct { int adapter_id; unsigned short address;Signature · 1 line
2.14.3
PATCH 3/8 media: v4l2-async: simplify v4l2_async_subdev structure
In reply to Mauro Carvalho ChehabQuoted 4 lines · Mauro Carvalho Chehab
The
V4L2_ASYNC_MATCH_FWNODEmatch criteria requires just one struct to be filled (structfwnode_handle). TheV4L2_ASYNC_MATCH_DEVNAMEmatch criteria requires just a device name.
Quoted 8 lines
So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union.
That makes easier to document it, as we don't need to document weird senseless structs.
At drivers, this makes even clearer about the match criteria.
For atmel:
Quoted 382 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/am437x/am437x-vpfe.c | 6 +++--- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- drivers/media/platform/davinci/vpif_capture.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 4 ++-- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/qcom/camss-8x16/camss.c | 2 +- drivers/media/platform/rcar-vin/rcar-core.c | 2 +- drivers/media/platform/rcar_drif.c | 4 ++-- drivers/media/platform/soc_camera/soc_camera.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 2 +- drivers/media/v4l2-core/v4l2-async.c | 16 ++++++++-------- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++----- drivers/staging/media/imx/imx-media-dev.c | 4 ++-- include/media/v4l2-async.h | 8 ++------ 17 files changed, 35 insertions(+), 39 deletions(-)drivers/media/platform/am437x/am437x-vpfe.c +3
-3@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,vpfe_dbg (1 , vpfe,"vpfe_async_bound\n" );for (i =0 ; i <ARRAY_SIZE (vpfe->cfg->asd); i++) { -if (vpfe->cfg->asd[i]->match.fwnode.fwnode == - asd[i].match.fwnode.fwnode) { +if (vpfe->cfg->asd[i]->match.fwnode == + asd[i].match.fwnode) { sdinfo = &vpfe->cfg->sub_devs[i]; vpfe->sd[i] = subdev; vpfe->sd[i]->grp_id = sdinfo->grp_id;@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/atmel/atmel-isc.c +1
-1@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity->pfe_cfg0 |=ISC_PFE_CFG0_PPOL_LOW ; subdev_entity->asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - subdev_entity->asd->match.fwnode.fwnode = + subdev_entity->asd->match.fwnode =of_fwnode_handle (rem);list_add_tail (&subdev_entity->list, &isc->subdev_entities); }drivers/media/platform/atmel/atmel-isi.c +1
-1@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)/* Remote node to connect */ isi->entity.node = remote; isi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - isi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + isi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/davinci/vpif_capture.c +2
-2@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,for (i =0 ; i < vpif_obj.config->asd_sizes[0 ]; i++) {struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i]; -const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode; +const struct fwnode_handle *fwnode = _asd->match.fwnode;if (fwnode == subdev->fwnode) { vpif_obj.sd[i] = subdev;@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/exynos4-is/media-dev.c +2
-2@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, } fmd->sensor[index].asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - fmd->sensor[index].asd.match.fwnode.fwnode =of_fwnode_handle (rem); + fmd->sensor[index].asd.match.fwnode =of_fwnode_handle (rem); fmd->async_subdevs[index] = &fmd->sensor[index].asd; fmd->num_sensors++;@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd.match.fwnode.fwnode == +if (fmd->sensor[i].asd.match.fwnode ==of_fwnode_handle (subdev->dev->of_node)) si = &fmd->sensor[i];drivers/media/platform/pxa_camera.c +1
-1@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev, asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; remote =of_graph_get_remote_port (np);if (remote) { - asd->match.fwnode.fwnode =of_fwnode_handle (remote); + asd->match.fwnode =of_fwnode_handle (remote);of_node_put (remote); }else {dev_notice (dev,"no remote for %pOF\n" , np);drivers/media/platform/qcom/camss-8x16/camss.c +1
-1@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev, } csd->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - csd->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + csd->asd.match.fwnode =of_fwnode_handle (remote); }return notifier->num_subdevs;drivers/media/platform/rcar-vin/rcar-core.c +1
-1@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)return -ENODEV ;vin_dbg (vin,"Found digital subdevice %pOF\n" , -to_of_node (vin->digital->asd.match.fwnode.fwnode)); +to_of_node (vin->digital->asd.match.fwnode)); vin->notifier.ops = &rvin_digital_notify_ops; ret =v4l2_async_notifier_register (&vin->v4l2_dev, &vin->notifier);drivers/media/platform/rcar_drif.c +2
-2@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,struct rcar_drif_sdr *sdr = container_of(notifier, struct rcar_drif_sdr, notifier); -if (sdr->ep.asd.match.fwnode.fwnode != +if (sdr->ep.asd.match.fwnode !=of_fwnode_handle (subdev->dev->of_node)) {rdrif_err (sdr,"subdev %s cannot bind\n" , subdev->name);return -EINVAL ;@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)return -EINVAL ; } - sdr->ep.asd.match.fwnode.fwnode = fwnode; + sdr->ep.asd.match.fwnode = fwnode; sdr->ep.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++;drivers/media/platform/soc_camera/soc_camera.c +1
-1@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,if (!info)return -ENOMEM ; - info->sasd.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + info->sasd.asd.match.fwnode =of_fwnode_handle (remote); info->sasd.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; info->subdev = &info->sasd.asd;drivers/media/platform/stm32/stm32-dcmi.c +1
-1@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)/* Remote node to connect */ dcmi->entity.node = remote; dcmi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - dcmi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + dcmi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/ti-vpe/cal.c +1
-1@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst) goto cleanup_exit; } asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode =of_fwnode_handle (sensor_node); + asd->match.fwnode =of_fwnode_handle (sensor_node); remote_ep =of_graph_get_remote_endpoint (ep_node);if (!remote_ep) {drivers/media/platform/xilinx/xilinx-vipp.c +1
-1@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev, entity->node = remote; entity->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - entity->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + entity->asd.match.fwnode =of_fwnode_handle (remote);list_add_tail (&entity->list, &xdev->entities); xdev->num_subdevs++; }drivers/media/v4l2-core/v4l2-async.c +8
-8@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)static bool match_devname (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); +return !strcmp (asd->match.device_name,dev_name (sd->dev)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwnode; +return sd->fwnode == asd->match.fwnode; }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (asd->match.fwnode.fwnode == fwnode) +if (asd->match.fwnode == fwnode)return true; }@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (sd->asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (sd->asd->match.fwnode.fwnode == fwnode) +if (sd->asd->match.fwnode == fwnode)return true; }@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(struct v4l2_async_subdev *other_asd = notifier->subdevs[j];if (other_asd->match_type ==V4L2_ASYNC_MATCH_FWNODE && - asd->match.fwnode.fwnode == - other_asd->match.fwnode.fwnode) + asd->match.fwnode == + other_asd->match.fwnode)return true; }@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)break ;case V4L2_ASYNC_MATCH_FWNODE :if (v4l2_async_notifier_fwnode_has_async_subdev ( - notifier, asd->match.fwnode.fwnode, i)) { + notifier, asd->match.fwnode, i)) {dev_err (dev,"fwnode has already been registered or in notifier's subdev list\n" ); ret = -EEXIST ;@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);break ;default :WARN_ON_ONCE (true);drivers/media/v4l2-core/v4l2-fwnode.c +5
-5@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return -ENOMEM ; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = + asd->match.fwnode =fwnode_graph_get_remote_port_parent (endpoint); -if (!asd->match.fwnode.fwnode) { +if (!asd->match.fwnode) {dev_warn (dev,"bad remote port parent\n" ); ret = -EINVAL ; goto out_err;@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return 0 ; out_err: -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);kfree (asd);return ret == -ENOTCONN ?0 : ret;@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = args.fwnode; + asd->match.fwnode = args.fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }drivers/staging/media/imx/imx-media-dev.c +2
-2@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd, asd = &imxasd->asd;switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -if (fwnode && asd->match.fwnode.fwnode == fwnode) +if (fwnode && asd->match.fwnode == fwnode)return asd;break ;case V4L2_ASYNC_MATCH_DEVNAME :@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,if (fwnode) { asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; }else { asd->match_type =V4L2_ASYNC_MATCH_DEVNAME ; asd->match.device_name.name = devname;include/media/v4l2-async.h +2
-6@@ -58,12 +58,8 @@ enum v4l2_async_match_type { struct v4l2_async_subdev { enum v4l2_async_match_type match_type; union { - struct { - struct fwnode_handle *fwnode; - } fwnode; - struct { - const char *name; - } device_name; + struct fwnode_handle *fwnode; + const char *device_name; struct { int adapter_id; unsigned short address;Signature · 1 line
2.14.3
Signature · 3 lines
Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 3/8 media: v4l2-async: simplify v4l2_async_subdev structure
In reply to Mauro Carvalho ChehabQuoted 7 lines · Mauro Carvalho Chehab
The
V4L2_ASYNC_MATCH_FWNODEmatch criteria requires just one struct to be filled (structfwnode_handle). TheV4L2_ASYNC_MATCH_DEVNAMEmatch criteria requires just a device name.So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union.
Quoted 7 lines
That makes easier to document it, as we don't need to document weird senseless structs.
At drivers, this makes even clearer about the match criteria.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
I'm not sure this is needed but it doesn't break anything either.
Feel free to add:
Signature · 2 lines
Sakari Ailus e-mail: sakari.ailus at iki.fi
Philipp Zabel
maintainerPATCH 3/8 media: v4l2-async: simplify v4l2_async_subdev structure
In reply to Mauro Carvalho ChehabQuoted 7 lines · Mauro Carvalho Chehab
The
V4L2_ASYNC_MATCH_FWNODEmatch criteria requires just one struct to be filled (structfwnode_handle). TheV4L2_ASYNC_MATCH_DEVNAMEmatch criteria requires just a device name.So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union.
Quoted 7 lines
That makes easier to document it, as we don't need to document weird senseless structs.
At drivers, this makes even clearer about the match criteria.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
Thanks, this does improve readability in the drivers. For imx-media,
regards
Philipp
Quoted 377 lines
--- drivers/media/platform/am437x/am437x-vpfe.c | 6 +++--- drivers/media/platform/atmel/atmel-isc.c | 2 +- drivers/media/platform/atmel/atmel-isi.c | 2 +- drivers/media/platform/davinci/vpif_capture.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 4 ++-- drivers/media/platform/pxa_camera.c | 2 +- drivers/media/platform/qcom/camss-8x16/camss.c | 2 +- drivers/media/platform/rcar-vin/rcar-core.c | 2 +- drivers/media/platform/rcar_drif.c | 4 ++-- drivers/media/platform/soc_camera/soc_camera.c | 2 +- drivers/media/platform/stm32/stm32-dcmi.c | 2 +- drivers/media/platform/ti-vpe/cal.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 2 +- drivers/media/v4l2-core/v4l2-async.c | 16 ++++++++-------- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++----- drivers/staging/media/imx/imx-media-dev.c | 4 ++-- include/media/v4l2-async.h | 8 ++------ 17 files changed, 35 insertions(+), 39 deletions(-)drivers/media/platform/am437x/am437x-vpfe.c +3
-3@@ -2304,8 +2304,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier,vpfe_dbg (1 , vpfe,"vpfe_async_bound\n" );for (i =0 ; i <ARRAY_SIZE (vpfe->cfg->asd); i++) { -if (vpfe->cfg->asd[i]->match.fwnode.fwnode == - asd[i].match.fwnode.fwnode) { +if (vpfe->cfg->asd[i]->match.fwnode == + asd[i].match.fwnode) { sdinfo = &vpfe->cfg->sub_devs[i]; vpfe->sd[i] = subdev; vpfe->sd[i]->grp_id = sdinfo->grp_id;@@ -2510,7 +2510,7 @@ vpfe_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/atmel/atmel-isc.c +1
-1@@ -2088,7 +2088,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) subdev_entity->pfe_cfg0 |=ISC_PFE_CFG0_PPOL_LOW ; subdev_entity->asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - subdev_entity->asd->match.fwnode.fwnode = + subdev_entity->asd->match.fwnode =of_fwnode_handle (rem);list_add_tail (&subdev_entity->list, &isc->subdev_entities); }drivers/media/platform/atmel/atmel-isi.c +1
-1@@ -1128,7 +1128,7 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node)/* Remote node to connect */ isi->entity.node = remote; isi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - isi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + isi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/davinci/vpif_capture.c +2
-2@@ -1390,7 +1390,7 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,for (i =0 ; i < vpif_obj.config->asd_sizes[0 ]; i++) {struct v4l2_async_subdev *_asd = vpif_obj.config->asd[i]; -const struct fwnode_handle *fwnode = _asd->match.fwnode.fwnode; +const struct fwnode_handle *fwnode = _asd->match.fwnode;if (fwnode == subdev->fwnode) { vpif_obj.sd[i] = subdev;@@ -1595,7 +1595,7 @@ vpif_capture_get_pdata(struct platform_device *pdev) } pdata->asd[i]->match_type =V4L2_ASYNC_MATCH_FWNODE ; - pdata->asd[i]->match.fwnode.fwnode =of_fwnode_handle (rem); + pdata->asd[i]->match.fwnode =of_fwnode_handle (rem);of_node_put (rem); }drivers/media/platform/exynos4-is/media-dev.c +2
-2@@ -456,7 +456,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, } fmd->sensor[index].asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - fmd->sensor[index].asd.match.fwnode.fwnode =of_fwnode_handle (rem); + fmd->sensor[index].asd.match.fwnode =of_fwnode_handle (rem); fmd->async_subdevs[index] = &fmd->sensor[index].asd; fmd->num_sensors++;@@ -1364,7 +1364,7 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier,/* Find platform data for this sensor subdev */ for (i =0 ; i <ARRAY_SIZE (fmd->sensor); i++) -if (fmd->sensor[i].asd.match.fwnode.fwnode == +if (fmd->sensor[i].asd.match.fwnode ==of_fwnode_handle (subdev->dev->of_node)) si = &fmd->sensor[i];drivers/media/platform/pxa_camera.c +1
-1@@ -2335,7 +2335,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev, asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; remote =of_graph_get_remote_port (np);if (remote) { - asd->match.fwnode.fwnode =of_fwnode_handle (remote); + asd->match.fwnode =of_fwnode_handle (remote);of_node_put (remote); }else {dev_notice (dev,"no remote for %pOF\n" , np);drivers/media/platform/qcom/camss-8x16/camss.c +1
-1@@ -341,7 +341,7 @@ static int camss_of_parse_ports(struct device *dev, } csd->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - csd->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + csd->asd.match.fwnode =of_fwnode_handle (remote); }return notifier->num_subdevs;drivers/media/platform/rcar-vin/rcar-core.c +1
-1@@ -187,7 +187,7 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)return -ENODEV ;vin_dbg (vin,"Found digital subdevice %pOF\n" , -to_of_node (vin->digital->asd.match.fwnode.fwnode)); +to_of_node (vin->digital->asd.match.fwnode)); vin->notifier.ops = &rvin_digital_notify_ops; ret =v4l2_async_notifier_register (&vin->v4l2_dev, &vin->notifier);drivers/media/platform/rcar_drif.c +2
-2@@ -1107,7 +1107,7 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier,struct rcar_drif_sdr *sdr = container_of(notifier, struct rcar_drif_sdr, notifier); -if (sdr->ep.asd.match.fwnode.fwnode != +if (sdr->ep.asd.match.fwnode !=of_fwnode_handle (subdev->dev->of_node)) {rdrif_err (sdr,"subdev %s cannot bind\n" , subdev->name);return -EINVAL ;@@ -1235,7 +1235,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)return -EINVAL ; } - sdr->ep.asd.match.fwnode.fwnode = fwnode; + sdr->ep.asd.match.fwnode = fwnode; sdr->ep.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++;drivers/media/platform/soc_camera/soc_camera.c +1
-1@@ -1517,7 +1517,7 @@ static int soc_of_bind(struct soc_camera_host *ici,if (!info)return -ENOMEM ; - info->sasd.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + info->sasd.asd.match.fwnode =of_fwnode_handle (remote); info->sasd.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; info->subdev = &info->sasd.asd;drivers/media/platform/stm32/stm32-dcmi.c +1
-1@@ -1520,7 +1520,7 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)/* Remote node to connect */ dcmi->entity.node = remote; dcmi->entity.asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - dcmi->entity.asd.match.fwnode.fwnode =of_fwnode_handle (remote); + dcmi->entity.asd.match.fwnode =of_fwnode_handle (remote);return 0 ; } }drivers/media/platform/ti-vpe/cal.c +1
-1@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst) goto cleanup_exit; } asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode =of_fwnode_handle (sensor_node); + asd->match.fwnode =of_fwnode_handle (sensor_node); remote_ep =of_graph_get_remote_endpoint (ep_node);if (!remote_ep) {drivers/media/platform/xilinx/xilinx-vipp.c +1
-1@@ -387,7 +387,7 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev, entity->node = remote; entity->asd.match_type =V4L2_ASYNC_MATCH_FWNODE ; - entity->asd.match.fwnode.fwnode =of_fwnode_handle (remote); + entity->asd.match.fwnode =of_fwnode_handle (remote);list_add_tail (&entity->list, &xdev->entities); xdev->num_subdevs++; }drivers/media/v4l2-core/v4l2-async.c +8
-8@@ -68,12 +68,12 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)static bool match_devname (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return !strcmp (asd->match.device_name.name,dev_name (sd->dev)); +return !strcmp (asd->match.device_name,dev_name (sd->dev)); }static bool match_fwnode (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->fwnode == asd->match.fwnode.fwnode; +return sd->fwnode == asd->match.fwnode; }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)@@ -319,7 +319,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (asd->match.fwnode.fwnode == fwnode) +if (asd->match.fwnode == fwnode)return true; }@@ -330,7 +330,7 @@ static bool __v4l2_async_notifier_fwnode_has_async_subdev(if (sd->asd->match_type !=V4L2_ASYNC_MATCH_FWNODE )continue ; -if (sd->asd->match.fwnode.fwnode == fwnode) +if (sd->asd->match.fwnode == fwnode)return true; }@@ -355,8 +355,8 @@ static bool v4l2_async_notifier_fwnode_has_async_subdev(struct v4l2_async_subdev *other_asd = notifier->subdevs[j];if (other_asd->match_type ==V4L2_ASYNC_MATCH_FWNODE && - asd->match.fwnode.fwnode == - other_asd->match.fwnode.fwnode) + asd->match.fwnode == + other_asd->match.fwnode)return true; }@@ -395,7 +395,7 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)break ;case V4L2_ASYNC_MATCH_FWNODE :if (v4l2_async_notifier_fwnode_has_async_subdev ( - notifier, asd->match.fwnode.fwnode, i)) { + notifier, asd->match.fwnode, i)) {dev_err (dev,"fwnode has already been registered or in notifier's subdev list\n" ); ret = -EEXIST ;@@ -510,7 +510,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);break ;default :WARN_ON_ONCE (true);drivers/media/v4l2-core/v4l2-fwnode.c +5
-5@@ -359,9 +359,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return -ENOMEM ; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = + asd->match.fwnode =fwnode_graph_get_remote_port_parent (endpoint); -if (!asd->match.fwnode.fwnode) { +if (!asd->match.fwnode) {dev_warn (dev,"bad remote port parent\n" ); ret = -EINVAL ; goto out_err;@@ -393,7 +393,7 @@ static int v4l2_async_notifier_fwnode_parse_endpoint(return 0 ; out_err: -fwnode_handle_put (asd->match.fwnode.fwnode); +fwnode_handle_put (asd->match.fwnode);kfree (asd);return ret == -ENOTCONN ?0 : ret;@@ -566,7 +566,7 @@ static int v4l2_fwnode_reference_parse( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = args.fwnode; + asd->match.fwnode = args.fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }@@ -853,7 +853,7 @@ static int v4l2_fwnode_reference_parse_int_props( } notifier->subdevs[notifier->num_subdevs] = asd; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; notifier->num_subdevs++; }drivers/staging/media/imx/imx-media-dev.c +2
-2@@ -48,7 +48,7 @@ find_async_subdev(struct imx_media_dev *imxmd, asd = &imxasd->asd;switch (asd->match_type) {case V4L2_ASYNC_MATCH_FWNODE : -if (fwnode && asd->match.fwnode.fwnode == fwnode) +if (fwnode && asd->match.fwnode == fwnode)return asd;break ;case V4L2_ASYNC_MATCH_DEVNAME :@@ -104,7 +104,7 @@ int imx_media_add_async_subdev(struct imx_media_dev *imxmd,if (fwnode) { asd->match_type =V4L2_ASYNC_MATCH_FWNODE ; - asd->match.fwnode.fwnode = fwnode; + asd->match.fwnode = fwnode; }else { asd->match_type =V4L2_ASYNC_MATCH_DEVNAME ; asd->match.device_name.name = devname;include/media/v4l2-async.h +2
-6@@ -58,12 +58,8 @@ enum v4l2_async_match_type { struct v4l2_async_subdev { enum v4l2_async_match_type match_type; union { - struct { - struct fwnode_handle *fwnode; - } fwnode; - struct { - const char *name; - } device_name; + struct fwnode_handle *fwnode; + const char *device_name; struct { int adapter_id; unsigned short address;
PATCH 4/8 media: v4l2-async: better describe match union at async match struct
In reply to Mauro Carvalho ChehabNow that kernel-doc handles nested unions, better document the match union at struct v4l2_async_subdev.
--- include/media/v4l2-async.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
include/media/v4l2-async.h +25 -0
@@ -48,6 +48,31 @@ enum v4l2_async_match_type {* * @match_type: type of match that will be used * @match: union of per-bus type matching data sets +* @match.fwnode: +* pointer to &struct fwnode_handle to be matched. +* Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE. +* @match.device_name: +* string containing the device name to be matched. +* Used if @match_type is %V4L2_ASYNC_MATCH_DEVNAME. +* @match.i2c: embedded struct with I2C parameters to be matched. +* Both @match.i2c.adapter_id and @match.i2c.address +* should be matched. +* Used if @match_type is %V4L2_ASYNC_MATCH_I2C. +* @match.i2c.adapter_id: +* I2C adapter ID to be matched. +* Used if @match_type is %V4L2_ASYNC_MATCH_I2C. +* @match.i2c.address: +* I2C address to be matched. +* Used if @match_type is %V4L2_ASYNC_MATCH_I2C. +* @match.custom: +* Driver-specific match criteria. +* Used if @match_type is %V4L2_ASYNC_MATCH_CUSTOM. +* @match.custom.match: +* Driver-specific match function to be used if +* %V4L2_ASYNC_MATCH_CUSTOM. +* @match.custom.priv: +* Driver-specific private struct with match parameters +* to be used if %V4L2_ASYNC_MATCH_CUSTOM. * @list: used to link struct v4l2_async_subdev objects, waiting to be * probed, to a notifier->waiting list *
Signature · 1 line
2.14.3
PATCH 5/8 media: v4l2-mediabus: convert flags to enums and document them
In reply to Mauro Carvalho ChehabThere is a mess with media bus flags: there are two sets of flags, one used by parallel and ITU-R BT.656 outputs, and another one for CSI2.
Depending on the type, the same bit has different meanings.
That's very confusing, and counter-intuitive. So, split them into two sets of flags, inside an enum.
This way, it becomes clearer that there are two separate sets of flags. It also makes easier if CSI1, CSP, CSI3, etc. would need a different set of flags.
As a side effect, enums can be documented via kernel-docs, so there will be an improvement at flags documentation.
Unfortunately, soc_camera and pxa_camera do a mess with the flags, using either one set of flags without proper checks about the type. That could be fixed, but, as both drivers are obsolete and in the process of cleanings, I opted to just keep the behavior, using an unsigned int inside those two drivers.
--- drivers/media/i2c/adv7180.c | 10 +- drivers/media/i2c/ml86v7667.c | 5 +- drivers/media/i2c/mt9m111.c | 8 +- drivers/media/i2c/ov6650.c | 19 +-- drivers/media/i2c/soc_camera/imx074.c | 6 +- drivers/media/i2c/soc_camera/mt9m001.c | 10 +- drivers/media/i2c/soc_camera/mt9t031.c | 11 +- drivers/media/i2c/soc_camera/mt9t112.c | 11 +- drivers/media/i2c/soc_camera/mt9v022.c | 16 ++- drivers/media/i2c/soc_camera/ov5642.c | 5 +- drivers/media/i2c/soc_camera/ov772x.c | 10 +- drivers/media/i2c/soc_camera/ov9640.c | 10 +- drivers/media/i2c/soc_camera/ov9740.c | 10 +- drivers/media/i2c/soc_camera/rj54n1cb0c.c | 12 +- drivers/media/i2c/soc_camera/tw9910.c | 13 +- drivers/media/i2c/tc358743.c | 10 +- drivers/media/i2c/tvp5150.c | 6 +- drivers/media/platform/pxa_camera.c | 8 +- drivers/media/platform/rcar-vin/rcar-core.c | 4 +- drivers/media/platform/rcar-vin/rcar-dma.c | 4 +- .../platform/soc_camera/sh_mobile_ceu_camera.c | 2 +- drivers/media/platform/soc_camera/soc_camera.c | 3 +- .../platform/soc_camera/soc_camera_platform.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 5 +- include/media/v4l2-fwnode.h | 4 +- include/media/v4l2-mediabus.h | 145 ++++++++++++++------- 27 files changed, 218 insertions(+), 133 deletions(-)
drivers/media/i2c/adv7180.c +5 -5
@@ -743,16 +743,16 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,if (state->chip_info->flags &ADV7180_FLAG_MIPI_CSI2 ) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_1_LANE | -V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_1_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; }else {/* * The ADV7180 sensor supports BT.601/656 output modes. * The BT.656 is default and not yet configurable by s/w. */ - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_BT656 ; }
drivers/media/i2c/ml86v7667.c +3 -2
@@ -226,8 +226,9 @@ static int ml86v7667_fill_fmt(struct v4l2_subdev *sd,static int ml86v7667_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_BT656 ;return 0 ;
drivers/media/i2c/mt9m111.c +5 -3
@@ -857,9 +857,11 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,static int mt9m111_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ;return 0 ;
drivers/media/i2c/ov6650.c +11 -8
@@ -880,11 +880,14 @@ static int ov6650_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ;return 0 ;
@@ -897,21 +900,21 @@ static int ov6650_s_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);int ret; -if (cfg->flags &V4L2_MBUS_PCLK_SAMPLE_RISING ) +if (cfg->pb_flags &V4L2_MBUS_PCLK_SAMPLE_RISING ) ret =ov6650_reg_rmw (client,REG_COMJ ,COMJ_PCLK_RISING ,0 );else ret =ov6650_reg_rmw (client,REG_COMJ ,0 ,COMJ_PCLK_RISING );if (ret)return ret; -if (cfg->flags &V4L2_MBUS_HSYNC_ACTIVE_LOW ) +if (cfg->pb_flags &V4L2_MBUS_HSYNC_ACTIVE_LOW ) ret =ov6650_reg_rmw (client,REG_COMF ,COMF_HREF_LOW ,0 );else ret =ov6650_reg_rmw (client,REG_COMF ,0 ,COMF_HREF_LOW );if (ret)return ret; -if (cfg->flags &V4L2_MBUS_VSYNC_ACTIVE_HIGH ) +if (cfg->pb_flags &V4L2_MBUS_VSYNC_ACTIVE_HIGH ) ret =ov6650_reg_rmw (client,REG_COMJ ,COMJ_VSYNC_HIGH ,0 );else ret =ov6650_reg_rmw (client,REG_COMJ ,0 ,COMJ_VSYNC_HIGH );
drivers/media/i2c/soc_camera/imx074.c +3 -3
@@ -264,9 +264,9 @@ static int imx074_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_2_LANE | -V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_2_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;return 0 ; }
drivers/media/i2c/soc_camera/mt9m001.c +6 -4
@@ -603,11 +603,13 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client);/* MT9M001 has all capture_format parameters fixed */ - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH |V4L2_MBUS_MASTER ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_MASTER ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/mt9t031.c +7 -4
@@ -704,11 +704,14 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_PCLK_SAMPLE_FALLING |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/mt9t112.c +7 -4
@@ -1009,11 +1009,14 @@ static int mt9t112_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_DATA_ACTIVE_HIGH | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/mt9v022.c +10 -6
@@ -798,13 +798,17 @@ static int mt9v022_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_SLAVE | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_SLAVE + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/ov5642.c +3 -2
@@ -914,8 +914,9 @@ static int ov5642_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_2_LANE |V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_2_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;return 0 ; }
drivers/media/i2c/soc_camera/ov772x.c +6 -4
@@ -1003,11 +1003,13 @@ static int ov772x_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/ov9640.c +6 -4
@@ -634,11 +634,13 @@ static int ov9640_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/ov9740.c +6 -4
@@ -882,11 +882,13 @@ static int ov9740_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/rj54n1cb0c.c +7 -5
@@ -1227,12 +1227,14 @@ static int rj54n1_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags = -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_MASTER |V4L2_MBUS_DATA_ACTIVE_HIGH | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_MASTER + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/soc_camera/tw9910.c +8 -5
@@ -862,12 +862,15 @@ static int tw9910_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }
drivers/media/i2c/tc358743.c +5 -5
@@ -1623,20 +1623,20 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd, cfg->type =V4L2_MBUS_CSI2 ;/* Support for non-continuous CSI-2 clock is missing in the driver */ - cfg->flags =V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;switch (state->csi_lanes_in_use) {case 1 : - cfg->flags |=V4L2_MBUS_CSI2_1_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_1_LANE ;break ;case 2 : - cfg->flags |=V4L2_MBUS_CSI2_2_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_2_LANE ;break ;case 3 : - cfg->flags |=V4L2_MBUS_CSI2_3_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_3_LANE ;break ;case 4 : - cfg->flags |=V4L2_MBUS_CSI2_4_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_4_LANE ;break ;default :return -EINVAL ;
drivers/media/i2c/tvp5150.c +4 -2
@@ -976,8 +976,10 @@ static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,struct tvp5150 *decoder =to_tvp5150 (sd); cfg->type = decoder->mbus_type; - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING - |V4L2_MBUS_FIELD_EVEN_LOW |V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_FIELD_EVEN_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ;return 0 ; }
drivers/media/platform/pxa_camera.c +4 -4
@@ -616,7 +616,7 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cfbool hsync = true, vsync = true, pclk, data, mode;bool mipi_lanes, mipi_clock; - common_flags = cfg->flags & flags; + common_flags = cfg->__legacy_flags & flags;switch (cfg->type) {case V4L2_MBUS_PARALLEL :
@@ -1621,7 +1621,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)if (!common_flags) {dev_warn (pcdev_to_dev (pcdev),"Flags incompatible: camera 0x%x, host 0x%lx\n" , - cfg.flags, bus_flags); + cfg.__legacy_flags, bus_flags);return -EINVAL ; } }else if (ret != -ENOIOCTLCMD ) {
@@ -1657,7 +1657,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev) common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING ; } - cfg.flags = common_flags; + cfg.__legacy_flags = common_flags; ret =sensor_call (pcdev, video, s_mbus_config, &cfg);if (ret <0 && ret != -ENOIOCTLCMD ) { dev_dbg(pcdev_to_dev(pcdev),
@@ -1688,7 +1688,7 @@ static int pxa_camera_try_bus_param(struct pxa_camera_dev *pcdev,if (!common_flags) {dev_warn (pcdev_to_dev (pcdev),"Flags incompatible: camera 0x%x, host 0x%lx\n" , - cfg.flags, bus_flags); + cfg.__legacy_flags, bus_flags);return -EINVAL ; } }else if (ret == -ENOIOCTLCMD ) {
drivers/media/platform/rcar-vin/rcar-core.c +2 -2
@@ -157,11 +157,11 @@ static int rvin_digital_parse_v4l2(struct device *dev,switch (rvge->mbus_cfg.type) {case V4L2_MBUS_PARALLEL :vin_dbg (vin,"Found PARALLEL media bus\n" ); - rvge->mbus_cfg.flags = vep->bus.parallel.flags; + rvge->mbus_cfg.pb_flags = vep->bus.parallel.flags;break ;case V4L2_MBUS_BT656 :vin_dbg (vin,"Found BT656 media bus\n" ); - rvge->mbus_cfg.flags =0 ; + rvge->mbus_cfg.pb_flags =0 ;break ;default :vin_err (vin,"Unknown media bus type\n" );
drivers/media/platform/rcar-vin/rcar-dma.c +2 -2
@@ -212,11 +212,11 @@ static int rvin_setup(struct rvin_dev *vin) dmr2 =VNDMR2_FTEV |VNDMR2_VLV (1 );/* Hsync Signal Polarity Select */ -if (!(vin->digital->mbus_cfg.flags &V4L2_MBUS_HSYNC_ACTIVE_LOW )) +if (!(vin->digital->mbus_cfg.pb_flags &V4L2_MBUS_HSYNC_ACTIVE_LOW )) dmr2 |=VNDMR2_HPS ;/* Vsync Signal Polarity Select */ -if (!(vin->digital->mbus_cfg.flags &V4L2_MBUS_VSYNC_ACTIVE_LOW )) +if (!(vin->digital->mbus_cfg.pb_flags &V4L2_MBUS_VSYNC_ACTIVE_LOW )) dmr2 |=VNDMR2_VPS ;/*
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +1 -1
@@ -744,7 +744,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW ; } - cfg.flags = common_flags; + cfg.__legacy_flags = common_flags; ret =v4l2_subdev_call (sd, video, s_mbus_config, &cfg);if (ret <0 && ret != -ENOIOCTLCMD )return ret;
drivers/media/platform/soc_camera/soc_camera.c +2 -1
@@ -217,7 +217,8 @@ EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);unsigned long soc_camera_apply_board_flags (struct soc_camera_subdev_desc *ssdd,const struct v4l2_mbus_config *cfg) { -unsigned long f, flags = cfg->flags; +unsigned long f; +enum v4l2_mbus_parallel_and_bt656_flags flags = cfg->pb_flags;/* If only one of the two polarities is supported, switch to the opposite */ if (ssdd->flags &SOCAM_SENSOR_INVERT_HSYNC ) {
drivers/media/platform/soc_camera/soc_camera_platform.c +1 -1
@@ -104,7 +104,7 @@ static int soc_camera_platform_g_mbus_config(struct v4l2_subdev *sd, {struct soc_camera_platform_info *p =v4l2_get_subdevdata (sd); - cfg->flags = p->mbus_param; + cfg->__legacy_flags = p->mbus_param; cfg->type = p->mbus_type;return 0 ;
drivers/media/platform/soc_camera/soc_mediabus.c +1 -1
@@ -486,7 +486,7 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,bool hsync = true, vsync = true, pclk, data, mode;bool mipi_lanes, mipi_clock; - common_flags = cfg->flags & flags; + common_flags = cfg->__legacy_flags & flags;switch (cfg->type) {case V4L2_MBUS_PARALLEL :
drivers/media/v4l2-core/v4l2-fwnode.c +3 -2
@@ -44,7 +44,8 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;bool have_clk_lane = false; -unsigned int flags =0 , lanes_used =0 ; +unsigned int lanes_used =0 ; +enum v4l2_mbus_csi2_flags flags =0 ;unsigned int i;u32 v;int rval;
@@ -112,7 +113,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus( struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep) { struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel; -unsigned int flags =0 ; +enum v4l2_mbus_parallel_and_bt656_flags flags =0 ;u32 v;if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v))
include/media/v4l2-fwnode.h +2 -2
@@ -32,7 +32,7 @@ struct v4l2_async_subdev;/** * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure -* @flags: media bus (V4L2_MBUS_*) flags +* @flags: media bus CSI flags, as defined by &enum v4l2_mbus_csi2_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
@@ -40,7 +40,7 @@ struct v4l2_async_subdev;* the physical lanes. */ struct v4l2_fwnode_bus_mipi_csi2 { -unsigned int flags; +enum v4l2_mbus_csi2_flags flags;unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES ];unsigned char clock_lane;unsigned short num_data_lanes;
include/media/v4l2-mediabus.h +98 -47
168 lines not on this page · raw message
Signature · 1 line
2.14.3
Philipp Zabel
maintainerRe: [PATCH 5/8] media: v4l2-mediabus: convert flags to enums and document them
Hi Mauro,
Quoted 23 lines · Mauro Carvalho Chehab
There is a mess with media bus flags: there are two sets of flags, one used by parallel and ITU-R BT.656 outputs, and another one for CSI2.
Depending on the type, the same bit has different meanings.
That's very confusing, and counter-intuitive. So, split them into two sets of flags, inside an enum.
This way, it becomes clearer that there are two separate sets of flags. It also makes easier if CSI1, CSP, CSI3, etc. would need a different set of flags.
As a side effect, enums can be documented via kernel-docs, so there will be an improvement at flags documentation.
Unfortunately,
soc_cameraandpxa_camerado a mess with the flags, using either one set of flags without proper checks about the type. That could be fixed, but, as both drivers are obsolete and in the process of cleanings, I opted to just keep the behavior, using an unsigned int inside those two drivers.
Quoted 2 lines
Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>
If I am not mistaken this is missing a conversion of drivers/staging/media/imx/imx-media-csi.c:
--------8<--------
drivers/staging/media/imx/imx-media-csi.c +0 -0
@@ -636,9 +636,10 @@ static int csi_setup(struct csi_priv *priv)
/* compose mbus_config from the upstream endpoint */ mbus_cfg.type = priv->upstream_ep.bus_type;
- mbus_cfg.flags = (priv->upstream_ep.bus_type == V4L2_MBUS_CSI2) ?
- priv->upstream_ep.bus.mipi_csi2.flags :
- priv->upstream_ep.bus.parallel.flags;
+ if (priv->upstream_ep.bus_type == V4L2_MBUS_CSI2)
+ mbus_cfg.csi2_flags = priv->upstream_ep.bus.mipi_csi2.flags;
+ else
+ mbus_cfg.pb_flags = priv->upstream_ep.bus.parallel.flags;
/*
* we need to pass input frame to CSI interface, but
-------->8--------
regards
Philipp
Quoted 780 lines
--- drivers/media/i2c/adv7180.c | 10 +- drivers/media/i2c/ml86v7667.c | 5 +- drivers/media/i2c/mt9m111.c | 8 +- drivers/media/i2c/ov6650.c | 19 +-- drivers/media/i2c/soc_camera/imx074.c | 6 +- drivers/media/i2c/soc_camera/mt9m001.c | 10 +- drivers/media/i2c/soc_camera/mt9t031.c | 11 +- drivers/media/i2c/soc_camera/mt9t112.c | 11 +- drivers/media/i2c/soc_camera/mt9v022.c | 16 ++- drivers/media/i2c/soc_camera/ov5642.c | 5 +- drivers/media/i2c/soc_camera/ov772x.c | 10 +- drivers/media/i2c/soc_camera/ov9640.c | 10 +- drivers/media/i2c/soc_camera/ov9740.c | 10 +- drivers/media/i2c/soc_camera/rj54n1cb0c.c | 12 +- drivers/media/i2c/soc_camera/tw9910.c | 13 +- drivers/media/i2c/tc358743.c | 10 +- drivers/media/i2c/tvp5150.c | 6 +- drivers/media/platform/pxa_camera.c | 8 +- drivers/media/platform/rcar-vin/rcar-core.c | 4 +- drivers/media/platform/rcar-vin/rcar-dma.c | 4 +- .../platform/soc_camera/sh_mobile_ceu_camera.c | 2 +- drivers/media/platform/soc_camera/soc_camera.c | 3 +- .../platform/soc_camera/soc_camera_platform.c | 2 +- drivers/media/platform/soc_camera/soc_mediabus.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 5 +- include/media/v4l2-fwnode.h | 4 +- include/media/v4l2-mediabus.h | 145 ++++++++++++++------- 27 files changed, 218 insertions(+), 133 deletions(-)drivers/media/i2c/adv7180.c +5
-5@@ -743,16 +743,16 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd,if (state->chip_info->flags &ADV7180_FLAG_MIPI_CSI2 ) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_1_LANE | -V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_1_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; }else {/* * The ADV7180 sensor supports BT.601/656 output modes. * The BT.656 is default and not yet configurable by s/w. */ - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_BT656 ; }drivers/media/i2c/ml86v7667.c +3
-2@@ -226,8 +226,9 @@ static int ml86v7667_fill_fmt(struct v4l2_subdev *sd,static int ml86v7667_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_BT656 ;return 0 ;drivers/media/i2c/mt9m111.c +5
-3@@ -857,9 +857,11 @@ static int mt9m111_enum_mbus_code(struct v4l2_subdev *sd,static int mt9m111_g_mbus_config (struct v4l2_subdev *sd,struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ;return 0 ;drivers/media/i2c/ov6650.c +11
-8@@ -880,11 +880,14 @@ static int ov6650_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { - cfg->flags =V4L2_MBUS_MASTER | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ;return 0 ;@@ -897,21 +900,21 @@ static int ov6650_s_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);int ret; -if (cfg->flags &V4L2_MBUS_PCLK_SAMPLE_RISING ) +if (cfg->pb_flags &V4L2_MBUS_PCLK_SAMPLE_RISING ) ret =ov6650_reg_rmw (client,REG_COMJ ,COMJ_PCLK_RISING ,0 );else ret =ov6650_reg_rmw (client,REG_COMJ ,0 ,COMJ_PCLK_RISING );if (ret)return ret; -if (cfg->flags &V4L2_MBUS_HSYNC_ACTIVE_LOW ) +if (cfg->pb_flags &V4L2_MBUS_HSYNC_ACTIVE_LOW ) ret =ov6650_reg_rmw (client,REG_COMF ,COMF_HREF_LOW ,0 );else ret =ov6650_reg_rmw (client,REG_COMF ,0 ,COMF_HREF_LOW );if (ret)return ret; -if (cfg->flags &V4L2_MBUS_VSYNC_ACTIVE_HIGH ) +if (cfg->pb_flags &V4L2_MBUS_VSYNC_ACTIVE_HIGH ) ret =ov6650_reg_rmw (client,REG_COMJ ,COMJ_VSYNC_HIGH ,0 );else ret =ov6650_reg_rmw (client,REG_COMJ ,0 ,COMJ_VSYNC_HIGH );drivers/media/i2c/soc_camera/imx074.c +3
-3@@ -264,9 +264,9 @@ static int imx074_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_2_LANE | -V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_2_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;return 0 ; }drivers/media/i2c/soc_camera/mt9m001.c +6
-4@@ -603,11 +603,13 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client);/* MT9M001 has all capture_format parameters fixed */ - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH |V4L2_MBUS_MASTER ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_MASTER ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/mt9t031.c +7
-4@@ -704,11 +704,14 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING | -V4L2_MBUS_PCLK_SAMPLE_FALLING |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/mt9t112.c +7
-4@@ -1009,11 +1009,14 @@ static int mt9t112_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_VSYNC_ACTIVE_HIGH | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_DATA_ACTIVE_HIGH | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/mt9v022.c +10
-6@@ -798,13 +798,17 @@ static int mt9v022_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_SLAVE | -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_SLAVE + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/ov5642.c +3
-2@@ -914,8 +914,9 @@ static int ov5642_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { cfg->type =V4L2_MBUS_CSI2 ; - cfg->flags =V4L2_MBUS_CSI2_2_LANE |V4L2_MBUS_CSI2_CHANNEL_0 | -V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_2_LANE + |V4L2_MBUS_CSI2_CHANNEL_0 + |V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;return 0 ; }drivers/media/i2c/soc_camera/ov772x.c +6
-4@@ -1003,11 +1003,13 @@ static int ov772x_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/ov9640.c +6
-4@@ -634,11 +634,13 @@ static int ov9640_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/ov9740.c +6
-4@@ -882,11 +882,13 @@ static int ov9740_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_HIGH | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/rj54n1cb0c.c +7
-5@@ -1227,12 +1227,14 @@ static int rj54n1_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags = -V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_PCLK_SAMPLE_FALLING | -V4L2_MBUS_MASTER |V4L2_MBUS_DATA_ACTIVE_HIGH | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_PCLK_SAMPLE_FALLING + |V4L2_MBUS_MASTER + |V4L2_MBUS_DATA_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/soc_camera/tw9910.c +8
-5@@ -862,12 +862,15 @@ static int tw9910_g_mbus_config(struct v4l2_subdev *sd,struct i2c_client *client =v4l2_get_subdevdata (sd);struct soc_camera_subdev_desc *ssdd =soc_camera_i2c_to_desc (client); - cfg->flags =V4L2_MBUS_PCLK_SAMPLE_RISING |V4L2_MBUS_MASTER | -V4L2_MBUS_VSYNC_ACTIVE_HIGH |V4L2_MBUS_VSYNC_ACTIVE_LOW | -V4L2_MBUS_HSYNC_ACTIVE_HIGH |V4L2_MBUS_HSYNC_ACTIVE_LOW | -V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_MASTER + |V4L2_MBUS_VSYNC_ACTIVE_HIGH + |V4L2_MBUS_VSYNC_ACTIVE_LOW + |V4L2_MBUS_HSYNC_ACTIVE_HIGH + |V4L2_MBUS_HSYNC_ACTIVE_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ; cfg->type =V4L2_MBUS_PARALLEL ; - cfg->flags =soc_camera_apply_board_flags (ssdd, cfg); + cfg->pb_flags =soc_camera_apply_board_flags (ssdd, cfg);return 0 ; }drivers/media/i2c/tc358743.c +5
-5@@ -1623,20 +1623,20 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd, cfg->type =V4L2_MBUS_CSI2 ;/* Support for non-continuous CSI-2 clock is missing in the driver */ - cfg->flags =V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ; + cfg->csi2_flags =V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ;switch (state->csi_lanes_in_use) {case 1 : - cfg->flags |=V4L2_MBUS_CSI2_1_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_1_LANE ;break ;case 2 : - cfg->flags |=V4L2_MBUS_CSI2_2_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_2_LANE ;break ;case 3 : - cfg->flags |=V4L2_MBUS_CSI2_3_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_3_LANE ;break ;case 4 : - cfg->flags |=V4L2_MBUS_CSI2_4_LANE ; + cfg->csi2_flags |=V4L2_MBUS_CSI2_4_LANE ;break ;default :return -EINVAL ;drivers/media/i2c/tvp5150.c +4
-2@@ -976,8 +976,10 @@ static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,struct tvp5150 *decoder =to_tvp5150 (sd); cfg->type = decoder->mbus_type; - cfg->flags =V4L2_MBUS_MASTER |V4L2_MBUS_PCLK_SAMPLE_RISING - |V4L2_MBUS_FIELD_EVEN_LOW |V4L2_MBUS_DATA_ACTIVE_HIGH ; + cfg->pb_flags =V4L2_MBUS_MASTER + |V4L2_MBUS_PCLK_SAMPLE_RISING + |V4L2_MBUS_FIELD_EVEN_LOW + |V4L2_MBUS_DATA_ACTIVE_HIGH ;return 0 ; }drivers/media/platform/pxa_camera.c +4
-4@@ -616,7 +616,7 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cfbool hsync = true, vsync = true, pclk, data, mode;bool mipi_lanes, mipi_clock; - common_flags = cfg->flags & flags; + common_flags = cfg->__legacy_flags & flags;switch (cfg->type) {case V4L2_MBUS_PARALLEL :@@ -1621,7 +1621,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)if (!common_flags) {dev_warn (pcdev_to_dev (pcdev),"Flags incompatible: camera 0x%x, host 0x%lx\n" , - cfg.flags, bus_flags); + cfg.__legacy_flags, bus_flags);return -EINVAL ; } }else if (ret != -ENOIOCTLCMD ) {@@ -1657,7 +1657,7 @@ static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev) common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING ; } - cfg.flags = common_flags; + cfg.__legacy_flags = common_flags; ret =sensor_call (pcdev, video, s_mbus_config, &cfg);if (ret <0 && ret != -ENOIOCTLCMD ) { dev_dbg(pcdev_to_dev(pcdev),@@ -1688,7 +1688,7 @@ static int pxa_camera_try_bus_param(struct pxa_camera_dev *pcdev,if (!common_flags) {dev_warn (pcdev_to_dev (pcdev),"Flags incompatible: camera 0x%x, host 0x%lx\n" , - cfg.flags, bus_flags); + cfg.__legacy_flags, bus_flags);return -EINVAL ; } }else if (ret == -ENOIOCTLCMD ) {drivers/media/platform/rcar-vin/rcar-core.c +2
-2@@ -157,11 +157,11 @@ static int rvin_digital_parse_v4l2(struct device *dev,switch (rvge->mbus_cfg.type) {case V4L2_MBUS_PARALLEL :vin_dbg (vin,"Found PARALLEL media bus\n" ); - rvge->mbus_cfg.flags = vep->bus.parallel.flags; + rvge->mbus_cfg.pb_flags = vep->bus.parallel.flags;break ;case V4L2_MBUS_BT656 :vin_dbg (vin,"Found BT656 media bus\n" ); - rvge->mbus_cfg.flags =0 ; + rvge->mbus_cfg.pb_flags =0 ;break ;default :vin_err (vin,"Unknown media bus type\n" );drivers/media/platform/rcar-vin/rcar-dma.c +2
-2@@ -212,11 +212,11 @@ static int rvin_setup(struct rvin_dev *vin) dmr2 =VNDMR2_FTEV |VNDMR2_VLV (1 );/* Hsync Signal Polarity Select */ -if (!(vin->digital->mbus_cfg.flags &V4L2_MBUS_HSYNC_ACTIVE_LOW )) +if (!(vin->digital->mbus_cfg.pb_flags &V4L2_MBUS_HSYNC_ACTIVE_LOW )) dmr2 |=VNDMR2_HPS ;/* Vsync Signal Polarity Select */ -if (!(vin->digital->mbus_cfg.flags &V4L2_MBUS_VSYNC_ACTIVE_LOW )) +if (!(vin->digital->mbus_cfg.pb_flags &V4L2_MBUS_VSYNC_ACTIVE_LOW )) dmr2 |=VNDMR2_VPS ;/* drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +1
-1@@ -744,7 +744,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW ; } - cfg.flags = common_flags; + cfg.__legacy_flags = common_flags; ret =v4l2_subdev_call (sd, video, s_mbus_config, &cfg);if (ret <0 && ret != -ENOIOCTLCMD )return ret;drivers/media/platform/soc_camera/soc_camera.c +2
-1@@ -217,7 +217,8 @@ EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);unsigned long soc_camera_apply_board_flags (struct soc_camera_subdev_desc *ssdd,const struct v4l2_mbus_config *cfg) { -unsigned long f, flags = cfg->flags; +unsigned long f; +enum v4l2_mbus_parallel_and_bt656_flags flags = cfg->pb_flags;/* If only one of the two polarities is supported, switch to the opposite */ if (ssdd->flags &SOCAM_SENSOR_INVERT_HSYNC ) {drivers/media/platform/soc_camera/soc_camera_platform.c +1
-1@@ -104,7 +104,7 @@ static int soc_camera_platform_g_mbus_config(struct v4l2_subdev *sd, {struct soc_camera_platform_info *p =v4l2_get_subdevdata (sd); - cfg->flags = p->mbus_param; + cfg->__legacy_flags = p->mbus_param; cfg->type = p->mbus_type;return 0 ;drivers/media/platform/soc_camera/soc_mediabus.c +1
-1@@ -486,7 +486,7 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,bool hsync = true, vsync = true, pclk, data, mode;bool mipi_lanes, mipi_clock; - common_flags = cfg->flags & flags; + common_flags = cfg->__legacy_flags & flags;switch (cfg->type) {case V4L2_MBUS_PARALLEL :drivers/media/v4l2-core/v4l2-fwnode.c +3
-2@@ -44,7 +44,8 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, {struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;bool have_clk_lane = false; -unsigned int flags =0 , lanes_used =0 ; +unsigned int lanes_used =0 ; +enum v4l2_mbus_csi2_flags flags =0 ;unsigned int i;u32 v;int rval;@@ -112,7 +113,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus( struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep) { struct v4l2_fwnode_bus_parallel *bus = &vep->bus.parallel; -unsigned int flags =0 ; +enum v4l2_mbus_parallel_and_bt656_flags flags =0 ;u32 v;if (!fwnode_property_read_u32 (fwnode,"hsync-active" , &v))include/media/v4l2-fwnode.h +2
-2@@ -32,7 +32,7 @@ struct v4l2_async_subdev;/** * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure -* @flags: media bus (V4L2_MBUS_*) flags +* @flags: media bus CSI flags, as defined by &enum v4l2_mbus_csi2_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 @@ -40,7 +40,7 @@ struct v4l2_async_subdev;* the physical lanes. */ struct v4l2_fwnode_bus_mipi_csi2 { -unsigned int flags; +enum v4l2_mbus_csi2_flags flags;unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES ];unsigned char clock_lane;unsigned short num_data_lanes;include/media/v4l2-mediabus.h +98
-47@@ -15,51 +15,90 @@#include <linux/bitops.h> -/* Parallel flags */ -/* -* Can the client run in master or in slave mode. By "Master mode" an operation -* mode is meant, when the client (e.g., a camera sensor) is producing -* horizontal and vertical synchronisation. In "Slave mode" the host is -* providing these signals to the slave. +/** +* enum v4l2_mbus_flags - Media bus parallel and polarity flags +* +* @V4L2_MBUS_MASTER: the client runs on parallel master mode; +* @V4L2_MBUS_SLAVE: the client runs on parallel slave mode. +* @V4L2_MBUS_HSYNC_ACTIVE_HIGH: horizontal sync active on high level +* @V4L2_MBUS_HSYNC_ACTIVE_LOW: horizontal sync active on low level +* @V4L2_MBUS_VSYNC_ACTIVE_HIGH: vertical sync active on high level +* @V4L2_MBUS_VSYNC_ACTIVE_LOW: vertical sync active on low level +* @V4L2_MBUS_PCLK_SAMPLE_RISING: pixel clock sample on level rising +* @V4L2_MBUS_PCLK_SAMPLE_FALLING: pixel clock sample on level falling +* @V4L2_MBUS_DATA_ACTIVE_HIGH: data active on high level +* @V4L2_MBUS_DATA_ACTIVE_LOW: data active on low level +* @V4L2_MBUS_FIELD_EVEN_HIGH: FIELD = 0/1 - Field1 (odd)/Field2 (even) +* @V4L2_MBUS_FIELD_EVEN_LOW: FIELD = 1/0 - Field1 (odd)/Field2 (even) +* @V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH: Sync-on-green (SoG) signal active +* on high level +* @V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW: Sync-on-green (SoG) signal active +* on low level +* +* Those flags are used when the bus is in %V4L2_MBUS_PARALLEL or +* %V4L2_MBUS_BT656 mode. +* +* .. note:: +* +* #) @V4L2_MBUS_MASTER and @V4L2_MBUS_SLAVE are only valid if the bus +* is in %V4L2_MBUS_PARALLEL mode. They are used to specify if the +* client runs in master or in slave mode. +* +* In "Master mode" (@V4L2_MBUS_MASTER), the client (e.g., a camera +* sensor) is producing horizontal and vertical synchronization. +* +* In "Slave mode" (@V4L2_MBUS_SLAVE) the host is providing these signals +* to the slave. +* #) in %V4L2_MBUS_BT656 mode, ``V4L2_MBUS_HSYNC_*``, ``V4L2_MBUS_VSYNC_*`` +* and ``V4L2_MBUS_FIELD_*`` flags are unused. +* #) ``V4L2_MBUS_[HV]SYNC*`` flags should be also used for specifying +* configuration of hardware that uses [HV]REF signals */ -#define V4L2_MBUS_MASTER BIT(0) -#define V4L2_MBUS_SLAVE BIT(1) -/* -* Signal polarity flags -* Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused -* V4L2_MBUS_[HV]SYNC* flags should be also used for specifying -* configuration of hardware that uses [HV]REF signals -*/ -#define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2) -#define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3) -#define V4L2_MBUS_VSYNC_ACTIVE_HIGH BIT(4) -#define V4L2_MBUS_VSYNC_ACTIVE_LOW BIT(5) -#define V4L2_MBUS_PCLK_SAMPLE_RISING BIT(6) -#define V4L2_MBUS_PCLK_SAMPLE_FALLING BIT(7) -#define V4L2_MBUS_DATA_ACTIVE_HIGH BIT(8) -#define V4L2_MBUS_DATA_ACTIVE_LOW BIT(9) -/* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ -#define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10) -/* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ -#define V4L2_MBUS_FIELD_EVEN_LOW BIT(11) -/* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ -#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12) -#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13) +enum v4l2_mbus_parallel_and_bt656_flags { +V4L2_MBUS_MASTER =BIT (0 ), +V4L2_MBUS_SLAVE =BIT (1 ), +V4L2_MBUS_HSYNC_ACTIVE_HIGH =BIT (2 ), +V4L2_MBUS_HSYNC_ACTIVE_LOW =BIT (3 ), +V4L2_MBUS_VSYNC_ACTIVE_HIGH =BIT (4 ), +V4L2_MBUS_VSYNC_ACTIVE_LOW =BIT (5 ), +V4L2_MBUS_PCLK_SAMPLE_RISING =BIT (6 ), +V4L2_MBUS_PCLK_SAMPLE_FALLING =BIT (7 ), +V4L2_MBUS_DATA_ACTIVE_HIGH =BIT (8 ), +V4L2_MBUS_DATA_ACTIVE_LOW =BIT (9 ), +V4L2_MBUS_FIELD_EVEN_HIGH =BIT (10 ), +V4L2_MBUS_FIELD_EVEN_LOW =BIT (11 ), +V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH =BIT (12 ), +V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW =BIT (13 ), +}; -/* Serial flags */ -/* How many lanes the client can use */ -#define V4L2_MBUS_CSI2_1_LANE BIT(0) -#define V4L2_MBUS_CSI2_2_LANE BIT(1) -#define V4L2_MBUS_CSI2_3_LANE BIT(2) -#define V4L2_MBUS_CSI2_4_LANE BIT(3) -/* On which channels it can send video data */ -#define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4) -#define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5) -#define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6) -#define V4L2_MBUS_CSI2_CHANNEL_3 BIT(7) -/* Does it support only continuous or also non-continuous clock mode */ -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8) -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9) +/** +* enum v4l2_mbus_csi2_flags - Media bus serial flags +* +* @V4L2_MBUS_CSI2_1_LANE: One lane in use +* @V4L2_MBUS_CSI2_2_LANE: Two lanes in use +* @V4L2_MBUS_CSI2_3_LANE: Three lanes in use +* @V4L2_MBUS_CSI2_4_LANE: Four lanes in use +* @V4L2_MBUS_CSI2_CHANNEL_0: Channel 0 can send video data +* @V4L2_MBUS_CSI2_CHANNEL_1: Channel 1 can send video data +* @V4L2_MBUS_CSI2_CHANNEL_2: Channel 2 can send video data +* @V4L2_MBUS_CSI2_CHANNEL_3: Channel 3 can send video data +* @V4L2_MBUS_CSI2_CONTINUOUS_CLOCK: Supports continuous clock mode +* @V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK: Supports non-continuous clock mode +* +* Used only when the bus type is MIPI CSI-2. +*/ +enum v4l2_mbus_csi2_flags { +V4L2_MBUS_CSI2_1_LANE =BIT (0 ), +V4L2_MBUS_CSI2_2_LANE =BIT (1 ), +V4L2_MBUS_CSI2_3_LANE =BIT (2 ), +V4L2_MBUS_CSI2_4_LANE =BIT (3 ), +V4L2_MBUS_CSI2_CHANNEL_0 =BIT (4 ), +V4L2_MBUS_CSI2_CHANNEL_1 =BIT (5 ), +V4L2_MBUS_CSI2_CHANNEL_2 =BIT (6 ), +V4L2_MBUS_CSI2_CHANNEL_3 =BIT (7 ), +V4L2_MBUS_CSI2_CONTINUOUS_CLOCK =BIT (8 ), +V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK =BIT (9 ), +};#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)@@ -69,8 +108,8 @@/** * enum v4l2_mbus_type - media bus type * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync -* @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can -* also be used for BT.1120 +* @V4L2_MBUS_BT656: parallel interface with embedded synchronization using ITU-R BT.656 +* signaling. Can also be used for ISO-R BT.1120 signaling. * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface @@ -86,11 +125,23 @@ enum v4l2_mbus_type {/** * struct v4l2_mbus_config - media bus configuration * @type: in: interface type -* @flags: in / out: configuration flags, depending on @type +* @pb_flags: in / out: configuration flags, if @type is +* %V4L2_MBUS_PARALLEL or %V4L2_MBUS_BT656. +* @csi2_flags: in / out: configuration flags, if @type is +* %V4L2_MBUS_CSI2. +* @__legacy_flags: +* access flags, no matter the @type. +* Used just to avoid needing to rewrite the logic inside +* soc_camera and pxa_camera drivers. Don't use on newer +* drivers! */ struct v4l2_mbus_config {enum v4l2_mbus_type type; -unsigned int flags; +union { +enum v4l2_mbus_parallel_and_bt656_flags pb_flags; +enum v4l2_mbus_csi2_flags csi2_flags; +unsigned int __legacy_flags; + }; };/**
Re: [PATCH 5/8] media: v4l2-mediabus: convert flags to enums and document them
Em Tue, 19 Dec 2017 10:30:15 +0100
Philipp Zabel <[email protected]> escreveu:
Quoted 49 lines
Hi Mauro,
Quoted 23 lines · Mauro Carvalho Chehab
There is a mess with media bus flags: there are two sets of flags, one used by parallel and ITU-R BT.656 outputs, and another one for CSI2.
Depending on the type, the same bit has different meanings.
That's very confusing, and counter-intuitive. So, split them into two sets of flags, inside an enum.
This way, it becomes clearer that there are two separate sets of flags. It also makes easier if CSI1, CSP, CSI3, etc. would need a different set of flags.
As a side effect, enums can be documented via kernel-docs, so there will be an improvement at flags documentation.
Unfortunately,
soc_cameraandpxa_camerado a mess with the flags, using either one set of flags without proper checks about the type. That could be fixed, but, as both drivers are obsolete and in the process of cleanings, I opted to just keep the behavior, using an unsigned int inside those two drivers.Quoted 2 lines
Acked-by Hans Verkuil <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>If I am not mistaken this is missing a conversion of
drivers/staging/media/imx/imx-media-csi.c:--------8<--------
drivers/staging/media/imx/imx-media-csi.c +0
-0@@ -636,9 +636,10 @@ static int csi_setup(struct csi_priv *priv)
/* composembus_configfrom the upstream endpoint */ mbus_cfg.type =priv->upstream_ep.bus_type;drivers/staging/media/imx/imx-media-csi.c +4
-3- mbus_cfg.flags = (priv->upstream_ep.bus_type ==V4L2_MBUS_CSI2 ) ? - priv->upstream_ep.bus.mipi_csi2.flags : - priv->upstream_ep.bus.parallel.flags; +if (priv->upstream_ep.bus_type ==V4L2_MBUS_CSI2 ) + mbus_cfg.csi2_flags = priv->upstream_ep.bus.mipi_csi2.flags; +else + mbus_cfg.pb_flags = priv->upstream_ep.bus.parallel.flags;
drivers/staging/media/imx/imx-media-csi.c
Quoted 2 lines
drivers/staging/media/imx/imx-media-csi.c +0
-0/* * we need to pass input frame to CSI interface, but
Oh, thanks for noticing! I really hate having drivers that don't build with COMPILE_TEST, as that makes a lot harder to check if something broke.
Thanks,
Mauro
PATCH 6/8 media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
In reply to Mauro Carvalho ChehabThe __V4L2_SUBDEV_MK_GET_TRY() macro is used to define 3 functions that have the same arguments. The code of those functions is simple enough to just declare them, de-obfuscating the code.
While here, replace BUG_ON() by WARN_ON() as there's no reason why to panic the Kernel if this fails.
--- include/media/v4l2-subdev.h | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-)
include/media/v4l2-subdev.h +28 -12
@@ -896,19 +896,35 @@ struct v4l2_subdev_fh { container_of(fh, struct v4l2_subdev_fh, vfh)#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API ) -#define __V4L2_SUBDEV_MK_GET_TRY (rtype, fun_name, field_name) \ - static inline struct rtype * \ - fun_name(struct v4l2_subdev *sd, \ - struct v4l2_subdev_pad_config *cfg, \ - unsigned int pad) \ - { \ - BUG_ON(pad >= sd->entity.num_pads); \ - return &cfg[pad].field_name; \ - } +static inline struct v4l2_mbus_framefmt +*v4l2_subdev_get_try_format (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +unsigned int pad) +{ +if (WARN_ON (pad >= sd->entity.num_pads)) +return -EINVAL ; +return &cfg[pad].try_fmt; +} -__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt) -__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop) -__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose) +static inline struct v4l2_rect +*v4l2_subdev_get_try_crop (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +unsigned int pad) +{ +if (WARN_ON (pad >= sd->entity.num_pads)) +return -EINVAL ; +return &cfg[pad].try_crop; +} + +static inline struct v4l2_rect +*v4l2_subdev_get_try_compose (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +unsigned int pad) +{ +if (WARN_ON (pad >= sd->entity.num_pads)) +return -EINVAL ; +return &cfg[pad].try_compose; +}#endif extern const struct v4l2_file_operations v4l2_subdev_fops;
Signature · 1 line
2.14.3
PATCH 7/8 media: v4l2-subdev: document remaining undocumented functions
In reply to Mauro Carvalho ChehabThere are several undocumented v4l2-subdev functions that are part of kAPI. Document them.
--- include/media/v4l2-subdev.h | 69 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 5 deletions(-)
include/media/v4l2-subdev.h +64 -5
@@ -867,6 +867,13 @@ struct v4l2_subdev {struct v4l2_subdev_platform_data *pdata; }; + +/** +* media_entity_to_v4l2_subdev - Returns a &struct v4l2_subdev from +* the &struct media_entity embedded in it. +* +* @ent: pointer to &struct media_entity. +*/ #define media_entity_to_v4l2_subdev (ent) \ ({ \ typeof(ent) __me_sd_ent = (ent); \
@@ -876,14 +883,20 @@ struct v4l2_subdev {NULL ; \ }) +/** +* vdev_to_v4l2_subdev - Returns a &struct v4l2_subdev from +* the &struct video_device embedded on it. +* +* @vdev: pointer to &struct video_device +*/ #define vdev_to_v4l2_subdev (vdev) \ ((struct v4l2_subdev *)video_get_drvdata(vdev))/** * struct v4l2_subdev_fh - Used for storing subdev information per file handle * -* @vfh: pointer to struct v4l2_fh -* @pad: pointer to v4l2_subdev_pad_config +* @vfh: pointer to &struct v4l2_fh +* @pad: pointer to &struct v4l2_subdev_pad_config */ struct v4l2_subdev_fh {struct v4l2_fh vfh;
@@ -892,10 +905,25 @@ struct v4l2_subdev_fh {#endif }; +/** +* to_v4l2_subdev_fh - Returns a &struct v4l2_subdev_fh from +* the &struct v4l2_fh embedded on it. +* +* @fh: pointer to &struct v4l2_fh +*/ #define to_v4l2_subdev_fh (fh) \ container_of(fh, struct v4l2_subdev_fh, vfh)#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API ) + +/** +* v4l2_subdev_get_try_format - ancillary routine to call +* &struct v4l2_subdev_pad_config->try_fmt +* +* @sd: pointer to &struct v4l2_subdev +* @cfg: pointer to &struct v4l2_subdev_pad_config array. +* @pad: index of the pad in the @cfg array. +*/ static inline struct v4l2_mbus_framefmt *v4l2_subdev_get_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
@@ -906,6 +934,14 @@ static inline struct v4l2_mbus_framefmtreturn &cfg[pad].try_fmt; } +/** +* v4l2_subdev_get_try_crop - ancillary routine to call +* &struct v4l2_subdev_pad_config->try_crop +* +* @sd: pointer to &struct v4l2_subdev +* @cfg: pointer to &struct v4l2_subdev_pad_config array. +* @pad: index of the pad in the @cfg array. +*/ static inline struct v4l2_rect *v4l2_subdev_get_try_crop(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
@@ -916,6 +952,14 @@ static inline struct v4l2_rectreturn &cfg[pad].try_crop; } +/** +* v4l2_subdev_get_try_crop - ancillary routine to call +* &struct v4l2_subdev_pad_config->try_compose +* +* @sd: pointer to &struct v4l2_subdev +* @cfg: pointer to &struct v4l2_subdev_pad_config array. +* @pad: index of the pad in the @cfg array. +*/ static inline struct v4l2_rect *v4l2_subdev_get_try_compose(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
@@ -1032,9 +1076,16 @@ void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);void v4l2_subdev_init (struct v4l2_subdev *sd,const struct v4l2_subdev_ops *ops); -/* -* Call an ops of a v4l2_subdev, doing the right checks against -* NULL pointers. +/** +* v4l2_subdev_call - call an operation of a v4l2_subdev. +* +* @sd: pointer to the &struct v4l2_subdev +* @o: name of the element at &struct v4l2_subdev_ops that contains @f. +* Each element there groups a set of callbacks functions. +* @f: callback function that will be called if @cond matches. +* The callback functions are defined in groups, according to +* each element at &struct v4l2_subdev_ops. +* @args...: arguments for @f. * * Example: err = v4l2_subdev_call(sd, video, s_std, norm); */
@@ -1050,6 +1101,14 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, __result; \ }) +/** +* v4l2_subdev_has_op - Checks if a subdev defines a certain operation. +* +* @sd: pointer to the &struct v4l2_subdev +* @o: The group of callback functions in &struct v4l2_subdev_ops +* which @f is a part of. +* @f: callback function to be checked for its existence. +*/ #define v4l2_subdev_has_op (sd, o, f) \ ((sd)->ops->o && (sd)->ops->o->f)
Signature · 1 line
2.14.3
PATCH 8/8 media: v4l2-subdev: use kernel-doc markups to document subdev flags
In reply to Mauro Carvalho ChehabRight now, those are documented together with the subdev struct, instead of together with the definitions.
Convert the definitions to an enum, use BIT() macros and document it at its right place.
--- include/media/v4l2-subdev.h | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
include/media/v4l2-subdev.h +19 -15
@@ -18,6 +18,7 @@#define _V4L2_SUBDEV_H#include <linux/types.h> +#include <linux/bitops.h> #include <linux/v4l2-subdev.h> #include <media/media-entity.h> #include <media/v4l2-async.h>
@@ -772,14 +773,23 @@ struct v4l2_subdev_internal_ops {#define V4L2_SUBDEV_NAME_SIZE 32 -/* Set this flag if this subdev is a i2c device. */ -#define V4L2_SUBDEV_FL_IS_I2C (1U << 0) -/* Set this flag if this subdev is a spi device. */ -#define V4L2_SUBDEV_FL_IS_SPI (1U << 1) -/* Set this flag if this subdev needs a device node. */ -#define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2) -/* Set this flag if this subdev generates events. */ -#define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3) +/** +* enum v4l2_subdev_flags - flags used to describe a sub-device +* at &struct v4l2_subdev. +* +* @V4L2_SUBDEV_FL_IS_I2C: set this flag if this subdev is an I2C device; +* @V4L2_SUBDEV_FL_IS_SPI: set this flag if this subdev is a SPI device; +* @V4L2_SUBDEV_FL_HAS_DEVNODE: set this flag if this subdev needs +* a device node; +* @V4L2_SUBDEV_FL_HAS_EVENTS: set this flag if this subdev +* generates events. +*/ +enum v4l2_subdev_flags { +V4L2_SUBDEV_FL_IS_I2C =BIT (0 ), +V4L2_SUBDEV_FL_IS_SPI =BIT (1 ), +V4L2_SUBDEV_FL_HAS_DEVNODE =BIT (2 ), +V4L2_SUBDEV_FL_HAS_EVENTS =BIT (3 ), +};struct regulator_bulk_data ;
@@ -805,13 +815,7 @@ struct v4l2_subdev_platform_data {* @owner: The owner is the same as the driver's &struct device owner. * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev * owner. Initialized by v4l2_device_register_subdev(). -* @flags: subdev flags. Can be: -* %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device; -* %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device; -* %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if this subdev needs a -* device node; -* %V4L2_SUBDEV_FL_HAS_EVENTS - Set this flag if this subdev generates -* events. +* @flags: subdev flags, as defined by &enum v4l2_subdev_flags. * * @v4l2_dev: pointer to struct &v4l2_device * @ops: pointer to struct &v4l2_subdev_ops
Signature · 1 line
2.14.3