vsp1_entity.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * vsp1_entity.h -- R-Car VSP1 Base Entity
  3. *
  4. * Copyright (C) 2013-2014 Renesas Electronics Corporation
  5. *
  6. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef __VSP1_ENTITY_H__
  14. #define __VSP1_ENTITY_H__
  15. #include <linux/list.h>
  16. #include <linux/mutex.h>
  17. #include <media/v4l2-subdev.h>
  18. struct vsp1_device;
  19. struct vsp1_dl_list;
  20. struct vsp1_pipeline;
  21. enum vsp1_entity_type {
  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_WPF,
  34. };
  35. /**
  36. * enum vsp1_entity_params - Entity configuration parameters class
  37. * @VSP1_ENTITY_PARAMS_INIT - Initial parameters
  38. * @VSP1_ENTITY_PARAMS_PARTITION - Per-image partition parameters
  39. * @VSP1_ENTITY_PARAMS_RUNTIME - Runtime-configurable parameters
  40. */
  41. enum vsp1_entity_params {
  42. VSP1_ENTITY_PARAMS_INIT,
  43. VSP1_ENTITY_PARAMS_PARTITION,
  44. VSP1_ENTITY_PARAMS_RUNTIME,
  45. };
  46. #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
  47. /*
  48. * struct vsp1_route - Entity routing configuration
  49. * @type: Entity type this routing entry is associated with
  50. * @index: Entity index this routing entry is associated with
  51. * @reg: Output routing configuration register
  52. * @inputs: Target node value for each input
  53. * @output: Target node value for entity output
  54. *
  55. * Each $vsp1_route entry describes routing configuration for the entity
  56. * specified by the entry's @type and @index. @reg indicates the register that
  57. * holds output routing configuration for the entity, and the @inputs array
  58. * store the target node value for each input of the entity. The @output field
  59. * stores the target node value of the entity output when used as a source for
  60. * histogram generation.
  61. */
  62. struct vsp1_route {
  63. enum vsp1_entity_type type;
  64. unsigned int index;
  65. unsigned int reg;
  66. unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
  67. unsigned int output;
  68. };
  69. /**
  70. * struct vsp1_entity_operations - Entity operations
  71. * @destroy: Destroy the entity.
  72. * @configure: Setup the hardware based on the entity state (pipeline, formats,
  73. * selection rectangles, ...)
  74. * @max_width: Return the max supported width of data that the entity can
  75. * process in a single operation.
  76. */
  77. struct vsp1_entity_operations {
  78. void (*destroy)(struct vsp1_entity *);
  79. void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
  80. struct vsp1_dl_list *, enum vsp1_entity_params);
  81. unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
  82. };
  83. struct vsp1_entity {
  84. struct vsp1_device *vsp1;
  85. const struct vsp1_entity_operations *ops;
  86. enum vsp1_entity_type type;
  87. unsigned int index;
  88. const struct vsp1_route *route;
  89. struct list_head list_dev;
  90. struct list_head list_pipe;
  91. struct media_pad *pads;
  92. unsigned int source_pad;
  93. struct media_entity **sources;
  94. struct media_entity *sink;
  95. unsigned int sink_pad;
  96. struct v4l2_subdev subdev;
  97. struct v4l2_subdev_pad_config *config;
  98. struct mutex lock; /* Protects the pad config */
  99. };
  100. static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
  101. {
  102. return container_of(subdev, struct vsp1_entity, subdev);
  103. }
  104. int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
  105. const char *name, unsigned int num_pads,
  106. const struct v4l2_subdev_ops *ops, u32 function);
  107. void vsp1_entity_destroy(struct vsp1_entity *entity);
  108. extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
  109. int vsp1_entity_link_setup(struct media_entity *entity,
  110. const struct media_pad *local,
  111. const struct media_pad *remote, u32 flags);
  112. struct v4l2_subdev_pad_config *
  113. vsp1_entity_get_pad_config(struct vsp1_entity *entity,
  114. struct v4l2_subdev_pad_config *cfg,
  115. enum v4l2_subdev_format_whence which);
  116. struct v4l2_mbus_framefmt *
  117. vsp1_entity_get_pad_format(struct vsp1_entity *entity,
  118. struct v4l2_subdev_pad_config *cfg,
  119. unsigned int pad);
  120. struct v4l2_rect *
  121. vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
  122. struct v4l2_subdev_pad_config *cfg,
  123. unsigned int pad, unsigned int target);
  124. int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
  125. struct v4l2_subdev_pad_config *cfg);
  126. void vsp1_entity_route_setup(struct vsp1_entity *entity,
  127. struct vsp1_pipeline *pipe,
  128. struct vsp1_dl_list *dl);
  129. struct media_pad *vsp1_entity_remote_pad(struct media_pad *pad);
  130. int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
  131. struct v4l2_subdev_pad_config *cfg,
  132. struct v4l2_subdev_format *fmt);
  133. int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
  134. struct v4l2_subdev_pad_config *cfg,
  135. struct v4l2_subdev_mbus_code_enum *code,
  136. const unsigned int *codes, unsigned int ncodes);
  137. int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
  138. struct v4l2_subdev_pad_config *cfg,
  139. struct v4l2_subdev_frame_size_enum *fse,
  140. unsigned int min_w, unsigned int min_h,
  141. unsigned int max_w, unsigned int max_h);
  142. #endif /* __VSP1_ENTITY_H__ */