Skip to content

pipeline: rpi: Derive RAW stream Bayer order from the selected sensor mode - #1

Open
santiagobarros wants to merge 1 commit into
framosimaging:framos_v0.5.2+rpt20250903from
santiagobarros:fix/imx900-fullres-bayer-order
Open

pipeline: rpi: Derive RAW stream Bayer order from the selected sensor mode#1
santiagobarros wants to merge 1 commit into
framosimaging:framos_v0.5.2+rpt20250903from
santiagobarros:fix/imx900-fullres-bayer-order

Conversation

@santiagobarros

@santiagobarros santiagobarros commented May 26, 2026

Copy link
Copy Markdown

Reported in framosimaging/framos-rpi-drivers#6

Problem

The IMX900 uses a different Bayer order per mode (binned 1032×776 = GBRG,
full-resolution 2064×1552 = RGGB). RPiCameraConfiguration::validate() sets the
RAW stream's Bayer order from sensor_->bayerOrder(combinedTransform_), i.e. the
sensor's single assumed native order, which libcamera takes from the
first-enumerated mbus code (SGBRG12, GBRG). At full resolution findBestFormat()
correctly selects the RGGB mode, but the RAW stream order stays GBRG, so the CFE
output node is configured with PC1g (GBRG) while the CSI2 source pad is RGGB.

The RP1 CFE then rejects the pipeline at stream-on:

rp1-cfe: Format mismatch!
/dev/video7: Failed to start streaming: Invalid argument

This breaks every capture wider than the binned mode (rpicam-still /
rpicam-raw at 1920×1080 and 2064×1552), while the binned 1032×776 mode works.

Fix

Derive the RAW stream Bayer order from the actually-selected sensor mode
(sensorFormat_.code), which is exactly what the CFE source pad carries, instead
of the assumed single native order. Full-res then selects PC1R (RGGB) and link
validation passes; the binned mode continues to use PC1g.

Testing

  • IMX900 (Framos FSM:GO) on Raspberry Pi 5, Raspberry Pi OS trixie, kernel
    6.18.29+rpt-rpi-2712, framos-libcamera framos_v0.5.2+rpt20250903.
  • Before: rpicam-still / rpicam-raw at 1920×1080 and 2064×1552 fail with the
    CFE "Format mismatch!" EINVAL above; 1032×776 works.
  • After: full-res selects 2064x1552-PC1R/RAW, captures a valid 2064×1552 JPEG
    and RAW; binned 1032×776 still works (selects PC1g).

Note / limitation

This derives the order purely from the selected mode's mbus code, which is correct
for the default (identity) transform. A sensor that also changes Bayer order
under H/V flip would additionally need the transform applied; that path is
unchanged here.

… mode

The IMX900 uses a different Bayer order per mode (binned 1032x776 = GBRG,
full-resolution 2064x1552 = RGGB). RPiCameraConfiguration::validate() sets the
RAW stream's Bayer order from sensor_->bayerOrder(combinedTransform_), i.e. the
sensor's single assumed native order, which libcamera takes from the
first-enumerated mbus code (SGBRG12, GBRG). At full resolution findBestFormat()
correctly selects the RGGB mode, but the RAW stream order stays GBRG, so the CFE
output node is configured with PC1g (GBRG) while the CSI2 source pad is RGGB.

The RP1 CFE then rejects the pipeline at stream-on:

    rp1-cfe: Format mismatch!
    /dev/video7: Failed to start streaming: Invalid argument

This breaks every capture wider than the binned mode.

Derive the RAW stream Bayer order from the actually-selected sensor mode
(sensorFormat_.code), which is exactly what the CFE source pad carries, instead
of the assumed single native order. Full-res then selects PC1R (RGGB) and link
validation passes; the binned mode continues to use PC1g.

Verified on IMX900 (Framos FSM:GO) on Raspberry Pi 5, Raspberry Pi OS trixie,
kernel 6.18.29+rpt-rpi-2712: full-res 2064x1552 JPEG + RAW capture now succeed.

Signed-off-by: Santiago Barros <santiagobarros@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant