]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/vc4: Switch DSI to the panel-bridge layer, and support bridges.
authorEric Anholt <eric@anholt.net>
Thu, 11 May 2017 18:31:23 +0000 (11:31 -0700)
committerArchit Taneja <architt@codeaurora.org>
Mon, 5 Jun 2017 09:37:37 +0000 (15:07 +0530)
The newer version of the RPi panel driver is going to be a combination
of a bridge and a panel, but we should also support panels without a
bridge, so the panel-bridge layer lets us do that cleanly.

v2: Drop "dev" argument.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20170511183128.25085-2-eric@anholt.net
drivers/gpu/drm/vc4/Kconfig
drivers/gpu/drm/vc4/vc4_dsi.c

index b16aefe4a8d3fd27bd032331bba57d1413d19583..4361bdcfd28a2177b762922ebe62ee15d1435fcb 100644 (file)
@@ -7,7 +7,7 @@ config DRM_VC4
        select DRM_KMS_HELPER
        select DRM_KMS_CMA_HELPER
        select DRM_GEM_CMA_HELPER
-       select DRM_PANEL
+       select DRM_PANEL_BRIDGE
        select SND_PCM
        select SND_PCM_ELD
        select SND_SOC_GENERIC_DMAENGINE_PCM
index 0ef41df3915f7266c3d34b890043e10f91394eae..5e8b81eaa168b8307f601117f32fd769d9dc446e 100644 (file)
@@ -503,8 +503,8 @@ struct vc4_dsi {
 
        struct mipi_dsi_host dsi_host;
        struct drm_encoder *encoder;
-       struct drm_connector *connector;
-       struct drm_panel *panel;
+       struct drm_bridge *bridge;
+       bool is_panel_bridge;
 
        void __iomem *regs;
 
@@ -605,18 +605,6 @@ to_vc4_dsi_encoder(struct drm_encoder *encoder)
        return container_of(encoder, struct vc4_dsi_encoder, base.base);
 }
 
-/* VC4 DSI connector KMS struct */
-struct vc4_dsi_connector {
-       struct drm_connector base;
-       struct vc4_dsi *dsi;
-};
-
-static inline struct vc4_dsi_connector *
-to_vc4_dsi_connector(struct drm_connector *connector)
-{
-       return container_of(connector, struct vc4_dsi_connector, base);
-}
-
 #define DSI_REG(reg) { reg, #reg }
 static const struct {
        u32 reg;
@@ -724,79 +712,6 @@ int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused)
 }
 #endif
 
-static enum drm_connector_status
-vc4_dsi_connector_detect(struct drm_connector *connector, bool force)
-{
-       struct vc4_dsi_connector *vc4_connector =
-               to_vc4_dsi_connector(connector);
-       struct vc4_dsi *dsi = vc4_connector->dsi;
-
-       if (dsi->panel)
-               return connector_status_connected;
-       else
-               return connector_status_disconnected;
-}
-
-static void vc4_dsi_connector_destroy(struct drm_connector *connector)
-{
-       drm_connector_unregister(connector);
-       drm_connector_cleanup(connector);
-}
-
-static int vc4_dsi_connector_get_modes(struct drm_connector *connector)
-{
-       struct vc4_dsi_connector *vc4_connector =
-               to_vc4_dsi_connector(connector);
-       struct vc4_dsi *dsi = vc4_connector->dsi;
-
-       if (dsi->panel)
-               return drm_panel_get_modes(dsi->panel);
-
-       return 0;
-}
-
-static const struct drm_connector_funcs vc4_dsi_connector_funcs = {
-       .dpms = drm_atomic_helper_connector_dpms,
-       .detect = vc4_dsi_connector_detect,
-       .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = vc4_dsi_connector_destroy,
-       .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 const struct drm_connector_helper_funcs vc4_dsi_connector_helper_funcs = {
-       .get_modes = vc4_dsi_connector_get_modes,
-};
-
-static struct drm_connector *vc4_dsi_connector_init(struct drm_device *dev,
-                                                   struct vc4_dsi *dsi)
-{
-       struct drm_connector *connector;
-       struct vc4_dsi_connector *dsi_connector;
-
-       dsi_connector = devm_kzalloc(dev->dev, sizeof(*dsi_connector),
-                                    GFP_KERNEL);
-       if (!dsi_connector)
-               return ERR_PTR(-ENOMEM);
-
-       connector = &dsi_connector->base;
-
-       dsi_connector->dsi = dsi;
-
-       drm_connector_init(dev, connector, &vc4_dsi_connector_funcs,
-                          DRM_MODE_CONNECTOR_DSI);
-       drm_connector_helper_add(connector, &vc4_dsi_connector_helper_funcs);
-
-       connector->polled = 0;
-       connector->interlace_allowed = 0;
-       connector->doublescan_allowed = 0;
-
-       drm_mode_connector_attach_encoder(connector, dsi->encoder);
-
-       return connector;
-}
-
 static void vc4_dsi_encoder_destroy(struct drm_encoder *encoder)
 {
        drm_encoder_cleanup(encoder);
@@ -894,12 +809,8 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder)
        struct vc4_dsi *dsi = vc4_encoder->dsi;
        struct device *dev = &dsi->pdev->dev;
 
-       drm_panel_disable(dsi->panel);
-
        vc4_dsi_ulps(dsi, true);
 
-       drm_panel_unprepare(dsi->panel);
-
        clk_disable_unprepare(dsi->pll_phy_clock);
        clk_disable_unprepare(dsi->escape_clock);
        clk_disable_unprepare(dsi->pixel_clock);
@@ -984,12 +895,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
                return;
        }
 
