Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-06 Thread Thierry Reding
On Fri, Jun 02, 2017 at 01:25:14PM -0700, Eric Anholt wrote:
[...]
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index f6968d3b4b41..adf9ae0e0b7c 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -4,6 +4,14 @@ config DRM_BRIDGE
>   help
> Bridge registration and lookup framework.
>  
> +config DRM_PANEL_BRIDGE

Nit: perhaps this would be better named DRM_BRIDGE_PANEL because it is
part of DRM_BRIDGE (and in fact depends on it). DRM_PANEL_ prefix with
the select on DRM_PANEL looks weird.

Thierry


signature.asc
Description: PGP signature


Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-06 Thread Thierry Reding
On Fri, Jun 02, 2017 at 01:25:14PM -0700, Eric Anholt wrote:
[...]
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index f6968d3b4b41..adf9ae0e0b7c 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -4,6 +4,14 @@ config DRM_BRIDGE
>   help
> Bridge registration and lookup framework.
>  
> +config DRM_PANEL_BRIDGE

Nit: perhaps this would be better named DRM_BRIDGE_PANEL because it is
part of DRM_BRIDGE (and in fact depends on it). DRM_PANEL_ prefix with
the select on DRM_PANEL looks weird.

Thierry


signature.asc
Description: PGP signature


Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-06 Thread Maarten Lankhorst
Op 05-06-17 om 12:08 schreef Archit Taneja:
>
>
> On 06/03/2017 01:55 AM, Eric Anholt wrote:
>> Many DRM drivers have common code to make a stub connector
>> implementation that wraps a drm_panel.  By wrapping the panel in a DRM
>> bridge, all of the connector code (including calls during encoder
>> enable/disable) goes away.
>>
>> v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
>> be the panel's dev, move kerneldoc up a level and document
>> _remove().
>> v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
>> CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
>> line.
>>
>> Signed-off-by: Eric Anholt 
>> Acked-by: Daniel Vetter  (v1)
>> Reviewed-by: Boris Brezillon  (v2)
>> Acked-by: Archit Taneja  (v2)
>> ---
>>
>> New version of the first patch with build fixes.  I've re-pushed to
>> get another round of kbuild test, but if it comes back clean, I'd like
>> to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
>> by the maintainer).  I'd be dropping my STM patch (replaced by their
>> DSI series), and mediatek (I'd like an ack from the maintainer first).
>
> Thanks, I've locally picked up this patch and the following patches from
> the v2 series:
>
> [PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support 
> bridges.
> [PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper.
> [PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func.
> [PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with 
> drm_panel_bridge. 

This patch breaks support for building drm as module, because it imports some 
of the drm_kms_helper stuff.



Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-06 Thread Maarten Lankhorst
Op 05-06-17 om 12:08 schreef Archit Taneja:
>
>
> On 06/03/2017 01:55 AM, Eric Anholt wrote:
>> Many DRM drivers have common code to make a stub connector
>> implementation that wraps a drm_panel.  By wrapping the panel in a DRM
>> bridge, all of the connector code (including calls during encoder
>> enable/disable) goes away.
>>
>> v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
>> be the panel's dev, move kerneldoc up a level and document
>> _remove().
>> v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
>> CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
>> line.
>>
>> Signed-off-by: Eric Anholt 
>> Acked-by: Daniel Vetter  (v1)
>> Reviewed-by: Boris Brezillon  (v2)
>> Acked-by: Archit Taneja  (v2)
>> ---
>>
>> New version of the first patch with build fixes.  I've re-pushed to
>> get another round of kbuild test, but if it comes back clean, I'd like
>> to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
>> by the maintainer).  I'd be dropping my STM patch (replaced by their
>> DSI series), and mediatek (I'd like an ack from the maintainer first).
>
> Thanks, I've locally picked up this patch and the following patches from
> the v2 series:
>
> [PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support 
> bridges.
> [PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper.
> [PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func.
> [PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with 
> drm_panel_bridge. 

This patch breaks support for building drm as module, because it imports some 
of the drm_kms_helper stuff.



Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-05 Thread Archit Taneja



On 06/03/2017 01:55 AM, Eric Anholt wrote:

Many DRM drivers have common code to make a stub connector
implementation that wraps a drm_panel.  By wrapping the panel in a DRM
bridge, all of the connector code (including calls during encoder
enable/disable) goes away.

v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
be the panel's dev, move kerneldoc up a level and document
_remove().
v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
line.

Signed-off-by: Eric Anholt 
Acked-by: Daniel Vetter  (v1)
Reviewed-by: Boris Brezillon  (v2)
Acked-by: Archit Taneja  (v2)
---

New version of the first patch with build fixes.  I've re-pushed to
get another round of kbuild test, but if it comes back clean, I'd like
to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
by the maintainer).  I'd be dropping my STM patch (replaced by their
DSI series), and mediatek (I'd like an ack from the maintainer first).


Thanks, I've locally picked up this patch and the following patches from
the v2 series:

[PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support 
bridges.
[PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper.
[PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func.
[PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with drm_panel_bridge.

I'll wait for a bit for kbuild to get back with anything, and then push to
drm-misc-next.

Thanks,
Archit



 Documentation/gpu/drm-kms-helpers.rst |   6 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/bridge/Kconfig|  11 +-
 drivers/gpu/drm/bridge/lvds-encoder.c | 157 +++---
 drivers/gpu/drm/bridge/panel.c| 200 ++
 include/drm/drm_bridge.h  |   7 ++
 6 files changed, 241 insertions(+), 141 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/panel.c

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index c075aadd7078..7c5e2549a58a 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -143,6 +143,12 @@ Bridge Helper Reference
 .. kernel-doc:: drivers/gpu/drm/drm_bridge.c
:export:

+Panel-Bridge Helper Reference
+-
+
+.. kernel-doc:: drivers/gpu/drm/bridge/panel.c
+   :export:
+
 .. _drm_panel_helper:

 Panel Helper Reference
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index acc88942c2e5..dc69175255b1 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -24,6 +24,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
 drm-$(CONFIG_PCI) += ati_pcigart.o
 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
+drm-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index f6968d3b4b41..adf9ae0e0b7c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -4,6 +4,14 @@ config DRM_BRIDGE
help
  Bridge registration and lookup framework.

+config DRM_PANEL_BRIDGE
+   def_bool y
+   depends on DRM_BRIDGE
+   depends on DRM_KMS_HELPER
+   select DRM_PANEL
+   help
+ DRM bridge wrapper of DRM panels
+
 menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE

@@ -27,8 +35,7 @@ config DRM_DUMB_VGA_DAC
 config DRM_LVDS_ENCODER
tristate "Transparent parallel to LVDS encoder support"
depends on OF
-   select DRM_KMS_HELPER
-   select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Support for transparent parallel to LVDS encoders that don't require
  any configuration.
diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index f1f67a279426..0903ba574f61 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -8,144 +8,18 @@
  */

 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 

 #include 

-struct lvds_encoder {
-   struct device *dev;
-
-   struct drm_bridge bridge;
-   struct drm_connector connector;
-   struct drm_panel *panel;
-};
-
-static inline struct lvds_encoder *
-drm_bridge_to_lvds_encoder(struct drm_bridge *bridge)
-{
-   return container_of(bridge, struct lvds_encoder, bridge);
-}
-
-static inline struct lvds_encoder *
-drm_connector_to_lvds_encoder(struct drm_connector *connector)
-{
-   return container_of(connector, struct lvds_encoder, connector);
-}
-
-static int lvds_connector_get_modes(struct drm_connector *connector)
-{
-   struct lvds_encoder 

Re: [PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-05 Thread Archit Taneja



On 06/03/2017 01:55 AM, Eric Anholt wrote:

Many DRM drivers have common code to make a stub connector
implementation that wraps a drm_panel.  By wrapping the panel in a DRM
bridge, all of the connector code (including calls during encoder
enable/disable) goes away.

v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
be the panel's dev, move kerneldoc up a level and document
_remove().
v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
line.

Signed-off-by: Eric Anholt 
Acked-by: Daniel Vetter  (v1)
Reviewed-by: Boris Brezillon  (v2)
Acked-by: Archit Taneja  (v2)
---

New version of the first patch with build fixes.  I've re-pushed to
get another round of kbuild test, but if it comes back clean, I'd like
to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
by the maintainer).  I'd be dropping my STM patch (replaced by their
DSI series), and mediatek (I'd like an ack from the maintainer first).


Thanks, I've locally picked up this patch and the following patches from
the v2 series:

[PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support 
bridges.
[PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper.
[PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func.
[PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with drm_panel_bridge.

I'll wait for a bit for kbuild to get back with anything, and then push to
drm-misc-next.

Thanks,
Archit



 Documentation/gpu/drm-kms-helpers.rst |   6 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/bridge/Kconfig|  11 +-
 drivers/gpu/drm/bridge/lvds-encoder.c | 157 +++---
 drivers/gpu/drm/bridge/panel.c| 200 ++
 include/drm/drm_bridge.h  |   7 ++
 6 files changed, 241 insertions(+), 141 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/panel.c

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index c075aadd7078..7c5e2549a58a 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -143,6 +143,12 @@ Bridge Helper Reference
 .. kernel-doc:: drivers/gpu/drm/drm_bridge.c
:export:

+Panel-Bridge Helper Reference
+-
+
+.. kernel-doc:: drivers/gpu/drm/bridge/panel.c
+   :export:
+
 .. _drm_panel_helper:

 Panel Helper Reference
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index acc88942c2e5..dc69175255b1 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -24,6 +24,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
 drm-$(CONFIG_PCI) += ati_pcigart.o
 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
+drm-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index f6968d3b4b41..adf9ae0e0b7c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -4,6 +4,14 @@ config DRM_BRIDGE
help
  Bridge registration and lookup framework.

+config DRM_PANEL_BRIDGE
+   def_bool y
+   depends on DRM_BRIDGE
+   depends on DRM_KMS_HELPER
+   select DRM_PANEL
+   help
+ DRM bridge wrapper of DRM panels
+
 menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE

@@ -27,8 +35,7 @@ config DRM_DUMB_VGA_DAC
 config DRM_LVDS_ENCODER
tristate "Transparent parallel to LVDS encoder support"
depends on OF
-   select DRM_KMS_HELPER
-   select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Support for transparent parallel to LVDS encoders that don't require
  any configuration.
diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index f1f67a279426..0903ba574f61 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -8,144 +8,18 @@
  */

 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 

 #include 

-struct lvds_encoder {
-   struct device *dev;
-
-   struct drm_bridge bridge;
-   struct drm_connector connector;
-   struct drm_panel *panel;
-};
-
-static inline struct lvds_encoder *
-drm_bridge_to_lvds_encoder(struct drm_bridge *bridge)
-{
-   return container_of(bridge, struct lvds_encoder, bridge);
-}
-
-static inline struct lvds_encoder *
-drm_connector_to_lvds_encoder(struct drm_connector *connector)
-{
-   return container_of(connector, struct lvds_encoder, connector);
-}
-
-static int lvds_connector_get_modes(struct drm_connector *connector)
-{
-   struct lvds_encoder *lvds = drm_connector_to_lvds_encoder(connector);
-
-   return drm_panel_get_modes(lvds->panel);
-}
-

[PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-02 Thread Eric Anholt
Many DRM drivers have common code to make a stub connector
implementation that wraps a drm_panel.  By wrapping the panel in a DRM
bridge, all of the connector code (including calls during encoder
enable/disable) goes away.

v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
be the panel's dev, move kerneldoc up a level and document
_remove().
v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
line.

Signed-off-by: Eric Anholt 
Acked-by: Daniel Vetter  (v1)
Reviewed-by: Boris Brezillon  (v2)
Acked-by: Archit Taneja  (v2)
---

New version of the first patch with build fixes.  I've re-pushed to
get another round of kbuild test, but if it comes back clean, I'd like
to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
by the maintainer).  I'd be dropping my STM patch (replaced by their
DSI series), and mediatek (I'd like an ack from the maintainer first).

 Documentation/gpu/drm-kms-helpers.rst |   6 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/bridge/Kconfig|  11 +-
 drivers/gpu/drm/bridge/lvds-encoder.c | 157 +++---
 drivers/gpu/drm/bridge/panel.c| 200 ++
 include/drm/drm_bridge.h  |   7 ++
 6 files changed, 241 insertions(+), 141 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/panel.c

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index c075aadd7078..7c5e2549a58a 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -143,6 +143,12 @@ Bridge Helper Reference
 .. kernel-doc:: drivers/gpu/drm/drm_bridge.c
:export:
 
+Panel-Bridge Helper Reference
+-
+
+.. kernel-doc:: drivers/gpu/drm/bridge/panel.c
+   :export:
+
 .. _drm_panel_helper:
 
 Panel Helper Reference
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index acc88942c2e5..dc69175255b1 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -24,6 +24,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
 drm-$(CONFIG_PCI) += ati_pcigart.o
 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
+drm-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index f6968d3b4b41..adf9ae0e0b7c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -4,6 +4,14 @@ config DRM_BRIDGE
help
  Bridge registration and lookup framework.
 
+config DRM_PANEL_BRIDGE
+   def_bool y
+   depends on DRM_BRIDGE
+   depends on DRM_KMS_HELPER
+   select DRM_PANEL
+   help
+ DRM bridge wrapper of DRM panels
+
 menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE
 
@@ -27,8 +35,7 @@ config DRM_DUMB_VGA_DAC
 config DRM_LVDS_ENCODER
tristate "Transparent parallel to LVDS encoder support"
depends on OF
-   select DRM_KMS_HELPER
-   select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Support for transparent parallel to LVDS encoders that don't require
  any configuration.
diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index f1f67a279426..0903ba574f61 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -8,144 +8,18 @@
  */
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
 
 #include 
 
-struct lvds_encoder {
-   struct device *dev;
-
-   struct drm_bridge bridge;
-   struct drm_connector connector;
-   struct drm_panel *panel;
-};
-
-static inline struct lvds_encoder *
-drm_bridge_to_lvds_encoder(struct drm_bridge *bridge)
-{
-   return container_of(bridge, struct lvds_encoder, bridge);
-}
-
-static inline struct lvds_encoder *
-drm_connector_to_lvds_encoder(struct drm_connector *connector)
-{
-   return container_of(connector, struct lvds_encoder, connector);
-}
-
-static int lvds_connector_get_modes(struct drm_connector *connector)
-{
-   struct lvds_encoder *lvds = drm_connector_to_lvds_encoder(connector);
-
-   return drm_panel_get_modes(lvds->panel);
-}
-
-static const struct drm_connector_helper_funcs lvds_connector_helper_funcs = {
-   .get_modes = lvds_connector_get_modes,
-};
-
-static const struct drm_connector_funcs lvds_connector_funcs = {
-   .dpms = drm_atomic_helper_connector_dpms,
-   .reset = drm_atomic_helper_connector_reset,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = drm_connector_cleanup,
-   

[PATCH v3] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.

2017-06-02 Thread Eric Anholt
Many DRM drivers have common code to make a stub connector
implementation that wraps a drm_panel.  By wrapping the panel in a DRM
bridge, all of the connector code (including calls during encoder
enable/disable) goes away.

v2: Fix build with CONFIG_DRM=m, drop "dev" argument that should just
be the panel's dev, move kerneldoc up a level and document
_remove().
v3: Fix another breakage with CONFIG_DRM=m, fix breakage with
CONFIG_OF=n, move protos under CONFIG_DRM_PANEL_BRIDGE, wrap a
line.

Signed-off-by: Eric Anholt 
Acked-by: Daniel Vetter  (v1)
Reviewed-by: Boris Brezillon  (v2)
Acked-by: Archit Taneja  (v2)
---

New version of the first patch with build fixes.  I've re-pushed to
get another round of kbuild test, but if it comes back clean, I'd like
to merge this one, the vc4 patches (unchanged), and atmel-hlcdc (acked
by the maintainer).  I'd be dropping my STM patch (replaced by their
DSI series), and mediatek (I'd like an ack from the maintainer first).

 Documentation/gpu/drm-kms-helpers.rst |   6 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/bridge/Kconfig|  11 +-
 drivers/gpu/drm/bridge/lvds-encoder.c | 157 +++---
 drivers/gpu/drm/bridge/panel.c| 200 ++
 include/drm/drm_bridge.h  |   7 ++
 6 files changed, 241 insertions(+), 141 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/panel.c

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index c075aadd7078..7c5e2549a58a 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -143,6 +143,12 @@ Bridge Helper Reference
 .. kernel-doc:: drivers/gpu/drm/drm_bridge.c
:export:
 
+Panel-Bridge Helper Reference
+-
+
+.. kernel-doc:: drivers/gpu/drm/bridge/panel.c
+   :export:
+
 .. _drm_panel_helper:
 
 Panel Helper Reference
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index acc88942c2e5..dc69175255b1 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -24,6 +24,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
 drm-$(CONFIG_PCI) += ati_pcigart.o
 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
+drm-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm-$(CONFIG_OF) += drm_of.o
 drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index f6968d3b4b41..adf9ae0e0b7c 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -4,6 +4,14 @@ config DRM_BRIDGE
help
  Bridge registration and lookup framework.
 
+config DRM_PANEL_BRIDGE
+   def_bool y
+   depends on DRM_BRIDGE
+   depends on DRM_KMS_HELPER
+   select DRM_PANEL
+   help
+ DRM bridge wrapper of DRM panels
+
 menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE
 
@@ -27,8 +35,7 @@ config DRM_DUMB_VGA_DAC
 config DRM_LVDS_ENCODER
tristate "Transparent parallel to LVDS encoder support"
depends on OF
-   select DRM_KMS_HELPER
-   select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Support for transparent parallel to LVDS encoders that don't require
  any configuration.
diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index f1f67a279426..0903ba574f61 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -8,144 +8,18 @@
  */
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
 
 #include 
 
-struct lvds_encoder {
-   struct device *dev;
-
-   struct drm_bridge bridge;
-   struct drm_connector connector;
-   struct drm_panel *panel;
-};
-
-static inline struct lvds_encoder *
-drm_bridge_to_lvds_encoder(struct drm_bridge *bridge)
-{
-   return container_of(bridge, struct lvds_encoder, bridge);
-}
-
-static inline struct lvds_encoder *
-drm_connector_to_lvds_encoder(struct drm_connector *connector)
-{
-   return container_of(connector, struct lvds_encoder, connector);
-}
-
-static int lvds_connector_get_modes(struct drm_connector *connector)
-{
-   struct lvds_encoder *lvds = drm_connector_to_lvds_encoder(connector);
-
-   return drm_panel_get_modes(lvds->panel);
-}
-
-static const struct drm_connector_helper_funcs lvds_connector_helper_funcs = {
-   .get_modes = lvds_connector_get_modes,
-};
-
-static const struct drm_connector_funcs lvds_connector_funcs = {
-   .dpms = drm_atomic_helper_connector_dpms,
-   .reset = drm_atomic_helper_connector_reset,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = drm_connector_cleanup,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state =