From patchwork Tue Jul 4 16:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 115852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1343141vqx; Tue, 4 Jul 2023 09:42:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/CGvFidTWiDgsbi3uvr32noE7JPDI4Kj9NWdJaOz4fUsGfGW8JbBU4NPu1buAFHp0KyEl X-Received: by 2002:a05:6870:8e1b:b0:1b3:afdc:6c14 with SMTP id lw27-20020a0568708e1b00b001b3afdc6c14mr5900092oab.2.1688488951968; Tue, 04 Jul 2023 09:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688488951; cv=none; d=google.com; s=arc-20160816; b=LySuCooUxCcITaMQbElojWvLVbfrlDXK0BDdEHWQCKYdY5FTu57wgVGAVEVe1SbLGP IWtGSNlkIzPHhJvqGPWOkUig16LaOCcqQHGytm9rhLXOwvFGmZh5firHCfftUBBJONaI JeH9ljXEt63mXUNU032MOD2auO4pR1DQJshIrC1Y3ablfbfNj++B+8SjIx7ubFYdKpsF gpLlPN+X59ux+upaj5iXAwmmw3WVZcyD5Rfl4WY+2rempYr7xgkbpYBiqQOygpgsxPwE r8F8z6vjVRFZ69cjbqdMZVjrHnfcM8wG+KKcZoldCIzAfXQTf8vro6RGqMF4/tVcNbyY hrQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IRxQze0GbOxW7gEgmYz7Ex9yrSvhISsfBQGDS9iYG7g=; fh=G5Q1HWVVVCfnntTRHMYoDxsmjmcUpCS33Y2jbkQG79s=; b=GcnHN6XDXBmx7s3igGUVEfeW6UCIprGPwe6uvStEr7fZtFsIKn7QHiZutonv99meBR TJKqpPF2RUKrvflPyOS5Vs4XloOkkxY2mqrLTkqdIDDAWSq4qMldCyxQeYvW/tAeUKOC 6FME5ASu5S87Hw5qkxVtKCYlsmftqkP/fDnevHtOY2AhGyD1nlhL7lQEiznsWOnvxQ66 rYHfQiHEMMsf8970O8hrm1vdUSta9ak8c04zfTisX20tTzQfjHavXS7waM44YiCcgX1h mWtJFzIanF2Kay58x+SpETNJr1Ghf3C4OSQAxBB7rstNJo8Gi9Ij+30Vd0tO4yjcWudN l/2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a17090aab0100b00263bb14ba00si5619334pjq.55.2023.07.04.09.42.16; Tue, 04 Jul 2023 09:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjGDQf0 (ORCPT + 99 others); Tue, 4 Jul 2023 12:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjGDQfZ (ORCPT ); Tue, 4 Jul 2023 12:35:25 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFC40E7A for ; Tue, 4 Jul 2023 09:35:19 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 23D0B15BF; Tue, 4 Jul 2023 09:36:02 -0700 (PDT) Received: from R913NWR2.arm.com (unknown [10.163.47.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A19993F73F; Tue, 4 Jul 2023 09:35:17 -0700 (PDT) From: Faiz Abbas To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: liviu.dudau@arm.com, airlied@gmail.com, daniel@ffwll.ch, faiz.abbas@arm.com Subject: [PATCH v2] drm/arm/komeda: Remove component framework and add a simple encoder Date: Tue, 4 Jul 2023 22:04:54 +0530 Message-Id: <20230704163454.5138-1-faiz.abbas@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769301804196569267?= X-GMAIL-MSGID: =?utf-8?q?1770508991626948336?= The Komeda driver always expects the remote connector node to initialize an encoder. It uses the component aggregator framework which consists of component->bind() calls used to initialize the remote encoder and attach it to the crtc. This makes it incompatible with connector drivers which implement drm_bridge APIs. Remove all component framework calls from the komeda driver and declare and attach an encoder inside komeda_crtc_add(). The remote connector driver has to implement the DRM bridge APIs which can be used to glue the encoder to the remote connector. Since we usually pair this with a component encoder that also implements a drm_bridge, dropping support is not expected to affect users of this driver. Signed-off-by: Faiz Abbas --- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 23 +++++++- .../gpu/drm/arm/display/komeda/komeda_drv.c | 57 ++----------------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 10 +--- .../gpu/drm/arm/display/komeda/komeda_kms.h | 3 + 4 files changed, 32 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index 4cc07d6bb9d82..e5a8a80b173f4 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "komeda_dev.h" #include "komeda_kms.h" @@ -613,9 +615,11 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, struct komeda_crtc *kcrtc) { struct drm_crtc *crtc = &kcrtc->base; + struct drm_device *base = &kms->base; + struct drm_bridge *bridge; int err; - err = drm_crtc_init_with_planes(&kms->base, crtc, + err = drm_crtc_init_with_planes(base, crtc, get_crtc_primary(kms, kcrtc), NULL, &komeda_crtc_funcs, NULL); if (err) @@ -625,6 +629,23 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, crtc->port = kcrtc->master->of_output_port; + + /* Construct an encoder for each pipeline and attach it to the remote + * bridge + */ + kcrtc->encoder.possible_crtcs = drm_crtc_mask(crtc); + err = drm_simple_encoder_init(base, &kcrtc->encoder, + DRM_MODE_ENCODER_TMDS); + if (err) + return err; + + bridge = devm_drm_of_get_bridge(base->dev, kcrtc->master->of_node, + KOMEDA_OF_PORT_OUTPUT, 0); + if (IS_ERR(bridge)) + return PTR_ERR(bridge); + + err = drm_bridge_attach(&kcrtc->encoder, bridge, NULL, 0); + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE); return err; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c index 9fce4239d4ad4..98e7ca1ad8fe7 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -27,13 +26,11 @@ struct komeda_dev *dev_to_mdev(struct device *dev) return mdrv ? mdrv->mdev : NULL; } -static void komeda_unbind(struct device *dev) +static int komeda_platform_remove(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct komeda_drv *mdrv = dev_get_drvdata(dev); - if (!mdrv) - return; - komeda_kms_detach(mdrv->kms); if (pm_runtime_enabled(dev)) @@ -45,10 +42,13 @@ static void komeda_unbind(struct device *dev) dev_set_drvdata(dev, NULL); devm_kfree(dev, mdrv); + + return 0; } -static int komeda_bind(struct device *dev) +static int komeda_platform_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct komeda_drv *mdrv; int err; @@ -88,52 +88,7 @@ static int komeda_bind(struct device *dev) free_mdrv: devm_kfree(dev, mdrv); return err; -} - -static const struct component_master_ops komeda_master_ops = { - .bind = komeda_bind, - .unbind = komeda_unbind, -}; -static void komeda_add_slave(struct device *master, - struct component_match **match, - struct device_node *np, - u32 port, u32 endpoint) -{ - struct device_node *remote; - - remote = of_graph_get_remote_node(np, port, endpoint); - if (remote) { - drm_of_component_match_add(master, match, component_compare_of, remote); - of_node_put(remote); - } -} - -static int komeda_platform_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct component_match *match = NULL; - struct device_node *child; - - if (!dev->of_node) - return -ENODEV; - - for_each_available_child_of_node(dev->of_node, child) { - if (of_node_cmp(child->name, "pipeline") != 0) - continue; - - /* add connector */ - komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 0); - komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 1); - } - - return component_master_add_with_match(dev, &komeda_master_ops, match); -} - -static int komeda_platform_remove(struct platform_device *pdev) -{ - component_master_del(&pdev->dev, &komeda_master_ops); - return 0; } static const struct of_device_id komeda_of_match[] = { diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index 451746ebbe713..95eb53c284366 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -4,7 +4,6 @@ * Author: James.Qian.Wang * */ -#include #include #include @@ -307,17 +306,13 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) if (err) goto cleanup_mode_config; - err = component_bind_all(mdev->dev, kms); - if (err) - goto cleanup_mode_config; - drm_mode_config_reset(drm); err = devm_request_irq(drm->dev, mdev->irq, komeda_kms_irq_handler, IRQF_SHARED, drm->driver->name, drm); if (err) - goto free_component_binding; + goto cleanup_mode_config; drm_kms_helper_poll_init(drm); @@ -329,8 +324,6 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) free_interrupts: drm_kms_helper_poll_fini(drm); -free_component_binding: - component_unbind_all(mdev->dev, drm); cleanup_mode_config: drm_mode_config_cleanup(drm); komeda_kms_cleanup_private_objs(kms); @@ -346,7 +339,6 @@ void komeda_kms_detach(struct komeda_kms_dev *kms) drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); drm_atomic_helper_shutdown(drm); - component_unbind_all(mdev->dev, drm); drm_mode_config_cleanup(drm); komeda_kms_cleanup_private_objs(kms); drm->dev_private = NULL; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index 7339339ef6b87..9b070d504f4ad 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -85,6 +85,9 @@ struct komeda_crtc { /** @disable_done: this flip_done is for tracing the disable */ struct completion *disable_done; + + /** @encoder: encoder at the end of the pipeline */ + struct drm_encoder encoder; }; /**