v4l2-async.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * V4L2 asynchronous subdevice registration API
  3. *
  4. * Copyright (C) 2012-2013, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef V4L2_ASYNC_H
  11. #define V4L2_ASYNC_H
  12. #include <linux/list.h>
  13. #include <linux/mutex.h>
  14. struct device;
  15. struct device_node;
  16. struct v4l2_device;
  17. struct v4l2_subdev;
  18. struct v4l2_async_notifier;
  19. /* A random max subdevice number, used to allocate an array on stack */
  20. #define V4L2_MAX_SUBDEVS 128U
  21. enum v4l2_async_match_type {
  22. V4L2_ASYNC_MATCH_CUSTOM,
  23. V4L2_ASYNC_MATCH_DEVNAME,
  24. V4L2_ASYNC_MATCH_I2C,
  25. V4L2_ASYNC_MATCH_OF,
  26. };
  27. /**
  28. * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge
  29. *
  30. * @match_type: type of match that will be used
  31. * @match: union of per-bus type matching data sets
  32. * @list: used to link struct v4l2_async_subdev objects, waiting to be
  33. * probed, to a notifier->waiting list
  34. */
  35. struct v4l2_async_subdev {
  36. enum v4l2_async_match_type match_type;
  37. union {
  38. struct {
  39. const struct device_node *node;
  40. } of;
  41. struct {
  42. const char *name;
  43. } device_name;
  44. struct {
  45. int adapter_id;
  46. unsigned short address;
  47. } i2c;
  48. struct {
  49. bool (*match)(struct device *,
  50. struct v4l2_async_subdev *);
  51. void *priv;
  52. } custom;
  53. } match;
  54. /* v4l2-async core private: not to be used by drivers */
  55. struct list_head list;
  56. };
  57. /**
  58. * struct v4l2_async_notifier - v4l2_device notifier data
  59. *
  60. * @num_subdevs: number of subdevices
  61. * @subdevs: array of pointers to subdevice descriptors
  62. * @v4l2_dev: pointer to struct v4l2_device
  63. * @waiting: list of struct v4l2_async_subdev, waiting for their drivers
  64. * @done: list of struct v4l2_subdev, already probed
  65. * @list: member in a global list of notifiers
  66. * @bound: a subdevice driver has successfully probed one of subdevices
  67. * @complete: all subdevices have been probed successfully
  68. * @unbind: a subdevice is leaving
  69. */
  70. struct v4l2_async_notifier {
  71. unsigned int num_subdevs;
  72. struct v4l2_async_subdev **subdevs;
  73. struct v4l2_device *v4l2_dev;
  74. struct list_head waiting;
  75. struct list_head done;
  76. struct list_head list;
  77. int (*bound)(struct v4l2_async_notifier *notifier,
  78. struct v4l2_subdev *subdev,
  79. struct v4l2_async_subdev *asd);
  80. int (*complete)(struct v4l2_async_notifier *notifier);
  81. void (*unbind)(struct v4l2_async_notifier *notifier,
  82. struct v4l2_subdev *subdev,
  83. struct v4l2_async_subdev *asd);
  84. };
  85. int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
  86. struct v4l2_async_notifier *notifier);
  87. void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier);
  88. int v4l2_async_register_subdev(struct v4l2_subdev *sd);
  89. void v4l2_async_unregister_subdev(struct v4l2_subdev *sd);
  90. #endif