vsp1_entity.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_HSI,
  25. VSP1_ENTITY_HST,
  26. VSP1_ENTITY_LIF,
  27. VSP1_ENTITY_LUT,
  28. VSP1_ENTITY_RPF,
  29. VSP1_ENTITY_SRU,
  30. VSP1_ENTITY_UDS,
  31. VSP1_ENTITY_WPF,
  32. };
  33. /**
  34. * enum vsp1_entity_params - Entity configuration parameters class
  35. * @VSP1_ENTITY_PARAMS_INIT - Initial parameters
  36. * @VSP1_ENTITY_PARAMS_PARTITION - Per-image partition parameters
  37. * @VSP1_ENTITY_PARAMS_RUNTIME - Runtime-configurable parameters
  38. */
  39. enum vsp1_entity_params {
  40. VSP1_ENTITY_PARAMS_INIT,
  41. VSP1_ENTITY_PARAMS_PARTITION,
  42. VSP1_ENTITY_PARAMS_RUNTIME,
  43. };
  44. #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
  45. /*
  46. * struct vsp1_route - Entity routing configuration
  47. * @type: Entity type this routing entry is associated with
  48. * @index: Entity index this routing entry is associated with
  49. * @reg: Output routing configuration register
  50. * @inputs: Target node value for each input
  51. * @output: Target node value for entity output
  52. *
  53. * Each $vsp1_route entry describes routing configuration for the entity
  54. * specified by the entry's @type and @index. @reg indicates the register that
  55. * holds output routing configuration for the entity, and the @inputs array
  56. * store the target node value for each input of the entity. The @output field
  57. * stores the target node value of the entity output when used as a source for
  58. * histogram generation.
  59. */
  60. struct vsp1_route {
  61. enum vsp1_entity_type type;
  62. unsigned int index;
  63. unsigned int reg;
  64. unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
  65. unsigned int output;
  66. };
  67. /**
  68. * struct vsp1_entity_operations - Entity operations
  69. * @destroy: Destroy the entity.
  70. * @configure: Setup the hardware based on the entity state (pipeline, formats,
  71. * selection rectangles, ...)
  72. * @max_width: Return the max supported width of data that the entity can
  73. * process in a single operation.
  74. */
  75. struct vsp1_entity_operations {
  76. void (*destroy)(struct vsp1_entity *);
  77. void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
  78. struct vsp1_dl_list *, enum vsp1_entity_params);
  79. unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
  80. };
  81. struct vsp1_entity {
  82. struct vsp1_device *vsp1;
  83. const struct vsp1_entity_operations *ops;
  84. enum vsp1_entity_type type;
  85. unsigned int index;
  86. const struct vsp1_route *route;
  87. struct list_head list_dev;
  88. struct list_head list_pipe;
  89. struct media_pad *pads;
  90. unsigned int source_pad;
  91. struct media_entity *sink;
  92. unsigned int sink_pad;
  93. struct v4l2_subdev subdev;
  94. struct v4l2_subdev_pad_config *config;
  95. struct mutex lock; /* Protects the pad config */
  96. };
  97. static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
  98. {
  99. return container_of(subdev, struct vsp1_entity, subdev);
  100. }
  101. int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
  102. const char *name, unsigned int num_pads,
  103. const struct v4l2_subdev_ops *ops, u32 function);
  104. void vsp1_entity_destroy(struct vsp1_entity *entity);
  105. extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
  106. int vsp1_entity_link_setup(struct media_entity *entity,
  107. const struct media_pad *local,
  108. const struct media_pad *remote, u32 flags);
  109. struct v4l2_subdev_pad_config *
  110. vsp1_entity_get_pad_config(struct vsp1_entity *entity,
  111. struct v4l2_subdev_pad_config *cfg,
  112. enum v4l2_subdev_format_whence which);
  113. struct v4l2_mbus_framefmt *
  114. vsp1_entity_get_pad_format(struct vsp1_entity *entity,
  115. struct v4l2_subdev_pad_config *cfg,
  116. unsigned int pad);
  117. struct v4l2_rect *
  118. vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
  119. struct v4l2_subdev_pad_config *cfg,
  120. unsigned int pad, unsigned int target);
  121. int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
  122. struct v4l2_subdev_pad_config *cfg);
  123. void vsp1_entity_route_setup(struct vsp1_entity *source,
  124. struct vsp1_dl_list *dl);
  125. int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
  126. struct v4l2_subdev_pad_config *cfg,
  127. struct v4l2_subdev_format *fmt);
  128. int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
  129. struct v4l2_subdev_pad_config *cfg,
  130. struct v4l2_subdev_mbus_code_enum *code,
  131. const unsigned int *codes, unsigned int ncodes);
  132. int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
  133. struct v4l2_subdev_pad_config *cfg,
  134. struct v4l2_subdev_frame_size_enum *fse,
  135. unsigned int min_w, unsigned int min_h,
  136. unsigned int max_w, unsigned int max_h);
  137. #endif /* __VSP1_ENTITY_H__ */