Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 2 | /* |
| 3 | * V4L2 asynchronous subdevice registration API |
| 4 | * |
| 5 | * Copyright (C) 2012-2013, Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef V4L2_ASYNC_H |
| 9 | #define V4L2_ASYNC_H |
| 10 | |
| 11 | #include <linux/list.h> |
| 12 | #include <linux/mutex.h> |
| 13 | |
Ezequiel Garcia | 517fd2b | 2021-01-08 18:17:28 +0100 | [diff] [blame] | 14 | struct dentry; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 15 | struct device; |
Sylwester Nawrocki | e7359f8 | 2013-07-19 12:21:29 -0300 | [diff] [blame] | 16 | struct device_node; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 17 | struct v4l2_device; |
| 18 | struct v4l2_subdev; |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 19 | struct v4l2_async_notifier; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 20 | |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 21 | /** |
| 22 | * enum v4l2_async_match_type - type of asynchronous subdevice logic to be used |
| 23 | * in order to identify a match |
| 24 | * |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 25 | * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address |
Sakari Ailus | ecdf0cf | 2016-08-16 06:54:59 -0300 | [diff] [blame] | 26 | * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 27 | * |
Kieran Bingham | 51a4756 | 2020-09-16 12:46:45 +0200 | [diff] [blame] | 28 | * This enum is used by the asynchronous sub-device logic to define the |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 29 | * algorithm that will be used to match an asynchronous device. |
| 30 | */ |
Sylwester Nawrocki | cfca764 | 2013-07-19 12:14:46 -0300 | [diff] [blame] | 31 | enum v4l2_async_match_type { |
Sylwester Nawrocki | cfca764 | 2013-07-19 12:14:46 -0300 | [diff] [blame] | 32 | V4L2_ASYNC_MATCH_I2C, |
Sakari Ailus | ecdf0cf | 2016-08-16 06:54:59 -0300 | [diff] [blame] | 33 | V4L2_ASYNC_MATCH_FWNODE, |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | /** |
| 37 | * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge |
Mauro Carvalho Chehab | f8b2737 | 2015-08-22 05:16:24 -0300 | [diff] [blame] | 38 | * |
| 39 | * @match_type: type of match that will be used |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 40 | * @match: union of per-bus type matching data sets |
Mauro Carvalho Chehab | eb0f73b | 2017-09-27 11:43:00 -0400 | [diff] [blame] | 41 | * @match.fwnode: |
| 42 | * pointer to &struct fwnode_handle to be matched. |
| 43 | * Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE. |
Mauro Carvalho Chehab | eb0f73b | 2017-09-27 11:43:00 -0400 | [diff] [blame] | 44 | * @match.i2c: embedded struct with I2C parameters to be matched. |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 45 | * Both @match.i2c.adapter_id and @match.i2c.address |
Mauro Carvalho Chehab | eb0f73b | 2017-09-27 11:43:00 -0400 | [diff] [blame] | 46 | * should be matched. |
| 47 | * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. |
| 48 | * @match.i2c.adapter_id: |
| 49 | * I2C adapter ID to be matched. |
| 50 | * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. |
| 51 | * @match.i2c.address: |
| 52 | * I2C address to be matched. |
| 53 | * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 54 | * @asd_list: used to add struct v4l2_async_subdev objects to the |
| 55 | * master notifier @asd_list |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 56 | * @list: used to link struct v4l2_async_subdev objects, waiting to be |
| 57 | * probed, to a notifier->waiting list |
Sakari Ailus | 9ca4653 | 2017-08-17 11:28:21 -0400 | [diff] [blame] | 58 | * |
| 59 | * When this struct is used as a member in a driver specific struct, |
| 60 | * the driver specific struct shall contain the &struct |
| 61 | * v4l2_async_subdev as its first member. |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 62 | */ |
| 63 | struct v4l2_async_subdev { |
Sylwester Nawrocki | cfca764 | 2013-07-19 12:14:46 -0300 | [diff] [blame] | 64 | enum v4l2_async_match_type match_type; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 65 | union { |
Mauro Carvalho Chehab | 4e48afe | 2017-09-27 10:12:00 -0400 | [diff] [blame] | 66 | struct fwnode_handle *fwnode; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 67 | struct { |
| 68 | int adapter_id; |
| 69 | unsigned short address; |
| 70 | } i2c; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 71 | } match; |
| 72 | |
| 73 | /* v4l2-async core private: not to be used by drivers */ |
| 74 | struct list_head list; |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 75 | struct list_head asd_list; |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | /** |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 79 | * struct v4l2_async_notifier_operations - Asynchronous V4L2 notifier operations |
| 80 | * @bound: a subdevice driver has successfully probed one of the subdevices |
Sakari Ailus | 2cab00b | 2017-09-24 20:54:31 -0400 | [diff] [blame] | 81 | * @complete: All subdevices have been probed successfully. The complete |
| 82 | * callback is only executed for the root notifier. |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 83 | * @unbind: a subdevice is leaving |
| 84 | */ |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 85 | struct v4l2_async_notifier_operations { |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 86 | int (*bound)(struct v4l2_async_notifier *notifier, |
| 87 | struct v4l2_subdev *subdev, |
| 88 | struct v4l2_async_subdev *asd); |
| 89 | int (*complete)(struct v4l2_async_notifier *notifier); |
| 90 | void (*unbind)(struct v4l2_async_notifier *notifier, |
| 91 | struct v4l2_subdev *subdev, |
| 92 | struct v4l2_async_subdev *asd); |
| 93 | }; |
| 94 | |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 95 | /** |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 96 | * struct v4l2_async_notifier - v4l2_device notifier data |
| 97 | * |
| 98 | * @ops: notifier operations |
Sakari Ailus | 2cab00b | 2017-09-24 20:54:31 -0400 | [diff] [blame] | 99 | * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise |
| 100 | * @sd: sub-device that registered the notifier, NULL otherwise |
| 101 | * @parent: parent notifier |
Steve Longerbeam | 66beb32 | 2018-09-29 15:54:19 -0400 | [diff] [blame] | 102 | * @asd_list: master list of struct v4l2_async_subdev |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 103 | * @waiting: list of struct v4l2_async_subdev, waiting for their drivers |
| 104 | * @done: list of struct v4l2_subdev, already probed |
| 105 | * @list: member in a global list of notifiers |
| 106 | */ |
| 107 | struct v4l2_async_notifier { |
| 108 | const struct v4l2_async_notifier_operations *ops; |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 109 | struct v4l2_device *v4l2_dev; |
Sakari Ailus | 2cab00b | 2017-09-24 20:54:31 -0400 | [diff] [blame] | 110 | struct v4l2_subdev *sd; |
| 111 | struct v4l2_async_notifier *parent; |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 112 | struct list_head asd_list; |
Laurent Pinchart | b6ee3f0 | 2017-08-30 13:18:04 -0400 | [diff] [blame] | 113 | struct list_head waiting; |
| 114 | struct list_head done; |
| 115 | struct list_head list; |
| 116 | }; |
| 117 | |
| 118 | /** |
Ezequiel Garcia | 517fd2b | 2021-01-08 18:17:28 +0100 | [diff] [blame] | 119 | * v4l2_async_debug_init - Initialize debugging tools. |
| 120 | * |
| 121 | * @debugfs_dir: pointer to the parent debugfs &struct dentry |
| 122 | */ |
| 123 | void v4l2_async_debug_init(struct dentry *debugfs_dir); |
| 124 | |
| 125 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 126 | * v4l2_async_nf_init - Initialize a notifier. |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 127 | * |
| 128 | * @notifier: pointer to &struct v4l2_async_notifier |
| 129 | * |
| 130 | * This function initializes the notifier @asd_list. It must be called |
Ezequiel Garcia | 3e90e5a | 2021-01-18 02:52:55 +0100 | [diff] [blame] | 131 | * before adding a subdevice to a notifier, using one of: |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 132 | * v4l2_async_nf_add_fwnode_remote(), |
| 133 | * v4l2_async_nf_add_fwnode(), |
| 134 | * v4l2_async_nf_add_i2c(), |
| 135 | * __v4l2_async_nf_add_subdev() or |
| 136 | * v4l2_async_nf_parse_fwnode_endpoints(). |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 137 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 138 | void v4l2_async_nf_init(struct v4l2_async_notifier *notifier); |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 139 | |
| 140 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 141 | * __v4l2_async_nf_add_subdev - Add an async subdev to the |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 142 | * notifier's master asd list. |
| 143 | * |
| 144 | * @notifier: pointer to &struct v4l2_async_notifier |
| 145 | * @asd: pointer to &struct v4l2_async_subdev |
| 146 | * |
Ezequiel Garcia | c1cc236 | 2021-01-18 02:52:57 +0100 | [diff] [blame] | 147 | * \warning: Drivers should avoid using this function and instead use one of: |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 148 | * v4l2_async_nf_add_fwnode(), |
| 149 | * v4l2_async_nf_add_fwnode_remote() or |
| 150 | * v4l2_async_nf_add_i2c(). |
Ezequiel Garcia | c1cc236 | 2021-01-18 02:52:57 +0100 | [diff] [blame] | 151 | * |
Laurent Pinchart | 6c11631 | 2020-08-11 22:59:35 +0200 | [diff] [blame] | 152 | * Call this function before registering a notifier to link the provided @asd to |
| 153 | * the notifiers master @asd_list. The @asd must be allocated with k*alloc() as |
| 154 | * it will be freed by the framework when the notifier is destroyed. |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 155 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 156 | int __v4l2_async_nf_add_subdev(struct v4l2_async_notifier *notifier, |
| 157 | struct v4l2_async_subdev *asd); |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 158 | |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 159 | struct v4l2_async_subdev * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 160 | __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, |
| 161 | struct fwnode_handle *fwnode, |
| 162 | unsigned int asd_struct_size); |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 163 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 164 | * v4l2_async_nf_add_fwnode - Allocate and add a fwnode async |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 165 | * subdev to the notifier's master asd_list. |
| 166 | * |
| 167 | * @notifier: pointer to &struct v4l2_async_notifier |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 168 | * @fwnode: fwnode handle of the sub-device to be matched, pointer to |
| 169 | * &struct fwnode_handle |
| 170 | * @type: Type of the driver's async sub-device struct. The &struct |
| 171 | * v4l2_async_subdev shall be the first member of the driver's async |
| 172 | * sub-device struct, i.e. both begin at the same memory address. |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 173 | * |
Sakari Ailus | 016413d | 2019-04-04 19:43:29 -0400 | [diff] [blame] | 174 | * Allocate a fwnode-matched asd of size asd_struct_size, and add it to the |
| 175 | * notifiers @asd_list. The function also gets a reference of the fwnode which |
| 176 | * is released later at notifier cleanup time. |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 177 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 178 | #define v4l2_async_nf_add_fwnode(notifier, fwnode, type) \ |
| 179 | ((type *)__v4l2_async_nf_add_fwnode(notifier, fwnode, sizeof(type))) |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 180 | |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 181 | struct v4l2_async_subdev * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 182 | __v4l2_async_nf_add_fwnode_remote(struct v4l2_async_notifier *notif, |
| 183 | struct fwnode_handle *endpoint, |
| 184 | unsigned int asd_struct_size); |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 185 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 186 | * v4l2_async_nf_add_fwnode_remote - Allocate and add a fwnode |
Sakari Ailus | 820342a | 2019-02-28 08:25:28 -0500 | [diff] [blame] | 187 | * remote async subdev to the |
| 188 | * notifier's master asd_list. |
| 189 | * |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 190 | * @notifier: pointer to &struct v4l2_async_notifier |
| 191 | * @ep: local endpoint pointing to the remote sub-device to be matched, |
| 192 | * pointer to &struct fwnode_handle |
| 193 | * @type: Type of the driver's async sub-device struct. The &struct |
| 194 | * v4l2_async_subdev shall be the first member of the driver's async |
| 195 | * sub-device struct, i.e. both begin at the same memory address. |
Sakari Ailus | 820342a | 2019-02-28 08:25:28 -0500 | [diff] [blame] | 196 | * |
| 197 | * Gets the remote endpoint of a given local endpoint, set it up for fwnode |
| 198 | * matching and adds the async sub-device to the notifier's @asd_list. The |
| 199 | * function also gets a reference of the fwnode which is released later at |
| 200 | * notifier cleanup time. |
| 201 | * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 202 | * This is just like v4l2_async_nf_add_fwnode(), but with the |
Ezequiel Garcia | c1cf3d8 | 2021-01-18 02:52:45 +0100 | [diff] [blame] | 203 | * exception that the fwnode refers to a local endpoint, not the remote one. |
Sakari Ailus | 820342a | 2019-02-28 08:25:28 -0500 | [diff] [blame] | 204 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 205 | #define v4l2_async_nf_add_fwnode_remote(notifier, ep, type) \ |
| 206 | ((type *)__v4l2_async_nf_add_fwnode_remote(notifier, ep, sizeof(type))) |
Sakari Ailus | 820342a | 2019-02-28 08:25:28 -0500 | [diff] [blame] | 207 | |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 208 | struct v4l2_async_subdev * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 209 | __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, |
| 210 | int adapter_id, unsigned short address, |
| 211 | unsigned int asd_struct_size); |
Sakari Ailus | 820342a | 2019-02-28 08:25:28 -0500 | [diff] [blame] | 212 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 213 | * v4l2_async_nf_add_i2c - Allocate and add an i2c async |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 214 | * subdev to the notifier's master asd_list. |
| 215 | * |
| 216 | * @notifier: pointer to &struct v4l2_async_notifier |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 217 | * @adapter: I2C adapter ID to be matched |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 218 | * @address: I2C address of sub-device to be matched |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 219 | * @type: Type of the driver's async sub-device struct. The &struct |
| 220 | * v4l2_async_subdev shall be the first member of the driver's async |
| 221 | * sub-device struct, i.e. both begin at the same memory address. |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 222 | * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 223 | * Same as v4l2_async_nf_add_fwnode() but for I2C matched |
Sakari Ailus | 8f202f8 | 2021-02-15 13:37:28 +0100 | [diff] [blame] | 224 | * sub-devices. |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 225 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 226 | #define v4l2_async_nf_add_i2c(notifier, adapter, address, type) \ |
| 227 | ((type *)__v4l2_async_nf_add_i2c(notifier, adapter, address, \ |
| 228 | sizeof(type))) |
Steve Longerbeam | 23989b4 | 2018-09-29 15:54:07 -0400 | [diff] [blame] | 229 | |
| 230 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 231 | * v4l2_async_nf_register - registers a subdevice asynchronous notifier |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 232 | * |
| 233 | * @v4l2_dev: pointer to &struct v4l2_device |
| 234 | * @notifier: pointer to &struct v4l2_async_notifier |
| 235 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 236 | int v4l2_async_nf_register(struct v4l2_device *v4l2_dev, |
| 237 | struct v4l2_async_notifier *notifier); |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 238 | |
| 239 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 240 | * v4l2_async_subdev_nf_register - registers a subdevice asynchronous |
Sakari Ailus | 2cab00b | 2017-09-24 20:54:31 -0400 | [diff] [blame] | 241 | * notifier for a sub-device |
| 242 | * |
| 243 | * @sd: pointer to &struct v4l2_subdev |
| 244 | * @notifier: pointer to &struct v4l2_async_notifier |
| 245 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 246 | int v4l2_async_subdev_nf_register(struct v4l2_subdev *sd, |
| 247 | struct v4l2_async_notifier *notifier); |
Sakari Ailus | 2cab00b | 2017-09-24 20:54:31 -0400 | [diff] [blame] | 248 | |
| 249 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 250 | * v4l2_async_nf_unregister - unregisters a subdevice |
Mauro Carvalho Chehab | 6087b21 | 2018-10-04 17:10:46 -0400 | [diff] [blame] | 251 | * asynchronous notifier |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 252 | * |
| 253 | * @notifier: pointer to &struct v4l2_async_notifier |
| 254 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 255 | void v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier); |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 256 | |
| 257 | /** |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 258 | * v4l2_async_nf_cleanup - clean up notifier resources |
Sakari Ailus | 9ca4653 | 2017-08-17 11:28:21 -0400 | [diff] [blame] | 259 | * @notifier: the notifier the resources of which are to be cleaned up |
| 260 | * |
| 261 | * Release memory resources related to a notifier, including the async |
| 262 | * sub-devices allocated for the purposes of the notifier but not the notifier |
| 263 | * itself. The user is responsible for calling this function to clean up the |
Steve Longerbeam | b47d7ff | 2018-09-29 15:54:06 -0400 | [diff] [blame] | 264 | * notifier after calling |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 265 | * v4l2_async_nf_add_fwnode_remote(), |
| 266 | * v4l2_async_nf_add_fwnode(), |
| 267 | * v4l2_async_nf_add_i2c(), |
| 268 | * __v4l2_async_nf_add_subdev() or |
| 269 | * v4l2_async_nf_parse_fwnode_endpoints(). |
Sakari Ailus | 9ca4653 | 2017-08-17 11:28:21 -0400 | [diff] [blame] | 270 | * |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 271 | * There is no harm from calling v4l2_async_nf_cleanup() in other |
Sakari Ailus | 9ca4653 | 2017-08-17 11:28:21 -0400 | [diff] [blame] | 272 | * cases as long as its memory has been zeroed after it has been |
| 273 | * allocated. |
| 274 | */ |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 275 | void v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier); |
Sakari Ailus | 9ca4653 | 2017-08-17 11:28:21 -0400 | [diff] [blame] | 276 | |
| 277 | /** |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 278 | * v4l2_async_register_subdev - registers a sub-device to the asynchronous |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 279 | * subdevice framework |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 280 | * |
| 281 | * @sd: pointer to &struct v4l2_subdev |
| 282 | */ |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 283 | int v4l2_async_register_subdev(struct v4l2_subdev *sd); |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 284 | |
| 285 | /** |
Sakari Ailus | 15786f7 | 2021-03-05 17:42:34 +0100 | [diff] [blame] | 286 | * v4l2_async_register_subdev_sensor - registers a sensor sub-device to the |
| 287 | * asynchronous sub-device framework and |
| 288 | * parse set up common sensor related |
| 289 | * devices |
Sakari Ailus | aef69d5 | 2017-09-24 18:47:44 -0400 | [diff] [blame] | 290 | * |
| 291 | * @sd: pointer to struct &v4l2_subdev |
| 292 | * |
| 293 | * This function is just like v4l2_async_register_subdev() with the exception |
| 294 | * that calling it will also parse firmware interfaces for remote references |
Sakari Ailus | 3c8c153 | 2021-03-05 18:13:12 +0100 | [diff] [blame] | 295 | * using v4l2_async_nf_parse_fwnode_sensor() and registers the |
Sakari Ailus | aef69d5 | 2017-09-24 18:47:44 -0400 | [diff] [blame] | 296 | * async sub-devices. The sub-device is similarly unregistered by calling |
| 297 | * v4l2_async_unregister_subdev(). |
| 298 | * |
| 299 | * While registered, the subdev module is marked as in-use. |
| 300 | * |
| 301 | * An error is returned if the module is no longer loaded on any attempts |
| 302 | * to register it. |
| 303 | */ |
Mauro Carvalho Chehab | 6087b21 | 2018-10-04 17:10:46 -0400 | [diff] [blame] | 304 | int __must_check |
Sakari Ailus | 15786f7 | 2021-03-05 17:42:34 +0100 | [diff] [blame] | 305 | v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd); |
Sakari Ailus | aef69d5 | 2017-09-24 18:47:44 -0400 | [diff] [blame] | 306 | |
| 307 | /** |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 308 | * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 309 | * subdevice framework |
Mauro Carvalho Chehab | ab4f5a4a | 2016-07-21 09:24:55 -0300 | [diff] [blame] | 310 | * |
| 311 | * @sd: pointer to &struct v4l2_subdev |
| 312 | */ |
Guennadi Liakhovetski | e9e3104 | 2013-01-08 07:06:31 -0300 | [diff] [blame] | 313 | void v4l2_async_unregister_subdev(struct v4l2_subdev *sd); |
| 314 | #endif |