Thread (99 messages) 99 messages, 13 authors, 2025-08-24

RE: [EXT] [PATCH 39/65] media: imx-jpeg: Access v4l2_fh from file

From: Ming Qian <ming.qian@nxp.com>
Date: 2025-08-05 01:58:05
Also in: imx, linux-amlogic, linux-arm-msm, linux-media, linux-mediatek, linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-staging, linux-sunxi, linux-tegra, linux-usb, lkml

-----Original Message-----
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Sent: Saturday, August 2, 2025 5:23 PM
To: Mauro Carvalho Chehab <mchehab@kernel.org>; Devarsh Thakkar
[off-list ref]; Benoit Parrot [off-list ref]; Hans Verkuil
[off-list ref]; Mike Isely [off-list ref]; Laurent Pinchart
[off-list ref]; Hans de Goede [off-list ref];
Parthiban Veerasooran [off-list ref]; Christian
Gromm [off-list ref]; Greg Kroah-Hartman
[off-list ref]; Alex Shi [off-list ref]; Yanteng Si
[off-list ref]; Dongliang Mu [off-list ref]; Jonathan
Corbet [off-list ref]; Tomasz Figa [off-list ref]; Marek
Szyprowski [off-list ref]; Andy Walls
[off-list ref]; Michael Tretter [off-list ref];
Pengutronix Kernel Team [off-list ref]; Bin Liu
[off-list ref]; Matthias Brugger [off-list ref];
AngeloGioacchino Del Regno [off-list ref];
Dmitry Osipenko [off-list ref]; Thierry Reding
[off-list ref]; Jonathan Hunter [off-list ref];
Mirela Rabulea [off-list ref]; Shawn Guo
[off-list ref]; Sascha Hauer [off-list ref]; Fabio
Estevam [off-list ref]; Kieran Bingham
[off-list ref]; Michal Simek
[off-list ref]; Ming Qian [off-list ref]; Eagle Zhou
[off-list ref]; Xavier Roumegue (OSS)
[off-list ref]; Philipp Zabel [off-list ref];
Vikash Garodia [off-list ref]; Dikshita Agarwal
[off-list ref]; Abhinav Kumar [off-list ref];
Bryan O'Donoghue [off-list ref]; Sylwester Nawrocki
[off-list ref]; Jernej Skrabec [off-list ref];
Chen-Yu Tsai [off-list ref]; Samuel Holland [off-list ref];
Daniel Almeida [off-list ref]; Neil Armstrong
[off-list ref]; Kevin Hilman [off-list ref]; Jerome
Brunet [off-list ref]; Martin Blumenstingl
[off-list ref]; Nas Chung
[off-list ref]; Jackson Lee
[off-list ref]; Minghsiu Tsai
[off-list ref]; Houlong Wei [off-list ref];
Andrew-CT Chen [off-list ref]; Tiffany Lin
[off-list ref]; Yunfei Dong [off-list ref];
Geert Uytterhoeven [off-list ref]; Magnus Damm
[off-list ref]; Mikhail Ulyanov
[off-list ref]; Jacob Chen <jacob-
chen@iotwrt.com>; Ezequiel Garcia [off-list ref]; Heiko
Stuebner [off-list ref]; Detlev Casanova
[off-list ref]; Krzysztof Kozlowski [off-list ref];
Alim Akhtar [off-list ref]; Sylwester Nawrocki
[off-list ref]; Łukasz Stelmach [off-list ref];
Andrzej Pietrasiewicz [off-list ref]; Jacek Anaszewski
[off-list ref]; Andrzej Hajda [off-list ref];
Fabien Dessenne [off-list ref]; Hugues Fruchet
[off-list ref]; Jean-Christophe Trotin <jean-
christophe.trotin@foss.st.com>; Maxime Coquelin
[off-list ref]; Alexandre Torgue
[off-list ref]; Nicolas Dufresne
[off-list ref]; Benjamin Gaignard
[off-list ref]; Steve Longerbeam
[off-list ref]; Maxime Ripard [off-list ref]; Paul
Kocialkowski [off-list ref]; Niklas Söderlund
[off-list ref]; Robert Foss [off-list ref]; Todor
Tomov [off-list ref]; Vladimir Zapolskiy
[off-list ref]; Corentin Labbe [off-list ref];
Sakari Ailus [off-list ref]; Bingbu Cao
[off-list ref]; Tianshu Qiu [off-list ref]; Stanislaw
Gruszka [off-list ref]
Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
staging@lists.linux.dev; linux-doc@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; linux-
tegra@vger.kernel.org; imx@lists.linux.dev; linux-renesas-soc@vger.kernel.org;
linux-arm-msm@vger.kernel.org; linux-samsung-soc@vger.kernel.org; linux-
sunxi@lists.linux.dev; linux-usb@vger.kernel.org; linux-
amlogic@lists.infradead.org; linux-rockchip@lists.infradead.org; linux-
stm32@st-md-mailman.stormreply.com; mjpeg-users@lists.sourceforge.net;
Jacopo Mondi [off-list ref]
Subject: [EXT] [PATCH 39/65] media: imx-jpeg: Access v4l2_fh from file

