drm/panel: decouple connector from drm_panel
authorSam Ravnborg <sam@ravnborg.org>
Sat, 7 Dec 2019 14:03:34 +0000 (15:03 +0100)
committerSam Ravnborg <sam@ravnborg.org>
Mon, 9 Dec 2019 21:57:26 +0000 (22:57 +0100)
To facilitate moving connector creation to display drivers,
decouple the drm_connector from drm_panel.

This patch adds a connector argument to drm_panel_get_modes().

All users of drm_panel_get_modes() already had the connector
available, so updating users was trivial.

With this patch drm_panel no longer keeps a reference to the drm_connector.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Alison Wang <alison.wang@nxp.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Torsten Duwe <duwe@lst.de>
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: Icenowy Zheng <icenowy@aosc.io>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Hariprasad Kelam <hariprasad.kelam@gmail.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Brian Masney <masneyb@onstation.org>
Cc: Rob Clark <robdclark@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Allison Randal <allison@lohutok.net>
Cc: Shayenne Moura <shayenneluzmoura@gmail.com>
Cc: Abhinav Kumar <abhinavk@codeaurora.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-tegra@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20191207140353.23967-7-sam@ravnborg.org
26 files changed:
drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
drivers/gpu/drm/bridge/panel.c
drivers/gpu/drm/bridge/parade-ps8622.c
drivers/gpu/drm/bridge/tc358764.c
drivers/gpu/drm/bridge/tc358767.c
drivers/gpu/drm/bridge/ti-sn65dsi86.c
drivers/gpu/drm/drm_panel.c
drivers/gpu/drm/exynos/exynos_drm_dpi.c
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
drivers/gpu/drm/imx/imx-ldb.c
drivers/gpu/drm/imx/parallel-display.c
drivers/gpu/drm/mediatek/mtk_dsi.c
drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c
drivers/gpu/drm/msm/dsi/dsi_manager.c
drivers/gpu/drm/mxsfb/mxsfb_out.c
drivers/gpu/drm/omapdrm/omap_connector.c
drivers/gpu/drm/rcar-du/rcar_lvds.c
drivers/gpu/drm/rockchip/rockchip_lvds.c
drivers/gpu/drm/sti/sti_dvo.c
drivers/gpu/drm/sun4i/sun4i_lvds.c
drivers/gpu/drm/sun4i/sun4i_rgb.c
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
drivers/gpu/drm/tegra/output.c
include/drm/drm_panel.h

index b4f3a923a52aac41f5e8c277fe1c49829257c229..9917ce0d86a0fc2e0a7c3d798bd87fa0a525f958 100644 (file)
@@ -493,7 +493,7 @@ unlock:
        mutex_unlock(&anx6345->lock);
 
        if (!num_modes && anx6345->panel)
-               num_modes += drm_panel_get_modes(anx6345->panel);
+               num_modes += drm_panel_get_modes(anx6345->panel, connector);
 
        return num_modes;
 }
index bb411fe52ae83d673b069b004acd6f1071334acf..6effe532f82005805c93b1ac98b059011a91e54d 100644 (file)
@@ -1111,7 +1111,7 @@ static int analogix_dp_get_modes(struct drm_connector *connector)
        int ret, num_modes = 0;
 
        if (dp->plat_data->panel) {
-               num_modes += drm_panel_get_modes(dp->plat_data->panel);
+               num_modes += drm_panel_get_modes(dp->plat_data->panel, connector);
        } else {
                ret = analogix_dp_prepare_panel(dp, true, false);
                if (ret) {
index 554da47f6d62116ab87ee951ad70988cd5927b09..1443897f999bef87815a6d4616c22ad61bf52047 100644 (file)
@@ -37,7 +37,7 @@ static int panel_bridge_connector_get_modes(struct drm_connector *connector)
        struct panel_bridge *panel_bridge =
                drm_connector_to_panel_bridge(connector);
 
-       return drm_panel_get_modes(panel_bridge->panel);
+       return drm_panel_get_modes(panel_bridge->panel, connector);
 }
 
 static const struct drm_connector_helper_funcs
index b7a72dfdcac3c77d04c29576a3d1c0b20facacb3..10c47c008b401e24561832f68dcfc025eb5620a0 100644 (file)
@@ -461,7 +461,7 @@ static int ps8622_get_modes(struct drm_connector *connector)
 
        ps8622 = connector_to_ps8622(connector);
 
-       return drm_panel_get_modes(ps8622->panel);
+       return drm_panel_get_modes(ps8622->panel, connector);
 }
 
 static const struct drm_connector_helper_funcs ps8622_connector_helper_funcs = {
index db298f550a5adfc7d7317c67ae7d7a2b77c5d425..96207fcfde19bda0df94a0f1aadcae95fbcd4d7d 100644 (file)
@@ -282,7 +282,7 @@ static int tc358764_get_modes(struct drm_connector *connector)
 {
        struct tc358764 *ctx = connector_to_tc358764(connector);
 
-       return drm_panel_get_modes(ctx->panel);
+       return drm_panel_get_modes(ctx->panel, connector);
 }
 
 static const
index 8029478ffebbc6eab05591322782014c6865eb39..3709e5ace7246086b3b4d172bdd5a7218cbf6306 100644 (file)
@@ -1346,7 +1346,7 @@ static int tc_connector_get_modes(struct drm_connector *connector)
                return 0;
        }
 
