vsp1_entity.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * vsp1_entity.h -- R-Car VSP1 Base Entity
  4. *
  5. * Copyright (C) 2013-2014 Renesas Electronics Corporation
  6. *
  7. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  8. */
  9. #ifndef __VSP1_ENTITY_H__
  10. #define __VSP1_ENTITY_H__
  11. #include <linux/list.h>
  12. #include <linux/mutex.h>
  13. #include <media/v4l2-subdev.h>
  14. struct vsp1_device;
  15. struct vsp1_dl_body;
  16. struct vsp1_dl_list;
  17. struct vsp1_pipeline;
  18. struct vsp1_partition;
  19. struct vsp1_partition_window;
  20. enum vsp1_entity_type {
  21. VSP1_ENTITY_BRS,
  22. VSP1_ENTITY_BRU,
  23. VSP1_ENTITY_CLU,
  24. VSP1_ENTITY_HGO,
  25. VSP1_ENTITY_HGT,
  26. VSP1_ENTITY_HSI,
  27. VSP1_ENTITY_HST,
  28. VSP1_ENTITY_LIF,
  29. VSP1_ENTITY_LUT,
  30. VSP1_ENTITY_RPF,
  31. VSP1_ENTITY_SRU,
  32. VSP1_ENTITY_UDS,
  33. VSP1_ENTITY_UIF,
  34. VSP1_ENTITY_WPF,
  35. };
  36. #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
  37. /*
  38. * struct vsp1_route - Entity routing configuration
  39. * @type: Entity type this routing entry is associated with
  40. * @index: Entity index this routing entry is associated with
  41. * @reg: Output routing configuration register
  42. * @inputs: Target node value for each input
  43. * @output: Target node value for entity output
  44. *
  45. * Each $vsp1_route entry describes routing configuration for the entity
  46. * specified by the entry's @type and @index. @reg indicates the register that
  47. * holds output routing configuration for the entity, and the @inputs array
  48. * store the target node value for each input of the entity. The @output field
  49. * stores the target node value of the entity output when used as a source for
  50. * histogram generation.
  51. */
  52. struct vsp1_route {
  53. enum vsp1_entity_type type;
  54. unsigned int index;
  55. unsigned int reg;
  56. unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
  57. unsigned int output;
  58. };
  59. /**
  60. * struct vsp1_entity_operations - Entity operations
  61. * @destroy: Destroy the entity.
  62. * @configure_stream: Setup the hardware parameters for the stream which do
  63. * not vary between frames (pipeline, formats).
  64. * @configure_frame: Configure the runtime parameters for each frame.
  65. * @configure_partition: Configure partition specific parameters.
  66. * @max_width: Return the max supported width of data that the entity can
  67. * process in a single operation.
  68. * @partition: Process the partition construction based on this entity's
  69. * configuration.
  70. */
  71. struct vsp1_entity_operations {
  72. void (*destroy)(struct vsp1_entity *);
  73. void (*configure_stream)(struct vsp1_entity *, struct vsp1_pipeline *,
  74. struct vsp1_dl_body *);
  75. void (*configure_frame)(struct vsp1_entity *, struct vsp1_pipeline *,
  76. struct vsp1_dl_list *, struct vsp1_dl_body *);
  77. void (*configure_partition)(struct vsp1_entity *,
  78. struct vsp1_pipeline *,
  79. struct vsp1_dl_list *,
  80. struct vsp1_dl_body *);
  81. unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
  82. void (*partition)(struct vsp1_entity *, struct vsp1_pipeline *,
  83. struct vsp1_partition *, unsigned int,
  84. struct vsp1_partition_window *);
  85. };
  86. struct vsp1_entity {
  87. struct vsp1_device *vsp1;
  88. const struct vsp1_entity_operations *ops;
  89. enum vsp1_entity_type type;
  90. unsigned int index;
  91. const struct vsp1_route *route;
  92. struct vsp1_pipeline *pipe;
  93. struct list_head list_dev;
  94. struct list_head list_pipe;
  95. struct media_pad *pads;
  96. unsigned int source_pad;
  97. struct vsp1_entity **sources;
  98. struct vsp1_entity *sink;
  99. unsigned int sink_pad;
  100. struct v4l2_subdev subdev;
  101. struct v4l2_subdev_pad_config *config;
  102. struct mutex lock; /* Protects the pad config */
  103. };
  104. static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
  105. {
  106. return container_of(subdev, struct vsp1_entity, subdev);
  107. }
  108. int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
  109. const char *name, unsigned int num_pads,
  110. const struct v4l2_subdev_ops *ops, u32 function);
  111. void vsp1_entity_destroy(struct vsp1_entity *entity);
  112. extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
  113. int vsp1_entity_link_setup(struct media_entity *entity,
  114. const struct media_pad *local,
  115. const struct media_pad *remote, u32 flags);
  116. struct v4l2_subdev_pad_config *
  117. vsp1_entity_get_pad_config(struct vsp1_entity *entity,
  118. struct v4l2_subdev_pad_config *cfg,
  119. enum v4l2_subdev_format_whence which);
  120. struct v4l2_mbus_framefmt *
  121. vsp1_entity_get_pad_format(struct vsp1_entity *entity,
  122. struct v4l2_subdev_pad_config *cfg,
  123. unsigned int pad);
  124. struct v4l2_rect *
  125. vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
  126. struct v4l2_subdev_pad_config *cfg,
  127. unsigned int pad, unsigned int target);
  128. int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
  129. struct v4l2_subdev_pad_config *cfg);
  130. void vsp1_entity_route_setup(struct vsp1_entity *entity,
  131. struct vsp1_pipeline *pipe,
  132. struct vsp1_dl_body *dlb);
  133. void vsp1_entity_configure_stream(struct vsp1_entity *entity,
  134. struct vsp1_pipeline *pipe,
  135. struct vsp1_dl_body *dlb);
  136. void vsp1_entity_configure_frame(struct vsp1_entity *entity,
  137. struct vsp1_pipeline *pipe,
  138. struct vsp1_dl_list *dl,
  139. struct vsp1_dl_body *dlb);
  140. void vsp1_entity_configure_partition(struct vsp1_entity *entity,
  141. struct vsp1_pipeline *pipe,
  142. struct vsp1_dl_list *dl,
  143. struct vsp1_dl_body *dlb);
  144. struct media_pad *vsp1_entity_remote_pad(struct media_pad *pad);
  145. int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
  146. struct v4l2_subdev_pad_config *cfg,
  147. struct v4l2_subdev_format *fmt);
  148. int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
  149. struct v4l2_subdev_pad_config *cfg,
  150. struct v4l2_subdev_format *fmt,
  151. const unsigned int *codes, unsigned int ncodes,
  152. unsigned int min_width, unsigned int min_height,
  153. unsigned int max_width, unsigned int max_height);
  154. int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
  155. struct v4l2_subdev_pad_config *cfg,
  156. struct v4l2_subdev_mbus_code_enum *code,
  157. const unsigned int *codes, unsigned int ncodes);
  158. int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
  159. struct v4l2_subdev_pad_config *cfg,
  160. struct v4l2_subdev_frame_size_enum *fse,
  161. unsigned int min_w, unsigned int min_h,
  162. unsigned int max_w, unsigned int max_h);
  163. #endif /* __VSP1_ENTITY_H__ */