vsp1_pipe.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * vsp1_pipe.h -- R-Car VSP1 Pipeline
  4. *
  5. * Copyright (C) 2013-2015 Renesas Electronics Corporation
  6. *
  7. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  8. */
  9. #ifndef __VSP1_PIPE_H__
  10. #define __VSP1_PIPE_H__
  11. #include <linux/kref.h>
  12. #include <linux/list.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/wait.h>
  15. #include <media/media-entity.h>
  16. struct vsp1_dl_list;
  17. struct vsp1_rwpf;
  18. /*
  19. * struct vsp1_format_info - VSP1 video format description
  20. * @fourcc: V4L2 pixel format FCC identifier
  21. * @mbus: media bus format code
  22. * @hwfmt: VSP1 hardware format
  23. * @swap: swap register control
  24. * @planes: number of planes
  25. * @bpp: bits per pixel
  26. * @swap_yc: the Y and C components are swapped (Y comes before C)
  27. * @swap_uv: the U and V components are swapped (V comes before U)
  28. * @hsub: horizontal subsampling factor
  29. * @vsub: vertical subsampling factor
  30. * @alpha: has an alpha channel
  31. */
  32. struct vsp1_format_info {
  33. u32 fourcc;
  34. unsigned int mbus;
  35. unsigned int hwfmt;
  36. unsigned int swap;
  37. unsigned int planes;
  38. unsigned int bpp[3];
  39. bool swap_yc;
  40. bool swap_uv;
  41. unsigned int hsub;
  42. unsigned int vsub;
  43. bool alpha;
  44. };
  45. enum vsp1_pipeline_state {
  46. VSP1_PIPELINE_STOPPED,
  47. VSP1_PIPELINE_RUNNING,
  48. VSP1_PIPELINE_STOPPING,
  49. };
  50. /*
  51. * struct vsp1_partition_window - Partition window coordinates
  52. * @left: horizontal coordinate of the partition start in pixels relative to the
  53. * left edge of the image
  54. * @width: partition width in pixels
  55. */
  56. struct vsp1_partition_window {
  57. unsigned int left;
  58. unsigned int width;
  59. };
  60. /*
  61. * struct vsp1_partition - A description of a slice for the partition algorithm
  62. * @rpf: The RPF partition window configuration
  63. * @uds_sink: The UDS input partition window configuration
  64. * @uds_source: The UDS output partition window configuration
  65. * @sru: The SRU partition window configuration
  66. * @wpf: The WPF partition window configuration
  67. */
  68. struct vsp1_partition {
  69. struct vsp1_partition_window rpf;
  70. struct vsp1_partition_window uds_sink;
  71. struct vsp1_partition_window uds_source;
  72. struct vsp1_partition_window sru;
  73. struct vsp1_partition_window wpf;
  74. };
  75. /*
  76. * struct vsp1_pipeline - A VSP1 hardware pipeline
  77. * @pipe: the media pipeline
  78. * @irqlock: protects the pipeline state
  79. * @state: current state
  80. * @wq: wait queue to wait for state change completion
  81. * @frame_end: frame end interrupt handler
  82. * @lock: protects the pipeline use count and stream count
  83. * @kref: pipeline reference count
  84. * @stream_count: number of streaming video nodes
  85. * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
  86. * @sequence: frame sequence number
  87. * @num_inputs: number of RPFs
  88. * @inputs: array of RPFs in the pipeline (indexed by RPF index)
  89. * @output: WPF at the output of the pipeline
  90. * @brx: BRx entity, if present
  91. * @hgo: HGO entity, if present
  92. * @hgt: HGT entity, if present
  93. * @lif: LIF entity, if present
  94. * @uds: UDS entity, if present
  95. * @uds_input: entity at the input of the UDS, if the UDS is present
  96. * @entities: list of entities in the pipeline
  97. * @stream_config: cached stream configuration for video pipelines
  98. * @configured: when false the @stream_config shall be written to the hardware
  99. * @interlaced: True when the pipeline is configured in interlaced mode
  100. * @partitions: The number of partitions used to process one frame
  101. * @partition: The current partition for configuration to process
  102. * @part_table: The pre-calculated partitions used by the pipeline
  103. */
  104. struct vsp1_pipeline {
  105. struct media_pipeline pipe;
  106. spinlock_t irqlock;
  107. enum vsp1_pipeline_state state;
  108. wait_queue_head_t wq;
  109. void (*frame_end)(struct vsp1_pipeline *pipe, unsigned int completion);
  110. struct mutex lock;
  111. struct kref kref;
  112. unsigned int stream_count;
  113. unsigned int buffers_ready;
  114. unsigned int sequence;
  115. unsigned int num_inputs;
  116. struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
  117. struct vsp1_rwpf *output;
  118. struct vsp1_entity *brx;
  119. struct vsp1_entity *hgo;
  120. struct vsp1_entity *hgt;
  121. struct vsp1_entity *lif;
  122. struct vsp1_entity *uds;
  123. struct vsp1_entity *uds_input;
  124. /*
  125. * The order of this list must be identical to the order of the entities
  126. * in the pipeline, as it is assumed by the partition algorithm that we
  127. * can walk this list in sequence.
  128. */
  129. struct list_head entities;
  130. struct vsp1_dl_body *stream_config;
  131. bool configured;
  132. bool interlaced;
  133. unsigned int partitions;
  134. struct vsp1_partition *partition;
  135. struct vsp1_partition *part_table;
  136. };
  137. void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
  138. void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
  139. void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
  140. bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
  141. int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
  142. bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
  143. void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
  144. void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
  145. struct vsp1_dl_body *dlb,
  146. unsigned int alpha);
  147. void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
  148. struct vsp1_partition *partition,
  149. unsigned int index,
  150. struct vsp1_partition_window *window);
  151. const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,
  152. u32 fourcc);
  153. #endif /* __VSP1_PIPE_H__ */