-       count = drm_panel_get_modes(tc->panel);
+       count = drm_panel_get_modes(tc->panel, connector);
        if (count > 0)
                return count;
 
index 43abf01ebd4ca00272f3ea781f96597e802a093a..9a2dd986afa58df99392fcaafabaa80a7b4c1b8a 100644 (file)
@@ -206,7 +206,7 @@ static int ti_sn_bridge_connector_get_modes(struct drm_connector *connector)
 {
        struct ti_sn_bridge *pdata = connector_to_ti_sn_bridge(connector);
 
-       return drm_panel_get_modes(pdata->panel);
+       return drm_panel_get_modes(pdata->panel, connector);
 }
 
 static enum drm_mode_status
index 8dded4b7d9a203b6756df068e408c8ef422cad75..f6a745949da86c108424c8cf69514b4d85d8febd 100644 (file)
@@ -114,10 +114,9 @@ EXPORT_SYMBOL(drm_panel_remove);
  */
 int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector)
 {
-       if (panel->connector)
+       if (panel->drm)
                return -EBUSY;
 
-       panel->connector = connector;
        panel->drm = connector->dev;
 
        return 0;
@@ -136,7 +135,6 @@ EXPORT_SYMBOL(drm_panel_attach);
  */
 void drm_panel_detach(struct drm_panel *panel)
 {
-       panel->connector = NULL;
        panel->drm = NULL;
 }
 EXPORT_SYMBOL(drm_panel_detach);
@@ -250,6 +248,7 @@ EXPORT_SYMBOL(drm_panel_disable);
 /**
  * drm_panel_get_modes - probe the available display modes of a panel
  * @panel: DRM panel
+ * @connector: DRM connector
  *
  * The modes probed from the panel are automatically added to the connector
  * that the panel is attached to.
@@ -257,13 +256,14 @@ EXPORT_SYMBOL(drm_panel_disable);
  * Return: The number of modes available from the panel on success or a
  * negative error code on failure.
  */
-int drm_panel_get_modes(struct drm_panel *panel)
+int drm_panel_get_modes(struct drm_panel *panel,
+                       struct drm_connector *connector)
 {
        if (!panel)
                return -EINVAL;
 
        if (panel->funcs && panel->funcs->get_modes)
-               return panel->funcs->get_modes(panel, panel->connector);
+               return panel->funcs->get_modes(panel, connector);
 
        return -EOPNOTSUPP;
 }
index 5479ff71cbc6a4530e8c072936965c6965e9c194..43fa0f26c052e97bc87248660d827e48c0ac14d8 100644 (file)
@@ -85,7 +85,7 @@ static int exynos_dpi_get_modes(struct drm_connector *connector)
        }
 
        if (ctx->panel)
-               return drm_panel_get_modes(ctx->panel);
+               return drm_panel_get_modes(ctx->panel, connector);
 
        return 0;
 }
index 7de82e22252adf3f2d8fbe4a4e63fb3f07c116bf..3955f84dc89356b093b0d9749c9fe2a04008347a 100644 (file)
@@ -1462,7 +1462,7 @@ static int exynos_dsi_get_modes(struct drm_connector *connector)
        struct exynos_dsi *dsi = connector_to_dsi(connector);
 
        if (dsi->panel)
