diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index e85979a7..55b1a10d 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -163,6 +163,8 @@ private:
 	void paramReady(FrameBuffer *buffer);
 	void statReady(FrameBuffer *buffer);
 	void frameStart(uint32_t sequence);
+	int findBestFitFormat(V4L2SubdeviceFormat *format,
+			      CameraSensor *sensor);
 
 	int allocateBuffers(Camera *camera);
 	int freeBuffers(Camera *camera);
@@ -551,6 +553,67 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
 	return config;
 }
 
+/**
+ * \brief Find the closest possible match to the desired configuration format,
+ *        that is valid on the RkISP1.
+ * \param[out] format The configuration format for the image sensor
+ * \param[in] sensor The camera sensor object
+ * \return 0 on success, -1 on failure
+ */
+int PipelineHandlerRkISP1::findBestFitFormat(
+	V4L2SubdeviceFormat *format, CameraSensor *sensor)
+{
+	V4L2Subdevice::Formats ispFormats = isp_->formats(0);
+	if (ispFormats.empty()) {
+		LOG(RkISP1, Error) << "Unable to fetch ISP formats.";
+		return -1;
+	}
+	/*
+	 * The maximum resolution is identical for all media bus codes on
+	 * the RkISP1 isp entity. Therefore take the first available resolution.
+	 */
+	Size ispMaximum = ispFormats.begin()->second[0].max;
+
+	if (ispMaximum.width < format->size.width ||
+	    ispMaximum.height < format->size.height) {
+		Size maxSize;
+		LOG(RkISP1, Info) << "Sensor format " << format->size.toString()
+				  << " is not supported by the ISP (maximum: "
+				  << ispMaximum.toString() << "), trying to "
+				  << "re-configure to a smaller sensor format";
+
+		for (const Size &size : sensor->sizes()) {
+			if (size.width > ispMaximum.width ||
+			    size.height > ispMaximum.height)
+				continue;
+			maxSize = std::max(maxSize, size);
+		}
+		if (maxSize == Size(0, 0)) {
+			LOG(RkISP1, Error) << "No avail. sensor resolution <= "
+					   << format->toString();
+			return -1;
+		}
+		format->size = maxSize;
+	}
+
+	auto mbusCodeMatch = ispFormats.find(format->mbus_code);
+	if (mbusCodeMatch == ispFormats.end()) {
+		format->mbus_code = 0;
+		for (unsigned int mbusCode : sensor->mbusCodes()) {
+			mbusCodeMatch = ispFormats.find(mbusCode);
+			if (mbusCodeMatch != ispFormats.end()) {
+				format->mbus_code = mbusCode;
+				break;
+			}
+		}
+		if (format->mbus_code == 0) {
+			LOG(RkISP1, Error) << "No valid sensor mbus-code found";
+			return -1;
+		}
+	}
+	return 0;
+}
+
 int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
 {
 	RkISP1CameraConfiguration *config =
@@ -570,6 +633,10 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
 	V4L2SubdeviceFormat format = config->sensorFormat();
 	LOG(RkISP1, Debug) << "Configuring sensor with " << format.toString();
 
+	ret = findBestFitFormat(&format, sensor);
+	if (ret < 0)
+		return -EINVAL;
+
 	ret = sensor->setFormat(&format);
 	if (ret < 0)
 		return ret;
