imx8-isi: Format support enhancements
Subsystems (3)
v4 cover imx8-isi: Format support enhancements
This is a follow-up series to the imx8-isi bug fixes and format support patches [1]. Patches 1/6, 2/6, and 5/6 from v2 have been merged into the maintainer's branch (pinchart/for-next/media/nxp). This series contains the remaining 3 patches rebased on top of the merged changes.
Patch 1 implements per-stream reference counting in the crossbar to properly enable multiple streams from different virtual channels on the same input pad.
Patch 2 adds support for 16-bit raw Bayer formats (SBGGR16, SGBRG16, SGRBG16, SRGGB16) and Y16 (16-bit monochrome).
Patch 3 extends RGB format support by adding BGRA32, RGBA32, BGRX32, RGBX32, and ARGB2101010 formats.
[1] https://lore.kernel.org/r/[email protected]
---
Changes in v4:
- [1/3] Make enable/disable symmetric by checking stream_in_use
- [1/3] Add mxc_isi_crossbar_stream_in_use() helper for both paths
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Rebased on maintainer's branch which already includes v2 patches 1/6, 2/6, and 5/6 (stream ID validation fixes and color map correction)
- Series reduced from 6 patches to 3 patches (remaining unmerged patches)
- Patch numbering updated: v2 3/6 -> v3 1/3, v2 4/6 -> v3 2/3, v2 6/6 -> v3 3/3
- [1/3] Change from "Fix" to "Implement" as multi-stream support is for newer SoCs not present when the driver was merged (Laurent)
- [1/3] Remove Fixes and Cc: stable tags (Laurent)
- [1/3] Store input/input_stream in mxc_isi_pipe instead of using per-stream counters array, avoiding arbitrary 64-entry limit (Laurent)
- [1/3] Use UINT_MAX to mark pipe as inactive to distinguish from valid pad 0
- [2/3] Remove "high-end" from description as RAW16 is common now (Laurent)
- [2/3] Add Y16 (16-bit monochrome) format support (Laurent)
- [2/3] Add Reviewed-by tag from Laurent
- [3/3] Drop M2M_OUT for ABGR32/BGRA32/RGBA32 as ISI ignores alpha bits (Laurent)
- [3/3] Remove Android requirements from commit message as alpha formats cannot be used as M2M input (Laurent)
- [3/3] Add Tested-by tag from Laurent Pinchart
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- [1/6] Split v1 patch 1/5 into two patches: this patch fixes the core for_each_active_route() bug, next patch adds additional stream validation (Frank Li)
- [2/6] New patch split from v1 1/5: adds stream ID validation on top of for_each_active_route() fix (Frank Li)
- [2/6] Remove incorrect sink_stream validation
- [3/6] Use fixed-size array for enabled_count instead of dynamic allocation
- [3/6] Use BIT_ULL() macro for u64 bitmask operations
- [3/6] Use MXC_ISI_MAX_STREAMS (64) as loop boundary instead of num_sources
- [3/6] Remove mxc_isi_stream_counters_alloc/free functions
- [4/6] Add Reviewed-by tag from Frank Li
- [5/6] Reword commit description for clarity (Frank Li)
- [6/6] Add Reviewed-by tag from Frank Li
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Guoniu Zhou (2):
media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
media: nxp: imx8-isi: Add additional 32-bit RGB format support
Laurentiu Palcu (1):
media: nxp: imx8-isi: Add 16-bit raw Bayer format support
.../media/platform/nxp/imx8-isi/imx8-isi-core.h | 5 +- .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 84 ++++++++++++++----- .../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 31 +++++++ .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 96 ++++++++++++++++++++++ 4 files changed, 193 insertions(+), 23 deletions(-)
---
base-commit: 4d32fbba9d23f50d157ed4a37c9e8fbce61c904a
change-id: 20260626-isi-00f05b044ac9
Best regards,
Signature · 1 line
Guoniu Zhou <[email protected]>
PATCH v4 1/3 media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
The ISI crossbar needs to properly enable multiple streams from different virtual channels on the same input pad. Currently only the first stream gets enabled in hardware, subsequent streams are silently ignored.
The driver uses a single enable_count per input to track the input state. When enable_count is non-zero, the code assumes the input is already active and skips calling v4l2_subdev_enable_streams() for additional streams:
Call 1: enable_streams(stream 0)
-> enable_count == 0, enable gasket and stream 0 in hardware
-> enable_count = 1 Call 2: enable_streams(stream 1)
-> enable_count == 1, skip hardware enable
-> enable_count = 2
-> stream 1 never gets enabledSimilarly on disable, when enable_count reaches zero, ALL streams are disabled regardless of which streams are actually still active.
Implement per-stream state tracking by storing the input index and stream mask in the mxc_isi_pipe structure. On enable, record which input and stream the pipe is receiving. On disable, clear the pipe's record and check if any other pipe is still using the same input stream before actually disabling it.
---
Changes in v4:
- Make enable/disable symmetric by checking stream_in_use
- Add mxc_isi_crossbar_stream_in_use() helper for both paths
Changes in v3:
- Change from "Fix" to "Implement" as multi-stream support is for newer SoCs not present when the driver was merged (Laurent)
- Remove Fixes and Cc: stable tags (Laurent)
- Store input/input_stream in mxc_isi_pipe instead of using per-stream counters array, avoiding arbitrary 64-entry limit (Laurent)
- Use UINT_MAX to mark pipe as inactive to distinguish from valid pad 0
Changes in v2:
- Use fixed-size array for enabled_count instead of dynamic allocation
- Use BIT_ULL() macro for u64 bitmask operations
- Use MXC_ISI_MAX_STREAMS (64) as loop boundary instead of num_sources
- Remove mxc_isi_stream_counters_alloc/free functions
--- .../media/platform/nxp/imx8-isi/imx8-isi-core.h | 5 +- .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 84 ++++++++++++++++------ .../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 1 + 3 files changed, 67 insertions(+), 23 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +4 -1
@@ -186,7 +186,7 @@ struct mxc_isi_dma_buffer { };struct mxc_isi_input { -unsigned int enable_count; +u64 enabled_streams; };struct mxc_isi_crossbar {
@@ -259,6 +259,9 @@ struct mxc_isi_pipe {u8 acquired_res;u8 chained_res;bool chained; + +unsigned int input; +u64 input_stream; };struct mxc_isi_m2m {
drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +62 -22
126 lines not on this page · raw message
drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c +1 -0
@@ -816,6 +816,7 @@ int mxc_isi_pipe_init(struct mxc_isi_dev *isi, unsigned int id) pipe->acquired_res =0 ; pipe->chained_res =0 ; pipe->chained = false; + pipe->input =UINT_MAX ; sd = &pipe->sd;v4l2_subdev_init (sd, &mxc_isi_pipe_subdev_ops);
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing NULL pointer dereference in mxc_isi_crossbar_xlate_streams when no remote pad is linked.
- [Medium] Using BIT() macro on 64-bit stream masks causes undefined behavior on 32-bit architectures. --
--- Patch [1]: [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams --- commit f312b9be3591414051fb03d9e8651437e1f95ef2
Author: Guoniu Zhou <[email protected]>
media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
The ISI crossbar needs to properly enable multiple streams from different virtual channels on the same input pad. This commit implements per-stream state tracking by storing the input index and stream mask in the mxc_isi_pipe structure to properly manage hardware state on enable and disable operations.
Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +0
-0@@ -318,11 +318,26 @@ static int mxc_isi_crossbar_set_routing(struct v4l2_subdev *sd,
[ ... ]
drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c static int mxc_isi_crossbar_set_routing(struct v4l2_subdev *sd, · line 355
Quoted 9 lines
static int mxc_isi_crossbar_enable_streams(struct
v4l2_subdev*sd,drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +1
-0struct v4l2_subdev_state *state, u32 pad, u64 streams_mask) { struct mxc_isi_crossbar *xbar = to_isi_crossbar(sd); +struct mxc_isi_pipe *pipe = &xbar->isi->pipes[pad - xbar->num_sinks];struct v4l2_subdev *remote_sd;struct mxc_isi_input *input;u64 sink_streams;
[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential NULL pointer dereference in mxc_isi_crossbar_xlate_streams() which is called from here.
If userspace configures routing that points to a disconnected sink pad and then attempts to enable streams, media_pad_remote_pad_first() can return NULL:
mxc_isi_crossbar_xlate_streams() {
...
pad = media_pad_remote_pad_first(&xbar->pads[sink_pad]);
sd = media_entity_to_v4l2_subdev(pad->entity);
if (!sd) {
...
}Does the immediate dereference of pad->entity crash the kernel before the subsequent if (!sd) validation can handle the missing entity?
[Severity: Medium]
This is also a pre-existing issue in mxc_isi_crossbar_xlate_streams(), but I noticed that BIT() is used on 64-bit stream masks:
mxc_isi_crossbar_xlate_streams() {
...
if (route->source_pad != source_pad ||
!(source_streams & BIT(route->source_stream)))
continue;
sink_streams |= BIT(route->sink_stream);
...
}Since source_streams and sink_streams are u64, and BIT() evaluates to a 32-bit unsigned long on 32-bit architectures, can this cause an out-of-bounds shift or incorrect stream mask calculations if userspace uses stream IDs of 32 or greater?
Should BIT_ULL() be used instead?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
In reply to Guoniu ZhouQuoted 20 lines · Guoniu Zhou
The ISI crossbar needs to properly enable multiple streams from different virtual channels on the same input pad. Currently only the first stream gets enabled in hardware, subsequent streams are silently ignored.
The driver uses a single
enable_countper input to track the input state. Whenenable_countis non-zero, the code assumes the input is already active and skips callingv4l2_subdev_enable_streams()for additional streams:Call 1:
enable_streams(stream 0)-> enable_count == 0, enable gasket and stream 0 in hardware -> enable_count = 1Call 2:
enable_streams(stream 1)-> enable_count == 1, skip hardware enable -> enable_count = 2 -> stream 1 never gets enabledSimilarly on disable, when
enable_countreaches zero, ALL streams are disabled regardless of which streams are actually still active.
Quoted 8 lines
Implement per-stream state tracking by storing the input index and stream mask in the
mxc_isi_pipestructure. On enable, record which input and stream the pipe is receiving. On disable, clear the pipe's record and check if any other pipe is still using the same input stream before actually disabling it.Signed-off-by Guoniu Zhou <[email protected]>---
Quoted 197 lines
Changes in v4:
- Make enable/disable symmetric by checkingstream_in_use
- Addmxc_isi_crossbar_stream_in_use()helper for both pathsChanges in v3:
- Change from "Fix" to "Implement" as multi-stream support is for newer SoCs not present when the driver was merged (Laurent)
- Remove Fixes and Cc: stable tags (Laurent)
- Store input/input_stream inmxc_isi_pipeinstead of using per-stream counters array, avoiding arbitrary 64-entry limit (Laurent)
- UseUINT_MAXto mark pipe as inactive to distinguish from valid pad 0Changes in v2:
- Use fixed-size array forenabled_countinstead of dynamic allocation
- UseBIT_ULL()macro for u64 bitmask operations
- UseMXC_ISI_MAX_STREAMS(64) as loop boundary instead ofnum_sources
- Remove mxc_isi_stream_counters_alloc/free functions--- .../media/platform/nxp/imx8-isi/imx8-isi-core.h | 5 +- .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 84 ++++++++++++++++------ .../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 1 + 3 files changed, 67 insertions(+), 23 deletions(-)drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +4
-1@@ -186,7 +186,7 @@ struct mxc_isi_dma_buffer { };struct mxc_isi_input { -unsigned int enable_count; +u64 enabled_streams; };struct mxc_isi_crossbar {@@ -259,6 +259,9 @@ struct mxc_isi_pipe {u8 acquired_res;u8 chained_res;bool chained; + +unsigned int input; +u64 input_stream; };struct mxc_isi_m2m {drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +62
-22@@ -330,11 +330,26 @@ static int mxc_isi_crossbar_set_routing(struct v4l2_subdev *sd,return __mxc_isi_crossbar_set_routing (sd, state, routing); } +static bool mxc_isi_crossbar_stream_in_use (struct mxc_isi_crossbar *xbar, +unsigned int sink_pad,u64 sink_streams) +{ +for (unsigned int i =0 ; i < xbar->isi->pdata->num_channels; ++i) { +struct mxc_isi_pipe *pipe = &xbar->isi->pipes[i]; + +if (pipe->input == sink_pad && + pipe->input_stream == sink_streams) +return true; + } + +return false; +} +static int mxc_isi_crossbar_enable_streams (struct v4l2_subdev *sd,struct v4l2_subdev_state *state,u32 pad,u64 streams_mask) {struct mxc_isi_crossbar *xbar =to_isi_crossbar (sd); +struct mxc_isi_pipe *pipe = &xbar->isi->pipes[pad - xbar->num_sinks];struct v4l2_subdev *remote_sd;struct mxc_isi_input *input;u64 sink_streams;@@ -351,29 +366,44 @@ static int mxc_isi_crossbar_enable_streams(struct v4l2_subdev *sd, input = &xbar->inputs[sink_pad];/* -* TODO: Track per-stream enable counts to support multiplexed -* streams. +* Check if any other pipe already receives the same input stream. +* If so, just record this pipe's usage and return. */ -if (!input->enable_count) { +if (mxc_isi_crossbar_stream_in_use (xbar, sink_pad, sink_streams)) { + pipe->input = sink_pad; + pipe->input_stream = sink_streams; +return 0 ; + } + +/* Enable the gasket when the first stream is enabled for this input. */ +if (!input->enabled_streams) { ret =mxc_isi_crossbar_gasket_enable (xbar, state, remote_sd, remote_pad, sink_pad);if (ret)return ret; + } - ret =v4l2_subdev_enable_streams (remote_sd, remote_pad, - sink_streams); -if (ret) { -dev_err (xbar->isi->dev, -"failed to enable streams 0x%llx on '%s':%u: %d\n" , - sink_streams, remote_sd->name, remote_pad, ret); -mxc_isi_crossbar_gasket_disable (xbar, sink_pad); -return ret; - } + ret =v4l2_subdev_enable_streams (remote_sd, remote_pad, sink_streams); +if (ret) { +dev_err (xbar->isi->dev, +"failed to enable streams 0x%llx on '%s':%u: %d\n" , + sink_streams, remote_sd->name, remote_pad, ret); + goto err_gasket_disable; } - input->enable_count++; + input->enabled_streams |= sink_streams; + +/* Record the input and stream for this pipe. */ + pipe->input = sink_pad; + pipe->input_stream = sink_streams;return 0 ; + +err_gasket_disable: +if (!input->enabled_streams) +mxc_isi_crossbar_gasket_disable (xbar, sink_pad); + +return ret; } static int mxc_isi_crossbar_disable_streams(struct v4l2_subdev *sd,@@ -381,6 +411,7 @@ static int mxc_isi_crossbar_disable_streams(struct v4l2_subdev *sd, u32 pad, u64 streams_mask) {struct mxc_isi_crossbar *xbar =to_isi_crossbar (sd); +struct mxc_isi_pipe *pipe = &xbar->isi->pipes[pad - xbar->num_sinks];struct v4l2_subdev *remote_sd;struct mxc_isi_input *input;u64 sink_streams;@@ -396,18 +427,27 @@ static int mxc_isi_crossbar_disable_streams(struct v4l2_subdev *sd, input = &xbar->inputs[sink_pad]; - input->enable_count--; +/* Clear the input and stream for this pipe. */ + pipe->input =UINT_MAX ; + pipe->input_stream =0 ; -if (!input->enable_count) { - ret =v4l2_subdev_disable_streams (remote_sd, remote_pad, - sink_streams); -if (ret) -dev_err (xbar->isi->dev, -"failed to disable streams 0x%llx on '%s':%u: %d\n" , - sink_streams, remote_sd->name, remote_pad, ret); +/* +* Check if any other pipe receives the same input stream. If so we +* can't disable it yet, so return immediately. +*/ +if (mxc_isi_crossbar_stream_in_use (xbar, sink_pad, sink_streams)) +return 0 ; + + ret =v4l2_subdev_disable_streams (remote_sd, remote_pad, sink_streams); +if (ret) +dev_err (xbar->isi->dev, +"failed to disable streams 0x%llx on '%s':%u: %d\n" , + sink_streams, remote_sd->name, remote_pad, ret); + + input->enabled_streams &= ~sink_streams; +if (!input->enabled_streams)mxc_isi_crossbar_gasket_disable (xbar, sink_pad); - }return ret; }drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c +1
-1@@ -816,6 +816,7 @@ int mxc_isi_pipe_init(struct mxc_isi_dev *isi, unsigned int id) pipe->acquired_res =0 ; pipe->chained_res =0 ; pipe->chained = false; + pipe->input =UINT_MAX ; sd = &pipe->sd;v4l2_subdev_init (sd, &mxc_isi_pipe_subdev_ops); --2.34.1
PATCH v4 2/3 media: nxp: imx8-isi: Add 16-bit raw Bayer format support
In reply to Guoniu ZhouFrom: Laurentiu Palcu <[email protected]>
Add support for 16-bit raw Bayer formats (SBGGR16, SGBRG16, SGRBG16, SRGGB16) to both the pipeline subdev and video capture interface.
These formats are used by image sensors that output 16-bit raw data, enabling the ISI to capture full dynamic range from such sensors.
---
Changes in v3:
- Remove "high-end" from description as RAW16 is common now (Laurent)
- Add Y16 (16-bit monochrome) format support (Laurent)
- Add Reviewed-by tag from Laurent
Changes in v2:
- Add Reviewed-by tag from Frank Li
--- .../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 30 +++++++++++++++ .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 45 ++++++++++++++++++++++ 2 files changed, 75 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c +30 -0
@@ -83,6 +83,12 @@ static const struct mxc_isi_bus_format_info mxc_isi_bus_formats[] = { .pads = BIT(MXC_ISI_PIPE_PAD_SINK) | BIT(MXC_ISI_PIPE_PAD_SOURCE), .encoding = MXC_ISI_ENC_RAW, + }, { + .mbus_code = MEDIA_BUS_FMT_Y16_1X16, + .output = MEDIA_BUS_FMT_Y16_1X16, + .pads = BIT(MXC_ISI_PIPE_PAD_SINK) + | BIT(MXC_ISI_PIPE_PAD_SOURCE), + .encoding = MXC_ISI_ENC_RAW, }, { .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, .output = MEDIA_BUS_FMT_SBGGR8_1X8,
@@ -179,6 +185,30 @@ static const struct mxc_isi_bus_format_info mxc_isi_bus_formats[] = { .pads = BIT(MXC_ISI_PIPE_PAD_SINK) | BIT(MXC_ISI_PIPE_PAD_SOURCE), .encoding = MXC_ISI_ENC_RAW, + }, { + .mbus_code = MEDIA_BUS_FMT_SBGGR16_1X16, + .output = MEDIA_BUS_FMT_SBGGR16_1X16, + .pads = BIT(MXC_ISI_PIPE_PAD_SINK) + | BIT(MXC_ISI_PIPE_PAD_SOURCE), + .encoding = MXC_ISI_ENC_RAW, + }, { + .mbus_code = MEDIA_BUS_FMT_SGBRG16_1X16, + .output = MEDIA_BUS_FMT_SGBRG16_1X16, + .pads = BIT(MXC_ISI_PIPE_PAD_SINK) + | BIT(MXC_ISI_PIPE_PAD_SOURCE), + .encoding = MXC_ISI_ENC_RAW, + }, { + .mbus_code = MEDIA_BUS_FMT_SGRBG16_1X16, + .output = MEDIA_BUS_FMT_SGRBG16_1X16, + .pads = BIT(MXC_ISI_PIPE_PAD_SINK) + | BIT(MXC_ISI_PIPE_PAD_SOURCE), + .encoding = MXC_ISI_ENC_RAW, + }, { + .mbus_code = MEDIA_BUS_FMT_SRGGB16_1X16, + .output = MEDIA_BUS_FMT_SRGGB16_1X16, + .pads = BIT(MXC_ISI_PIPE_PAD_SINK) + | BIT(MXC_ISI_PIPE_PAD_SOURCE), + .encoding = MXC_ISI_ENC_RAW, }, /* JPEG */ {
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 3/3 media: nxp: imx8-isi: Add additional 32-bit RGB format support
In reply to Guoniu ZhouAdd support for additional 32-bit RGB pixel formats (BGRA32, RGBA32, BGRX32, RGBX32, ARGB2101010).
Formats with alpha channel (BGRA32, RGBA32) only support capture as ISI ignores alpha bits when reading from memory.
---
Changes in v3:
- Drop M2M_OUT for ABGR32/BGRA32/RGBA32 as ISI ignores alpha bits (Laurent)
- Remove Android requirements from commit message as alpha formats cannot be used as M2M input (Laurent)
- Add Tested-by tag from Laurent Pinchart
Changes in v2:
- Add Reviewed-by tag from Frank Li
--- .../media/platform/nxp/imx8-isi/imx8-isi-video.c | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +51 -0
@@ -166,6 +166,57 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = { .color_planes = 1, .depth = { 32 }, .encoding = MXC_ISI_ENC_RGB, + }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_BGRA32, + .type = MXC_ISI_VIDEO_CAP | MXC_ISI_VIDEO_M2M_CAP, + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RGBA8888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB, + }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_RGBA32, + .type = MXC_ISI_VIDEO_CAP | MXC_ISI_VIDEO_M2M_CAP, + .isi_out_format = CHNL_IMG_CTRL_FORMAT_ABGR8888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB, + }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_BGRX32, + .type =MXC_ISI_VIDEO_CAP |MXC_ISI_VIDEO_M2M_OUT + | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_RGBX8, + .isi_out_format = CHNL_IMG_CTRL_FORMAT_RGBX888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB, + }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_RGBX32, + .type =MXC_ISI_VIDEO_CAP |MXC_ISI_VIDEO_M2M_OUT + | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8, + .isi_out_format = CHNL_IMG_CTRL_FORMAT_XBGR888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB, + }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_ARGB2101010, + .type =MXC_ISI_VIDEO_CAP |MXC_ISI_VIDEO_M2M_OUT + | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_A2RGB10, + .isi_out_format = CHNL_IMG_CTRL_FORMAT_A2RGB10, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB, },/* * RAW formats
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] V4L2_PIX_FMT_RGBX32 and V4L2_PIX_FMT_XBGR32 share the same isi_in_format, which will result in…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] V4L2_PIX_FMT_RGBX32 and V4L2_PIX_FMT_XBGR32 share the same isi_in_format, which will result in swapped color channels during M2M reads. --
--- Patch [3]: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support --- commit 60dac66057b0040d017034c0952f79ec30cec366
Author: Guoniu Zhou <[email protected]>
media: nxp: imx8-isi: Add additional 32-bit RGB format support
This commit adds support for additional 32-bit RGB pixel formats (BGRA32, RGBA32, BGRX32, RGBX32, ARGB2101010) to the i.MX8 ISI driver. Formats with an alpha channel only support capture, as the ISI ignores alpha bits when reading from memory.
Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +0
-0@@ -166,6 +166,57 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
[ ... ]
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = { · line 203
Quoted 6 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +6
-0+ }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_RGBX32, + .type =MXC_ISI_VIDEO_CAP |MXC_ISI_VIDEO_M2M_OUT + | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8,
[Severity: High]
Does this mapping for V4L2_PIX_FMT_RGBX32 swap the red and blue channels during M2M reads?
The newly added V4L2_PIX_FMT_RGBX32 format (memory layout R,G,B,X) maps to CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8 for DMA reads.
However, earlier in mxc_isi_formats[], the pre-existing V4L2_PIX_FMT_XBGR32 format (memory layout B,G,R,X) uses this exact same configuration:
{
.mbus_code = MEDIA_BUS_FMT_RGB888_1X24,
.fourcc = V4L2_PIX_FMT_XBGR32,
.type = MXC_ISI_VIDEO_CAP | MXC_ISI_VIDEO_M2M_OUT
| MXC_ISI_VIDEO_M2M_CAP,
.isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8,
...
}Since these two formats have opposite red and blue channel locations in memory, can the hardware DMA controller correctly interpret both layouts using the identical input format configuration?
It looks like this could result in corrupted color conversions for one of these formats during M2M operations.
Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5
-0+ .isi_out_format = CHNL_IMG_CTRL_FORMAT_XBGR888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB,
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support
Quoted 33 lines · On Fri, Jul 24, 2026 at 08:03:42AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High]V4L2_PIX_FMT_RGBX32andV4L2_PIX_FMT_XBGR32share the sameisi_in_format, which will result in swapped color channels during M2M reads. ----- Patch [3]: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support --- commit
60dac66057b0040d017034c0952f79ec30cec366
Author: Guoniu Zhou <[email protected]>media: nxp: imx8-isi: Add additional 32-bit RGB format support
This commit adds support for additional 32-bit RGB pixel formats (BGRA32, RGBA32, BGRX32, RGBX32, ARGB2101010) to the i.MX8 ISI driver. Formats with an alpha channel only support capture, as the ISI ignores alpha bits when reading from memory.
Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +0
-0@@ -166,6 +166,57 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {[ ... ]
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = { · line 203
Quoted 6 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +6
-0+ }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_RGBX32, + .type =MXC_ISI_VIDEO_CAP |MXC_ISI_VIDEO_M2M_OUT + | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8,[Severity: High]
Does this mapping forV4L2_PIX_FMT_RGBX32swap the red and blue channels during M2M reads?
Quoted 5 lines
The newly added
V4L2_PIX_FMT_RGBX32format (memory layout R,G,B,X) maps toCHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8for DMA reads.However, earlier in mxc_isi_formats[], the pre-existing
V4L2_PIX_FMT_XBGR32format (memory layout B,G,R,X) uses this exact same configuration:
Is this true?
Frank
Quoted 27 lines
{ .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, .fourcc = V4L2_PIX_FMT_XBGR32, .type = MXC_ISI_VIDEO_CAP | MXC_ISI_VIDEO_M2M_OUT | MXC_ISI_VIDEO_M2M_CAP, .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8, ... }Since these two formats have opposite red and blue channel locations in memory, can the hardware DMA controller correctly interpret both layouts using the identical input format configuration?
It looks like this could result in corrupted color conversions for one of these formats during M2M operations.
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = { · line 208
Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5
-0+ .isi_out_format = CHNL_IMG_CTRL_FORMAT_XBGR888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB,[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
RE: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support
Hi Frank,
Quoted 53 lines
-----Original Message-----
From: Frank Li (OSS) <[email protected]>
Sent: Friday, July 24, 2026 11:31 PM
To: [email protected]
Cc: G.N. Zhou (OSS) <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format supportQuoted 1 line · On Fri, Jul 24, 2026 at 08:03:42AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to
consider:
Quoted 1 line
- [High]
V4L2_PIX_FMT_RGBX32andV4L2_PIX_FMT_XBGR32share the same
isi_in_format, which will result in swapped color channels during M2M reads.Quoted 23 lines
--
--- Patch [3]: [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB format support --- commit
60dac66057b0040d017034c0952f79ec30cec366
Author: Guoniu Zhou <[email protected]>media: nxp: imx8-isi: Add additional 32-bit RGB format support
This commit adds support for additional 32-bit RGB pixel formats (BGRA32, RGBA32, BGRX32, RGBX32, ARGB2101010) to the i.MX8 ISI driver. Formats with an alpha channel only support capture, as the ISI ignores alpha bits when reading from memory.
Quoted 6 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +0
-0@@ -166,6 +166,57 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {[ ... ]
Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = {
Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +4
-0+ }, { + .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, + .fourcc = V4L2_PIX_FMT_RGBX32, + .type = MXC_ISI_VIDEO_CAP |
MXC_ISI_VIDEO_M2M_OUTQuoted 11 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
Quoted 2 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +2
-0+ | MXC_ISI_VIDEO_M2M_CAP, + .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8,[Severity: High]
Does this mapping forV4L2_PIX_FMT_RGBX32swap the red and blue channels during M2M reads?The newly added
V4L2_PIX_FMT_RGBX32format (memory layout R,G,B,X) maps toCHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8for DMA reads.
Quoted 6 lines
Quoted 2 lines
However, earlier in mxc_isi_formats[], the pre-existing
V4L2_PIX_FMT_XBGR32format (memory layout B,G,R,X) uses this exact sameconfiguration:
Is this true?
No, there is patch to fix the earlier incorrect mapping.
https://lore.kernel.org/linux-media/[email protected]/
Best Regards
G.N Zhou
Quoted 32 lines
Frank
Quoted 5 lines
{ .mbus_code = MEDIA_BUS_FMT_RGB888_1X24, .fourcc = V4L2_PIX_FMT_XBGR32, .type = MXC_ISI_VIDEO_CAP |
MXC_ISI_VIDEO_M2M_OUTQuoted 24 lines
| MXC_ISI_VIDEO_M2M_CAP, .isi_in_format = CHNL_MEM_RD_CTRL_IMG_TYPE_XBGR8, ... }Since these two formats have opposite red and blue channel locations in memory, can the hardware DMA controller correctly interpret both layouts using the identical input format configuration?
It looks like this could result in corrupted color conversions for one of these formats during M2M operations.
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = { · line 208
Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5
-0+ .isi_out_format = CHNL_IMG_CTRL_FORMAT_XBGR888, + .mem_planes = 1, + .color_planes = 1, + .depth = { 32 }, + .encoding = MXC_ISI_ENC_RGB,[ ... ]
--
Sashiko AI review *
https://sashiko.dev/#/patchset/[email protected].
com?part=3