• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2022 MediaTek Inc.
4  * Author: Ping-Hsun Wu <ping-hsun.wu@mediatek.com>
5  */
6 
7 #ifndef __MTK_MDP3_REGS_H__
8 #define __MTK_MDP3_REGS_H__
9 
10 #include <linux/videodev2.h>
11 #include <media/videobuf2-core.h>
12 #include "mtk-img-ipi.h"
13 
14 /*
15  * MDP native color code
16  * Plane count: 1, 2, 3
17  * H-subsample: 0, 1, 2
18  * V-subsample: 0, 1
19  * Color group: 0-RGB, 1-YUV, 2-raw
20  */
21 #define MDP_COLOR(PACKED, LOOSE, VIDEO, PLANE, HF, VF, BITS, GROUP, SWAP, ID)\
22 	(((PACKED) << 27) | ((LOOSE) << 26) | ((VIDEO) << 23) |\
23 	 ((PLANE) << 21) | ((HF) << 19) | ((VF) << 18) | ((BITS) << 8) |\
24 	 ((GROUP) << 6) | ((SWAP) << 5) | ((ID) << 0))
25 
26 #define MDP_COLOR_IS_10BIT_PACKED(c)	((0x08000000 & (c)) >> 27)
27 #define MDP_COLOR_IS_10BIT_LOOSE(c)	(((0x0c000000 & (c)) >> 26) == 1)
28 #define MDP_COLOR_IS_10BIT_TILE(c)	(((0x0c000000 & (c)) >> 26) == 3)
29 #define MDP_COLOR_IS_UFP(c)		((0x02000000 & (c)) >> 25)
30 #define MDP_COLOR_IS_INTERLACED(c)	((0x01000000 & (c)) >> 24)
31 #define MDP_COLOR_IS_BLOCK_MODE(c)	((0x00800000 & (c)) >> 23)
32 #define MDP_COLOR_GET_PLANE_COUNT(c)	((0x00600000 & (c)) >> 21)
33 #define MDP_COLOR_GET_H_SUBSAMPLE(c)	((0x00180000 & (c)) >> 19)
34 #define MDP_COLOR_GET_V_SUBSAMPLE(c)	((0x00040000 & (c)) >> 18)
35 #define MDP_COLOR_BITS_PER_PIXEL(c)	((0x0003ff00 & (c)) >>  8)
36 #define MDP_COLOR_GET_GROUP(c)		((0x000000c0 & (c)) >>  6)
37 #define MDP_COLOR_IS_SWAPPED(c)		((0x00000020 & (c)) >>  5)
38 #define MDP_COLOR_GET_UNIQUE_ID(c)	((0x0000001f & (c)) >>  0)
39 #define MDP_COLOR_GET_HW_FORMAT(c)	((0x0000001f & (c)) >>  0)
40 
41 #define MDP_COLOR_IS_RGB(c)		(MDP_COLOR_GET_GROUP(c) == 0)
42 #define MDP_COLOR_IS_YUV(c)		(MDP_COLOR_GET_GROUP(c) == 1)
43 
44 enum mdp_color {
45 	MDP_COLOR_UNKNOWN	= 0,
46 
47 	//MDP_COLOR_FULLG8,
48 	MDP_COLOR_FULLG8_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0,  8, 2,  0, 21),
49 	MDP_COLOR_FULLG8_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1,  8, 2,  0, 21),
50 	MDP_COLOR_FULLG8_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0,  8, 2,  0, 21),
51 	MDP_COLOR_FULLG8_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1,  8, 2,  0, 21),
52 	MDP_COLOR_FULLG8	= MDP_COLOR_FULLG8_BGGR,
53 
54 	//MDP_COLOR_FULLG10,
55 	MDP_COLOR_FULLG10_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 10, 2,  0, 21),
56 	MDP_COLOR_FULLG10_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 10, 2,  0, 21),
57 	MDP_COLOR_FULLG10_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 10, 2,  0, 21),
58 	MDP_COLOR_FULLG10_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 10, 2,  0, 21),
59 	MDP_COLOR_FULLG10	= MDP_COLOR_FULLG10_BGGR,
60 
61 	//MDP_COLOR_FULLG12,
62 	MDP_COLOR_FULLG12_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 12, 2,  0, 21),
63 	MDP_COLOR_FULLG12_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 12, 2,  0, 21),
64 	MDP_COLOR_FULLG12_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 12, 2,  0, 21),
65 	MDP_COLOR_FULLG12_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 12, 2,  0, 21),
66 	MDP_COLOR_FULLG12	= MDP_COLOR_FULLG12_BGGR,
67 
68 	//MDP_COLOR_FULLG14,
69 	MDP_COLOR_FULLG14_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 14, 2,  0, 21),
70 	MDP_COLOR_FULLG14_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 14, 2,  0, 21),
71 	MDP_COLOR_FULLG14_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 14, 2,  0, 21),
72 	MDP_COLOR_FULLG14_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 14, 2,  0, 21),
73 	MDP_COLOR_FULLG14	= MDP_COLOR_FULLG14_BGGR,
74 
75 	MDP_COLOR_UFO10		= MDP_COLOR(0, 0, 0, 1, 0, 0, 10, 2,  0, 24),
76 
77 	//MDP_COLOR_BAYER8,
78 	MDP_COLOR_BAYER8_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0,  8, 2,  0, 20),
79 	MDP_COLOR_BAYER8_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1,  8, 2,  0, 20),
80 	MDP_COLOR_BAYER8_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0,  8, 2,  0, 20),
81 	MDP_COLOR_BAYER8_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1,  8, 2,  0, 20),
82 	MDP_COLOR_BAYER8	= MDP_COLOR_BAYER8_BGGR,
83 
84 	//MDP_COLOR_BAYER10,
85 	MDP_COLOR_BAYER10_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 10, 2,  0, 20),
86 	MDP_COLOR_BAYER10_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 10, 2,  0, 20),
87 	MDP_COLOR_BAYER10_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 10, 2,  0, 20),
88 	MDP_COLOR_BAYER10_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 10, 2,  0, 20),
89 	MDP_COLOR_BAYER10	= MDP_COLOR_BAYER10_BGGR,
90 
91 	//MDP_COLOR_BAYER12,
92 	MDP_COLOR_BAYER12_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 12, 2,  0, 20),
93 	MDP_COLOR_BAYER12_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 12, 2,  0, 20),
94 	MDP_COLOR_BAYER12_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 12, 2,  0, 20),
95 	MDP_COLOR_BAYER12_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 12, 2,  0, 20),
96 	MDP_COLOR_BAYER12	= MDP_COLOR_BAYER12_BGGR,
97 
98 	//MDP_COLOR_BAYER14,
99 	MDP_COLOR_BAYER14_RGGB	= MDP_COLOR(0, 0, 0, 1, 0, 0, 14, 2,  0, 20),
100 	MDP_COLOR_BAYER14_GRBG	= MDP_COLOR(0, 0, 0, 1, 0, 1, 14, 2,  0, 20),
101 	MDP_COLOR_BAYER14_GBRG	= MDP_COLOR(0, 0, 0, 1, 1, 0, 14, 2,  0, 20),
102 	MDP_COLOR_BAYER14_BGGR	= MDP_COLOR(0, 0, 0, 1, 1, 1, 14, 2,  0, 20),
103 	MDP_COLOR_BAYER14	= MDP_COLOR_BAYER14_BGGR,
104 
105 	MDP_COLOR_RGB48		= MDP_COLOR(0, 0, 0, 1, 0, 0, 48, 0,  0, 23),
106 	/* For bayer+mono raw-16 */
107 	MDP_COLOR_RGB565_RAW	= MDP_COLOR(0, 0, 0, 1, 0, 0, 16, 2,  0, 0),
108 
109 	MDP_COLOR_BAYER8_UNPAK	= MDP_COLOR(0, 0, 0, 1, 0, 0,  8, 2,  0, 22),
110 	MDP_COLOR_BAYER10_UNPAK	= MDP_COLOR(0, 0, 0, 1, 0, 0, 10, 2,  0, 22),
111 	MDP_COLOR_BAYER12_UNPAK	= MDP_COLOR(0, 0, 0, 1, 0, 0, 12, 2,  0, 22),
112 	MDP_COLOR_BAYER14_UNPAK	= MDP_COLOR(0, 0, 0, 1, 0, 0, 14, 2,  0, 22),
113 
114 	/* Unified formats */
115 	MDP_COLOR_GREY		= MDP_COLOR(0, 0, 0, 1, 0, 0,  8, 1,  0, 7),
116 
117 	MDP_COLOR_RGB565	= MDP_COLOR(0, 0, 0, 1, 0, 0, 16, 0,  0, 0),
118 	MDP_COLOR_BGR565	= MDP_COLOR(0, 0, 0, 1, 0, 0, 16, 0,  1, 0),
119 	MDP_COLOR_RGB888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 24, 0,  1, 1),
120 	MDP_COLOR_BGR888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 24, 0,  0, 1),
121 	MDP_COLOR_RGBA8888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 32, 0,  1, 2),
122 	MDP_COLOR_BGRA8888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 32, 0,  0, 2),
123 	MDP_COLOR_ARGB8888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 32, 0,  1, 3),
124 	MDP_COLOR_ABGR8888	= MDP_COLOR(0, 0, 0, 1, 0, 0, 32, 0,  0, 3),
125 
126 	MDP_COLOR_UYVY		= MDP_COLOR(0, 0, 0, 1, 1, 0, 16, 1,  0, 4),
127 	MDP_COLOR_VYUY		= MDP_COLOR(0, 0, 0, 1, 1, 0, 16, 1,  1, 4),
128 	MDP_COLOR_YUYV		= MDP_COLOR(0, 0, 0, 1, 1, 0, 16, 1,  0, 5),
129 	MDP_COLOR_YVYU		= MDP_COLOR(0, 0, 0, 1, 1, 0, 16, 1,  1, 5),
130 
131 	MDP_COLOR_I420		= MDP_COLOR(0, 0, 0, 3, 1, 1,  8, 1,  0, 8),
132 	MDP_COLOR_YV12		= MDP_COLOR(0, 0, 0, 3, 1, 1,  8, 1,  1, 8),
133 	MDP_COLOR_I422		= MDP_COLOR(0, 0, 0, 3, 1, 0,  8, 1,  0, 9),
134 	MDP_COLOR_YV16		= MDP_COLOR(0, 0, 0, 3, 1, 0,  8, 1,  1, 9),
135 	MDP_COLOR_I444		= MDP_COLOR(0, 0, 0, 3, 0, 0,  8, 1,  0, 10),
136 	MDP_COLOR_YV24		= MDP_COLOR(0, 0, 0, 3, 0, 0,  8, 1,  1, 10),
137 
138 	MDP_COLOR_NV12		= MDP_COLOR(0, 0, 0, 2, 1, 1,  8, 1,  0, 12),
139 	MDP_COLOR_NV21		= MDP_COLOR(0, 0, 0, 2, 1, 1,  8, 1,  1, 12),
140 	MDP_COLOR_NV16		= MDP_COLOR(0, 0, 0, 2, 1, 0,  8, 1,  0, 13),
141 	MDP_COLOR_NV61		= MDP_COLOR(0, 0, 0, 2, 1, 0,  8, 1,  1, 13),
142 	MDP_COLOR_NV24		= MDP_COLOR(0, 0, 0, 2, 0, 0,  8, 1,  0, 14),
143 	MDP_COLOR_NV42		= MDP_COLOR(0, 0, 0, 2, 0, 0,  8, 1,  1, 14),
144 
145 	/* MediaTek proprietary formats */
146 	/* UFO encoded block mode */
147 	MDP_COLOR_420_BLK_UFO	= MDP_COLOR(0, 0, 5, 2, 1, 1, 256, 1, 0, 12),
148 	/* Block mode */
149 	MDP_COLOR_420_BLK	= MDP_COLOR(0, 0, 1, 2, 1, 1, 256, 1, 0, 12),
150 	/* Block mode + field mode */
151 	MDP_COLOR_420_BLKI	= MDP_COLOR(0, 0, 3, 2, 1, 1, 256, 1, 0, 12),
152 	/* Block mode */
153 	MDP_COLOR_422_BLK	= MDP_COLOR(0, 0, 1, 1, 1, 0, 512, 1, 0, 4),
154 
155 	MDP_COLOR_IYU2		= MDP_COLOR(0, 0, 0, 1, 0, 0, 24,  1, 0, 25),
156 	MDP_COLOR_YUV444	= MDP_COLOR(0, 0, 0, 1, 0, 0, 24,  1, 0, 30),
157 
158 	/* Packed 10-bit formats */
159 	MDP_COLOR_RGBA1010102	= MDP_COLOR(1, 0, 0, 1, 0, 0, 32,  0, 1, 2),
160 	MDP_COLOR_BGRA1010102	= MDP_COLOR(1, 0, 0, 1, 0, 0, 32,  0, 0, 2),
161 	/* Packed 10-bit UYVY */
162 	MDP_COLOR_UYVY_10P	= MDP_COLOR(1, 0, 0, 1, 1, 0, 20,  1, 0, 4),
163 	/* Packed 10-bit NV21 */
164 	MDP_COLOR_NV21_10P	= MDP_COLOR(1, 0, 0, 2, 1, 1, 10,  1, 1, 12),
165 	/* 10-bit block mode */
166 	MDP_COLOR_420_BLK_10_H	= MDP_COLOR(1, 0, 1, 2, 1, 1, 320, 1, 0, 12),
167 	/* 10-bit HEVC tile mode */
168 	MDP_COLOR_420_BLK_10_V	= MDP_COLOR(1, 1, 1, 2, 1, 1, 320, 1, 0, 12),
169 	/* UFO encoded 10-bit block mode */
170 	MDP_COLOR_420_BLK_U10_H	= MDP_COLOR(1, 0, 5, 2, 1, 1, 320, 1, 0, 12),
171 	/* UFO encoded 10-bit HEVC tile mode */
172 	MDP_COLOR_420_BLK_U10_V	= MDP_COLOR(1, 1, 5, 2, 1, 1, 320, 1, 0, 12),
173 
174 	/* Loose 10-bit formats */
175 	MDP_COLOR_UYVY_10L	= MDP_COLOR(0, 1, 0, 1, 1, 0, 20,  1, 0, 4),
176 	MDP_COLOR_VYUY_10L	= MDP_COLOR(0, 1, 0, 1, 1, 0, 20,  1, 1, 4),
177 	MDP_COLOR_YUYV_10L	= MDP_COLOR(0, 1, 0, 1, 1, 0, 20,  1, 0, 5),
178 	MDP_COLOR_YVYU_10L	= MDP_COLOR(0, 1, 0, 1, 1, 0, 20,  1, 1, 5),
179 	MDP_COLOR_NV12_10L	= MDP_COLOR(0, 1, 0, 2, 1, 1, 10,  1, 0, 12),
180 	MDP_COLOR_NV21_10L	= MDP_COLOR(0, 1, 0, 2, 1, 1, 10,  1, 1, 12),
181 	MDP_COLOR_NV16_10L	= MDP_COLOR(0, 1, 0, 2, 1, 0, 10,  1, 0, 13),
182 	MDP_COLOR_NV61_10L	= MDP_COLOR(0, 1, 0, 2, 1, 0, 10,  1, 1, 13),
183 	MDP_COLOR_YV12_10L	= MDP_COLOR(0, 1, 0, 3, 1, 1, 10,  1, 1, 8),
184 	MDP_COLOR_I420_10L	= MDP_COLOR(0, 1, 0, 3, 1, 1, 10,  1, 0, 8),
185 };
186 
MDP_COLOR_IS_UV_COPLANE(enum mdp_color c)187 static inline bool MDP_COLOR_IS_UV_COPLANE(enum mdp_color c)
188 {
189 	return (MDP_COLOR_GET_PLANE_COUNT(c) == 2 && MDP_COLOR_IS_YUV(c));
190 }
191 
192 /* Minimum Y stride that is accepted by MDP HW */
mdp_color_get_min_y_stride(enum mdp_color c,u32 width)193 static inline u32 mdp_color_get_min_y_stride(enum mdp_color c, u32 width)
194 {
195 	return ((MDP_COLOR_BITS_PER_PIXEL(c) * width) + 4) >> 3;
196 }
197 
198 /* Minimum UV stride that is accepted by MDP HW */
mdp_color_get_min_uv_stride(enum mdp_color c,u32 width)199 static inline u32 mdp_color_get_min_uv_stride(enum mdp_color c, u32 width)
200 {
201 	u32 min_stride;
202 
203 	if (MDP_COLOR_GET_PLANE_COUNT(c) == 1)
204 		return 0;
205 	min_stride = mdp_color_get_min_y_stride(c, width)
206 		>> MDP_COLOR_GET_H_SUBSAMPLE(c);
207 	if (MDP_COLOR_IS_UV_COPLANE(c) && !MDP_COLOR_IS_BLOCK_MODE(c))
208 		min_stride = min_stride * 2;
209 	return min_stride;
210 }
211 
212 /* Minimum Y plane size that is necessary in buffer */
mdp_color_get_min_y_size(enum mdp_color c,u32 width,u32 height)213 static inline u32 mdp_color_get_min_y_size(enum mdp_color c,
214 					   u32 width, u32 height)
215 {
216 	if (MDP_COLOR_IS_BLOCK_MODE(c))
217 		return ((MDP_COLOR_BITS_PER_PIXEL(c) * width) >> 8) * height;
218 	return mdp_color_get_min_y_stride(c, width) * height;
219 }
220 
221 /* Minimum UV plane size that is necessary in buffer */
mdp_color_get_min_uv_size(enum mdp_color c,u32 width,u32 height)222 static inline u32 mdp_color_get_min_uv_size(enum mdp_color c,
223 					    u32 width, u32 height)
224 {
225 	height = height >> MDP_COLOR_GET_V_SUBSAMPLE(c);
226 	if (MDP_COLOR_IS_BLOCK_MODE(c) && (MDP_COLOR_GET_PLANE_COUNT(c) > 1))
227 		return ((MDP_COLOR_BITS_PER_PIXEL(c) * width) >> 8) * height;
228 	return mdp_color_get_min_uv_stride(c, width) * height;
229 }
230 
231 /* Combine colorspace, xfer_func, ycbcr_encoding, and quantization */
232 enum mdp_ycbcr_profile {
233 	/* V4L2_YCBCR_ENC_601 and V4L2_QUANTIZATION_LIM_RANGE */
234 	MDP_YCBCR_PROFILE_BT601,
235 	/* V4L2_YCBCR_ENC_709 and V4L2_QUANTIZATION_LIM_RANGE */
236 	MDP_YCBCR_PROFILE_BT709,
237 	/* V4L2_YCBCR_ENC_601 and V4L2_QUANTIZATION_FULL_RANGE */
238 	MDP_YCBCR_PROFILE_JPEG,
239 	MDP_YCBCR_PROFILE_FULL_BT601 = MDP_YCBCR_PROFILE_JPEG,
240 
241 	/* Colorspaces not support for capture */
242 	/* V4L2_YCBCR_ENC_BT2020 and V4L2_QUANTIZATION_LIM_RANGE */
243 	MDP_YCBCR_PROFILE_BT2020,
244 	/* V4L2_YCBCR_ENC_709 and V4L2_QUANTIZATION_FULL_RANGE */
245 	MDP_YCBCR_PROFILE_FULL_BT709,
246 	/* V4L2_YCBCR_ENC_BT2020 and V4L2_QUANTIZATION_FULL_RANGE */
247 	MDP_YCBCR_PROFILE_FULL_BT2020,
248 };
249 
250 #define MDP_FMT_FLAG_OUTPUT	BIT(0)
251 #define MDP_FMT_FLAG_CAPTURE	BIT(1)
252 
253 struct mdp_format {
254 	u32	pixelformat;
255 	u32	mdp_color;
256 	u8	depth[VIDEO_MAX_PLANES];
257 	u8	row_depth[VIDEO_MAX_PLANES];
258 	u8	num_planes;
259 	u8	walign;
260 	u8	halign;
261 	u8	salign;
262 	u32	flags;
263 };
264 
265 struct mdp_pix_limit {
266 	u32	wmin;
267 	u32	hmin;
268 	u32	wmax;
269 	u32	hmax;
270 };
271 
272 struct mdp_limit {
273 	struct mdp_pix_limit	out_limit;
274 	struct mdp_pix_limit	cap_limit;
275 	u32			h_scale_up_max;
276 	u32			v_scale_up_max;
277 	u32			h_scale_down_max;
278 	u32			v_scale_down_max;
279 };
280 
281 enum mdp_stream_type {
282 	MDP_STREAM_TYPE_UNKNOWN,
283 	MDP_STREAM_TYPE_BITBLT,
284 	MDP_STREAM_TYPE_GPU_BITBLT,
285 	MDP_STREAM_TYPE_DUAL_BITBLT,
286 	MDP_STREAM_TYPE_2ND_BITBLT,
287 	MDP_STREAM_TYPE_ISP_IC,
288 	MDP_STREAM_TYPE_ISP_VR,
289 	MDP_STREAM_TYPE_ISP_ZSD,
290 	MDP_STREAM_TYPE_ISP_IP,
291 	MDP_STREAM_TYPE_ISP_VSS,
292 	MDP_STREAM_TYPE_ISP_ZSD_SLOW,
293 	MDP_STREAM_TYPE_WPE,
294 	MDP_STREAM_TYPE_WPE2,
295 };
296 
297 struct mdp_crop {
298 	struct v4l2_rect	c;
299 	struct v4l2_fract	left_subpix;
300 	struct v4l2_fract	top_subpix;
301 	struct v4l2_fract	width_subpix;
302 	struct v4l2_fract	height_subpix;
303 };
304 
305 struct mdp_frame {
306 	struct v4l2_format	format;
307 	const struct mdp_format	*mdp_fmt;
308 	u32			ycbcr_prof;	/* enum mdp_ycbcr_profile */
309 	u32			usage;		/* enum mdp_buffer_usage */
310 	struct mdp_crop		crop;
311 	struct v4l2_rect	compose;
312 	s32			rotation;
313 	u32			hflip:1;
314 	u32			vflip:1;
315 	u32			hdr:1;
316 	u32			dre:1;
317 	u32			sharpness:1;
318 	u32			dither:1;
319 };
320 
mdp_target_is_crop(u32 target)321 static inline bool mdp_target_is_crop(u32 target)
322 {
323 	return (target == V4L2_SEL_TGT_CROP) ||
324 		(target == V4L2_SEL_TGT_CROP_DEFAULT) ||
325 		(target == V4L2_SEL_TGT_CROP_BOUNDS);
326 }
327 
mdp_target_is_compose(u32 target)328 static inline bool mdp_target_is_compose(u32 target)
329 {
330 	return (target == V4L2_SEL_TGT_COMPOSE) ||
331 		(target == V4L2_SEL_TGT_COMPOSE_DEFAULT) ||
332 		(target == V4L2_SEL_TGT_COMPOSE_BOUNDS);
333 }
334 
335 #define MDP_MAX_CAPTURES	IMG_MAX_HW_OUTPUTS
336 
337 #define MDP_VPU_INIT		BIT(0)
338 #define MDP_M2M_CTX_ERROR	BIT(1)
339 
340 struct mdp_frameparam {
341 	struct list_head	list;
342 	struct mdp_m2m_ctx	*ctx;
343 	atomic_t		state;
344 	const struct mdp_limit	*limit;
345 	u32			type;	/* enum mdp_stream_type */
346 	u32			frame_no;
347 	struct mdp_frame	output;
348 	struct mdp_frame	captures[MDP_MAX_CAPTURES];
349 	u32			num_captures;
350 	enum v4l2_colorspace		colorspace;
351 	enum v4l2_ycbcr_encoding	ycbcr_enc;
352 	enum v4l2_xfer_func		xfer_func;
353 	enum v4l2_quantization		quant;
354 };
355 
356 int mdp_enum_fmt_mplane(struct v4l2_fmtdesc *f);
357 const struct mdp_format *mdp_try_fmt_mplane(struct v4l2_format *f,
358 					    struct mdp_frameparam *param,
359 					    u32 ctx_id);
360 enum mdp_ycbcr_profile mdp_map_ycbcr_prof_mplane(struct v4l2_format *f,
361 						 u32 mdp_color);
362 int mdp_try_crop(struct mdp_m2m_ctx *ctx, struct v4l2_rect *r,
363 		 const struct v4l2_selection *s, struct mdp_frame *frame);
364 int mdp_check_scaling_ratio(const struct v4l2_rect *crop,
365 			    const struct v4l2_rect *compose, s32 rotation,
366 	const struct mdp_limit *limit);
367 void mdp_set_src_config(struct img_input *in,
368 			struct mdp_frame *frame, struct vb2_buffer *vb);
369 void mdp_set_dst_config(struct img_output *out,
370 			struct mdp_frame *frame, struct vb2_buffer *vb);
371 int mdp_frameparam_init(struct mdp_frameparam *param);
372 
373 #endif  /* __MTK_MDP3_REGS_H__ */
374