[libcamera-devel,v2,4/4] libcamera: ipa: raspberrypi: plumb the libcamera sharpness control through to the Raspberry Pi implementation

Message ID 20200622135550.10788-5-david.plowman@raspberrypi.com
State Superseded
Headers show
Series
  • libcamera sharpness strength control
Related show

Commit Message

David Plowman June 22, 2020, 1:55 p.m. UTC
This simply wires up the libcamera sharpness control in the Raspberry
Pi IPAs so that it controls the strength of the Raspberry Pi sharpness
control algorithm.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 include/libcamera/ipa/raspberrypi.h |  1 +
 src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++++++++
 2 files changed, 13 insertions(+)

Comments

Laurent Pinchart June 22, 2020, 11:05 p.m. UTC | #1
Hi David,

Thank you for the patch.

Same comment as for patch 3/4, maybe the subject line could be shortened
to "libcamera: ipa: raspberrypi: Plumb the libcamera sharpness control" ?

On Mon, Jun 22, 2020 at 02:55:50PM +0100, David Plowman wrote:
> This simply wires up the libcamera sharpness control in the Raspberry
> Pi IPAs so that it controls the strength of the Raspberry Pi sharpness
> control algorithm.
> 
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  include/libcamera/ipa/raspberrypi.h |  1 +
>  src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
> index c109469..a18ce9a 100644
> --- a/include/libcamera/ipa/raspberrypi.h
> +++ b/include/libcamera/ipa/raspberrypi.h
> @@ -51,6 +51,7 @@ static const ControlInfoMap RPiControls = {
>  	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
>  	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
>  	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },
> +	{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
>  };
>  
>  } /* namespace libcamera */
> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
> index 42c84b1..bc89ab5 100644
> --- a/src/ipa/raspberrypi/raspberrypi.cpp
> +++ b/src/ipa/raspberrypi/raspberrypi.cpp
> @@ -47,6 +47,7 @@
>  #include "metadata.hpp"
>  #include "noise_status.h"
>  #include "sdn_status.h"
> +#include "sharpen_algorithm.hpp"
>  #include "sharpen_status.h"
>  
>  namespace libcamera {
> @@ -633,6 +634,17 @@ void IPARPi::queueRequest(const ControlList &controls)
>  			break;
>  		}
>  
> +		case controls::SHARPNESS: {
> +			RPi::SharpenAlgorithm *sharpen = dynamic_cast<RPi::SharpenAlgorithm *>(
> +				controller_.GetAlgorithm("sharpen"));
> +			ASSERT(sharpen);
> +
> +			sharpen->SetStrength(ctrl.second.get<float>());
> +			libcameraMetadata_.set(controls::Sharpness,
> +					       ctrl.second.get<float>());
> +			break;
> +		}
> +
>  		default:
>  			LOG(IPARPI, Warning)
>  				<< "Ctrl " << controls::controls.at(ctrl.first)->name()

Patch

diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
index c109469..a18ce9a 100644
--- a/include/libcamera/ipa/raspberrypi.h
+++ b/include/libcamera/ipa/raspberrypi.h
@@ -51,6 +51,7 @@  static const ControlInfoMap RPiControls = {
 	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
 	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
 	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },
+	{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
 };
 
 } /* namespace libcamera */
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index 42c84b1..bc89ab5 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -47,6 +47,7 @@ 
 #include "metadata.hpp"
 #include "noise_status.h"
 #include "sdn_status.h"
+#include "sharpen_algorithm.hpp"
 #include "sharpen_status.h"
 
 namespace libcamera {
@@ -633,6 +634,17 @@  void IPARPi::queueRequest(const ControlList &controls)
 			break;
 		}
 
+		case controls::SHARPNESS: {
+			RPi::SharpenAlgorithm *sharpen = dynamic_cast<RPi::SharpenAlgorithm *>(
+				controller_.GetAlgorithm("sharpen"));
+			ASSERT(sharpen);
+
+			sharpen->SetStrength(ctrl.second.get<float>());
+			libcameraMetadata_.set(controls::Sharpness,
+					       ctrl.second.get<float>());
+			break;
+		}
+
 		default:
 			LOG(IPARPI, Warning)
 				<< "Ctrl " << controls::controls.at(ctrl.first)->name()