Show a patch.

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

{
    "id": 15843,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15843/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15843/",
    "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": "<20220510115147.19360-4-laurent.pinchart@ideasonboard.com>",
    "date": "2022-05-10T11:51:00",
    "name": "[libcamera-devel,03/50] staging: media: imx: imx7-media-csi: Import notifier helpers",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "404fc76af2bff987862ec9c327e69e93e02485e2",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15843/mbox/",
    "series": [
        {
            "id": 3106,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3106/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3106",
            "date": "2022-05-10T11:50:57",
            "name": "staging: media: imx: Prepare destaging of imx7-media-csi",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3106/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15843/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15843/checks/",
    "tags": {},
    "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 09B72C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 May 2022 11:52:03 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B75C665655;\n\tTue, 10 May 2022 13:52:02 +0200 (CEST)",
            "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 3E4A065643\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 May 2022 13:51:59 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 68431BA9;\n\tTue, 10 May 2022 13:51:58 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652183522;\n\tbh=DQNnAnAdnM1VsPNzt3WveXXRzKRWpGwQ+Fq/1O4hhtE=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=DPJnMPeE0LfUZZLd7cUqu841nMiWmrz6QKxCu76bRYZrYRnMJVByAjsZxxbAohfDR\n\tYRZg8SNbeI3h5fVJ8HOAeN2FbZ2hgQ5VurJz+pYFNUQ1F5MocELigm1tk0XKLwYazN\n\thvFDFG591Cioabu2KLZVfBsvxJ+uPMWbVx4+Wv9NZBI9haxJ1vbtws84jmlQu74U+l\n\tMu2qxZ0zkdq3Pj6d2Z0FxLokLrddlGrBcmwIMp9C94DM5L85Hsze9+3NPG5LsJJVyZ\n\tdAGPwqHli+xuwhJE3fnTZdnmx2CrDJg9wY5Of4xcFAP1i47O7gCX6gz/WxGyZmHaXH\n\ta3RTivYydTDfQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652183519;\n\tbh=DQNnAnAdnM1VsPNzt3WveXXRzKRWpGwQ+Fq/1O4hhtE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ib/NdEi4kYMQOj1L5mXLkEDV91quvFIfEI54tFOZNPAVqgrdfNy218mDVHPil6czZ\n\tQ6M76QsN8GJG25f8uToPhExcXiHcjHF0Wds4ElBXvtnWZqrwagz+SNqkdV2YeRlQ2Y\n\tWeHPXipo9nBJHtkQwFmVGyiLY1in5/ax5PtYUogE="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ib/NdEi4\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 10 May 2022 14:51:00 +0300",
        "Message-Id": "<20220510115147.19360-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220510115147.19360-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220510115147.19360-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 03/50] staging: media: imx:\n\timx7-media-csi: Import notifier helpers",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Cc": "Martin Kepplinger <martin.kepplinger@puri.sm>, kernel@pengutronix.de,\n\tDorota Czaplejewicz <dorota.czaplejewicz@puri.sm>,\n\tAlexander Stein <alexander.stein@ew.tq-group.com>,\n\tRui Miguel Silva <rmfrfs@gmail.com>,\n\tPhilipp Zabel <p.zabel@pengutronix.de>, \n\tSteve Longerbeam <slongerbeam@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "To prepare for code refactoring, copy the V4L2 async notifier helper\ncode used by this driver verbatim from imx-media-dev-common.c. Rename\nsome functions to avoid name clashes. No functional change included.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n drivers/staging/media/imx/imx7-media-csi.c | 210 ++++++++++++++++++++-\n 1 file changed, 209 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c\nindex d7c65b8bb3c9..708076b7045a 100644\n--- a/drivers/staging/media/imx/imx7-media-csi.c\n+++ b/drivers/staging/media/imx/imx7-media-csi.c\n@@ -717,6 +717,214 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data)\n \treturn IRQ_HANDLED;\n }\n \n+/* -----------------------------------------------------------------------------\n+ * Temporary copy of imx_media_dev helpers\n+ */\n+\n+static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n)\n+{\n+\treturn container_of(n, struct imx_media_dev, notifier);\n+}\n+\n+/*\n+ * Create the missing media links from the CSI-2 receiver.\n+ * Called after all async subdevs have bound.\n+ */\n+static void imx_media_create_csi2_links(struct imx_media_dev *imxmd)\n+{\n+\tstruct v4l2_subdev *sd, *csi2 = NULL;\n+\n+\tlist_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {\n+\t\tif (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) {\n+\t\t\tcsi2 = sd;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tif (!csi2)\n+\t\treturn;\n+\n+\tlist_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {\n+\t\t/* skip if not a CSI or a CSI mux */\n+\t\tif (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) &&\n+\t\t    !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) &&\n+\t\t    !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI_MUX))\n+\t\t\tcontinue;\n+\n+\t\tv4l2_create_fwnode_links(csi2, sd);\n+\t}\n+}\n+\n+/*\n+ * adds given video device to given imx-media source pad vdev list.\n+ * Continues upstream from the pad entity's sink pads.\n+ */\n+static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd,\n+\t\t\t\t     struct imx_media_video_dev *vdev,\n+\t\t\t\t     struct media_pad *srcpad)\n+{\n+\tstruct media_entity *entity = srcpad->entity;\n+\tstruct imx_media_pad_vdev *pad_vdev;\n+\tstruct list_head *pad_vdev_list;\n+\tstruct media_link *link;\n+\tstruct v4l2_subdev *sd;\n+\tint i, ret;\n+\n+\t/* skip this entity if not a v4l2_subdev */\n+\tif (!is_media_entity_v4l2_subdev(entity))\n+\t\treturn 0;\n+\n+\tsd = media_entity_to_v4l2_subdev(entity);\n+\n+\tpad_vdev_list = to_pad_vdev_list(sd, srcpad->index);\n+\tif (!pad_vdev_list) {\n+\t\tv4l2_warn(&imxmd->v4l2_dev, \"%s:%u has no vdev list!\\n\",\n+\t\t\t  entity->name, srcpad->index);\n+\t\t/*\n+\t\t * shouldn't happen, but no reason to fail driver load,\n+\t\t * just skip this entity.\n+\t\t */\n+\t\treturn 0;\n+\t}\n+\n+\t/* just return if we've been here before */\n+\tlist_for_each_entry(pad_vdev, pad_vdev_list, list) {\n+\t\tif (pad_vdev->vdev == vdev)\n+\t\t\treturn 0;\n+\t}\n+\n+\tdev_dbg(imxmd->md.dev, \"adding %s to pad %s:%u\\n\",\n+\t\tvdev->vfd->entity.name, entity->name, srcpad->index);\n+\n+\tpad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL);\n+\tif (!pad_vdev)\n+\t\treturn -ENOMEM;\n+\n+\t/* attach this vdev to this pad */\n+\tpad_vdev->vdev = vdev;\n+\tlist_add_tail(&pad_vdev->list, pad_vdev_list);\n+\n+\t/* move upstream from this entity's sink pads */\n+\tfor (i = 0; i < entity->num_pads; i++) {\n+\t\tstruct media_pad *pad = &entity->pads[i];\n+\n+\t\tif (!(pad->flags & MEDIA_PAD_FL_SINK))\n+\t\t\tcontinue;\n+\n+\t\tlist_for_each_entry(link, &entity->links, list) {\n+\t\t\tif (link->sink != pad)\n+\t\t\t\tcontinue;\n+\t\t\tret = imx_media_add_vdev_to_pad(imxmd, vdev,\n+\t\t\t\t\t\t\tlink->source);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * For every subdevice, allocate an array of list_head's, one list_head\n+ * for each pad, to hold the list of video devices reachable from that\n+ * pad.\n+ */\n+static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd)\n+{\n+\tstruct list_head *vdev_lists;\n+\tstruct media_entity *entity;\n+\tstruct v4l2_subdev *sd;\n+\tint i;\n+\n+\tlist_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {\n+\t\tentity = &sd->entity;\n+\t\tvdev_lists = devm_kcalloc(imxmd->md.dev,\n+\t\t\t\t\t  entity->num_pads, sizeof(*vdev_lists),\n+\t\t\t\t\t  GFP_KERNEL);\n+\t\tif (!vdev_lists)\n+\t\t\treturn -ENOMEM;\n+\n+\t\t/* attach to the subdev's host private pointer */\n+\t\tsd->host_priv = vdev_lists;\n+\n+\t\tfor (i = 0; i < entity->num_pads; i++)\n+\t\t\tINIT_LIST_HEAD(to_pad_vdev_list(sd, i));\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* form the vdev lists in all imx-media source pads */\n+static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd)\n+{\n+\tstruct imx_media_video_dev *vdev;\n+\tstruct media_link *link;\n+\tint ret;\n+\n+\tret = imx_media_alloc_pad_vdev_lists(imxmd);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tlist_for_each_entry(vdev, &imxmd->vdev_list, list) {\n+\t\tlink = list_first_entry(&vdev->vfd->entity.links,\n+\t\t\t\t\tstruct media_link, list);\n+\t\tret = imx_media_add_vdev_to_pad(imxmd, vdev, link->source);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* async subdev complete notifier */\n+static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier)\n+{\n+\tstruct imx_media_dev *imxmd = notifier2dev(notifier);\n+\tint ret;\n+\n+\tmutex_lock(&imxmd->mutex);\n+\n+\timx_media_create_csi2_links(imxmd);\n+\n+\tret = imx_media_create_pad_vdev_lists(imxmd);\n+\tif (ret)\n+\t\tgoto unlock;\n+\n+\tret = v4l2_device_register_subdev_nodes(&imxmd->v4l2_dev);\n+unlock:\n+\tmutex_unlock(&imxmd->mutex);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn media_device_register(&imxmd->md);\n+}\n+\n+static const struct v4l2_async_notifier_operations imx_media_notifier_ops = {\n+\t.complete = __imx_media_probe_complete,\n+};\n+\n+static int __imx_media_dev_notifier_register(struct imx_media_dev *imxmd,\n+\t\t\t    const struct v4l2_async_notifier_operations *ops)\n+{\n+\tint ret;\n+\n+\t/* no subdevs? just bail */\n+\tif (list_empty(&imxmd->notifier.asd_list)) {\n+\t\tv4l2_err(&imxmd->v4l2_dev, \"no subdevs\\n\");\n+\t\treturn -ENODEV;\n+\t}\n+\n+\t/* prepare the async subdev notifier and register it */\n+\timxmd->notifier.ops = ops ? ops : &imx_media_notifier_ops;\n+\tret = v4l2_async_nf_register(&imxmd->v4l2_dev, &imxmd->notifier);\n+\tif (ret) {\n+\t\tv4l2_err(&imxmd->v4l2_dev,\n+\t\t\t \"v4l2_async_nf_register failed with %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /* -----------------------------------------------------------------------------\n  * V4L2 Subdev Operations\n  */\n@@ -1200,7 +1408,7 @@ static int imx7_csi_media_init(struct imx7_csi *csi)\n \t\treturn ret;\n \t}\n \n-\tret = imx_media_dev_notifier_register(imxmd, NULL);\n+\tret = __imx_media_dev_notifier_register(imxmd, NULL);\n \tif (ret < 0) {\n \t\timx7_csi_media_cleanup(csi);\n \t\treturn ret;\n",
    "prefixes": [
        "libcamera-devel",
        "03/50"
    ]
}