hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/media/v4l2-device.h
....@@ -1,21 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 V4L2 device support header.
34
45 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
56
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
197 */
208
219 #ifndef _V4L2_DEVICE_H
....@@ -84,7 +72,7 @@
8472 }
8573
8674 /**
87
- * v4l2_device_put - putss a V4L2 device reference
75
+ * v4l2_device_put - puts a V4L2 device reference
8876 *
8977 * @v4l2_dev: pointer to struct &v4l2_device
9078 *
....@@ -186,14 +174,56 @@
186174 void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
187175
188176 /**
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.
192196 *
193197 * @v4l2_dev: pointer to struct v4l2_device
194198 */
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
+}
197227
198228 /**
199229 * v4l2_subdev_notify - Sends a notification to v4l2_device.
....@@ -209,6 +239,17 @@
209239 {
210240 if (sd && sd->v4l2_dev && sd->v4l2_dev->notify)
211241 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;
212253 }
213254
214255 /* Helper macros to iterate over all subdevs. */
....@@ -241,7 +282,7 @@
241282 * @f: operation function that will be called if @cond matches.
242283 * The operation functions are defined in groups, according to
243284 * each element at &struct v4l2_subdev_ops.
244
- * @args...: arguments for @f.
285
+ * @args: arguments for @f.
245286 *
246287 * Ignore any errors.
247288 *
....@@ -266,7 +307,7 @@
266307 * @f: operation function that will be called if @cond matches.
267308 * The operation functions are defined in groups, according to
268309 * each element at &struct v4l2_subdev_ops.
269
- * @args...: arguments for @f.
310
+ * @args: arguments for @f.
270311 *
271312 * Ignore any errors.
272313 *
....@@ -294,7 +335,7 @@
294335 * @f: operation function that will be called if @cond matches.
295336 * The operation functions are defined in groups, according to
296337 * each element at &struct v4l2_subdev_ops.
297
- * @args...: arguments for @f.
338
+ * @args: arguments for @f.
298339 *
299340 * Return:
300341 *
....@@ -329,7 +370,7 @@
329370 * @f: operation function that will be called if @cond matches.
330371 * The operation functions are defined in groups, according to
331372 * each element at &struct v4l2_subdev_ops.
332
- * @args...: arguments for @f.
373
+ * @args: arguments for @f.
333374 *
334375 * Return:
335376 *
....@@ -360,7 +401,7 @@
360401 * @f: operation function that will be called if @cond matches.
361402 * The operation functions are defined in groups, according to
362403 * each element at &struct v4l2_subdev_ops.
363
- * @args...: arguments for @f.
404
+ * @args: arguments for @f.
364405 *
365406 * Ignore any errors.
366407 *
....@@ -389,7 +430,7 @@
389430 * @f: operation function that will be called if @cond matches.
390431 * The operation functions are defined in groups, according to
391432 * each element at &struct v4l2_subdev_ops.
392
- * @args...: arguments for @f.
433
+ * @args: arguments for @f.
393434 *
394435 * Return:
395436 *
....@@ -420,7 +461,7 @@
420461 * @f: operation function that will be called if @cond matches.
421462 * The operation functions are defined in groups, according to
422463 * each element at &struct v4l2_subdev_ops.
423
- * @args...: arguments for @f.
464
+ * @args: arguments for @f.
424465 *
425466 * Ignore any errors.
426467 *
....@@ -448,7 +489,7 @@
448489 * @f: operation function that will be called if @cond matches.
449490 * The operation functions are defined in groups, according to
450491 * each element at &struct v4l2_subdev_ops.
451
- * @args...: arguments for @f.
492
+ * @args: arguments for @f.
452493 *
453494 * Return:
454495 *