cam_subdev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /**
  16. * struct cam_subdev - describes a camera sub-device
  17. *
  18. * @pdev: Pointer to the platform device
  19. * @sd: V4l2 subdevice
  20. * @ops: V4l2 subdecie operations
  21. * @internal_ops: V4l2 subdevice internal operations
  22. * @name: Name of the sub-device. Please notice that the name
  23. * must be unique.
  24. * @sd_flags: Subdev flags. Can be:
  25. * %V4L2_SUBDEV_FL_HAS_DEVNODE - Set this flag if
  26. * this subdev needs a device node.
  27. * %V4L2_SUBDEV_FL_HAS_EVENTS - Set this flag if
  28. * this subdev generates events.
  29. * @token: Pointer to cookie of the client driver
  30. * @ent_function: Media entity function type. Can be:
  31. * %CAM_IFE_DEVICE_TYPE - identifies as IFE device.
  32. * %CAM_ICP_DEVICE_TYPE - identifies as ICP device.
  33. * @subdev_node_created: Enabled sub-device
  34. *
  35. * Each instance of a subdev driver should create this struct, either
  36. * stand-alone or embedded in a larger struct. This structure should be
  37. * initialized/registered by cam_register_subdev
  38. *
  39. */
  40. struct cam_subdev {
  41. struct platform_device *pdev;
  42. struct v4l2_subdev sd;
  43. const struct v4l2_subdev_ops *ops;
  44. const struct v4l2_subdev_internal_ops *internal_ops;
  45. char *name;
  46. u32 sd_flags;
  47. void *token;
  48. u32 ent_function;
  49. bool subdev_node_created;
  50. };
  51. /**
  52. * cam_subdev_probe()
  53. *
  54. * @brief: Camera Subdevice node probe function for v4l2 setup
  55. *
  56. * @sd: Camera subdevice object
  57. * @name: Name of the subdevice node
  58. * @dev_type: Subdevice node type
  59. *
  60. */
  61. int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev,
  62. char *name, uint32_t dev_type);
  63. /**
  64. * cam_subdev_remove()
  65. *
  66. * @brief: Called when subdevice node is unloaded
  67. *
  68. * @sd: Camera subdevice node object
  69. *
  70. */
  71. int cam_subdev_remove(struct cam_subdev *sd);
  72. /**
  73. * cam_register_subdev()
  74. *
  75. * @brief: This is the common utility function to be called by each camera
  76. * subdevice node when it tries to register itself to the camera
  77. * request manager
  78. *
  79. * @sd: Pointer to struct cam_subdev.
  80. */
  81. int cam_register_subdev(struct cam_subdev *sd);
  82. /**
  83. * cam_unregister_subdev()
  84. *
  85. * @brief: This is the common utility function to be called by each camera
  86. * subdevice node when it tries to unregister itself from the
  87. * camera request manger
  88. *
  89. * @sd: Pointer to struct cam_subdev.
  90. */
  91. int cam_unregister_subdev(struct cam_subdev *sd);
  92. #endif /* _CAM_SUBDEV_H_ */