Show a patch.

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

{
    "id": 4162,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/4162/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/4162/",
    "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": "<20200623164224.44476-5-jacopo@jmondi.org>",
    "date": "2020-06-23T16:42:24",
    "name": "[libcamera-devel,15/25] media: ov5647: Break out format handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "856090930417620af3942dca7fd9cf5fe60969e4",
    "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/4162/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/4162/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/4162/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "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 B577360103\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 18:39:25 +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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 327ED60006;\n\tTue, 23 Jun 2020 16:39:22 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.34.118.233",
        "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, Jacopo Mondi <jacopo@jmondi.org>",
        "Date": "Tue, 23 Jun 2020 18:42:24 +0200",
        "Message-Id": "<20200623164224.44476-5-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 15/25] media: ov5647: Break out format\n\thandling",
        "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:39:25 -0000"
    },
    "content": "Break format handling out from the main driver structure.\n\nThis commit prepares for the introduction of more sensor formats and\nresolutions by instrumenting the existing operation to work on multiple\nmodes instead of assuming a single one supported.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n drivers/media/i2c/ov5647.c | 84 +++++++++++++++++++++++++++-----------\n 1 file changed, 61 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c\nindex 03f4f1a257ecd..a801ed0249aad 100644\n--- a/drivers/media/i2c/ov5647.c\n+++ b/drivers/media/i2c/ov5647.c\n@@ -84,18 +84,28 @@ struct regval_list {\n \tu8 data;\n };\n \n+struct ov5647_mode {\n+\tstruct v4l2_mbus_framefmt\tformat;\n+\tstruct regval_list\t\t*reg_list;\n+\tunsigned int\t\t\tnum_regs;\n+};\n+\n+struct ov5647_format_list {\n+\tunsigned int\t\t\tmbus_code;\n+\tstruct ov5647_mode\t\t*modes;\n+\tunsigned int\t\t\tnum_modes;\n+};\n+\n struct ov5647 {\n \tstruct v4l2_subdev\t\tsd;\n \tstruct media_pad\t\tpad;\n \tstruct mutex\t\t\tlock;\n-\tstruct v4l2_mbus_framefmt\tformat;\n-\tunsigned int\t\t\twidth;\n-\tunsigned int\t\t\theight;\n \tint\t\t\t\tpower_count;\n \tstruct clk\t\t\t*xclk;\n \tstruct gpio_desc\t\t*pwdn;\n \tbool\t\t\t\tclock_ncont;\n \tstruct v4l2_ctrl_handler\tctrls;\n+\tstruct ov5647_mode\t\t*mode;\n };\n \n static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd)\n@@ -205,6 +215,33 @@ static struct regval_list ov5647_640x480[] = {\n \t{0x0100, 0x01},\n };\n \n+static struct ov5647_mode ov5647_8bit_modes[] = {\n+\t{\n+\t\t.format\t= {\n+\t\t\t.code\t\t= MEDIA_BUS_FMT_SBGGR8_1X8,\n+\t\t\t.colorspace\t= V4L2_COLORSPACE_SRGB,\n+\t\t\t.field\t\t= V4L2_FIELD_NONE,\n+\t\t\t.width\t\t= 640,\n+\t\t\t.height\t\t= 480\n+\t\t},\n+\t\t.reg_list\t= ov5647_640x480,\n+\t\t.num_regs\t= ARRAY_SIZE(ov5647_640x480)\n+\t},\n+};\n+\n+static const struct ov5647_format_list ov5647_formats[] = {\n+\t{\n+\t\t.mbus_code\t= MEDIA_BUS_FMT_SBGGR8_1X8,\n+\t\t.modes\t\t= ov5647_8bit_modes,\n+\t\t.num_modes\t= ARRAY_SIZE(ov5647_8bit_modes),\n+\t},\n+};\n+\n+#define OV5647_NUM_FORMATS\t(ARRAY_SIZE(ov5647_formats))\n+\n+#define OV5647_DEFAULT_MODE\t(&ov5647_formats[0].modes[0])\n+#define OV5647_DEFAULT_FORMAT\t(ov5647_formats[0].modes[0].format)\n+\n static int ov5647_write(struct v4l2_subdev *sd, u16 reg, u8 val)\n {\n \tunsigned char data[3] = { reg >> 8, reg & 0xff, val};\n@@ -282,8 +319,7 @@ static int ov5647_set_mode(struct v4l2_subdev *sd)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tret = ov5647_write_array(sd, ov5647_640x480,\n-\t\t\t\t ARRAY_SIZE(ov5647_640x480));\n+\tret = ov5647_write_array(sd, sensor->mode->reg_list, sensor->mode->num_regs);\n \tif (ret < 0) {\n \t\tdev_err(&client->dev, \"write sensor default regs error\\n\");\n \t\treturn ret;\n@@ -494,10 +530,10 @@ static int ov5647_enum_mbus_code(struct v4l2_subdev *sd,\n \t\t\t\t struct v4l2_subdev_pad_config *cfg,\n \t\t\t\t struct v4l2_subdev_mbus_code_enum *code)\n {\n-\tif (code->index > 0)\n+\tif (code->index >= OV5647_NUM_FORMATS)\n \t\treturn -EINVAL;\n \n-\tcode->code = MEDIA_BUS_FMT_SBGGR8_1X8;\n+\tcode->code = ov5647_formats[code->index].mbus_code;\n \n \treturn 0;\n }\n@@ -506,16 +542,24 @@ static int ov5647_enum_frame_size(struct v4l2_subdev *sd,\n \t\t\t\t  struct v4l2_subdev_pad_config *cfg,\n \t\t\t\t  struct v4l2_subdev_frame_size_enum *fse)\n {\n-\tif (fse->index)\n+\tconst struct v4l2_mbus_framefmt *fmt;\n+\tunsigned int i = 0;\n+\n+\tfor (; i < OV5647_NUM_FORMATS; ++i) {\n+\t\tif (ov5647_formats[i].mbus_code == fse->code)\n+\t\t\tbreak;\n+\t}\n+\tif (i == OV5647_NUM_FORMATS)\n \t\treturn -EINVAL;\n \n-\tif (fse->code != MEDIA_BUS_FMT_SBGGR8_1X8)\n+\tif (fse->index >= ov5647_formats[i].num_modes)\n \t\treturn -EINVAL;\n \n-\tfse->min_width = 640;\n-\tfse->max_width = 640;\n-\tfse->min_height = 480;\n-\tfse->max_height = 480;\n+\tfmt = &ov5647_formats[i].modes[fse->index].format;\n+\tfse->min_width = fmt->width;\n+\tfse->max_width = fmt->width;\n+\tfse->min_height = fmt->height;\n+\tfse->max_height = fmt->height;\n \n \treturn 0;\n }\n@@ -528,11 +572,7 @@ static int ov5647_set_get_fmt(struct v4l2_subdev *sd,\n \n \t/* Only one format is supported, so return that. */\n \tmemset(fmt, 0, sizeof(*fmt));\n-\tfmt->code = MEDIA_BUS_FMT_SBGGR8_1X8;\n-\tfmt->colorspace = V4L2_COLORSPACE_SRGB;\n-\tfmt->field = V4L2_FIELD_NONE;\n-\tfmt->width = 640;\n-\tfmt->height = 480;\n+\t*fmt = OV5647_DEFAULT_FORMAT;\n \n \treturn 0;\n }\n@@ -591,11 +631,7 @@ static int ov5647_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)\n \tcrop->width = OV5647_WINDOW_WIDTH_DEF;\n \tcrop->height = OV5647_WINDOW_HEIGHT_DEF;\n \n-\tformat->code = MEDIA_BUS_FMT_SBGGR8_1X8;\n-\tformat->width = 640;\n-\tformat->height = 480;\n-\tformat->field = V4L2_FIELD_NONE;\n-\tformat->colorspace = V4L2_COLORSPACE_SRGB;\n+\t*format = OV5647_DEFAULT_FORMAT;\n \n \treturn 0;\n }\n@@ -813,6 +849,8 @@ static int ov5647_probe(struct i2c_client *client)\n \n \tmutex_init(&sensor->lock);\n \n+\tsensor->mode = OV5647_DEFAULT_MODE;\n+\n \tret = ov5647_init_controls(sensor);\n \tif (ret)\n \t\tgoto mutex_destroy;\n",
    "prefixes": [
        "libcamera-devel",
        "15/25"
    ]
}