[PATCH 1/1] libcamera: Add v4l2_subdev_format in V4L2SubdeviceFormat
Harvey Yang
chenghaoyang at chromium.org
Tue Nov 5 11:49:21 CET 2024
From: Han-Lin Chen <hanlinchen at chromium.org>
Add v4l2_subdev_format in V4L2SubdeviceFormat and set the value when
setFormat() and getFormat().
Signed-off-by: Han-Lin Chen <hanlinchen at chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang at chromium.org>
Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
---
include/libcamera/internal/v4l2_subdevice.h | 2 ++
src/libcamera/pipeline/simple/simple.cpp | 2 +-
src/libcamera/sensor/camera_sensor.cpp | 1 +
src/libcamera/v4l2_subdevice.cpp | 10 ++++++++++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
index 194382f84..d81296ee6 100644
--- a/include/libcamera/internal/v4l2_subdevice.h
+++ b/include/libcamera/internal/v4l2_subdevice.h
@@ -66,6 +66,8 @@ struct V4L2SubdeviceFormat {
std::optional<ColorSpace> colorSpace;
const std::string toString() const;
+
+ struct v4l2_subdev_format subdevFmt;
};
std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f);
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 3ddce71d3..6ec055596 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -1063,7 +1063,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()
LOG(SimplePipeline, Debug)
<< "Picked "
- << V4L2SubdeviceFormat{ pipeConfig_->code, pipeConfig_->sensorSize, {} }
+ << V4L2SubdeviceFormat{ pipeConfig_->code, pipeConfig_->sensorSize, {}, {} }
<< " -> " << pipeConfig_->captureSize
<< "-" << pipeConfig_->captureFormat
<< " for max stream size " << maxStreamSize;
diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp
index 1b224f198..ac96b4843 100644
--- a/src/libcamera/sensor/camera_sensor.cpp
+++ b/src/libcamera/sensor/camera_sensor.cpp
@@ -744,6 +744,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
.code = bestCode,
.size = *bestSize,
.colorSpace = ColorSpace::Raw,
+ .subdevFmt = {},
};
return format;
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 9f2ec4798..677714890 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -808,6 +808,14 @@ const MediaBusFormatInfo &MediaBusFormatInfo::info(uint32_t code)
* resulting color space is acceptable.
*/
+/**
+ * \var V4L2SubdeviceFormat::subdevFmt
+ * \brief The whole v4l2_subdev_format after calling setFormat()/getFormat()
+ *
+ * It's used in some pipeline handlers that need extra information apart from
+ * the existing fields.
+ */
+
/**
* \brief Assemble and return a string describing the format
* \return A string describing the V4L2SubdeviceFormat
@@ -1266,6 +1274,7 @@ int V4L2Subdevice::getFormat(const Stream &stream, V4L2SubdeviceFormat *format,
format->size.height = subdevFmt.format.height;
format->code = subdevFmt.format.code;
format->colorSpace = toColorSpace(subdevFmt.format);
+ format->subdevFmt = subdevFmt;
return 0;
}
@@ -1324,6 +1333,7 @@ int V4L2Subdevice::setFormat(const Stream &stream, V4L2SubdeviceFormat *format,
format->size.height = subdevFmt.format.height;
format->code = subdevFmt.format.code;
format->colorSpace = toColorSpace(subdevFmt.format);
+ format->subdevFmt = subdevFmt;
return 0;
}
--
2.47.0.199.ga7371fff76-goog
More information about the libcamera-devel
mailing list