cam_subdev.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_SUBDEV_H_
  6. #define _CAM_SUBDEV_H_
  7. #include <linux/types.h>
  8. #include <linux/platform_device.h>
  9. #include <media/v4l2-fh.h>
  10. #include <media/v4l2-device.h>
  11. #include <media/v4l2-subdev.h>
  12. #include <media/v4l2-event.h>
  13. #include <media/v4l2-ioctl.h>
  14. #define CAM_SUBDEVICE_EVENT_MAX 30
  15. enum cam_subdev_message_type_t {
  16. CAM_SUBDEV_MESSAGE_IRQ_ERR = 0x1
  17. };
  18. /**
  19. * struct cam_subdev - describes a camera sub-device
  20. *
  21. * @pdev: Pointer to the platform device
  22. * @sd: V4l2 subdevice
  23. * @ops: V4l2 subdecie operations
  24. * @internal_ops: V4l2 subdevice internal operations
  25. * @name: Name of the sub-device. Please notice that the name
  26. * must be unique.
  27. * @sd_flags: Subdev flags. Can be:
  28. * %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if
  29. * this subdev needs a device node.
  30. * %V4L2_SUBDEV_FL_HAS_EVENTS - Set this flag if
  31. * this subdev generates events.
  32. * @token: Pointer to cookie of the client driver
  33. * @ent_function: Media entity function type. Can be:
  34. * %CAM_IFE_DEVICE_TYPE - identifies as IFE device.
  35. * %CAM_ICP_DEVICE_TYPE - identifies as ICP device.
  36. *
  37. * Each instance of a subdev driver should create this struct, either
  38. * stand-alone or embedded in a larger struct. This structure should be
  39. * initialized/registered by cam_register_subdev
  40. *
  41. */
  42. struct cam_subdev {
  43. struct platform_device *pdev;
  44. struct v4l2_subdev sd;
  45. const struct v4l2_subdev_ops *ops;
  46. const struct v4l2_subdev_internal_ops *internal_ops;
  47. char *name;
  48. u32 sd_flags;
  49. void *token;
  50. u32 ent_function;
  51. void (*msg_cb)(
  52. struct v4l2_subdev *sd,
  53. enum cam_subdev_message_type_t msg_type,
  54. uint32_t data);
  55. };
  56. /**
  57. * cam_subdev_notify_message()
  58. *
  59. * @brief: Notify message to a subdevs of specific type
  60. *
  61. * @subdev_type: Subdev type
  62. * @message_type: message type
  63. * @data: data to be delivered.
  64. *
  65. */
  66. void cam_subdev_notify_message(u32 subdev_type,
  67. enum cam_subdev_message_type_t message_type,
  68. uint32_t data);
  69. /**
  70. * cam_subdev_probe()
  71. *
  72. * @brief: Camera Subdevice node probe function for v4l2 setup
  73. *
  74. * @sd: Camera subdevice object
  75. * @name: Name of the subdevice node
  76. * @dev_type: Subdevice node type
  77. *
  78. */
  79. int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev,
  80. char *name, uint32_t dev_type);
  81. /**
  82. * cam_subdev_remove()
  83. *
  84. * @brief: Called when subdevice node is unloaded
  85. *
  86. * @sd: Camera subdevice node object
  87. *
  88. */
  89. int cam_subdev_remove(struct cam_subdev *sd);
  90. /**
  91. * cam_register_subdev()
  92. *
  93. * @brief: This is the common utility function to be called by each camera
  94. * subdevice node when it tries to register itself to the camera
  95. * request manager
  96. *
  97. * @sd: Pointer to struct cam_subdev.
  98. */
  99. int cam_register_subdev(struct cam_subdev *sd);
  100. /**
  101. * cam_unregister_subdev()
  102. *
  103. * @brief: This is the common utility function to be called by each camera
  104. * subdevice node when it tries to unregister itself from the
  105. * camera request manger
  106. *
  107. * @sd: Pointer to struct cam_subdev.
  108. */
  109. int cam_unregister_subdev(struct cam_subdev *sd);
  110. #endif /* _CAM_SUBDEV_H_ */