1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * vsp1_pipe.h -- R-Car VSP1 Pipeline
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
9 #ifndef __VSP1_PIPE_H__
10 #define __VSP1_PIPE_H__
12 #include <linux/dynamic_debug.h>
13 #include <linux/kref.h>
14 #include <linux/list.h>
15 #include <linux/spinlock.h>
16 #include <linux/wait.h>
18 #include <media/media-entity.h>
24 * struct vsp1_format_info - VSP1 video format description
25 * @fourcc: V4L2 pixel format FCC identifier
26 * @mbus: media bus format code
27 * @hwfmt: VSP1 hardware format
28 * @swap: swap register control
29 * @planes: number of planes
30 * @bpp: bits per pixel
31 * @swap_yc: the Y and C components are swapped (Y comes before C)
32 * @swap_uv: the U and V components are swapped (V comes before U)
33 * @hsub: horizontal subsampling factor
34 * @vsub: vertical subsampling factor
35 * @alpha: has an alpha channel
37 struct vsp1_format_info {
51 enum vsp1_pipeline_state {
52 VSP1_PIPELINE_STOPPED,
53 VSP1_PIPELINE_RUNNING,
54 VSP1_PIPELINE_STOPPING,
58 * struct vsp1_partition - A description of a slice for the partition algorithm
59 * @rpf: The RPF partition window configuration
60 * @uds_sink: The UDS input partition window configuration
61 * @uds_source: The UDS output partition window configuration
62 * @sru: The SRU partition window configuration
63 * @wpf: The WPF partition window configuration
65 struct vsp1_partition {
66 struct v4l2_rect rpf[VSP1_MAX_RPF];
67 struct v4l2_rect uds_sink;
68 struct v4l2_rect uds_source;
74 * struct vsp1_pipeline - A VSP1 hardware pipeline
75 * @pipe: the media pipeline
76 * @irqlock: protects the pipeline state
77 * @state: current state
78 * @wq: wait queue to wait for state change completion
79 * @frame_end: frame end interrupt handler
80 * @lock: protects the pipeline use count and stream count
81 * @kref: pipeline reference count
82 * @stream_count: number of streaming video nodes
83 * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
84 * @sequence: frame sequence number
85 * @num_inputs: number of RPFs
86 * @inputs: array of RPFs in the pipeline (indexed by RPF index)
87 * @output: WPF at the output of the pipeline
88 * @brx: BRx entity, if present
89 * @hgo: HGO entity, if present
90 * @hgt: HGT entity, if present
91 * @lif: LIF entity, if present
92 * @uds: UDS entity, if present
93 * @uds_input: entity at the input of the UDS, if the UDS is present
94 * @entities: list of entities in the pipeline
95 * @stream_config: cached stream configuration for video pipelines
96 * @configured: when false the @stream_config shall be written to the hardware
97 * @interlaced: True when the pipeline is configured in interlaced mode
98 * @partitions: The number of partitions used to process one frame
99 * @part_table: The pre-calculated partitions used by the pipeline
101 struct vsp1_pipeline {
102 struct media_pipeline pipe;
105 enum vsp1_pipeline_state state;
106 wait_queue_head_t wq;
108 void (*frame_end)(struct vsp1_pipeline *pipe, unsigned int completion);
112 unsigned int stream_count;
113 unsigned int buffers_ready;
114 unsigned int sequence;
116 unsigned int num_inputs;
117 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
118 struct vsp1_rwpf *output;
119 struct vsp1_entity *brx;
120 struct vsp1_entity *hgo;
121 struct vsp1_entity *hgt;
122 struct vsp1_entity *lif;
123 struct vsp1_entity *uds;
124 struct vsp1_entity *uds_input;
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.
131 struct list_head entities;
133 struct vsp1_dl_body *stream_config;
137 unsigned int partitions;
138 struct vsp1_partition *part_table;
143 void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
144 void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
146 void __vsp1_pipeline_dump(struct _ddebug *, struct vsp1_pipeline *pipe,
149 #if defined(CONFIG_DYNAMIC_DEBUG) || \
150 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
151 #define vsp1_pipeline_dump(pipe, msg) \
152 _dynamic_func_call("vsp1_pipeline_dump()", __vsp1_pipeline_dump, pipe, msg)
154 #define vsp1_pipeline_dump(pipe, msg) \
155 __vsp1_pipeline_dump(NULL, pipe, msg)
157 #define vsp1_pipeline_dump(pipe, msg) \
160 __vsp1_pipeline_dump(NULL, pipe, msg); \
164 void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
165 bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
166 int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
167 bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
169 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
171 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
172 struct vsp1_dl_body *dlb,
175 void vsp1_pipeline_calculate_partition(struct vsp1_pipeline *pipe,
176 struct vsp1_partition *partition,
177 unsigned int div_size,
180 const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,
183 #endif /* __VSP1_PIPE_H__ */