From patchwork Sun Feb 14 19:41:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1636 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AC41A3F158 for ; Sun, 14 Feb 2021 20:41:46 +0100 (CET) Received: by mail-pf1-f198.google.com with SMTP id j7sf5666057pfa.14 for ; Sun, 14 Feb 2021 11:41:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613331705; cv=pass; d=google.com; s=arc-20160816; b=tFSLQ/oKDjWMcLQXsZYENCMSjyJ0v33gxellzox50YrQaeZZYgwrIy86huVIJNIs0M IjQO+8gxRZVKBbBDekSwh2I33Mh9CSCehtBghteX24qazKK1oHGOiYbLz9xd2r0UqBI0 ipdcXHzjP5HfqksCuXXN5+y21GE+AyxCyf3zkV5Rj4vODSyjE1PD+p82N7V2vAbdD/qv 5I6Rv/wAJQlPeTkaMmzz8Fl8RNwg9iToOouIazdfNO9z1MpHFoC3mv0D4nL5wxsqtM0i Y4k0tj7cdQS5SFxpFvzEJa0Jw48KqP2PgdwO/xfCZbjA0jyQGMdfmaw7JAhNsDjKuG4e QWWw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Q1H+yXgianXCpNdNQplB2BmzmdyEtyLuMrk7zgPz5bw=; b=k+ywl5YTjrw1Z9JQOByUlPSDfC5eXrFJseTOcVH/6fkLuNO4kJO4MZe7bHXhhxN8g5 psjz6uAZU1Op81G5TDq0AiPnhwtyGzyZFOpz5mttRwN/ypMwhy+e2DKk9NclB7Wq7xH7 58HdkrQyY+NxW4bjH35Rg1DhQUXj+qlN9FN4xoeITH9BGrKykKew3HZArVHZzbQrhdnZ jDXY36FfPKbtnPpJ18fAhcv/vvS1bi2eX1Oxg+4y4XZBFln7lUVMvT3mBEOBSn08ymjn 4tfUTltGetFwU4cj8YCrbi8GcrjZqNwaBq3r3ceykSuJfk+aguwF2cFFq6W9GWPdJM/C rrnA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Mccj3Wh+; 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:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Q1H+yXgianXCpNdNQplB2BmzmdyEtyLuMrk7zgPz5bw=; b=OOd6dNvsj4FWfFnLdJ5NhyGgHm5JaBJ7Cn9fJxzv0PFrlMNUDS/NVTHs7GZTt9b3IL md3D9C6eifrV8xm1EJaPFmWDZdMe9l0qcVo8v9Ey03pmShp8KnKRbq3GEst81cw03XGK 6Ras3Ag8g1oZlmjEC43DlYAFaRr7mwozAseyg= 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: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=Q1H+yXgianXCpNdNQplB2BmzmdyEtyLuMrk7zgPz5bw=; b=VFJU9Lsar4IblcD/MiYknzf/Wtix6x9djTqFZ3kZmpvWf3M+qHoxG/1R1PiVuVKiim yQfUviK5AJnlUM2xldxf9aOwAMnQcZh27QBRxT1AvLErVKw9lUUUIwawW543OamTOjZ1 xBDzp7n+59h6Gq0f4RLyma0bO630LISKlbD3/99w+bUN56UpLmBE+df/K55Ob5gnNoDT qU02c/Vl6rR9PwXsRYvFAgl2ER08LaaHiJ2a01Eah9asBAp8VXebMTZYxTxcXtToePQo 3u+3VvMKKpd2GWfNgtAfxue/kMaKCupcRTppbkvI6UXYGWbQYXPd9K4clWfDs4sL+QJS sgJg== X-Gm-Message-State: AOAM533N1KPo2HmCbuXBD5vdfJGLgZc6XRwqvu3uWk2MimwVePrM9pDG d6CWVIoLuh/ViogoYRpnMGz56JR1 X-Google-Smtp-Source: ABdhPJwqCgRN+10rRXha4pkPTRbjX+5VofrGW4aznRK1kn4RdA+zgrhkTnH8jfY1GRfDBIfXma2ntw== X-Received: by 2002:a17:90a:206:: with SMTP id c6mr12964331pjc.50.1613331705548; Sun, 14 Feb 2021 11:41:45 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:85d4:: with SMTP id z20ls5564487pfn.0.gmail; Sun, 14 Feb 2021 11:41:45 -0800 (PST) X-Received: by 2002:a65:624a:: with SMTP id q10mr12261370pgv.2.1613331704829; Sun, 14 Feb 2021 11:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613331704; cv=none; d=google.com; s=arc-20160816; b=NHUgkNbbKpJjeSErgYJjaFS461ysJeD3V64OtZwhM3cHNAGJvwhENm6LpaodwbitIh JNiOsGbOtiKTYoQUf83B0lBcle81/2rIpfSEUQGb+T+BrSPdYZf5B5aPX972RxJXjcDT 4vf9HIfsJ0WO/YkOcq27Qz2lf6IUTwiVPo6CcAEmBUSQJbkzzZlqUospavt0T3xIljJI DQA15LnWNHGgL3SH5YVkwMFmN9GXZ0CBPJZBEUBvkrEIl+MwBR631YYOZ4I+S7Hp4Ne8 0ydy9JBOLTTd91weo1Q80ARlSQu+mrt+iF3gBtq8DvrQc4L9S2Tt1BjjNAcuuwfgI19C S4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Vc5KRcpkrSfSP9D4LPgPMNcSqRtFMop54GG77rWCzXY=; b=QYGBD1uTGqE6CvVl1V3FrD4d+CNKy+QuVLscSiBriFX83bcy0FdDE6RlUNPtzVMNMx R3xJ8Rvw4XM97xFPiHXQMPt30zriRv+Zbq4sURAuMg6/PM20Ui0utNP77VzOu2HfXDjF JF4aLRQdsMEPYud1RsA1acxnz/gngbnKIWHeMy9OsyUQVdBUs13JLb14iF6y61tZm4gi bO0tJlchieMTu0hxkAufdbkeOlZtWX9CtZXmVOnQqmMDRsQCqqJs/z7OsRxvdN1mY4t7 tq7tCdnrGEFnQS8OR0q872U2+3XfYTKLQw467cm9QSAf6wrLFLxi1NFEQBvvBvAPvQcx FLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Mccj3Wh+; 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 t2sor3565590plq.61.2021.02.14.11.41.44 for (Google Transport Security); Sun, 14 Feb 2021 11:41:44 -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:902:860a:b029:e3:5d18:29af with SMTP id f10-20020a170902860ab02900e35d1829afmr188248plo.64.1613331704576; Sun, 14 Feb 2021 11:41:44 -0800 (PST) Received: from ub-XPS-13-9350.domain.name ([45.249.78.214]) by smtp.gmail.com with ESMTPSA id 125sm15129247pfu.7.2021.02.14.11.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 11:41:44 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v3 6/7] drm: sun4i: dsi: Use drm_panel_bridge, connector API Date: Mon, 15 Feb 2021 01:11:01 +0530 Message-Id: <20210214194102.126146-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214194102.126146-1-jagan@amarulasolutions.com> References: <20210214194102.126146-1-jagan@amarulasolutions.com> 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=Mccj3Wh+; 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: , Use drm_panel_bridge to replace manual panel handling code. This simplifies the driver to allows all components in the display pipeline to be treated as bridges, paving the way to generic connector handling. Use drm_bridge_connector_init to create a connector for display pipelines that use drm_bridge. This allows splitting connector operations across multiple bridges when necessary, instead of having the last bridge in the chain creating the connector and handling all connector operations internally. Signed-off-by: Jagan Teki --- Changes for v3: - new patch drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 108 +++++++------------------ drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 7 -- 2 files changed, 27 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 3cdc14daf25c..5e5d3789b3df 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -769,12 +770,6 @@ static void sun6i_dsi_bridge_pre_enable(struct drm_bridge *bridge) phy_set_mode(dsi->dphy, PHY_MODE_MIPI_DPHY); phy_configure(dsi->dphy, &opts); phy_power_on(dsi->dphy); - - if (dsi->panel) - drm_panel_prepare(dsi->panel); - - if (dsi->panel_bridge) - dsi->panel_bridge->funcs->pre_enable(dsi->panel_bridge); } static void sun6i_dsi_bridge_enable(struct drm_bridge *bridge) @@ -793,12 +788,6 @@ static void sun6i_dsi_bridge_enable(struct drm_bridge *bridge) * ordering on the panels I've tested it with, so I guess this * will do for now, until that IP is better understood. */ - if (dsi->panel) - drm_panel_enable(dsi->panel); - - if (dsi->panel_bridge) - dsi->panel_bridge->funcs->enable(dsi->panel_bridge); - sun6i_dsi_start(dsi, DSI_START_HSC); udelay(1000); @@ -812,14 +801,6 @@ static void sun6i_dsi_bridge_disable(struct drm_bridge *bridge) DRM_DEBUG_DRIVER("Disabling DSI output\n"); - if (dsi->panel) { - drm_panel_disable(dsi->panel); - drm_panel_unprepare(dsi->panel); - } else if (dsi->panel_bridge) { - dsi->panel_bridge->funcs->disable(dsi->panel_bridge); - dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge); - } - phy_power_off(dsi->dphy); phy_exit(dsi->dphy); @@ -828,63 +809,13 @@ static void sun6i_dsi_bridge_disable(struct drm_bridge *bridge) regulator_disable(dsi->regulator); } -static int sun6i_dsi_get_modes(struct drm_connector *connector) -{ - struct sun6i_dsi *dsi = connector_to_sun6i_dsi(connector); - - return drm_panel_get_modes(dsi->panel, connector); -} - -static const struct drm_connector_helper_funcs sun6i_dsi_connector_helper_funcs = { - .get_modes = sun6i_dsi_get_modes, -}; - -static enum drm_connector_status -sun6i_dsi_connector_detect(struct drm_connector *connector, bool force) -{ - struct sun6i_dsi *dsi = connector_to_sun6i_dsi(connector); - - return dsi->panel ? connector_status_connected : - connector_status_disconnected; -} - -static const struct drm_connector_funcs sun6i_dsi_connector_funcs = { - .detect = sun6i_dsi_connector_detect, - .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 int sun6i_dsi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct sun6i_dsi *dsi = bridge_to_sun6i_dsi(bridge); - int ret; - - if (dsi->panel_bridge) - return drm_bridge_attach(bridge->encoder, dsi->panel_bridge, NULL, 0); - - if (dsi->panel) { - drm_connector_helper_add(&dsi->connector, - &sun6i_dsi_connector_helper_funcs); - ret = drm_connector_init(bridge->dev, &dsi->connector, - &sun6i_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); - if (ret) { - dev_err(dsi->dev, "Couldn't initialise the DSI connector\n"); - goto err_cleanup_connector; - } - - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - } - - return 0; -err_cleanup_connector: - drm_encoder_cleanup(&dsi->encoder); - return ret; + return drm_bridge_attach(bridge->encoder, dsi->panel_bridge, + &dsi->bridge, flags); } static const struct drm_bridge_funcs sun6i_dsi_bridge_funcs = { @@ -1010,17 +941,24 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); + struct drm_panel *panel; int ret; ret = drm_of_find_panel_or_bridge(dsi->dev->of_node, 0, 0, - &dsi->panel, &dsi->panel_bridge); + &panel, &dsi->panel_bridge); if (ret) return ret; + if (panel) { + dsi->panel_bridge = devm_drm_panel_bridge_add(dsi->dev, panel); + if (IS_ERR(dsi->panel_bridge)) + return PTR_ERR(dsi->panel_bridge); + } + dsi->device = device; - dev_info(host->dev, "Attached %s %s\n", - device->name, dsi->panel ? "panel" : "bridge"); + dev_info(host->dev, + "Attached %s %s\n", device->name, panel ? "panel" : "bridge"); return 0; } @@ -1030,7 +968,6 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, { struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); - dsi->panel = NULL; dsi->panel_bridge = NULL; dsi->device = NULL; @@ -1098,6 +1035,7 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, { struct drm_device *drm = data; struct sun6i_dsi *dsi = dev_get_drvdata(dev); + struct drm_connector *connector; int ret; ret = drm_simple_encoder_init(drm, &dsi->encoder, @@ -1108,15 +1046,23 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, } dsi->encoder.possible_crtcs = BIT(0); - ret = drm_bridge_attach(&dsi->encoder, &dsi->bridge, NULL, 0); - if (ret) { - dev_err(dsi->dev, "Couldn't attach drm bridge\n"); - goto err_cleanup_connector; + ret = drm_bridge_attach(&dsi->encoder, &dsi->bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); + if (ret) + goto err_cleanup_encoder; + + connector = drm_bridge_connector_init(drm, &dsi->encoder); + if (IS_ERR(connector)) { + DRM_ERROR("Unable to create bridge connector\n"); + ret = PTR_ERR(connector); + goto err_cleanup_encoder; } + drm_connector_attach_encoder(connector, &dsi->encoder); + return 0; -err_cleanup_connector: +err_cleanup_encoder: drm_encoder_cleanup(&dsi->encoder); return ret; } diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h index 5e70666089ad..91ea95326ed4 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -17,7 +17,6 @@ struct sun6i_dsi { struct drm_bridge bridge; - struct drm_connector connector; struct drm_encoder encoder; struct mipi_dsi_host host; @@ -30,7 +29,6 @@ struct sun6i_dsi { struct device *dev; struct mipi_dsi_device *device; - struct drm_panel *panel; struct drm_bridge *panel_bridge; }; @@ -44,11 +42,6 @@ static inline struct sun6i_dsi *bridge_to_sun6i_dsi(struct drm_bridge *bridge) return container_of(bridge, struct sun6i_dsi, bridge); } -static inline struct sun6i_dsi *connector_to_sun6i_dsi(struct drm_connector *connector) -{ - return container_of(connector, struct sun6i_dsi, connector); -}; - static inline struct sun6i_dsi *encoder_to_sun6i_dsi(const struct drm_encoder *encoder) { return container_of(encoder, struct sun6i_dsi, encoder);