Caution: This is an external email. Please take care when clicking links or
opening attachments. When in doubt, report the message using the 'Report
this email' button


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.

While at it, remove the now unused mxc_jpeg_fh_to_ctx() macro.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Ming Qian <redacted>
quoted hunk ↗ jump to hunk
---
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 33 +++++++++++--------------
-
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index
fa7d74d8c1aabd3bf74482e214165d8c1a7e89da..df3ccdf767baf0bf6687808e2c
017063181a7220 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -644,11 +644,6 @@ static void print_mxc_buf(struct mxc_jpeg_dev *jpeg,
struct vb2_buffer *buf,
       }
}

-static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh) -{
-       return container_of(fh, struct mxc_jpeg_ctx, fh);
-}
-
static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp)  {
       return container_of(file_to_v4l2_fh(filp), struct mxc_jpeg_ctx, fh); @@ -
1610,7 +1605,7 @@ static int mxc_jpeg_decoder_cmd(struct file *file, void
*priv,
                               struct v4l2_decoder_cmd *cmd)  {
       struct v4l2_fh *fh = file_to_v4l2_fh(file);
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       unsigned long flags;
       int ret;
@@ -1643,7 +1638,7 @@ static int mxc_jpeg_encoder_cmd(struct file *file,
void *priv,
                               struct v4l2_encoder_cmd *cmd)  {
       struct v4l2_fh *fh = file_to_v4l2_fh(file);
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       unsigned long flags;
       int ret;
@@ -2260,7 +2255,7 @@ static int mxc_jpeg_querycap(struct file *file, void
*priv,  static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
                                    struct v4l2_fmtdesc *f)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_q_data *q_data = mxc_jpeg_get_q_data(ctx, f->type);

       if (ctx->mxc_jpeg->mode == MXC_JPEG_ENCODE) { @@ -2300,7 +2295,7
@@ static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,  static
int mxc_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
                                    struct v4l2_fmtdesc *f)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       u32 type = ctx->mxc_jpeg->mode == MXC_JPEG_DECODE ?
MXC_JPEG_FMT_TYPE_ENC :
                                                            MXC_JPEG_FMT_TYPE_RAW;
       int ret;
@@ -2441,7 +2436,7 @@ static int mxc_jpeg_try_fmt(struct v4l2_format *f,
static int mxc_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
                                   struct v4l2_format *f)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
       struct device *dev = jpeg->dev;
       struct mxc_jpeg_q_data tmp_q;
@@ -2460,7 +2455,7 @@ static int mxc_jpeg_try_fmt_vid_cap(struct file *file,
void *priv,  static int mxc_jpeg_try_fmt_vid_out(struct file *file, void *priv,
                                   struct v4l2_format *f)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
       struct device *dev = jpeg->dev;
       struct mxc_jpeg_q_data tmp_q;
@@ -2512,20 +2507,20 @@ static int mxc_jpeg_s_fmt(struct mxc_jpeg_ctx
*ctx,  static int mxc_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
                                 struct v4l2_format *f)  {
-       return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
+       return mxc_jpeg_s_fmt(mxc_jpeg_file_to_ctx(file), f);
}

static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv,
                                 struct v4l2_format *f)  {
       int ret;
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct vb2_queue *dst_vq;
       struct mxc_jpeg_q_data *q_data_cap;
       enum v4l2_buf_type cap_type =
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
       struct v4l2_format fc;

-       ret = mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
+       ret = mxc_jpeg_s_fmt(ctx, f);
       if (ret)
               return ret;
@@ -2554,7 +2549,7 @@ static int mxc_jpeg_s_fmt_vid_out(struct file *file,
void *priv,  static int mxc_jpeg_g_fmt_vid(struct file *file, void *priv,
                             struct v4l2_format *f)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
       struct device *dev = jpeg->dev;
       struct v4l2_pix_format_mplane   *pix_mp = &f->fmt.pix_mp;
@@ -2592,7 +2587,7 @@ static int mxc_jpeg_g_fmt_vid(struct file *file, void
*priv,

static int mxc_jpeg_dec_g_selection(struct file *file, void *fh, struct
v4l2_selection *s)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_q_data *q_data_cap;

       if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && s->type !=
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
@@ -2621,7 +2616,7 @@ static int mxc_jpeg_dec_g_selection(struct file *file,
void *fh, struct v4l2_sel

static int mxc_jpeg_enc_g_selection(struct file *file, void *fh, struct
v4l2_selection *s)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_q_data *q_data_out;

       if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && s->type !=
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -2649,7 +2644,7 @@ static int mxc_jpeg_enc_g_selection(struct file *file,
void *fh, struct v4l2_sel

static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selection
*s)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);

       if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE)
               return mxc_jpeg_dec_g_selection(file, fh, s); @@ -2659,7 +2654,7 @@
static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selecti

static int mxc_jpeg_s_selection(struct file *file, void *fh, struct v4l2_selection
*s)  {
-       struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+       struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
       struct mxc_jpeg_q_data *q_data_out;

       if (ctx->mxc_jpeg->mode != MXC_JPEG_ENCODE)

--
2.49.0
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help