-               return drm_panel_get_modes(dsi->panel);
+               return drm_panel_get_modes(dsi->panel, connector);
 
        return 0;
 }
index 82c972e9c02461b47603b9709071e7ccd335cd2b..9598ee3cc4d293422b37e32042eb08a69d2f0b0f 100644 (file)
@@ -68,7 +68,7 @@ static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
        struct fsl_dcu_drm_connector *fsl_connector;
 
        fsl_connector = to_fsl_dcu_connector(connector);
-       return drm_panel_get_modes(fsl_connector->panel);
+       return drm_panel_get_modes(fsl_connector->panel, connector);
 }
 
 static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,
index 208069faf183dd46622f0f6789ab6992bb07ccce..8cb2665b2c7425b1cab030e58db9a8f63965d7cb 100644 (file)
@@ -127,7 +127,7 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
        struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
        int num_modes;
 
-       num_modes = drm_panel_get_modes(imx_ldb_ch->panel);
+       num_modes = drm_panel_get_modes(imx_ldb_ch->panel, connector);
        if (num_modes > 0)
                return num_modes;
 
index 35518e5de356d7b0adb16a01266db15cf4307979..3dca424059f769c129d19454f7e41b589da75728 100644 (file)
@@ -50,7 +50,7 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
        struct device_node *np = imxpd->dev->of_node;
        int num_modes;
 
-       num_modes = drm_panel_get_modes(imxpd->panel);
+       num_modes = drm_panel_get_modes(imxpd->panel, connector);
        if (num_modes > 0)
                return num_modes;
 
index e9931bbbe846478efce7b294e001d1b916ed4493..3b5e016d16c48095b6fb2b0b589d77f045a270c7 100644 (file)
@@ -821,7 +821,7 @@ static int mtk_dsi_connector_get_modes(struct drm_connector *connector)
 {
        struct mtk_dsi *dsi = connector_to_dsi(connector);
 
-       return drm_panel_get_modes(dsi->panel);
+       return drm_panel_get_modes(dsi->panel, connector);
 }
 
 static const struct drm_encoder_helper_funcs mtk_dsi_encoder_helper_funcs = {
index 31abd2352f3e3adcd3b609bd555ac53722bcb4d4..c7df71e2fafca2df22773b77e020295d92ee6f4c 100644 (file)
@@ -53,7 +53,7 @@ static int mdp4_lvds_connector_get_modes(struct drm_connector *connector)
        if (panel) {
                drm_panel_attach(panel, connector);
 
-               ret = drm_panel_get_modes(panel);
+               ret = drm_panel_get_modes(panel, connector);
 
                drm_panel_detach(panel);
        }
index 271aa7bbca925fd95de80964aed83c0cd9fce240..0fc29f1be8cc6ddb4b02aac6be4bc66b8aec3741 100644 (file)
@@ -329,7 +329,7 @@ static int dsi_mgr_connector_get_modes(struct drm_connector *connector)
         * attached to the drm_panel.
         */
        drm_panel_attach(panel, connector);
-       num = drm_panel_get_modes(panel);
+       num = drm_panel_get_modes(panel, connector);
        if (!num)
                return 0;
 
index 4eb94744c526322000098bcac69e01f28820e232..9eca1605d11d69f37b2613de989ea01271d09e09 100644 (file)
@@ -31,7 +31,7 @@ static int mxsfb_panel_get_modes(struct drm_connector *connector)
                        drm_connector_to_mxsfb_drm_private(connector);
 
        if (mxsfb->panel)
-               return drm_panel_get_modes(mxsfb->panel);
+               return drm_panel_get_modes(mxsfb->panel, connector);
 
        return 0;
 }
index 5b8799c69f684936a96034665c38b2aef84a6408..94cded3871746e8f367e823cb7968a61c861a8f2 100644 (file)
@@ -229,7 +229,8 @@ static int omap_connector_get_modes(struct drm_connector *connector)
         * operation to the panel API.
         */
        if (omap_connector->output->panel)
