[libcamera-devel] android: camera_device: Propagate the requested test pattern mode
diff mbox series

Message ID 20210628163644.3195189-1-hiroh@chromium.org
State Accepted
Commit 4c61c5d22371d416453f3124c73894a6c3b4422a
Headers show
Series
  • [libcamera-devel] android: camera_device: Propagate the requested test pattern mode
Related show

Commit Message

Hirokazu Honda June 28, 2021, 4:36 p.m. UTC
Propagate the requested test pattern mode to libcamera::Camera
through libcamera::Request and also set the android metadata to
the test pattern mode contained by the complete Request.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/android/camera_device.cpp | 47 ++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

Comments

Hirokazu Honda Aug. 4, 2021, 3:48 a.m. UTC | #1
Can we merge this patch?

On Tue, Jun 29, 2021 at 1:36 AM Hirokazu Honda <hiroh@chromium.org> wrote:
>
> Propagate the requested test pattern mode to libcamera::Camera
> through libcamera::Request and also set the android metadata to
> the test pattern mode contained by the complete Request.
>
> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/android/camera_device.cpp | 47 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 678cde23..bce3fe48 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -768,16 +768,54 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
>                 return 0;
>
>         /* Translate the Android request settings to libcamera controls. */
> +       ControlList &controls = descriptor->request_->controls();
>         camera_metadata_ro_entry_t entry;
>         if (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) {
>                 const int32_t *data = entry.data.i32;
>                 Rectangle cropRegion{ data[0], data[1],
>                                       static_cast<unsigned int>(data[2]),
>                                       static_cast<unsigned int>(data[3]) };
> -               ControlList &controls = descriptor->request_->controls();
>                 controls.set(controls::ScalerCrop, cropRegion);
>         }
>
> +       if (settings.getEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, &entry)) {
> +               const int32_t data = *entry.data.i32;
> +               int32_t testPatternMode = controls::draft::TestPatternModeOff;
> +               switch (data) {
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF:
> +                       testPatternMode = controls::draft::TestPatternModeOff;
> +                       break;
> +
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR:
> +                       testPatternMode = controls::draft::TestPatternModeSolidColor;
> +                       break;
> +
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS:
> +                       testPatternMode = controls::draft::TestPatternModeColorBars;
> +                       break;
> +
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY:
> +                       testPatternMode = controls::draft::TestPatternModeColorBarsFadeToGray;
> +                       break;
> +
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9:
> +                       testPatternMode = controls::draft::TestPatternModePn9;
> +                       break;
> +
> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1:
> +                       testPatternMode = controls::draft::TestPatternModeCustom1;
> +                       break;
> +
> +               default:
> +                       LOG(HAL, Error)
> +                               << "Unknown test pattern mode: " << data;
> +
> +                       return -EINVAL;
> +               }
> +
> +               controls.set(controls::draft::TestPatternMode, testPatternMode);
> +       }
> +
>         return 0;
>  }
>
> @@ -1329,6 +1367,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons
>                 resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect);
>         }
>
> +       if (metadata.contains(controls::draft::TestPatternMode)) {
> +               const int32_t testPatternMode =
> +                       metadata.get(controls::draft::TestPatternMode);
> +               resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE,
> +                                        testPatternMode);
> +       }
> +
>         /*
>          * Return the result metadata pack even is not valid: get() will return
>          * nullptr.
> --
> 2.32.0.93.g670b81a890-goog
>
Kieran Bingham Aug. 6, 2021, 10:30 a.m. UTC | #2
Hi Hiro,

On 04/08/2021 04:48, Hirokazu Honda wrote:
> Can we merge this patch?
> 
> On Tue, Jun 29, 2021 at 1:36 AM Hirokazu Honda <hiroh@chromium.org> wrote:
>>
>> Propagate the requested test pattern mode to libcamera::Camera
>> through libcamera::Request and also set the android metadata to
>> the test pattern mode contained by the complete Request.
>>
>> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
>> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I'll run this through the compile matrix and integrate next.

--
Kieran


>> ---
>>  src/android/camera_device.cpp | 47 ++++++++++++++++++++++++++++++++++-
>>  1 file changed, 46 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
>> index 678cde23..bce3fe48 100644
>> --- a/src/android/camera_device.cpp
>> +++ b/src/android/camera_device.cpp
>> @@ -768,16 +768,54 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
>>                 return 0;
>>
>>         /* Translate the Android request settings to libcamera controls. */
>> +       ControlList &controls = descriptor->request_->controls();
>>         camera_metadata_ro_entry_t entry;
>>         if (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) {
>>                 const int32_t *data = entry.data.i32;
>>                 Rectangle cropRegion{ data[0], data[1],
>>                                       static_cast<unsigned int>(data[2]),
>>                                       static_cast<unsigned int>(data[3]) };
>> -               ControlList &controls = descriptor->request_->controls();
>>                 controls.set(controls::ScalerCrop, cropRegion);
>>         }
>>
>> +       if (settings.getEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, &entry)) {
>> +               const int32_t data = *entry.data.i32;
>> +               int32_t testPatternMode = controls::draft::TestPatternModeOff;
>> +               switch (data) {
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF:
>> +                       testPatternMode = controls::draft::TestPatternModeOff;
>> +                       break;
>> +
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR:
>> +                       testPatternMode = controls::draft::TestPatternModeSolidColor;
>> +                       break;
>> +
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS:
>> +                       testPatternMode = controls::draft::TestPatternModeColorBars;
>> +                       break;
>> +
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY:
>> +                       testPatternMode = controls::draft::TestPatternModeColorBarsFadeToGray;
>> +                       break;
>> +
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9:
>> +                       testPatternMode = controls::draft::TestPatternModePn9;
>> +                       break;
>> +
>> +               case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1:
>> +                       testPatternMode = controls::draft::TestPatternModeCustom1;
>> +                       break;
>> +
>> +               default:
>> +                       LOG(HAL, Error)
>> +                               << "Unknown test pattern mode: " << data;
>> +
>> +                       return -EINVAL;
>> +               }
>> +
>> +               controls.set(controls::draft::TestPatternMode, testPatternMode);
>> +       }
>> +
>>         return 0;
>>  }
>>
>> @@ -1329,6 +1367,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons
>>                 resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect);
>>         }
>>
>> +       if (metadata.contains(controls::draft::TestPatternMode)) {
>> +               const int32_t testPatternMode =
>> +                       metadata.get(controls::draft::TestPatternMode);
>> +               resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE,
>> +                                        testPatternMode);
>> +       }
>> +
>>         /*
>>          * Return the result metadata pack even is not valid: get() will return
>>          * nullptr.
>> --
>> 2.32.0.93.g670b81a890-goog
>>

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 678cde23..bce3fe48 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -768,16 +768,54 @@  int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
 		return 0;
 
 	/* Translate the Android request settings to libcamera controls. */
