hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
....@@ -1,16 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Copyright (c) 2016 MediaTek Inc.
34 * Author: PC Chen <pc.chen@mediatek.com>
45 * Tiffany Lin <tiffany.lin@mediatek.com>
5
-*
6
-* This program is free software; you can redistribute it and/or modify
7
-* it under the terms of the GNU General Public License version 2 as
8
-* published by the Free Software Foundation.
9
-*
10
-* This program is distributed in the hope that it will be useful,
11
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
-* GNU General Public License for more details.
146 */
157
168 #ifndef _MTK_VCODEC_DRV_H_
....@@ -107,6 +99,7 @@
10799 u32 fourcc;
108100 enum mtk_fmt_type type;
109101 u32 num_planes;
102
+ u32 flags;
110103 };
111104
112105 /**
....@@ -137,7 +130,7 @@
137130 enum v4l2_field field;
138131 unsigned int bytesperline[MTK_VCODEC_MAX_PLANES];
139132 unsigned int sizeimage[MTK_VCODEC_MAX_PLANES];
140
- struct mtk_video_fmt *fmt;
133
+ const struct mtk_video_fmt *fmt;
141134 };
142135
143136 /**
....@@ -151,9 +144,9 @@
151144 * @intra_period: I frame period
152145 * @gop_size: group of picture size, it's used as the intra frame period
153146 * @framerate_num: frame rate numerator. ex: framerate_num=30 and
154
- * framerate_denom=1 menas FPS is 30
147
+ * framerate_denom=1 means FPS is 30
155148 * @framerate_denom: frame rate denominator. ex: framerate_num=30 and
156
- * framerate_denom=1 menas FPS is 30
149
+ * framerate_denom=1 means FPS is 30
157150 * @h264_max_qp: Max value for H.264 quantization parameter
158151 * @h264_profile: V4L2 defined H.264 profile
159152 * @h264_level: V4L2 defined H.264 level
....@@ -176,22 +169,29 @@
176169 };
177170
178171 /**
172
+ * struct mtk_vcodec_clk_info - Structure used to store clock name
173
+ */
174
+struct mtk_vcodec_clk_info {
175
+ const char *clk_name;
176
+ struct clk *vcodec_clk;
177
+};
178
+
179
+/**
180
+ * struct mtk_vcodec_clk - Structure used to store vcodec clock information
181
+ */
182
+struct mtk_vcodec_clk {
183
+ struct mtk_vcodec_clk_info *clk_info;
184
+ int clk_num;
185
+};
186
+
187
+/**
179188 * struct mtk_vcodec_pm - Power management data structure
180189 */
181190 struct mtk_vcodec_pm {
182
- struct clk *vdec_bus_clk_src;
183
- struct clk *vencpll;
184
-
185
- struct clk *vcodecpll;
186
- struct clk *univpll_d2;
187
- struct clk *clk_cci400_sel;
188
- struct clk *vdecpll;
189
- struct clk *vdec_sel;
190
- struct clk *vencpll_d2;
191
- struct clk *venc_sel;
192
- struct clk *univpll1_d2;
193
- struct clk *venc_lt_sel;
191
+ struct mtk_vcodec_clk vdec_clk;
194192 struct device *larbvdec;
193
+
194
+ struct mtk_vcodec_clk venc_clk;
195195 struct device *larbvenc;
196196 struct device *larbvenclt;
197197 struct device *dev;
....@@ -204,24 +204,20 @@
204204 * @pic_h: picture height
205205 * @buf_w: picture buffer width (64 aligned up from pic_w)
206206 * @buf_h: picture buffer heiht (64 aligned up from pic_h)
207
- * @y_bs_sz: Y bitstream size
208
- * @c_bs_sz: CbCr bitstream size
209
- * @y_len_sz: additional size required to store decompress information for y
210
- * plane
211
- * @c_len_sz: additional size required to store decompress information for cbcr
212
- * plane
207
+ * @fb_sz: bitstream size of each plane
213208 * E.g. suppose picture size is 176x144,
214209 * buffer size will be aligned to 176x160.
210
+ * @cap_fourcc: fourcc number(may changed when resolution change)
211
+ * @reserved: align struct to 64-bit in order to adjust 32-bit and 64-bit os.
215212 */
216213 struct vdec_pic_info {
217214 unsigned int pic_w;
218215 unsigned int pic_h;
219216 unsigned int buf_w;
220217 unsigned int buf_h;
221
- unsigned int y_bs_sz;
222
- unsigned int c_bs_sz;
223
- unsigned int y_len_sz;
224
- unsigned int c_len_sz;
218
+ unsigned int fb_sz[VIDEO_MAX_PLANES];
219
+ unsigned int cap_fourcc;
220
+ unsigned int reserved;
225221 };
226222
227223 /**
....@@ -278,7 +274,7 @@
278274
279275 const struct vdec_common_if *dec_if;
280276 const struct venc_common_if *enc_if;
281
- unsigned long drv_handle;
277
+ void *drv_handle;
282278
283279 struct vdec_pic_info picinfo;
284280 int dpb_size;
....@@ -304,6 +300,40 @@
304300
305301 };
306302
303
+enum mtk_chip {
304
+ MTK_MT8173,
305
+ MTK_MT8183,
306
+};
307
+
308
+/**
309
+ * struct mtk_vcodec_enc_pdata - compatible data for each IC
310
+ *
311
+ * @chip: chip this encoder is compatible with
312
+ *
313
+ * @uses_ext: whether the encoder uses the extended firmware messaging format
314
+ * @has_lt_irq: whether the encoder uses the LT irq
315
+ * @min_birate: minimum supported encoding bitrate
316
+ * @max_bitrate: maximum supported encoding bitrate
317
+ * @capture_formats: array of supported capture formats
318
+ * @num_capture_formats: number of entries in capture_formats
319
+ * @output_formats: array of supported output formats
320
+ * @num_output_formats: number of entries in output_formats
321
+ */
322
+struct mtk_vcodec_enc_pdata {
323
+ enum mtk_chip chip;
324
+
325
+ bool uses_ext;
326
+ bool has_lt_irq;
327
+ unsigned long min_bitrate;
328
+ unsigned long max_bitrate;
329
+ const struct mtk_video_fmt *capture_formats;
330
+ size_t num_capture_formats;
331
+ const struct mtk_video_fmt *output_formats;
332
+ size_t num_output_formats;
333
+};
334
+
335
+#define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
336
+
307337 /**
308338 * struct mtk_vcodec_dev - driver data
309339 * @v4l2_dev: V4L2 device to register video devices for.
....@@ -313,13 +343,13 @@
313343 * @m2m_dev_dec: m2m device for decoder
314344 * @m2m_dev_enc: m2m device for encoder.
315345 * @plat_dev: platform device
316
- * @vpu_plat_dev: mtk vpu platform device
317346 * @ctx_list: list of struct mtk_vcodec_ctx
318347 * @irqlock: protect data access by irq handler and work thread
319348 * @curr_ctx: The context that is waiting for codec hardware
320349 *
321350 * @reg_base: Mapped address of MTK Vcodec registers.
322351 *
352
+ * @fw_handler: used to communicate with the firmware.
323353 * @id_counter: used to identify current opened instance
324354 *
325355 * @encode_workqueue: encode work queue
....@@ -348,11 +378,13 @@
348378 struct v4l2_m2m_dev *m2m_dev_dec;
349379 struct v4l2_m2m_dev *m2m_dev_enc;
350380 struct platform_device *plat_dev;
351
- struct platform_device *vpu_plat_dev;
352381 struct list_head ctx_list;
353382 spinlock_t irqlock;
354383 struct mtk_vcodec_ctx *curr_ctx;
355384 void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
385
+ const struct mtk_vcodec_enc_pdata *venc_pdata;
386
+
387
+ struct mtk_vcodec_fw *fw_handler;
356388
357389 unsigned long id_counter;
358390