diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
index b4a5f87aa93d..41e1b46a1136 100644
--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp
+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp
@@ -23,6 +23,7 @@
 #include <linux/videodev2.h>
 
 #include <libcamera/base/shared_fd.h>
+#include <libcamera/color_filter_array.h>
 #include <libcamera/formats.h>
 
 #include "libcamera/internal/device_enumerator.h"
@@ -56,32 +57,12 @@ constexpr unsigned int DefaultCompressionOffset = 2048;
 constexpr unsigned int DefaultCompressionMode = 1;
 
 const std::vector<std::pair<BayerFormat, unsigned int>> BayerToMbusCodeMap{
-	{ { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, },
-	{ { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, },
-	{ { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, },
-	{ { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, },
-	{ { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, },
-	{ { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, },
-	{ { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, },
-	{ { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, },
-	{ { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, },
-	{ { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, },
-	{ { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, },
-	{ { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, },
-	{ { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, },
-	{ { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, },
-	{ { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, },
-	{ { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, },
-	{ { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, },
-	{ { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, },
-	{ { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, },
-	{ { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, },
-	{ { ColorFilterArray::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, },
-	{ { ColorFilterArray::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, },
-	{ { ColorFilterArray::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, },
-	{ { ColorFilterArray::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, },
-	{ { ColorFilterArray::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, },
-	{ { ColorFilterArray::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, },
+	{ { 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_8, },
+	{ { 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_10, },
+	{ { 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_12, },
+	{ { 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_14, },
+	{ { 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_16, },
+	{ { 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_RAW_16, },
 };
 
 unsigned int bayerToMbusCode(const BayerFormat &bayer)
@@ -97,19 +78,9 @@ unsigned int bayerToMbusCode(const BayerFormat &bayer)
 	return 0;
 }
 
-uint32_t mbusCodeUnpacked16(unsigned int code)
+uint8_t toPiSPBayerOrder(const ColorFilterArray &cfa)
 {
-	BayerFormat bayer = BayerFormat::fromMbusCode(code);
-	BayerFormat bayer16(bayer.cfa.order, 16, BayerFormat::Packing::None);
-
-	return bayerToMbusCode(bayer16);
-}
-
-uint8_t toPiSPBayerOrder(V4L2PixelFormat format)
-{
-	BayerFormat bayer = BayerFormat::fromV4L2PixelFormat(format);
-
-	switch (bayer.cfa.order) {
+	switch (cfa.order) {
 	case ColorFilterArray::Order::BGGR:
 		return PISP_BAYER_ORDER_BGGR;
 	case ColorFilterArray::Order::GBRG:
@@ -816,9 +787,10 @@ private:
 
 	int configureEntities(V4L2SubdeviceFormat sensorFormat,
 			      V4L2SubdeviceFormat &embeddedFormat);
-	int configureCfe();
+	int configureCfe(const ColorFilterArray &bayerOrder);
 	bool calculateCscConfiguration(const V4L2DeviceFormat &v4l2Format, pisp_be_ccm_config &csc);
-	int configureBe(const std::optional<ColorSpace> &yuvColorSpace);
+	int configureBe(const std::optional<ColorSpace> &yuvColorSpace,
+			const ColorFilterArray &bayerOrder);
 
 	void platformSetIspCrop(unsigned int index, const Rectangle &ispCrop) override;
 
@@ -1444,6 +1416,13 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf
 	V4L2VideoDevice *cfe = cfe_[Cfe::Output0].dev();
 	V4L2DeviceFormat cfeFormat;
 
+	/*
+	 * The sensor bayer order is the order of the data arriving at the
+	 * CFE Frontend, as affected by any transform applied to the sensor.
+	 */
+	ColorFilterArray sensorBayerOrder =
+		sensor_->bayerOrder(rpiConfig->combinedTransform_);
+
 	/*
 	 * See which streams are requested, and route the user
 	 * StreamConfiguration appropriately.
@@ -1454,7 +1433,7 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf
 		 * mbus code right at the start.
 		 */
 		V4L2SubdeviceFormat sensorFormatMod = rpiConfig->sensorFormat_;
-		sensorFormatMod.code = mbusCodeUnpacked16(sensorFormatMod.code);
+		sensorFormatMod.code = MEDIA_BUS_FMT_RAW_16;
 		cfeFormat = RPi::PipelineHandlerBase::toV4L2DeviceFormat(cfe,
 									 sensorFormatMod,
 									 BayerFormat::Packing::PISP1);
@@ -1679,10 +1658,10 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf
 	}
 
 	configureEntities(rpiConfig->sensorFormat_, embeddedFormat);
-	configureCfe();
+	configureCfe(sensorBayerOrder);
 
 	if (beEnabled_)
-		configureBe(rpiConfig->yuvColorSpace_);
+		configureBe(rpiConfig->yuvColorSpace_, sensorBayerOrder);
 
 	return 0;
 }
@@ -1915,7 +1894,7 @@ void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool
 	handleState();
 }
 
-int PiSPCameraData::configureCfe()
+int PiSPCameraData::configureCfe(const ColorFilterArray &bayerOrder)
 {
 	V4L2DeviceFormat cfeFormat;
 	cfe_[Cfe::Output0].dev()->getFormat(&cfeFormat);
@@ -1927,7 +1906,7 @@ int PiSPCameraData::configureCfe()
 	global.enables &= ~PISP_FE_ENABLE_COMPRESS0;
 
 	global.enables |= PISP_FE_ENABLE_OUTPUT0;
-	global.bayer_order = toPiSPBayerOrder(cfeFormat.fourcc);
+	global.bayer_order = toPiSPBayerOrder(bayerOrder);
 
 	pisp_image_format_config image = toPiSPImageFormat(cfeFormat);
 	pisp_fe_input_config input = {};
@@ -2002,7 +1981,8 @@ bool PiSPCameraData::calculateCscConfiguration(const V4L2DeviceFormat &v4l2Forma
 	return false;
 }
 
-int PiSPCameraData::configureBe(const std::optional<ColorSpace> &yuvColorSpace)
+int PiSPCameraData::configureBe(const std::optional<ColorSpace> &yuvColorSpace,
+				const ColorFilterArray &bayerOrder)
 {
 	pisp_image_format_config inputFormat;
 	V4L2DeviceFormat cfeFormat;
@@ -2025,7 +2005,7 @@ int PiSPCameraData::configureBe(const std::optional<ColorSpace> &yuvColorSpace)
 				PISP_BE_RGB_ENABLE_CSC1);
 
 	global.bayer_enables |= PISP_BE_BAYER_ENABLE_INPUT;
-	global.bayer_order = toPiSPBayerOrder(cfeFormat.fourcc);
+	global.bayer_order = toPiSPBayerOrder(bayerOrder);
 
 	if (PISP_IMAGE_FORMAT_COMPRESSED(inputFormat.format)) {
 		pisp_decompress_config decompress;
@@ -2249,7 +2229,7 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat,
 	}
 
 	V4L2SubdeviceFormat feFormat = sensorFormat;
-	feFormat.code = mbusCodeUnpacked16(sensorFormat.code);
+	feFormat.code = MEDIA_BUS_FMT_RAW_16;
 	ret = feSubdev_->setFormat(feVideoSinkPad, &feFormat);
 	if (ret)
 		return ret;
