From patchwork Wed Jun 21 08:41:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 110869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4217451vqr; Wed, 21 Jun 2023 01:54:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CWX7SgK5f4mHsvSTeeJ50NAx2Z5Y3oJja/x3sphYULxhkkwBH9tzmqSkvkSAbNXb3RMY2 X-Received: by 2002:a9d:6a03:0:b0:6b4:71d4:157d with SMTP id g3-20020a9d6a03000000b006b471d4157dmr7217635otn.33.1687337688849; Wed, 21 Jun 2023 01:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687337688; cv=none; d=google.com; s=arc-20160816; b=a7oqSgWvUaj1+9wNzP+8BpiYPGA+nU+SAmFSAlQhK4T3BuJbI6W8LZd14K5cMKrD2X YenvcR6LiABsqtHiIfy2S5Zu82/z+XW+u25oKc6RVQ1O6jHGx6owp4uXQA5O8qjO5JSN yqwGxFZtgFnrFpsIUJfDbgF3z9iaOlVBk13VtFBTc/RydAdKaIBo6tQV2eR44ykOMrhL MI2Febnf3kzo6RoNDMWNKtyJIvRM8NiHTF69IVo/lNDso99BT4VV/zgPFr08ycLxvU/6 gIBffAF7fiyYBrRSQWC9J6ovWlRPv0KXaqzwn0vJQgpEGMqt+pxFYfkVbCnBjGNry6kK CImA== 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=WcqBzgAnPQlbcLoE8vLXxoAHH06torhkBkGoo+l1yA8=; b=Xapua6P5oQWyi77I2sVnpAj6k9uWwUMwRAUc0dVswdo9ILEkgAhSQS4wUBEBhc9IyV VNt3oKN+xSld+owZWjhAyYluol6ZF2I3/C5JE3QfuJP8Y2QfPJhJU4UCAamzD9Louhu+ NVQAiqM+jGw3zgXGEvRe8TBnD2jFKojigP+u5BF5rqqlPwTujVSYOC8hm+JmFOSGVDGq 7Il09BC7l+DUWJQRQUEUGhivzlJxcHuHeJNDExDnouH9v7j/oOMzdUjH49sSUkblmBkn HKL8MkQr7FJZzLFcx8ZaTSRl6/tG3ybob3tZLasm+H06Rk98tG1UwFKkTJvi09q4ixBN 4nrw== 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 q30-20020a638c5e000000b0054ffca12339si3672122pgn.441.2023.06.21.01.54.34; Wed, 21 Jun 2023 01:54:48 -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 S230419AbjFUImv (ORCPT + 99 others); Wed, 21 Jun 2023 04:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbjFUImd (ORCPT ); Wed, 21 Jun 2023 04:42:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75C741FE2 for ; Wed, 21 Jun 2023 01:41:29 -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 B6D421063; Wed, 21 Jun 2023 01:42:12 -0700 (PDT) Received: from R913NWR2.arm.com (unknown [10.163.45.168]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B77DB3F663; Wed, 21 Jun 2023 01:41:26 -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] drm/arm/komeda: Remove component framework and add a simple encoder Date: Wed, 21 Jun 2023 14:11:16 +0530 Message-Id: <20230621084116.26882-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 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?1769301804196569267?= 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 is different from other drm implementations which expect the display driver to supply a crtc and connect an encoder to it. 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. Signed-off-by: Faiz Abbas --- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 22 +++++++- .../gpu/drm/arm/display/komeda/komeda_drv.c | 56 ++----------------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 4 -- .../gpu/drm/arm/display/komeda/komeda_kms.h | 3 + 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index cea3fd5772b57..144736a69b0ee 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "komeda_dev.h" #include "komeda_kms.h" @@ -612,9 +614,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) @@ -626,6 +630,22 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE); + /* 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); + 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 28f76e07dd958..70b1b693c6eff 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c @@ -28,13 +28,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)) @@ -46,10 +44,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; @@ -89,52 +90,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 62dc64550793e..91cbcb6974021 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -305,10 +305,6 @@ 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, diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h index 3a872c2920912..6ef6553263570 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h @@ -84,6 +84,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; }; /**