From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.167.242.64 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796046247; b=01Bf28SzScaxG09s1jVRRKeuMEw4VxHoPcNyqxV5mdJdQ97z+Lm1pX9uOKRwloDvSFjy ztIvZQ+lM24pXx1BCymuzamIzQ1/8SJ5Hd0ZY+xBZteHPu0swe3vn12EDJnTncJeaDmk8 /bMHGM8LEW2mPMMbzGSLx/zar3EnaNfy3wKpk/dOQ9HR6yCYugDhER8W4hIUu+ZrAiiEG P+CEGiO2j8MZr1V//l/i2uvi7HB4XFvR29z6doLQgvSYMMi/VEP7PeigPbElU87DGJrZz kUlX6j7yJevLGWle54TmESSqkV1oHSZbGT16iAAlsJZQ5J70cmNlBI7zi0aeYHF+4Dw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046247; h=DMARC-Filter:Received:DKIM-Signature:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=0yFjaQG0ljcTbJvj44/XzUNTZm1ZinE3nuAy7aSlKdo=; b=ObJYLCMffvn0/rG6DJoRxawhJyj2p+HgZTokQXxXxoIES1amNtw96igsJJ6F8mU70LMl NrMhTtwTDpRK3TEjXCpZO++mCDLt/d+zq3S9UjuiseajdxftkxS6NnU0WRdbfDTr4VpqA aEd+qltZYIrSbAiPpbx6u7gAaRSZIb/t+B7SBCwbmQ4ml0sM1IxDGol8/kIPXJ0QiyM86 WK1neP35gY0hmeku3cdu5g3b7tQfuTFlbmx2msGswytNlan1jKrgRO0vBYXqHhtmFmEvf fLJbK7F+QO8x92M00mLti0BwyxvLOvtdEa93zlo6084KPS2Mz3aqAPAiae7lEb0R2Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=WK3csnGx; arc=none smtp.remote-ip=213.167.242.64 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F692606A325; Mon, 30 Nov 2026 13:44:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F692606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=WK3csnGx Received: from killaraus.ideasonboard.com (p773008-ipoe.ipoe.ocn.ne.jp [153.242.130.7]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 438474B0; Mon, 30 Nov 2026 14:41:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796046088; bh=kra3RosJp6zdjR4MBuHILu0aRfCBBW1SY7iXj0PFbzA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WK3csnGxfC4hNTom0uqt5y3Rmkm7j+8gUbDnJbpoXZYDgFtEg8Qa71Yea90lIx2bN +3oM96Q12fa3lyW2Sxcbpz596+MIi/+23q9POB1astDaRi7b+rCUa1o4Pix9uHZUAR mHLqVH18boI4aBWAsP7qsVlgMpwe/n29WumVCGRI= Date: Mon, 30 Nov 2026 22:43:59 +0900 From: Laurent Pinchart To: Guoniu Zhou Cc: Frank Li , Mauro Carvalho Chehab , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Loic Poulain , linux-media@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v5 05/11] media: imx8-isi: Apply RAW output format workaround at runtime Message-ID: <20261130134359.GE24781@killaraus.ideasonboard.com> References: <20261116-isi_imx952-v5-0-46de1d24efd4@oss.nxp.com> <20261116-isi_imx952-v5-5-46de1d24efd4@oss.nxp.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261116-isi_imx952-v5-5-46de1d24efd4@oss.nxp.com> Hi Zhou, On Mon, Nov 16, 2026 at 11:28:23AM +0800, Guoniu Zhou wrote: > Refactor the RAW format handling by storing the actual hardware output > format (RAW10/RAW12) in the format table instead of the workaround value It's not a workaround, it's just the correct way for all platforms supported so far to produce the RAW10/12/14 formats that V4L2 expect. > RAW16. The RAW16 workaround is now applied at runtime in > mxc_isi_channel_set_output_format() via the new isi_out_raw_shifted() > helper in imx8-isi-regs.h. > > This makes the format table accurately reflect the real hardware > capability. The commit message should explain why. > Reviewed-by: Frank Li > Signed-off-by: Guoniu Zhou > --- > Changes in v4: > - New patch > --- > drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c | 7 ++++- > .../media/platform/nxp/imx8-isi/imx8-isi-regs.h | 13 ++++++++++ > .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 30 ++++++++-------------- > 3 files changed, 30 insertions(+), 20 deletions(-) > > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c > index 6aa760ce3605..cc52a90c2477 100644 > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c > @@ -411,13 +411,18 @@ void mxc_isi_channel_set_output_format(struct mxc_isi_pipe *pipe, > struct v4l2_pix_format_mplane *format) > { > u32 val; > + u32 fmt; > > /* set outbuf format */ > dev_dbg(pipe->isi->dev, "output format %p4cc", &format->pixelformat); > > + fmt = isi_out_raw_shifted(info->isi_out_format) > + ? CHNL_IMG_CTRL_FORMAT_RAW16 > + : info->isi_out_format; > + > val = mxc_isi_read(pipe, CHNL_IMG_CTRL); > val &= ~CHNL_IMG_CTRL_FORMAT_MASK; > - val |= CHNL_IMG_CTRL_FORMAT(info->isi_out_format); > + val |= CHNL_IMG_CTRL_FORMAT(fmt); > mxc_isi_write(pipe, CHNL_IMG_CTRL, val); > > /* line pitch */ > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h > index c704be882705..0f3ada30e71e 100644 > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h > @@ -421,4 +421,17 @@ > /* Channel Input Buffer Extended Address Bits */ > #define CHNL_IN_BUF_XTND_ADDR 0x00b8 > > +/* > + * The ISI shifts the 10-bit and 12-bit RAW formats left by 6 and 4 bits when > + * using CHNL_IMG_CTRL_FORMAT_RAW10 or CHNL_IMG_CTRL_FORMAT_RAW12 respectively, > + * to align the bits to the left and pad with zeros in the LSBs. The > + * corresponding V4L2 formats are however right-aligned, so > + * CHNL_IMG_CTRL_FORMAT_RAW16 must be used to avoid the left shift. > + */ > +static inline bool isi_out_raw_shifted(u32 format) Reading this function, and other similar helpers in subsequent patches, I think the APIs need to be improved. This series makes the code complicated to follow, with functions whose names are confusing. It gives me a feeling of LLM-generated code, that is not completely wrong, but also not quite right. > +{ > + return format == CHNL_IMG_CTRL_FORMAT_RAW10 || > + format == CHNL_IMG_CTRL_FORMAT_RAW12; > +} > + > #endif /* __IMX8_ISI_REGS_H__ */ > diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c > index af91bd65b2c1..978a637f539d 100644 > --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c > +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c > @@ -218,15 +218,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .depth = { 32 }, > .encoding = MXC_ISI_ENC_RGB, > }, > - /* > - * RAW formats > - * > - * The ISI shifts the 10-bit and 12-bit formats left by 6 and 4 bits > - * when using CHNL_IMG_CTRL_FORMAT_RAW10 or MXC_ISI_OUT_FMT_RAW12 > - * respectively, to align the bits to the left and pad with zeros in > - * the LSBs. The corresponding V4L2 formats are however right-aligned, > - * we have to use CHNL_IMG_CTRL_FORMAT_RAW16 to avoid the left shift. > - */ > + /* RAW formats */ > { > .mbus_code = MEDIA_BUS_FMT_Y8_1X8, > .fourcc = V4L2_PIX_FMT_GREY, > @@ -240,7 +232,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_Y10_1X10, > .fourcc = V4L2_PIX_FMT_Y10, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW10, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -249,7 +241,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_Y12_1X12, > .fourcc = V4L2_PIX_FMT_Y12, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW12, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -312,7 +304,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, > .fourcc = V4L2_PIX_FMT_SBGGR10, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW10, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -321,7 +313,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, > .fourcc = V4L2_PIX_FMT_SGBRG10, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW10, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -330,7 +322,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, > .fourcc = V4L2_PIX_FMT_SGRBG10, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW10, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -339,7 +331,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, > .fourcc = V4L2_PIX_FMT_SRGGB10, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW10, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -348,7 +340,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, > .fourcc = V4L2_PIX_FMT_SBGGR12, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW12, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -357,7 +349,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, > .fourcc = V4L2_PIX_FMT_SGBRG12, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW12, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -366,7 +358,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, > .fourcc = V4L2_PIX_FMT_SGRBG12, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW12, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, > @@ -375,7 +367,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { > .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, > .fourcc = V4L2_PIX_FMT_SRGGB12, > .type = MXC_ISI_VIDEO_CAP, > - .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW16, > + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RAW12, > .mem_planes = 1, > .color_planes = 1, > .depth = { 16 }, -- Regards, Laurent Pinchart