Patch Detail
Show a patch.
GET /api/1.1/patches/4172/?format=api
{ "id": 4172, "url": "https://patchwork.libcamera.org/api/1.1/patches/4172/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4172/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200623165550.45835-6-jacopo@jmondi.org>", "date": "2020-06-23T16:55:50", "name": "[libcamera-devel,25/25] media: ov5647: Advertise the correct exposure range", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "18f1df3514ba66da8fef144276472622a53a17d4", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/4172/mbox/", "series": [ { "id": 1030, "url": "https://patchwork.libcamera.org/api/1.1/series/1030/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1030", "date": "2020-06-23T10:07:50", "name": "media: ov5647: Support RaspberryPi Camera Module v1", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1030/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4172/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4172/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D1C74609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 18:53:00 +0200 (CEST)", "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 2C20F200018;\n\tTue, 23 Jun 2020 16:52:56 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "mchehab@kernel.org, sakari.ailus@linux.intel.com, hverkuil@xs4all.nl,\n\tlaurent.pinchart@ideasonboard.com, roman.kovalivskyi@globallogic.com, \n\tdave.stevenson@raspberrypi.org, naush@raspberrypi.com", "Cc": "mrodin@de.adit-jv.com, hugues.fruchet@st.com, mripard@kernel.org,\n\taford173@gmail.com, sudipi@jp.adit-jv.com, andrew_gabbasov@mentor.com,\n\terosca@de.adit-jv.com, linux-media@vger.kernel.org,\n\tlibcamera-devel@lists.libcamera.org,\n\tDave Stevenson <dave.stevenson@raspberrypi.com>,\n\tJacopo Mondi <jacopo@jmondi.org>", "Date": "Tue, 23 Jun 2020 18:55:50 +0200", "Message-Id": "<20200623165550.45835-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200623100815.10674-1-jacopo@jmondi.org>", "References": "<20200623100815.10674-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 25/25] media: ov5647: Advertise the\n\tcorrect exposure range", "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": "Tue, 23 Jun 2020 16:53:01 -0000" }, "content": "From: Dave Stevenson <dave.stevenson@raspberrypi.com>\n\nExposure is clipped by the VTS of the mode, so it needs to be updated\nwhen this is changed.\n\nSigned-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n drivers/media/i2c/ov5647.c | 41 ++++++++++++++++++++++++++++++++------\n 1 file changed, 35 insertions(+), 6 deletions(-)", "diff": "diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c\nindex 209218fb073d6..8f62415c07aad 100644\n--- a/drivers/media/i2c/ov5647.c\n+++ b/drivers/media/i2c/ov5647.c\n@@ -73,6 +73,11 @@\n #define OV5647_VBLANK_MIN\t\t4\n #define OV5647_VTS_MAX\t\t\t32767\n \n+#define OV5647_EXPOSURE_MIN\t\t4\n+#define OV5647_EXPOSURE_STEP\t\t1\n+#define OV5647_EXPOSURE_DEFAULT\t\t1000\n+#define OV5647_EXPOSURE_MAX\t\t65535\n+\n struct regval_list {\n \tu16 addr;\n \tu8 data;\n@@ -108,6 +113,7 @@ struct ov5647 {\n \tstruct v4l2_ctrl\t\t*pixel_rate;\n \tstruct v4l2_ctrl\t\t*hblank;\n \tstruct v4l2_ctrl\t\t*vblank;\n+\tstruct v4l2_ctrl\t\t*exposure;\n };\n \n static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd)\n@@ -1102,10 +1108,10 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,\n {\n \tstruct v4l2_mbus_framefmt *fmt = &format->format;\n \tstruct ov5647 *sensor = to_sensor(sd);\n+\tint hblank, exposure_max, exposure_def;\n \tstruct ov5647_mode *ov5647_mode_list;\n \tstruct ov5647_mode *mode;\n \tunsigned int num_modes;\n-\tint hblank;\n \n \t/*\n \t * Default mbus code MEDIA_BUS_FMT_SBGGR10_1X10 if the requested one\n@@ -1147,6 +1153,13 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,\n \t\t\t\t 1, mode->vts - mode->format.height);\n \t__v4l2_ctrl_s_ctrl(sensor->vblank, mode->vts - mode->format.height);\n \n+\texposure_max = mode->vts - 4;\n+\texposure_def = exposure_max < OV5647_EXPOSURE_DEFAULT ? exposure_max\n+\t\t\t\t\t\t\t : OV5647_EXPOSURE_DEFAULT;\n+\t__v4l2_ctrl_modify_range(sensor->exposure, sensor->exposure->minimum,\n+\t\t\t\t exposure_max, sensor->exposure->step,\n+\t\t\t\t exposure_def);\n+\n \t*fmt = mode->format;\n \tmutex_unlock(&sensor->lock);\n \n@@ -1329,6 +1342,18 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)\n \n \t/* v4l2_ctrl_lock() locks our own mutex */\n \n+\tif (ctrl->id == V4L2_CID_VBLANK) {\n+\t\tint exposure_max, exposure_def;\n+\n+\t\t/* Update max exposure while meeting expected vblanking */\n+\t\texposure_max = sensor->mode->format.height + ctrl->val - 4;\n+\t\texposure_def = exposure_max < OV5647_EXPOSURE_DEFAULT\n+\t\t\t ? exposure_max : OV5647_EXPOSURE_DEFAULT;\n+\t\t__v4l2_ctrl_modify_range(sensor->exposure, sensor->exposure->minimum,\n+\t\t\t\t\t exposure_max, sensor->exposure->step,\n+\t\t\t\t\t exposure_def);\n+\t}\n+\n \t/*\n \t * If the device is not powered up by the host driver do\n \t * not apply any controls to H/W at this time. Instead\n@@ -1374,9 +1399,9 @@ static const struct v4l2_ctrl_ops ov5647_ctrl_ops = {\n static int ov5647_init_controls(struct ov5647 *sensor)\n {\n \tstruct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);\n-\tint hblank;\n+\tint hblank, exposure_max, exposure_def;\n \n-\tv4l2_ctrl_handler_init(&sensor->ctrls, 8);\n+\tv4l2_ctrl_handler_init(&sensor->ctrls, 9);\n \n \tv4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n \t\t\t V4L2_CID_AUTOGAIN, 0, 1, 1, 0);\n@@ -1388,9 +1413,13 @@ static int ov5647_init_controls(struct ov5647 *sensor)\n \t\t\t V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL,\n \t\t\t 0, V4L2_EXPOSURE_MANUAL);\n \n-\t/* min: 4 lines; max: 0xffff lines; default: 1000 lines. */\n-\tv4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n-\t\t\t V4L2_CID_EXPOSURE, 4, 65535, 1, 1000);\n+\texposure_max = sensor->mode->vts - 4;\n+\texposure_def = exposure_max < OV5647_EXPOSURE_DEFAULT ? exposure_max\n+\t\t\t\t\t\t\t : OV5647_EXPOSURE_DEFAULT;\n+\tsensor->exposure = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n+\t\t\t\t\t V4L2_CID_EXPOSURE, OV5647_EXPOSURE_MIN,\n+\t\t\t\t\t exposure_max, OV5647_EXPOSURE_STEP,\n+\t\t\t\t\t exposure_def);\n \n \t/* min: 16 = 1.0x; max (10 bits); default: 32 = 2.0x. */\n \tv4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n", "prefixes": [ "libcamera-devel", "25/25" ] }