gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / media / platform / vsp1 / vsp1_pipe.h
blobae646c9ef337317ad1b7c1b589f3bfd080af363e
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * vsp1_pipe.h -- R-Car VSP1 Pipeline
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8 */
9 #ifndef __VSP1_PIPE_H__
10 #define __VSP1_PIPE_H__
12 #include <linux/kref.h>
13 #include <linux/list.h>
14 #include <linux/spinlock.h>
15 #include <linux/wait.h>
17 #include <media/media-entity.h>
19 struct vsp1_dl_list;
20 struct vsp1_rwpf;
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
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;
50 enum vsp1_pipeline_state {
51 VSP1_PIPELINE_STOPPED,
52 VSP1_PIPELINE_RUNNING,
53 VSP1_PIPELINE_STOPPING,
57 * struct vsp1_partition_window - Partition window coordinates
58 * @left: horizontal coordinate of the partition start in pixels relative to the
59 * left edge of the image
60 * @width: partition width in pixels
62 struct vsp1_partition_window {
63 unsigned int left;
64 unsigned int width;
68 * struct vsp1_partition - A description of a slice for the partition algorithm
69 * @rpf: The RPF partition window configuration
70 * @uds_sink: The UDS input partition window configuration
71 * @uds_source: The UDS output partition window configuration
72 * @sru: The SRU partition window configuration
73 * @wpf: The WPF partition window configuration
75 struct vsp1_partition {
76 struct vsp1_partition_window rpf;
77 struct vsp1_partition_window uds_sink;
78 struct vsp1_partition_window uds_source;
79 struct vsp1_partition_window sru;
80 struct vsp1_partition_window wpf;
84 * struct vsp1_pipeline - A VSP1 hardware pipeline
85 * @pipe: the media pipeline
86 * @irqlock: protects the pipeline state
87 * @state: current state
88 * @wq: wait queue to wait for state change completion
89 * @frame_end: frame end interrupt handler
90 * @lock: protects the pipeline use count and stream count
91 * @kref: pipeline reference count
92 * @stream_count: number of streaming video nodes
93 * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
94 * @sequence: frame sequence number
95 * @num_inputs: number of RPFs
96 * @inputs: array of RPFs in the pipeline (indexed by RPF index)
97 * @output: WPF at the output of the pipeline
98 * @brx: BRx entity, if present
99 * @hgo: HGO entity, if present
100 * @hgt: HGT entity, if present
101 * @lif: LIF entity, if present
102 * @uds: UDS entity, if present
103 * @uds_input: entity at the input of the UDS, if the UDS is present
104 * @entities: list of entities in the pipeline
105 * @stream_config: cached stream configuration for video pipelines
106 * @configured: when false the @stream_config shall be written to the hardware
107 * @interlaced: True when the pipeline is configured in interlaced mode
108 * @partitions: The number of partitions used to process one frame
109 * @partition: The current partition for configuration to process
110 * @part_table: The pre-calculated partitions used by the pipeline
112 struct vsp1_pipeline {
113 struct media_pipeline pipe;
115 spinlock_t irqlock;
116 enum vsp1_pipeline_state state;
117 wait_queue_head_t wq;
119 void (*frame_end)(struct vsp1_pipeline *pipe, unsigned int completion);
121 struct mutex lock;
122 struct kref kref;
123 unsigned int stream_count;
124 unsigned int buffers_ready;
125 unsigned int sequence;
127 unsigned int num_inputs;
128 struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
129 struct vsp1_rwpf *output;
130 struct vsp1_entity *brx;
131 struct vsp1_entity *hgo;
132 struct vsp1_entity *hgt;
133 struct vsp1_entity *lif;
134 struct vsp1_entity *uds;
135 struct vsp1_entity *uds_input;
138 * The order of this list must be identical to the order of the entities
139 * in the pipeline, as it is assumed by the partition algorithm that we
140 * can walk this list in sequence.
142 struct list_head entities;
144 struct vsp1_dl_body *stream_config;
145 bool configured;
146 bool interlaced;
148 unsigned int partitions;
149 struct vsp1_partition *partition;
150 struct vsp1_partition *part_table;
153 void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
154 void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
156 void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
157 bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
158 int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
159 bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
161 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
163 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
164 struct vsp1_dl_body *dlb,
165 unsigned int alpha);
167 void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
168 struct vsp1_partition *partition,
169 unsigned int index,
170 struct vsp1_partition_window *window);
172 const struct vsp1_format_info *vsp1_get_format_info(struct vsp1_device *vsp1,
173 u32 fourcc);
175 #endif /* __VSP1_PIPE_H__ */