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