1 // SPDX-License-Identifier: GPL-2.0
3 #include <media/v4l2-event.h>
4 #include <media/v4l2-mem2mem.h>
5 #include <media/videobuf2-dma-contig.h>
7 #include "mtk_vcodec_drv.h"
8 #include "mtk_vcodec_dec.h"
9 #include "mtk_vcodec_intr.h"
10 #include "mtk_vcodec_util.h"
11 #include "mtk_vcodec_dec_pm.h"
12 #include "vdec_drv_if.h"
14 static struct mtk_video_fmt mtk_video_formats[] = {
16 .fourcc = V4L2_PIX_FMT_H264,
19 .flags = V4L2_FMT_FLAG_DYN_RESOLUTION,
20 .frmsize = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
21 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
24 .fourcc = V4L2_PIX_FMT_VP8,
27 .flags = V4L2_FMT_FLAG_DYN_RESOLUTION,
28 .frmsize = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
29 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
32 .fourcc = V4L2_PIX_FMT_VP9,
35 .flags = V4L2_FMT_FLAG_DYN_RESOLUTION,
36 .frmsize = { MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
37 MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
40 .fourcc = V4L2_PIX_FMT_MT21C,
41 .type = MTK_FMT_FRAME,
46 static const unsigned int num_supported_formats =
47 ARRAY_SIZE(mtk_video_formats);
49 #define DEFAULT_OUT_FMT_IDX 0
50 #define DEFAULT_CAP_FMT_IDX 3
53 * This function tries to clean all display buffers, the buffers will return
55 * Note the buffers returned from codec driver may still be in driver's
58 static struct vb2_buffer *get_display_buffer(struct mtk_vcodec_ctx *ctx)
60 struct vdec_fb *disp_frame_buffer = NULL;
61 struct mtk_video_dec_buf *dstbuf;
62 struct vb2_v4l2_buffer *vb;
64 mtk_v4l2_debug(3, "[%d]", ctx->id);
65 if (vdec_if_get_param(ctx, GET_PARAM_DISP_FRAME_BUFFER,
66 &disp_frame_buffer)) {
67 mtk_v4l2_err("[%d]Cannot get param : GET_PARAM_DISP_FRAME_BUFFER", ctx->id);
71 if (!disp_frame_buffer) {
72 mtk_v4l2_debug(3, "No display frame buffer");
76 dstbuf = container_of(disp_frame_buffer, struct mtk_video_dec_buf,
78 vb = &dstbuf->m2m_buf.vb;
79 mutex_lock(&ctx->lock);
81 mtk_v4l2_debug(2, "[%d]status=%x queue id=%d to done_list %d",
82 ctx->id, disp_frame_buffer->status,
83 vb->vb2_buf.index, dstbuf->queued_in_vb2);
85 v4l2_m2m_buf_done(vb, VB2_BUF_STATE_DONE);
86 ctx->decoded_frame_cnt++;
88 mutex_unlock(&ctx->lock);
93 * This function tries to clean all capture buffers that are not used as
94 * reference buffers by codec driver any more
95 * In this case, we need re-queue buffer to vb2 buffer if user space
96 * already returns this buffer to v4l2 or this buffer is just the output of
97 * previous sps/pps/resolution change decode, or do nothing if user
98 * space still owns this buffer
100 static struct vb2_buffer *get_free_buffer(struct mtk_vcodec_ctx *ctx)
102 struct mtk_video_dec_buf *dstbuf;
103 struct vdec_fb *free_frame_buffer = NULL;
104 struct vb2_v4l2_buffer *vb;
106 if (vdec_if_get_param(ctx, GET_PARAM_FREE_FRAME_BUFFER,
107 &free_frame_buffer)) {
108 mtk_v4l2_err("[%d] Error!! Cannot get param", ctx->id);
111 if (!free_frame_buffer) {
112 mtk_v4l2_debug(3, " No free frame buffer");
116 mtk_v4l2_debug(3, "[%d] tmp_frame_addr = 0x%p", ctx->id,
119 dstbuf = container_of(free_frame_buffer, struct mtk_video_dec_buf,
121 vb = &dstbuf->m2m_buf.vb;
123 mutex_lock(&ctx->lock);
125 if (dstbuf->queued_in_vb2 && dstbuf->queued_in_v4l2 &&
126 free_frame_buffer->status == FB_ST_FREE) {
128 * After decode sps/pps or non-display buffer, we don't
129 * need to return capture buffer to user space, but
130 * just re-queue this capture buffer to vb2 queue.
131 * This reduce overheads that dq/q unused capture
132 * buffer. In this case, queued_in_vb2 = true.
134 mtk_v4l2_debug(2, "[%d]status=%x queue id=%d to rdy_queue %d",
135 ctx->id, free_frame_buffer->status,
136 vb->vb2_buf.index, dstbuf->queued_in_vb2);
137 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
138 } else if (!dstbuf->queued_in_vb2 && dstbuf->queued_in_v4l2) {
140 * If buffer in v4l2 driver but not in vb2 queue yet,
141 * and we get this buffer from free_list, it means
142 * that codec driver do not use this buffer as
143 * reference buffer anymore. We should q buffer to vb2
144 * queue, so later work thread could get this buffer
145 * for decode. In this case, queued_in_vb2 = false
146 * means this buffer is not from previous decode
150 "[%d]status=%x queue id=%d to rdy_queue",
151 ctx->id, free_frame_buffer->status,
153 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
154 dstbuf->queued_in_vb2 = true;
157 * Codec driver do not need to reference this capture
158 * buffer and this buffer is not in v4l2 driver.
159 * Then we don't need to do any thing, just add log when
160 * we need to debug buffer flow.
161 * When this buffer q from user space, it could
162 * directly q to vb2 buffer
164 mtk_v4l2_debug(3, "[%d]status=%x err queue id=%d %d %d",
165 ctx->id, free_frame_buffer->status,
166 vb->vb2_buf.index, dstbuf->queued_in_vb2,
167 dstbuf->queued_in_v4l2);
169 dstbuf->used = false;
171 mutex_unlock(&ctx->lock);
175 static void clean_display_buffer(struct mtk_vcodec_ctx *ctx)
177 while (get_display_buffer(ctx))
181 static void clean_free_buffer(struct mtk_vcodec_ctx *ctx)
183 while (get_free_buffer(ctx))
187 static void mtk_vdec_queue_res_chg_event(struct mtk_vcodec_ctx *ctx)
189 static const struct v4l2_event ev_src_ch = {
190 .type = V4L2_EVENT_SOURCE_CHANGE,
191 .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
194 mtk_v4l2_debug(1, "[%d]", ctx->id);
195 v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
198 static int mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx)
203 ret = vdec_if_decode(ctx, NULL, NULL, &res_chg);
205 mtk_v4l2_err("DecodeFinal failed, ret=%d", ret);
207 clean_display_buffer(ctx);
208 clean_free_buffer(ctx);
213 static void mtk_vdec_update_fmt(struct mtk_vcodec_ctx *ctx,
214 unsigned int pixelformat)
216 const struct mtk_video_fmt *fmt;
217 struct mtk_q_data *dst_q_data;
220 dst_q_data = &ctx->q_data[MTK_Q_DATA_DST];
221 for (k = 0; k < num_supported_formats; k++) {
222 fmt = &mtk_video_formats[k];
223 if (fmt->fourcc == pixelformat) {
224 mtk_v4l2_debug(1, "Update cap fourcc(%d -> %d)",
225 dst_q_data->fmt->fourcc, pixelformat);
226 dst_q_data->fmt = fmt;
231 mtk_v4l2_err("Cannot get fourcc(%d), using init value", pixelformat);
234 static int mtk_vdec_pic_info_update(struct mtk_vcodec_ctx *ctx)
236 unsigned int dpbsize = 0;
239 if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO,
240 &ctx->last_decoded_picinfo)) {
241 mtk_v4l2_err("[%d]Error!! Cannot get param : GET_PARAM_PICTURE_INFO ERR", ctx->id);
245 if (ctx->last_decoded_picinfo.pic_w == 0 ||
246 ctx->last_decoded_picinfo.pic_h == 0 ||
247 ctx->last_decoded_picinfo.buf_w == 0 ||
248 ctx->last_decoded_picinfo.buf_h == 0) {
249 mtk_v4l2_err("Cannot get correct pic info");
253 if (ctx->last_decoded_picinfo.cap_fourcc != ctx->picinfo.cap_fourcc &&
254 ctx->picinfo.cap_fourcc != 0)
255 mtk_vdec_update_fmt(ctx, ctx->picinfo.cap_fourcc);
257 if (ctx->last_decoded_picinfo.pic_w == ctx->picinfo.pic_w ||
258 ctx->last_decoded_picinfo.pic_h == ctx->picinfo.pic_h)
261 mtk_v4l2_debug(1, "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)", ctx->id,
262 ctx->last_decoded_picinfo.pic_w,
263 ctx->last_decoded_picinfo.pic_h, ctx->picinfo.pic_w,
264 ctx->picinfo.pic_h, ctx->last_decoded_picinfo.buf_w,
265 ctx->last_decoded_picinfo.buf_h);
267 ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
269 mtk_v4l2_err("Incorrect dpb size, ret=%d", ret);
271 ctx->dpb_size = dpbsize;
276 static void mtk_vdec_worker(struct work_struct *work)
278 struct mtk_vcodec_ctx *ctx =
279 container_of(work, struct mtk_vcodec_ctx, decode_work);
280 struct mtk_vcodec_dev *dev = ctx->dev;
281 struct vb2_v4l2_buffer *src_buf, *dst_buf;
282 struct mtk_vcodec_mem buf;
284 bool res_chg = false;
286 struct mtk_video_dec_buf *dst_buf_info, *src_buf_info;
288 src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
290 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
291 mtk_v4l2_debug(1, "[%d] src_buf empty!!", ctx->id);
295 dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
297 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
298 mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id);
303 container_of(dst_buf, struct mtk_video_dec_buf, m2m_buf.vb);
305 pfb = &dst_buf_info->frame_buffer;
306 pfb->base_y.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
307 pfb->base_y.dma_addr =
308 vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
309 pfb->base_y.size = ctx->picinfo.fb_sz[0];
311 pfb->base_c.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 1);
312 pfb->base_c.dma_addr =
313 vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 1);
314 pfb->base_c.size = ctx->picinfo.fb_sz[1];
316 mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id);
319 "id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
320 dst_buf->vb2_buf.index, pfb, pfb->base_y.va,
321 &pfb->base_y.dma_addr, &pfb->base_c.dma_addr, pfb->base_y.size);
323 if (src_buf == &ctx->empty_flush_buf.vb) {
324 mtk_v4l2_debug(1, "Got empty flush input buffer.");
325 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
327 /* update dst buf status */
328 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
329 mutex_lock(&ctx->lock);
330 dst_buf_info->used = false;
331 mutex_unlock(&ctx->lock);
333 vdec_if_decode(ctx, NULL, NULL, &res_chg);
334 clean_display_buffer(ctx);
335 vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 0);
336 if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2)
337 vb2_set_plane_payload(&dst_buf->vb2_buf, 1, 0);
338 dst_buf->flags |= V4L2_BUF_FLAG_LAST;
339 v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
340 clean_free_buffer(ctx);
341 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
346 container_of(src_buf, struct mtk_video_dec_buf, m2m_buf.vb);
348 buf.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
349 buf.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
350 buf.size = (size_t)src_buf->vb2_buf.planes[0].bytesused;
352 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
353 mtk_v4l2_err("[%d] id=%d src_addr is NULL!!", ctx->id,
354 src_buf->vb2_buf.index);
357 mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
358 ctx->id, buf.va, &buf.dma_addr, buf.size, src_buf);
359 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
360 dst_buf->timecode = src_buf->timecode;
361 mutex_lock(&ctx->lock);
362 dst_buf_info->used = true;
363 mutex_unlock(&ctx->lock);
364 src_buf_info->used = true;
366 ret = vdec_if_decode(ctx, &buf, pfb, &res_chg);
369 mtk_v4l2_err(" <===[%d], src_buf[%d] sz=0x%zx pts=%llu dst_buf[%d] vdec_if_decode() ret=%d res_chg=%d===>",
370 ctx->id, src_buf->vb2_buf.index, buf.size,
371 src_buf->vb2_buf.timestamp, dst_buf->vb2_buf.index, ret, res_chg);
372 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
374 mutex_lock(&ctx->lock);
375 src_buf_info->error = true;
376 mutex_unlock(&ctx->lock);
378 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
379 } else if (!res_chg) {
381 * we only return src buffer with VB2_BUF_STATE_DONE
382 * when decode success without resolution change
384 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
385 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
388 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
389 clean_display_buffer(ctx);
390 clean_free_buffer(ctx);
392 if (!ret && res_chg) {
393 mtk_vdec_pic_info_update(ctx);
395 * On encountering a resolution change in the stream.
396 * The driver must first process and decode all
397 * remaining buffers from before the resolution change
398 * point, so call flush decode here
400 mtk_vdec_flush_decoder(ctx);
402 * After all buffers containing decoded frames from
403 * before the resolution change point ready to be
404 * dequeued on the CAPTURE queue, the driver sends a
405 * V4L2_EVENT_SOURCE_CHANGE event for source change
406 * type V4L2_EVENT_SRC_CH_RESOLUTION
408 mtk_vdec_queue_res_chg_event(ctx);
410 v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
413 static void vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
415 struct vb2_v4l2_buffer *src_buf;
416 struct mtk_vcodec_mem src_mem;
417 bool res_chg = false;
419 unsigned int dpbsize = 1, i;
420 struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
421 struct vb2_v4l2_buffer *vb2_v4l2;
422 struct mtk_q_data *dst_q_data;
424 mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id,
425 vb->vb2_queue->type, vb->index, vb);
427 * check if this buffer is ready to be used after decode
429 if (vb->vb2_queue->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
430 struct mtk_video_dec_buf *buf;
432 vb2_v4l2 = to_vb2_v4l2_buffer(vb);
433 buf = container_of(vb2_v4l2, struct mtk_video_dec_buf,
435 mutex_lock(&ctx->lock);
437 v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2);
438 buf->queued_in_vb2 = true;
439 buf->queued_in_v4l2 = true;
441 buf->queued_in_vb2 = false;
442 buf->queued_in_v4l2 = true;
444 mutex_unlock(&ctx->lock);
448 v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb));
450 if (ctx->state != MTK_STATE_INIT) {
451 mtk_v4l2_debug(3, "[%d] already init driver %d", ctx->id,
456 src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
458 mtk_v4l2_err("No src buffer");
462 if (src_buf == &ctx->empty_flush_buf.vb) {
463 /* This shouldn't happen. Just in case. */
464 mtk_v4l2_err("Invalid flush buffer.");
465 v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
469 src_mem.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
470 src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
471 src_mem.size = (size_t)src_buf->vb2_buf.planes[0].bytesused;
472 mtk_v4l2_debug(2, "[%d] buf id=%d va=%p dma=%pad size=%zx", ctx->id,
473 src_buf->vb2_buf.index, src_mem.va, &src_mem.dma_addr,
476 ret = vdec_if_decode(ctx, &src_mem, NULL, &res_chg);
477 if (ret || !res_chg) {
479 * fb == NULL means to parse SPS/PPS header or
480 * resolution info in src_mem. Decode can fail
481 * if there is no SPS header or picture info
485 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
487 mtk_v4l2_err("[%d] Unrecoverable error in vdec_if_decode.", ctx->id);
488 ctx->state = MTK_STATE_ABORT;
489 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
491 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
493 mtk_v4l2_debug(ret ? 0 : 1,
494 "[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
495 ctx->id, src_buf->vb2_buf.index, src_mem.size, ret, res_chg);
499 if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo)) {
500 mtk_v4l2_err("[%d]Error!! Cannot get param : GET_PARAM_PICTURE_INFO ERR", ctx->id);
504 ctx->last_decoded_picinfo = ctx->picinfo;
505 dst_q_data = &ctx->q_data[MTK_Q_DATA_DST];
506 for (i = 0; i < dst_q_data->fmt->num_planes; i++) {
507 dst_q_data->sizeimage[i] = ctx->picinfo.fb_sz[i];
508 dst_q_data->bytesperline[i] = ctx->picinfo.buf_w;
511 mtk_v4l2_debug(2, "[%d] vdec_if_init() OK wxh=%dx%d pic wxh=%dx%d sz[0]=0x%x sz[1]=0x%x",
512 ctx->id, ctx->picinfo.buf_w, ctx->picinfo.buf_h, ctx->picinfo.pic_w,
513 ctx->picinfo.pic_h, dst_q_data->sizeimage[0], dst_q_data->sizeimage[1]);
515 ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
517 mtk_v4l2_err("[%d] GET_PARAM_DPB_SIZE fail=%d", ctx->id, ret);
519 ctx->dpb_size = dpbsize;
520 ctx->state = MTK_STATE_HEADER;
521 mtk_v4l2_debug(1, "[%d] dpbsize=%d", ctx->id, ctx->dpb_size);
523 mtk_vdec_queue_res_chg_event(ctx);
526 static int mtk_vdec_g_v_ctrl(struct v4l2_ctrl *ctrl)
528 struct mtk_vcodec_ctx *ctx = ctrl_to_ctx(ctrl);
532 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
533 if (ctx->state >= MTK_STATE_HEADER) {
534 ctrl->val = ctx->dpb_size;
536 mtk_v4l2_debug(0, "Seqinfo not ready");
546 static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = {
547 .g_volatile_ctrl = mtk_vdec_g_v_ctrl,
550 static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx)
552 struct v4l2_ctrl *ctrl;
554 v4l2_ctrl_handler_init(&ctx->ctrl_hdl, 1);
556 ctrl = v4l2_ctrl_new_std(&ctx->ctrl_hdl, &mtk_vcodec_dec_ctrl_ops,
557 V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 0, 32, 1, 1);
558 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
559 v4l2_ctrl_new_std_menu(&ctx->ctrl_hdl, &mtk_vcodec_dec_ctrl_ops,
560 V4L2_CID_MPEG_VIDEO_VP9_PROFILE,
561 V4L2_MPEG_VIDEO_VP9_PROFILE_0, 0,
562 V4L2_MPEG_VIDEO_VP9_PROFILE_0);
564 * H264. Baseline / Extended decoding is not supported.
566 v4l2_ctrl_new_std_menu(&ctx->ctrl_hdl, &mtk_vcodec_dec_ctrl_ops,
567 V4L2_CID_MPEG_VIDEO_H264_PROFILE, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
568 BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) |
569 BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
570 V4L2_MPEG_VIDEO_H264_PROFILE_MAIN);
572 if (ctx->ctrl_hdl.error) {
573 mtk_v4l2_err("Adding control failed %d", ctx->ctrl_hdl.error);
574 return ctx->ctrl_hdl.error;
577 v4l2_ctrl_handler_setup(&ctx->ctrl_hdl);
581 static void mtk_init_vdec_params(struct mtk_vcodec_ctx *ctx)
585 if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED)) {
586 for (i = 0; i < num_supported_formats; i++) {
587 mtk_video_formats[i].frmsize.max_width =
588 VCODEC_DEC_4K_CODED_WIDTH;
589 mtk_video_formats[i].frmsize.max_height =
590 VCODEC_DEC_4K_CODED_HEIGHT;
595 static struct vb2_ops mtk_vdec_frame_vb2_ops = {
596 .queue_setup = vb2ops_vdec_queue_setup,
597 .buf_prepare = vb2ops_vdec_buf_prepare,
598 .wait_prepare = vb2_ops_wait_prepare,
599 .wait_finish = vb2_ops_wait_finish,
600 .start_streaming = vb2ops_vdec_start_streaming,
602 .buf_queue = vb2ops_vdec_stateful_buf_queue,
603 .buf_init = vb2ops_vdec_buf_init,
604 .buf_finish = vb2ops_vdec_buf_finish,
605 .stop_streaming = vb2ops_vdec_stop_streaming,
608 const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
609 .init_vdec_params = mtk_init_vdec_params,
610 .ctrls_setup = mtk_vcodec_dec_ctrls_setup,
611 .vdec_vb2_ops = &mtk_vdec_frame_vb2_ops,
612 .vdec_formats = mtk_video_formats,
613 .num_formats = &num_supported_formats,
614 .default_out_fmt = &mtk_video_formats[DEFAULT_OUT_FMT_IDX],
615 .default_cap_fmt = &mtk_video_formats[DEFAULT_CAP_FMT_IDX],
616 .worker = mtk_vdec_worker,
617 .flush_decoder = mtk_vdec_flush_decoder,
618 .is_subdev_supported = false,
619 .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,