[libcamera-devel] pipeline: raspberrypi: Update lens shading control in-place
diff mbox series

Message ID 20210217103626.1555692-1-naush@raspberrypi.com
State Superseded
Headers show
Series
  • [libcamera-devel] pipeline: raspberrypi: Update lens shading control in-place
Related show

Commit Message

Naushir Patuck Feb. 17, 2021, 10:36 a.m. UTC
Add the dmabuf file descriptor to the lens shading control in-place
rather than taking a copy.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 .../pipeline/raspberrypi/raspberrypi.cpp        | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 1a0bd6275578..a60415d93705 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1338,18 +1338,15 @@  void RPiCameraData::embeddedComplete(uint32_t bufferId)
 
 void RPiCameraData::setIspControls(const ControlList &controls)
 {
-	ControlList ctrls = controls;
+	ControlList ctrls = std::move(controls);
 
 	if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) {
-		Span<const uint8_t> s =
-			ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data();
-		bcm2835_isp_lens_shading ls =
-			*reinterpret_cast<const bcm2835_isp_lens_shading *>(s.data());
-		ls.dmabuf = lsTable_.fd();
-
-		ControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&ls),
-						    sizeof(ls) });
-		ctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c);
+		ControlValue &value =
+			const_cast<ControlValue &>(ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING));
+		Span<uint8_t> s = value.data();
+		bcm2835_isp_lens_shading *ls =
+			reinterpret_cast<bcm2835_isp_lens_shading *>(s.data());
+		ls->dmabuf = lsTable_.fd();
 	}
 
 	isp_[Isp::Input].dev()->setControls(&ctrls);