From patchwork Mon Dec 13 12:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1824 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D7B353F18E for ; Mon, 13 Dec 2021 13:19:45 +0100 (CET) Received: by mail-pf1-f197.google.com with SMTP id s22-20020a056a00179600b004b31f2cdb19sf1412156pfg.7 for ; Mon, 13 Dec 2021 04:19:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1639397982; cv=pass; d=google.com; s=arc-20160816; b=FvCPRM1yyGtKpPL0wUTQuYGtwntjq25Gohx1EfXfmp+gyJwyl7XR0ylTVZl3dgGjiO OxwGalSkuNKBc/tUucswvmNJfue2qgCeqFRllzqifX+5JGQw+VqgISbzkIlnSz8/AcDl jEcX17WHiGcqnTGkheRe0l6e4E5rvo7CMLCmM3U25Kt23so2tKWAPpcYh02OGPktej35 KtwMyATxjsN3II6OS1MMzkiN+jty5sf+VzNBqGczeP6kbEZr8+d6G1ARuNPS8zxzPb2f xQO2MbkfyXnmZ+vwxk0rI/JQOEOAflYxKYtGBmM3ACOWHp1P0s/Mw/ELe/6AVriI+fW+ 7k0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=qcJnJfx2+aRK1R1frmubBKzhYPVEnSL7mkL0spyRKeA=; b=wyXr8bfBkyftJF1tUobHpYlwOgYEq7c8iDB9ZgnuwdyEh1cNf2myQUFkymX6LcBj/Q rtqgSDD6yvAUqs0JMbJq+CKGo9mP34PrTT4epK8V8CxxXbvLefcpxyAASVMKje8HPUyM JiKEztDK7R1624r7SLCdJ9QIqtqihfo3qed6jNz17FHgHWZifvKdxcPmZ8YffZqsU7R5 SZQbqSa+CWXf0SpksP/8Ki5eVyUugB4GbotqCrau0jbYipqgp3AmpNPN7KItOA4hPs04 w32/p9PgJd+HtBKuEGtyfTKfCnIA2Gr+dsDKsoQkMfpLRPIJowSqNIni8E53IyRkqfmE fG7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gNTaV8ZZ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=qcJnJfx2+aRK1R1frmubBKzhYPVEnSL7mkL0spyRKeA=; b=m7JM+EpaDvotm8z4ueFEFHGHXIDtluFQraDTfLRdb7KAgBWYECccpQdsuLk+C1/ky7 ii/qxhmBrzc7B5LD1u9Pe6p00dCutXrWUm1RGp340LreWQyDILyfCazafoIjuXK6rx4+ cjGCUBhjkNRi5BgwKa3HG3xnln5GuzqV37oB4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-unsubscribe; bh=qcJnJfx2+aRK1R1frmubBKzhYPVEnSL7mkL0spyRKeA=; b=Tv0/nDE5cohCXMnH34F9ilUHbt6ZHCWErkxSjekyJukdUIWrfdBpO2DXE5QKh4PZk6 zrt3TSinWr+UxNvkwx/rDttmnq09DhLeGDLyTCEbiL18gufmy69IMSuP56DIQYJpCBLM lS4ixFJNOFXRVSuKRLZXdTydE4d4xvJX9fRrAES6gtjAJUIS+pgJgU4r7HewjZ/TyzXt KYfqxZlcWOjO7rejvSXgwbrQ5+9QzJlov/30SisPDHY5kIhd20qbVhET5DgepjhsLUdg XJZ4Zf+Er1ZIh6CrzdPpw0wJorpnXjTrqU8KOCEV2tQpm3hDmibR+P8jK7aAn4261W8A NlFw== X-Gm-Message-State: AOAM531dR3lG0OBIxWEG8ZiYhLI2O5mcf7vatLbd1QIOHqAZbUbciwEw 5WAAQPos9uKvCKT5QhIkwhwPYGeO X-Google-Smtp-Source: ABdhPJxF8TtjfDXfQrTr1t3+2w92iAO0JIyfLzzjKmW8B4b2+L2PDjiDY5+K/Onqdffzz7J9NZg6dw== X-Received: by 2002:a62:e904:0:b0:4a4:b4e3:a712 with SMTP id j4-20020a62e904000000b004a4b4e3a712mr33021656pfh.25.1639397982154; Mon, 13 Dec 2021 04:19:42 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:c40d:: with SMTP id k13ls7980760plk.5.gmail; Mon, 13 Dec 2021 04:19:41 -0800 (PST) X-Received: by 2002:a17:902:dac9:b0:141:e931:3b49 with SMTP id q9-20020a170902dac900b00141e9313b49mr94403002plx.45.1639397981409; Mon, 13 Dec 2021 04:19:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639397981; cv=none; d=google.com; s=arc-20160816; b=uuawHl+VD61T9/ualDwKIutAh0J+O3wUZcNOv1nUEAdb4ZWDZ+tDoX1mug2kuQ0b4T QRYUxRjnR2woc1zB+EKB2x8yAabFEfDvb+noYB437YgQqyr37NnXQDW3RLPZ8VPErM5v FkPvOVjypu62BMh40J2kLpwuCgDswhaRpe+Fq7eQzj1/AX7aGJO5VGS1YImPHti3Tan1 nf88QqVDguwPQj+Aa0S4wE7BI5c532VmoO9i6dqmxD3rniHGT53rpHCtIrNvx5rAJcuF bsHYKF5NEkoj9RARV90AIi7d6S7CeBkFAjN9P04epnefN3D/Ko5jQgkkPjQm5APaLenI 6kDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Rc0RebPIDuofIPxVer4Qgu75W8k4/lkVMlGMDPHKxKM=; b=KNfa0Z3jbbgIMVXUGGJx+0AjmcAK08jcVHdCufZO7+zeJVOEv00HvI+byhjIlQNmtV SckbSSpy5+YC3cHj63/yzrzqy14T+uni1gIwpEkrXu5efSEvH3Lm3Tmw2fcwj3ym6XiK wCMKtMXXO5HMU6lJyXkwGvV+L4nZxJDJGuW4jLMXwmI0753y4pZWJx0+DbselnnKPk+e VVEwNI8vqhzPQpybTKdLI9d4khKjklF4gq5689dfm80u9iHPIox6CVJ8VzTfiEb5OYj7 TYAP4OKQE3sgXXbM6rCf2GhCpLAyI+43dAuBUoUsai0N0WZa7vPG8hRQ6y7mnNKHHILv ktig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gNTaV8ZZ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id kk17sor3060730pjb.25.2021.12.13.04.19.39 for (Google Transport Security); Mon, 13 Dec 2021 04:19:39 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:90b:4a52:: with SMTP id lb18mr43386600pjb.84.1639397979492; Mon, 13 Dec 2021 04:19:39 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a0a9:a39d:db10:5743:a46e]) by smtp.gmail.com with ESMTPSA id v63sm10229059pgv.71.2021.12.13.04.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 04:19:39 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Marek Szyprowski Cc: devicetree@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH] drm: bridge: tc358764: Use drm panel_bridge API Date: Mon, 13 Dec 2021 17:49:29 +0530 Message-Id: <20211213121929.3377752-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gNTaV8ZZ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Replace the manual panel handling code by a drm panel_bridge via devm_drm_of_get_bridge(). Adding panel_bridge handling, - Drops drm_connector and related operations as drm_bridge_attach creates connector during attachment. - Drops panel pointer and panel healpers. This simplifies the driver and allows all components in the display pipeline to be treated as bridges. Signed-off-by: Jagan Teki --- drivers/gpu/drm/bridge/tc358764.c | 99 ++----------------------------- 1 file changed, 6 insertions(+), 93 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358764.c b/drivers/gpu/drm/bridge/tc358764.c index c1e35bdf9232..28480bdc4287 100644 --- a/drivers/gpu/drm/bridge/tc358764.c +++ b/drivers/gpu/drm/bridge/tc358764.c @@ -153,10 +153,9 @@ static const char * const tc358764_supplies[] = { struct tc358764 { struct device *dev; struct drm_bridge bridge; - struct drm_connector connector; + struct drm_bridge *panel_bridge; struct regulator_bulk_data supplies[ARRAY_SIZE(tc358764_supplies)]; struct gpio_desc *gpio_reset; - struct drm_panel *panel; int error; }; @@ -210,12 +209,6 @@ static inline struct tc358764 *bridge_to_tc358764(struct drm_bridge *bridge) return container_of(bridge, struct tc358764, bridge); } -static inline -struct tc358764 *connector_to_tc358764(struct drm_connector *connector) -{ - return container_of(connector, struct tc358764, connector); -} - static int tc358764_init(struct tc358764 *ctx) { u32 v = 0; @@ -278,43 +271,11 @@ static void tc358764_reset(struct tc358764 *ctx) usleep_range(1000, 2000); } -static int tc358764_get_modes(struct drm_connector *connector) -{ - struct tc358764 *ctx = connector_to_tc358764(connector); - - return drm_panel_get_modes(ctx->panel, connector); -} - -static const -struct drm_connector_helper_funcs tc358764_connector_helper_funcs = { - .get_modes = tc358764_get_modes, -}; - -static const struct drm_connector_funcs tc358764_connector_funcs = { - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, - .reset = drm_atomic_helper_connector_reset, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, -}; - -static void tc358764_disable(struct drm_bridge *bridge) -{ - struct tc358764 *ctx = bridge_to_tc358764(bridge); - int ret = drm_panel_disable(bridge_to_tc358764(bridge)->panel); - - if (ret < 0) - dev_err(ctx->dev, "error disabling panel (%d)\n", ret); -} - static void tc358764_post_disable(struct drm_bridge *bridge) { struct tc358764 *ctx = bridge_to_tc358764(bridge); int ret; - ret = drm_panel_unprepare(ctx->panel); - if (ret < 0) - dev_err(ctx->dev, "error unpreparing panel (%d)\n", ret); tc358764_reset(ctx); usleep_range(10000, 15000); ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); @@ -335,72 +296,25 @@ static void tc358764_pre_enable(struct drm_bridge *bridge) ret = tc358764_init(ctx); if (ret < 0) dev_err(ctx->dev, "error initializing bridge (%d)\n", ret); - ret = drm_panel_prepare(ctx->panel); - if (ret < 0) - dev_err(ctx->dev, "error preparing panel (%d)\n", ret); -} - -static void tc358764_enable(struct drm_bridge *bridge) -{ - struct tc358764 *ctx = bridge_to_tc358764(bridge); - int ret = drm_panel_enable(ctx->panel); - - if (ret < 0) - dev_err(ctx->dev, "error enabling panel (%d)\n", ret); } static int tc358764_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) -{ - struct tc358764 *ctx = bridge_to_tc358764(bridge); - struct drm_device *drm = bridge->dev; - int ret; - - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { - DRM_ERROR("Fix bridge driver to make connector optional!"); - return -EINVAL; - } - - ctx->connector.polled = DRM_CONNECTOR_POLL_HPD; - ret = drm_connector_init(drm, &ctx->connector, - &tc358764_connector_funcs, - DRM_MODE_CONNECTOR_LVDS); - if (ret) { - DRM_ERROR("Failed to initialize connector\n"); - return ret; - } - - drm_connector_helper_add(&ctx->connector, - &tc358764_connector_helper_funcs); - drm_connector_attach_encoder(&ctx->connector, bridge->encoder); - ctx->connector.funcs->reset(&ctx->connector); - drm_connector_register(&ctx->connector); - - return 0; -} - -static void tc358764_detach(struct drm_bridge *bridge) { struct tc358764 *ctx = bridge_to_tc358764(bridge); - drm_connector_unregister(&ctx->connector); - ctx->panel = NULL; - drm_connector_put(&ctx->connector); + return drm_bridge_attach(bridge->encoder, ctx->panel_bridge, bridge, flags); } static const struct drm_bridge_funcs tc358764_bridge_funcs = { - .disable = tc358764_disable, .post_disable = tc358764_post_disable, - .enable = tc358764_enable, .pre_enable = tc358764_pre_enable, .attach = tc358764_attach, - .detach = tc358764_detach, }; static int tc358764_parse_dt(struct tc358764 *ctx) { struct device *dev = ctx->dev; - int ret; ctx->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ctx->gpio_reset)) { @@ -408,12 +322,11 @@ static int tc358764_parse_dt(struct tc358764 *ctx) return PTR_ERR(ctx->gpio_reset); } - ret = drm_of_find_panel_or_bridge(ctx->dev->of_node, 1, 0, &ctx->panel, - NULL); - if (ret && ret != -EPROBE_DEFER) - dev_err(dev, "cannot find panel (%d)\n", ret); + ctx->panel_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); + if (IS_ERR(ctx->panel_bridge)) + return PTR_ERR(ctx->panel_bridge); - return ret; + return 0; } static int tc358764_configure_regulators(struct tc358764 *ctx)