| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | V4L2 device support header. |
|---|
| 3 | 4 | |
|---|
| 4 | 5 | Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl> |
|---|
| 5 | 6 | |
|---|
| 6 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - (at your option) any later version. |
|---|
| 10 | | - |
|---|
| 11 | | - This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - GNU General Public License for more details. |
|---|
| 15 | | - |
|---|
| 16 | | - You should have received a copy of the GNU General Public License |
|---|
| 17 | | - along with this program; if not, write to the Free Software |
|---|
| 18 | | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | |
|---|
| 21 | 9 | #ifndef _V4L2_DEVICE_H |
|---|
| .. | .. |
|---|
| 84 | 72 | } |
|---|
| 85 | 73 | |
|---|
| 86 | 74 | /** |
|---|
| 87 | | - * v4l2_device_put - putss a V4L2 device reference |
|---|
| 75 | + * v4l2_device_put - puts a V4L2 device reference |
|---|
| 88 | 76 | * |
|---|
| 89 | 77 | * @v4l2_dev: pointer to struct &v4l2_device |
|---|
| 90 | 78 | * |
|---|
| .. | .. |
|---|
| 186 | 174 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); |
|---|
| 187 | 175 | |
|---|
| 188 | 176 | /** |
|---|
| 189 | | - * v4l2_device_register_subdev_nodes - Registers device nodes for all subdevs |
|---|
| 190 | | - * of the v4l2 device that are marked with |
|---|
| 191 | | - * the %V4L2_SUBDEV_FL_HAS_DEVNODE flag. |
|---|
| 177 | + * __v4l2_device_register_ro_subdev_nodes - Registers device nodes for |
|---|
| 178 | + * all subdevs of the v4l2 device that are marked with the |
|---|
| 179 | + * %V4L2_SUBDEV_FL_HAS_DEVNODE flag. |
|---|
| 180 | + * |
|---|
| 181 | + * @v4l2_dev: pointer to struct v4l2_device |
|---|
| 182 | + * @read_only: subdevices read-only flag. True to register the subdevices |
|---|
| 183 | + * device nodes in read-only mode, false to allow full access to the |
|---|
| 184 | + * subdevice userspace API. |
|---|
| 185 | + */ |
|---|
| 186 | +int __must_check |
|---|
| 187 | +__v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev, |
|---|
| 188 | + bool read_only); |
|---|
| 189 | + |
|---|
| 190 | +/** |
|---|
| 191 | + * v4l2_device_register_subdev_nodes - Registers subdevices device nodes with |
|---|
| 192 | + * unrestricted access to the subdevice userspace operations |
|---|
| 193 | + * |
|---|
| 194 | + * Internally calls __v4l2_device_register_subdev_nodes(). See its documentation |
|---|
| 195 | + * for more details. |
|---|
| 192 | 196 | * |
|---|
| 193 | 197 | * @v4l2_dev: pointer to struct v4l2_device |
|---|
| 194 | 198 | */ |
|---|
| 195 | | -int __must_check |
|---|
| 196 | | -v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev); |
|---|
| 199 | +static inline int __must_check |
|---|
| 200 | +v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) |
|---|
| 201 | +{ |
|---|
| 202 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
|---|
| 203 | + return __v4l2_device_register_subdev_nodes(v4l2_dev, false); |
|---|
| 204 | +#else |
|---|
| 205 | + return 0; |
|---|
| 206 | +#endif |
|---|
| 207 | +} |
|---|
| 208 | + |
|---|
| 209 | +/** |
|---|
| 210 | + * v4l2_device_register_ro_subdev_nodes - Registers subdevices device nodes |
|---|
| 211 | + * in read-only mode |
|---|
| 212 | + * |
|---|
| 213 | + * Internally calls __v4l2_device_register_subdev_nodes(). See its documentation |
|---|
| 214 | + * for more details. |
|---|
| 215 | + * |
|---|
| 216 | + * @v4l2_dev: pointer to struct v4l2_device |
|---|
| 217 | + */ |
|---|
| 218 | +static inline int __must_check |
|---|
| 219 | +v4l2_device_register_ro_subdev_nodes(struct v4l2_device *v4l2_dev) |
|---|
| 220 | +{ |
|---|
| 221 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
|---|
| 222 | + return __v4l2_device_register_subdev_nodes(v4l2_dev, true); |
|---|
| 223 | +#else |
|---|
| 224 | + return 0; |
|---|
| 225 | +#endif |
|---|
| 226 | +} |
|---|
| 197 | 227 | |
|---|
| 198 | 228 | /** |
|---|
| 199 | 229 | * v4l2_subdev_notify - Sends a notification to v4l2_device. |
|---|
| .. | .. |
|---|
| 209 | 239 | { |
|---|
| 210 | 240 | if (sd && sd->v4l2_dev && sd->v4l2_dev->notify) |
|---|
| 211 | 241 | sd->v4l2_dev->notify(sd, notification, arg); |
|---|
| 242 | +} |
|---|
| 243 | + |
|---|
| 244 | +/** |
|---|
| 245 | + * v4l2_device_supports_requests - Test if requests are supported. |
|---|
| 246 | + * |
|---|
| 247 | + * @v4l2_dev: pointer to struct v4l2_device |
|---|
| 248 | + */ |
|---|
| 249 | +static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev) |
|---|
| 250 | +{ |
|---|
| 251 | + return v4l2_dev->mdev && v4l2_dev->mdev->ops && |
|---|
| 252 | + v4l2_dev->mdev->ops->req_queue; |
|---|
| 212 | 253 | } |
|---|
| 213 | 254 | |
|---|
| 214 | 255 | /* Helper macros to iterate over all subdevs. */ |
|---|
| .. | .. |
|---|
| 241 | 282 | * @f: operation function that will be called if @cond matches. |
|---|
| 242 | 283 | * The operation functions are defined in groups, according to |
|---|
| 243 | 284 | * each element at &struct v4l2_subdev_ops. |
|---|
| 244 | | - * @args...: arguments for @f. |
|---|
| 285 | + * @args: arguments for @f. |
|---|
| 245 | 286 | * |
|---|
| 246 | 287 | * Ignore any errors. |
|---|
| 247 | 288 | * |
|---|
| .. | .. |
|---|
| 266 | 307 | * @f: operation function that will be called if @cond matches. |
|---|
| 267 | 308 | * The operation functions are defined in groups, according to |
|---|
| 268 | 309 | * each element at &struct v4l2_subdev_ops. |
|---|
| 269 | | - * @args...: arguments for @f. |
|---|
| 310 | + * @args: arguments for @f. |
|---|
| 270 | 311 | * |
|---|
| 271 | 312 | * Ignore any errors. |
|---|
| 272 | 313 | * |
|---|
| .. | .. |
|---|
| 294 | 335 | * @f: operation function that will be called if @cond matches. |
|---|
| 295 | 336 | * The operation functions are defined in groups, according to |
|---|
| 296 | 337 | * each element at &struct v4l2_subdev_ops. |
|---|
| 297 | | - * @args...: arguments for @f. |
|---|
| 338 | + * @args: arguments for @f. |
|---|
| 298 | 339 | * |
|---|
| 299 | 340 | * Return: |
|---|
| 300 | 341 | * |
|---|
| .. | .. |
|---|
| 329 | 370 | * @f: operation function that will be called if @cond matches. |
|---|
| 330 | 371 | * The operation functions are defined in groups, according to |
|---|
| 331 | 372 | * each element at &struct v4l2_subdev_ops. |
|---|
| 332 | | - * @args...: arguments for @f. |
|---|
| 373 | + * @args: arguments for @f. |
|---|
| 333 | 374 | * |
|---|
| 334 | 375 | * Return: |
|---|
| 335 | 376 | * |
|---|
| .. | .. |
|---|
| 360 | 401 | * @f: operation function that will be called if @cond matches. |
|---|
| 361 | 402 | * The operation functions are defined in groups, according to |
|---|
| 362 | 403 | * each element at &struct v4l2_subdev_ops. |
|---|
| 363 | | - * @args...: arguments for @f. |
|---|
| 404 | + * @args: arguments for @f. |
|---|
| 364 | 405 | * |
|---|
| 365 | 406 | * Ignore any errors. |
|---|
| 366 | 407 | * |
|---|
| .. | .. |
|---|
| 389 | 430 | * @f: operation function that will be called if @cond matches. |
|---|
| 390 | 431 | * The operation functions are defined in groups, according to |
|---|
| 391 | 432 | * each element at &struct v4l2_subdev_ops. |
|---|
| 392 | | - * @args...: arguments for @f. |
|---|
| 433 | + * @args: arguments for @f. |
|---|
| 393 | 434 | * |
|---|
| 394 | 435 | * Return: |
|---|
| 395 | 436 | * |
|---|
| .. | .. |
|---|
| 420 | 461 | * @f: operation function that will be called if @cond matches. |
|---|
| 421 | 462 | * The operation functions are defined in groups, according to |
|---|
| 422 | 463 | * each element at &struct v4l2_subdev_ops. |
|---|
| 423 | | - * @args...: arguments for @f. |
|---|
| 464 | + * @args: arguments for @f. |
|---|
| 424 | 465 | * |
|---|
| 425 | 466 | * Ignore any errors. |
|---|
| 426 | 467 | * |
|---|
| .. | .. |
|---|
| 448 | 489 | * @f: operation function that will be called if @cond matches. |
|---|
| 449 | 490 | * The operation functions are defined in groups, according to |
|---|
| 450 | 491 | * each element at &struct v4l2_subdev_ops. |
|---|
| 451 | | - * @args...: arguments for @f. |
|---|
| 492 | + * @args: arguments for @f. |
|---|
| 452 | 493 | * |
|---|
| 453 | 494 | * Return: |
|---|
| 454 | 495 | * |
|---|