-               return drm_panel_get_modes(omap_connector->output->panel);
+               return drm_panel_get_modes(omap_connector->output->panel,
+                                          connector);
 
        /*
         * We can't retrieve modes, which can happen for instance for a DVI or
index 8c6c172bbf2ea2f60c230c9ac85734d206cc4a5a..2cf44b91853c11f4b850cf6e2bd281237fb44509 100644 (file)
@@ -91,7 +91,7 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector)
 {
        struct rcar_lvds *lvds = connector_to_rcar_lvds(connector);
 
-       return drm_panel_get_modes(lvds->panel);
+       return drm_panel_get_modes(lvds->panel, connector);
 }
 
 static int rcar_lvds_connector_atomic_check(struct drm_connector *connector,
index 8a4c9af0ba73c08b24fd55fc3eb1779f15384990..325811d2e26e181d788ceb58364705d366be5f0b 100644 (file)
@@ -201,7 +201,7 @@ static int rockchip_lvds_connector_get_modes(struct drm_connector *connector)
        struct rockchip_lvds *lvds = connector_to_lvds(connector);
        struct drm_panel *panel = lvds->panel;
 
-       return drm_panel_get_modes(panel);
+       return drm_panel_get_modes(panel, connector);
 }
 
 static const
index 68289b0b063a7a06c06e8d54e603fd4047fc05e9..df2ee86cd4c175fe52794792ce6230d52ffce5b3 100644 (file)
@@ -339,7 +339,7 @@ static int sti_dvo_connector_get_modes(struct drm_connector *connector)
        struct sti_dvo *dvo = dvo_connector->dvo;
 
        if (dvo->panel)
-               return drm_panel_get_modes(dvo->panel);
+               return drm_panel_get_modes(dvo->panel, connector);
 
        return 0;
 }
index 25ab2ef6d5454fb427fb9439ddffdcca35a672c2..65b7a873966678e3f4e7d391c4f869c7193b5749 100644 (file)
@@ -43,7 +43,7 @@ static int sun4i_lvds_get_modes(struct drm_connector *connector)
        struct sun4i_lvds *lvds =
                drm_connector_to_sun4i_lvds(connector);
 
-       return drm_panel_get_modes(lvds->panel);
+       return drm_panel_get_modes(lvds->panel, connector);
 }
 
 static struct drm_connector_helper_funcs sun4i_lvds_con_helper_funcs = {
index e74b9eddca0133973457f4de80dc9cbf0c8db4c2..b27f16af50f5d1940834dafec1789342fdf42061 100644 (file)
@@ -47,7 +47,7 @@ static int sun4i_rgb_get_modes(struct drm_connector *connector)
        struct sun4i_rgb *rgb =
                drm_connector_to_sun4i_rgb(connector);
 
-       return drm_panel_get_modes(rgb->panel);
+       return drm_panel_get_modes(rgb->panel, connector);
 }
 
 /*
index c958ca9bae632222f76e2d8840386dedc92f370f..4e8f634cc2dbb0ed4c5368cc42a7e05e62c29968 100644 (file)
@@ -795,7 +795,7 @@ 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);
+       return drm_panel_get_modes(dsi->panel, connector);
 }
 
 static struct drm_connector_helper_funcs sun6i_dsi_connector_helper_funcs = {
index 5bdbf9ffcda1628148060d7d831e18beeb3292ac..4948373d8c7569219db6c522abb118b27595b419 100644 (file)
@@ -23,7 +23,7 @@ int tegra_output_connector_get_modes(struct drm_connector *connector)
         * ignore any other means of obtaining a mode.
         */
        if (output->panel) {
-               err = drm_panel_get_modes(output->panel);
+               err = drm_panel_get_modes(output->panel, connector);
                if (err > 0)
                        return err;
        }
index feebec16e33a72f82e04ad861c27f85a9148d22c..03a5860f1a1bc5ed7ebe1f24b3233e5be4b8d316 100644 (file)
@@ -136,13 +136,6 @@ struct drm_panel {
         */
        struct drm_device *drm;
 
-       /**
-        * @connector:
-        *
-        * DRM connector that the panel is attached to.
-        */
-       struct drm_connector *connector;
-
        /**
         * @dev:
         *
@@ -201,7 +194,7 @@ int drm_panel_unprepare(struct drm_panel *panel);
 int drm_panel_enable(struct drm_panel *panel);
 int drm_panel_disable(struct drm_panel *panel);
 
-int drm_panel_get_modes(struct drm_panel *panel);
+int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector);
 
 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL)
 struct drm_panel *of_drm_find_panel(const struct device_node *np);