]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: exynos-gsc: Access v4l2_fh from file
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Sun, 10 Aug 2025 01:30:34 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:51 +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/samsung/exynos-gsc/gsc-core.h
drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c

index 56856e9f9baf354da75bb423641bb4db49d42d0c..265221abf4dcd87f2ab10758e145fa96ac9d420e 100644 (file)
@@ -85,8 +85,6 @@ enum gsc_yuv_fmt {
        GSC_CRCB,
 };
 
-#define fh_to_ctx(__fh) container_of(__fh, struct gsc_ctx, fh)
-
 #define is_rgb(x) (!!((x) & 0x1))
 #define is_yuv420(x) (!!((x) & 0x2))
 #define is_yuv422(x) (!!((x) & 0x4))
@@ -384,7 +382,7 @@ struct gsc_ctx {
 
 static inline struct gsc_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 gsc_ctx, fh);
 }
 
 void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm);
index 2999fb2610f0f61b63d0331f94883469ff43d751..722e2531e23f1bc01f5e9a9c08dfe4745cc2aa4f 100644 (file)
@@ -297,7 +297,7 @@ static int gsc_m2m_enum_fmt(struct file *file, void *priv,
 static int gsc_m2m_g_fmt_mplane(struct file *file, void *fh,
                             struct v4l2_format *f)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
 
        return gsc_g_fmt_mplane(ctx, f);
 }
@@ -305,7 +305,7 @@ static int gsc_m2m_g_fmt_mplane(struct file *file, void *fh,
 static int gsc_m2m_try_fmt_mplane(struct file *file, void *fh,
                                  struct v4l2_format *f)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
 
        return gsc_try_fmt_mplane(ctx, f);
 }
@@ -313,7 +313,7 @@ static int gsc_m2m_try_fmt_mplane(struct file *file, void *fh,
 static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
                                 struct v4l2_format *f)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        struct vb2_queue *vq;
        struct gsc_frame *frame;
        struct v4l2_pix_format_mplane *pix;
@@ -359,7 +359,7 @@ static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
 static int gsc_m2m_reqbufs(struct file *file, void *fh,
                          struct v4l2_requestbuffers *reqbufs)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        struct gsc_dev *gsc = ctx->gsc_dev;
        u32 max_cnt;
 
@@ -374,35 +374,35 @@ static int gsc_m2m_reqbufs(struct file *file, void *fh,
 static int gsc_m2m_expbuf(struct file *file, void *fh,
                                struct v4l2_exportbuffer *eb)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
 }
 
 static int gsc_m2m_querybuf(struct file *file, void *fh,
                                        struct v4l2_buffer *buf)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
 }
 
 static int gsc_m2m_qbuf(struct file *file, void *fh,
                          struct v4l2_buffer *buf)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
 }
 
 static int gsc_m2m_dqbuf(struct file *file, void *fh,
                           struct v4l2_buffer *buf)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
 }
 
 static int gsc_m2m_streamon(struct file *file, void *fh,
                           enum v4l2_buf_type type)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
 
        /* The source and target color format need to be set */
        if (V4L2_TYPE_IS_OUTPUT(type)) {
@@ -418,7 +418,7 @@ static int gsc_m2m_streamon(struct file *file, void *fh,
 static int gsc_m2m_streamoff(struct file *file, void *fh,
                            enum v4l2_buf_type type)
 {
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
 }
 
@@ -440,8 +440,8 @@ static int is_rectangle_enclosed(struct v4l2_rect *a, struct v4l2_rect *b)
 static int gsc_m2m_g_selection(struct file *file, void *fh,
                        struct v4l2_selection *s)
 {
+       struct gsc_ctx *ctx = file_to_ctx(file);
        struct gsc_frame *frame;
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
 
        if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
            (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
@@ -478,7 +478,7 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,
                                struct v4l2_selection *s)
 {
        struct gsc_frame *frame;
-       struct gsc_ctx *ctx = fh_to_ctx(fh);
+       struct gsc_ctx *ctx = file_to_ctx(file);
        struct gsc_variant *variant = ctx->gsc_dev->variant;
        struct v4l2_selection sel = *s;
        int ret;