[{"id":12390,"web_url":"https://patchwork.libcamera.org/comment/12390/","msgid":"<20200909110133.35eri5yyaav3rumo@uno.localdomain>","date":"2020-09-09T11:01:33","subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Umang,\n sorry I got late on v1\n\nOn Wed, Sep 09, 2020 at 04:17:54PM +0530, Umang Jain wrote:\n> Android's orientation metadata cannot have identical numerical\n> value to libcamera's rotation property. This is due to the fact\n> that libcamera's rotation property specify the correction angle\n\nspecifies\n\n> in anticlockwise direction whereas Android's orientation metadata\n> specifies the value in clockwise direction. Fix that by computing\n> corresponding value for clockwise direction from libcamera's rotation\n> property.\n>\n\nWe used 'counterclockwise', but I think it's the same\n\n> Signed-off-by: Umang Jain <email@uajain.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/android/camera_device.cpp | 15 ++++++++++-----\n>  1 file changed, 10 insertions(+), 5 deletions(-)\n>\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 2582991..8be846b 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -265,12 +265,17 @@ int CameraDevice::initialize()\n>  \t}\n>\n>  \t/*\n> -\t * The Android orientation metadata and libcamera rotation property are\n> -\t * defined differently but have identical numerical values for Android\n> -\t * devices such as phones and tablets.\n> +\t * The Android orientation metadata specifies its rotation correction\n> +\t * value in clockwise direction whereas libcamera specifies the\n> +\t * rotation property in anticlockwise direction. Read the libcamera's\n> +\t * rotation property (anticlockwise) and compute the corresponding\n> +\t * value for clockwise direction as required by the Android orientation\n> +\t * metadata.\n>  \t */\n> -\tif (properties.contains(properties::Rotation))\n> -\t\torientation_ = properties.get(properties::Rotation);\n> +\tif (properties.contains(properties::Rotation)) {\n> +\t\tint rotation = properties.get(properties::Rotation);\n> +\t\torientation_ = (360 - rotation) % 360;\n\nThe % 360 'should' not be necessary, but I guess it doesn't hurt.\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> +\t}\n>\n>  \tint ret = camera_->acquire();\n>  \tif (ret) {\n> --\n> 2.26.2\n>","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 E1ABEBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Sep 2020 10:57:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8225E62B90;\n\tWed,  9 Sep 2020 12:57:47 +0200 (CEST)","from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F134C60534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Sep 2020 12:57:45 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 358E024000F;\n\tWed,  9 Sep 2020 10:57:44 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Wed, 9 Sep 2020 13:01:33 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Umang Jain <email@uajain.com>","Message-ID":"<20200909110133.35eri5yyaav3rumo@uno.localdomain>","References":"<20200909104754.25940-1-email@uajain.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200909104754.25940-1-email@uajain.com>","Subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","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=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12391,"web_url":"https://patchwork.libcamera.org/comment/12391/","msgid":"<20200909111038.GB3931@pendragon.ideasonboard.com>","date":"2020-09-09T11:10:38","subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Sep 09, 2020 at 01:01:33PM +0200, Jacopo Mondi wrote:\n> Hi Umang,\n>  sorry I got late on v1\n> \n> On Wed, Sep 09, 2020 at 04:17:54PM +0530, Umang Jain wrote:\n> > Android's orientation metadata cannot have identical numerical\n> > value to libcamera's rotation property. This is due to the fact\n> > that libcamera's rotation property specify the correction angle\n> \n> specifies\n> \n> > in anticlockwise direction whereas Android's orientation metadata\n> > specifies the value in clockwise direction. Fix that by computing\n> > corresponding value for clockwise direction from libcamera's rotation\n> > property.\n> \n> We used 'counterclockwise', but I think it's the same\n\nSeems anticlockwise is UK English and counterclockwise US English :-)\n\n> > Signed-off-by: Umang Jain <email@uajain.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/android/camera_device.cpp | 15 ++++++++++-----\n> >  1 file changed, 10 insertions(+), 5 deletions(-)\n> >\n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 2582991..8be846b 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -265,12 +265,17 @@ int CameraDevice::initialize()\n> >  \t}\n> >\n> >  \t/*\n> > -\t * The Android orientation metadata and libcamera rotation property are\n> > -\t * defined differently but have identical numerical values for Android\n> > -\t * devices such as phones and tablets.\n> > +\t * The Android orientation metadata specifies its rotation correction\n> > +\t * value in clockwise direction whereas libcamera specifies the\n> > +\t * rotation property in anticlockwise direction. Read the libcamera's\n> > +\t * rotation property (anticlockwise) and compute the corresponding\n> > +\t * value for clockwise direction as required by the Android orientation\n> > +\t * metadata.\n> >  \t */\n> > -\tif (properties.contains(properties::Rotation))\n> > -\t\torientation_ = properties.get(properties::Rotation);\n> > +\tif (properties.contains(properties::Rotation)) {\n> > +\t\tint rotation = properties.get(properties::Rotation);\n> > +\t\torientation_ = (360 - rotation) % 360;\n> \n> The % 360 'should' not be necessary, but I guess it doesn't hurt.\n\nWithout % 360 a 0° rotation will be translated to 360°, not 0°.\n\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> > +\t}\n> >\n> >  \tint ret = camera_->acquire();\n> >  \tif (ret) {","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 2C48CBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Sep 2020 11:11:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B2B0F62B90;\n\tWed,  9 Sep 2020 13:11:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 31E2860534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Sep 2020 13:11:06 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2291339;\n\tWed,  9 Sep 2020 13:11:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BzVagcCk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1599649864;\n\tbh=ztFkjA3m7e4kQGf0MRfXisRgEnwr+WWlEWIg3nLoElU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BzVagcCkfXpwmcSlIXZM6+XdyrarJ5VzCFNg3rb2D8VrRqVtT3HWJwHqzyTtaFyMC\n\tpECs12JBocUB3ft3LYE7nV5rftiyLQn52X+oKJ/JpI+73nefb5yuGhMrn5mkAVejPe\n\teT3l3FYjrlOfFjSp5Fdf4K41jCEaOJpDzez+xf6E=","Date":"Wed, 9 Sep 2020 14:10:38 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200909111038.GB3931@pendragon.ideasonboard.com>","References":"<20200909104754.25940-1-email@uajain.com>\n\t<20200909110133.35eri5yyaav3rumo@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200909110133.35eri5yyaav3rumo@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":12392,"web_url":"https://patchwork.libcamera.org/comment/12392/","msgid":"<20200909124143.fzb3oxa4oxmfbgv6@uno.localdomain>","date":"2020-09-09T12:41:43","subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Sep 09, 2020 at 02:10:38PM +0300, Laurent Pinchart wrote:\n> On Wed, Sep 09, 2020 at 01:01:33PM +0200, Jacopo Mondi wrote:\n> > Hi Umang,\n> >  sorry I got late on v1\n> >\n> > On Wed, Sep 09, 2020 at 04:17:54PM +0530, Umang Jain wrote:\n> > > Android's orientation metadata cannot have identical numerical\n> > > value to libcamera's rotation property. This is due to the fact\n> > > that libcamera's rotation property specify the correction angle\n> >\n> > specifies\n> >\n> > > in anticlockwise direction whereas Android's orientation metadata\n> > > specifies the value in clockwise direction. Fix that by computing\n> > > corresponding value for clockwise direction from libcamera's rotation\n> > > property.\n> >\n> > We used 'counterclockwise', but I think it's the same\n>\n> Seems anticlockwise is UK English and counterclockwise US English :-)\n>\n> > > Signed-off-by: Umang Jain <email@uajain.com>\n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  src/android/camera_device.cpp | 15 ++++++++++-----\n> > >  1 file changed, 10 insertions(+), 5 deletions(-)\n> > >\n> > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > > index 2582991..8be846b 100644\n> > > --- a/src/android/camera_device.cpp\n> > > +++ b/src/android/camera_device.cpp\n> > > @@ -265,12 +265,17 @@ int CameraDevice::initialize()\n> > >  \t}\n> > >\n> > >  \t/*\n> > > -\t * The Android orientation metadata and libcamera rotation property are\n> > > -\t * defined differently but have identical numerical values for Android\n> > > -\t * devices such as phones and tablets.\n> > > +\t * The Android orientation metadata specifies its rotation correction\n> > > +\t * value in clockwise direction whereas libcamera specifies the\n> > > +\t * rotation property in anticlockwise direction. Read the libcamera's\n> > > +\t * rotation property (anticlockwise) and compute the corresponding\n> > > +\t * value for clockwise direction as required by the Android orientation\n> > > +\t * metadata.\n> > >  \t */\n> > > -\tif (properties.contains(properties::Rotation))\n> > > -\t\torientation_ = properties.get(properties::Rotation);\n> > > +\tif (properties.contains(properties::Rotation)) {\n> > > +\t\tint rotation = properties.get(properties::Rotation);\n> > > +\t\torientation_ = (360 - rotation) % 360;\n> >\n> > The % 360 'should' not be necessary, but I guess it doesn't hurt.\n>\n> Without % 360 a 0° rotation will be translated to 360°, not 0°.\n>\n\nAh ups. I was thinking about the fact we refuse 360 rotations in\nkernel\n\nfrom v4l2_fwnode_device_parse():\n\n\tprops->rotation = V4L2_FWNODE_PROPERTY_UNSET;\n\tret = fwnode_property_read_u32(fwnode, \"rotation\", &val);\n\tif (!ret) {\n\t\tif (val >= 360) {\n\t\t\tdev_warn(dev, \"Unsupported device rotation: %u\\n\", val);\n\t\t\treturn -EINVAL;\n\t\t}\n\n\t\tprops->rotation = val;\n\t\tdev_dbg(dev, \"device rotation: %u\\n\", val);\n\t}\n\nbut yes, 360 - 0 = 360 :)\n\n\n> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> >\n> > > +\t}\n> > >\n> > >  \tint ret = camera_->acquire();\n> > >  \tif (ret) {\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 46360BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Sep 2020 12:37:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A63FF62CBA;\n\tWed,  9 Sep 2020 14:37:57 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F03C160534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Sep 2020 14:37:55 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id EA1CA60005;\n\tWed,  9 Sep 2020 12:37:54 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Wed, 9 Sep 2020 14:41:43 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200909124143.fzb3oxa4oxmfbgv6@uno.localdomain>","References":"<20200909104754.25940-1-email@uajain.com>\n\t<20200909110133.35eri5yyaav3rumo@uno.localdomain>\n\t<20200909111038.GB3931@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200909111038.GB3931@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] android: camera_device: Fix value\n\tof orientation metadata","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]