From patchwork Mon Aug 5 23:34:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45F5A912 for ; Mon, 5 Aug 2019 23:36:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 344B22891F for ; Mon, 5 Aug 2019 23:36:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28D8E28927; Mon, 5 Aug 2019 23:36:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D19B328970 for ; Mon, 5 Aug 2019 23:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731037AbfHEXfN (ORCPT ); Mon, 5 Aug 2019 19:35:13 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45535 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728483AbfHEXfN (ORCPT ); Mon, 5 Aug 2019 19:35:13 -0400 Received: by mail-pg1-f195.google.com with SMTP id o13so40498210pgp.12; Mon, 05 Aug 2019 16:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fpjseVSUss2LkAdgKt7/i93QGkQFGmCf+/5YmrX1uIQ=; b=UEBoLUE6TOnktq0qwecZhcc58krHIy0NrLnA2JejGKdaPwA71LeRZgFPOgmSxAweHr IoXl6dWBSi5zvPf3JJfkosVWfC/RgGOSnwomIBoCms6iyd+A5uBNMH0I9ldaECqQqjez /TUqbAWemIc6vm8Or2nD481kCJKxUdGe8+4SQHJoveoJw301QfY19jbrvwDIUsWnS8jK ddXOpeAWPMODrQoVhaKlRSCJWMcDRwUj3xKXvv08nOLNA7YT2tGN9K0fI0IgOofqVCO7 rX9TD79OC3MIc2djYfbPQ2UYYM8ugJU4NveAgNpOP19a04uJEo0F4dRmwYdiQac2qiVD TWMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fpjseVSUss2LkAdgKt7/i93QGkQFGmCf+/5YmrX1uIQ=; b=eCpV0nOBBkG2/xIzB2KtLN/gP3EfbBNtnpJoixYmiBZWDdIRt0OCt9NHgDobdsUH6C y7jCqqkTwr8AlkH60oCZ1k/ofpz0OVIg4yP3jbbgvDpVd1+VbpTjOO6L423NjpXlr8ze 3hpctnqERMogKZgjv/PCOlPksY1R07tgaSj9r3hjtpfVwgdW4OnHHMG1WaesqSZrY8hF jvAL4XjcLomms0ol+cXgIYuJc6fUEJUNepVjEAn/Xi67rURhD0T+pwbxtwZWaV3ScjVj +2qup5Dwmx4I4Tj9FZbcTRuq0uQ/3q1rs7cnRuhD7tbtLSR+rLv00OOr9FABc51wHYRE jsXA== X-Gm-Message-State: APjAAAXO4Ushk9YJ+xtYrjbyWClylPvPyoLbTHxactgPUoV503I9Lv+h p1H32+kPgMT0uoaql1f0B9PVMZAT X-Google-Smtp-Source: APXvYqzYukYrcOoU9GMSBqOK3gJWry7lChLl+XFcob2BVHpiHpWIpjdxmlmyLQONGs8F/7psO3EqJg== X-Received: by 2002:aa7:93bb:: with SMTP id x27mr587342pff.10.1565048112341; Mon, 05 Aug 2019 16:35:12 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:11 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 01/22] media: entity: Pass entity to get_fwnode_pad operation Date: Mon, 5 Aug 2019 16:34:44 -0700 Message-Id: <20190805233505.21167-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a missing pointer to the entity in the media_entity operation get_fwnode_pad. Fixes: ae45cd5efc120 ("[media] media: entity: Add get_fwnode_pad entity operation") Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 2 +- include/media/media-entity.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 7c429ce98bae..c333320f790a 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -386,7 +386,7 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, if (ret) return ret; - ret = entity->ops->get_fwnode_pad(&endpoint); + ret = entity->ops->get_fwnode_pad(entity, &endpoint); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8cb2c504a05c..cde80ad029b7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -212,7 +212,8 @@ struct media_pad { * mutex held. */ struct media_entity_operations { - int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint); + int (*get_fwnode_pad)(struct media_entity *entity, + struct fwnode_endpoint *endpoint); int (*link_setup)(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags); From patchwork Mon Aug 5 23:34:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58AC513B1 for ; Mon, 5 Aug 2019 23:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480442891F for ; Mon, 5 Aug 2019 23:35:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C19428927; Mon, 5 Aug 2019 23:35:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DA052891F for ; Mon, 5 Aug 2019 23:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731058AbfHEXfQ (ORCPT ); Mon, 5 Aug 2019 19:35:16 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34406 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728483AbfHEXfO (ORCPT ); Mon, 5 Aug 2019 19:35:14 -0400 Received: by mail-pf1-f195.google.com with SMTP id b13so40420175pfo.1; Mon, 05 Aug 2019 16:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u/PbVO0GF+3G1LmQDJT1XFH8AmJHxoqEkGwCBY/zSdU=; b=Rmd3ZzYTRxOqchGIwYWUUpvkDRr5s2EsB6qEHX67RjuuYAkgUxfHqcpfewJ5S5O4eQ k8DQmrLg75em+CJxBjHeBnEeALQ5SigD8WnXOQLEPs//SPHJw5zl76YW7Fl4K7L51ozW 3l4On5GCQL+29WIbp9xAsazY3623XLv/FjDk+dCHNz1vDewNvawXYzg2cZptdCMhJqwd yeOec5NwL44JOspgc8abBqdBwLYIFd+xlv86dmjRUv4eUOzCQfiBzI5jPsKkPbbNRG+W o1DPw3xYd9+iPnyLnHhJmlOa01gNx2Vs4CoeFGyNlf36x8qz0EbATkdgj+B28034OWJ8 wyCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u/PbVO0GF+3G1LmQDJT1XFH8AmJHxoqEkGwCBY/zSdU=; b=ENI+HzFyvCJArc9TJw3EMspfNdbLiLf6uObnMnYxOGskSODjEjy3VYaDE25VRPauMp Nw/h2OgFWmdBXwh/ukQ9nKqHUZ4aC8Af9TDxS1s5Kpc6wi5GbAk+ODvYcszcMwFmDaOr lP5ZpGPYQbBCURucdSr0TgJpaJxjT6g0h3ehaUJQZvSSuRmTJUTUenujvI1l9iJ+wYWe K/KzMZoi3UBue4ipihjWMZL3SFhXY+Xag+JMBPntEhv3L1R5hfX7A2/+Lnq7MWBvr+Oo 5kGj2+IPRTq7VygHk/j0YmjlQtz/Krd90Ue+eF0UyIrVd+OihbZnK+OLEX7KMwU0XNm0 hOWg== X-Gm-Message-State: APjAAAXzBAhn5GD5XVkhmREY3EEGiGcu0q20STKMNgzfE8Cvt2ipO4TY /SH0VNSBnPdCnoW6uvK67dU+pkER X-Google-Smtp-Source: APXvYqx+LrojXALlauo335nICJL2fXUDtyIcilbnqjR4ImFHiwROCHxErqT525lwBXqgrgQe0UWy6g== X-Received: by 2002:a62:7a8a:: with SMTP id v132mr509377pfc.103.1565048113505; Mon, 05 Aug 2019 16:35:13 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:12 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 02/22] media: entity: Modify default behavior of media_entity_get_fwnode_pad Date: Mon, 5 Aug 2019 16:34:45 -0700 Message-Id: <20190805233505.21167-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Modify the default behavior of media_entity_get_fwnode_pad() (when the entity does not provide the get_fwnode_pad op) to first assume the entity implements a 1:1 mapping between fwnode port number and media pad index. If the 1:1 mapping is not valid, e.g. the port number falls outside the entity's pad index range, or the pad at that port number doesn't match the given direction_flags, fall-back to the previous behavior that searches the entity for the first pad that matches the given direction_flags. The previous default behavior can choose the wrong pad for entities with multiple sink or source pads. With this change the function will choose the correct pad index if the entity implements a 1:1 port to pad mapping at that port. Add some comments to the @get_fwnode_pad operation to make it more clear under what conditions entities must implement the operation. Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 25 ++++++++++++++++++++----- include/media/media-entity.h | 21 +++++++++++++++------ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index c333320f790a..47a39d9383d8 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -370,22 +370,37 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, unsigned long direction_flags) { struct fwnode_endpoint endpoint; - unsigned int i; int ret; + ret = fwnode_graph_parse_endpoint(fwnode, &endpoint); + if (ret) + return ret; + if (!entity->ops || !entity->ops->get_fwnode_pad) { + unsigned int i; + + /* + * for the default case, first try a 1:1 mapping between + * fwnode port number and pad index. + */ + ret = endpoint.port; + if (ret < entity->num_pads && + (entity->pads[ret].flags & direction_flags)) + return ret; + + /* + * if that didn't work search the entity for the first + * pad that matches the @direction_flags. + */ for (i = 0; i < entity->num_pads; i++) { if (entity->pads[i].flags & direction_flags) return i; } + /* else fail */ return -ENXIO; } - ret = fwnode_graph_parse_endpoint(fwnode, &endpoint); - if (ret) - return ret; - ret = entity->ops->get_fwnode_pad(entity, &endpoint); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index cde80ad029b7..ed00adb4313b 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -199,6 +199,12 @@ struct media_pad { * @get_fwnode_pad: Return the pad number based on a fwnode endpoint or * a negative value on error. This operation can be used * to map a fwnode to a media pad number. Optional. + * Entities do not need to implement this operation + * unless two conditions are met: + * - the entity has more than one sink and/or source + * pad, _and_ + * - the entity does not implement a 1:1 mapping of + * fwnode port numbers to pad indexes. * @link_setup: Notify the entity of link changes. The operation can * return an error, in which case link setup will be * cancelled. Optional. @@ -858,21 +864,24 @@ struct media_link *media_entity_find_link(struct media_pad *source, struct media_pad *media_entity_remote_pad(const struct media_pad *pad); /** - * media_entity_get_fwnode_pad - Get pad number from fwnode + * media_entity_get_fwnode_pad - Get pad number from an endpoint fwnode * * @entity: The entity - * @fwnode: Pointer to the fwnode_handle which should be used to find the pad + * @fwnode: Pointer to the endpoint fwnode_handle which should be used to + * find the pad * @direction_flags: Expected direction of the pad, as defined in * :ref:`include/uapi/linux/media.h ` * (seek for ``MEDIA_PAD_FL_*``) * * This function can be used to resolve the media pad number from - * a fwnode. This is useful for devices which use more complex - * mappings of media pads. + * an endpoint fwnode. This is useful for devices which use more + * complex mappings of media pads. * * If the entity does not implement the get_fwnode_pad() operation - * then this function searches the entity for the first pad that - * matches the @direction_flags. + * then this function first assumes the entity implements a 1:1 mapping + * between fwnode port number and media pad index. If the 1:1 mapping + * is not valid, then the function searches the entity for the first pad + * that matches the @direction_flags. * * Return: returns the pad number on success or a negative error code. */ From patchwork Mon Aug 5 23:34:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEF1915AC for ; Mon, 5 Aug 2019 23:36:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB9D62891F for ; Mon, 5 Aug 2019 23:36:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDFED2894D; Mon, 5 Aug 2019 23:36:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67AC028927 for ; Mon, 5 Aug 2019 23:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731126AbfHEXgt (ORCPT ); Mon, 5 Aug 2019 19:36:49 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35581 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731057AbfHEXfP (ORCPT ); Mon, 5 Aug 2019 19:35:15 -0400 Received: by mail-pg1-f193.google.com with SMTP id n4so5243000pgv.2; Mon, 05 Aug 2019 16:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3hiXeQQV1KrdCEAIpSQAk9Ltt3Glhe3/FQmcNgwcF6I=; b=WK97h2Gxi7lfr4FpaCZdEE6yb8tmSN60vE5Ahq7PYXjtBL+BVy/eniGtFtqRVhsrEw JeB2t/F2D/kZBGLZlFw9LGtgtRGcAgsSrgYs6GFbxr6jD+AJ5RNSeyki1JGL8qok0aZN AqJbeluAc086VbxCIzYAW6PoQOwdxGB5pqkbtNEfryP8R2feACWJaZIEQwivEY0vu0Oy FiM84V4Zvsb3hY/+Arn06VLPRv5pEbnFPwAmUdEClTdIf6XoygSZ1AT6uhHmufCnFl4u IaA7TldEVoa80dwl5ThE0gLdtwdQtrA2FPZ99dRTQ6ztgrcOPx3DeEt7T4u/xCiiHr+n J6Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3hiXeQQV1KrdCEAIpSQAk9Ltt3Glhe3/FQmcNgwcF6I=; b=a0iadvFMRQptk7X83wUVTDmSJOpYLby2CG/8NDOGZy2NBjwW3pgVI4jf0y2DhCwClr SXe+WlvY+M602+vS/tOXnQZdFB1MYrQ6Mw2y8OXlxsFzSvN1pvnag5yv3f8FJ6JZr9V3 o0skVlT51hoyJdYz2sKqcVGGVXeKptALlf9tznYhVTE+Sb+GLs/WWENhme9Gpg4DezuH r5E/huu9nti/B1QHjcbD7aUgPeQGyYyUOEbptENMKjennC7Sr7FVOXKBe8VfKUH7sXiO nHQdO9MMyIe4IT4bLZYLsUm0nWqCSbbYCLsuvx/Qh0PfWxHuEoQEynVF45dWw4bhL2Qi d35g== X-Gm-Message-State: APjAAAW0jG2dV3wPVbr52zeHxDqRo7EGTK0iOOdwnOOI7qhpRuKrcfyA B6iQDcAWGua7lF/9+5CAgQdXxQRY X-Google-Smtp-Source: APXvYqxKVm5fkj8NRo91yo6fTIS54zqYPfOuVt6pelKsqlZ5bMNtwElDmJJ7V6YR95YmOzs/98BxZw== X-Received: by 2002:aa7:8f2c:: with SMTP id y12mr588868pfr.38.1565048114461; Mon, 05 Aug 2019 16:35:14 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:14 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 03/22] media: entity: Convert media_entity_get_fwnode_pad() args to const Date: Mon, 5 Aug 2019 16:34:46 -0700 Message-Id: <20190805233505.21167-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function media_entity_get_fwnode_pad() can be passed the const local_fwnode member from a struct fwnode_endpoint, so the fwnode argument should be a const pointer. Change the direction_flags argument to const in the process. Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 4 ++-- include/media/media-entity.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 47a39d9383d8..e9e090244fd4 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -366,8 +366,8 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph) EXPORT_SYMBOL_GPL(media_graph_walk_next); int media_entity_get_fwnode_pad(struct media_entity *entity, - struct fwnode_handle *fwnode, - unsigned long direction_flags) + const struct fwnode_handle *fwnode, + const unsigned long direction_flags) { struct fwnode_endpoint endpoint; int ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index ed00adb4313b..de7fc3676b5a 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -886,8 +886,8 @@ struct media_pad *media_entity_remote_pad(const struct media_pad *pad); * Return: returns the pad number on success or a negative error code. */ int media_entity_get_fwnode_pad(struct media_entity *entity, - struct fwnode_handle *fwnode, - unsigned long direction_flags); + const struct fwnode_handle *fwnode, + const unsigned long direction_flags); /** * media_graph_walk_init - Allocate resources used by graph walk. From patchwork Mon Aug 5 23:34:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE3C113B1 for ; Mon, 5 Aug 2019 23:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C05F2891F for ; Mon, 5 Aug 2019 23:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9004B28970; Mon, 5 Aug 2019 23:36:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E7E62891F for ; Mon, 5 Aug 2019 23:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731082AbfHEXfV (ORCPT ); Mon, 5 Aug 2019 19:35:21 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35586 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728483AbfHEXfU (ORCPT ); Mon, 5 Aug 2019 19:35:20 -0400 Received: by mail-pg1-f193.google.com with SMTP id n4so5243082pgv.2; Mon, 05 Aug 2019 16:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C0KFhBb04zphSNDFERKuxXP3f//3wIxB1UOM6YjQ1JA=; b=N8D9sJ8lCraliMA+o+xwJJNn4uLnig+zXYMH3wlaLT8ULMzCNaeUSEU0z+LO6EIjBC AWS6UIjR7QJUd2kW28gVO3LhUHbLxHffRXPueaVYg+1IHZCt5otJXvkmdOKu5ZOeDGTq yiDWN493oTmlmm55dPslo65IJvjEIlCObuTHWbTKKsJm8CUfhh27x3O6/LTh4DQcuwf9 VIjHAmYhLNzdYHZmuMXXVzMskpckOEi7P/qyoS0vqpAZG/kfSQFjK4M6cyMLo8VICOr5 FVuoy2OnI+auXXhD/oFNc9GxsxWpErFmKUSRSUmA7hxo9OMC6C9ZwV+n9fMR42T84Q/F rQwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C0KFhBb04zphSNDFERKuxXP3f//3wIxB1UOM6YjQ1JA=; b=qRI+T+xizNLuOOE1BDc3pJkLhifKxLn3OkE0Q+7hdlM6wisvMqAb5QRmizIKsxeNWP +dZ5O/f9rf27n0i+2VBTumr/kvZgYY++SqBW4wox4ewCI7B/UzxEcl86p2vuRinLBUi7 sfDFukYtWbJe/cZwPaGg6Lna7GwD4tzaPkkfu4oTJ3+BHRzmLThWJj8KwCn2ReBD2OUL t9asc8e3zhT/MXHEC31mCZVFStAwt0LX4TuoA1sMaeJNIt7lW+TWP0X9YXQGOQutE0qr YMkhnWdEtCkD5Trz8/sb9c5Gp0q4qwllRvgkqETpz2bBAqJjyn4f/FoD8ocor68/kasL 07Iw== X-Gm-Message-State: APjAAAWLMqemPh9N8DbH0fajcRqugVrcwJHGbX2gpVaQvg+SVUXWNB2O iW2vk0+Gak4mNOLZgZGu2Mwgt8tj X-Google-Smtp-Source: APXvYqx1h2MYP9gOdii1NHHm4eOTFfUILZD0i85u26GABo+FgCNCOKhGylZXC4n1bVflBRkJrtiLFg== X-Received: by 2002:a63:6206:: with SMTP id w6mr331230pgb.428.1565048118835; Mon, 05 Aug 2019 16:35:18 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:18 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Greg Kroah-Hartman , "Rafael J. Wysocki" , Hyun Kwon , Laurent Pinchart , Mauro Carvalho Chehab , Michal Simek , Philipp Zabel , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Len Brown , Sakari Ailus , Jacopo Mondi , Hans Verkuil , Heikki Krogerus , Andy Shevchenko , Enrico Weigelt , Thomas Gleixner , linux-kernel@vger.kernel.org (open list), linux-arm-kernel@lists.infradead.org (moderated list:ARM/ZYNQ ARCHITECTURE), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-acpi@vger.kernel.org (open list:ACPI) Subject: [PATCH 04/22] media: Move v4l2_fwnode_parse_link from v4l2 to driver base Date: Mon, 5 Aug 2019 16:34:47 -0700 Message-Id: <20190805233505.21167-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is nothing v4l2-specific about v4l2_fwnode_{parse|put}_link(). Make these functions more generally available by moving them to driver base, with the appropriate name changes to the functions and struct. In the process embed a 'struct fwnode_endpoint' in 'struct fwnode_link' for both sides of the link, and make use of fwnode_graph_parse_endpoint() to fully parse both endpoints. Rename members local_node and remote_node to more descriptive local_port_parent and remote_port_parent. Signed-off-by: Steve Longerbeam --- drivers/base/property.c | 63 +++++++++++++++++++ drivers/media/platform/xilinx/xilinx-vipp.c | 69 +++++++++++---------- drivers/media/v4l2-core/v4l2-fwnode.c | 39 ------------ drivers/staging/media/imx/imx-media-of.c | 49 +++++++-------- include/linux/fwnode.h | 14 +++++ include/linux/property.h | 5 ++ include/media/v4l2-fwnode.h | 44 ------------- 7 files changed, 141 insertions(+), 142 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 81bd01ed4042..dd82cd150d84 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1100,6 +1100,69 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, } EXPORT_SYMBOL(fwnode_graph_parse_endpoint); +/** + * fwnode_graph_parse_link() - parse a link between two endpoints + * @local_endpoint: the endpoint's fwnode at the local end of the link + * @link: pointer to the fwnode link data structure + * + * Fill the link structure with the parsed local and remote endpoint info + * and the local and remote port parent nodes. + * + * A reference is taken to both the local and remote port parent nodes, + * the caller must use fwnode_graph_put_link() to drop the references + * when done with the link. + * + * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode + * can't be found. + */ +int fwnode_graph_parse_link(struct fwnode_handle *local_endpoint, + struct fwnode_link *link) +{ + struct fwnode_handle *remote_endpoint; + int ret; + + memset(link, 0, sizeof(*link)); + + ret = fwnode_graph_parse_endpoint(local_endpoint, &link->local); + if (ret < 0) + return ret; + + remote_endpoint = fwnode_graph_get_remote_endpoint(local_endpoint); + if (!remote_endpoint) + return -ENOLINK; + + ret = fwnode_graph_parse_endpoint(remote_endpoint, &link->remote); + if (ret < 0) { + fwnode_handle_put(remote_endpoint); + return ret; + } + + link->local_port_parent = + fwnode_graph_get_port_parent(local_endpoint); + link->remote_port_parent = + fwnode_graph_get_port_parent(remote_endpoint); + + fwnode_handle_put(remote_endpoint); + + return 0; +} +EXPORT_SYMBOL_GPL(fwnode_graph_parse_link); + +/** + * fwnode_graph_put_link() - drop references to port parent nodes in a link + * @link: pointer to the fwnode link data structure + * + * Drop references to the local and remote port parent nodes in the link. + * This function must be called on every link parsed with + * fwnode_graph_parse_link(). + */ +void fwnode_graph_put_link(struct fwnode_link *link) +{ + fwnode_handle_put(link->local_port_parent); + fwnode_handle_put(link->remote_port_parent); +} +EXPORT_SYMBOL_GPL(fwnode_graph_put_link); + const void *device_get_match_data(struct device *dev) { return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index cc2856efea59..9c0dfc694478 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -74,7 +74,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, struct media_pad *local_pad; struct media_pad *remote_pad; struct xvip_graph_entity *ent; - struct v4l2_fwnode_link link; + struct fwnode_link link; struct fwnode_handle *ep = NULL; int ret = 0; @@ -89,7 +89,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, dev_dbg(xdev->dev, "processing endpoint %p\n", ep); - ret = v4l2_fwnode_parse_link(ep, &link); + ret = fwnode_graph_parse_link(ep, &link); if (ret < 0) { dev_err(xdev->dev, "failed to parse link for %p\n", ep); @@ -99,54 +99,55 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, /* Skip sink ports, they will be processed from the other end of * the link. */ - if (link.local_port >= local->num_pads) { + if (link.local.port >= local->num_pads) { dev_err(xdev->dev, "invalid port number %u for %p\n", - link.local_port, link.local_node); - v4l2_fwnode_put_link(&link); + link.local.port, link.local_port_parent); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } - local_pad = &local->pads[link.local_port]; + local_pad = &local->pads[link.local.port]; if (local_pad->flags & MEDIA_PAD_FL_SINK) { dev_dbg(xdev->dev, "skipping sink port %p:%u\n", - link.local_node, link.local_port); - v4l2_fwnode_put_link(&link); + link.local_port_parent, link.local.port); + fwnode_graph_put_link(&link); continue; } /* Skip DMA engines, they will be processed separately. */ - if (link.remote_node == of_fwnode_handle(xdev->dev->of_node)) { + if (link.remote_port_parent == + of_fwnode_handle(xdev->dev->of_node)) { dev_dbg(xdev->dev, "skipping DMA port %p:%u\n", - link.local_node, link.local_port); - v4l2_fwnode_put_link(&link); + link.local_port_parent, link.local.port); + fwnode_graph_put_link(&link); continue; } /* Find the remote entity. */ - ent = xvip_graph_find_entity(xdev, link.remote_node); + ent = xvip_graph_find_entity(xdev, link.remote_port_parent); if (ent == NULL) { dev_err(xdev->dev, "no entity found for %p\n", - link.remote_node); - v4l2_fwnode_put_link(&link); + link.remote_port_parent); + fwnode_graph_put_link(&link); ret = -ENODEV; break; } remote = ent->entity; - if (link.remote_port >= remote->num_pads) { + if (link.remote.port >= remote->num_pads) { dev_err(xdev->dev, "invalid port number %u on %p\n", - link.remote_port, link.remote_node); - v4l2_fwnode_put_link(&link); + link.remote.port, link.remote_port_parent); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } - remote_pad = &remote->pads[link.remote_port]; + remote_pad = &remote->pads[link.remote.port]; - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); /* Create the media link. */ dev_dbg(xdev->dev, "creating %s:%u -> %s:%u link\n", @@ -191,7 +192,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) struct media_pad *source_pad; struct media_pad *sink_pad; struct xvip_graph_entity *ent; - struct v4l2_fwnode_link link; + struct fwnode_link link; struct device_node *ep = NULL; struct xvip_dma *dma; int ret = 0; @@ -206,7 +207,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); + ret = fwnode_graph_parse_link(of_fwnode_handle(ep), &link); if (ret < 0) { dev_err(xdev->dev, "failed to parse link for %pOF\n", ep); @@ -214,11 +215,11 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) } /* Find the DMA engine. */ - dma = xvip_graph_find_dma(xdev, link.local_port); + dma = xvip_graph_find_dma(xdev, link.local.port); if (dma == NULL) { dev_err(xdev->dev, "no DMA engine found for port %u\n", - link.local_port); - v4l2_fwnode_put_link(&link); + link.local.port); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } @@ -227,20 +228,20 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) dma->video.name); /* Find the remote entity. */ - ent = xvip_graph_find_entity(xdev, link.remote_node); + ent = xvip_graph_find_entity(xdev, link.remote_port_parent); if (ent == NULL) { dev_err(xdev->dev, "no entity found for %pOF\n", - to_of_node(link.remote_node)); - v4l2_fwnode_put_link(&link); + to_of_node(link.remote_port_parent)); + fwnode_graph_put_link(&link); ret = -ENODEV; break; } - if (link.remote_port >= ent->entity->num_pads) { + if (link.remote.port >= ent->entity->num_pads) { dev_err(xdev->dev, "invalid port number %u on %pOF\n", - link.remote_port, - to_of_node(link.remote_node)); - v4l2_fwnode_put_link(&link); + link.remote.port, + to_of_node(link.remote_port_parent)); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } @@ -249,15 +250,15 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) source = &dma->video.entity; source_pad = &dma->pad; sink = ent->entity; - sink_pad = &sink->pads[link.remote_port]; + sink_pad = &sink->pads[link.remote.port]; } else { source = ent->entity; - source_pad = &source->pads[link.remote_port]; + source_pad = &source->pads[link.remote.port]; sink = &dma->video.entity; sink_pad = &dma->pad; } - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); /* Create the media link. */ dev_dbg(xdev->dev, "creating %s:%u -> %s:%u link\n", diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 3bd1888787eb..5d4ce4aa3fdc 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -556,45 +556,6 @@ int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, } EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse); -int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, - struct v4l2_fwnode_link *link) -{ - const char *port_prop = is_of_node(__fwnode) ? "reg" : "port"; - struct fwnode_handle *fwnode; - - memset(link, 0, sizeof(*link)); - - fwnode = fwnode_get_parent(__fwnode); - fwnode_property_read_u32(fwnode, port_prop, &link->local_port); - fwnode = fwnode_get_next_parent(fwnode); - if (is_of_node(fwnode) && of_node_name_eq(to_of_node(fwnode), "ports")) - fwnode = fwnode_get_next_parent(fwnode); - link->local_node = fwnode; - - fwnode = fwnode_graph_get_remote_endpoint(__fwnode); - if (!fwnode) { - fwnode_handle_put(fwnode); - return -ENOLINK; - } - - fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, port_prop, &link->remote_port); - fwnode = fwnode_get_next_parent(fwnode); - if (is_of_node(fwnode) && of_node_name_eq(to_of_node(fwnode), "ports")) - fwnode = fwnode_get_next_parent(fwnode); - link->remote_node = fwnode; - - return 0; -} -EXPORT_SYMBOL_GPL(v4l2_fwnode_parse_link); - -void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link) -{ - fwnode_handle_put(link->local_node); - fwnode_handle_put(link->remote_node); -} -EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link); - static int v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev, struct v4l2_async_notifier *notifier, diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 2d3efd2a6dde..736c954a8ff5 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -84,28 +84,29 @@ EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs); */ static int create_of_link(struct imx_media_dev *imxmd, struct v4l2_subdev *sd, - struct v4l2_fwnode_link *link) + struct fwnode_link *link) { struct v4l2_subdev *remote, *src, *sink; int src_pad, sink_pad; - if (link->local_port >= sd->entity.num_pads) + if (link->local.port >= sd->entity.num_pads) return -EINVAL; - remote = imx_media_find_subdev_by_fwnode(imxmd, link->remote_node); + remote = imx_media_find_subdev_by_fwnode(imxmd, + link->remote_port_parent); if (!remote) return 0; - if (sd->entity.pads[link->local_port].flags & MEDIA_PAD_FL_SINK) { + if (sd->entity.pads[link->local.port].flags & MEDIA_PAD_FL_SINK) { src = remote; - src_pad = link->remote_port; + src_pad = link->remote.port; sink = sd; - sink_pad = link->local_port; + sink_pad = link->local.port; } else { src = sd; - src_pad = link->local_port; + src_pad = link->local.port; sink = remote; - sink_pad = link->remote_port; + sink_pad = link->remote.port; } /* make sure link doesn't already exist before creating */ @@ -126,17 +127,17 @@ static int create_of_link(struct imx_media_dev *imxmd, int imx_media_create_of_links(struct imx_media_dev *imxmd, struct v4l2_subdev *sd) { - struct v4l2_fwnode_link link; - struct device_node *ep; + struct fwnode_handle *endpoint; + struct fwnode_link link; int ret; - for_each_endpoint_of_node(sd->dev->of_node, ep) { - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); + fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { + ret = fwnode_graph_parse_link(endpoint, &link); if (ret) continue; ret = create_of_link(imxmd, sd, &link); - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); if (ret) return ret; } @@ -152,35 +153,33 @@ EXPORT_SYMBOL_GPL(imx_media_create_of_links); int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, struct v4l2_subdev *csi) { - struct device_node *csi_np = csi->dev->of_node; - struct device_node *ep; + struct fwnode_handle *csi_np = dev_fwnode(csi->dev); + struct fwnode_handle *csi_ep; - for_each_child_of_node(csi_np, ep) { - struct fwnode_handle *fwnode, *csi_ep; - struct v4l2_fwnode_link link; + fwnode_for_each_child_node(csi_np, csi_ep) { + struct fwnode_handle *fwnode; + struct fwnode_link link; int ret; memset(&link, 0, sizeof(link)); - link.local_node = of_fwnode_handle(csi_np); - link.local_port = CSI_SINK_PAD; - - csi_ep = of_fwnode_handle(ep); + link.local_port_parent = csi_np; + link.local.port = CSI_SINK_PAD; fwnode = fwnode_graph_get_remote_endpoint(csi_ep); if (!fwnode) continue; fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, "reg", &link.remote_port); + fwnode_property_read_u32(fwnode, "reg", &link.remote.port); fwnode = fwnode_get_next_parent(fwnode); if (is_of_node(fwnode) && of_node_name_eq(to_of_node(fwnode), "ports")) fwnode = fwnode_get_next_parent(fwnode); - link.remote_node = fwnode; + link.remote_port_parent = fwnode; ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_node); + fwnode_handle_put(link.remote_port_parent); if (ret) return ret; } diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index a11c8c56c78b..c2063ae2affe 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -31,6 +31,20 @@ struct fwnode_endpoint { const struct fwnode_handle *local_fwnode; }; +/** + * struct fwnode_link - a link between two fwnode graph endpoints + * @local: parsed local endpoint of the link + * @local_port_parent: port parent fwnode of local endpoint + * @remote: parsed remote endpoint of the link + * @remote_port_parent: port parent fwnode of the remote endpoint + */ +struct fwnode_link { + struct fwnode_endpoint local; + struct fwnode_handle *local_port_parent; + struct fwnode_endpoint remote; + struct fwnode_handle *remote_port_parent; +}; + #define NR_FWNODE_REFERENCE_ARGS 8 /** diff --git a/include/linux/property.h b/include/linux/property.h index 5a910ad79591..3923906fc314 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -374,6 +374,11 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); +int fwnode_graph_parse_link(struct fwnode_handle *fwnode, + struct fwnode_link *link); + +void fwnode_graph_put_link(struct fwnode_link *link); + /* -------------------------------------------------------------------------- */ /* Software fwnode support - when HW description is incomplete or missing */ diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f6a7bcd13197..f81f8bf34526 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -109,20 +109,6 @@ struct v4l2_fwnode_endpoint { unsigned int nr_of_link_frequencies; }; -/** - * struct v4l2_fwnode_link - a link between two endpoints - * @local_node: pointer to device_node of this endpoint - * @local_port: identifier of the port this endpoint belongs to - * @remote_node: pointer to device_node of the remote endpoint - * @remote_port: identifier of the port the remote endpoint belongs to - */ -struct v4l2_fwnode_link { - struct fwnode_handle *local_node; - unsigned int local_port; - struct fwnode_handle *remote_node; - unsigned int remote_port; -}; - /** * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties * @fwnode: pointer to the endpoint's fwnode handle @@ -203,36 +189,6 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); -/** - * v4l2_fwnode_parse_link() - parse a link between two endpoints - * @fwnode: pointer to the endpoint's fwnode at the local end of the link - * @link: pointer to the V4L2 fwnode link data structure - * - * Fill the link structure with the local and remote nodes and port numbers. - * The local_node and remote_node fields are set to point to the local and - * remote port's parent nodes respectively (the port parent node being the - * parent node of the port node if that node isn't a 'ports' node, or the - * grand-parent node of the port node otherwise). - * - * A reference is taken to both the local and remote nodes, the caller must use - * v4l2_fwnode_put_link() to drop the references when done with the - * link. - * - * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode can't be - * found. - */ -int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, - struct v4l2_fwnode_link *link); - -/** - * v4l2_fwnode_put_link() - drop references to nodes in a link - * @link: pointer to the V4L2 fwnode link data structure - * - * Drop references to the local and remote nodes in the link. This function - * must be called on every link parsed with v4l2_fwnode_parse_link(). - */ -void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); - /** * typedef parse_endpoint_func - Driver's callback function to be called on * each V4L2 fwnode endpoint. From patchwork Mon Aug 5 23:34:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDD00912 for ; Mon, 5 Aug 2019 23:36:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC4422891F for ; Mon, 5 Aug 2019 23:36:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B055C2894D; Mon, 5 Aug 2019 23:36:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 002882891F for ; Mon, 5 Aug 2019 23:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731064AbfHEXgm (ORCPT ); Mon, 5 Aug 2019 19:36:42 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39135 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730900AbfHEXfV (ORCPT ); Mon, 5 Aug 2019 19:35:21 -0400 Received: by mail-pl1-f196.google.com with SMTP id b7so37103507pls.6; Mon, 05 Aug 2019 16:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YFQ4AoMFvQmMSyDzoiWHzk59x+QNTk1pRP20/urZlo0=; b=Z6jrILgg++NDytvDTNzU7ffPKGYG+xNJz/aNfoeFluS8ytP+Gph24wSxjN4tQdGDPt RGfkJ/6Ux7CrEB0hUBmVilI13ZocAUrxnx/bzdbgQTruJm/XKHy7T+pmWiYwb2OK3n8S hRC5bzqJDTQOWxOSskUr72/tYu4aAuReXJWD1ITNfgtSb0gpMTCv2GsoHkmyLCf/efd5 VjkV63HlqMIEFi5vkqSep9mIC3cHAhLQj5nmGv4Zg6tfwMBxWOIuZWD/+LDW0R1RHvcW pmyzpuJmTG9CnUN2j5FSlsbphNqoR8xh4jAf06IVEuY9dcSB/PuFROxx9Za9efDRxZE/ eYVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YFQ4AoMFvQmMSyDzoiWHzk59x+QNTk1pRP20/urZlo0=; b=RC2Spck+zB/E8omyBlO5B75dKos3hiUB6A4voQB92nIsVxpX72w0Uy1BQYbssGljna Mi6zp7zZTW4euHPFVolqP3mhKUME5wyVlooFVlYUSfDD2QY734yjaJpHKILczxnqyWbT 9a9qryOggiscfg/Rbtjm4h9/NOJRZmDkrriu9755KowW3h2NmZFwEs9ltvGX8HFi4cbd ERtfQEuv7/iBPvotADL8f6vN9dObxFiWgf3zVkesuK9ROitcqyc1yWacGdw80J+bEzkw UmKeL51S361mQqJZMHuNYiiegL6hquLIBHv9yrbzGvilf2/QW7k7ssWtQCKGSHqC5pEh exhQ== X-Gm-Message-State: APjAAAU1OwnZBq7y1Mr7NfVAwvDkzYEgkG5vrWa/+pLNdHU4n16E32+D epGnwfC+NyAlw6c/PulibyVJlbmO X-Google-Smtp-Source: APXvYqwk6uHxQUupum1kLR2fneJjb9XpXYhfHpsb6IFjE+beuEbsUj6EwqWsKhsllFtRvWk4kgL4YA== X-Received: by 2002:a17:902:7781:: with SMTP id o1mr233895pll.205.1565048120080; Mon, 05 Aug 2019 16:35:20 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:19 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 05/22] media: entity: Add functions to convert fwnode endpoints to media links Date: Mon, 5 Aug 2019 16:34:48 -0700 Message-Id: <20190805233505.21167-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds two functions: media_create_fwnode_pad_links(), which converts fwnode endpoints that connect a local pad to all pads on a remote entity into media links. media_create_fwnode_links(), which converts fwnode endpoints that connect all pads from a local entity to all pads on a remote entity into media links. Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 178 +++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 71 ++++++++++++++ 2 files changed, 249 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index e9e090244fd4..45bbd6c91019 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -787,6 +787,184 @@ int media_create_pad_links(const struct media_device *mdev, } EXPORT_SYMBOL_GPL(media_create_pad_links); +static int __media_create_fwnode_pad_link(struct media_pad *local_pad, + struct media_entity *remote, + const struct fwnode_handle *remote_ep, + const u32 flags) +{ + struct media_entity *local = local_pad->entity; + unsigned long local_dir = local_pad->flags; + unsigned long remote_dir = (local_dir & MEDIA_PAD_FL_SOURCE) ? + MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; + struct media_entity *src, *sink; + int src_pad, sink_pad; + int remote_pad; + int ret; + + remote_pad = media_entity_get_fwnode_pad(remote, remote_ep, + remote_dir); + if (remote_pad < 0) + return 0; + + if (local_dir & MEDIA_PAD_FL_SOURCE) { + src = local; + src_pad = local_pad->index; + sink = remote; + sink_pad = remote_pad; + } else { + src = remote; + src_pad = remote_pad; + sink = local; + sink_pad = local_pad->index; + } + + /* make sure link doesn't already exist */ + if (media_entity_find_link(&src->pads[src_pad], + &sink->pads[sink_pad])) + return 0; + + ret = media_create_pad_link(src, src_pad, sink, sink_pad, flags); + if (ret) { + dev_dbg(sink->graph_obj.mdev->dev, + "%s:%d -> %s:%d failed with %d\n", + src->name, src_pad, sink->name, sink_pad, + ret); + return ret; + } + + dev_dbg(sink->graph_obj.mdev->dev, "%s:%d -> %s:%d\n", + src->name, src_pad, sink->name, sink_pad); + + return 0; +} + +int __media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct fwnode_handle *endpoint; + + fwnode_graph_for_each_endpoint(remote_fwnode, endpoint) { + struct fwnode_link link; + int ret; + + ret = fwnode_graph_parse_link(endpoint, &link); + if (ret) + continue; + + /* + * if this endpoint does not link to the local fwnode + * device, ignore it and continue. + */ + if (link.remote_port_parent != local_fwnode) { + fwnode_graph_put_link(&link); + continue; + } + + ret = __media_create_fwnode_pad_link(local_pad, + remote, endpoint, + link_flags); + + fwnode_graph_put_link(&link); + + if (ret) { + fwnode_handle_put(endpoint); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(__media_create_fwnode_pad_links); + +int media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct media_device *mdev = local_pad->entity->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __media_create_fwnode_pad_links(local_pad, local_fwnode, + remote, remote_fwnode, + link_flags); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(media_create_fwnode_pad_links); + +int __media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct fwnode_handle *endpoint; + + fwnode_graph_for_each_endpoint(local_fwnode, endpoint) { + struct fwnode_link link; + int local_pad; + int ret; + + local_pad = media_entity_get_fwnode_pad(local, endpoint, + MEDIA_PAD_FL_SINK | + MEDIA_PAD_FL_SOURCE); + if (local_pad < 0) + continue; + + ret = fwnode_graph_parse_link(endpoint, &link); + if (ret) + continue; + + /* + * if this endpoint does not link to the remote fwnode + * device, ignore it and continue. + */ + if (link.remote_port_parent != remote_fwnode) { + fwnode_graph_put_link(&link); + continue; + } + + ret = __media_create_fwnode_pad_link(&local->pads[local_pad], + remote, + link.remote.local_fwnode, + link_flags); + + fwnode_graph_put_link(&link); + + if (ret) { + fwnode_handle_put(endpoint); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(__media_create_fwnode_links); + +int media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct media_device *mdev = local->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __media_create_fwnode_links(local, local_fwnode, + remote, remote_fwnode, link_flags); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(media_create_fwnode_links); + void __media_entity_remove_links(struct media_entity *entity) { struct media_link *link, *tmp; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index de7fc3676b5a..781ac2df6460 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -772,6 +772,77 @@ int media_create_pad_links(const struct media_device *mdev, u32 flags, const bool allow_both_undefined); +/** + * media_create_fwnode_links() - create links formed by the fwnode + * endpoints between a known local pad and + * a remote entity. + * + * @local_pad: Pointer to &media_pad of the local media pad. + * @local_fwnode: Pointer to the local device's firmware node. + * @remote: Pointer to &media_entity of the remote device. + * @remote_fwnode: Pointer to the remote device's firmware node. + * @link_flags: Link flags, as defined in include/uapi/linux/media.h. + * + * .. note:: + * + * Before calling this function, media_entity_pads_init() and + * media_device_register_entity() should be called previously for + * both entities to be linked. + * + * Locked (via the mdev graph_mutex) and unlocked versions of this + * function are provided. If this function is called from v4l2-async + * notifier bound handlers, the locked version should be used to + * prevent races with other subdevices loading and binding to their + * notifiers in parallel. The unlocked version can for example be + * called from v4l2-async notifier complete handlers, after all + * subdevices have loaded and bound. + */ +int __media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); +int media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); + +/** + * media_create_fwnode_links() - create links formed by the fwnode + * endpoints between two entities. + * + * @local: Pointer to &media_entity of the local device. + * @local_fwnode: Pointer to the local device's firmware node. + * @remote: Pointer to &media_entity of the remote device. + * @remote_fwnode: Pointer to the remote device's firmware node. + * @link_flags: Link flags, as defined in include/uapi/linux/media.h. + * + * .. note:: + * + * Before calling this function, media_entity_pads_init() and + * media_device_register_entity() should be called previously for + * both entities to be linked. + * + * Locked (via the mdev graph_mutex) and unlocked versions of this + * function are provided. If this function is called from v4l2-async + * notifier bound handlers, the locked version should be used to + * prevent races with other subdevices loading and binding to their + * notifiers in parallel. The unlocked version can for example be + * called from v4l2-async notifier complete handlers, after all + * subdevices have loaded and bound. + */ +int __media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); +int media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); + void __media_entity_remove_links(struct media_entity *entity); /** From patchwork Mon Aug 5 23:34:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 113E113B1 for ; Mon, 5 Aug 2019 23:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 012612891F for ; Mon, 5 Aug 2019 23:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9AA82894D; Mon, 5 Aug 2019 23:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 979332891F for ; Mon, 5 Aug 2019 23:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731112AbfHEXfW (ORCPT ); Mon, 5 Aug 2019 19:35:22 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37627 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731097AbfHEXfW (ORCPT ); Mon, 5 Aug 2019 19:35:22 -0400 Received: by mail-pg1-f193.google.com with SMTP id d1so7698927pgp.4; Mon, 05 Aug 2019 16:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0YKGrpYeoAEn9gUSXzC9FX/K5C81TuWUa0ZyQnxQgg4=; b=NB75LqfP9iOlcrV9L++uSoIZ0A/Gz+fEqpArVizRSYxfGlY4jmd0leWG6WY360/YQi bw+tqNPIL1+Ymnl4UWFR4iL0+h3Q8QYBFIl4k9cM/BB2nrKXrLqVkH3qj0TNQueFQTVi SEtA4DJEjf/BnHrBUhYR69WMgY8fbjFkoHxmH/MI4PQsz2ZiRbnglV7eQMWiWy/knUDp 9qPT8XqvL53sXyD9POVVnYBz03r4b35jE1RdMn4T5BWJOp3iQFayFKsbxeDeVRXP5Xa+ XbqPvR3wbHhOaifv7ezUZB/XjXlHJJPnSLEnrgk9oK408Oz2cOuNj5s+VeudroacMz5L suyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0YKGrpYeoAEn9gUSXzC9FX/K5C81TuWUa0ZyQnxQgg4=; b=n05Tq5SUp8Rag54VAAG0rytCoev9qcDh98DQcE/Jidp5/FCQjxFHZaxXvlz1A864mK dRGeboGyZkOdQdCG3LJfQq/rWKrXPDSDeMUy8BqUgMJJEXVaY/NvS3rxoWo+ts/Q9glb s2tdLGgEye5uX+XAyyTEUBx70Y2xI9MRrA+/stAMNAypj/ZMQF76weI+QQtQZI8RmUFN pQjJDz+ZBsGxwyoLsxU94ng5BlS32QQ6HkhBQiMq3SJnQFnTjdSbwK9TPja2ltOx6tnE v7Ymgsb2EvGQIqVrjOAsdrdifXMIzvOTz2hkas62PqzBPplvxbq9XdFp0GuoOoAdN5sw 1dYw== X-Gm-Message-State: APjAAAWCu5+wrgKnxAvelC2IXDhvzSYw0bwO4aiLVyayhNjs2azhpU+D sXBZrVezk7BQsDX9qUeTco7QMl4W X-Google-Smtp-Source: APXvYqwVy1vsx6X+g2YUpWBSfEcDbd7CqIq3nB6v1wnUaPlcwVjKtF8JMVayTWFyrgTanYpawdhhuw== X-Received: by 2002:a63:724b:: with SMTP id c11mr377260pgn.30.1565048120941; Mon, 05 Aug 2019 16:35:20 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:20 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Kieran Bingham , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 06/22] media: adv748x: csi2: Implement get_fwnode_pad Date: Mon, 5 Aug 2019 16:34:49 -0700 Message-Id: <20190805233505.21167-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the given endpoint fwnode passed to the .get_fwnode_pad() op is the adv748x-csi2 TXA/TXB source endpoint, return the associated media pad index ADV748X_CSI2_SOURCE. The adv748x-csi2 has no other media pads that are associated with fwnode endpoints. Signed-off-by: Steve Longerbeam --- drivers/media/i2c/adv748x/adv748x-csi2.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index 2091cda50935..810085a1f2f0 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -228,6 +228,24 @@ static const struct v4l2_subdev_ops adv748x_csi2_ops = { .pad = &adv748x_csi2_pad_ops, }; +/* ----------------------------------------------------------------------------- + * media_entity_operations + */ + +static int adv748x_csi2_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); + + return endpoint->local_fwnode == tx->sd.fwnode ? + ADV748X_CSI2_SOURCE : -ENXIO; +} + +static const struct media_entity_operations adv748x_csi2_entity_ops = { + .get_fwnode_pad = adv748x_csi2_get_fwnode_pad, +}; + /* ----------------------------------------------------------------------------- * Subdev module and controls */ @@ -295,6 +313,9 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) /* Register internal ops for incremental subdev registration */ tx->sd.internal_ops = &adv748x_csi2_internal_ops; + /* Register media_entity ops */ + tx->sd.entity.ops = &adv748x_csi2_entity_ops; + tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK; tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE; From patchwork Mon Aug 5 23:34:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7EAC13B1 for ; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C666F28783 for ; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB2992891F; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CE4828927 for ; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731149AbfHEXf0 (ORCPT ); Mon, 5 Aug 2019 19:35:26 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36916 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731115AbfHEXfX (ORCPT ); Mon, 5 Aug 2019 19:35:23 -0400 Received: by mail-pl1-f195.google.com with SMTP id b3so37084722plr.4; Mon, 05 Aug 2019 16:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6iYP0JvYAFLVtV3J8Qmrytu1XRzVtGshvxdwIhQDdoY=; b=scLTDol5C2jg+ClxVnIhjbbp5VE8ZjWIY804LSIf8WVkN9YLR8H1FdXIik1FpaRpky 4U4mydJhQ8PTw22Ek03c2kmX+JPGhkfUJl+cnpsQraCQQBT/60I03Tu7jJhV+J7UEIw6 boeinbU/unQsZpaWQRKziufNLBaJtxc2j/6vLvRJVVYkddDfaOGv1e6Zx542QTKUD53b ry8OUjsqgYiSV18EHY0g1DNTNhLfN5TCo+f/OqZB5DGEnyHzWwJIaa4A+WgJUQW8Jxqf FTGYaFPrapdDmtEjJNdzOqvnb8U9y/Ix/mmPHCNynIiTHNmezvJYOSEHcrwnp8hKdZKy y2SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6iYP0JvYAFLVtV3J8Qmrytu1XRzVtGshvxdwIhQDdoY=; b=DiFKdT3wAY9+8NFw9rFyT8uxCa35fBqG2wezXbO7GGgiYNBcBR5/lcnj2+51CGPjDI 90Q78ckQ+PouxOfCFkSn8woAiPvyrjLS+XHbH8fsusgKFHaaj3NtWx84quHtt6kzpJc2 oOZoQAWDRIkxdMlGeu3e/9/K2Nk7Gd7cpzzMuthYMDgByVdFv3OJAyURCkYmRUuJcr/H LKX8DkU/nywu0TfFP/ZGXyC0/fn7yY/vM81R5BaeTadm/2pdSrzg0JV/GWp38hx30DSR 7BOU563aLzQzebvXkEYvx0ObLhopiZYDWe59I2JiTgpx1L3i8O+gWyw4hNUhoRyUVCvc spkw== X-Gm-Message-State: APjAAAXDHd+ud2bnyQR02CiYO5zcEHCxKeE4hh7p7xPwKqaeEyzz5hZj 1Lva9xlYgsWf9yDsQhUhisu65JGn X-Google-Smtp-Source: APXvYqxnFV+w2xRTJC/frsYbXUgsKT+u5wgE+5vFHDLK4JO+xBtwCGP51zB3HGy/3zAybgG02MgcnQ== X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr275038plp.126.1565048121997; Mon, 05 Aug 2019 16:35:21 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:21 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , =?utf-8?q?Niklas_S=C3=B6derlun?= =?utf-8?q?d?= , Mauro Carvalho Chehab , linux-renesas-soc@vger.kernel.org (open list:MEDIA DRIVERS FOR RENESAS - VIN), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 07/22] media: rcar-csi2: Fix fwnode media link creation Date: Mon, 5 Aug 2019 16:34:50 -0700 Message-Id: <20190805233505.21167-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rcsi2_notify_bound() passes the bound subdev's match fwnode to media_entity_get_fwnode_pad() to determine the subdev's source pad for creating the media link to it. When the bound subdev is the adv748x-csi2 transmitter, this is in fact correctly the endpoint fwnode. For other subdevices this likely will not be the case, the asd match fwnode is usually not an endpoint fwnode but rather the port parent fwnode. So rcar-csi2 will fail to get the correct source pad for bound subdev's other than the adv748x. To fix and make rcar-csi2 connect more generally to other subdevices, replace the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 769afd212b160 ("media: rcar-csi2: add Renesas R-Car MIPI CSI-2 receiver driver") Signed-off-by: Steve Longerbeam --- drivers/media/platform/rcar-vin/rcar-csi2.c | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index c14af1b929df..13242cbad8d3 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -738,23 +738,20 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd) { struct rcar_csi2 *priv = notifier_to_csi2(notifier); - int pad; + int ret; - pad = media_entity_get_fwnode_pad(&subdev->entity, asd->match.fwnode, - MEDIA_PAD_FL_SOURCE); - if (pad < 0) { - dev_err(priv->dev, "Failed to find pad for %s\n", subdev->name); - return pad; - } + ret = media_create_fwnode_pad_links(&priv->subdev.entity.pads[0], + dev_fwnode(priv->dev), + &subdev->entity, + dev_fwnode(subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; priv->remote = subdev; - dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad); - - return media_create_pad_link(&subdev->entity, pad, - &priv->subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + return 0; } static void rcsi2_notify_unbind(struct v4l2_async_notifier *notifier, From patchwork Mon Aug 5 23:34:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 930A3912 for ; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83FCD28783 for ; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78A552897C; Mon, 5 Aug 2019 23:35:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5E2B2891F for ; Mon, 5 Aug 2019 23:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731139AbfHEXfZ (ORCPT ); Mon, 5 Aug 2019 19:35:25 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45676 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731128AbfHEXfY (ORCPT ); Mon, 5 Aug 2019 19:35:24 -0400 Received: by mail-pl1-f194.google.com with SMTP id y8so37069587plr.12; Mon, 05 Aug 2019 16:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dAKOIEeoGKu9ksf9veB0nLPjInrgxCMs8JCeUaCJVi0=; b=e3xC1zSth5xJ9t+xenegQIapzXe7iP2UT8tigtvLc/Gr33QnxqBOEBhtRWyDqeoM0l sxbis/aNlfzP9WITSOp8XAymZZ2H/P8zBbWcZs8ofDRSIfunB1PaaczoIv7NfTyGgUbJ z+crIVRh2y8O16DDwh+UWmN5hfz0vn+9+I46V0yPR41l22XDBW6ql95YzIb1x4gPlCkg UV0cw01giVtIesB8Enr2F9YDVvxHjvbCXYoFc3RCIcKz2a1Fklm78Jue9Fzj/eWTRB2l cSBCMjs0nSskqfF1AKmnm9NmtjGz2jcPLnzW/htot7YlQtsDec58kcEI0vYLvW9sGQBk TBrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dAKOIEeoGKu9ksf9veB0nLPjInrgxCMs8JCeUaCJVi0=; b=iKsqTNyyRlQwwcjk0GTHgglMVRnaM22PBKexMvhX1+7KJ+g0Wsh/vNpkKO2j6Nlmpj jKcHfvXWOFrTQ+47qaNUrVBijWrZf3gTq/Foeoke6jDuYD+hGWspm/4FSTqFOUpz3rHh qs4trMUNw+U3Ai1c2jhMKF321Bspbb77CbGCy898DwJZj/AhvyZrN0Gmj5pdHtDhLEKK WjN3lP+7+2MlnCmA2VrmILy5E450B3q+XD62gbP9VSVMGOdoRn5rsueMySbt29zOhB5t r18xl1/I2G3QHyAJDQ4HzKfOrBwAK/gRd5NDTjWetn7k97OUuu4S3wjCGSScUzFUmKM+ L+gg== X-Gm-Message-State: APjAAAU+lIX3Fhj/UYfZ9mLG3ks0HL5AscyQocGHapvE/RhGlGPTAqhT PkfxknnqEIpP0E0X+3zU+Ji2EPqW X-Google-Smtp-Source: APXvYqzD2xGj9zA7t3v6eQic5J2mNV9AGfP/U50BBVRpjt4OK6trPgi1se6DWSe3zb4fWjPBj3Xm8Q== X-Received: by 2002:a17:902:4283:: with SMTP id h3mr243406pld.15.1565048123016; Mon, 05 Aug 2019 16:35:23 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:22 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Maxime Ripard , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 08/22] media: cadence: csi2rx: Fix fwnode media link creation Date: Mon, 5 Aug 2019 16:34:51 -0700 Message-Id: <20190805233505.21167-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP csi2rx_async_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 1fc3b37f34f69 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver") Signed-off-by: Steve Longerbeam --- drivers/media/platform/cadence/cdns-csi2rx.c | 27 ++++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 31ace114eda1..d478800a3859 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -83,7 +83,6 @@ struct csi2rx_priv { /* Remote source */ struct v4l2_async_subdev asd; struct v4l2_subdev *source_subdev; - int source_pad; }; static inline @@ -251,26 +250,20 @@ static int csi2rx_async_bound(struct v4l2_async_notifier *notifier, { struct v4l2_subdev *subdev = notifier->sd; struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + int ret; - csi2rx->source_pad = media_entity_get_fwnode_pad(&s_subdev->entity, - s_subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - if (csi2rx->source_pad < 0) { - dev_err(csi2rx->dev, "Couldn't find output pad for subdev %s\n", - s_subdev->name); - return csi2rx->source_pad; - } + ret = media_create_fwnode_pad_links(&csi2rx->subdev.entity.pads[0], + dev_fwnode(csi2rx->dev), + &s_subdev->entity, + dev_fwnode(s_subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; csi2rx->source_subdev = s_subdev; - dev_dbg(csi2rx->dev, "Bound %s pad: %d\n", s_subdev->name, - csi2rx->source_pad); - - return media_create_pad_link(&csi2rx->source_subdev->entity, - csi2rx->source_pad, - &csi2rx->subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + return 0; } static const struct v4l2_async_notifier_operations csi2rx_notifier_ops = { From patchwork Mon Aug 5 23:34:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5EDE13B1 for ; Mon, 5 Aug 2019 23:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AFD2891F for ; Mon, 5 Aug 2019 23:36:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8C3A2894D; Mon, 5 Aug 2019 23:36:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AB192891F for ; Mon, 5 Aug 2019 23:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731441AbfHEXge (ORCPT ); Mon, 5 Aug 2019 19:36:34 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42480 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731097AbfHEXfZ (ORCPT ); Mon, 5 Aug 2019 19:35:25 -0400 Received: by mail-pf1-f194.google.com with SMTP id q10so40406170pff.9; Mon, 05 Aug 2019 16:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sLSukBr2Dr/fkgKqS432Drjpjtgmp1YtkMGvOGWg9/A=; b=ssmMvt5WCl/uRVDnSNPt4nSuNoE1M3ZRy31D9o4qEeDpQBL314Lb5MhF1Y88I5QXwd +76WDYgBLRNqZn+i0gu8M+NaYA6MGYuQmuGzkKDhOrQtN51oZcn9hIVzZacRJRdTVLY6 3Au6tNwHcx3LkgmIZJCqdTV2lCmGLjNNKfybzQgH7yoHFPKuo3lUhiOSSRgKrN0JngKn xVviFCYLs1IopioWs6AX5zvksXZexNZsp1H03p/Wsytz5o6PJmDztvm1FcPBD/0EcUiY n+Imbga638jsSiV8ZM4Z+qSDJ2MdYwK64CbIyPbDuBC/+gzfKTziJMwDLGcwc7hYTnKS k7bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sLSukBr2Dr/fkgKqS432Drjpjtgmp1YtkMGvOGWg9/A=; b=Ah86oymqPNDhNyS1IdnX4xGj1JbnlopS2c8JDJtbuJkd8JTHBM1K43uNryHgO+c+Tg NTVU8qYh3faACks1VRw9sL1s+fp5bWKFXU24rahbK45nYMWWK+A7J9B7zD236N15MK+E 6O9xo4nbIbuqjaYLb9oxF6Gw53nWPmYcEteef2t6E1IAJkU69QJFuq1LkvZBjv7BXHYZ NFcwvarkYXoHli4RDbdhzM8Q/qa5wjQ5qxJyHNV8/8axgLCWPieDk2EqO9DcMCPsgnU3 DeDqSdYWsfm2Qc0KfRy5i2XWe2Xxd9pa9I/dxG/f9uKQx34Hmc/FgbIrII/tr2w3rOK/ xo7Q== X-Gm-Message-State: APjAAAWKGtd2CPPdlL3Wf14KQes7Uil7Unllrt89azlrU+uCykJDG7kj 9e/H012xgePK5yfZExk5QJMUeJEX X-Google-Smtp-Source: APXvYqxdrgMTw3ampNtYtP76n+DzZeeu18uPjTa9aAYoc3tHW8eoeyXU0JU2dmiZHiOit2WQTYQmlA== X-Received: by 2002:a63:4404:: with SMTP id r4mr311426pga.245.1565048124005; Mon, 05 Aug 2019 16:35:24 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:23 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Yong Deng , Mauro Carvalho Chehab , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 09/22] media: sun6i: Fix fwnode media link creation Date: Mon, 5 Aug 2019 16:34:52 -0700 Message-Id: <20190805233505.21167-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sun6i_csi_link_entity() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 5cc7522d89655 ("media: sun6i: Add support for Allwinner CSI V3s") Signed-off-by: Steve Longerbeam --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 6e0e894154f4..9cf726b5c25a 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -630,37 +630,11 @@ static int sun6i_csi_link_entity(struct sun6i_csi *csi, struct media_entity *entity, struct fwnode_handle *fwnode) { - struct media_entity *sink; - struct media_pad *sink_pad; - int src_pad_index; - int ret; - - ret = media_entity_get_fwnode_pad(entity, fwnode, MEDIA_PAD_FL_SOURCE); - if (ret < 0) { - dev_err(csi->dev, "%s: no source pad in external entity %s\n", - __func__, entity->name); - return -EINVAL; - } - - src_pad_index = ret; - - sink = &csi->video.vdev.entity; - sink_pad = &csi->video.pad; - - dev_dbg(csi->dev, "creating %s:%u -> %s:%u link\n", - entity->name, src_pad_index, sink->name, sink_pad->index); - ret = media_create_pad_link(entity, src_pad_index, sink, - sink_pad->index, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) { - dev_err(csi->dev, "failed to create %s:%u -> %s:%u link\n", - entity->name, src_pad_index, - sink->name, sink_pad->index); - return ret; - } - - return 0; + return media_create_fwnode_pad_links(&csi->video.pad, + dev_fwnode(csi->dev), + entity, fwnode, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); } static int sun6i_subdev_notify_complete(struct v4l2_async_notifier *notifier) From patchwork Mon Aug 5 23:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DCF613B1 for ; Mon, 5 Aug 2019 23:36:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08C8C2891F for ; Mon, 5 Aug 2019 23:36:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEF252894D; Mon, 5 Aug 2019 23:36:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 982BB2891F for ; Mon, 5 Aug 2019 23:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731186AbfHEXg1 (ORCPT ); Mon, 5 Aug 2019 19:36:27 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41549 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731136AbfHEXf0 (ORCPT ); Mon, 5 Aug 2019 19:35:26 -0400 Received: by mail-pl1-f194.google.com with SMTP id m9so36921728pls.8; Mon, 05 Aug 2019 16:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zuSwOrhBwRQRJK3HV6p1JJE9Ot+MWPiWfnDhw3EwSv0=; b=FGVT31NIzx7m9SF7Q0Dc1L8TsU4TH+S600fxoJ9YuNKFMCRHwmFra98AB2Ef9nWJf1 DdO6fY1kLxQN7xXToQ0cagEvPC5e3rIPjMa57igQ7ALrU7KEFwGy8Sf01gJS5nEzYmqW CXiENe5g8DuLhFJs3XDaoGNmVm+B/96Z3ZM8E3t29/nhccr0eQMmyZOXdoD8IQjUfYOT R7HEfUbnARG0IxRVTO1PQtn6Tr9423SMsfm7HZzZcmC9g6x0TSFhxYTa02JTETEz9BnF xuNhZ/BylpxFyArCh30z8hjyE7pd0fgWBzKbByT81KkjA31jhxm2L56kOS/AROSiqlxv Wryw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zuSwOrhBwRQRJK3HV6p1JJE9Ot+MWPiWfnDhw3EwSv0=; b=DeTiwHHKNCx645ix/0mi/81J3v4bCJuaE2ijY+Dw5W/9MBcSlIBtIj3K1/c02tN14o jOcCGNX0oFqhrNUbB2OClqNQw7qmpLLis1ckj0xDonLcO0pSjUFSHpMGsVgWIQDH2bdh WPOpb6TPIzmmuA0QQgASqyKMWwjBY0Ke8GzPIy2VXizpwfXmV6aUHtBwmXCt61XDmiaT muFcwWtukuz/NMbM2PvOevWwEhJ/fMxNBOBzz9mkgGLhsEzd17VpjmleyTisHveeYSwK 75tIO9KdAucmIyWVTPDfXky2+REEn7SDu1pydaz1FQlzSpKJYC+wE/1qsKhdis5RckRC Ltmg== X-Gm-Message-State: APjAAAXqgtAN2/OzIbGEBFgj51IO01MGFLsAFYoGZuJPG+eH3+t0IHs6 VwuMldxTE0l0JChIK8mRah0PESay X-Google-Smtp-Source: APXvYqxK4pAauGaw8Udm7cWR+aa6q19pAm0uea65JLPXzYXqBuTFmmBzLFxGNrVU7vSGiVXiEq8cwQ== X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr254403plo.290.1565048125076; Mon, 05 Aug 2019 16:35:25 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:24 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Mickael Guene , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 10/22] media: st-mipid02: Fix fwnode media link creation Date: Mon, 5 Aug 2019 16:34:53 -0700 Message-Id: <20190805233505.21167-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP mipid02_async_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 642bb5e88fed8 ("media: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver") Signed-off-by: Steve Longerbeam --- drivers/media/i2c/st-mipid02.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index 81285b8d5cfb..b26d5550874f 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -798,24 +798,16 @@ static int mipid02_async_bound(struct v4l2_async_notifier *notifier, { struct mipid02_dev *bridge = to_mipid02_dev(notifier->sd); struct i2c_client *client = bridge->i2c_client; - int source_pad; int ret; dev_dbg(&client->dev, "sensor_async_bound call %p", s_subdev); - source_pad = media_entity_get_fwnode_pad(&s_subdev->entity, - s_subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - if (source_pad < 0) { - dev_err(&client->dev, "Couldn't find output pad for subdev %s\n", - s_subdev->name); - return source_pad; - } - - ret = media_create_pad_link(&s_subdev->entity, source_pad, - &bridge->sd.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + ret = media_create_fwnode_pad_links(&bridge->sd.entity.pads[0], + dev_fwnode(&client->dev), + &s_subdev->entity, + dev_fwnode(s_subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); if (ret) { dev_err(&client->dev, "Couldn't create media link %d", ret); return ret; From patchwork Mon Aug 5 23:34:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA9EA912 for ; Mon, 5 Aug 2019 23:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6C62891F for ; Mon, 5 Aug 2019 23:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE4D32894D; Mon, 5 Aug 2019 23:36:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DF272891F for ; Mon, 5 Aug 2019 23:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731184AbfHEXfa (ORCPT ); Mon, 5 Aug 2019 19:35:30 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45085 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731172AbfHEXf2 (ORCPT ); Mon, 5 Aug 2019 19:35:28 -0400 Received: by mail-pf1-f193.google.com with SMTP id r1so40409689pfq.12; Mon, 05 Aug 2019 16:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UgoIagqsWr60jnSWexngudSw/GwE5rD1jIoLj49qMwY=; b=R2Q3ujMPxawa8Ih7aXqp3Qg1h8/R/awfKhqLCTfyfpIm5oT6+RVS4em3Jx8/I4Cku9 pwQECqGipkn48+tT5RSkwHjVxKeRBUftfOuNTsO4cy0o49HItAynGTsARGDY1Vq3jDu8 fse/w6WUMHDLhuLJsJSQvew7Z/PElcZ4VHDxGQ3/3JJjH/mNfQdL3lcUZAhUv8DSuhMh lrKbji7udkd5AZuLqkW6QWapCMe0mIDBur5YVAk6bWxQuAAoYUAKRSGQUA8Oru6kOWMV uKPJ33SyiOWgdmODdyzKJ8e03JSz7RKmF7lISuIzf7Ji7+Gq0HJ9DtWNBjIUeMSZpozN Q+GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UgoIagqsWr60jnSWexngudSw/GwE5rD1jIoLj49qMwY=; b=tK7EwKta2AQL9Pjfcwf0l8huPxV/yhd3vkabvBIW7LCSh+Vfs8tbw2p61pHhpa0CXV YGLrSuyJCl0/AqHz2s8et3rIyU7DiBsfBgorJDnLBnqcY8EDPzgmACVNZtifaz3Zt+xS qL3eFudBBmTjfcQNmv2Dv33C+NgQWG+/8XR/v4C+wSKIpL5nYUU6HKVhIjC5G4Hj2z6h KBpTTnY1XrXal73feWa0kaRLGnqcR16uwAXpQjX2Y/8VZL/KgwXdm6iH0Lkh96wEL+us 1xtaDVuDHOrYy+/MuMZxfyCs9lZ298lLSh/DpJR75fFlMXmrOe5TxoSaH9Itlbs6koFV LZug== X-Gm-Message-State: APjAAAV32y+ytCwLPkdYp4jXygtF6AzkJq0XBPZu2iQpUAl7klaF22kU GGDJN2S2FSEEo4ZIOSygNh1Fslcv X-Google-Smtp-Source: APXvYqy9NbfueskhgMm+yPwYldKJ5nVyez32oNS70n9npXFHhG92pCWMjWrdWUkzDDfL2FSIvahpDQ== X-Received: by 2002:a62:e910:: with SMTP id j16mr525719pfh.123.1565048127806; Mon, 05 Aug 2019 16:35:27 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:27 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , Sakari Ailus , Jacopo Mondi , Hans Verkuil , linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH 11/22] media: v4l2-fwnode: Pass notifier to v4l2_async_register_fwnode_subdev() Date: Mon, 5 Aug 2019 16:34:54 -0700 Message-Id: <20190805233505.21167-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of allocating a notifier in v4l2_async_register_fwnode_subdev(), have the caller provide one. This allows the caller to implement notifier ops (bind, unbind). The caller is now responsible for first initializing its notifier with a call to v4l2_async_notifier_init(). Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 6 +++++- drivers/media/v4l2-core/v4l2-fwnode.c | 11 +---------- drivers/staging/media/imx/imx6-mipi-csi2.c | 5 ++++- drivers/staging/media/imx/imx7-media-csi.c | 5 ++++- drivers/staging/media/imx/imx7-mipi-csis.c | 5 ++++- include/media/v4l2-fwnode.h | 12 ++++++++---- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ddd0e338f9e4..ca1cef783646 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -21,6 +21,7 @@ struct video_mux { struct v4l2_subdev subdev; + struct v4l2_async_notifier notifier; struct media_pad *pads; struct v4l2_mbus_framefmt *format_mbus; struct mux_control *mux; @@ -354,8 +355,11 @@ static int video_mux_async_register(struct video_mux *vmux, for (i = 0; i < num_input_pads; i++) ports[i] = i; + v4l2_async_notifier_init(&vmux->notifier); + ret = v4l2_async_register_fwnode_subdev( - &vmux->subdev, sizeof(struct v4l2_async_subdev), + &vmux->subdev, &vmux->notifier, + sizeof(struct v4l2_async_subdev), ports, num_input_pads, video_mux_parse_endpoint); kfree(ports); diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 5d4ce4aa3fdc..8f5b3fdea061 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -1124,12 +1124,12 @@ int v4l2_async_register_subdev_sensor_common(struct v4l2_subdev *sd) EXPORT_SYMBOL_GPL(v4l2_async_register_subdev_sensor_common); int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, parse_endpoint_func parse_endpoint) { - struct v4l2_async_notifier *notifier; struct device *dev = sd->dev; struct fwnode_handle *fwnode; int ret; @@ -1141,12 +1141,6 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (!fwnode_device_is_available(fwnode)) return -ENODEV; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); - if (!ports) { ret = v4l2_async_notifier_parse_fwnode_endpoints(dev, notifier, asd_struct_size, @@ -1171,15 +1165,12 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (ret < 0) goto out_unregister; - sd->subdev_notifier = notifier; - return 0; out_unregister: v4l2_async_notifier_unregister(notifier); out_cleanup: v4l2_async_notifier_cleanup(notifier); - kfree(notifier); return ret; } diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index f29e28df36ed..408ee2765e77 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -35,6 +35,7 @@ struct csi2_dev { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct media_pad pad[CSI2_NUM_PADS]; struct clk *dphy_clk; struct clk *pllref_clk; @@ -643,8 +644,10 @@ static int csi2_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &csi2->sd); + v4l2_async_notifier_init(&csi2->notifier); + ret = v4l2_async_register_fwnode_subdev( - &csi2->sd, sizeof(struct v4l2_async_subdev), + &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); if (ret) goto dphy_off; diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 500b4c08d967..a1c96c52a606 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -155,6 +155,7 @@ struct imx7_csi { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct imx_media_video_dev *vdev; struct imx_media_dev *imxmd; struct media_pad pad[IMX7_CSI_PADS_NUM]; @@ -1250,7 +1251,9 @@ static int imx7_csi_probe(struct platform_device *pdev) v4l2_ctrl_handler_init(&csi->ctrl_hdlr, 0); csi->sd.ctrl_handler = &csi->ctrl_hdlr; - ret = v4l2_async_register_fwnode_subdev(&csi->sd, + v4l2_async_notifier_init(&csi->notifier); + + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, imx7_csi_parse_endpoint); diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index d1cdf011c8f1..f71d9183cad2 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -223,6 +223,7 @@ struct csi_state { struct device *dev; struct media_pad pads[CSIS_PADS_NUM]; struct v4l2_subdev mipi_sd; + struct v4l2_async_notifier notifier; struct v4l2_subdev *src_sd; u8 index; @@ -892,7 +893,9 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, v4l2_set_subdevdata(mipi_sd, &pdev->dev); - ret = v4l2_async_register_fwnode_subdev(mipi_sd, + v4l2_async_notifier_init(&state->notifier); + + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, mipi_csis_parse_endpoint); diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f81f8bf34526..27a7b78149c2 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -331,6 +331,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * and parses fwnode endpoints * * @sd: pointer to struct &v4l2_subdev + * @notifier: the sub-device's notifier. * @asd_struct_size: size of the driver's async sub-device struct, including * sizeof(struct v4l2_async_subdev). The &struct * v4l2_async_subdev shall be the first member of @@ -343,13 +344,15 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * endpoint. Optional. * * This function is just like v4l2_async_register_subdev() with the - * exception that calling it will also allocate a notifier for the - * sub-device, parse the sub-device's firmware node endpoints using - * v4l2_async_notifier_parse_fwnode_endpoints() or + * exception that calling it will also parse the sub-device's firmware + * node endpoints using v4l2_async_notifier_parse_fwnode_endpoints() or * v4l2_async_notifier_parse_fwnode_endpoints_by_port(), and - * registers the sub-device notifier. The sub-device is similarly + * registers the sub-device's notifier. The sub-device is similarly * unregistered by calling v4l2_async_unregister_subdev(). * + * The caller must first initialize the notifier with a call to + * v4l2_async_notifier_init(). + * * While registered, the subdev module is marked as in-use. * * An error is returned if the module is no longer loaded on any attempts @@ -357,6 +360,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, */ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, From patchwork Mon Aug 5 23:34:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A95213B1 for ; Mon, 5 Aug 2019 23:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ABA12891F for ; Mon, 5 Aug 2019 23:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F0A42894D; Mon, 5 Aug 2019 23:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF3E72891F for ; Mon, 5 Aug 2019 23:36:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731194AbfHEXfb (ORCPT ); Mon, 5 Aug 2019 19:35:31 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41144 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731115AbfHEXf3 (ORCPT ); Mon, 5 Aug 2019 19:35:29 -0400 Received: by mail-pf1-f195.google.com with SMTP id m30so40432226pff.8; Mon, 05 Aug 2019 16:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y+3BTNqSaca7NC83BwvFX9hsocsd054ub84DKx6q1XE=; b=KoKc5DK30Md16JA+DyXHLNy33mpCUrYqHHRCkddG8pzUv9kdPZK/iQalA1WFhuM8E1 CySVvGmma07vfpeZRuy67pE6/W2/kPU9GtIuHAzgJVcf4cEsluharV+eONBG+qcTqGq7 ApEFWz0upkwViZh6KIZ0S3jDOZpo307dMP/DG07srgjcypogMOfNpXetQSOGt8MkyP/f D3LSYPhs+EfV/u0Xj+qMn7beIb5zBLYUEhNuyC7sP4U6h5sfq9JPtMxpN5jOQrVZYFCA 0yCcfTFwHirxl1lcPUotkWooGXujerpoB0DWUJbWkZ1YzK7QR49hIc5IS91aEf8bgY9u TENw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y+3BTNqSaca7NC83BwvFX9hsocsd054ub84DKx6q1XE=; b=QZJI6eOwsCVXDvoF9jkRjvO3fthZyowykqbVbC4O2ayU3tc0gk8hVTrDvud0ZvEqjg C1vQthlEfVhx+9G/1SNGV7O9tYi3hO8Xo5/7UqVf4BDW/ugGSL1SFOjMzoxvC3pxH9H3 qaLYRWYFOAi91b04YhX8MGowelm2adsxc4eCvACTkvrm8ojgSUYGtP9N28ianAKgmN5Q niNa//gWyTP++EAutAQmN3/g+xLjMnAiFyWlbMZxKhbisyW2Fvs0aq626PPu09RWMhoz dlxVBfATpAR39DTR/o20KG5sSX4Xjwfh4bnK5hhoo0aF8ZWBMP2s68b6/hTGSLphZKNj +M2Q== X-Gm-Message-State: APjAAAWKL/zej9NNwwyxAnvDrQKDzsyv31TL5F3QzG1VGSw4KTRe/yL4 2AUoel7S2SJ4fF5P9MFG9wNYMSKC X-Google-Smtp-Source: APXvYqwjVjMjyeJjldrM9dQ93kuihvd5boLWfVbSw0+/fP9idMGt/uh0HYrkaEumlKFactdy8oQXRQ== X-Received: by 2002:a62:2ccc:: with SMTP id s195mr525087pfs.256.1565048128785; Mon, 05 Aug 2019 16:35:28 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:28 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 12/22] media: video-mux: Create media links in bound notifier Date: Mon, 5 Aug 2019 16:34:55 -0700 Message-Id: <20190805233505.21167-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a notifier bound op to register media links from the remote sub-device's source pads to all of the video-mux sink pads. Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ca1cef783646..de5b0698fc1d 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -36,6 +36,12 @@ static const struct v4l2_mbus_framefmt video_mux_format_mbus_default = { .field = V4L2_FIELD_NONE, }; +static inline struct video_mux * +notifier_to_video_mux(struct v4l2_async_notifier *n) +{ + return container_of(n, struct video_mux, notifier); +} + static inline struct video_mux *v4l2_subdev_to_video_mux(struct v4l2_subdev *sd) { return container_of(sd, struct video_mux, subdev); @@ -343,6 +349,22 @@ static int video_mux_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int video_mux_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct video_mux *vmux = notifier_to_video_mux(notifier); + + return media_create_fwnode_links(&vmux->subdev.entity, + dev_fwnode(vmux->subdev.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations video_mux_notify_ops = { + .bound = video_mux_notify_bound, +}; + static int video_mux_async_register(struct video_mux *vmux, unsigned int num_input_pads) { @@ -357,6 +379,8 @@ static int video_mux_async_register(struct video_mux *vmux, v4l2_async_notifier_init(&vmux->notifier); + vmux->notifier.ops = &video_mux_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &vmux->subdev, &vmux->notifier, sizeof(struct v4l2_async_subdev), From patchwork Mon Aug 5 23:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F7FA912 for ; Mon, 5 Aug 2019 23:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F32E52891F for ; Mon, 5 Aug 2019 23:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E748E2892D; Mon, 5 Aug 2019 23:36:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 916932891F for ; Mon, 5 Aug 2019 23:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731391AbfHEXgO (ORCPT ); Mon, 5 Aug 2019 19:36:14 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40166 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731186AbfHEXfb (ORCPT ); Mon, 5 Aug 2019 19:35:31 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so40516675pgj.7; Mon, 05 Aug 2019 16:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fq0ktF/hBsnVFU7IozmhPFjtW2ydpZCCyFzM6I7LgOw=; b=X1OFNeqhQV0f90G9Q7+G/pt7EmUwrtUkbHW/9JOGxoTbmYiXMk1Gj8dkdpGlNnMIGU wlOOqDsjYDIbpNdCyuIysrh8YqS3FTQHYSEsfxu6VJSZV5FBXrd9ZVMZkzOSiUR3yA7q EAktoUHQQMN5VidRCbgrtsBJqlD4u9AH8Dm6kJwWq5rluZLYfKVE6zRJIScYE3HNRgY2 xXDcJi1j75wi81PTvQQXY3CRCCF1fL1MkxWwNbdulab2B9AxUf4/X8cRgu5k9ittbDTD fXbDLmVbTjoaPuzBDLcfgAcjPvA4XeY6rSQEgAl2eIpxNNDhoQSNJUtKymgqCZv9GaaG 30JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fq0ktF/hBsnVFU7IozmhPFjtW2ydpZCCyFzM6I7LgOw=; b=U6TNY6AgcJ+fxwUqgwrTZWCAM77oh4chTfP/irMDek5O/WJkjkMcoWq7uzRFnSr9hK ETEu4H5cHaMe28WDiuLxtFdpfrFEG4dgHXoisvsISn69b2oJV0oiW0nUCdCPV4efQG/W I2vD0av7ZHaZPpVBjWm97Mz0b12Wv+Zy8bnGRQGP0gzYULKVb9Qxb1smiNmP/bCKNzbd 3/uB3mPQfsWiEL/uSiyP7DHlKhqZQ+GYrH25T5ilu5nx5c80oY4+JbMc7bIXK8caA37C iX54GOYhEXq0psCTIylQwsQHYZ3F9WEvGHxHmqxl9CtawT97MqV+XAmNSuL7y9/AEL/S sM7A== X-Gm-Message-State: APjAAAVDS+RFFoiFO1d8wEdH62Xn0+LOUaUWw1de6c0G1ZgXWcaXLLla d5cgQx1F80CQMP4MhtgqkLxKFjvZ X-Google-Smtp-Source: APXvYqz//7Zz8md/vVO2OPMxigo9UdlkkrkEJTsuzTyBl7CXjyfMV9TJYqhZbR9u7wNriFPY1YaD/w== X-Received: by 2002:a17:90a:cb81:: with SMTP id a1mr189808pju.81.1565048130114; Mon, 05 Aug 2019 16:35:30 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:29 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 13/22] media: imx: mipi csi-2: Create media links in bound notifier Date: Mon, 5 Aug 2019 16:34:56 -0700 Message-Id: <20190805233505.21167-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx6-mipi-csi2.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index 408ee2765e77..5b2258156781 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -91,6 +91,11 @@ static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi2_dev, sd); } +static inline struct csi2_dev *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi2_dev, notifier); +} + /* * The required sequence of MIPI CSI-2 startup as specified in the i.MX6 * reference manual is as follows: @@ -573,6 +578,23 @@ static int csi2_parse_endpoint(struct device *dev, return 0; } +static int csi2_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi2_dev *csi2 = notifier_to_dev(notifier); + struct media_pad *sink = &csi2->sd.entity.pads[CSI2_SINK_PAD]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(csi2->dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations csi2_notify_ops = { + .bound = csi2_notify_bound, +}; + static int csi2_probe(struct platform_device *pdev) { unsigned int sink_port = 0; @@ -646,6 +668,8 @@ static int csi2_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi2->notifier); + csi2->notifier.ops = &csi2_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); From patchwork Mon Aug 5 23:34:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C620113B1 for ; Mon, 5 Aug 2019 23:36:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B53BD2891F for ; Mon, 5 Aug 2019 23:36:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A89822897D; Mon, 5 Aug 2019 23:36:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 512DB28927 for ; Mon, 5 Aug 2019 23:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731385AbfHEXgN (ORCPT ); Mon, 5 Aug 2019 19:36:13 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44379 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731203AbfHEXfc (ORCPT ); Mon, 5 Aug 2019 19:35:32 -0400 Received: by mail-pg1-f194.google.com with SMTP id i18so40517064pgl.11; Mon, 05 Aug 2019 16:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fbs1mFAvJTATM6fIvB9UCHmR0ykE58CEjMWw0CNcKVw=; b=J3zvZBPbrHmjS6LZta22eIsImAqYXiEzcBjlGvfa482lW8RjJx4Akc0Ae3QmAzH2GO h0LOzT6sPTs/PEl8B7wYP3VutzzoymShyzc7QKqD/z/fAxou3Ejno26qhQWzTw9ZbvoX s7CM7TZYWM4m8Mm10u8JGrDRrw1V21hEUkPPSbplPewwOJ2nAcvDkID94cqB8PC87Pb8 vfxjBV11vQ5JhzuWPxQ/5hvbjhBvvhnci3txlljSsa0yTGdtVQksNsnCcfLM8pAgpluZ TwfQZi+2cQTMR9/zLZB2EAsHJaW1U7vUPTntLgrdSicwrUJKpr7z6mcPQ1RurdeOh4Wn 2Ndg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fbs1mFAvJTATM6fIvB9UCHmR0ykE58CEjMWw0CNcKVw=; b=M3JBsk2R6lZHuLFCbUGZXko/7mrm5SsEhgp7izLb+QNZgcQCi5Mffr8wFr7B270J3S YhL3lsZFODNHahzQcIyKLj+tyCCKm5OQVda6njHU9csdXWDZJw2ZUl/By1IGUPG46KaZ oy3sdicXIQN8MTWD+yn6GA6kFRphIfzNOMqUsf0VtDnGC7Zg89TYn40b8o+jbrq9SUsv LHBzUtzpymPEukWkMV2OmS10jepEQ4W4XG6CbuPPrQ6z2uzy0J95iBWshstalz8dQK5O W5ON+kwU/1fI526XWjqATBSaiyeqP5ewIoDpis2KkW35ySRjz0+KmahTpYVa9hAtHW/v bAsg== X-Gm-Message-State: APjAAAWsBSCHO7DcMc59rZJn6a7Tjj+ldZxZINHMMjWgsSjQZkWdBBAX fJ4mJpszgv2WhJ6gDGI4/zAtispl X-Google-Smtp-Source: APXvYqxMcB13LsIEJrOTuGY/j/XtK9RITES5UnefU9LWRAVWxAW33EUR/o2Ph3AMnZGny6/J1lcIww== X-Received: by 2002:a62:ce07:: with SMTP id y7mr548956pfg.12.1565048131431; Mon, 05 Aug 2019 16:35:31 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:30 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Rui Miguel Silva , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 14/22] media: imx7-mipi-csis: Create media links in bound notifier Date: Mon, 5 Aug 2019 16:34:57 -0700 Message-Id: <20190805233505.21167-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx7-mipi-csis.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index f71d9183cad2..e03b2317a1ac 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -259,6 +259,12 @@ struct csi_state { bool sink_linked; }; +static inline struct csi_state * +notifier_to_csis_state(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_state, notifier); +} + struct csis_pix_format { unsigned int pix_width_alignment; u32 code; @@ -863,6 +869,23 @@ static int mipi_csis_parse_endpoint(struct device *dev, return 0; } +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_state *state = notifier_to_csis_state(notifier); + struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(state->mipi_sd.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = { + .bound = mipi_csis_notify_bound, +}; + static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, struct platform_device *pdev, const struct v4l2_subdev_ops *ops) @@ -895,6 +918,8 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, v4l2_async_notifier_init(&state->notifier); + state->notifier.ops = &mipi_csis_notify_ops; + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, From patchwork Mon Aug 5 23:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4497513B1 for ; Mon, 5 Aug 2019 23:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3290F2891F for ; Mon, 5 Aug 2019 23:36:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 263EF2892D; Mon, 5 Aug 2019 23:36:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C62242891F for ; Mon, 5 Aug 2019 23:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731371AbfHEXgI (ORCPT ); Mon, 5 Aug 2019 19:36:08 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36065 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731212AbfHEXfd (ORCPT ); Mon, 5 Aug 2019 19:35:33 -0400 Received: by mail-pf1-f193.google.com with SMTP id r7so40423645pfl.3; Mon, 05 Aug 2019 16:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=80zZuvj+LjB7muc1lRSag1oD8GSQkupjbn/Cdl2Z1us=; b=m9+1Z16t7VCOSQhnktxeXV9tpgKBUk4i4dqvz1AUM2uLciXya2YHvUdXKQPg0nahrp Ls2DL2gNH8qovIXjYf3Ou4K404eivEwkhL8C+H1EjVAuTSOaDqxBoT63k1fy4l7adTzQ A8FZAf4UVV73lJCmwuyKdNwn+s/AHZiFq+Lfy7cgnR0uOjHpcX4BXip0NbwJaeDsALPC POF+Gbq9VZLBATGU2wh30Jfth38krYE1Tlw/3A1u8v02JkC6ye9uz57r4S+AHmfDMw/Q Sy8FW41P88uHNyoSkU+TtXlmHiDG1qLCBe2VO7hgLpTe/I1MZqUKNtKVgKmQSdu5Q+x8 6Prw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=80zZuvj+LjB7muc1lRSag1oD8GSQkupjbn/Cdl2Z1us=; b=nIxMgldzLGrTKqeGHOSXHfnPOHjQIK0XvvgzAOlwZLpX2WMgffLOqr1+VpfjblyVYK z+XRoQc90JyR1QGefy3XJZXSWcK1ciDDLPPeQk1OL/hjXsbjlVJYB5KCctz51uB8l5l7 2G/IvwXymJ8krJpuXp3CH4dUEPBNSRXRLU9HaYTIgQEktMLbkdw8CDB2TqyPflvr92Hh vV6gOGar7NfT+pEYyEeH+IP0UKM9HGHLlU0LtrmF93JH3IcZ2tw20Uu59dKyGzcbJkdU mI1QwGSQD858xd4TmE7pTEVqzD8EI3wM6irIJ2OteO2xvZ9gLZkSx5rpIfyX7PQYoT+e wfcA== X-Gm-Message-State: APjAAAWpW30zfvdK9Sl6/6RipCe1MYilLSXajLWqLtCGaQhbD1kKvyGo ImcJgjCUMt/FfIy34a7g8buLS/xm X-Google-Smtp-Source: APXvYqynuc9WSN7P4iFLSAjU9euUo/l2aSIhsQXrCHSGZFYLHfCOnZ0+BnlOVd8HxGgj63ZeqPGtRw== X-Received: by 2002:aa7:9481:: with SMTP id z1mr560979pfk.92.1565048132680; Mon, 05 Aug 2019 16:35:32 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:32 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Rui Miguel Silva , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 15/22] media: imx7-media-csi: Create media links in bound notifier Date: Mon, 5 Aug 2019 16:34:58 -0700 Message-Id: <20190805233505.21167-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the CSI sink pad. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx7-media-csi.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index a1c96c52a606..f71ac485f780 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -196,6 +196,11 @@ struct imx7_csi { struct completion last_eof_completion; }; +static inline struct imx7_csi *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct imx7_csi, notifier); +} + static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset) { return readl(csi->regbase + offset); @@ -1173,6 +1178,23 @@ static int imx7_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; } +static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct imx7_csi *csi = notifier_to_dev(notifier); + struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(csi->sd.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { + .bound = imx7_csi_notify_bound, +}; + static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1253,6 +1275,8 @@ static int imx7_csi_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi->notifier); + csi->notifier.ops = &imx7_csi_notify_ops; + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, From patchwork Mon Aug 5 23:34:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 628F3912 for ; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4583027C0B for ; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33F3027F7F; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD8526538 for ; Mon, 5 Aug 2019 23:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731227AbfHEXff (ORCPT ); Mon, 5 Aug 2019 19:35:35 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45093 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731219AbfHEXff (ORCPT ); Mon, 5 Aug 2019 19:35:35 -0400 Received: by mail-pf1-f196.google.com with SMTP id r1so40409791pfq.12; Mon, 05 Aug 2019 16:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dlPssYq0ryvhz0STq2y2DANQYDQwBzmO+X3pNrhAOiU=; b=HauhLk8diwPqoMNLaCvVs+Va+/vM1Lotb6yd4g0srzVoCT4ME7KaWNu46fQtchpf/Y 4jTYQIFp17uXOCGxJEVna4L87qT8UKZ4PxAgbP0E6TajvP0s8uJ8RAlATnruwoMXZ0xQ km1KDe2Qx7lImi9sH0snspt9BhAQc6j2B6PdzFEZwxOsk/Mul5as2/6VJiQAcDwXUfNX AcbzzFdw4/Ea7UZibCr/bs+/nMXotUYIrcImd2RbnlZKvt0xXYl8v79Cx8tLs1G0goQF 09ZJu2P2wAhzIzFe8JYfWdcle5OunSW837g9RZb0iDfm/DZBfy2XiEi+hElxP0oulYap ikOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dlPssYq0ryvhz0STq2y2DANQYDQwBzmO+X3pNrhAOiU=; b=DuT4+CtSU5bUMszr1sRp6VSwBH0NCs0KDUZgp7zgB6IMDx4w4n+S+SF4l/cTwaC7zx sYLPCdZAQtRBPKgIdr4C92D8HsnxjyRkfajRf+XOL2x1xmdXmP7CDdCv37G23J/xjptl aZow1M7EO+9M/HvNBc2x0mWVc3dLkyQ9lHV6/AuZi18atYuJD1PGVM94IAftqhQ+w+/X yO5A6NnsN8cG5xBPi2PTAMmfrhskq5jvXPHS7gycgt6McqJ3ypU/9KhO/vbdoEPmDkFD lInYvN1JqZo0gCcVIVQgIQi+vD4Hoy1x2mpw/6rstgQeeKJwYA76HqyZKfU7vNQcAMrg sfNw== X-Gm-Message-State: APjAAAU0OyfakmOKmY0GjJTC+C7YRbDPtawZ4J3iSU/5qY34dUdNWDVa lKZ3/3NFW7DIAePUDjk7Lddr9q4L X-Google-Smtp-Source: APXvYqyC9KlTqQHjqDVHhWoeilDLM2Elce3C2IsDg6J+VQpzucQEZbF8tGngST/M5+v2rf41OtR9fw== X-Received: by 2002:aa7:956d:: with SMTP id x13mr553906pfq.132.1565048133803; Mon, 05 Aug 2019 16:35:33 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:33 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 16/22] media: imx: csi: Implement get_fwnode_pad Date: Mon, 5 Aug 2019 16:34:59 -0700 Message-Id: <20190805233505.21167-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The CSI does not have a 1:1 relationship between fwnode port numbers and pad indexes. In fact the CSI fwnode device is itself a port which is the sink, containing only a single fwnode endpoint. Implement media_entity operation get_fwnode_pad to first verify the given endpoint is the CSI's sink endpoint, and if so return the CSI sink pad index. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 367e39f5b382..e193f66fa230 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1824,9 +1824,32 @@ static void csi_unregistered(struct v4l2_subdev *sd) ipu_csi_put(priv->csi); } +/* + * The CSI has only one fwnode endpoint, at the sink pad. Verify the + * endpoint belongs to us, and return CSI_SINK_PAD. + */ +static int csi_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct fwnode_handle *csi_port = dev_fwnode(priv->dev); + struct fwnode_handle *csi_ep; + int ret; + + csi_ep = fwnode_get_next_child_node(csi_port, NULL); + + ret = endpoint->local_fwnode == csi_ep ? CSI_SINK_PAD : -ENXIO; + + fwnode_handle_put(csi_ep); + + return ret; +} + static const struct media_entity_operations csi_entity_ops = { .link_setup = csi_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi_get_fwnode_pad, }; static const struct v4l2_subdev_core_ops csi_core_ops = { From patchwork Mon Aug 5 23:35:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA78217E0 for ; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A704E26538 for ; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AE0826E38; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43FA826538 for ; Mon, 5 Aug 2019 23:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731240AbfHEXfh (ORCPT ); Mon, 5 Aug 2019 19:35:37 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42295 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731115AbfHEXff (ORCPT ); Mon, 5 Aug 2019 19:35:35 -0400 Received: by mail-pl1-f193.google.com with SMTP id ay6so37098798plb.9; Mon, 05 Aug 2019 16:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bCNueNWeJXTLrTZ3Gue5cMu55WsUG1STmKF9FRV9s+k=; b=rIpRcB1BhG0BVBiNb6PGBxOSF1DpSDhe84KSk3pvLNQv3cUbn/23W6D3K/Zmjox+vX foyZFaKt89ShO7Iz6ACajUVuOCsCH0aKrxZ3R7i2U27rwESg+mXZuj+B1n/eUYZ9cXM9 0kf1MgdxKLGEZb8fNcGz/zndSK5NAH4hNFqoCzv4ZO5ijR7C5LbnW6dfz0+AsXsdOj9A D6f83KMbyH6LX6ey0ZnClcPUmBVhLZsk2C2VpPfz6p3mH+PZvDUPMXF22lbiFL2hLmuE xOACOyVKgVhiqvrzjqdpSalDnRxmDUDB+0SzcsgrxwOMjR6i0wUxoT++O9I0zM6nIWMx 0YJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bCNueNWeJXTLrTZ3Gue5cMu55WsUG1STmKF9FRV9s+k=; b=FA/n8Oen1Fq9dpdQ0MhaxB/sZAj2JPmAN/Xv/tE9HY1wotVDcTxF0wgSBhhQWrSQtb Z2NZmtdEomPGbV6Er1+G/kHtf4pgIEMozV0p9VZi2ooBoS7qIkTXN4d1AuTnqQt/Igbe WaGRhFdc+W/4iKiTl4xi1ajDm+Ulh4O2bwZxIokXgScHdPI0EA3ScjYhPWNf/1kgmD41 0MyEfU6XOGtWF0RdrVHKXO8/4UhFdZH22M0IL3ZeHlx+u7Ru/bgU69CqR7WvQHbQRRLd B3lGegZr53owmqYAt1Qv9NIx/NkuT8JUfoorDYR9Wb0ISBrz+eqRU6BrprHEkWBdSATr Uc9Q== X-Gm-Message-State: APjAAAWl0m9wTWS3YMk73lUFB+72m9LMpE9+q0K/+an0+hKxA5Y0s0r+ ftjIU+jfqKAeKMkHAOD7amF1K1oZ X-Google-Smtp-Source: APXvYqxpbMjWVmnzuUM113Irj8RV4B5McZoB/4/bm7rnZLncgrGREH4kOM/mJnNymVLlq9X+TkbBzA== X-Received: by 2002:a17:902:820c:: with SMTP id x12mr272388pln.216.1565048134995; Mon, 05 Aug 2019 16:35:34 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:34 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 17/22] media: imx: csi: Embed notifier in struct csi_priv Date: Mon, 5 Aug 2019 16:35:00 -0700 Message-Id: <20190805233505.21167-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Embed the notifier in 'struct csi_priv', instead of dynamically allocating it, to make it possible to retrieve csi_priv in a notifier callback op. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index e193f66fa230..b39d79e63ac2 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -58,6 +58,8 @@ struct csi_priv { struct ipu_soc *ipu; struct v4l2_subdev sd; struct media_pad pad[CSI_NUM_PADS]; + struct v4l2_async_notifier notifier; + /* the video device at IDMAC output pad */ struct imx_media_video_dev *vdev; struct imx_media_fim *fim; @@ -1895,31 +1897,28 @@ static int imx_csi_parse_endpoint(struct device *dev, static int imx_csi_async_register(struct csi_priv *priv) { - struct v4l2_async_notifier *notifier; struct fwnode_handle *fwnode; unsigned int port; int ret; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); + v4l2_async_notifier_init(&priv->notifier); fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ ret = fwnode_property_read_u32(fwnode, "reg", &port); if (ret < 0) - goto out_free; + return ret; ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port( - priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev), + priv->dev->parent, &priv->notifier, + sizeof(struct v4l2_async_subdev), port, imx_csi_parse_endpoint); if (ret < 0) goto out_cleanup; - ret = v4l2_async_subdev_notifier_register(&priv->sd, notifier); + ret = v4l2_async_subdev_notifier_register(&priv->sd, + &priv->notifier); if (ret < 0) goto out_cleanup; @@ -1927,16 +1926,12 @@ static int imx_csi_async_register(struct csi_priv *priv) if (ret < 0) goto out_unregister; - priv->sd.subdev_notifier = notifier; - return 0; out_unregister: - v4l2_async_notifier_unregister(notifier); + v4l2_async_notifier_unregister(&priv->notifier); out_cleanup: - v4l2_async_notifier_cleanup(notifier); -out_free: - kfree(notifier); + v4l2_async_notifier_cleanup(&priv->notifier); return ret; } From patchwork Mon Aug 5 23:35:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60166912 for ; Mon, 5 Aug 2019 23:36:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE6826538 for ; Mon, 5 Aug 2019 23:36:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42D9627C0B; Mon, 5 Aug 2019 23:36:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A0726538 for ; Mon, 5 Aug 2019 23:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731248AbfHEXfi (ORCPT ); Mon, 5 Aug 2019 19:35:38 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41783 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731231AbfHEXfh (ORCPT ); Mon, 5 Aug 2019 19:35:37 -0400 Received: by mail-pg1-f193.google.com with SMTP id x15so30169830pgg.8; Mon, 05 Aug 2019 16:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Pj12shXDJ0qL2ITkdFID+0sK7YPIfnJU0EODI45PAo=; b=P0cWEJqDtIxlI1iTv4y7nWfH9E/dxbKOHhDEh1Ldkd4KsNCON8XIrlTGdDK1ATCV24 1pIOi/RmvDSo99JRk88cCOrbmxC7aRhJu7psaA0w/Wb8Dy7uQd0qAqeAWD6gS89htzum IXoJG5CORpjEXHBRY0klwJJh1HpapaZ7g5kv2Ar2lryCWFh4NwADK88QZxREjbpWskO1 7iRKe9s9zr0BQS6lPdiqAHIyjO62zig/8ZcIipv999RP/bKmNDcwpPVac7YKd6ubANy3 M8sIgODKgXP1t/GSK4n0bavVAMcyuHQzQnpD3Pg/Ld/IKwiHaxJMhawz31vUWPTDcSym W54w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Pj12shXDJ0qL2ITkdFID+0sK7YPIfnJU0EODI45PAo=; b=HSKkuzEs97l9bS3k4mdcAncOHZ9IbdgUEkTrqagIEe3BSKZTmxoRvaa0Mx9PMz+4eB oBfqqfoTg48v2rXrI4FpQ6Z/rbfKXzkW3ZAx+jNn4NNvNUnKkEgvk5GAyg14OjAPfhEn F0fZyyIRrdhlNATeqplk7Y4Hhj824vL2tph01kZJK3ve+d6ALN2lsd0cQSz6cKAd9zPF XZ+IBITgNnFp6KRWwggqlFdN4A+XQ/n65vXw8uxkuPWSKWCayPVRSq5AUBKPGL/O18g8 fz8+4k2KNyoJW3HWLuoeFTzkM7LkZCvZ5us1vfaiBnZMhLzxKKjjqGBqBldk18l3Qv9k ea8A== X-Gm-Message-State: APjAAAUR9JATyqFujkmOlI6zgACWiPXanuYOqHrb+omk3kgrGPsf5zTu g4aO9czMu4eqV1ILjDWotvFImB3J X-Google-Smtp-Source: APXvYqwCuNAlXO9lVulSaYfkaEjh7QPRwoh7y+NSTuatvygZigIcX3cPqTy4WpLO+oFiGtP3uC0Vaw== X-Received: by 2002:a17:90a:ca11:: with SMTP id x17mr194531pjt.107.1565048136137; Mon, 05 Aug 2019 16:35:36 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:35 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 18/22] media: imx: csi: Create media links in bound notifier Date: Mon, 5 Aug 2019 16:35:01 -0700 Message-Id: <20190805233505.21167-19-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the CSI sink pad. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index b39d79e63ac2..37b10cbf3c1a 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -120,6 +120,11 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi_priv, sd); } +static inline struct csi_priv *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_priv, notifier); +} + static inline bool is_parallel_bus(struct v4l2_fwnode_endpoint *ep) { return ep->bus_type != V4L2_MBUS_CSI2_DPHY; @@ -1895,6 +1900,23 @@ static int imx_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int imx_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_priv *priv = notifier_to_dev(notifier); + struct media_pad *sink = &priv->sd.entity.pads[CSI_SINK_PAD]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(priv->dev->parent), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations csi_notify_ops = { + .bound = imx_csi_notify_bound, +}; + static int imx_csi_async_register(struct csi_priv *priv) { struct fwnode_handle *fwnode; @@ -1903,6 +1925,8 @@ static int imx_csi_async_register(struct csi_priv *priv) v4l2_async_notifier_init(&priv->notifier); + priv->notifier.ops = &csi_notify_ops; + fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ From patchwork Mon Aug 5 23:35:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 899EF912 for ; Mon, 5 Aug 2019 23:36:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E9426538 for ; Mon, 5 Aug 2019 23:36:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C2CA27C0B; Mon, 5 Aug 2019 23:36:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D929826538 for ; Mon, 5 Aug 2019 23:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731280AbfHEXgC (ORCPT ); Mon, 5 Aug 2019 19:36:02 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41786 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731246AbfHEXfi (ORCPT ); Mon, 5 Aug 2019 19:35:38 -0400 Received: by mail-pg1-f195.google.com with SMTP id x15so30169852pgg.8; Mon, 05 Aug 2019 16:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SzPXhAIDJJVPxRQjm5dl35CCesjMMtT8aLvkE/D76vE=; b=AhxGn7uGF82d3u+PITZWpmxompnLOWgJO9HrgllV8YvuhA6O+sm+OT2Fmo4+ReXhIH rc6PsyRUFKuyEkruD0L9Dfhx9JKLJSxpD2f3BWRsk+8sj07mfSPzkmQTpF+3axXh7C7a BVsnk3jIJSGjF/uLAgHc7jF9s3RsLw87/IFLxVi9JkYVRytq+MD/WlKPogWdJ+klCPW0 B7RfPX0/Nb9ayS9qH48WFo7uvOYw/3JW59AM4skWrMadcq1XOrkCofBD/jrZ07MlTXA3 BKNJAL1f2Z4OPtxSfdUgIHu7I9JxQa7LLiQVI+EoXzDX24xu5dotr/IwM0RyEdZ8kCjT f1mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SzPXhAIDJJVPxRQjm5dl35CCesjMMtT8aLvkE/D76vE=; b=DEtkDlx2ZK+X2jR71upskta5qtBgdmfg58dTMgyBcNtXgZTWbC9yh1zwCmJv0IIBBs V8JKIqN5ppcyAQfV1ob5r0KNASAMjrvrYuCHluZJBnTmuqOz/ev99bhAPj5nkugYdx9A XSevP7DdTH3SYiJB9NY7HAWPCANUJaZ8L6KOtCGS2gRZquZ2JUdIgTNVPOdE0DKvhhMK 6Rer2YkvvWOu9+NJDOYO/9YhKqSDuQH9xMLfLUaaC6BZLpdoOttbYl1rj8Ed7FjgKY0m DWP//hbYZrxSLUGsIYIaK0bF2IcymHdArw4Lyv9w0r0FWPZGTeyV/Z2zAYGZ0fg/uiw1 YTig== X-Gm-Message-State: APjAAAWPWL1ZRmw7j+YkcO8RFDi7F6ombXvoFsP9nTH1XA77gWhZBhfI aJ0M3rhALE+e2xIKv+bBjrZxr7oA X-Google-Smtp-Source: APXvYqzI0G6RmtOIgcu5JlAUTuDB6qP16++PmpcC16BXSP2WyOz+NuOkX6F+YZTN+IpvcZ6pmS1dyg== X-Received: by 2002:a65:690e:: with SMTP id s14mr336282pgq.47.1565048137522; Mon, 05 Aug 2019 16:35:37 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:37 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 19/22] media: imx: csi: Lookup endpoint fwnode with media_entity_get_fwnode_pad Date: Mon, 5 Aug 2019 16:35:02 -0700 Message-Id: <20190805233505.21167-20-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix the 1:1 port-id:pad-index assumption for the upstream subdevice connected to a CSI via one of the subdevice's pads, by searching the upstream subdevice's endpoints for one that maps to the pad's index, using media_entity_get_fwnode_pad(). This is carried out by a new reverse mapping function imx_media_get_pad_fwnode(). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 22 ++++---------- drivers/staging/media/imx/imx-media-utils.c | 33 +++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 1 + drivers/staging/media/imx/imx7-media-csi.c | 25 +++++----------- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 37b10cbf3c1a..38e70082ff2d 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -164,7 +164,7 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep, static int csi_get_upstream_endpoint(struct csi_priv *priv, struct v4l2_fwnode_endpoint *ep) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; struct v4l2_subdev *sd; struct media_pad *pad; @@ -203,23 +203,13 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; - - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 4cc6a7462ae2..2e4f27c214c4 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -908,6 +908,39 @@ imx_media_pipeline_video_device(struct media_entity *start_entity, } EXPORT_SYMBOL_GPL(imx_media_pipeline_video_device); +/* + * Find a fwnode endpoint that maps to the given subdevice's pad. + * If there are multiple endpoints that map to the pad, only the + * first endpoint encountered is returned. + * + * On success the refcount of the returned fwnode endpoint is + * incremented. + */ +struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad) +{ + struct fwnode_handle *endpoint; + struct v4l2_subdev *sd; + + if (!is_media_entity_v4l2_subdev(pad->entity)) + return ERR_PTR(-ENODEV); + + sd = media_entity_to_v4l2_subdev(pad->entity); + + fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { + int pad_idx = media_entity_get_fwnode_pad(&sd->entity, + endpoint, + pad->flags); + if (pad_idx < 0) + continue; + + if (pad_idx == pad->index) + return endpoint; + } + + return ERR_PTR(-ENODEV); +} +EXPORT_SYMBOL_GPL(imx_media_get_pad_fwnode); + /* * Turn current pipeline streaming on/off starting from entity. */ diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 4d124a86b358..d75b3c80101a 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -195,6 +195,7 @@ imx_media_pipeline_subdev(struct media_entity *start_entity, u32 grp_id, struct video_device * imx_media_pipeline_video_device(struct media_entity *start_entity, enum v4l2_buf_type buftype, bool upstream); +struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad); struct imx_media_dma_buf { void *virt; diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index f71ac485f780..50826e637cb5 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -438,9 +438,8 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, struct v4l2_fwnode_endpoint *ep, bool skip_mux) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; - struct v4l2_subdev *sd; struct media_pad *pad; if (!csi->src_sd) @@ -462,29 +461,19 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); - /* To get bus type we may need to skip video mux */ if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { - src = &sd->entity; + src = pad->entity; goto skip_video_mux; } - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } From patchwork Mon Aug 5 23:35:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 828BC13B1 for ; Mon, 5 Aug 2019 23:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7303626538 for ; Mon, 5 Aug 2019 23:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6754827C0B; Mon, 5 Aug 2019 23:35:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06D5F26538 for ; Mon, 5 Aug 2019 23:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731267AbfHEXfk (ORCPT ); Mon, 5 Aug 2019 19:35:40 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40762 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731252AbfHEXfj (ORCPT ); Mon, 5 Aug 2019 19:35:39 -0400 Received: by mail-pl1-f195.google.com with SMTP id a93so36998057pla.7; Mon, 05 Aug 2019 16:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zrm8LxDqKTEIfziOzXkM6e2flIMXktLlvnyDC/cWAXU=; b=E8PFWAlEca7XGp/ypYPJskiPyA9K+7OS18DItOnG2Bfl6FCKtkimS9/DnRw/hE1zFu OouSg6pW06IaMrrAq2zQYNzh3HlvYNDC7/+6Pd2pGb73nYxYAiOzuLNakyx/gs/0ne7M tOiWcZ32wmqRG7rODw5zO3uH76Efd0ztx6BR2HX5j+4+nFvZGQKj+AqMcwtpxFdu2Jqn D0zHlOtu7eB9PrDypfvevuW51VXdxNfXi2g+oXIyE+i8StDi8QWlJbqn41x/0jmmJhZn Uka/xY8sq5AdPsUB/yIUOTcehc9mCEBwQG6nlixCt38ifTG1RaeP0DX+8kwp+yp8gMOv Oc0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zrm8LxDqKTEIfziOzXkM6e2flIMXktLlvnyDC/cWAXU=; b=DfbWyIK2OkV8YyCNosXYLucQn8E5zNTW7T5K92a7NP3P8J00cpuVyWT1rGl5fFrunI t2x2g57tC1JEUAYn4WtY3a0O1Er6KYNq/W2zGGsPQtvR+JOa19JYS/fSeyWgKTuIULaR +xr3oG39uZaTiXtE5hx6BfduDVd5EfZ2jNgBrjg2MAAhLo84+GoCD+ZgxhE8YeVsR7a8 Sgxu7nbMiD5xx9eM1g0PeZeCf1lSEHF//uc4gJ7/i0aZuFpUSxHd/2iXI0ztUfye1J+s TgGplSrosiZ+TRrNItXPqj4nvSSgk64kXHShFZQXisEnD7C5mUHY+dz+NOvmQsm8OTfD iypQ== X-Gm-Message-State: APjAAAXjIgPNl6VORf5fpyzG9Vk8MEBlr6HHfo45gogvWmCmYfQS7sFZ sZD9Ht09CMun8AfHm5ItGLsHmtRw X-Google-Smtp-Source: APXvYqyH8CdkrHUQnPTNSLlBsJ0vtRNhSprKbx26bouPjx5BmsIKdhqcv08x/6Q/83cWW2HTKFyUEQ== X-Received: by 2002:a17:902:5a2:: with SMTP id f31mr277744plf.72.1565048138734; Mon, 05 Aug 2019 16:35:38 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:38 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 20/22] media: imx: Add is_ipu_internal_subdev() Date: Mon, 5 Aug 2019 16:35:03 -0700 Message-Id: <20190805233505.21167-21-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a convenience inline function that returns true if the given subdevice is one of the i.MX5/6 IPU-internal subdevices. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index d75b3c80101a..c42a2cafb8fb 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -282,4 +282,12 @@ void imx_media_capture_device_error(struct imx_media_video_dev *vdev); #define IMX_MEDIA_GRP_ID_IPU_IC_PRPENC BIT(14) #define IMX_MEDIA_GRP_ID_IPU_IC_PRPVF BIT(15) +static inline bool is_ipu_internal_subdev(struct v4l2_subdev *sd) +{ + return sd->grp_id == IMX_MEDIA_GRP_ID_IPU_VDIC || + sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRP || + sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRPENC || + sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRPVF; +} + #endif From patchwork Mon Aug 5 23:35:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93D1A912 for ; Mon, 5 Aug 2019 23:35:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82A6026E38 for ; Mon, 5 Aug 2019 23:35:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76E9B27F7F; Mon, 5 Aug 2019 23:35:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE2A026E38 for ; Mon, 5 Aug 2019 23:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731279AbfHEXfl (ORCPT ); Mon, 5 Aug 2019 19:35:41 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43635 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731266AbfHEXfl (ORCPT ); Mon, 5 Aug 2019 19:35:41 -0400 Received: by mail-pl1-f193.google.com with SMTP id 4so30052616pld.10; Mon, 05 Aug 2019 16:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0S1ar2fMdERTJzIO99lo9VyZc288UAn1DrH6O+6xG3A=; b=Tg9MUibHxcwDQfGvRWXjw3IaHbqAI3CNSNU94W3GDMVrNbYxaWalkgmaZG9xLSdcdC RWB/02yluRHJjyCd9jgp/t4tUYWHrBj/Y4Tj3e/05X+9GMEoJwuKvu3ZI6BnbQzoZ6sX 0Ha64RCnDaDxQ5Mn4igGvJn+cvDlfx9BFinUjymmVINucui/sV9MJopRFBwGsFGAdgOv BsSNrturNVt+kJdz96eJTgOyVs86jIDpmHeBY7IyrKP8tC7sVnmaIRI964/ktYq4hoI5 QH196OBdiu9Lr7dD8F0HUv86fYgx7+E8zI9F472sQo7jzhoNtp1ULH5Fj1gYWEUnIbEE 0ACA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0S1ar2fMdERTJzIO99lo9VyZc288UAn1DrH6O+6xG3A=; b=cQl6RgizhOOmlMjZkYwa514ltctO29r9T/hEenVALLw/uF3r7MOeIXh85J/Rc4Is2h Kb80gT7dFGHKi/z9pFzDmda4R8KYE5RbsgGzTRzMFFAVQX2WuX/hQ1gwOzzKJXHVW5m1 6P2TUzzWuBncEXC+bD+bumAVSCwIQ3UwPiUWSeoFubob2nrupYe6+duGal/5PLCTns9h WBMmW3VLytEGQUSmQCC2DJLTmPOa7hSTT12nm4CqtjC7znWXGv60sZXjEaDArvZY31aA em0dpVyTVd2fOhZdvGh26c1VYDRZJ3Z5Gx4L8UM29snHEX3zJZHG5ZgPjJOT79h1Ni5y QYTA== X-Gm-Message-State: APjAAAVrcNpePH54j+y6F3iWZ/nVN2VFd3oluWEHPWyyoOhQtyyTZ7n5 d3QyqLYFXZ8UeW3q2Hv5ILE8ubJl X-Google-Smtp-Source: APXvYqxarRCZVmeKkHTq+3l7c5xuS2KTn9u0u55xlL4X1ShwB8l5jm4IbrYWk7boV6jD2FtQt8b7oA== X-Received: by 2002:a17:902:bd06:: with SMTP id p6mr243778pls.189.1565048140051; Mon, 05 Aug 2019 16:35:40 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:39 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 21/22] media: imx: Use media_create_fwnode_links for external links Date: Mon, 5 Aug 2019 16:35:04 -0700 Message-Id: <20190805233505.21167-22-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The entities external to the i.MX6 IPU and i.MX7 now create the links to their fwnode-endpoint connected entities in their notifier bound callbacks. This should mean that there is no longer a need for the imx-media driver to create these external fwnode-endpoint based links. But the v4l2-async framework does not allow multiple subdevice notifiers to contain a duplicate subdevice in their asd_list. Only the first subdev notifier that discovers and adds that one subdevice to its asd_list will receive a bound callback for it. Other subdevices that also have firmware endpoint connections to this duplicate subdevice will not have it in their asd_list, and thus will never receive a bound callback for it. Until there is a solution to that problem, imx_media_create_links() is still needed to create media links for subdevices that never received a bound callback. But media_create_fwnode_links() can now be used to do that work, so imx_media_create_of_links() and imx_media_create_csi_of_links() are removed. Signed-off-by: Steve Longerbeam --- .../staging/media/imx/imx-media-dev-common.c | 49 ++++---- drivers/staging/media/imx/imx-media-of.c | 113 ------------------ drivers/staging/media/imx/imx-media.h | 4 - 3 files changed, 27 insertions(+), 139 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index 66b505f7e8df..4dbe983af030 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -36,31 +36,36 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, static int imx_media_create_links(struct v4l2_async_notifier *notifier) { struct imx_media_dev *imxmd = notifier2dev(notifier); - struct v4l2_subdev *sd; + struct fwnode_handle *sda_fwnode, *sdb_fwnode; + struct v4l2_subdev *sda, *sdb; + + list_for_each_entry(sda, &imxmd->v4l2_dev.subdevs, list) { + /* links have already been created for the IPU subdevs */ + if (is_ipu_internal_subdev(sda)) + continue; + + sda_fwnode = (sda->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) ? + dev_fwnode(sda->dev->parent) : + dev_fwnode(sda->dev); + + list_for_each_entry(sdb, &imxmd->v4l2_dev.subdevs, list) { + if (sda == sdb) + continue; + if (is_ipu_internal_subdev(sdb)) + continue; + + sdb_fwnode = (sdb->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) ? + dev_fwnode(sdb->dev->parent) : + dev_fwnode(sdb->dev); - list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - switch (sd->grp_id) { - case IMX_MEDIA_GRP_ID_IPU_VDIC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRP: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF: - /* - * links have already been created for the - * sync-registered subdevs. - */ - break; - case IMX_MEDIA_GRP_ID_IPU_CSI0: - case IMX_MEDIA_GRP_ID_IPU_CSI1: - case IMX_MEDIA_GRP_ID_CSI: - imx_media_create_csi_of_links(imxmd, sd); - break; - default: /* - * if this subdev has fwnode links, create media - * links for them. + * if there are fwnode endpoint connections between + * these subdevs, create media links for them. */ - imx_media_create_of_links(imxmd, sd); - break; + __media_create_fwnode_links(&sda->entity, + sda_fwnode, + &sdb->entity, + sdb_fwnode, 0); } } diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 736c954a8ff5..82e13e972e23 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -74,116 +74,3 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd, return ret; } EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs); - -/* - * Create a single media link to/from sd using a fwnode link. - * - * NOTE: this function assumes an OF port node is equivalent to - * a media pad (port id equal to media pad index), and that an - * OF endpoint node is equivalent to a media link. - */ -static int create_of_link(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd, - struct fwnode_link *link) -{ - struct v4l2_subdev *remote, *src, *sink; - int src_pad, sink_pad; - - if (link->local.port >= sd->entity.num_pads) - return -EINVAL; - - remote = imx_media_find_subdev_by_fwnode(imxmd, - link->remote_port_parent); - if (!remote) - return 0; - - if (sd->entity.pads[link->local.port].flags & MEDIA_PAD_FL_SINK) { - src = remote; - src_pad = link->remote.port; - sink = sd; - sink_pad = link->local.port; - } else { - src = sd; - src_pad = link->local.port; - sink = remote; - sink_pad = link->remote.port; - } - - /* make sure link doesn't already exist before creating */ - if (media_entity_find_link(&src->entity.pads[src_pad], - &sink->entity.pads[sink_pad])) - return 0; - - v4l2_info(sd->v4l2_dev, "%s:%d -> %s:%d\n", - src->name, src_pad, sink->name, sink_pad); - - return media_create_pad_link(&src->entity, src_pad, - &sink->entity, sink_pad, 0); -} - -/* - * Create media links to/from sd using its device-tree endpoints. - */ -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd) -{ - struct fwnode_handle *endpoint; - struct fwnode_link link; - int ret; - - fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { - ret = fwnode_graph_parse_link(endpoint, &link); - if (ret) - continue; - - ret = create_of_link(imxmd, sd, &link); - fwnode_graph_put_link(&link); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_of_links); - -/* - * Create media links to the given CSI subdevice's sink pads, - * using its device-tree endpoints. - */ -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi) -{ - struct fwnode_handle *csi_np = dev_fwnode(csi->dev); - struct fwnode_handle *csi_ep; - - fwnode_for_each_child_node(csi_np, csi_ep) { - struct fwnode_handle *fwnode; - struct fwnode_link link; - int ret; - - memset(&link, 0, sizeof(link)); - - link.local_port_parent = csi_np; - link.local.port = CSI_SINK_PAD; - - fwnode = fwnode_graph_get_remote_endpoint(csi_ep); - if (!fwnode) - continue; - - fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, "reg", &link.remote.port); - fwnode = fwnode_get_next_parent(fwnode); - if (is_of_node(fwnode) && - of_node_name_eq(to_of_node(fwnode), "ports")) - fwnode = fwnode_get_next_parent(fwnode); - link.remote_port_parent = fwnode; - - ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_port_parent); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_csi_of_links); diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index c42a2cafb8fb..7bdeecd29248 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -238,10 +238,6 @@ void imx_media_unregister_ipu_internal_subdevs(struct imx_media_dev *imxmd); /* imx-media-of.c */ int imx_media_add_of_subdevs(struct imx_media_dev *dev, struct device_node *np); -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd); -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi); int imx_media_of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np); From patchwork Mon Aug 5 23:35:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11077875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5781315AC for ; Mon, 5 Aug 2019 23:35:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 455C226E38 for ; Mon, 5 Aug 2019 23:35:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39AEC27F7F; Mon, 5 Aug 2019 23:35:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFE0D26E38 for ; Mon, 5 Aug 2019 23:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731292AbfHEXfn (ORCPT ); Mon, 5 Aug 2019 19:35:43 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36935 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731280AbfHEXfm (ORCPT ); Mon, 5 Aug 2019 19:35:42 -0400 Received: by mail-pl1-f195.google.com with SMTP id b3so37084980plr.4; Mon, 05 Aug 2019 16:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2TmLGvTN3FaWVeRsZPV3e4KNsmV2AReP7cWUVSqpqFQ=; b=YW2JbBhT1KOAfZKebBO9NM/G5Db95SUaRLnTey3pDLof4EeuR2oudZUxy8zi3ksHrp n/rM4Ga7htyDE97Ns+wPj+3Z8PhgQ/mkooxrj+Oj+RLx4/nnq0bUD+aDUnVf1LBrq9xF dY0j2ZVZAyPgtxwlAKR9qwP4wj/h48HGi4ffXdnH8gu8bIzxJ8uHY2W+u7NH0GnqxTD8 dRHgc922vuRBkdb5WRupFzWcgYSpGtu+hSoihVTRk9nHn6Zo5xvrqkBk6f2tAOvr6c0G mFXWCA9xq+KMxQdYSaIZjMOJSVwdiGQuFvo1KeBfdkD79sC1CTS7ef5vvvfOPlyvigqS IVNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2TmLGvTN3FaWVeRsZPV3e4KNsmV2AReP7cWUVSqpqFQ=; b=teNXJwM2nAyOGhatMv1pZrNVWswP76C7iQvGHwog712DchYdMjhi7mDy1woI8d8v0H hGNfk9jk/Y0H5uOOU4a22AzzrcvmjT3Uk9T3wJb3YWrUnQfdjsoX95am9prX9GnAvu0S Guuj/G0GeCMhBi4SYXa6CVjKtgghq01ycTzwXrw4wMkPa7ZggL/IBYStVeFVNGCuwAal wLrJ7SySRsI+Eyoqf7NtgY2Zd3/PzRuhTjyHTahMRuBOTFCTMTz1ulBYpNzyXGyzvTrQ BIi/2PIE/wLw8q+G4G6kiz8MhP3QeUx/xO9Nld9zcb4tfwfybhDCsE++Sa1j/vxvNOGw w7GQ== X-Gm-Message-State: APjAAAXVBfW3rDE/IdYLv5oRoJCcpWuiMWgvpmjtRiCCghMU0zEEWWI3 LkAV5k9nP74M2oom8XlzUKWt1vPf X-Google-Smtp-Source: APXvYqzJbrsuJ3HwTZ98E/Apw4jZA8VmFc9SY7qiYBjg/8j77ZDblKl2/AqIbDwaFPx6pAGuizw+Iw== X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr251709plk.336.1565048141256; Mon, 05 Aug 2019 16:35:41 -0700 (PDT) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id 30sm31296349pjk.17.2019.08.05.16.35.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 16:35:40 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 22/22] media: imx: TODO: Remove issues regarding media link creation Date: Mon, 5 Aug 2019 16:35:05 -0700 Message-Id: <20190805233505.21167-23-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805233505.21167-1-slongerbeam@gmail.com> References: <20190805233505.21167-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the TODO items regarding media link creation, these issues are resolved after exporting media link creation to individual entity bound callbacks and the use of media_create_fwnode_links(), media_create_fwnode_pad_links(), and media_entity_get_fwnode_pad(). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/TODO | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO index 6f29b5ca5324..a371cdedcdb0 100644 --- a/drivers/staging/media/imx/TODO +++ b/drivers/staging/media/imx/TODO @@ -17,35 +17,6 @@ decided whether this feature is useful enough to make it generally available by exporting to v4l2-core. -- After all async subdevices have been bound, v4l2_fwnode_parse_link() - is used to form the media links between the devices discovered in - the OF graph. - - While this approach allows support for arbitrary OF graphs, there - are some assumptions for this to work: - - 1. If a port owned by a device in the graph has endpoint nodes, the - port is treated as a media pad. - - This presents problems for devices that don't make this port = pad - assumption. Examples are SMIAPP compatible cameras which define only - a single output port node, but which define multiple pads owned - by multiple subdevices (pixel-array, binner, scaler). Or video - decoders (entity function MEDIA_ENT_F_ATV_DECODER), which also define - only a single output port node, but define multiple pads for video, - VBI, and audio out. - - A workaround at present is to set the port reg properties to - correspond to the media pad index that the port represents. A - possible long-term solution is to implement a subdev API that - maps a port id to a media pad index. - - 2. Every endpoint of a port owned by a device in the graph is treated - as a media link. - - Which means a port must not contain mixed-use endpoints, they - must all refer to media links between V4L2 subdevices. - - i.MX7: all of the above, since it uses the imx media core - i.MX7: use Frame Interval Monitor