+	ControlList &controls = descriptor->request_->controls();
 	camera_metadata_ro_entry_t entry;
 	if (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) {
 		const int32_t *data = entry.data.i32;
 		Rectangle cropRegion{ data[0], data[1],
 				      static_cast<unsigned int>(data[2]),
 				      static_cast<unsigned int>(data[3]) };
-		ControlList &controls = descriptor->request_->controls();
 		controls.set(controls::ScalerCrop, cropRegion);
 	}
 
+	if (settings.getEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, &entry)) {
+		const int32_t data = *entry.data.i32;
+		int32_t testPatternMode = controls::draft::TestPatternModeOff;
+		switch (data) {
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF:
+			testPatternMode = controls::draft::TestPatternModeOff;
+			break;
+
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR:
+			testPatternMode = controls::draft::TestPatternModeSolidColor;
+			break;
+
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS:
+			testPatternMode = controls::draft::TestPatternModeColorBars;
+			break;
+
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY:
+			testPatternMode = controls::draft::TestPatternModeColorBarsFadeToGray;
+			break;
+
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9:
+			testPatternMode = controls::draft::TestPatternModePn9;
+			break;
+
+		case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1:
+			testPatternMode = controls::draft::TestPatternModeCustom1;
+			break;
+
+		default:
+			LOG(HAL, Error)
+				<< "Unknown test pattern mode: " << data;
+
+			return -EINVAL;
+		}
+
+		controls.set(controls::draft::TestPatternMode, testPatternMode);
+	}
+
 	return 0;
 }
 
@@ -1329,6 +1367,13 @@  CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons
 		resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect);
 	}
 
+	if (metadata.contains(controls::draft::TestPatternMode)) {
+		const int32_t testPatternMode =
+			metadata.get(controls::draft::TestPatternMode);
+		resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE,
+					 testPatternMode);
+	}
+
 	/*
 	 * Return the result metadata pack even is not valid: get() will return
 	 * nullptr.