Re: [PATCH 3/7 v3] drm/pl111: Replace custom connector with panel bridge

2017-09-07 Thread Eric Anholt
Linus Walleij  writes:

> This replaces the custom connector in the PL111 with the
> panel bridge helper.
>
> This works nicely for all standard panels, but since there
> are several PL11x-based systems that will need to use the dumb
> VGA connector bridge we use drm_of_find_panel_or_bridge()
> and make some headroom for dealing with bridges that are
> not panels as well, and drop a TODO in the code.
>
> Signed-off-by: Linus Walleij 

> +out_bridge:
> + if (panel)
> + drm_panel_bridge_remove(bridge);
> + else
> + drm_bridge_remove(bridge);

Drop the "else drm_bridge_remove(bridge)" here and in the hunk below --
that unregisters the bridge driver entirely, rather than unreferencing
it from your driver (there's no refcounting to be done).

With that change,

Reviewed-by: Eric Anholt 

>  out_config:
>   drm_mode_config_cleanup(dev);
>  finish:
> @@ -236,6 +250,10 @@ static int pl111_amba_remove(struct amba_device 
> *amba_dev)
>   drm_dev_unregister(drm);
>   if (priv->fbdev)
>   drm_fbdev_cma_fini(priv->fbdev);
> + if (priv->panel)
> + drm_panel_bridge_remove(priv->bridge);
> + else
> + drm_bridge_remove(priv->bridge);
>   drm_mode_config_cleanup(drm);
>   drm_dev_unref(drm);
>  
> -- 
> 2.13.5


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/7 v3] drm/pl111: Replace custom connector with panel bridge

2017-09-07 Thread Linus Walleij
This replaces the custom connector in the PL111 with the
panel bridge helper.

This works nicely for all standard panels, but since there
are several PL11x-based systems that will need to use the dumb
VGA connector bridge we use drm_of_find_panel_or_bridge()
and make some headroom for dealing with bridges that are
not panels as well, and drop a TODO in the code.

Signed-off-by: Linus Walleij 
---
ChangeLog v2->v3:
- Rebase on DRM-TIP
- Use drm_simple_display_pipe_attach_bridge() as suggested
  by Daniel Vetter.
ChangeLog v1->v2:
- Remove the panel [un]prepare() and [en|dis]able() calls
  from the display driver, since this is now handled
  by the bridge.
---
 drivers/gpu/drm/pl111/Kconfig   |   3 +-
 drivers/gpu/drm/pl111/Makefile  |   3 +-
 drivers/gpu/drm/pl111/pl111_connector.c | 126 
 drivers/gpu/drm/pl111/pl111_display.c   |  18 ++---
 drivers/gpu/drm/pl111/pl111_drm.h   |  17 ++---
 drivers/gpu/drm/pl111/pl111_drv.c   |  52 -
 6 files changed, 52 insertions(+), 167 deletions(-)
 delete mode 100644 drivers/gpu/drm/pl111/pl111_connector.c

diff --git a/drivers/gpu/drm/pl111/Kconfig b/drivers/gpu/drm/pl111/Kconfig
index bbfba87cd1a8..e5e2abd66491 100644
--- a/drivers/gpu/drm/pl111/Kconfig
+++ b/drivers/gpu/drm/pl111/Kconfig
@@ -6,7 +6,8 @@ config DRM_PL111
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
select DRM_GEM_CMA_HELPER
-   select DRM_PANEL
+   select DRM_BRIDGE
+   select DRM_PANEL_BRIDGE
select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
help
  Choose this option for DRM support for the PL111 CLCD controller.
diff --git a/drivers/gpu/drm/pl111/Makefile b/drivers/gpu/drm/pl111/Makefile
index 59483d610ef5..c5f8f9684848 100644
--- a/drivers/gpu/drm/pl111/Makefile
+++ b/drivers/gpu/drm/pl111/Makefile
@@ -1,5 +1,4 @@
-pl111_drm-y += pl111_connector.o \
-   pl111_display.o \
+pl111_drm-y += pl111_display.o \
pl111_drv.o
 
 pl111_drm-$(CONFIG_DEBUG_FS) += pl111_debugfs.o
diff --git a/drivers/gpu/drm/pl111/pl111_connector.c 
b/drivers/gpu/drm/pl111/pl111_connector.c
deleted file mode 100644
index d335f9a29ce4..
--- a/drivers/gpu/drm/pl111/pl111_connector.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
- *
- * Parts of this file were based on sources as follows:
- *
- * Copyright (c) 2006-2008 Intel Corporation
- * Copyright (c) 2007 Dave Airlie 
- * Copyright (C) 2011 Texas Instruments
- *
- * This program is free software and is provided to you under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation, and any use by you of this program is subject to the terms of
- * such GNU licence.
- *
- */
-
-/**
- * pl111_drm_connector.c
- * Implementation of the connector functions for PL111 DRM
- */
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "pl111_drm.h"
-
-static void pl111_connector_destroy(struct drm_connector *connector)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   if (pl111_connector->panel)
-   drm_panel_detach(pl111_connector->panel);
-
-   drm_connector_unregister(connector);
-   drm_connector_cleanup(connector);
-}
-
-static enum drm_connector_status pl111_connector_detect(struct drm_connector
-   *connector, bool force)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   return (pl111_connector->panel ?
-   connector_status_connected :
-   connector_status_disconnected);
-}
-
-static int pl111_connector_helper_get_modes(struct drm_connector *connector)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   if (!pl111_connector->panel)
-   return 0;
-
-   return drm_panel_get_modes(pl111_connector->panel);
-}
-
-const struct drm_connector_funcs connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = pl111_connector_destroy,
-   .detect = pl111_connector_detect,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-const struct drm_connector_helper_funcs connector_helper_funcs = {
-   .get_modes = pl111_connector_helper_get_modes,
-};
-
-/* Walks the OF graph to find the panel node and then asks DRM to look
- * up the panel.
- */
-static struct drm_panel *pl111_get_panel(struct device *dev)
-{
-   struct device_node *endpoint, *panel_node;
-   struct device_node *np = dev->of_node;
-   struct