v4l2-async.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * @bus_type: subdevice bus type to select the appropriate matching method
  30. * @match: union of per-bus type matching data sets
  31. * @list: used to link struct v4l2_async_subdev objects, waiting to be
  32. * probed, to a notifier->waiting list
  33. */
  34. struct v4l2_async_subdev {
  35. enum v4l2_async_match_type match_type;
  36. union {
  37. struct {
  38. const struct device_node *node;
  39. } of;
  40. struct {
  41. const char *name;
  42. } device_name;
  43. struct {
  44. int adapter_id;
  45. unsigned short address;
  46. } i2c;
  47. struct {
  48. bool (*match)(struct device *,
  49. struct v4l2_async_subdev *);
  50. void *priv;
  51. } custom;
  52. } match;
  53. /* v4l2-async core private: not to be used by drivers */
  54. struct list_head list;
  55. };
  56. /**
  57. * v4l2_async_notifier - v4l2_device notifier data
  58. * @num_subdevs:number of subdevices
  59. * @subdevs: array of pointers to subdevice descriptors
  60. * @v4l2_dev: pointer to struct v4l2_device
  61. * @waiting: list of struct v4l2_async_subdev, waiting for their drivers
  62. * @done: list of struct v4l2_subdev, already probed
  63. * @list: member in a global list of notifiers
  64. * @bound: a subdevice driver has successfully probed one of subdevices
  65. * @complete: all subdevices have been probed successfully
  66. * @unbind: a subdevice is leaving
  67. */
  68. struct v4l2_async_notifier {
  69. unsigned int num_subdevs;
  70. struct v4l2_async_subdev **subdevs;
  71. struct v4l2_device *v4l2_dev;
  72. struct list_head waiting;
  73. struct list_head done;
  74. struct list_head list;
  75. int (*bound)(struct v4l2_async_notifier *notifier,
  76. struct v4l2_subdev *subdev,
  77. struct v4l2_async_subdev *asd);
  78. int (*complete)(struct v4l2_async_notifier *notifier);
  79. void (*unbind)(struct v4l2_async_notifier *notifier,
  80. struct v4l2_subdev *subdev,
  81. struct v4l2_async_subdev *asd);
  82. };
  83. int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
  84. struct v4l2_async_notifier *notifier);
  85. void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier);
  86. int v4l2_async_register_subdev(struct v4l2_subdev *sd);
  87. void v4l2_async_unregister_subdev(struct v4l2_subdev *sd);
  88. #endif