>-----Original Message----- >From: Jacopo Mondi <jacopo.mo...@ideasonboard.com> >Sent: Saturday, August 2, 2025 5:23 PM >To: Mauro Carvalho Chehab <mche...@kernel.org>; Devarsh Thakkar ><devar...@ti.com>; Benoit Parrot <bpar...@ti.com>; Hans Verkuil ><hverk...@kernel.org>; Mike Isely <is...@pobox.com>; Laurent Pinchart ><laurent.pinch...@ideasonboard.com>; Hans de Goede <ha...@kernel.org>; >Parthiban Veerasooran <parthiban.veerasoo...@microchip.com>; Christian >Gromm <christian.gr...@microchip.com>; Greg Kroah-Hartman ><gre...@linuxfoundation.org>; Alex Shi <al...@kernel.org>; Yanteng Si ><si.yant...@linux.dev>; Dongliang Mu <dz...@hust.edu.cn>; Jonathan >Corbet <cor...@lwn.net>; Tomasz Figa <tf...@chromium.org>; Marek >Szyprowski <m.szyprow...@samsung.com>; Andy Walls ><awa...@md.metrocast.net>; Michael Tretter <m.tret...@pengutronix.de>; >Pengutronix Kernel Team <ker...@pengutronix.de>; Bin Liu ><bin....@mediatek.com>; Matthias Brugger <matthias....@gmail.com>; >AngeloGioacchino Del Regno <angelogioacchino.delre...@collabora.com>; >Dmitry Osipenko <dig...@gmail.com>; Thierry Reding ><thierry.red...@gmail.com>; Jonathan Hunter <jonath...@nvidia.com>; >Mirela Rabulea <mirela.rabu...@nxp.com>; Shawn Guo ><shawn...@kernel.org>; Sascha Hauer <s.ha...@pengutronix.de>; Fabio >Estevam <feste...@gmail.com>; Kieran Bingham ><kieran.bingham+rene...@ideasonboard.com>; Michal Simek ><michal.si...@amd.com>; Ming Qian <ming.q...@nxp.com>; Eagle Zhou ><eagle.z...@nxp.com>; Xavier Roumegue (OSS) ><xavier.roume...@oss.nxp.com>; Philipp Zabel <p.za...@pengutronix.de>; >Vikash Garodia <quic_vgaro...@quicinc.com>; Dikshita Agarwal ><quic_diksh...@quicinc.com>; Abhinav Kumar <abhinav.ku...@linux.dev>; >Bryan O'Donoghue <bryan.odonog...@linaro.org>; Sylwester Nawrocki ><sylvester.nawro...@gmail.com>; Jernej Skrabec <jernej.skra...@gmail.com>; >Chen-Yu Tsai <w...@csie.org>; Samuel Holland <sam...@sholland.org>; >Daniel Almeida <daniel.alme...@collabora.com>; Neil Armstrong ><neil.armstr...@linaro.org>; Kevin Hilman <khil...@baylibre.com>; Jerome >Brunet <jbru...@baylibre.com>; Martin Blumenstingl ><martin.blumensti...@googlemail.com>; Nas Chung ><nas.ch...@chipsnmedia.com>; Jackson Lee ><jackson....@chipsnmedia.com>; Minghsiu Tsai ><minghsiu.t...@mediatek.com>; Houlong Wei <houlong....@mediatek.com>; >Andrew-CT Chen <andrew-ct.c...@mediatek.com>; Tiffany Lin ><tiffany....@mediatek.com>; Yunfei Dong <yunfei.d...@mediatek.com>; >Geert Uytterhoeven <geert+rene...@glider.be>; Magnus Damm ><magnus.d...@gmail.com>; Mikhail Ulyanov ><mikhail.ulya...@cogentembedded.com>; Jacob Chen <jacob- >c...@iotwrt.com>; Ezequiel Garcia <ezequ...@vanguardiasur.com.ar>; Heiko >Stuebner <he...@sntech.de>; Detlev Casanova ><detlev.casan...@collabora.com>; Krzysztof Kozlowski <k...@kernel.org>; >Alim Akhtar <alim.akh...@samsung.com>; Sylwester Nawrocki ><s.nawro...@samsung.com>; Łukasz Stelmach <l.stelm...@samsung.com>; >Andrzej Pietrasiewicz <andrzejtp2...@gmail.com>; Jacek Anaszewski ><jacek.anaszew...@gmail.com>; Andrzej Hajda <andrzej.ha...@intel.com>; >Fabien Dessenne <fabien.desse...@foss.st.com>; Hugues Fruchet ><hugues.fruc...@foss.st.com>; Jean-Christophe Trotin <jean- >christophe.tro...@foss.st.com>; Maxime Coquelin ><mcoquelin.st...@gmail.com>; Alexandre Torgue ><alexandre.tor...@foss.st.com>; Nicolas Dufresne ><nicolas.dufre...@collabora.com>; Benjamin Gaignard ><benjamin.gaign...@collabora.com>; Steve Longerbeam ><slongerb...@gmail.com>; Maxime Ripard <mrip...@kernel.org>; Paul >Kocialkowski <pa...@sys-base.io>; Niklas Söderlund ><niklas.soderl...@ragnatech.se>; Robert Foss <rf...@kernel.org>; Todor >Tomov <todor....@gmail.com>; Vladimir Zapolskiy ><vladimir.zapols...@linaro.org>; Corentin Labbe <cla...@baylibre.com>; >Sakari Ailus <sakari.ai...@linux.intel.com>; Bingbu Cao ><bingbu....@intel.com>; Tianshu Qiu <tian.shu....@intel.com>; Stanislaw >Gruszka <stanislaw.grus...@linux.intel.com> >Cc: linux-me...@vger.kernel.org; linux-ker...@vger.kernel.org; linux- >stag...@lists.linux.dev; linux-...@vger.kernel.org; linux-arm- >ker...@lists.infradead.org; linux-media...@lists.infradead.org; linux- >te...@vger.kernel.org; i...@lists.linux.dev; linux-renesas-...@vger.kernel.org; >linux-arm-...@vger.kernel.org; linux-samsung-...@vger.kernel.org; linux- >su...@lists.linux.dev; linux-...@vger.kernel.org; linux- >amlo...@lists.infradead.org; linux-rockc...@lists.infradead.org; linux- >st...@st-md-mailman.stormreply.com; mjpeg-users@lists.sourceforge.net; >Jacopo Mondi <jacopo.mo...@ideasonboard.com> >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.mo...@ideasonboard.com>
Reviewed-by: Ming Qian <ming.q...@oss.nxp.com> >--- > 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 _______________________________________________ Mjpeg-users mailing list Mjpeg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mjpeg-users