Commit cf67cc9a authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Inki Dae

drm/exynos: remove struct exynos_drm_display

This struct was just representing encoder information, it was a member of
struct exynos_drm_encoder, so any code trying to access encoder data would
have to go through the encoder struct, get the display struct and then get
the data it want.

During this patchset we also realized that the only data
exynos_drm_encoder needs to store is the drm_encoder parent and the
exynos_drm_encoder_ops.
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent d1fa72d0
...@@ -61,7 +61,7 @@ struct decon_context { ...@@ -61,7 +61,7 @@ struct decon_context {
atomic_t wait_vsync_event; atomic_t wait_vsync_event;
struct exynos_drm_panel_info panel; struct exynos_drm_panel_info panel;
struct exynos_drm_display *display; struct exynos_drm_encoder *encoder;
}; };
static const struct of_device_id decon_driver_dt_match[] = { static const struct of_device_id decon_driver_dt_match[] = {
...@@ -681,8 +681,9 @@ static int decon_bind(struct device *dev, struct device *master, void *data) ...@@ -681,8 +681,9 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
return PTR_ERR(ctx->crtc); return PTR_ERR(ctx->crtc);
} }
if (ctx->display) if (ctx->encoder)
exynos_drm_create_enc_conn(drm_dev, ctx->display); exynos_drm_create_enc_conn(drm_dev, ctx->encoder,
EXYNOS_DISPLAY_TYPE_LCD);
return 0; return 0;
...@@ -695,8 +696,8 @@ static void decon_unbind(struct device *dev, struct device *master, ...@@ -695,8 +696,8 @@ static void decon_unbind(struct device *dev, struct device *master,
decon_disable(ctx->crtc); decon_disable(ctx->crtc);
if (ctx->display) if (ctx->encoder)
exynos_dpi_remove(ctx->display); exynos_dpi_remove(ctx->encoder);
decon_ctx_remove(ctx); decon_ctx_remove(ctx);
} }
...@@ -781,9 +782,9 @@ static int decon_probe(struct platform_device *pdev) ...@@ -781,9 +782,9 @@ static int decon_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ctx); platform_set_drvdata(pdev, ctx);
ctx->display = exynos_dpi_probe(dev); ctx->encoder = exynos_dpi_probe(dev);
if (IS_ERR(ctx->display)) { if (IS_ERR(ctx->encoder)) {
ret = PTR_ERR(ctx->display); ret = PTR_ERR(ctx->encoder);
goto err_iounmap; goto err_iounmap;
} }
......
...@@ -38,13 +38,13 @@ ...@@ -38,13 +38,13 @@
static inline struct exynos_drm_crtc *dp_to_crtc(struct exynos_dp_device *dp) static inline struct exynos_drm_crtc *dp_to_crtc(struct exynos_dp_device *dp)
{ {
return to_exynos_crtc(dp->encoder->crtc); return to_exynos_crtc(dp->encoder.base.crtc);
} }
static inline struct exynos_dp_device * static inline struct exynos_dp_device *encoder_to_dp(
display_to_dp(struct exynos_drm_display *d) struct exynos_drm_encoder *e)
{ {
return container_of(d, struct exynos_dp_device, display); return container_of(e, struct exynos_dp_device, encoder);
} }
struct bridge_init { struct bridge_init {
...@@ -891,9 +891,9 @@ static void exynos_dp_hotplug(struct work_struct *work) ...@@ -891,9 +891,9 @@ static void exynos_dp_hotplug(struct work_struct *work)
drm_helper_hpd_irq_event(dp->drm_dev); drm_helper_hpd_irq_event(dp->drm_dev);
} }
static void exynos_dp_commit(struct exynos_drm_display *display) static void exynos_dp_commit(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dp_device *dp = display_to_dp(display); struct exynos_dp_device *dp = encoder_to_dp(encoder);
int ret; int ret;
/* Keep the panel disabled while we configure video */ /* Keep the panel disabled while we configure video */
...@@ -994,7 +994,7 @@ static struct drm_encoder *exynos_dp_best_encoder( ...@@ -994,7 +994,7 @@ static struct drm_encoder *exynos_dp_best_encoder(
{ {
struct exynos_dp_device *dp = ctx_from_connector(connector); struct exynos_dp_device *dp = ctx_from_connector(connector);
return dp->encoder; return &dp->encoder.base;
} }
static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = { static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
...@@ -1019,15 +1019,13 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp, ...@@ -1019,15 +1019,13 @@ static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
return 0; return 0;
} }
static int exynos_dp_create_connector(struct exynos_drm_display *display, static int exynos_dp_create_connector(struct exynos_drm_encoder *exynos_encoder)
struct drm_encoder *encoder)
{ {
struct exynos_dp_device *dp = display_to_dp(display); struct exynos_dp_device *dp = encoder_to_dp(exynos_encoder);
struct drm_encoder *encoder = &exynos_encoder->base;
struct drm_connector *connector = &dp->connector; struct drm_connector *connector = &dp->connector;
int ret; int ret;
dp->encoder = encoder;
/* Pre-empt DP connector creation if there's a bridge */ /* Pre-empt DP connector creation if there's a bridge */
if (dp->bridge) { if (dp->bridge) {
ret = exynos_drm_attach_lcd_bridge(dp, encoder); ret = exynos_drm_attach_lcd_bridge(dp, encoder);
...@@ -1054,9 +1052,9 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display, ...@@ -1054,9 +1052,9 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
return ret; return ret;
} }
static void exynos_dp_enable(struct exynos_drm_display *display) static void exynos_dp_enable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dp_device *dp = display_to_dp(display); struct exynos_dp_device *dp = encoder_to_dp(encoder);
struct exynos_drm_crtc *crtc = dp_to_crtc(dp); struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
if (dp->dpms_mode == DRM_MODE_DPMS_ON) if (dp->dpms_mode == DRM_MODE_DPMS_ON)
...@@ -1076,14 +1074,14 @@ static void exynos_dp_enable(struct exynos_drm_display *display) ...@@ -1076,14 +1074,14 @@ static void exynos_dp_enable(struct exynos_drm_display *display)
phy_power_on(dp->phy); phy_power_on(dp->phy);
exynos_dp_init_dp(dp); exynos_dp_init_dp(dp);
enable_irq(dp->irq); enable_irq(dp->irq);
exynos_dp_commit(&dp->display); exynos_dp_commit(&dp->encoder);
dp->dpms_mode = DRM_MODE_DPMS_ON; dp->dpms_mode = DRM_MODE_DPMS_ON;
} }
static void exynos_dp_disable(struct exynos_drm_display *display) static void exynos_dp_disable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dp_device *dp = display_to_dp(display); struct exynos_dp_device *dp = encoder_to_dp(encoder);
struct exynos_drm_crtc *crtc = dp_to_crtc(dp); struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
if (dp->dpms_mode != DRM_MODE_DPMS_ON) if (dp->dpms_mode != DRM_MODE_DPMS_ON)
...@@ -1112,7 +1110,7 @@ static void exynos_dp_disable(struct exynos_drm_display *display) ...@@ -1112,7 +1110,7 @@ static void exynos_dp_disable(struct exynos_drm_display *display)
dp->dpms_mode = DRM_MODE_DPMS_OFF; dp->dpms_mode = DRM_MODE_DPMS_OFF;
} }
static struct exynos_drm_display_ops exynos_dp_display_ops = { static struct exynos_drm_encoder_ops exynos_dp_encoder_ops = {
.create_connector = exynos_dp_create_connector, .create_connector = exynos_dp_create_connector,
.enable = exynos_dp_enable, .enable = exynos_dp_enable,
.disable = exynos_dp_disable, .disable = exynos_dp_disable,
...@@ -1287,7 +1285,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1287,7 +1285,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->drm_dev = drm_dev; dp->drm_dev = drm_dev;
return exynos_drm_create_enc_conn(drm_dev, &dp->display); return exynos_drm_create_enc_conn(drm_dev, &dp->encoder,
EXYNOS_DISPLAY_TYPE_LCD);
} }
static void exynos_dp_unbind(struct device *dev, struct device *master, static void exynos_dp_unbind(struct device *dev, struct device *master,
...@@ -1295,7 +1294,7 @@ static void exynos_dp_unbind(struct device *dev, struct device *master, ...@@ -1295,7 +1294,7 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
{ {
struct exynos_dp_device *dp = dev_get_drvdata(dev); struct exynos_dp_device *dp = dev_get_drvdata(dev);
exynos_dp_disable(&dp->display); exynos_dp_disable(&dp->encoder);
} }
static const struct component_ops exynos_dp_ops = { static const struct component_ops exynos_dp_ops = {
...@@ -1314,8 +1313,7 @@ static int exynos_dp_probe(struct platform_device *pdev) ...@@ -1314,8 +1313,7 @@ static int exynos_dp_probe(struct platform_device *pdev)
if (!dp) if (!dp)
return -ENOMEM; return -ENOMEM;
dp->display.type = EXYNOS_DISPLAY_TYPE_LCD; dp->encoder.ops = &exynos_dp_encoder_ops;
dp->display.ops = &exynos_dp_display_ops;
platform_set_drvdata(pdev, dp); platform_set_drvdata(pdev, dp);
panel_node = of_parse_phandle(dev->of_node, "panel", 0); panel_node = of_parse_phandle(dev->of_node, "panel", 0);
...@@ -1353,7 +1351,7 @@ static int exynos_dp_suspend(struct device *dev) ...@@ -1353,7 +1351,7 @@ static int exynos_dp_suspend(struct device *dev)
{ {
struct exynos_dp_device *dp = dev_get_drvdata(dev); struct exynos_dp_device *dp = dev_get_drvdata(dev);
exynos_dp_disable(&dp->display); exynos_dp_disable(&dp->encoder);
return 0; return 0;
} }
...@@ -1361,7 +1359,7 @@ static int exynos_dp_resume(struct device *dev) ...@@ -1361,7 +1359,7 @@ static int exynos_dp_resume(struct device *dev)
{ {
struct exynos_dp_device *dp = dev_get_drvdata(dev); struct exynos_dp_device *dp = dev_get_drvdata(dev);
exynos_dp_enable(&dp->display); exynos_dp_enable(&dp->encoder);
return 0; return 0;
} }
#endif #endif
......
...@@ -147,11 +147,10 @@ struct link_train { ...@@ -147,11 +147,10 @@ struct link_train {
}; };
struct exynos_dp_device { struct exynos_dp_device {
struct exynos_drm_display display; struct exynos_drm_encoder encoder;
struct device *dev; struct device *dev;
struct drm_device *drm_dev; struct drm_device *drm_dev;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_panel *panel; struct drm_panel *panel;
struct drm_bridge *bridge; struct drm_bridge *bridge;
struct clk *clock; struct clk *clock;
......
...@@ -21,38 +21,33 @@ ...@@ -21,38 +21,33 @@
static LIST_HEAD(exynos_drm_subdrv_list); static LIST_HEAD(exynos_drm_subdrv_list);
int exynos_drm_create_enc_conn(struct drm_device *dev, int exynos_drm_create_enc_conn(struct drm_device *dev,
struct exynos_drm_display *display) struct exynos_drm_encoder *exynos_encoder,
enum exynos_drm_output_type type)
{ {
struct drm_encoder *encoder;
int ret; int ret;
unsigned long possible_crtcs = 0; unsigned long possible_crtcs = 0;
ret = exynos_drm_crtc_get_pipe_from_type(dev, display->type); ret = exynos_drm_crtc_get_pipe_from_type(dev, type);
if (ret < 0) if (ret < 0)
return ret; return ret;
possible_crtcs |= 1 << ret; possible_crtcs |= 1 << ret;
/* create and initialize a encoder for this sub driver. */ /* create and initialize a encoder for this sub driver. */
encoder = exynos_drm_encoder_create(dev, display, possible_crtcs); ret = exynos_drm_encoder_create(dev, exynos_encoder, possible_crtcs);
if (!encoder) { if (ret) {
DRM_ERROR("failed to create encoder\n"); DRM_ERROR("failed to create encoder\n");
return -EFAULT; return ret;
} }
display->encoder = encoder; ret = exynos_encoder->ops->create_connector(exynos_encoder);
ret = display->ops->create_connector(display, encoder);
if (ret) { if (ret) {
DRM_ERROR("failed to create connector ret = %d\n", ret); DRM_ERROR("failed to create connector ret = %d\n", ret);
goto err_destroy_encoder; drm_encoder_cleanup(&exynos_encoder->base);
return ret;
} }
return 0; return 0;
err_destroy_encoder:
encoder->funcs->destroy(encoder);
return ret;
} }
int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv) int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv)
......
...@@ -237,7 +237,7 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb) ...@@ -237,7 +237,7 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb)
} }
int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
unsigned int out_type) enum exynos_drm_output_type out_type)
{ {
struct drm_crtc *crtc; struct drm_crtc *crtc;
......
...@@ -30,7 +30,7 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb); ...@@ -30,7 +30,7 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb);
/* This function gets pipe value to crtc device matched with out_type. */ /* This function gets pipe value to crtc device matched with out_type. */
int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
unsigned int out_type); enum exynos_drm_output_type out_type);
/* /*
* This function calls the crtc device(manager)'s te_handler() callback * This function calls the crtc device(manager)'s te_handler() callback
......
...@@ -23,22 +23,21 @@ ...@@ -23,22 +23,21 @@
#include "exynos_drm_drv.h" #include "exynos_drm_drv.h"
struct exynos_dpi { struct exynos_dpi {
struct exynos_drm_display display; struct exynos_drm_encoder encoder;
struct device *dev; struct device *dev;
struct device_node *panel_node; struct device_node *panel_node;
struct drm_panel *panel; struct drm_panel *panel;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder *encoder;
struct videomode *vm; struct videomode *vm;
}; };
#define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector) #define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector)
static inline struct exynos_dpi *display_to_dpi(struct exynos_drm_display *d) static inline struct exynos_dpi *encoder_to_dpi(struct exynos_drm_encoder *e)
{ {
return container_of(d, struct exynos_dpi, display); return container_of(e, struct exynos_dpi, encoder);
} }
static enum drm_connector_status static enum drm_connector_status
...@@ -98,7 +97,7 @@ exynos_dpi_best_encoder(struct drm_connector *connector) ...@@ -98,7 +97,7 @@ exynos_dpi_best_encoder(struct drm_connector *connector)
{ {
struct exynos_dpi *ctx = connector_to_dpi(connector); struct exynos_dpi *ctx = connector_to_dpi(connector);
return ctx->encoder; return &ctx->encoder.base;
} }
static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = { static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = {
...@@ -106,15 +105,14 @@ static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = { ...@@ -106,15 +105,14 @@ static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = {
.best_encoder = exynos_dpi_best_encoder, .best_encoder = exynos_dpi_best_encoder,
}; };
static int exynos_dpi_create_connector(struct exynos_drm_display *display, static int exynos_dpi_create_connector(
struct drm_encoder *encoder) struct exynos_drm_encoder *exynos_encoder)
{ {
struct exynos_dpi *ctx = display_to_dpi(display); struct exynos_dpi *ctx = encoder_to_dpi(exynos_encoder);
struct drm_encoder *encoder = &exynos_encoder->base;
struct drm_connector *connector = &ctx->connector; struct drm_connector *connector = &ctx->connector;
int ret; int ret;
ctx->encoder = encoder;
connector->polled = DRM_CONNECTOR_POLL_HPD; connector->polled = DRM_CONNECTOR_POLL_HPD;
ret = drm_connector_init(encoder->dev, connector, ret = drm_connector_init(encoder->dev, connector,
...@@ -132,9 +130,9 @@ static int exynos_dpi_create_connector(struct exynos_drm_display *display, ...@@ -132,9 +130,9 @@ static int exynos_dpi_create_connector(struct exynos_drm_display *display,
return 0; return 0;
} }
static void exynos_dpi_enable(struct exynos_drm_display *display) static void exynos_dpi_enable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dpi *ctx = display_to_dpi(display); struct exynos_dpi *ctx = encoder_to_dpi(encoder);
if (ctx->panel) { if (ctx->panel) {
drm_panel_prepare(ctx->panel); drm_panel_prepare(ctx->panel);
...@@ -142,9 +140,9 @@ static void exynos_dpi_enable(struct exynos_drm_display *display) ...@@ -142,9 +140,9 @@ static void exynos_dpi_enable(struct exynos_drm_display *display)
} }
} }
static void exynos_dpi_disable(struct exynos_drm_display *display) static void exynos_dpi_disable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dpi *ctx = display_to_dpi(display); struct exynos_dpi *ctx = encoder_to_dpi(encoder);
if (ctx->panel) { if (ctx->panel) {
drm_panel_disable(ctx->panel); drm_panel_disable(ctx->panel);
...@@ -152,7 +150,7 @@ static void exynos_dpi_disable(struct exynos_drm_display *display) ...@@ -152,7 +150,7 @@ static void exynos_dpi_disable(struct exynos_drm_display *display)
} }
} }
static struct exynos_drm_display_ops exynos_dpi_display_ops = { static struct exynos_drm_encoder_ops exynos_dpi_encoder_ops = {
.create_connector = exynos_dpi_create_connector, .create_connector = exynos_dpi_create_connector,
.enable = exynos_dpi_enable, .enable = exynos_dpi_enable,
.disable = exynos_dpi_disable, .disable = exynos_dpi_disable,
...@@ -282,7 +280,7 @@ static int exynos_dpi_parse_dt(struct exynos_dpi *ctx) ...@@ -282,7 +280,7 @@ static int exynos_dpi_parse_dt(struct exynos_dpi *ctx)
return 0; return 0;
} }
struct exynos_drm_display *exynos_dpi_probe(struct device *dev) struct exynos_drm_encoder *exynos_dpi_probe(struct device *dev)
{ {
struct exynos_dpi *ctx; struct exynos_dpi *ctx;
int ret; int ret;
...@@ -291,8 +289,7 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev) ...@@ -291,8 +289,7 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
if (!ctx) if (!ctx)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ctx->display.type = EXYNOS_DISPLAY_TYPE_LCD; ctx->encoder.ops = &exynos_dpi_encoder_ops;
ctx->display.ops = &exynos_dpi_display_ops;
ctx->dev = dev; ctx->dev = dev;
ret = exynos_dpi_parse_dt(ctx); ret = exynos_dpi_parse_dt(ctx);
...@@ -307,14 +304,14 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev) ...@@ -307,14 +304,14 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
return ERR_PTR(-EPROBE_DEFER); return ERR_PTR(-EPROBE_DEFER);
} }
return &ctx->display; return &ctx->encoder;
} }
int exynos_dpi_remove(struct exynos_drm_display *display) int exynos_dpi_remove(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dpi *ctx = display_to_dpi(display); struct exynos_dpi *ctx = encoder_to_dpi(encoder);
exynos_dpi_disable(&ctx->display); exynos_dpi_disable(&ctx->encoder);
if (ctx->panel) if (ctx->panel)
drm_panel_detach(ctx->panel); drm_panel_detach(ctx->panel);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define MAX_PLANE 5 #define MAX_PLANE 5
#define MAX_FB_BUFFER 4 #define MAX_FB_BUFFER 4
#define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder, base)
#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc, base) #define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc, base)
#define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base) #define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base)
...@@ -77,7 +78,7 @@ struct exynos_drm_plane { ...@@ -77,7 +78,7 @@ struct exynos_drm_plane {
}; };
/* /*
* Exynos DRM Display Structure. * Exynos DRM Encoder Structure.
* - this structure is common to analog tv, digital tv and lcd panel. * - this structure is common to analog tv, digital tv and lcd panel.
* *
* @create_connector: initialize and register a new connector * @create_connector: initialize and register a new connector
...@@ -88,37 +89,30 @@ struct exynos_drm_plane { ...@@ -88,37 +89,30 @@ struct exynos_drm_plane {
* @disable: display device off. * @disable: display device off.
* @commit: apply changes to hw * @commit: apply changes to hw
*/ */
struct exynos_drm_display; struct exynos_drm_encoder;
struct exynos_drm_display_ops { struct exynos_drm_encoder_ops {
int (*create_connector)(struct exynos_drm_display *display, int (*create_connector)(struct exynos_drm_encoder *encoder);
struct drm_encoder *encoder); void (*mode_fixup)(struct exynos_drm_encoder *encoder,
void (*mode_fixup)(struct exynos_drm_display *display,
struct drm_connector *connector, struct drm_connector *connector,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode); struct drm_display_mode *adjusted_mode);
void (*mode_set)(struct exynos_drm_display *display, void (*mode_set)(struct exynos_drm_encoder *encoder,
struct drm_display_mode *mode); struct drm_display_mode *mode);
void (*enable)(struct exynos_drm_display *display); void (*enable)(struct exynos_drm_encoder *encoder);
void (*disable)(struct exynos_drm_display *display); void (*disable)(struct exynos_drm_encoder *encoder);
void (*commit)(struct exynos_drm_display *display); void (*commit)(struct exynos_drm_encoder *encoder);
}; };
/* /*
* Exynos drm display structure, maps 1:1 with an encoder/connector * exynos specific encoder structure.
* *
* @list: the list entry for this manager * @drm_encoder: encoder object.
* @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI. * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI.
* @encoder: encoder object this display maps to
* @connector: connector object this display maps to
* @ops: pointer to callbacks for exynos drm specific functionality * @ops: pointer to callbacks for exynos drm specific functionality
* @ctx: A pointer to the display's implementation specific context
*/ */
struct exynos_drm_display { struct exynos_drm_encoder {
struct list_head list; struct drm_encoder base;
enum exynos_drm_output_type type; struct exynos_drm_encoder_ops *ops;
struct drm_encoder *encoder;
struct drm_connector *connector;
struct exynos_drm_display_ops *ops;
}; };
/* /*
...@@ -265,12 +259,12 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file); ...@@ -265,12 +259,12 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file); void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
#ifdef CONFIG_DRM_EXYNOS_DPI #ifdef CONFIG_DRM_EXYNOS_DPI
struct exynos_drm_display * exynos_dpi_probe(struct device *dev); struct exynos_drm_encoder *exynos_dpi_probe(struct device *dev);
int exynos_dpi_remove(struct exynos_drm_display *display); int exynos_dpi_remove(struct exynos_drm_encoder *encoder);
#else #else
static inline struct exynos_drm_display * static inline struct exynos_drm_encoder *
exynos_dpi_probe(struct device *dev) { return NULL; } exynos_dpi_probe(struct device *dev) { return NULL; }
static inline int exynos_dpi_remove(struct exynos_drm_display *display) static inline int exynos_dpi_remove(struct exynos_drm_encoder *encoder)
{ {
return 0; return 0;
} }
...@@ -278,7 +272,8 @@ static inline int exynos_dpi_remove(struct exynos_drm_display *display) ...@@ -278,7 +272,8 @@ static inline int exynos_dpi_remove(struct exynos_drm_display *display)
/* This function creates a encoder and a connector, and initializes them. */ /* This function creates a encoder and a connector, and initializes them. */
int exynos_drm_create_enc_conn(struct drm_device *dev, int exynos_drm_create_enc_conn(struct drm_device *dev,
struct exynos_drm_display *display); struct exynos_drm_encoder *encoder,
enum exynos_drm_output_type type);
extern struct platform_driver fimd_driver; extern struct platform_driver fimd_driver;
extern struct platform_driver exynos5433_decon_driver; extern struct platform_driver exynos5433_decon_driver;
......
...@@ -259,7 +259,7 @@ struct exynos_dsi_driver_data { ...@@ -259,7 +259,7 @@ struct exynos_dsi_driver_data {
}; };
struct exynos_dsi { struct exynos_dsi {
struct exynos_drm_display display; struct exynos_drm_encoder encoder;
struct mipi_dsi_host dsi_host; struct mipi_dsi_host dsi_host;
struct drm_connector connector; struct drm_connector connector;
struct device_node *panel_node; struct device_node *panel_node;
...@@ -295,9 +295,9 @@ struct exynos_dsi { ...@@ -295,9 +295,9 @@ struct exynos_dsi {
#define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) #define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host)
#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector) #define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector)
static inline struct exynos_dsi *display_to_dsi(struct exynos_drm_display *d) static inline struct exynos_dsi *encoder_to_dsi(struct exynos_drm_encoder *e)
{ {
return container_of(d, struct exynos_dsi, display); return container_of(e, struct exynos_dsi, encoder);
} }
enum reg_idx { enum reg_idx {
...@@ -1272,7 +1272,7 @@ static irqreturn_t exynos_dsi_irq(int irq, void *dev_id) ...@@ -1272,7 +1272,7 @@ static irqreturn_t exynos_dsi_irq(int irq, void *dev_id)
static irqreturn_t exynos_dsi_te_irq_handler(int irq, void *dev_id) static irqreturn_t exynos_dsi_te_irq_handler(int irq, void *dev_id)
{ {
struct exynos_dsi *dsi = (struct exynos_dsi *)dev_id; struct exynos_dsi *dsi = (struct exynos_dsi *)dev_id;
struct drm_encoder *encoder = dsi->display.encoder; struct drm_encoder *encoder = &dsi->encoder.base;
if (dsi->state & DSIM_STATE_VIDOUT_AVAILABLE) if (dsi->state & DSIM_STATE_VIDOUT_AVAILABLE)
exynos_drm_crtc_te_handler(encoder->crtc); exynos_drm_crtc_te_handler(encoder->crtc);
...@@ -1518,9 +1518,9 @@ static void exynos_dsi_poweroff(struct exynos_dsi *dsi) ...@@ -1518,9 +1518,9 @@ static void exynos_dsi_poweroff(struct exynos_dsi *dsi)
dev_err(dsi->dev, "cannot disable regulators %d\n", ret); dev_err(dsi->dev, "cannot disable regulators %d\n", ret);
} }
static void exynos_dsi_enable(struct exynos_drm_display *display) static void exynos_dsi_enable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(encoder);
int ret; int ret;
if (dsi->state & DSIM_STATE_ENABLED) if (dsi->state & DSIM_STATE_ENABLED)
...@@ -1554,9 +1554,9 @@ static void exynos_dsi_enable(struct exynos_drm_display *display) ...@@ -1554,9 +1554,9 @@ static void exynos_dsi_enable(struct exynos_drm_display *display)
dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE;
} }
static void exynos_dsi_disable(struct exynos_drm_display *display) static void exynos_dsi_disable(struct exynos_drm_encoder *encoder)
{ {
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(encoder);
if (!(dsi->state & DSIM_STATE_ENABLED)) if (!(dsi->state & DSIM_STATE_ENABLED))
return; return;
...@@ -1582,10 +1582,10 @@ exynos_dsi_detect(struct drm_connector *connector, bool force) ...@@ -1582,10 +1582,10 @@ exynos_dsi_detect(struct drm_connector *connector, bool force)
if (dsi->panel) if (dsi->panel)
drm_panel_attach(dsi->panel, &dsi->connector); drm_panel_attach(dsi->panel, &dsi->connector);
} else if (!dsi->panel_node) { } else if (!dsi->panel_node) {
struct exynos_drm_display *display; struct exynos_drm_encoder *encoder;
display = platform_get_drvdata(to_platform_device(dsi->dev)); encoder = platform_get_drvdata(to_platform_device(dsi->dev));
exynos_dsi_disable(display); exynos_dsi_disable(encoder);
drm_panel_detach(dsi->panel); drm_panel_detach(dsi->panel);
dsi->panel = NULL; dsi->panel = NULL;
} }
...@@ -1628,7 +1628,7 @@ exynos_dsi_best_encoder(struct drm_connector *connector) ...@@ -1628,7 +1628,7 @@ exynos_dsi_best_encoder(struct drm_connector *connector)
{ {
struct exynos_dsi *dsi = connector_to_dsi(connector); struct exynos_dsi *dsi = connector_to_dsi(connector);
return dsi->display.encoder; return &dsi->encoder.base;
} }
static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = { static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = {
...@@ -1636,10 +1636,11 @@ static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = { ...@@ -1636,10 +1636,11 @@ static struct drm_connector_helper_funcs exynos_dsi_connector_helper_funcs = {
.best_encoder = exynos_dsi_best_encoder, .best_encoder = exynos_dsi_best_encoder,
}; };
static int exynos_dsi_create_connector(struct exynos_drm_display *display, static int exynos_dsi_create_connector(
struct drm_encoder *encoder) struct exynos_drm_encoder *exynos_encoder)
{ {
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(exynos_encoder);
struct drm_encoder *encoder = &exynos_encoder->base;
struct drm_connector *connector = &dsi->connector; struct drm_connector *connector = &dsi->connector;
int ret; int ret;
...@@ -1660,10 +1661,10 @@ static int exynos_dsi_create_connector(struct exynos_drm_display *display, ...@@ -1660,10 +1661,10 @@ static int exynos_dsi_create_connector(struct exynos_drm_display *display,
return 0; return 0;
} }
static void exynos_dsi_mode_set(struct exynos_drm_display *display, static void exynos_dsi_mode_set(struct exynos_drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(encoder);
struct videomode *vm = &dsi->vm; struct videomode *vm = &dsi->vm;
vm->hactive = mode->hdisplay; vm->hactive = mode->hdisplay;
...@@ -1676,7 +1677,7 @@ static void exynos_dsi_mode_set(struct exynos_drm_display *display, ...@@ -1676,7 +1677,7 @@ static void exynos_dsi_mode_set(struct exynos_drm_display *display,
vm->hsync_len = mode->hsync_end - mode->hsync_start; vm->hsync_len = mode->hsync_end - mode->hsync_start;
} }
static struct exynos_drm_display_ops exynos_dsi_display_ops = { static struct exynos_drm_encoder_ops exynos_dsi_encoder_ops = {
.create_connector = exynos_dsi_create_connector, .create_connector = exynos_dsi_create_connector,
.mode_set = exynos_dsi_mode_set, .mode_set = exynos_dsi_mode_set,
.enable = exynos_dsi_enable, .enable = exynos_dsi_enable,
...@@ -1803,22 +1804,22 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi) ...@@ -1803,22 +1804,22 @@ static int exynos_dsi_parse_dt(struct exynos_dsi *dsi)
static int exynos_dsi_bind(struct device *dev, struct device *master, static int exynos_dsi_bind(struct device *dev, struct device *master,
void *data) void *data)
{ {
struct exynos_drm_display *display = dev_get_drvdata(dev); struct exynos_drm_encoder *encoder = dev_get_drvdata(dev);
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(encoder);
struct drm_device *drm_dev = data; struct drm_device *drm_dev = data;
struct drm_bridge *bridge; struct drm_bridge *bridge;
int ret; int ret;
ret = exynos_drm_create_enc_conn(drm_dev, display); ret = exynos_drm_create_enc_conn(drm_dev, encoder,
EXYNOS_DISPLAY_TYPE_LCD);
if (ret) { if (ret) {
DRM_ERROR("Encoder create [%d] failed with %d\n", DRM_ERROR("Encoder create [%d] failed with %d\n",
display->type, ret); EXYNOS_DISPLAY_TYPE_LCD, ret);
return ret; return ret;
} }
bridge = of_drm_find_bridge(dsi->bridge_node); bridge = of_drm_find_bridge(dsi->bridge_node);
if (bridge) { if (bridge) {
display->encoder->bridge = bridge;
drm_bridge_attach(drm_dev, bridge); drm_bridge_attach(drm_dev, bridge);
} }
...@@ -1828,10 +1829,10 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, ...@@ -1828,10 +1829,10 @@ static int exynos_dsi_bind(struct device *dev, struct device *master,
static void exynos_dsi_unbind(struct device *dev, struct device *master, static void exynos_dsi_unbind(struct device *dev, struct device *master,
void *data) void *data)
{ {
struct exynos_drm_display *display = dev_get_drvdata(dev); struct exynos_drm_encoder *encoder = dev_get_drvdata(dev);
struct exynos_dsi *dsi = display_to_dsi(display); struct exynos_dsi *dsi = encoder_to_dsi(encoder);
exynos_dsi_disable(display); exynos_dsi_disable(encoder);
mipi_dsi_host_unregister(&dsi->dsi_host); mipi_dsi_host_unregister(&dsi->dsi_host);
} }
...@@ -1852,8 +1853,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) ...@@ -1852,8 +1853,7 @@ static int exynos_dsi_probe(struct platform_device *pdev)
if (!dsi) if (!dsi)
return -ENOMEM; return -ENOMEM;
dsi->display.type = EXYNOS_DISPLAY_TYPE_LCD; dsi->encoder.ops = &exynos_dsi_encoder_ops;
dsi->display.ops = &exynos_dsi_display_ops;
/* To be checked as invalid one */ /* To be checked as invalid one */
dsi->te_gpio = -ENOENT; dsi->te_gpio = -ENOENT;
...@@ -1930,7 +1930,7 @@ static int exynos_dsi_probe(struct platform_device *pdev) ...@@ -1930,7 +1930,7 @@ static int exynos_dsi_probe(struct platform_device *pdev)
return ret; return ret;
} }
platform_set_drvdata(pdev, &dsi->display); platform_set_drvdata(pdev, &dsi->encoder);
return component_add(dev, &exynos_dsi_component_ops); return component_add(dev, &exynos_dsi_component_ops);
} }
......
...@@ -18,20 +18,6 @@ ...@@ -18,20 +18,6 @@
#include "exynos_drm_drv.h" #include "exynos_drm_drv.h"
#include "exynos_drm_encoder.h" #include "exynos_drm_encoder.h"
#define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder,\
drm_encoder)
/*
* exynos specific encoder structure.
*
* @drm_encoder: encoder object.
* @display: the display structure that maps to this encoder
*/
struct exynos_drm_encoder {
struct drm_encoder drm_encoder;
struct exynos_drm_display *display;
};
static bool static bool
exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder, exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
...@@ -39,16 +25,16 @@ exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder, ...@@ -39,16 +25,16 @@ exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder,
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
struct exynos_drm_display *display = exynos_encoder->display;
struct drm_connector *connector; struct drm_connector *connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
if (connector->encoder != encoder) if (connector->encoder != encoder)
continue; continue;
if (display->ops->mode_fixup) if (exynos_encoder->ops->mode_fixup)
display->ops->mode_fixup(display, connector, mode, exynos_encoder->ops->mode_fixup(exynos_encoder,
adjusted_mode); connector, mode,
adjusted_mode);
} }
return true; return true;
...@@ -59,31 +45,28 @@ static void exynos_drm_encoder_mode_set(struct drm_encoder *encoder, ...@@ -59,31 +45,28 @@ static void exynos_drm_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
{ {
struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
struct exynos_drm_display *display = exynos_encoder->display;
if (display->ops->mode_set) if (exynos_encoder->ops->mode_set)
display->ops->mode_set(display, adjusted_mode); exynos_encoder->ops->mode_set(exynos_encoder, adjusted_mode);
} }
static void exynos_drm_encoder_enable(struct drm_encoder *encoder) static void exynos_drm_encoder_enable(struct drm_encoder *encoder)
{ {
struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
struct exynos_drm_display *display = exynos_encoder->display;
if (display->ops->enable) if (exynos_encoder->ops->enable)
display->ops->enable(display); exynos_encoder->ops->enable(exynos_encoder);
if (display->ops->commit) if (exynos_encoder->ops->commit)
display->ops->commit(display); exynos_encoder->ops->commit(exynos_encoder);
} }
static void exynos_drm_encoder_disable(struct drm_encoder *encoder) static void exynos_drm_encoder_disable(struct drm_encoder *encoder)
{ {
struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
struct exynos_drm_display *display = exynos_encoder->display;
if (display->ops->disable) if (exynos_encoder->ops->disable)
display->ops->disable(display); exynos_encoder->ops->disable(exynos_encoder);
} }
static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = { static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = {
...@@ -93,16 +76,8 @@ static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = { ...@@ -93,16 +76,8 @@ static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = {
.disable = exynos_drm_encoder_disable, .disable = exynos_drm_encoder_disable,
}; };
static void exynos_drm_encoder_destroy(struct drm_encoder *encoder)
{
struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
drm_encoder_cleanup(encoder);
kfree(exynos_encoder);
}
static struct drm_encoder_funcs exynos_encoder_funcs = { static struct drm_encoder_funcs exynos_encoder_funcs = {
.destroy = exynos_drm_encoder_destroy, .destroy = drm_encoder_cleanup,
}; };
void exynos_drm_encoder_setup(struct drm_device *dev) void exynos_drm_encoder_setup(struct drm_device *dev)
...@@ -118,23 +93,16 @@ void exynos_drm_encoder_setup(struct drm_device *dev) ...@@ -118,23 +93,16 @@ void exynos_drm_encoder_setup(struct drm_device *dev)
encoder->possible_clones = clone_mask; encoder->possible_clones = clone_mask;
} }
struct drm_encoder * int exynos_drm_encoder_create(struct drm_device *dev,
exynos_drm_encoder_create(struct drm_device *dev, struct exynos_drm_encoder *exynos_encoder,
struct exynos_drm_display *display, unsigned long possible_crtcs)
unsigned long possible_crtcs)
{ {
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct exynos_drm_encoder *exynos_encoder;
if (!possible_crtcs) if (!possible_crtcs)
return NULL; return -EINVAL;
exynos_encoder = kzalloc(sizeof(*exynos_encoder), GFP_KERNEL);
if (!exynos_encoder)
return NULL;
exynos_encoder->display = display; encoder = &exynos_encoder->base;
encoder = &exynos_encoder->drm_encoder;
encoder->possible_crtcs = possible_crtcs; encoder->possible_crtcs = possible_crtcs;
DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs); DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs);
...@@ -146,10 +114,5 @@ exynos_drm_encoder_create(struct drm_device *dev, ...@@ -146,10 +114,5 @@ exynos_drm_encoder_create(struct drm_device *dev,
DRM_DEBUG_KMS("encoder has been created\n"); DRM_DEBUG_KMS("encoder has been created\n");
return encoder; return 0;
}
struct exynos_drm_display *exynos_drm_get_display(struct drm_encoder *encoder)
{
return to_exynos_encoder(encoder)->display;
} }
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
#define _EXYNOS_DRM_ENCODER_H_ #define _EXYNOS_DRM_ENCODER_H_
void exynos_drm_encoder_setup(struct drm_device *dev); void exynos_drm_encoder_setup(struct drm_device *dev);
struct drm_encoder *exynos_drm_encoder_create(struct drm_device *dev, int exynos_drm_encoder_create(struct drm_device *dev, struct exynos_drm_encoder
struct exynos_drm_display *mgr, *encoder, unsigned long possible_crtcs);
unsigned long possible_crtcs);
struct exynos_drm_display *exynos_drm_get_display(struct drm_encoder *encoder);
#endif #endif
...@@ -169,7 +169,7 @@ struct fimd_context { ...@@ -169,7 +169,7 @@ struct fimd_context {
struct exynos_drm_panel_info panel; struct exynos_drm_panel_info panel;
struct fimd_driver_data *driver_data; struct fimd_driver_data *driver_data;
struct exynos_drm_display *display; struct exynos_drm_encoder *encoder;
}; };
static const struct of_device_id fimd_driver_dt_match[] = { static const struct of_device_id fimd_driver_dt_match[] = {
...@@ -945,8 +945,9 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) ...@@ -945,8 +945,9 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
if (IS_ERR(ctx->crtc)) if (IS_ERR(ctx->crtc))
return PTR_ERR(ctx->crtc); return PTR_ERR(ctx->crtc);
if (ctx->display) if (ctx->encoder)
exynos_drm_create_enc_conn(drm_dev, ctx->display); exynos_drm_create_enc_conn(drm_dev, ctx->encoder,
EXYNOS_DISPLAY_TYPE_LCD);
if (is_drm_iommu_supported(drm_dev)) if (is_drm_iommu_supported(drm_dev))
fimd_clear_channels(ctx->crtc); fimd_clear_channels(ctx->crtc);
...@@ -967,8 +968,8 @@ static void fimd_unbind(struct device *dev, struct device *master, ...@@ -967,8 +968,8 @@ static void fimd_unbind(struct device *dev, struct device *master,
drm_iommu_detach_device(ctx->drm_dev, ctx->dev); drm_iommu_detach_device(ctx->drm_dev, ctx->dev);
if (ctx->display) if (ctx->encoder)
exynos_dpi_remove(ctx->display); exynos_dpi_remove(ctx->encoder);
} }
static const struct component_ops fimd_component_ops = { static const struct component_ops fimd_component_ops = {
...@@ -1075,10 +1076,9 @@ static int fimd_probe(struct platform_device *pdev) ...@@ -1075,10 +1076,9 @@ static int fimd_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ctx); platform_set_drvdata(pdev, ctx);
ctx->display = exynos_dpi_probe(dev); ctx->encoder = exynos_dpi_probe(dev);
if (IS_ERR(ctx->display)) { if (IS_ERR(ctx->encoder))
return PTR_ERR(ctx->display); return PTR_ERR(ctx->encoder);
}
pm_runtime_enable(dev); pm_runtime_enable(dev);
......
...@@ -35,11 +35,10 @@ ...@@ -35,11 +35,10 @@
connector) connector)
struct vidi_context { struct vidi_context {
struct exynos_drm_display display; struct exynos_drm_encoder encoder;
struct platform_device *pdev; struct platform_device *pdev;
struct drm_device *drm_dev; struct drm_device *drm_dev;
struct exynos_drm_crtc *crtc; struct exynos_drm_crtc *crtc;
struct drm_encoder *encoder;
struct drm_connector connector; struct drm_connector connector;
struct exynos_drm_plane planes[WINDOWS_NR]; struct exynos_drm_plane planes[WINDOWS_NR];
struct edid *raw_edid; struct edid *raw_edid;
...@@ -55,9 +54,9 @@ struct vidi_context { ...@@ -55,9 +54,9 @@ struct vidi_context {
int pipe; int pipe;
}; };
static inline struct vidi_context *display_to_vidi(struct exynos_drm_display *d) static inline struct vidi_context *encoder_to_vidi(struct exynos_drm_encoder *e)
{ {
return container_of(d, struct vidi_context, display); return container_of(e, struct vidi_context, encoder);
} }
static const char fake_edid_info[] = { static const char fake_edid_info[] = {
...@@ -254,9 +253,7 @@ static DEVICE_ATTR(connection, 0644, vidi_show_connection, ...@@ -254,9 +253,7 @@ static DEVICE_ATTR(connection, 0644, vidi_show_connection,
int vidi_connection_ioctl(struct drm_device *drm_dev, void *data, int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
struct vidi_context *ctx = NULL; struct vidi_context *ctx = dev_get_drvdata(drm_dev->dev);
struct drm_encoder *encoder;
struct exynos_drm_display *display;
struct drm_exynos_vidi_connection *vidi = data; struct drm_exynos_vidi_connection *vidi = data;
if (!vidi) { if (!vidi) {
...@@ -269,21 +266,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data, ...@@ -269,21 +266,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
return -EINVAL; return -EINVAL;
} }
list_for_each_entry(encoder, &drm_dev->mode_config.encoder_list,
head) {
display = exynos_drm_get_display(encoder);
if (display->type == EXYNOS_DISPLAY_TYPE_VIDI) {
ctx = display_to_vidi(display);
break;
}
}
if (!ctx) {
DRM_DEBUG_KMS("not found virtual device type encoder.\n");
return -EINVAL;
}
if (ctx->connected == vidi->connection) { if (ctx->connected == vidi->connection) {
DRM_DEBUG_KMS("same connection request.\n"); DRM_DEBUG_KMS("same connection request.\n");
return -EINVAL; return -EINVAL;
...@@ -376,7 +358,7 @@ static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector) ...@@ -376,7 +358,7 @@ static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector)
{ {
struct vidi_context *ctx = ctx_from_connector(connector); struct vidi_context *ctx = ctx_from_connector(connector);
return ctx->encoder; return &ctx->encoder.base;
} }
static struct drm_connector_helper_funcs vidi_connector_helper_funcs = { static struct drm_connector_helper_funcs vidi_connector_helper_funcs = {
...@@ -384,14 +366,13 @@ static struct drm_connector_helper_funcs vidi_connector_helper_funcs = { ...@@ -384,14 +366,13 @@ static struct drm_connector_helper_funcs vidi_connector_helper_funcs = {
.best_encoder = vidi_best_encoder, .best_encoder = vidi_best_encoder,
}; };
static int vidi_create_connector(struct exynos_drm_display *display, static int vidi_create_connector(struct exynos_drm_encoder *exynos_encoder)
struct drm_encoder *encoder)
{ {
struct vidi_context *ctx = display_to_vidi(display); struct vidi_context *ctx = encoder_to_vidi(exynos_encoder);
struct drm_encoder *encoder = &exynos_encoder->base;
struct drm_connector *connector = &ctx->connector; struct drm_connector *connector = &ctx->connector;
int ret; int ret;
ctx->encoder = encoder;
connector->polled = DRM_CONNECTOR_POLL_HPD; connector->polled = DRM_CONNECTOR_POLL_HPD;
ret = drm_connector_init(ctx->drm_dev, connector, ret = drm_connector_init(ctx->drm_dev, connector,
...@@ -409,7 +390,7 @@ static int vidi_create_connector(struct exynos_drm_display *display, ...@@ -409,7 +390,7 @@ static int vidi_create_connector(struct exynos_drm_display *display,
} }
static struct exynos_drm_display_ops vidi_display_ops = { static struct exynos_drm_encoder_ops vidi_encoder_ops = {
.create_connector = vidi_create_connector, .create_connector = vidi_create_connector,
}; };
...@@ -442,7 +423,8 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) ...@@ -442,7 +423,8 @@ static int vidi_bind(struct device *dev, struct device *master, void *data)
return PTR_ERR(ctx->crtc); return PTR_ERR(ctx->crtc);
} }
ret = exynos_drm_create_enc_conn(drm_dev, &ctx->display); ret = exynos_drm_create_enc_conn(drm_dev, &ctx->encoder,
EXYNOS_DISPLAY_TYPE_VIDI);
if (ret) { if (ret) {
ctx->crtc->base.funcs->destroy(&ctx->crtc->base); ctx->crtc->base.funcs->destroy(&ctx->crtc->base);
return ret; return ret;
...@@ -470,8 +452,7 @@ static int vidi_probe(struct platform_device *pdev) ...@@ -470,8 +452,7 @@ static int vidi_probe(struct platform_device *pdev)
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
ctx->display.type = EXYNOS_DISPLAY_TYPE_VIDI; ctx->encoder.ops = &vidi_encoder_ops;
ctx->display.ops = &vidi_display_ops;
ctx->default_win = 0; ctx->default_win = 0;
ctx->pdev = pdev; ctx->pdev = pdev;
......
...@@ -87,11 +87,11 @@ struct hdmi_resources { ...@@ -87,11 +87,11 @@ struct hdmi_resources {
}; };
struct hdmi_context { struct hdmi_context {
struct exynos_drm_display display; struct exynos_drm_encoder encoder;
struct device *dev; struct device *dev;
struct drm_device *drm_dev; struct drm_device *drm_dev;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder *encoder; bool hpd;
bool powered; bool powered;
bool dvi_mode; bool dvi_mode;
...@@ -115,9 +115,9 @@ struct hdmi_context { ...@@ -115,9 +115,9 @@ struct hdmi_context {
struct regmap *pmureg; struct regmap *pmureg;
}; };
static inline struct hdmi_context *display_to_hdmi(struct exynos_drm_display *d) static inline struct hdmi_context *encoder_to_hdmi(struct exynos_drm_encoder *e)
{ {
return container_of(d, struct hdmi_context, display); return container_of(e, struct hdmi_context, encoder);
} }
struct hdmiphy_config { struct hdmiphy_config {
...@@ -1031,7 +1031,7 @@ static struct drm_encoder *hdmi_best_encoder(struct drm_connector *connector) ...@@ -1031,7 +1031,7 @@ static struct drm_encoder *hdmi_best_encoder(struct drm_connector *connector)
{ {
struct hdmi_context *hdata = ctx_from_connector(connector); struct hdmi_context *hdata = ctx_from_connector(connector);
return hdata->encoder; return &hdata->encoder.base;
} }
static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = { static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
...@@ -1040,14 +1040,12 @@ static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = { ...@@ -1040,14 +1040,12 @@ static struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
.best_encoder = hdmi_best_encoder, .best_encoder = hdmi_best_encoder,
}; };
static int hdmi_create_connector(struct exynos_drm_display *display, static int hdmi_create_connector(struct exynos_drm_encoder *exynos_encoder)
struct drm_encoder *encoder)
{ {
struct hdmi_context *hdata = display_to_hdmi(display); struct hdmi_context *hdata = encoder_to_hdmi(exynos_encoder);
struct drm_connector *connector = &hdata->connector; struct drm_connector *connector = &hdata->connector;
int ret; int ret;
hdata->encoder = encoder;
connector->interlace_allowed = true; connector->interlace_allowed = true;
connector->polled = DRM_CONNECTOR_POLL_HPD; connector->polled = DRM_CONNECTOR_POLL_HPD;
...@@ -1060,12 +1058,12 @@ static int hdmi_create_connector(struct exynos_drm_display *display, ...@@ -1060,12 +1058,12 @@ static int hdmi_create_connector(struct exynos_drm_display *display,
drm_connector_helper_add(connector, &hdmi_connector_helper_funcs); drm_connector_helper_add(connector, &hdmi_connector_helper_funcs);
drm_connector_register(connector); drm_connector_register(connector);
drm_mode_connector_attach_encoder(connector, encoder); drm_mode_connector_attach_encoder(connector, &exynos_encoder->base);
return 0; return 0;
} }
static void hdmi_mode_fixup(struct exynos_drm_display *display, static void hdmi_mode_fixup(struct exynos_drm_encoder *encoder,
struct drm_connector *connector, struct drm_connector *connector,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
...@@ -1698,10 +1696,10 @@ static void hdmi_conf_apply(struct hdmi_context *hdata) ...@@ -1698,10 +1696,10 @@ static void hdmi_conf_apply(struct hdmi_context *hdata)
hdmi_regs_dump(hdata, "start"); hdmi_regs_dump(hdata, "start");
} }
static void hdmi_mode_set(struct exynos_drm_display *display, static void hdmi_mode_set(struct exynos_drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct hdmi_context *hdata = display_to_hdmi(display); struct hdmi_context *hdata = encoder_to_hdmi(encoder);
struct drm_display_mode *m = mode; struct drm_display_mode *m = mode;
DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n", DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%s\n",
...@@ -1713,9 +1711,9 @@ static void hdmi_mode_set(struct exynos_drm_display *display, ...@@ -1713,9 +1711,9 @@ static void hdmi_mode_set(struct exynos_drm_display *display,
hdata->cea_video_id = drm_match_cea_mode(mode); hdata->cea_video_id = drm_match_cea_mode(mode);
} }
static void hdmi_commit(struct exynos_drm_display *display) static void hdmi_commit(struct exynos_drm_encoder *encoder)
{ {
struct hdmi_context *hdata = display_to_hdmi(display); struct hdmi_context *hdata = encoder_to_hdmi(encoder);
if (!hdata->powered) if (!hdata->powered)
return; return;
...@@ -1723,9 +1721,9 @@ static void hdmi_commit(struct exynos_drm_display *display) ...@@ -1723,9 +1721,9 @@ static void hdmi_commit(struct exynos_drm_display *display)
hdmi_conf_apply(hdata); hdmi_conf_apply(hdata);
} }
static void hdmi_enable(struct exynos_drm_display *display) static void hdmi_enable(struct exynos_drm_encoder *encoder)
{ {
struct hdmi_context *hdata = display_to_hdmi(display); struct hdmi_context *hdata = encoder_to_hdmi(encoder);
struct hdmi_resources *res = &hdata->res; struct hdmi_resources *res = &hdata->res;
if (hdata->powered) if (hdata->powered)
...@@ -1746,14 +1744,14 @@ static void hdmi_enable(struct exynos_drm_display *display) ...@@ -1746,14 +1744,14 @@ static void hdmi_enable(struct exynos_drm_display *display)
clk_prepare_enable(res->sclk_hdmi); clk_prepare_enable(res->sclk_hdmi);
hdmiphy_poweron(hdata); hdmiphy_poweron(hdata);
hdmi_commit(display); hdmi_commit(encoder);
} }
static void hdmi_disable(struct exynos_drm_display *display) static void hdmi_disable(struct exynos_drm_encoder *encoder)
{ {
struct hdmi_context *hdata = display_to_hdmi(display); struct hdmi_context *hdata = encoder_to_hdmi(encoder);
struct hdmi_resources *res = &hdata->res; struct hdmi_resources *res = &hdata->res;
struct drm_crtc *crtc = hdata->encoder->crtc; struct drm_crtc *crtc = hdata->encoder.base.crtc;
const struct drm_crtc_helper_funcs *funcs = NULL; const struct drm_crtc_helper_funcs *funcs = NULL;
if (!hdata->powered) if (!hdata->powered)
...@@ -1794,7 +1792,7 @@ static void hdmi_disable(struct exynos_drm_display *display) ...@@ -1794,7 +1792,7 @@ static void hdmi_disable(struct exynos_drm_display *display)
hdata->powered = false; hdata->powered = false;
} }
static struct exynos_drm_display_ops hdmi_display_ops = { static struct exynos_drm_encoder_ops hdmi_encoder_ops = {
.create_connector = hdmi_create_connector, .create_connector = hdmi_create_connector,
.mode_fixup = hdmi_mode_fixup, .mode_fixup = hdmi_mode_fixup,
.mode_set = hdmi_mode_set, .mode_set = hdmi_mode_set,
...@@ -1933,7 +1931,8 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data) ...@@ -1933,7 +1931,8 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
hdata->drm_dev = drm_dev; hdata->drm_dev = drm_dev;
return exynos_drm_create_enc_conn(drm_dev, &hdata->display); return exynos_drm_create_enc_conn(drm_dev, &hdata->encoder,
EXYNOS_DISPLAY_TYPE_HDMI);
} }
static void hdmi_unbind(struct device *dev, struct device *master, void *data) static void hdmi_unbind(struct device *dev, struct device *master, void *data)
...@@ -1982,8 +1981,7 @@ static int hdmi_probe(struct platform_device *pdev) ...@@ -1982,8 +1981,7 @@ static int hdmi_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
hdata->drv_data = match->data; hdata->drv_data = match->data;
hdata->display.type = EXYNOS_DISPLAY_TYPE_HDMI; hdata->encoder.ops = &hdmi_encoder_ops;
hdata->display.ops = &hdmi_display_ops;
platform_set_drvdata(pdev, hdata); platform_set_drvdata(pdev, hdata);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment