[{"id":11684,"web_url":"https://patchwork.libcamera.org/comment/11684/","msgid":"<20200729001046.GE151012@oden.dyn.berto.se>","date":"2020-07-29T00:10:46","subject":"Re: [libcamera-devel] [PATCH 5/5] android: camera_device: Re-use\n\tPREVIEW template for other cases","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your patch.\n\nOn 2020-07-25 18:42:43 +0200, Jacopo Mondi wrote:\n> As the VideoRecording and Manual request templates are very similar to\n> the one used for the Preview use case, re-use it and update the entries\n> that differ between use-cases.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nAs you state in the cover letter this could be squashed, I think it's a \ngood idea but I won't push it. If you wish to keep this as is,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/android/camera_device.cpp | 149 ++--------------------------------\n>  1 file changed, 9 insertions(+), 140 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index bd501a9b1660..363151755366 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -920,168 +920,37 @@ CameraMetadata *CameraDevice::requestTemplatePreview()\n>  \n>  CameraMetadata *CameraDevice::requestTemplateVideoRecord()\n>  {\n> -\t/*\n> -\t * \\todo Keep this in sync with the actual number of entries.\n> -\t * Currently: 20 entries, 35 bytes\n> -\t */\n> -\tCameraMetadata *requestTemplate = new CameraMetadata(20, 35);\n> -\tif (!requestTemplate->isValid()) {\n> +\tCameraMetadata *requestTemplate = requestTemplatePreview();\n> +\tif (!requestTemplate || !requestTemplate->isValid()) {\n>  \t\tdelete requestTemplate;\n>  \t\treturn nullptr;\n>  \t}\n>  \n> -\tuint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_MODE,\n> -\t\t\t\t  &aeMode, 1);\n> -\n> -\tint32_t aeExposureCompensation = 0;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,\n> -\t\t\t\t  &aeExposureCompensation, 1);\n> -\n> -\tuint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,\n> -\t\t\t\t  &aePrecaptureTrigger, 1);\n> -\n> -\tuint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK,\n> -\t\t\t\t  &aeLock, 1);\n> -\n>  \tstd::vector<int32_t> aeFpsTarget = {\n>  \t\t30, 30,\n>  \t};\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,\n> -\t\t\t\t  aeFpsTarget.data(),\n> -\t\t\t\t  aeFpsTarget.size());\n> -\n> -\tuint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE,\n> -\t\t\t\t  &aeAntibandingMode, 1);\n> -\n> -\tuint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AF_TRIGGER,\n> -\t\t\t\t  &afTrigger, 1);\n> -\n> -\tuint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AWB_MODE,\n> -\t\t\t\t  &awbMode, 1);\n> -\n> -\tuint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AWB_LOCK,\n> -\t\t\t\t  &awbLock, 1);\n> -\n> -\tuint8_t flashMode = ANDROID_FLASH_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_FLASH_MODE,\n> -\t\t\t\t  &flashMode, 1);\n> -\n> -\tuint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE,\n> -\t\t\t\t  &faceDetectMode, 1);\n> -\n> -\tuint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE,\n> -\t\t\t\t  &noiseReduction, 1);\n> -\n> -\tuint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE,\n> -\t\t\t\t  &aberrationMode, 1);\n> -\n> -\tuint8_t controlMode = ANDROID_CONTROL_MODE_AUTO;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_MODE, &controlMode, 1);\n> -\n> -\tfloat lensAperture = 2.53 / 100;\n> -\trequestTemplate->addEntry(ANDROID_LENS_APERTURE, &lensAperture, 1);\n> -\n> -\tuint8_t opticalStabilization = ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,\n> -\t\t\t\t  &opticalStabilization, 1);\n> -\n> -\tuint8_t captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT,\n> -\t\t\t\t  &captureIntent, 1);\n> +\trequestTemplate->updateEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,\n> +\t\t\t\t     aeFpsTarget.data(), aeFpsTarget.size());\n>  \n>  \treturn requestTemplate;\n>  }\n>  \n>  CameraMetadata *CameraDevice::requestTemplateManual()\n>  {\n> -\t/*\n> -\t * \\todo Keep this in sync with the actual number of entries.\n> -\t * Currently: 20 entries, 35 bytes\n> -\t */\n> -\tCameraMetadata *requestTemplate = new CameraMetadata(20, 35);\n> -\tif (!requestTemplate->isValid()) {\n> +\tCameraMetadata *requestTemplate = requestTemplatePreview();\n> +\tif (!requestTemplate || !requestTemplate->isValid()) {\n>  \t\tdelete requestTemplate;\n>  \t\treturn nullptr;\n>  \t}\n>  \n>  \tuint8_t aeMode = ANDROID_CONTROL_AE_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_MODE,\n> -\t\t\t\t  &aeMode, 1);\n> -\n> -\tint32_t aeExposureCompensation = 0;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,\n> -\t\t\t\t  &aeExposureCompensation, 1);\n> -\n> -\tuint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,\n> -\t\t\t\t  &aePrecaptureTrigger, 1);\n> -\n> -\tuint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK,\n> -\t\t\t\t  &aeLock, 1);\n> -\n> -\tstd::vector<int32_t> aeFpsTarget = {\n> -\t\t15, 30,\n> -\t};\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,\n> -\t\t\t\t  aeFpsTarget.data(),\n> -\t\t\t\t  aeFpsTarget.size());\n> -\n> -\tuint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE,\n> -\t\t\t\t  &aeAntibandingMode, 1);\n> -\n> -\tuint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AF_TRIGGER,\n> -\t\t\t\t  &afTrigger, 1);\n> +\trequestTemplate->updateEntry(ANDROID_CONTROL_AE_MODE, &aeMode, 1);\n>  \n>  \tuint8_t awbMode = ANDROID_CONTROL_AWB_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AWB_MODE,\n> -\t\t\t\t  &awbMode, 1);\n> -\n> -\tuint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_AWB_LOCK,\n> -\t\t\t\t  &awbLock, 1);\n> -\n> -\tuint8_t flashMode = ANDROID_FLASH_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_FLASH_MODE,\n> -\t\t\t\t  &flashMode, 1);\n> -\n> -\tuint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE,\n> -\t\t\t\t  &faceDetectMode, 1);\n> -\n> -\tuint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE,\n> -\t\t\t\t  &noiseReduction, 1);\n> -\n> -\tuint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE,\n> -\t\t\t\t  &aberrationMode, 1);\n> +\trequestTemplate->updateEntry(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);\n>  \n>  \tuint8_t controlMode = ANDROID_CONTROL_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_MODE, &controlMode, 1);\n> -\n> -\tfloat lensAperture = 2.53 / 100;\n> -\trequestTemplate->addEntry(ANDROID_LENS_APERTURE, &lensAperture, 1);\n> -\n> -\tuint8_t opticalStabilization = ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;\n> -\trequestTemplate->addEntry(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,\n> -\t\t\t\t  &opticalStabilization, 1);\n> -\n> -\tuint8_t captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;\n> -\trequestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT,\n> -\t\t\t\t  &captureIntent, 1);\n> +\trequestTemplate->updateEntry(ANDROID_CONTROL_MODE, &controlMode, 1);\n>  \n>  \treturn requestTemplate;\n>  }\n> -- \n> 2.27.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 30652BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jul 2020 00:10:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 00349613C6;\n\tWed, 29 Jul 2020 02:10:50 +0200 (CEST)","from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 367F560535\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 02:10:48 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id b11so11999703lfe.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jul 2020 17:10:48 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn205sm43414lfd.59.2020.07.28.17.10.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 28 Jul 2020 17:10:47 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"Wjmq3ruq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=ykyLa7WGZ+nqSU9j/YWZJeQOr4+GcLdTRpHmJqyYXks=;\n\tb=Wjmq3ruqmUhw2yJdUPS2ajbpIT0jxg053akKVZ3iSR/6r7bY6pd0/Ssl5x1mI704nf\n\t8siINfbrME6dTNZ9H9VG7CDfgqfMG7OQWdAqprs9l+3Q+pXw8mbA6OsAkDZmH5zoUfKu\n\tNsX0v2bZ660aTr03uTxZqR/mzSRbju4tN1wm+tQziRBGptKrju/mdWwO4jBG6PLP2weo\n\tRrSZ4xWnu2r3hcmctbFxKAI2tNnk+KHi80P6G53DUllIBus0DoVoOdSlJLSfG4yjP0Yl\n\tOlBqKOmTsQJTwvrdD4lCfSIav8zZTrend6wi4tOluMmkPGhPFOvdX4q0eLY90IB4Jfpc\n\t6Nyg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=ykyLa7WGZ+nqSU9j/YWZJeQOr4+GcLdTRpHmJqyYXks=;\n\tb=rsAWkku75DH3Kd1ZAdci3DgPp4lLMhltUyhSOjoSNy+GoqIWn/vPYxMa/WTduJmkRL\n\thpNTXuH0znrhmbAYdK56MlWI9ZjVUQnLYdNyrr8mG8m3eRPLpy5VEVAjMCDRFDk/gGwY\n\tOPjZaB7NnHsWW8qLpiX8p6mkijaI5C6KFCoew4CX/bYowOsFcDwHRCDucdJCJ7aPQUwy\n\tKRj9aoKvT6CSTwsV0U55Johj2AeaAZavfh7fR7TeG9KSXPu6N6v9dEDmAtwqqZXDqit6\n\txZ5BqdDMuOiAw0g15+3oZGNS6/BEyDNwnOQsSfT5RT/8mb8YDXl6aXZkvdfPcJ29VxT/\n\tfvLQ==","X-Gm-Message-State":"AOAM530NV6bkK20Ogxz+dTiI3tUzP5xK+lI1Kz7MwSkkdAi3yTX6zxCD\n\t8xqMrVJmLMqJnIwWZNkDw4e8M6Fc89k=","X-Google-Smtp-Source":"ABdhPJzqef/T6WUHZFu1ArzK8LdMl28m9UrQy7vWwurGsng+HUphZZ5b1tSKPEbB5wPU7+8MCrgXYA==","X-Received":"by 2002:a19:8b55:: with SMTP id\n\tn82mr15611107lfd.35.1595981447583; \n\tTue, 28 Jul 2020 17:10:47 -0700 (PDT)","Date":"Wed, 29 Jul 2020 02:10:46 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200729001046.GE151012@oden.dyn.berto.se>","References":"<20200725164243.168297-1-jacopo@jmondi.org>\n\t<20200725164243.168297-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200725164243.168297-6-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 5/5] android: camera_device: Re-use\n\tPREVIEW template for other cases","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]