[v2,3/7] camss: Add cammss utility functions
diff mbox series

Message ID 20260721145958.68489-4-johannes.goede@oss.qualcomm.com
State New
Headers show
Series
  • camss: Add CAMSS pipeline handler
Related show

Commit Message

Hans de Goede July 21, 2026, 2:59 p.m. UTC
Add camss_util.[h|cpp] files with some small helper functions shared
between Camss* classes.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 src/libcamera/pipeline/camss/camss_util.cpp | 39 +++++++++++++++++++++
 src/libcamera/pipeline/camss/camss_util.h   | 19 ++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 src/libcamera/pipeline/camss/camss_util.cpp
 create mode 100644 src/libcamera/pipeline/camss/camss_util.h

Comments

Bryan O'Donoghue July 22, 2026, 9:24 a.m. UTC | #1
On 21/07/2026 15:59, Hans de Goede wrote:
> Add camss_util.[h|cpp] files with some small helper functions shared
> between Camss* classes.
> 
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

:g/cammss/s//camss/g

> ---
>   src/libcamera/pipeline/camss/camss_util.cpp | 39 +++++++++++++++++++++
>   src/libcamera/pipeline/camss/camss_util.h   | 19 ++++++++++
>   2 files changed, 58 insertions(+)
>   create mode 100644 src/libcamera/pipeline/camss/camss_util.cpp
>   create mode 100644 src/libcamera/pipeline/camss/camss_util.h
> 
> diff --git a/src/libcamera/pipeline/camss/camss_util.cpp b/src/libcamera/pipeline/camss/camss_util.cpp
> new file mode 100644
> index 000000000..96b1bbc72
> --- /dev/null
> +++ b/src/libcamera/pipeline/camss/camss_util.cpp
> @@ -0,0 +1,39 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Qualcomm CAMSS utility functions
> + *
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#include "camss_util.h"
> +
> +#include <libcamera/base/log.h>
> +
> +#include <libcamera/stream.h>
> +
> +#include "libcamera/internal/v4l2_videodevice.h"
> +
> +namespace libcamera {
> +
> +LOG_DECLARE_CATEGORY(Camss)
> +
> +bool camssV4L2DeviceFormatMatchesStreamConfig(const V4L2DeviceFormat &fmt,
> +					      const StreamConfiguration &cfg,
> +					      const char *msgPrefix)
> +{
> +	if (cfg.pixelFormat != fmt.fourcc.toPixelFormat(false) || cfg.size != fmt.size ||
> +	    cfg.stride != fmt.planes[0].bpl) {
> +		LOG(Camss, Error)
> +			<< msgPrefix
> +			<< " StreamConfiguration vs V4L2DeviceFormat mismatch"
> +			<< " pixelFormat " << cfg.pixelFormat << ", " << fmt.fourcc.toPixelFormat(false)
> +			<< " size " << cfg.size << ", " << fmt.size
> +			<< " stride " << cfg.stride << ", " << fmt.planes[0].bpl
> +			<< " frameSize " << cfg.frameSize << ", " << fmt.planes[0].size;
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +} /* namespace libcamera */
> diff --git a/src/libcamera/pipeline/camss/camss_util.h b/src/libcamera/pipeline/camss/camss_util.h
> new file mode 100644
> index 000000000..111c305aa
> --- /dev/null
> +++ b/src/libcamera/pipeline/camss/camss_util.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Qualcomm CAMSS utility functions
> + *
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#pragma once
> +
> +namespace libcamera {
> +
> +struct StreamConfiguration;
> +class V4L2DeviceFormat;
> +
> +bool camssV4L2DeviceFormatMatchesStreamConfig(const V4L2DeviceFormat &fmt,
> +					      const StreamConfiguration &cfg,
> +					      const char *msgPrefix);
> +
> +} /* namespace libcamera */
> --
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/camss/camss_util.cpp b/src/libcamera/pipeline/camss/camss_util.cpp
new file mode 100644
index 000000000..96b1bbc72
--- /dev/null
+++ b/src/libcamera/pipeline/camss/camss_util.cpp
@@ -0,0 +1,39 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Qualcomm CAMSS utility functions
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#include "camss_util.h"
+
+#include <libcamera/base/log.h>
+
+#include <libcamera/stream.h>
+
+#include "libcamera/internal/v4l2_videodevice.h"
+
+namespace libcamera {
+
+LOG_DECLARE_CATEGORY(Camss)
+
+bool camssV4L2DeviceFormatMatchesStreamConfig(const V4L2DeviceFormat &fmt,
+					      const StreamConfiguration &cfg,
+					      const char *msgPrefix)
+{
+	if (cfg.pixelFormat != fmt.fourcc.toPixelFormat(false) || cfg.size != fmt.size ||
+	    cfg.stride != fmt.planes[0].bpl) {
+		LOG(Camss, Error)
+			<< msgPrefix
+			<< " StreamConfiguration vs V4L2DeviceFormat mismatch"
+			<< " pixelFormat " << cfg.pixelFormat << ", " << fmt.fourcc.toPixelFormat(false)
+			<< " size " << cfg.size << ", " << fmt.size
+			<< " stride " << cfg.stride << ", " << fmt.planes[0].bpl
+			<< " frameSize " << cfg.frameSize << ", " << fmt.planes[0].size;
+		return false;
+	}
+
+	return true;
+}
+
+} /* namespace libcamera */
diff --git a/src/libcamera/pipeline/camss/camss_util.h b/src/libcamera/pipeline/camss/camss_util.h
new file mode 100644
index 000000000..111c305aa
--- /dev/null
+++ b/src/libcamera/pipeline/camss/camss_util.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Qualcomm CAMSS utility functions
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#pragma once
+
+namespace libcamera {
+
+struct StreamConfiguration;
+class V4L2DeviceFormat;
+
+bool camssV4L2DeviceFormatMatchesStreamConfig(const V4L2DeviceFormat &fmt,
+					      const StreamConfiguration &cfg,
+					      const char *msgPrefix);
+
+} /* namespace libcamera */