cam_subdev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, 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. *
  34. * Each instance of a subdev driver should create this struct, either
  35. * stand-alone or embedded in a larger struct. This structure should be
  36. * initialized/registered by cam_register_subdev
  37. *
  38. */
  39. struct cam_subdev {
  40. struct platform_device *pdev;
  41. struct v4l2_subdev sd;
  42. const struct v4l2_subdev_ops *ops;
  43. const struct v4l2_subdev_internal_ops *internal_ops;
  44. char *name;
  45. u32 sd_flags;
  46. void *token;
  47. u32 ent_function;
  48. bool subdev_node_created;
  49. };
  50. /**
  51. * cam_subdev_probe()
  52. *
  53. * @brief: Camera Subdevice node probe function for v4l2 setup
  54. *
  55. * @sd: Camera subdevice object
  56. * @name: Name of the subdevice node
  57. * @dev_type: Subdevice node type
  58. *
  59. */
  60. int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev,
  61. char *name, uint32_t dev_type);
  62. /**
  63. * cam_subdev_remove()
  64. *
  65. * @brief: Called when subdevice node is unloaded
  66. *
  67. * @sd: Camera subdevice node object
  68. *
  69. */
  70. int cam_subdev_remove(struct cam_subdev *sd);
  71. /**
  72. * cam_register_subdev()
  73. *
  74. * @brief: This is the common utility function to be called by each camera
  75. * subdevice node when it tries to register itself to the camera
  76. * request manager
  77. *
  78. * @sd: Pointer to struct cam_subdev.
  79. */
  80. int cam_register_subdev(struct cam_subdev *sd);
  81. /**
  82. * cam_unregister_subdev()
  83. *
  84. * @brief: This is the common utility function to be called by each camera
  85. * subdevice node when it tries to unregister itself from the
  86. * camera request manger
  87. *
  88. * @sd: Pointer to struct cam_subdev.
  89. */
  90. int cam_unregister_subdev(struct cam_subdev *sd);
  91. #endif /* _CAM_SUBDEV_H_ */