#include "mtk-mdp3-cfg.h"
 #include "mtk-mdp3-core.h"
 #include "mtk-mdp3-comp.h"
+#include "mtk-mdp3-regs.h"
 
 enum mt8183_mdp_comp_id {
        /* ISP */
        {}
 };
 
+/*
+ * All 10-bit related formats are not added in the basic format list,
+ * please add the corresponding format settings before use.
+ */
+static const struct mdp_format mt8183_formats[] = {
+       {
+               .pixelformat    = V4L2_PIX_FMT_GREY,
+               .mdp_color      = MDP_COLOR_GREY,
+               .depth          = { 8 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_RGB565X,
+               .mdp_color      = MDP_COLOR_BGR565,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_RGB565,
+               .mdp_color      = MDP_COLOR_RGB565,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_RGB24,
+               .mdp_color      = MDP_COLOR_RGB888,
+               .depth          = { 24 },
+               .row_depth      = { 24 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_BGR24,
+               .mdp_color      = MDP_COLOR_BGR888,
+               .depth          = { 24 },
+               .row_depth      = { 24 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_ABGR32,
+               .mdp_color      = MDP_COLOR_BGRA8888,
+               .depth          = { 32 },
+               .row_depth      = { 32 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_ARGB32,
+               .mdp_color      = MDP_COLOR_ARGB8888,
+               .depth          = { 32 },
+               .row_depth      = { 32 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_UYVY,
+               .mdp_color      = MDP_COLOR_UYVY,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_VYUY,
+               .mdp_color      = MDP_COLOR_VYUY,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YUYV,
+               .mdp_color      = MDP_COLOR_YUYV,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YVYU,
+               .mdp_color      = MDP_COLOR_YVYU,
+               .depth          = { 16 },
+               .row_depth      = { 16 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YUV420,
+               .mdp_color      = MDP_COLOR_I420,
+               .depth          = { 12 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YVU420,
+               .mdp_color      = MDP_COLOR_YV12,
+               .depth          = { 12 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV12,
+               .mdp_color      = MDP_COLOR_NV12,
+               .depth          = { 12 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV21,
+               .mdp_color      = MDP_COLOR_NV21,
+               .depth          = { 12 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV16,
+               .mdp_color      = MDP_COLOR_NV16,
+               .depth          = { 16 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV61,
+               .mdp_color      = MDP_COLOR_NV61,
+               .depth          = { 16 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV24,
+               .mdp_color      = MDP_COLOR_NV24,
+               .depth          = { 24 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV42,
+               .mdp_color      = MDP_COLOR_NV42,
+               .depth          = { 24 },
+               .row_depth      = { 8 },
+               .num_planes     = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_MT21C,
+               .mdp_color      = MDP_COLOR_420_BLK_UFO,
+               .depth          = { 8, 4 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 4,
+               .halign         = 5,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_MM21,
+               .mdp_color      = MDP_COLOR_420_BLK,
+               .depth          = { 8, 4 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 4,
+               .halign         = 5,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV12M,
+               .mdp_color      = MDP_COLOR_NV12,
+               .depth          = { 8, 4 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV21M,
+               .mdp_color      = MDP_COLOR_NV21,
+               .depth          = { 8, 4 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV16M,
+               .mdp_color      = MDP_COLOR_NV16,
+               .depth          = { 8, 8 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_NV61M,
+               .mdp_color      = MDP_COLOR_NV61,
+               .depth          = { 8, 8 },
+               .row_depth      = { 8, 8 },
+               .num_planes     = 2,
+               .walign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YUV420M,
+               .mdp_color      = MDP_COLOR_I420,
+               .depth          = { 8, 2, 2 },
+               .row_depth      = { 8, 4, 4 },
+               .num_planes     = 3,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }, {
+               .pixelformat    = V4L2_PIX_FMT_YVU420M,
+               .mdp_color      = MDP_COLOR_YV12,
+               .depth          = { 8, 2, 2 },
+               .row_depth      = { 8, 4, 4 },
+               .num_planes     = 3,
+               .walign         = 1,
+               .halign         = 1,
+               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
+       }
+};
+
 const struct mtk_mdp_driver_data mt8183_mdp_driver_data = {
        .mdp_probe_infra = mt8183_mdp_probe_infra,
        .mdp_cfg = &mt8183_plat_cfg,
        .comp_data = mt8183_mdp_comp_data,
        .comp_data_len = ARRAY_SIZE(mt8183_mdp_comp_data),
        .mdp_sub_comp_dt_ids = mt8183_sub_comp_dt_ids,
+       .format = mt8183_formats,
+       .format_len = ARRAY_SIZE(mt8183_formats),
 };
 
 s32 mdp_cfg_get_id_inner(struct mdp_dev *mdp_dev, enum mtk_mdp_comp_id id)
 
 #include "mtk-mdp3-regs.h"
 #include "mtk-mdp3-m2m.h"
 
-/*
- * All 10-bit related formats are not added in the basic format list,
- * please add the corresponding format settings before use.
- */
-static const struct mdp_format mdp_formats[] = {
-       {
-               .pixelformat    = V4L2_PIX_FMT_GREY,
-               .mdp_color      = MDP_COLOR_GREY,
-               .depth          = { 8 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_RGB565X,
-               .mdp_color      = MDP_COLOR_BGR565,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_RGB565,
-               .mdp_color      = MDP_COLOR_RGB565,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_RGB24,
-               .mdp_color      = MDP_COLOR_RGB888,
-               .depth          = { 24 },
-               .row_depth      = { 24 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_BGR24,
-               .mdp_color      = MDP_COLOR_BGR888,
-               .depth          = { 24 },
-               .row_depth      = { 24 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_ABGR32,
-               .mdp_color      = MDP_COLOR_BGRA8888,
-               .depth          = { 32 },
-               .row_depth      = { 32 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_ARGB32,
-               .mdp_color      = MDP_COLOR_ARGB8888,
-               .depth          = { 32 },
-               .row_depth      = { 32 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_UYVY,
-               .mdp_color      = MDP_COLOR_UYVY,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_VYUY,
-               .mdp_color      = MDP_COLOR_VYUY,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YUYV,
-               .mdp_color      = MDP_COLOR_YUYV,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YVYU,
-               .mdp_color      = MDP_COLOR_YVYU,
-               .depth          = { 16 },
-               .row_depth      = { 16 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YUV420,
-               .mdp_color      = MDP_COLOR_I420,
-               .depth          = { 12 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YVU420,
-               .mdp_color      = MDP_COLOR_YV12,
-               .depth          = { 12 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV12,
-               .mdp_color      = MDP_COLOR_NV12,
-               .depth          = { 12 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV21,
-               .mdp_color      = MDP_COLOR_NV21,
-               .depth          = { 12 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV16,
-               .mdp_color      = MDP_COLOR_NV16,
-               .depth          = { 16 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV61,
-               .mdp_color      = MDP_COLOR_NV61,
-               .depth          = { 16 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV24,
-               .mdp_color      = MDP_COLOR_NV24,
-               .depth          = { 24 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV42,
-               .mdp_color      = MDP_COLOR_NV42,
-               .depth          = { 24 },
-               .row_depth      = { 8 },
-               .num_planes     = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_MT21C,
-               .mdp_color      = MDP_COLOR_420_BLK_UFO,
-               .depth          = { 8, 4 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 4,
-               .halign         = 5,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_MM21,
-               .mdp_color      = MDP_COLOR_420_BLK,
-               .depth          = { 8, 4 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 4,
-               .halign         = 5,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV12M,
-               .mdp_color      = MDP_COLOR_NV12,
-               .depth          = { 8, 4 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV21M,
-               .mdp_color      = MDP_COLOR_NV21,
-               .depth          = { 8, 4 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV16M,
-               .mdp_color      = MDP_COLOR_NV16,
-               .depth          = { 8, 8 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_NV61M,
-               .mdp_color      = MDP_COLOR_NV61,
-               .depth          = { 8, 8 },
-               .row_depth      = { 8, 8 },
-               .num_planes     = 2,
-               .walign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YUV420M,
-               .mdp_color      = MDP_COLOR_I420,
-               .depth          = { 8, 2, 2 },
-               .row_depth      = { 8, 4, 4 },
-               .num_planes     = 3,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }, {
-               .pixelformat    = V4L2_PIX_FMT_YVU420M,
-               .mdp_color      = MDP_COLOR_YV12,
-               .depth          = { 8, 2, 2 },
-               .row_depth      = { 8, 4, 4 },
-               .num_planes     = 3,
-               .walign         = 1,
-               .halign         = 1,
-               .flags          = MDP_FMT_FLAG_OUTPUT | MDP_FMT_FLAG_CAPTURE,
-       }
-};
-
 static const struct mdp_limit mdp_def_limit = {
        .out_limit = {
                .wmin   = 16,
        .v_scale_down_max = 128,
 };
 
-static const struct mdp_format *mdp_find_fmt(u32 pixelformat, u32 type)
+static const struct mdp_format *mdp_find_fmt(const struct mtk_mdp_driver_data *mdp_data,
+                                            u32 pixelformat, u32 type)
 {
        u32 i, flag;
 
        flag = V4L2_TYPE_IS_OUTPUT(type) ? MDP_FMT_FLAG_OUTPUT :
                                        MDP_FMT_FLAG_CAPTURE;
-       for (i = 0; i < ARRAY_SIZE(mdp_formats); ++i) {
-               if (!(mdp_formats[i].flags & flag))
+       for (i = 0; i < mdp_data->format_len; ++i) {
+               if (!(mdp_data->format[i].flags & flag))
                        continue;
-               if (mdp_formats[i].pixelformat == pixelformat)
-                       return &mdp_formats[i];
+               if (mdp_data->format[i].pixelformat == pixelformat)
+                       return &mdp_data->format[i];
        }
        return NULL;
 }
 
-static const struct mdp_format *mdp_find_fmt_by_index(u32 index, u32 type)
+static const struct mdp_format *mdp_find_fmt_by_index(const struct mtk_mdp_driver_data *mdp_data,
+                                                     u32 index, u32 type)
 {
        u32 i, flag, num = 0;
 
        flag = V4L2_TYPE_IS_OUTPUT(type) ? MDP_FMT_FLAG_OUTPUT :
                                        MDP_FMT_FLAG_CAPTURE;
-       for (i = 0; i < ARRAY_SIZE(mdp_formats); ++i) {
-               if (!(mdp_formats[i].flags & flag))
+       for (i = 0; i < mdp_data->format_len; ++i) {
+               if (!(mdp_data->format[i].flags & flag))
                        continue;
                if (index == num)
-                       return &mdp_formats[i];
+                       return &mdp_data->format[i];
                num++;
        }
        return NULL;
        return 0;
 }
 
-int mdp_enum_fmt_mplane(struct v4l2_fmtdesc *f)
+int mdp_enum_fmt_mplane(struct mdp_dev *mdp, struct v4l2_fmtdesc *f)
 {
        const struct mdp_format *fmt;
 
-       fmt = mdp_find_fmt_by_index(f->index, f->type);
+       fmt = mdp_find_fmt_by_index(mdp->mdp_data, f->index, f->type);
        if (!fmt)
                return -EINVAL;
 
        return 0;
 }
 
-const struct mdp_format *mdp_try_fmt_mplane(struct v4l2_format *f,
+const struct mdp_format *mdp_try_fmt_mplane(struct mdp_dev *mdp,
+                                           struct v4l2_format *f,
                                            struct mdp_frameparam *param,
                                            u32 ctx_id)
 {
        u32 org_w, org_h;
        unsigned int i;
 
-       fmt = mdp_find_fmt(pix_mp->pixelformat, f->type);
+       fmt = mdp_find_fmt(mdp->mdp_data, pix_mp->pixelformat, f->type);
        if (!fmt) {
-               fmt = mdp_find_fmt_by_index(0, f->type);
+               fmt = mdp_find_fmt_by_index(mdp->mdp_data, 0, f->type);
                if (!fmt) {
                        dev_dbg(dev, "%d: pixelformat %c%c%c%c invalid", ctx_id,
                                (pix_mp->pixelformat & 0xff),
        mdp_set_orientation(out, frame->rotation, frame->hflip, frame->vflip);
 }
 
-int mdp_frameparam_init(struct mdp_frameparam *param)
+int mdp_frameparam_init(struct mdp_dev *mdp, struct mdp_frameparam *param)
 {
        struct mdp_frame *frame;
 
 
        frame = ¶m->output;
        frame->format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-       frame->mdp_fmt = mdp_try_fmt_mplane(&frame->format, param, 0);
+       frame->mdp_fmt = mdp_try_fmt_mplane(mdp, &frame->format, param, 0);
        frame->ycbcr_prof =
                mdp_map_ycbcr_prof_mplane(&frame->format,
                                          frame->mdp_fmt->mdp_color);
        param->num_captures = 1;
        frame = ¶m->captures[0];
        frame->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-       frame->mdp_fmt = mdp_try_fmt_mplane(&frame->format, param, 0);
+       frame->mdp_fmt = mdp_try_fmt_mplane(mdp, &frame->format, param, 0);
        frame->ycbcr_prof =
                mdp_map_ycbcr_prof_mplane(&frame->format,
                                          frame->mdp_fmt->mdp_color);