cam_subdev.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. *
  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. };
  49. /**
  50. * cam_subdev_probe()
  51. *
  52. * @brief: Camera Subdevice node probe function for v4l2 setup
  53. *
  54. * @sd: Camera subdevice object
  55. * @name: Name of the subdevice node
  56. * @dev_type: Subdevice node type
  57. *
  58. */
  59. int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev,
  60. char *name, uint32_t dev_type);
  61. /**
  62. * cam_subdev_remove()
  63. *
  64. * @brief: Called when subdevice node is unloaded
  65. *
  66. * @sd: Camera subdevice node object
  67. *
  68. */
  69. int cam_subdev_remove(struct cam_subdev *sd);
  70. /**
  71. * cam_register_subdev()
  72. *
  73. * @brief: This is the common utility function to be called by each camera
  74. * subdevice node when it tries to register itself to the camera
  75. * request manager
  76. *
  77. * @sd: Pointer to struct cam_subdev.
  78. */
  79. int cam_register_subdev(struct cam_subdev *sd);
  80. /**
  81. * cam_unregister_subdev()
  82. *
  83. * @brief: This is the common utility function to be called by each camera
  84. * subdevice node when it tries to unregister itself from the
  85. * camera request manger
  86. *
  87. * @sd: Pointer to struct cam_subdev.
  88. */
  89. int cam_unregister_subdev(struct cam_subdev *sd);
  90. #endif /* _CAM_SUBDEV_H_ */