[PATCH v3 47/76] media: imx-isi: Access v4l2_fh from file
Frank Li
Frank.li at nxp.com
Mon Aug 11 08:05:09 PDT 2025
On Sun, Aug 10, 2025 at 04:30:29AM +0300, Laurent Pinchart wrote:
> From: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
>
> 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 at ideasonboard.com>
> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> ---
Reviewed-by: Frank Li <Frank.Li at nxp.com>
> Changes since v1:
>
> - Update file-to-ctx macro due to removal of fh-to-ctx macro
> ---
> .../media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> index 31298307c672..5501214cc6c0 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> @@ -74,14 +74,9 @@ to_isi_m2m_buffer(struct vb2_v4l2_buffer *buf)
> return container_of(buf, struct mxc_isi_m2m_buffer, buf.vb);
> }
>
> -static inline struct mxc_isi_m2m_ctx *to_isi_m2m_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct mxc_isi_m2m_ctx, fh);
> -}
> -
> static inline struct mxc_isi_m2m_ctx *file_to_isi_m2m_ctx(struct file *filp)
> {
> - return to_isi_m2m_ctx(file_to_v4l2_fh(filp));
> + return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
> }
>
> static inline struct mxc_isi_m2m_ctx_queue_data *
> @@ -432,7 +427,7 @@ static int mxc_isi_m2m_try_fmt_vid(struct file *file, void *fh,
> const enum mxc_isi_video_type type =
> f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?
> MXC_ISI_VIDEO_M2M_OUT : MXC_ISI_VIDEO_M2M_CAP;
> - struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
> + struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
>
> __mxc_isi_m2m_try_fmt_vid(ctx, &f->fmt.pix_mp, type);
>
> @@ -442,7 +437,7 @@ static int mxc_isi_m2m_try_fmt_vid(struct file *file, void *fh,
> static int mxc_isi_m2m_g_fmt_vid(struct file *file, void *fh,
> struct v4l2_format *f)
> {
> - struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
> + struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
> const struct mxc_isi_m2m_ctx_queue_data *qdata =
> mxc_isi_m2m_ctx_qdata(ctx, f->type);
>
> @@ -457,7 +452,7 @@ static int mxc_isi_m2m_s_fmt_vid(struct file *file, void *fh,
> const enum mxc_isi_video_type type =
> f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?
> MXC_ISI_VIDEO_M2M_OUT : MXC_ISI_VIDEO_M2M_CAP;
> - struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
> + struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
> struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
> const struct mxc_isi_format_info *info;
> struct vb2_queue *vq;
> @@ -489,7 +484,7 @@ static int mxc_isi_m2m_s_fmt_vid(struct file *file, void *fh,
> static int mxc_isi_m2m_streamon(struct file *file, void *fh,
> enum v4l2_buf_type type)
> {
> - struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
> + struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
> struct mxc_isi_m2m_ctx_queue_data *q = mxc_isi_m2m_ctx_qdata(ctx, type);
> const struct v4l2_pix_format_mplane *out_pix = &ctx->queues.out.format;
> const struct v4l2_pix_format_mplane *cap_pix = &ctx->queues.cap.format;
> @@ -577,7 +572,7 @@ static int mxc_isi_m2m_streamon(struct file *file, void *fh,
> static int mxc_isi_m2m_streamoff(struct file *file, void *fh,
> enum v4l2_buf_type type)
> {
> - struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
> + struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
> struct mxc_isi_m2m_ctx_queue_data *q = mxc_isi_m2m_ctx_qdata(ctx, type);
> struct mxc_isi_m2m *m2m = ctx->m2m;
>
> --
> Regards,
>
> Laurent Pinchart
>
More information about the linux-arm-kernel
mailing list