[{"id":22043,"web_url":"https://patchwork.libcamera.org/comment/22043/","msgid":"<164241847220.10801.13869875671718114811@Monstersaurus>","date":"2022-01-17T11:21:12","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor:\n\tClear camera flips after opening the device","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting David Plowman (2022-01-13 14:15:57)\n> We clear the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls immediately\n> after opening the camera device. This means the camera's Bayer format\n> and mbus codes will be in the sensor's \"native\" order, and we document\n> this to be the case so that it can be relied upon.\n> \n> Clearing the flips is harmless where sensor flips do not affect the\n> Bayer order.\n> \n> This also fixes a bug in the Raspberry Pi pipeline handler where the\n> native Bayer order was being computed wrongly, but the new behaviour\n> here will be helpful to other pipeline handlers too. A subsequent\n> commit will tidy up the Raspberry Pi pipeline handler in this area as\n> it can now be simplified.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Fixes: 83a512816189 (pipeline: raspberrypi: Convert the pipeline handler to use media controller)\n\nFixes: 83a512816189 (\"pipeline: raspberrypi: Convert the pipeline handler to use media controller\")\n\nFixes tags usually have the $SUBJECT of the fix in quotes I believe.\n\nIt's defined by the kernel at:\n\nhttps://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes\n\nI don't think that needs a resubmit by itself though, just highlighting\nfor awareness, as I'm sure I've seen more fixes tags without quotes on\nthe list.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/camera_sensor.cpp | 16 ++++++++++++++++\n>  1 file changed, 16 insertions(+)\n> \n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index c3999d35..64f7f12c 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -107,6 +107,17 @@ int CameraSensor::init()\n>         if (ret < 0)\n>                 return ret;\n>  \n> +       /*\n> +        * Clear any flips to be sure we get the \"native\" Bayer order. This is\n> +        * harmless for sensors where the flips don't affect the Bayer order.\n> +        */\n> +       ControlList ctrls(subdev_->controls());\n> +       if (subdev_->controls().find(V4L2_CID_HFLIP) != subdev_->controls().end())\n> +               ctrls.set(V4L2_CID_HFLIP, 0);\n> +       if (subdev_->controls().find(V4L2_CID_VFLIP) != subdev_->controls().end())\n> +               ctrls.set(V4L2_CID_VFLIP, 0);\n> +       subdev_->setControls(&ctrls);\n> +\n>         /* Enumerate, sort and cache media bus codes and sizes. */\n>         formats_ = subdev_->formats(pad_);\n>         if (formats_.empty()) {\n> @@ -461,6 +472,11 @@ int CameraSensor::initProperties()\n>  /**\n>   * \\fn CameraSensor::mbusCodes()\n>   * \\brief Retrieve the media bus codes supported by the camera sensor\n> + *\n> + * Any Bayer formats are listed using the sensor's native Bayer order,\n> + * that is, with the effect of V4L2_CID_HFLIP and V4L2_CID_VFLIP undone\n> + * (where these controls exist).\n> + *\n>   * \\return The supported media bus codes sorted in increasing order\n>   */\n>  \n> -- \n> 2.30.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 70F07BE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Jan 2022 11:21:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D69C56021A;\n\tMon, 17 Jan 2022 12:21:16 +0100 (CET)","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 1035460217\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jan 2022 12:21:15 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AA4D6596;\n\tMon, 17 Jan 2022 12:21:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"oQhosRmF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1642418474;\n\tbh=+VKqa8JOZwjynPoUlhnXRFeqCclXCcJMoy1OQ2cRQ8U=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=oQhosRmF7kkhpeeL4W6pQNCEt/8/PVon9u2JDbP/lqFnIv9cQ+UPpd7Bivd6M2/7P\n\tdwcaTAAdVXKn9UfyRt6hhSS1WkhfAN6ZvFxt9Jh6M7FIwOoz8/3ANTiz9HgjxC7x+V\n\tue/cKhT/HpeTu8TmZbvmVWlcP3z/ULJrj6Z8LH70=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220113141558.5805-2-david.plowman@raspberrypi.com>","References":"<20220113141558.5805-1-david.plowman@raspberrypi.com>\n\t<20220113141558.5805-2-david.plowman@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 17 Jan 2022 11:21:12 +0000","Message-ID":"<164241847220.10801.13869875671718114811@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor:\n\tClear camera flips after opening the device","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22045,"web_url":"https://patchwork.libcamera.org/comment/22045/","msgid":"<CAEmqJPpFQ3Sv1N-F36kgYnNsjsegfED0=mH+_hr29nhWA7Qp6g@mail.gmail.com>","date":"2022-01-17T14:57:34","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor:\n\tClear camera flips after opening the device","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for your patch.\n\nOn Thu, 13 Jan 2022 at 14:16, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\n> We clear the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls immediately\n> after opening the camera device. This means the camera's Bayer format\n> and mbus codes will be in the sensor's \"native\" order, and we document\n> this to be the case so that it can be relied upon.\n>\n> Clearing the flips is harmless where sensor flips do not affect the\n> Bayer order.\n>\n> This also fixes a bug in the Raspberry Pi pipeline handler where the\n> native Bayer order was being computed wrongly, but the new behaviour\n> here will be helpful to other pipeline handlers too. A subsequent\n> commit will tidy up the Raspberry Pi pipeline handler in this area as\n> it can now be simplified.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Fixes: 83a512816189 (pipeline: raspberrypi: Convert the pipeline handler\n> to use media controller)\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n---\n>  src/libcamera/camera_sensor.cpp | 16 ++++++++++++++++\n>  1 file changed, 16 insertions(+)\n>\n> diff --git a/src/libcamera/camera_sensor.cpp\n> b/src/libcamera/camera_sensor.cpp\n> index c3999d35..64f7f12c 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -107,6 +107,17 @@ int CameraSensor::init()\n>         if (ret < 0)\n>                 return ret;\n>\n> +       /*\n> +        * Clear any flips to be sure we get the \"native\" Bayer order.\n> This is\n> +        * harmless for sensors where the flips don't affect the Bayer\n> order.\n> +        */\n> +       ControlList ctrls(subdev_->controls());\n> +       if (subdev_->controls().find(V4L2_CID_HFLIP) !=\n> subdev_->controls().end())\n> +               ctrls.set(V4L2_CID_HFLIP, 0);\n> +       if (subdev_->controls().find(V4L2_CID_VFLIP) !=\n> subdev_->controls().end())\n> +               ctrls.set(V4L2_CID_VFLIP, 0);\n> +       subdev_->setControls(&ctrls);\n> +\n>         /* Enumerate, sort and cache media bus codes and sizes. */\n>         formats_ = subdev_->formats(pad_);\n>         if (formats_.empty()) {\n> @@ -461,6 +472,11 @@ int CameraSensor::initProperties()\n>  /**\n>   * \\fn CameraSensor::mbusCodes()\n>   * \\brief Retrieve the media bus codes supported by the camera sensor\n> + *\n> + * Any Bayer formats are listed using the sensor's native Bayer order,\n> + * that is, with the effect of V4L2_CID_HFLIP and V4L2_CID_VFLIP undone\n> + * (where these controls exist).\n> + *\n>   * \\return The supported media bus codes sorted in increasing order\n>   */\n>\n> --\n> 2.30.2\n>\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 423E4BE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Jan 2022 14:57:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 71BE660931;\n\tMon, 17 Jan 2022 15:57:53 +0100 (CET)","from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com\n\t[IPv6:2a00:1450:4864:20::12a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E3E160217\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jan 2022 15:57:50 +0100 (CET)","by mail-lf1-x12a.google.com with SMTP id x11so32883847lfa.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Jan 2022 06:57:50 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"keKi4bA0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=lJiLOw+8E015fw2CD7G4UcGZJ8bSw0FmiKu0H/wV/dY=;\n\tb=keKi4bA0BLHbauSQFdFQCXUSS38kTaheCuNCLDGyax3I7ichQHyhytC2z7WAx+Ih+Z\n\t21jlEF8qTBD7z1V5ojhRbTvo59685TXuBaOGDCc18d1AcBK+iN6+k+8YxxSm+jBDFwCr\n\tmdQVNV1LsrjhJQ4if6xjWhyIzRAAL5/bW23MqtC960dQ9VXQwdQqJn2ShI2Om0Y/BGVt\n\tutZenb9nAeUsmVYo3ANRl/s/O6ldMMns2xNQm6a6c2NU87aErLWTMdj7jFwuXvrsjeU/\n\tCe1wSaoDkTuWqgqKSJbKRaKoy22tSTBdVaesqP2RNg5uMVuQ3Kceh+goxs5zAoBPrGjy\n\tfr9g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=lJiLOw+8E015fw2CD7G4UcGZJ8bSw0FmiKu0H/wV/dY=;\n\tb=6S+4kljWP657bDvc0TRM45aJcKshvokA+/5yxGWC1oxfYeiSrB9PRwXNSPO3C3ItOb\n\tawePBx0qpCIwpfDjhD/7SGlzzssTrO1CJiNjfOHvIaKLK+20d/z7FkLg7ROoHe8CqyJ8\n\t75TxZ9i9s4U1Fxd4L9XRd+clxXOyaVTkfGVIWE8z/+ONdtPZGhpvnb0CfIKMhOQOvG6v\n\tokCzdmnemxKh7cPwxFy6KUAOvq6iZQophLhszzTvMae45xi94Ef9facUkYE+shGhs0hP\n\tgiCEHLFrZHxilbKKWaFkj4qrXEgv/DwBBH6ZXHdf0+XnWjM6be+r2b1RlSgUiH0dyhfG\n\tYFpA==","X-Gm-Message-State":"AOAM531FkaXQmHm9ztei+gSMNLZbaPIAMNsdmjBSDaKjJLzHRTmAqfBJ\n\tu8F+KO2cmPhnEaI5gvl3FsJxmoQc9ooAowUsP4rInw==","X-Google-Smtp-Source":"ABdhPJyPX/ftrgJp8L9mAOH2Nj7IefIaHGongz9eM1Z+dTkyxR1cVtbdjqmV6bj7JKpwKZhOThBJ3Buz3se+zFuE0nM=","X-Received":"by 2002:a05:6512:a8f:: with SMTP id\n\tm15mr17106620lfu.687.1642431470095; \n\tMon, 17 Jan 2022 06:57:50 -0800 (PST)","MIME-Version":"1.0","References":"<20220113141558.5805-1-david.plowman@raspberrypi.com>\n\t<20220113141558.5805-2-david.plowman@raspberrypi.com>","In-Reply-To":"<20220113141558.5805-2-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Mon, 17 Jan 2022 14:57:34 +0000","Message-ID":"<CAEmqJPpFQ3Sv1N-F36kgYnNsjsegfED0=mH+_hr29nhWA7Qp6g@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"00000000000057e57b05d5c860ff\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor:\n\tClear camera flips after opening the device","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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]