Show a patch.

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

{
    "id": 4163,
    "url": "https://patchwork.libcamera.org/api/patches/4163/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/4163/",
    "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": "<20200623164911.45147-1-jacopo@jmondi.org>",
    "date": "2020-06-23T16:49:08",
    "name": "[libcamera-devel,16/25] media: ov5647: Add support for get_selection()",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "920809c0bce344b192df4f201ffcbc699cca6063",
    "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/4163/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/4163/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/4163/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 082B260103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 18:46:14 +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 relay11.mail.gandi.net (Postfix) with ESMTPSA id 030E0100006;\n\tTue, 23 Jun 2020 16:46:07 +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:49:08 +0200",
        "Message-Id": "<20200623164911.45147-1-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 16/25] media: ov5647: Add support for\n\tget_selection()",
        "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:46:14 -0000"
    },
    "content": "From: Dave Stevenson <dave.stevenson@raspberrypi.com>\n\nSupport the get_selection() pad operation to report the device\nfull pixel array size, the currently applied analogue crop rectangle and\nthe active pixel array dimensions.\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 | 95 ++++++++++++++++++++++++++++----------\n 1 file changed, 71 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c\nindex a801ed0249aad..3757f0b10fe93 100644\n--- a/drivers/media/i2c/ov5647.c\n+++ b/drivers/media/i2c/ov5647.c\n@@ -59,25 +59,14 @@\n #define VAL_TERM 0xfe\n #define REG_DLY  0xffff\n \n-#define OV5647_ROW_START\t\t0x01\n-#define OV5647_ROW_START_MIN\t\t0\n-#define OV5647_ROW_START_MAX\t\t2004\n-#define OV5647_ROW_START_DEF\t\t54\n-\n-#define OV5647_COLUMN_START\t\t0x02\n-#define OV5647_COLUMN_START_MIN\t\t0\n-#define OV5647_COLUMN_START_MAX\t\t2750\n-#define OV5647_COLUMN_START_DEF\t\t16\n-\n-#define OV5647_WINDOW_HEIGHT\t\t0x03\n-#define OV5647_WINDOW_HEIGHT_MIN\t2\n-#define OV5647_WINDOW_HEIGHT_MAX\t2006\n-#define OV5647_WINDOW_HEIGHT_DEF\t1944\n-\n-#define OV5647_WINDOW_WIDTH\t\t0x04\n-#define OV5647_WINDOW_WIDTH_MIN\t\t2\n-#define OV5647_WINDOW_WIDTH_MAX\t\t2752\n-#define OV5647_WINDOW_WIDTH_DEF\t\t2592\n+/* OV5647 native and active pixel array size */\n+#define OV5647_NATIVE_WIDTH\t\t2624U\n+#define OV5647_NATIVE_HEIGHT\t\t1956U\n+\n+#define OV5647_PIXEL_ARRAY_LEFT\t\t16U\n+#define OV5647_PIXEL_ARRAY_TOP\t\t16U\n+#define OV5647_PIXEL_ARRAY_WIDTH\t2592U\n+#define OV5647_PIXEL_ARRAY_HEIGHT\t1944U\n \n struct regval_list {\n \tu16 addr;\n@@ -86,6 +75,7 @@ struct regval_list {\n \n struct ov5647_mode {\n \tstruct v4l2_mbus_framefmt\tformat;\n+\tstruct v4l2_rect\t\tcrop;\n \tstruct regval_list\t\t*reg_list;\n \tunsigned int\t\t\tnum_regs;\n };\n@@ -224,6 +214,12 @@ static struct ov5647_mode ov5647_8bit_modes[] = {\n \t\t\t.width\t\t= 640,\n \t\t\t.height\t\t= 480\n \t\t},\n+\t\t.crop = {\n+\t\t\t.left\t\t= 0,\n+\t\t\t.top\t\t= 0,\n+\t\t\t.width\t\t= 1280,\n+\t\t\t.height\t\t= 960,\n+\t\t},\n \t\t.reg_list\t= ov5647_640x480,\n \t\t.num_regs\t= ARRAY_SIZE(ov5647_640x480)\n \t},\n@@ -412,7 +408,7 @@ static int set_sw_standby(struct v4l2_subdev *sd, bool standby)\n static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)\n {\n \tstruct i2c_client *client = v4l2_get_subdevdata(sd);\n-\tstruct ov5647 *ov5647 = to_state(sd);\n+\tstruct ov5647 *sensor = to_sensor(sd);\n \tint ret = 0;\n \n \tmutex_lock(&sensor->lock);\n@@ -507,6 +503,20 @@ static const struct v4l2_subdev_core_ops ov5647_subdev_core_ops = {\n #endif\n };\n \n+static const struct v4l2_rect *\n+__ov5647_get_pad_crop(struct ov5647 *ov5647, struct v4l2_subdev_pad_config *cfg,\n+\t\t      unsigned int pad, enum v4l2_subdev_format_whence which)\n+{\n+\tswitch (which) {\n+\tcase V4L2_SUBDEV_FORMAT_TRY:\n+\t\treturn v4l2_subdev_get_try_crop(&ov5647->sd, cfg, pad);\n+\tcase V4L2_SUBDEV_FORMAT_ACTIVE:\n+\t\treturn &ov5647->mode->crop;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)\n {\n \tstruct ov5647 *sensor = to_sensor(sd);\n@@ -577,11 +587,48 @@ static int ov5647_set_get_fmt(struct v4l2_subdev *sd,\n \treturn 0;\n }\n \n+static int ov5647_get_selection(struct v4l2_subdev *sd,\n+\t\t\t\tstruct v4l2_subdev_pad_config *cfg,\n+\t\t\t\tstruct v4l2_subdev_selection *sel)\n+{\n+\tswitch (sel->target) {\n+\tcase V4L2_SEL_TGT_CROP: {\n+\t\tstruct ov5647 *sensor = to_sensor(sd);\n+\n+\t\tmutex_lock(&sensor->lock);\n+\t\tsel->r = *__ov5647_get_pad_crop(sensor, cfg, sel->pad,\n+\t\t\t\t\t\tsel->which);\n+\t\tmutex_unlock(&sensor->lock);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tcase V4L2_SEL_TGT_NATIVE_SIZE:\n+\t\tsel->r.top = 0;\n+\t\tsel->r.left = 0;\n+\t\tsel->r.width = OV5647_NATIVE_WIDTH;\n+\t\tsel->r.height = OV5647_NATIVE_HEIGHT;\n+\n+\t\treturn 0;\n+\n+\tcase V4L2_SEL_TGT_CROP_DEFAULT:\n+\t\tsel->r.top = OV5647_PIXEL_ARRAY_TOP;\n+\t\tsel->r.left = OV5647_PIXEL_ARRAY_LEFT;\n+\t\tsel->r.width = OV5647_PIXEL_ARRAY_WIDTH;\n+\t\tsel->r.height = OV5647_PIXEL_ARRAY_HEIGHT;\n+\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n static const struct v4l2_subdev_pad_ops ov5647_subdev_pad_ops = {\n \t.enum_mbus_code\t\t= ov5647_enum_mbus_code,\n \t.enum_frame_size\t= ov5647_enum_frame_size,\n \t.set_fmt\t\t= ov5647_set_get_fmt,\n \t.get_fmt\t\t= ov5647_set_get_fmt,\n+\t.get_selection\t\t= ov5647_get_selection,\n };\n \n static const struct v4l2_subdev_ops ov5647_subdev_ops = {\n@@ -626,10 +673,10 @@ static int ov5647_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)\n \tstruct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);\n \tstruct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0);\n \n-\tcrop->left = OV5647_COLUMN_START_DEF;\n-\tcrop->top = OV5647_ROW_START_DEF;\n-\tcrop->width = OV5647_WINDOW_WIDTH_DEF;\n-\tcrop->height = OV5647_WINDOW_HEIGHT_DEF;\n+\tcrop->left = OV5647_PIXEL_ARRAY_LEFT;\n+\tcrop->top = OV5647_PIXEL_ARRAY_TOP;\n+\tcrop->width = OV5647_PIXEL_ARRAY_WIDTH;\n+\tcrop->height = OV5647_PIXEL_ARRAY_HEIGHT;\n \n \t*format = OV5647_DEFAULT_FORMAT;\n \n",
    "prefixes": [
        "libcamera-devel",
        "16/25"
    ]
}