Show a patch.

GET /api/patches/4169/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 4169,
    "url": "https://patchwork.libcamera.org/api/patches/4169/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/4169/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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-3-jacopo@jmondi.org>",
    "date": "2020-06-23T16:55:47",
    "name": "[libcamera-devel,22/25] media: ov5647: Support V4L2_CID_PIXEL_RATE",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "bb3a90a43eeb33ecce0a768114485aeadd560eb7",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/4169/mbox/",
    "series": [
        {
            "id": 1030,
            "url": "https://patchwork.libcamera.org/api/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/4169/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/4169/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 01E5B60103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 18:52:50 +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 C5874200008;\n\tTue, 23 Jun 2020 16:52:46 +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:47 +0200",
        "Message-Id": "<20200623165550.45835-3-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 22/25] media: ov5647: Support\n\tV4L2_CID_PIXEL_RATE",
        "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:52:50 -0000"
    },
    "content": "From: Dave Stevenson <dave.stevenson@raspberrypi.com>\n\nClients need to know the pixel rate in order to compute exposure\nand frame rate values. Advertise it.\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 | 40 +++++++++++++++++++++++++++++++-------\n 1 file changed, 33 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c\nindex 35865e56de5f9..218576a05e66b 100644\n--- a/drivers/media/i2c/ov5647.c\n+++ b/drivers/media/i2c/ov5647.c\n@@ -76,6 +76,7 @@ struct regval_list {\n struct ov5647_mode {\n \tstruct v4l2_mbus_framefmt\tformat;\n \tstruct v4l2_rect\t\tcrop;\n+\tu64\t\t\t\tpixel_rate;\n \tstruct regval_list\t\t*reg_list;\n \tunsigned int\t\t\tnum_regs;\n };\n@@ -97,6 +98,7 @@ struct ov5647 {\n \tstruct v4l2_ctrl_handler\tctrls;\n \tstruct ov5647_mode\t\t*mode;\n \tstruct ov5647_mode\t\t*current_mode;\n+\tstruct v4l2_ctrl\t\t*pixel_rate;\n };\n \n static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd)\n@@ -583,6 +585,7 @@ static struct ov5647_mode ov5647_sbggr8_modes[] = {\n \t\t\t.width\t\t= 1280,\n \t\t\t.height\t\t= 960,\n \t\t},\n+\t\t.pixel_rate\t= 77291670,\n \t\t.reg_list\t= ov5647_640x480_sbggr8,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_640x480_sbggr8)\n \t},\n@@ -604,6 +607,7 @@ static struct ov5647_mode ov5647_sbggr10_modes[] = {\n \t\t\t.width\t\t= 2592,\n \t\t\t.height\t\t= 1944\n \t\t},\n+\t\t.pixel_rate\t= 87500000,\n \t\t.reg_list\t= ov5647_2592x1944_sbggr10,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_2592x1944_sbggr10)\n \t},\n@@ -622,6 +626,7 @@ static struct ov5647_mode ov5647_sbggr10_modes[] = {\n \t\t\t.width\t\t= 1928,\n \t\t\t.height\t\t= 1080,\n \t\t},\n+\t\t.pixel_rate\t= 81666700,\n \t\t.reg_list\t= ov5647_1080p30_sbggr10,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_1080p30_sbggr10)\n \t},\n@@ -640,6 +645,7 @@ static struct ov5647_mode ov5647_sbggr10_modes[] = {\n \t\t\t.width\t\t= 2592,\n \t\t\t.height\t\t= 1944,\n \t\t},\n+\t\t.pixel_rate\t= 81666700,\n \t\t.reg_list\t= ov5647_2x2binned_sbggr10,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_2x2binned_sbggr10)\n \t},\n@@ -658,6 +664,7 @@ static struct ov5647_mode ov5647_sbggr10_modes[] = {\n \t\t\t.width\t\t= 2560,\n \t\t\t.height\t\t= 1920,\n \t\t},\n+\t\t.pixel_rate\t= 55000000,\n \t\t.reg_list\t= ov5647_640x480_sbggr10,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_640x480_sbggr10)\n \t},\n@@ -1094,6 +1101,10 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,\n \t/* Update the sensor mode and apply at it at streamon time. */\n \tmutex_lock(&sensor->lock);\n \tsensor->mode = mode;\n+\n+\t__v4l2_ctrl_modify_range(sensor->pixel_rate, mode->pixel_rate,\n+\t\t\t\t mode->pixel_rate, 1, mode->pixel_rate);\n+\n \t*fmt = mode->format;\n \tmutex_unlock(&sensor->lock);\n \n@@ -1295,6 +1306,9 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)\n \t\treturn  ov5647_s_analogue_gain(sd, ctrl->val);\n \tcase V4L2_CID_EXPOSURE:\n \t\treturn ov5647_s_exposure(sd, ctrl->val);\n+\tcase V4L2_CID_PIXEL_RATE:\n+\t\t/* Read-only, but we adjust it based on mode. */\n+\t\treturn 0;\n \tdefault:\n \t\tdev_info(&client->dev,\n \t\t\t \"Control (id:0x%x, val:0x%x) not supported\\n\",\n@@ -1313,7 +1327,7 @@ static int ov5647_init_controls(struct ov5647 *sensor)\n {\n \tstruct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);\n \n-\tv4l2_ctrl_handler_init(&sensor->ctrls, 5);\n+\tv4l2_ctrl_handler_init(&sensor->ctrls, 6);\n \n \tv4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n \t\t\t  V4L2_CID_AUTOGAIN, 0, 1, 1, 0);\n@@ -1333,17 +1347,29 @@ static int ov5647_init_controls(struct ov5647 *sensor)\n \tv4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n \t\t\t  V4L2_CID_ANALOGUE_GAIN, 16, 1023, 1, 32);\n \n-\tif (sensor->ctrls.error) {\n-\t\tdev_err(&client->dev, \"%s Controls initialization failed (%d)\\n\",\n-\t\t\t__func__, sensor->ctrls.error);\n-\t\tv4l2_ctrl_handler_free(&sensor->ctrls);\n+\t/* By default, PIXEL_RATE is read only, but it does change per mode */\n+\tsensor->pixel_rate = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,\n+\t\t\t\t\t       V4L2_CID_PIXEL_RATE,\n+\t\t\t\t\t       sensor->mode->pixel_rate,\n+\t\t\t\t\t       sensor->mode->pixel_rate, 1,\n+\t\t\t\t\t       sensor->mode->pixel_rate);\n+\tif (!sensor->pixel_rate)\n+\t\tgoto handler_free;\n+\tsensor->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;\n \n-\t\treturn sensor->ctrls.error;\n-\t}\n+\tif (sensor->ctrls.error)\n+\t\tgoto handler_free;\n \n \tsensor->sd.ctrl_handler = &sensor->ctrls;\n \n \treturn 0;\n+\n+handler_free:\n+\tdev_err(&client->dev, \"%s Controls initialization failed (%d)\\n\",\n+\t\t__func__, sensor->ctrls.error);\n+\tv4l2_ctrl_handler_free(&sensor->ctrls);\n+\n+\treturn sensor->ctrls.error;\n }\n \n static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)\n",
    "prefixes": [
        "libcamera-devel",
        "22/25"
    ]
}