drm: improve various bridge devices support
Subsystems (7)
Inki Dae
maintainerRFC PATCH 1/1 drm: improve various bridge devices support
This patch integrates existing drm_panel and drm_bridge frameworks to one integrated framework, drm_hw_block.
For this, I had already sent a email to make a discussion[1] about how we could support all bridges, one bridge between crtc and encoder, and another bridge between encoder and panel.
Now existing drm_panel could be used only for real panel, and drm_bridge only for lvds bridge devices between encoder and panel. However, some embedded SoC have bridge devices of other type between crtc and encoder, i.e. Image Enhancer chip.
So the existing encoder driver couldn't control such bridge commonly using existing drm_bridge because only drm_encoder has drm_bridge.
Below shows how encoder driver could control bridge device using existing drm_bridge.
display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel
| /|\ /|\
|---------------| |
controlled by drm_bridge |
| |
|---------------------------| controlled by drm_panel
In the other hands, drm_panel has no any dependency of drm_encoder, and its infrastructure could be used by crtc driver with a little change. So this integrated framework basically uses existing infrastructure of drm_panel, and just adds drm_lvds structure to it for backward compatibility.
And then, we could add a new bridge type, i.e. drm_enhancer in the near future. So this patch is just ready for that.
As a result, if we add drm_enhancer, crtc driver could control a bridge device between crtc and encoder like below.
display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel
| /|\ | /|\ /|\
|--------------------| |---------------| |
controlled by drm_enhancer controlled by drm_lvds |
| |
|--------------------------| controlled by drm_panel
[1] http://www.spinics.net/lists/dri-devel/msg55555.html
--- drivers/gpu/drm/Kconfig | 4 ++ drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_hw_block.c | 104 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 100 ------------------------------- drivers/gpu/drm/exynos/Kconfig | 1 + drivers/gpu/drm/panel/Kconfig | 1 + drivers/gpu/drm/panel/panel-simple.c | 37 ++++++------ drivers/gpu/drm/tegra/drm.h | 2 +- drivers/gpu/drm/tegra/dsi.c | 10 ++-- drivers/gpu/drm/tegra/output.c | 22 +++---- include/drm/drm_hw_block.h | 107 ++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 82 -------------------------- 12 files changed, 254 insertions(+), 218 deletions(-) create mode 100644 drivers/gpu/drm/drm_hw_block.c delete mode 100644 drivers/gpu/drm/drm_panel.c create mode 100644 include/drm/drm_hw_block.h delete mode 100644 include/drm/drm_panel.h
drivers/gpu/drm/Kconfig +4 -0
@@ -24,6 +24,10 @@ config DRM_MIPI_DSI bool depends on DRM +config DRM_HW_BLOCK + bool + depends on DRM + config DRM_USB tristate depends on DRM
drivers/gpu/drm/Makefile +1 -1
@@ -18,7 +18,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ 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_HW_BLOCK) += drm_hw_block.o drm-usb-y := drm_usb.o
drivers/gpu/drm/drm_hw_block.c new file +104 -0
104 lines not on this page · raw message
drivers/gpu/drm/drm_panel.c deleted +0 -100
100 lines not on this page · raw message
drivers/gpu/drm/exynos/Kconfig +1 -0
@@ -8,6 +8,7 @@ config DRM_EXYNOS select FB_CFB_IMAGEBLIT select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE select VIDEOMODE_HELPERS + select DRM_PANEL help Choose this option if you have a Samsung SoC EXYNOS chipset. If M is selected the module will be called exynosdrm.
drivers/gpu/drm/panel/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_PANEL bool depends on DRM + select DRM_HW_BLOCK help Panel registration and lookup framework.
drivers/gpu/drm/panel/panel-simple.c +19 -18
@@ -32,7 +32,7 @@#include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> struct panel_desc {const struct drm_display_mode *modes;
@@ -48,7 +48,7 @@ struct panel_desc {#define GPIO_ACTIVE_LOW (1 << 0)struct panel_simple { -struct drm_panel base; +struct drm_hw_block base;bool enabled;const struct panel_desc *desc;
@@ -61,9 +61,9 @@ struct panel_simple {int enable_gpio; }; -static inline struct panel_simple *to_panel_simple (struct drm_panel *panel) +static inline struct panel_simple *to_panel_simple (struct drm_hw_block *block) { - return container_of(panel, struct panel_simple, base); + return container_of(block, struct panel_simple, base); }static int panel_simple_get_fixed_modes (struct panel_simple *panel)
@@ -98,9 +98,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel)return num; } -static int panel_simple_disable (struct drm_panel *panel) +static int panel_simple_disable (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);if (!p->enabled)return 0 ;
@@ -123,9 +123,9 @@ static int panel_simple_disable(struct drm_panel *panel)return 0 ; } -static int panel_simple_enable (struct drm_panel *panel) +static int panel_simple_enable (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);int err;if (p->enabled)
@@ -133,7 +133,7 @@ static int panel_simple_enable(struct drm_panel *panel) err =regulator_enable (p->supply);if (err <0 ) { -dev_err (panel->dev,"failed to enable supply: %d\n" , err); +dev_err (block->dev,"failed to enable supply: %d\n" , err);return err; }
@@ -154,16 +154,16 @@ static int panel_simple_enable(struct drm_panel *panel)return 0 ; } -static int panel_simple_get_modes (struct drm_panel *panel) +static int panel_simple_get_modes (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);int num =0 ;/* probe EDID if a DDC bus is available */ if (p->ddc) { -struct edid *edid =drm_get_edid (panel->connector, p->ddc); +struct edid *edid =drm_get_edid (block->connector, p->ddc);if (edid) { - num +=drm_add_edid_modes (panel->connector, edid); + num +=drm_add_edid_modes (block->connector, edid);kfree (edid); } }
@@ -246,11 +246,12 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) } } -drm_panel_init (&panel->base); + panel->base.type =DRM_HW_BLOCK_PANEL ; +drm_hw_block_init (&panel->base); panel->base.dev = dev; - panel->base.funcs = &panel_simple_funcs; + panel->base.panel_funcs = &panel_simple_funcs; - err =drm_panel_add (&panel->base); + err =drm_hw_block_add (&panel->base);if (err <0 ) goto free_ddc;
@@ -275,8 +276,8 @@ static int panel_simple_remove(struct device *dev) {struct panel_simple *panel =dev_get_drvdata (dev); -drm_panel_detach (&panel->base); -drm_panel_remove (&panel->base); +drm_hw_block_detach (&panel->base); +drm_hw_block_remove (&panel->base);panel_simple_disable (&panel->base);
drivers/gpu/drm/tegra/drm.h +1 -1
@@ -194,7 +194,7 @@ struct tegra_output {const struct tegra_output_ops *ops;enum tegra_output_type type; -struct drm_panel *panel; +struct drm_hw_block *block;struct i2c_adapter *ddc;const struct edid *edid;unsigned int hpd_irq;
drivers/gpu/drm/tegra/dsi.c +5 -5
@@ -29,7 +29,7 @@#include <linux/reset.h> #include <drm/drm_mipi_dsi.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> #include <video/mipi_display.h>
@@ -792,8 +792,8 @@ static int tegra_dsi_host_attach(struct mipi_dsi_host *host, dsi->format = device->format; dsi->lanes = device->lanes; - output->panel =of_drm_find_panel (device->dev.of_node); -if (output->panel) { + output->block =of_drm_find_hw_block (device->dev.of_node); +if (output->block) {if (output->connector.dev)drm_helper_hpd_irq_event (output->connector.dev); }
@@ -807,11 +807,11 @@ static int tegra_dsi_host_detach(struct mipi_dsi_host *host,struct tegra_dsi *dsi =host_to_tegra (host);struct tegra_output *output = &dsi->output; -if (output->panel && &device->dev == output->panel->dev) { +if (output->block && &device->dev == output->block->dev) {if (output->connector.dev)drm_helper_hpd_irq_event (output->connector.dev); - output->panel =NULL ; + output->block =NULL ; }return 0 ;
drivers/gpu/drm/tegra/output.c +11 -11
@@ -9,7 +9,7 @@#include <linux/of_gpio.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> #include "drm.h" static int tegra_connector_get_modes (struct drm_connector *connector)
@@ -18,8 +18,8 @@ static int tegra_connector_get_modes(struct drm_connector *connector)struct edid *edid =NULL ;int err =0 ; -if (output->panel) { - err = output->panel->funcs->get_modes (output->panel); +if (output->block) { + err = output->block->panel_funcs->get_modes (output->block);if (err >0 )return err; }
@@ -79,7 +79,7 @@ tegra_connector_detect(struct drm_connector *connector, bool force)else status = connector_status_connected; }else { -if (!output->panel) +if (!output->block) status = connector_status_disconnected;else status = connector_status_connected;
@@ -128,14 +128,14 @@ static const struct drm_encoder_funcs encoder_funcs = {static void tegra_encoder_dpms (struct drm_encoder *encoder,int mode) {struct tegra_output *output =encoder_to_output (encoder); -struct drm_panel *panel = output->panel; +struct drm_hw_block *block = output->block;if (mode !=DRM_MODE_DPMS_ON ) { -drm_panel_disable (panel); +drm_hw_block_disable (block);tegra_output_disable (output); }else {tegra_output_enable (output); -drm_panel_enable (panel); +drm_hw_block_enable (block); } }
@@ -195,8 +195,8 @@ int tegra_output_probe(struct tegra_output *output) panel =of_parse_phandle (output->of_node,"nvidia,panel" ,0 );if (panel) { - output->panel =of_drm_find_panel (panel); -if (!output->panel) + output->block =of_drm_find_hw_block (panel); +if (!output->block)return -EPROBE_DEFER ;of_node_put (panel);
@@ -300,8 +300,8 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)drm_connector_helper_add (&output->connector, &connector_helper_funcs); output->connector.dpms =DRM_MODE_DPMS_OFF ; -if (output->panel) -drm_panel_attach (output->panel, &output->connector); +if (output->block) +drm_hw_block_attach (output->block, &output->connector);drm_encoder_init (drm, &output->encoder, &encoder_funcs, encoder);drm_encoder_helper_add (&output->encoder, &encoder_helper_funcs);
include/drm/drm_hw_block.h new file +107 -0
107 lines not on this page · raw message
include/drm/drm_panel.h deleted +0 -82
82 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Inki Dae
maintainerRFC PATCH v2 1/1 drm: improve various bridge devices support
This patch integrates existing drm_panel and drm_bridge frameworks to one integrated framework, drm_hw_block.
For this, I had already sent a email to make a discussion[1] about how we could support all bridges, one bridge between crtc and encoder, and another bridge between encoder and panel.
Now existing drm_panel could be used only for real panel, and drm_bridge only for lvds bridge devices between encoder and panel. However, some embedded SoC have bridge devices of other type between crtc and encoder, i.e. Image Enhancer chip.
So the existing encoder driver couldn't control such bridge commonly using existing drm_bridge because only drm_encoder has drm_bridge.
Below shows how encoder driver could control bridge device using existing drm_bridge.
display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel
| /|\ /|\
|---------------| |
controlled by drm_bridge |
| |
|---------------------------| controlled by drm_panel
In the other hands, drm_panel has no any dependency of drm_encoder, and its infrastructure could be used by crtc driver with a little change. So this integrated framework basically uses existing infrastructure of drm_panel, and just adds drm_lvds structure to it for backward compatibility.
And then, we could add a new bridge type, i.e. drm_enhancer in the near future. So this patch is just ready for that.
As a result, if we add drm_enhancer, crtc driver could control a bridge device between crtc and encoder like below.
display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel
| /|\ | /|\ /|\
|--------------------| |---------------| |
controlled by drm_enhancer controlled by drm_lvds |
| |
|--------------------------| controlled by drm_panel
Changelog v2:
- Call enable and disable callback according to bridge type.
- Correct module description.
[1] http://www.spinics.net/lists/dri-devel/msg55555.html
--- drivers/gpu/drm/Kconfig | 4 ++ drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_hw_block.c | 104 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 100 -------------------------- drivers/gpu/drm/exynos/Kconfig | 1 + drivers/gpu/drm/panel/Kconfig | 1 + drivers/gpu/drm/panel/panel-simple.c | 37 +++++----- drivers/gpu/drm/tegra/drm.h | 2 +- drivers/gpu/drm/tegra/dsi.c | 10 +-- drivers/gpu/drm/tegra/output.c | 22 +++--- include/drm/drm_hw_block.h | 127 ++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 82 ---------------------- 12 files changed, 274 insertions(+), 218 deletions(-) create mode 100644 drivers/gpu/drm/drm_hw_block.c delete mode 100644 drivers/gpu/drm/drm_panel.c create mode 100644 include/drm/drm_hw_block.h delete mode 100644 include/drm/drm_panel.h
drivers/gpu/drm/Kconfig +4 -0
@@ -24,6 +24,10 @@ config DRM_MIPI_DSI bool depends on DRM +config DRM_HW_BLOCK + bool + depends on DRM + config DRM_USB tristate depends on DRM
drivers/gpu/drm/Makefile +1 -1
@@ -18,7 +18,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ 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_HW_BLOCK) += drm_hw_block.o drm-usb-y := drm_usb.o
drivers/gpu/drm/drm_hw_block.c new file +104 -0
104 lines not on this page · raw message
drivers/gpu/drm/drm_panel.c deleted +0 -100
100 lines not on this page · raw message
drivers/gpu/drm/exynos/Kconfig +1 -0
@@ -8,6 +8,7 @@ config DRM_EXYNOS select FB_CFB_IMAGEBLIT select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE select VIDEOMODE_HELPERS + select DRM_PANEL help Choose this option if you have a Samsung SoC EXYNOS chipset. If M is selected the module will be called exynosdrm.
drivers/gpu/drm/panel/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_PANEL bool depends on DRM + select DRM_HW_BLOCK help Panel registration and lookup framework.
drivers/gpu/drm/panel/panel-simple.c +19 -18
@@ -32,7 +32,7 @@#include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> struct panel_desc {const struct drm_display_mode *modes;
@@ -48,7 +48,7 @@ struct panel_desc {#define GPIO_ACTIVE_LOW (1 << 0)struct panel_simple { -struct drm_panel base; +struct drm_hw_block base;bool enabled;const struct panel_desc *desc;
@@ -61,9 +61,9 @@ struct panel_simple {int enable_gpio; }; -static inline struct panel_simple *to_panel_simple (struct drm_panel *panel) +static inline struct panel_simple *to_panel_simple (struct drm_hw_block *block) { - return container_of(panel, struct panel_simple, base); + return container_of(block, struct panel_simple, base); }static int panel_simple_get_fixed_modes (struct panel_simple *panel)
@@ -98,9 +98,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel)return num; } -static int panel_simple_disable (struct drm_panel *panel) +static int panel_simple_disable (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);if (!p->enabled)return 0 ;
@@ -123,9 +123,9 @@ static int panel_simple_disable(struct drm_panel *panel)return 0 ; } -static int panel_simple_enable (struct drm_panel *panel) +static int panel_simple_enable (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);int err;if (p->enabled)
@@ -133,7 +133,7 @@ static int panel_simple_enable(struct drm_panel *panel) err =regulator_enable (p->supply);if (err <0 ) { -dev_err (panel->dev,"failed to enable supply: %d\n" , err); +dev_err (block->dev,"failed to enable supply: %d\n" , err);return err; }
@@ -154,16 +154,16 @@ static int panel_simple_enable(struct drm_panel *panel)return 0 ; } -static int panel_simple_get_modes (struct drm_panel *panel) +static int panel_simple_get_modes (struct drm_hw_block *block) { -struct panel_simple *p =to_panel_simple (panel); +struct panel_simple *p =to_panel_simple (block);int num =0 ;/* probe EDID if a DDC bus is available */ if (p->ddc) { -struct edid *edid =drm_get_edid (panel->connector, p->ddc); +struct edid *edid =drm_get_edid (block->connector, p->ddc);if (edid) { - num +=drm_add_edid_modes (panel->connector, edid); + num +=drm_add_edid_modes (block->connector, edid);kfree (edid); } }
@@ -246,11 +246,12 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) } } -drm_panel_init (&panel->base); + panel->base.type =DRM_HW_BLOCK_PANEL ; +drm_hw_block_init (&panel->base); panel->base.dev = dev; - panel->base.funcs = &panel_simple_funcs; + panel->base.panel_funcs = &panel_simple_funcs; - err =drm_panel_add (&panel->base); + err =drm_hw_block_add (&panel->base);if (err <0 ) goto free_ddc;
@@ -275,8 +276,8 @@ static int panel_simple_remove(struct device *dev) {struct panel_simple *panel =dev_get_drvdata (dev); -drm_panel_detach (&panel->base); -drm_panel_remove (&panel->base); +drm_hw_block_detach (&panel->base); +drm_hw_block_remove (&panel->base);panel_simple_disable (&panel->base);
drivers/gpu/drm/tegra/drm.h +1 -1
@@ -194,7 +194,7 @@ struct tegra_output {const struct tegra_output_ops *ops;enum tegra_output_type type; -struct drm_panel *panel; +struct drm_hw_block *block;struct i2c_adapter *ddc;const struct edid *edid;unsigned int hpd_irq;
drivers/gpu/drm/tegra/dsi.c +5 -5
@@ -29,7 +29,7 @@#include <linux/reset.h> #include <drm/drm_mipi_dsi.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> #include <video/mipi_display.h>
@@ -792,8 +792,8 @@ static int tegra_dsi_host_attach(struct mipi_dsi_host *host, dsi->format = device->format; dsi->lanes = device->lanes; - output->panel =of_drm_find_panel (device->dev.of_node); -if (output->panel) { + output->block =of_drm_find_hw_block (device->dev.of_node); +if (output->block) {if (output->connector.dev)drm_helper_hpd_irq_event (output->connector.dev); }
@@ -807,11 +807,11 @@ static int tegra_dsi_host_detach(struct mipi_dsi_host *host,struct tegra_dsi *dsi =host_to_tegra (host);struct tegra_output *output = &dsi->output; -if (output->panel && &device->dev == output->panel->dev) { +if (output->block && &device->dev == output->block->dev) {if (output->connector.dev)drm_helper_hpd_irq_event (output->connector.dev); - output->panel =NULL ; + output->block =NULL ; }return 0 ;
drivers/gpu/drm/tegra/output.c +11 -11
@@ -9,7 +9,7 @@#include <linux/of_gpio.h> -#include <drm/drm_panel.h> +#include <drm/drm_hw_block.h> #include "drm.h" static int tegra_connector_get_modes (struct drm_connector *connector)
@@ -18,8 +18,8 @@ static int tegra_connector_get_modes(struct drm_connector *connector)struct edid *edid =NULL ;int err =0 ; -if (output->panel) { - err = output->panel->funcs->get_modes (output->panel); +if (output->block) { + err = output->block->panel_funcs->get_modes (output->block);if (err >0 )return err; }
@@ -79,7 +79,7 @@ tegra_connector_detect(struct drm_connector *connector, bool force)else status = connector_status_connected; }else { -if (!output->panel) +if (!output->block) status = connector_status_disconnected;else status = connector_status_connected;
@@ -128,14 +128,14 @@ static const struct drm_encoder_funcs encoder_funcs = {static void tegra_encoder_dpms (struct drm_encoder *encoder,int mode) {struct tegra_output *output =encoder_to_output (encoder); -struct drm_panel *panel = output->panel; +struct drm_hw_block *block = output->block;if (mode !=DRM_MODE_DPMS_ON ) { -drm_panel_disable (panel); +drm_hw_block_disable (block);tegra_output_disable (output); }else {tegra_output_enable (output); -drm_panel_enable (panel); +drm_hw_block_enable (block); } }
@@ -195,8 +195,8 @@ int tegra_output_probe(struct tegra_output *output) panel =of_parse_phandle (output->of_node,"nvidia,panel" ,0 );if (panel) { - output->panel =of_drm_find_panel (panel); -if (!output->panel) + output->block =of_drm_find_hw_block (panel); +if (!output->block)return -EPROBE_DEFER ;of_node_put (panel);
@@ -300,8 +300,8 @@ int tegra_output_init(struct drm_device *drm, struct tegra_output *output)drm_connector_helper_add (&output->connector, &connector_helper_funcs); output->connector.dpms =DRM_MODE_DPMS_OFF ; -if (output->panel) -drm_panel_attach (output->panel, &output->connector); +if (output->block) +drm_hw_block_attach (output->block, &output->connector);drm_encoder_init (drm, &output->encoder, &encoder_funcs, encoder);drm_encoder_helper_add (&output->encoder, &encoder_helper_funcs);
include/drm/drm_hw_block.h new file +127 -0
127 lines not on this page · raw message
include/drm/drm_panel.h deleted +0 -82
82 lines not on this page · raw message
Signature · 1 line
1.7.9.5