about summary refs log tree commit diff
path: root/users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-01-30T09·43+0200
committerflokli <flokli@flokli.de>2024-01-30T09·54+0000
commitaf9a8d372b24710bf7fc27c8e81244e1ca6d1658 (patch)
treedf8bee03b202ec5081b9bd7e7b5d7b6ecdd28e1b /users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch
parentb38be028d96ce107439f3323026270228a871a13 (diff)
feat(users/flokli/ipu6-softisp): init r/7454
This code adds support for the ipu6 webcams via libcamera, based on the work in
https://copr.fedorainfracloud.org/coprs/jwrdegoede/ipu6-softisp/.

It's supposed to be included in your NixOS configuration imports.

Change-Id: Ifb71999ad61161fa23506b97cb449f73fb1270e3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10709
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch')
-rw-r--r--users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch131
1 files changed, 131 insertions, 0 deletions
diff --git a/users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch b/users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch
new file mode 100644
index 000000000000..44985a94e16f
--- /dev/null
+++ b/users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch
@@ -0,0 +1,131 @@
+From f939e68a3ef556e572f0140df6d7ef17d72f457e Mon Sep 17 00:00:00 2001
+From: Marttico <g.martti@gmail.com>
+Date: Wed, 20 Dec 2023 20:26:15 +0100
+Subject: [PATCH 21/25] libcamera: swstats_cpu: Add support for 10bpp
+ IGIG_GBGR_IGIG_GRGB input
+
+Add support to SwStatsCpu for 10bpp IGIG_GBGR_IGIG_GRGB input
+generated by the Omnivision ov01a1s sensor.
+
+Co-authored-by: Dennis Bonke <admin@dennisbonke.com>
+Signed-off-by: Dennis Bonke <admin@dennisbonke.com>
+Co-authored-by: Toon Langendam <t.langendam@gmail.com>
+Signed-off-by: Toon Langendam <t.langendam@gmail.com>
+Signed-off-by: Marttico <g.martti@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+---
+ .../internal/software_isp/swstats_cpu.h       |  3 +
+ src/libcamera/software_isp/swstats_cpu.cpp    | 76 +++++++++++++++++++
+ 2 files changed, 79 insertions(+)
+
+diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h
+index e7abc6bb..a47241e1 100644
+--- a/include/libcamera/internal/software_isp/swstats_cpu.h
++++ b/include/libcamera/internal/software_isp/swstats_cpu.h
+@@ -42,6 +42,9 @@ private:
+ 	/* Bayer 10 bpp packed */
+ 	void statsBGGR10PLine0(const uint8_t *src[]);
+ 	void statsGBRG10PLine0(const uint8_t *src[]);
++	/* IGIG_GBGR_IGIG_GRGB 10 bpp unpacked */
++	void statsRGBIR10Line0(const uint8_t *src[]);
++	void statsRGBIR10Line2(const uint8_t *src[]);
+ 	void resetStats(void);
+ 	void finishStats(void);
+ 
+diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
+index 87550371..96e21be5 100644
+--- a/src/libcamera/software_isp/swstats_cpu.cpp
++++ b/src/libcamera/software_isp/swstats_cpu.cpp
+@@ -187,6 +187,68 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[])
+ 	statsBayer10P(window_.width, src0, src1, false, stats_);
+ }
+ 
++void SwStatsCpu::statsRGBIR10Line0(const uint8_t *src[])
++{
++	const uint16_t *src0_16 = (const uint16_t *)src[2] + window_.x;
++	const uint16_t *src1_16 = (const uint16_t *)src[3] + window_.x;
++	uint16_t g3, g4;
++
++	SWISP_LINARO_START_LINE_STATS(uint16_t)
++
++	/* x += 8 sample every other 4x4 block */
++	for (int x = 0; x < (int)window_.width; x += 8) {
++		/* IGIG */
++		//i = src0_16[x];
++		g2 = src0_16[x + 1];
++		//i = src0_16[x + 2];
++		g4 = src0_16[x + 3];
++
++		/* GBGR */
++		g = src1_16[x];
++		b = src1_16[x + 1];
++		g3 = src1_16[x + 2];
++		r = src1_16[x + 3];
++
++		g = (g + g2 + g3 + g4) / 4;
++
++		/* divide Y by 4 for 10 -> 8 bpp value */
++		SWISP_LINARO_ACCUMULATE_LINE_STATS(4)
++	}
++
++	SWISP_LINARO_FINISH_LINE_STATS()
++}
++
++void SwStatsCpu::statsRGBIR10Line2(const uint8_t *src[])
++{
++	const uint16_t *src0_16 = (const uint16_t *)src[2] + window_.x;
++	const uint16_t *src1_16 = (const uint16_t *)src[3] + window_.x;
++	uint16_t g3, g4;
++
++	SWISP_LINARO_START_LINE_STATS(uint16_t)
++
++	/* x += 8 sample every other 4x4 block */
++	for (int x = 0; x < (int)window_.width; x += 8) {
++		/* IGIG */
++		//i = src0_16[x];
++		g2 = src0_16[x + 1];
++		//i = src0_16[x + 2];
++		g4 = src0_16[x + 3];
++
++		/* GRGB */
++		g = src1_16[x];
++		r = src1_16[x + 1];
++		g3 = src1_16[x + 2];
++		b = src1_16[x + 3];
++
++		g = (g + g2 + g3 + g4) / 4;
++
++		/* divide Y by 4 for 10 -> 8 bpp value */
++		SWISP_LINARO_ACCUMULATE_LINE_STATS(4)
++	}
++
++	SWISP_LINARO_FINISH_LINE_STATS()
++}
++
+ void SwStatsCpu::resetStats(void)
+ {
+ 	stats_.sumR_ = 0;
+@@ -282,6 +344,20 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg)
+ 		}
+ 	}
+ 
++	if (bayerFormat.bitDepth == 10 &&
++	    bayerFormat.packing == BayerFormat::Packing::None &&
++	    bayerFormat.order == BayerFormat::IGIG_GBGR_IGIG_GRGB) {
++		bpp_ = 16;
++		patternSize_.height = 4;
++		patternSize_.width = 4;
++		y_skip_mask_ = 0x04;
++		x_shift_ = 0;
++		swap_lines_ = false;
++		stats0_ = (SwStats::statsProcessFn)&SwStatsCpu::statsRGBIR10Line0;
++		stats2_ = (SwStats::statsProcessFn)&SwStatsCpu::statsRGBIR10Line2;
++		return 0;
++	}
++
+ 	LOG(SwStats, Info)
+ 		<< "Unsupported input format " << inputCfg.pixelFormat.toString();
+ 	return -EINVAL;
+-- 
+2.43.0
+