]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: mtk_mdp_m2m: Access v4l2_fh from file
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Sun, 10 Aug 2025 01:30:24 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:49 +0000 (08:33 +0200)
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().

Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c

index 7e89a8443707d82ba7f90c14c3ea41cbe039aa23..03c07948dfdd07c6395c391ccad1788b08b1a867 100644 (file)
@@ -348,14 +348,9 @@ static int mtk_mdp_try_crop(struct mtk_mdp_ctx *ctx, u32 type,
        return 0;
 }
 
-static inline struct mtk_mdp_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
-       return container_of(fh, struct mtk_mdp_ctx, fh);
-}
-
 static inline struct mtk_mdp_ctx *file_to_ctx(struct file *filp)
 {
-       return fh_to_ctx(file_to_v4l2_fh(filp));
+       return container_of(file_to_v4l2_fh(filp), struct mtk_mdp_ctx, fh);
 }
 
 static inline struct mtk_mdp_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
@@ -594,7 +589,7 @@ static const struct vb2_ops mtk_mdp_m2m_qops = {
 static int mtk_mdp_m2m_querycap(struct file *file, void *fh,
                                struct v4l2_capability *cap)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        struct mtk_mdp_dev *mdp = ctx->mdp_dev;
 
        strscpy(cap->driver, MTK_MDP_MODULE_NAME, sizeof(cap->driver));
@@ -632,7 +627,7 @@ static int mtk_mdp_m2m_enum_fmt_vid_out(struct file *file, void *priv,
 static int mtk_mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        struct mtk_mdp_frame *frame;
        struct v4l2_pix_format_mplane *pix_mp;
        int i;
@@ -671,7 +666,7 @@ static int mtk_mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
 static int mtk_mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
                                      struct v4l2_format *f)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
 
        if (!mtk_mdp_try_fmt_mplane(ctx, f))
                return -EINVAL;
@@ -681,7 +676,7 @@ static int mtk_mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
 static int mtk_mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        struct vb2_queue *vq;
        struct mtk_mdp_frame *frame;
        struct v4l2_pix_format_mplane *pix_mp;
@@ -727,7 +722,7 @@ static int mtk_mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
 static int mtk_mdp_m2m_reqbufs(struct file *file, void *fh,
                               struct v4l2_requestbuffers *reqbufs)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
 
        return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
 }
@@ -735,7 +730,7 @@ static int mtk_mdp_m2m_reqbufs(struct file *file, void *fh,
 static int mtk_mdp_m2m_streamon(struct file *file, void *fh,
                                enum v4l2_buf_type type)
 {
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        int ret;
 
        if (!mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_VPU_INIT)) {
@@ -773,8 +768,8 @@ static inline bool mtk_mdp_is_target_crop(u32 target)
 static int mtk_mdp_m2m_g_selection(struct file *file, void *fh,
                                       struct v4l2_selection *s)
 {
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        struct mtk_mdp_frame *frame;
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
        bool valid = false;
 
        if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -840,8 +835,8 @@ static int mtk_mdp_check_scaler_ratio(struct mtk_mdp_variant *var, int src_w,
 static int mtk_mdp_m2m_s_selection(struct file *file, void *fh,
                                   struct v4l2_selection *s)
 {
+       struct mtk_mdp_ctx *ctx = file_to_ctx(file);
        struct mtk_mdp_frame *frame;
-       struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
        struct v4l2_rect new_r;
        struct mtk_mdp_variant *variant = ctx->mdp_dev->variant;
        int ret;