v4l2-async.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 v4l2_device;
  16. struct v4l2_subdev;
  17. struct v4l2_async_notifier;
  18. /* A random max subdevice number, used to allocate an array on stack */
  19. #define V4L2_MAX_SUBDEVS 128U
  20. enum v4l2_async_bus_type {
  21. V4L2_ASYNC_BUS_CUSTOM,
  22. V4L2_ASYNC_BUS_PLATFORM,
  23. V4L2_ASYNC_BUS_I2C,
  24. };
  25. /**
  26. * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge
  27. * @bus_type: subdevice bus type to select the appropriate matching method
  28. * @match: union of per-bus type matching data sets
  29. * @list: used to link struct v4l2_async_subdev objects, waiting to be
  30. * probed, to a notifier->waiting list
  31. */
  32. struct v4l2_async_subdev {
  33. enum v4l2_async_bus_type bus_type;
  34. union {
  35. struct {
  36. const char *name;
  37. } platform;
  38. struct {
  39. int adapter_id;
  40. unsigned short address;
  41. } i2c;
  42. struct {
  43. bool (*match)(struct device *,
  44. struct v4l2_async_subdev *);
  45. void *priv;
  46. } custom;
  47. } match;
  48. /* v4l2-async core private: not to be used by drivers */
  49. struct list_head list;
  50. };
  51. /**
  52. * v4l2_async_subdev_list - provided by subdevices
  53. * @list: links struct v4l2_async_subdev_list objects to a global list
  54. * before probing, and onto notifier->done after probing
  55. * @asd: pointer to respective struct v4l2_async_subdev
  56. * @notifier: pointer to managing notifier
  57. */
  58. struct v4l2_async_subdev_list {
  59. struct list_head list;
  60. struct v4l2_async_subdev *asd;
  61. struct v4l2_async_notifier *notifier;
  62. };
  63. /**
  64. * v4l2_async_notifier - v4l2_device notifier data
  65. * @num_subdevs:number of subdevices
  66. * @subdev: array of pointers to subdevice descriptors
  67. * @v4l2_dev: pointer to struct v4l2_device
  68. * @waiting: list of struct v4l2_async_subdev, waiting for their drivers
  69. * @done: list of struct v4l2_async_subdev_list, already probed
  70. * @list: member in a global list of notifiers
  71. * @bound: a subdevice driver has successfully probed one of subdevices
  72. * @complete: all subdevices have been probed successfully
  73. * @unbind: a subdevice is leaving
  74. */
  75. struct v4l2_async_notifier {
  76. unsigned int num_subdevs;
  77. struct v4l2_async_subdev **subdev;
  78. struct v4l2_device *v4l2_dev;
  79. struct list_head waiting;
  80. struct list_head done;
  81. struct list_head list;
  82. int (*bound)(struct v4l2_async_notifier *notifier,
  83. struct v4l2_subdev *subdev,
  84. struct v4l2_async_subdev *asd);
  85. int (*complete)(struct v4l2_async_notifier *notifier);
  86. void (*unbind)(struct v4l2_async_notifier *notifier,
  87. struct v4l2_subdev *subdev,
  88. struct v4l2_async_subdev *asd);
  89. };
  90. int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
  91. struct v4l2_async_notifier *notifier);
  92. void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier);
  93. int v4l2_async_register_subdev(struct v4l2_subdev *sd);
  94. void v4l2_async_unregister_subdev(struct v4l2_subdev *sd);
  95. #endif