{"record":{"id":"62e7c9bb0e35ed21","repo":"embassy-rs/embassy","slug":"ycbcr-pixel-format-not-supported-for-background-bu","errorCode":null,"errorMessage":"YCbCr pixel format not supported for background buffer","messagePattern":"YCbCr pixel format not supported for background buffer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/dma2d/mod.rs","lineNumber":213,"sourceCode":"    }\n}\n\nimpl Into<vals::BgpfccrCm> for PixelFormat {\n    fn into(self) -> vals::BgpfccrCm {\n        match self {\n            PixelFormat::Argb8888 => vals::BgpfccrCm::Argb8888,\n            PixelFormat::Rgb888 => vals::BgpfccrCm::Rgb888,\n            PixelFormat::Rgb565 => vals::BgpfccrCm::Rgb565,\n            PixelFormat::Argb1555 => vals::BgpfccrCm::Argb1555,\n            PixelFormat::Argb4444 => vals::BgpfccrCm::Argb4444,\n            PixelFormat::L8 => vals::BgpfccrCm::L8,\n            PixelFormat::AL44 => vals::BgpfccrCm::Al44,\n            PixelFormat::AL88 => vals::BgpfccrCm::Al88,\n            PixelFormat::L4 => vals::BgpfccrCm::L4,\n            PixelFormat::A8 => vals::BgpfccrCm::A8,\n            PixelFormat::A4 => vals::BgpfccrCm::A4,\n            #[cfg(dma2d_v2)]\n            _ => panic!(\"YCbCr pixel format not supported for background buffer\"),\n        }\n    }\n}\n\nimpl Into<vals::OpfccrCm> for PixelFormat {\n    fn into(self) -> vals::OpfccrCm {\n        match self {\n            PixelFormat::Argb8888 => vals::OpfccrCm::Argb8888,\n            PixelFormat::Rgb888 => vals::OpfccrCm::Rgb888,\n            PixelFormat::Rgb565 => vals::OpfccrCm::Rgb565,\n            PixelFormat::Argb1555 => vals::OpfccrCm::Argb1555,\n            PixelFormat::Argb4444 => vals::OpfccrCm::Argb4444,\n            _ => panic!(\"Selected output pixel format not supported\"),\n        }\n    }\n}\n\n/// Input buffer alpha Mode","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/dma2d/mod.rs#L195-L231","documentation":"When converting a PixelFormat for the DMA2D background layer (BGPFCCR), the YCbCr formats are only valid as foreground/chroma input, not for the background buffer. On dma2d_v2 hardware the driver panics rather than writing an invalid CM value.","triggerScenarios":"Creating/configuring a DMA2D background layer with PixelFormat::YCbCr420/YCbCr422 (any non-RGB/alpha variant rejected here) on a dma2d_v2 part.","commonSituations":"Video pipelines that decode YCbCr and set it as the background framebuffer; copying foreground-layer setup code to the background layer.","solutions":["Use an RGB/ARGB/L4/A8/A4/AL44/AL88 pixel format for the background layer.","Convert YCbCr frames to RGB via the DMA2D foreground chroma path before blitting.","Pass the YCbCr format only to the foreground layer where it is accepted."],"exampleFix":"// before\nlet mut bg = BgLayer::new(&mut dma2d, buf, layout, PixelFormat::YCbCr420);\n// after\nlet mut bg = BgLayer::new(&mut dma2d, buf, layout, PixelFormat::Rgb565);","handlingStrategy":"validation","validationCode":"fn assert_bg_format(f: PixelFormat) {\n    assert!(!matches!(f, PixelFormat::YCbCr420 | PixelFormat::YCbCr422),\n        \"YCbCr not valid for DMA2D background buffer\");\n}","typeGuard":"fn is_bg_pixel_format(f: PixelFormat) -> bool { !matches!(f, PixelFormat::YCbCr420 | PixelFormat::YCbCr422) }","tryCatchPattern":null,"preventionTips":["Reserve YCbCr formats for the foreground/chroma path only.","Keep background framebuffers in RGB/ARGB/L4/A8 formats."],"tags":["embedded","rust","dma2d","graphics"],"backgroundTag":"unsupported-enum-value","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}