aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-device.h')
-rw-r--r--include/media/v4l2-device.h246
1 files changed, 211 insertions, 35 deletions
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8ffa94009d1a..0c9e4da55499 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -38,7 +38,7 @@ struct v4l2_ctrl_handler;
38 * @lock: lock this struct; can be used by the driver as well 38 * @lock: lock this struct; can be used by the driver as well
39 * if this struct is embedded into a larger struct. 39 * if this struct is embedded into a larger struct.
40 * @name: unique device name, by default the driver name + bus ID 40 * @name: unique device name, by default the driver name + bus ID
41 * @notify: notify callback called by some sub-devices. 41 * @notify: notify operation called by some sub-devices.
42 * @ctrl_handler: The control handler. May be %NULL. 42 * @ctrl_handler: The control handler. May be %NULL.
43 * @prio: Device's priority state 43 * @prio: Device's priority state
44 * @ref: Keep track of the references to this struct. 44 * @ref: Keep track of the references to this struct.
@@ -56,7 +56,6 @@ struct v4l2_ctrl_handler;
56 * #) @dev->driver_data points to this struct. 56 * #) @dev->driver_data points to this struct.
57 * #) @dev might be %NULL if there is no parent device 57 * #) @dev might be %NULL if there is no parent device
58 */ 58 */
59
60struct v4l2_device { 59struct v4l2_device {
61 struct device *dev; 60 struct device *dev;
62#if defined(CONFIG_MEDIA_CONTROLLER) 61#if defined(CONFIG_MEDIA_CONTROLLER)
@@ -166,7 +165,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
166 * v4l2_device_register_subdev - Registers a subdev with a v4l2 device. 165 * v4l2_device_register_subdev - Registers a subdev with a v4l2 device.
167 * 166 *
168 * @v4l2_dev: pointer to struct &v4l2_device 167 * @v4l2_dev: pointer to struct &v4l2_device
169 * @sd: pointer to struct &v4l2_subdev 168 * @sd: pointer to &struct v4l2_subdev
170 * 169 *
171 * While registered, the subdev module is marked as in-use. 170 * While registered, the subdev module is marked as in-use.
172 * 171 *
@@ -179,7 +178,7 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
179/** 178/**
180 * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device. 179 * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device.
181 * 180 *
182 * @sd: pointer to struct &v4l2_subdev 181 * @sd: pointer to &struct v4l2_subdev
183 * 182 *
184 * .. note :: 183 * .. note ::
185 * 184 *
@@ -201,7 +200,7 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
201/** 200/**
202 * v4l2_subdev_notify - Sends a notification to v4l2_device. 201 * v4l2_subdev_notify - Sends a notification to v4l2_device.
203 * 202 *
204 * @sd: pointer to struct &v4l2_subdev 203 * @sd: pointer to &struct v4l2_subdev
205 * @notification: type of notification. Please notice that the notification 204 * @notification: type of notification. Please notice that the notification
206 * type is driver-specific. 205 * type is driver-specific.
207 * @arg: arguments for the notification. Those are specific to each 206 * @arg: arguments for the notification. Those are specific to each
@@ -214,13 +213,43 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
214 sd->v4l2_dev->notify(sd, notification, arg); 213 sd->v4l2_dev->notify(sd, notification, arg);
215} 214}
216 215
217/* Iterate over all subdevs. */ 216/* Helper macros to iterate over all subdevs. */
217
218/**
219 * v4l2_device_for_each_subdev - Helper macro that interates over all
220 * sub-devices of a given &v4l2_device.
221 *
222 * @sd: pointer that will be filled by the macro with all
223 * &struct v4l2_subdev pointer used as an iterator by the loop.
224 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
225 *
226 * This macro iterates over all sub-devices owned by the @v4l2_dev device.
227 * It acts as a for loop iterator and executes the next statement with
228 * the @sd variable pointing to each sub-device in turn.
229 */
218#define v4l2_device_for_each_subdev(sd, v4l2_dev) \ 230#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
219 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) 231 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
220 232
221/* Call the specified callback for all subdevs matching the condition. 233/**
222 Ignore any errors. Note that you cannot add or delete a subdev 234 * __v4l2_device_call_subdevs_p - Calls the specified operation for
223 while walking the subdevs list. */ 235 * all subdevs matching the condition.
236 *
237 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
238 * @sd: pointer that will be filled by the macro with all
239 * &struct v4l2_subdev pointer used as an iterator by the loop.
240 * @cond: condition to be match
241 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
242 * Each element there groups a set of operations functions.
243 * @f: operation function that will be called if @cond matches.
244 * The operation functions are defined in groups, according to
245 * each element at &struct v4l2_subdev_ops.
246 * @args...: arguments for @f.
247 *
248 * Ignore any errors.
249 *
250 * Note: subdevs cannot be added or deleted while walking
251 * the subdevs list.
252 */
224#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ 253#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
225 do { \ 254 do { \
226 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \ 255 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
@@ -228,6 +257,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
228 (sd)->ops->o->f((sd) , ##args); \ 257 (sd)->ops->o->f((sd) , ##args); \
229 } while (0) 258 } while (0)
230 259
260/**
261 * __v4l2_device_call_subdevs - Calls the specified operation for
262 * all subdevs matching the condition.
263 *
264 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
265 * @cond: condition to be match
266 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
267 * Each element there groups a set of operations functions.
268 * @f: operation function that will be called if @cond matches.
269 * The operation functions are defined in groups, according to
270 * each element at &struct v4l2_subdev_ops.
271 * @args...: arguments for @f.
272 *
273 * Ignore any errors.
274 *
275 * Note: subdevs cannot be added or deleted while walking
276 * the subdevs list.
277 */
231#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ 278#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
232 do { \ 279 do { \
233 struct v4l2_subdev *__sd; \ 280 struct v4l2_subdev *__sd; \
@@ -236,10 +283,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
236 f , ##args); \ 283 f , ##args); \
237 } while (0) 284 } while (0)
238 285
239/* Call the specified callback for all subdevs matching the condition. 286/**
240 If the callback returns an error other than 0 or -ENOIOCTLCMD, then 287 * __v4l2_device_call_subdevs_until_err_p - Calls the specified operation for
241 return with that error code. Note that you cannot add or delete a 288 * all subdevs matching the condition.
242 subdev while walking the subdevs list. */ 289 *
290 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
291 * @sd: pointer that will be filled by the macro with all
292 * &struct v4l2_subdev sub-devices associated with @v4l2_dev.
293 * @cond: condition to be match
294 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
295 * Each element there groups a set of operations functions.
296 * @f: operation function that will be called if @cond matches.
297 * The operation functions are defined in groups, according to
298 * each element at &struct v4l2_subdev_ops.
299 * @args...: arguments for @f.
300 *
301 * Return:
302 *
303 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
304 * for any subdevice, then abort and return with that error code, zero
305 * otherwise.
306 *
307 * Note: subdevs cannot be added or deleted while walking
308 * the subdevs list.
309 */
243#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ 310#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
244({ \ 311({ \
245 long __err = 0; \ 312 long __err = 0; \
@@ -253,6 +320,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
253 (__err == -ENOIOCTLCMD) ? 0 : __err; \ 320 (__err == -ENOIOCTLCMD) ? 0 : __err; \
254}) 321})
255 322
323/**
324 * __v4l2_device_call_subdevs_until_err - Calls the specified operation for
325 * all subdevs matching the condition.
326 *
327 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
328 * @cond: condition to be match
329 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
330 * Each element there groups a set of operations functions.
331 * @f: operation function that will be called if @cond matches.
332 * The operation functions are defined in groups, according to
333 * each element at &struct v4l2_subdev_ops.
334 * @args...: arguments for @f.
335 *
336 * Return:
337 *
338 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
339 * for any subdevice, then abort and return with that error code,
340 * zero otherwise.
341 *
342 * Note: subdevs cannot be added or deleted while walking
343 * the subdevs list.
344 */
256#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ 345#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
257({ \ 346({ \
258 struct v4l2_subdev *__sd; \ 347 struct v4l2_subdev *__sd; \
@@ -260,9 +349,26 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
260 f , ##args); \ 349 f , ##args); \
261}) 350})
262 351
263/* Call the specified callback for all subdevs matching grp_id (if 0, then 352/**
264 match them all). Ignore any errors. Note that you cannot add or delete 353 * v4l2_device_call_all - Calls the specified operation for
265 a subdev while walking the subdevs list. */ 354 * all subdevs matching the &v4l2_subdev.grp_id, as assigned
355 * by the bridge driver.
356 *
357 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
358 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
359 * Use 0 to match them all.
360 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
361 * Each element there groups a set of operations functions.
362 * @f: operation function that will be called if @cond matches.
363 * The operation functions are defined in groups, according to
364 * each element at &struct v4l2_subdev_ops.
365 * @args...: arguments for @f.
366 *
367 * Ignore any errors.
368 *
369 * Note: subdevs cannot be added or deleted while walking
370 * the subdevs list.
371 */
266#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ 372#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
267 do { \ 373 do { \
268 struct v4l2_subdev *__sd; \ 374 struct v4l2_subdev *__sd; \
@@ -272,10 +378,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
272 ##args); \ 378 ##args); \
273 } while (0) 379 } while (0)
274 380
275/* Call the specified callback for all subdevs matching grp_id (if 0, then 381/**
276 match them all). If the callback returns an error other than 0 or 382 * v4l2_device_call_until_err - Calls the specified operation for
277 -ENOIOCTLCMD, then return with that error code. Note that you cannot 383 * all subdevs matching the &v4l2_subdev.grp_id, as assigned
278 add or delete a subdev while walking the subdevs list. */ 384 * by the bridge driver, until an error occurs.
385 *
386 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
387 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
388 * Use 0 to match them all.
389 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
390 * Each element there groups a set of operations functions.
391 * @f: operation function that will be called if @cond matches.
392 * The operation functions are defined in groups, according to
393 * each element at &struct v4l2_subdev_ops.
394 * @args...: arguments for @f.
395 *
396 * Return:
397 *
398 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
399 * for any subdevice, then abort and return with that error code,
400 * zero otherwise.
401 *
402 * Note: subdevs cannot be added or deleted while walking
403 * the subdevs list.
404 */
279#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ 405#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
280({ \ 406({ \
281 struct v4l2_subdev *__sd; \ 407 struct v4l2_subdev *__sd; \
@@ -284,10 +410,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
284 ##args); \ 410 ##args); \
285}) 411})
286 412
287/* 413/**
288 * Call the specified callback for all subdevs where grp_id & grpmsk != 0 414 * v4l2_device_mask_call_all - Calls the specified operation for
289 * (if grpmsk == `0, then match them all). Ignore any errors. Note that you 415 * all subdevices where a group ID matches a specified bitmask.
290 * cannot add or delete a subdev while walking the subdevs list. 416 *
417 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
418 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
419 * group ID to be matched. Use 0 to match them all.
420 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
421 * Each element there groups a set of operations functions.
422 * @f: operation function that will be called if @cond matches.
423 * The operation functions are defined in groups, according to
424 * each element at &struct v4l2_subdev_ops.
425 * @args...: arguments for @f.
426 *
427 * Ignore any errors.
428 *
429 * Note: subdevs cannot be added or deleted while walking
430 * the subdevs list.
291 */ 431 */
292#define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \ 432#define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \
293 do { \ 433 do { \
@@ -298,11 +438,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
298 ##args); \ 438 ##args); \
299 } while (0) 439 } while (0)
300 440
301/* 441/**
302 * Call the specified callback for all subdevs where grp_id & grpmsk != 0 442 * v4l2_device_mask_call_until_err - Calls the specified operation for
303 * (if grpmsk == 0, then match them all). If the callback returns an error 443 * all subdevices where a group ID matches a specified bitmask.
304 * other than 0 or %-ENOIOCTLCMD, then return with that error code. Note that 444 *
305 * you cannot add or delete a subdev while walking the subdevs list. 445 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
446 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
447 * group ID to be matched. Use 0 to match them all.
448 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
449 * Each element there groups a set of operations functions.
450 * @f: operation function that will be called if @cond matches.
451 * The operation functions are defined in groups, according to
452 * each element at &struct v4l2_subdev_ops.
453 * @args...: arguments for @f.
454 *
455 * Return:
456 *
457 * If the operation returns an error other than 0 or ``-ENOIOCTLCMD``
458 * for any subdevice, then abort and return with that error code,
459 * zero otherwise.
460 *
461 * Note: subdevs cannot be added or deleted while walking
462 * the subdevs list.
306 */ 463 */
307#define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \ 464#define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \
308({ \ 465({ \
@@ -312,9 +469,19 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
312 ##args); \ 469 ##args); \
313}) 470})
314 471
315/* 472
316 * Does any subdev with matching grpid (or all if grpid == 0) has the given 473/**
317 * op? 474 * v4l2_device_has_op - checks if any subdev with matching grpid has a
475 * given ops.
476 *
477 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
478 * @grpid: &struct v4l2_subdev->grp_id group ID to match.
479 * Use 0 to match them all.
480 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
481 * Each element there groups a set of operations functions.
482 * @f: operation function that will be called if @cond matches.
483 * The operation functions are defined in groups, according to
484 * each element at &struct v4l2_subdev_ops.
318 */ 485 */
319#define v4l2_device_has_op(v4l2_dev, grpid, o, f) \ 486#define v4l2_device_has_op(v4l2_dev, grpid, o, f) \
320({ \ 487({ \
@@ -331,9 +498,18 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
331 __result; \ 498 __result; \
332}) 499})
333 500
334/* 501/**
335 * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given 502 * v4l2_device_mask_has_op - checks if any subdev with matching group
336 * op? 503 * mask has a given ops.
504 *
505 * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over.
506 * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id
507 * group ID to be matched. Use 0 to match them all.
508 * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
509 * Each element there groups a set of operations functions.
510 * @f: operation function that will be called if @cond matches.
511 * The operation functions are defined in groups, according to
512 * each element at &struct v4l2_subdev_ops.
337 */ 513 */
338#define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \ 514#define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \
339({ \ 515({ \