vsp1_pipe.h 5.3 KB

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