-       ret = drm_panel_prepare(dsi->panel);
-       if (ret) {
-               DRM_ERROR("Panel failed to prepare\n");
-               return;
-       }
-
        if (debug_dump_regs) {
                DRM_INFO("DSI regs before:\n");
                vc4_dsi_dump_regs(dsi);
@@ -1211,13 +1116,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
                DRM_INFO("DSI regs after:\n");
                vc4_dsi_dump_regs(dsi);
        }
-
-       ret = drm_panel_enable(dsi->panel);
-       if (ret) {
-               DRM_ERROR("Panel failed to enable\n");
-               drm_panel_unprepare(dsi->panel);
-               return;
-       }
 }
 
 static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,
@@ -1415,17 +1313,22 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,
                return 0;
        }
 
-       dsi->panel = of_drm_find_panel(device->dev.of_node);
-       if (!dsi->panel)
-               return 0;
-
-       ret = drm_panel_attach(dsi->panel, dsi->connector);
-       if (ret != 0)
-               return ret;
+       dsi->bridge = of_drm_find_bridge(device->dev.of_node);
+       if (!dsi->bridge) {
+               struct drm_panel *panel =
+                       of_drm_find_panel(device->dev.of_node);
 
-       drm_helper_hpd_irq_event(dsi->connector->dev);
+               dsi->bridge = drm_panel_bridge_add(panel,
+                                                  DRM_MODE_CONNECTOR_DSI);
+               if (IS_ERR(dsi->bridge)) {
+                       ret = PTR_ERR(dsi->bridge);
+                       dsi->bridge = NULL;
+                       return ret;
+               }
+               dsi->is_panel_bridge = true;
+       }
 
-       return 0;
+       return drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
 }
 
 static int vc4_dsi_host_detach(struct mipi_dsi_host *host,
@@ -1433,15 +1336,9 @@ static int vc4_dsi_host_detach(struct mipi_dsi_host *host,
 {
        struct vc4_dsi *dsi = host_to_dsi(host);
 
-       if (dsi->panel) {
-               int ret = drm_panel_detach(dsi->panel);
-
-               if (ret)
-                       return ret;
-
-               dsi->panel = NULL;
-
-               drm_helper_hpd_irq_event(dsi->connector->dev);
+       if (dsi->is_panel_bridge) {
+               drm_panel_bridge_remove(dsi->bridge);
+               dsi->bridge = NULL;
        }
 
        return 0;
@@ -1708,12 +1605,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
                         DRM_MODE_ENCODER_DSI, NULL);
        drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
 
-       dsi->connector = vc4_dsi_connector_init(drm, dsi);
-       if (IS_ERR(dsi->connector)) {
-               ret = PTR_ERR(dsi->connector);
-               goto err_destroy_encoder;
-       }
-
        dsi->dsi_host.ops = &vc4_dsi_host_ops;
        dsi->dsi_host.dev = dev;
 
@@ -1724,11 +1615,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
        pm_runtime_enable(dev);
 
        return 0;
-
-err_destroy_encoder:
-       vc4_dsi_encoder_destroy(dsi->encoder);
-
-       return ret;
 }
 
 static void vc4_dsi_unbind(struct device *dev, struct device *master,
@@ -1740,7 +1626,7 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master,
 
        pm_runtime_disable(dev);
 
-       vc4_dsi_connector_destroy(dsi->connector);
+       drm_bridge_remove(dsi->bridge);
        vc4_dsi_encoder_destroy(dsi->encoder);
 
        mipi_dsi_host_unregister(&dsi->dsi_host);