[{"id":4999,"web_url":"https://patchwork.libcamera.org/comment/4999/","msgid":"<20200604023240.GD7617@pendragon.ideasonboard.com>","date":"2020-06-04T02:32:40","subject":"Re: [libcamera-devel] [PATCH 7/8] android: camera_device: Translate\n\tAndroid format","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, May 26, 2020 at 04:22:36PM +0200, Jacopo Mondi wrote:\n> Translate the Android format code to the libcamera format code\n> at stream configuration time, using the translation map built at\n> camera device initialization time.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/android/camera_device.cpp | 26 +++++++++++++++++---------\n>  1 file changed, 17 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index f8a52342abe5..b0f5a6a2edb5 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -904,12 +904,27 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n>  \t\t\t       << \", format: \" << utils::hex(stream->format);\n>  \t}\n>  \n> -\t/* Hardcode viewfinder role, collecting sizes from the stream config. */\n> +\t/* Only one stream is supported. */\n>  \tif (stream_list->num_streams != 1) {\n>  \t\tLOG(HAL, Error) << \"Only one stream supported\";\n>  \t\treturn -EINVAL;\n>  \t}\n\nBlank line here ?\n\n> +\tcamera3_stream_t *camera3Stream = stream_list->streams[0];\n> +\n> +\t/* Translate Android format code to libcamera format code. */\n> +\tauto it = formatsMap_.find(camera3Stream->format);\n> +\tif (it == formatsMap_.end()) {\n> +\t\tLOG(HAL, Error) << \"Requested format \"\n> +\t\t\t\t<< utils::hex(camera3Stream->format)\n> +\t\t\t\t<< \" not supported\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\tuint32_t libcameraFormatCode = it->second;\n\nLet's make this a PixelFormat too.\n\n>  \n> +\t/*\n> +\t * Hardcode viewfinder role, replacing the generate configuration\n\ns/generate/generated/\n\n> +\t * parameters with the Android framework requestes ones.\n\ns/requestes/requested/\n\nThis sounds a bit strange to my ears though, I would have written \"...\nwith the ones requested by the Android framework\". I've asked Paul who\nconfirmed, as I don't always trust my gut feelings about English, but\nI'm not sure why I find your formulation strange :-)\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t */\n>  \tStreamRoles roles = { StreamRole::Viewfinder };\n>  \tconfig_ = camera_->generateConfiguration(roles);\n>  \tif (!config_ || config_->empty()) {\n> @@ -917,17 +932,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> -\t/* Only one stream is supported. */\n> -\tcamera3_stream_t *camera3Stream = stream_list->streams[0];\n>  \tStreamConfiguration *streamConfiguration = &config_->at(0);\n>  \tstreamConfiguration->size.width = camera3Stream->width;\n>  \tstreamConfiguration->size.height = camera3Stream->height;\n> -\n> -\t/*\n> -\t * \\todo We'll need to translate from Android defined pixel format codes\n> -\t * to the libcamera image format codes. For now, do not change the\n> -\t * format returned from Camera::generateConfiguration().\n> -\t */\n> +\tstreamConfiguration->pixelFormat = PixelFormat(libcameraFormatCode);\n>  \n>  \tswitch (config_->validate()) {\n>  \tcase CameraConfiguration::Valid:","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 23A4461012\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jun 2020 04:32:57 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9426C29B;\n\tThu,  4 Jun 2020 04:32:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"UiSBlJE+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591237976;\n\tbh=cbaq7VrXT3DaF9z8Ta6UxZRD5KJoHvlkGva/5P0SKbY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UiSBlJE+L67sijrjblyairP0yVSbCC9K8snwNX+vBkbvMxk2MMTIcevcvQcVNz0k/\n\tSwMtlHoFKRr+yuG7H4TiqkgvKSLAeTf9Ws0EZS0BNp8aFVbDBAiFoOcJpaPxXVdKuy\n\tZiVd/Vh1+z01Uy+64ZBkv+tVdObOdOdqbd1DWRdA=","Date":"Thu, 4 Jun 2020 05:32:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200604023240.GD7617@pendragon.ideasonboard.com>","References":"<20200526142237.407557-1-jacopo@jmondi.org>\n\t<20200526142237.407557-8-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200526142237.407557-8-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 7/8] android: camera_device: Translate\n\tAndroid format","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>","X-List-Received-Date":"Thu, 04 Jun 2020 02:32:57 -0000"}}]