From ffceaed64ed103fea35e3546227a86441a7e61e4 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Fri, 31 Oct 2014 14:32:32 +0000 Subject: [PATCH 01/22] drm/exynos: move to_exynos_crtc() macro to main header With this change we allow other pieces of the code to use this macro. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 3 --- drivers/gpu/drm/exynos/exynos_drm_drv.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 45026e693225..c8a3169ab977 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -20,9 +20,6 @@ #include "exynos_drm_encoder.h" #include "exynos_drm_plane.h" -#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ - drm_crtc) - enum exynos_crtc_mode { CRTC_MODE_NORMAL, /* normal mode */ CRTC_MODE_BLANK, /* The private plane of crtc is blank */ diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 2e5063488c50..abbee752d64b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -23,6 +23,9 @@ #define MAX_FB_BUFFER 4 #define DEFAULT_ZPOS -1 +#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ + drm_crtc) + /* This enumerates device type. */ enum exynos_drm_device_type { EXYNOS_DEVICE_TYPE_NONE, From 2bf053eb264ef6f51ba930c74812d9edd0b43798 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Fri, 31 Oct 2014 17:33:30 +0000 Subject: [PATCH 02/22] drm/exynos: expose struct exynos_drm_crtc Let other pieces of the driver access struct exynos_drm_crtc as well. struct exynos_drm_manager will be merged into struct exynos_drm_crtc, in the sense we will move all its members to exynos_drm_crtc, so to start this conversion exynos_drm_crtc need to be exposed as well. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 30 ------------------------ drivers/gpu/drm/exynos/exynos_drm_drv.h | 30 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index c8a3169ab977..e74b6fecef9b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -20,36 +20,6 @@ #include "exynos_drm_encoder.h" #include "exynos_drm_plane.h" -enum exynos_crtc_mode { - CRTC_MODE_NORMAL, /* normal mode */ - CRTC_MODE_BLANK, /* The private plane of crtc is blank */ -}; - -/* - * Exynos specific crtc structure. - * - * @drm_crtc: crtc object. - * @manager: the manager associated with this crtc - * @pipe: a crtc index created at load() with a new crtc object creation - * and the crtc object would be set to private->crtc array - * to get a crtc object corresponding to this pipe from private->crtc - * array when irq interrupt occurred. the reason of using this pipe is that - * drm framework doesn't support multiple irq yet. - * we can refer to the crtc to current hardware interrupt occurred through - * this pipe value. - * @dpms: store the crtc dpms value - * @mode: store the crtc mode value - */ -struct exynos_drm_crtc { - struct drm_crtc drm_crtc; - struct exynos_drm_manager *manager; - unsigned int pipe; - unsigned int dpms; - enum exynos_crtc_mode mode; - wait_queue_head_t pending_flip_queue; - atomic_t pending_flip; -}; - static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index abbee752d64b..984ddb2f4ce6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -215,6 +215,36 @@ struct exynos_drm_manager { struct exynos_drm_manager_ops *ops; }; +enum exynos_crtc_mode { + CRTC_MODE_NORMAL, /* normal mode */ + CRTC_MODE_BLANK, /* The private plane of crtc is blank */ +}; + +/* + * Exynos specific crtc structure. + * + * @drm_crtc: crtc object. + * @manager: the manager associated with this crtc + * @pipe: a crtc index created at load() with a new crtc object creation + * and the crtc object would be set to private->crtc array + * to get a crtc object corresponding to this pipe from private->crtc + * array when irq interrupt occurred. the reason of using this pipe is that + * drm framework doesn't support multiple irq yet. + * we can refer to the crtc to current hardware interrupt occurred through + * this pipe value. + * @dpms: store the crtc dpms value + * @mode: store the crtc mode value + */ +struct exynos_drm_crtc { + struct drm_crtc drm_crtc; + struct exynos_drm_manager *manager; + unsigned int pipe; + unsigned int dpms; + enum exynos_crtc_mode mode; + wait_queue_head_t pending_flip_queue; + atomic_t pending_flip; +}; + struct exynos_drm_g2d_private { struct device *dev; struct list_head inuse_cmdlist; From 1e3b423d0b79dfa25e5f09f558da264d4050eca8 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Wed, 29 Oct 2014 19:25:53 +0000 Subject: [PATCH 03/22] drm/exynos: remove exynos_drm_crtc_plane_* wrappers This functions were doing nothing but calling a manager op function, so remove them and call the manager directly. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 33 ----------------------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 19 ++++++++++--- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index e74b6fecef9b..13c7ba5d5d5d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -410,39 +410,6 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe) spin_unlock_irqrestore(&dev->event_lock, flags); } -void exynos_drm_crtc_plane_mode_set(struct drm_crtc *crtc, - struct exynos_drm_overlay *overlay) -{ - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; - - if (manager->ops->win_mode_set) - manager->ops->win_mode_set(manager, overlay); -} - -void exynos_drm_crtc_plane_commit(struct drm_crtc *crtc, int zpos) -{ - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; - - if (manager->ops->win_commit) - manager->ops->win_commit(manager, zpos); -} - -void exynos_drm_crtc_plane_enable(struct drm_crtc *crtc, int zpos) -{ - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; - - if (manager->ops->win_enable) - manager->ops->win_enable(manager, zpos); -} - -void exynos_drm_crtc_plane_disable(struct drm_crtc *crtc, int zpos) -{ - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; - - if (manager->ops->win_disable) - manager->ops->win_disable(manager, zpos); -} - void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb) { struct exynos_drm_manager *manager; diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index c7045a663763..7d768612e567 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -76,6 +76,7 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_w, uint32_t src_h) { struct exynos_plane *exynos_plane = to_exynos_plane(plane); + struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; struct exynos_drm_overlay *overlay = &exynos_plane->overlay; unsigned int actual_w; unsigned int actual_h; @@ -141,7 +142,8 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, plane->crtc = crtc; - exynos_drm_crtc_plane_mode_set(crtc, overlay); + if (manager->ops->win_mode_set) + manager->ops->win_mode_set(manager, overlay); return 0; } @@ -150,26 +152,35 @@ void exynos_plane_commit(struct drm_plane *plane) { struct exynos_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_overlay *overlay = &exynos_plane->overlay; + struct exynos_drm_manager *manager = to_exynos_crtc(plane->crtc)->manager; - exynos_drm_crtc_plane_commit(plane->crtc, overlay->zpos); + if (manager->ops->win_commit) + manager->ops->win_commit(manager, overlay->zpos); } void exynos_plane_dpms(struct drm_plane *plane, int mode) { struct exynos_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_overlay *overlay = &exynos_plane->overlay; + struct exynos_drm_manager *manager; if (mode == DRM_MODE_DPMS_ON) { if (exynos_plane->enabled) return; - exynos_drm_crtc_plane_enable(plane->crtc, overlay->zpos); + manager = to_exynos_crtc(plane->crtc)->manager; + if (manager->ops->win_enable) + manager->ops->win_enable(manager, overlay->zpos); + exynos_plane->enabled = true; } else { if (!exynos_plane->enabled) return; - exynos_drm_crtc_plane_disable(plane->crtc, overlay->zpos); + manager = to_exynos_crtc(plane->crtc)->manager; + if (manager->ops->win_disable) + manager->ops->win_disable(manager, overlay->zpos); + exynos_plane->enabled = false; } } From 8837deeab462a30d5a760fa1ae7c29242d985700 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Mon, 3 Nov 2014 18:13:27 -0200 Subject: [PATCH 04/22] drm/exynos: remove struct exynos_drm_overlay struct exynos_drm_overlay has no practical advantage nor serves as important piece of the exynos API design. The only place it was used was inside the struct exynos_plane which was just causing a extra access overhead. Users had to access the overlay first and just then get the plane information it contains. This patch merges struct exynos_drm_overlay into struct exynos_plane. It also renames struct exynos_plane to struct exynos_drm_plane. The rational is to cut one step to access plane information. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 10 ++- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 44 ++++++------ drivers/gpu/drm/exynos/exynos_drm_plane.c | 85 ++++++++++------------- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 38 +++++----- drivers/gpu/drm/exynos/exynos_mixer.c | 50 ++++++------- 6 files changed, 112 insertions(+), 117 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index e353d353836f..dbd42270dbc4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -24,7 +24,7 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe); void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb); void exynos_drm_crtc_plane_mode_set(struct drm_crtc *crtc, - struct exynos_drm_overlay *overlay); + struct exynos_drm_plane *plane); void exynos_drm_crtc_plane_commit(struct drm_crtc *crtc, int zpos); void exynos_drm_crtc_plane_enable(struct drm_crtc *crtc, int zpos); void exynos_drm_crtc_plane_disable(struct drm_crtc *crtc, int zpos); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 984ddb2f4ce6..187dde53625c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -25,6 +25,7 @@ #define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ drm_crtc) +#define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base) /* This enumerates device type. */ enum exynos_drm_device_type { @@ -47,6 +48,7 @@ enum exynos_drm_output_type { /* * Exynos drm common overlay structure. * + * @base: plane object * @fb_x: offset x on a framebuffer to be displayed. * - the unit is screen coordinates. * @fb_y: offset y on a framebuffer to be displayed. @@ -76,11 +78,14 @@ enum exynos_drm_output_type { * @local_path: in case of lcd type, local path mode on or off. * @transparency: transparency on or off. * @activated: activated or not. + * @enabled: enabled or not. * * this structure is common to exynos SoC and its contents would be copied * to hardware specific overlay info. */ -struct exynos_drm_overlay { + +struct exynos_drm_plane { + struct drm_plane base; unsigned int fb_x; unsigned int fb_y; unsigned int fb_width; @@ -107,6 +112,7 @@ struct exynos_drm_overlay { bool local_path:1; bool transparency:1; bool activated:1; + bool enabled:1; }; /* @@ -188,7 +194,7 @@ struct exynos_drm_manager_ops { void (*disable_vblank)(struct exynos_drm_manager *mgr); void (*wait_for_vblank)(struct exynos_drm_manager *mgr); void (*win_mode_set)(struct exynos_drm_manager *mgr, - struct exynos_drm_overlay *overlay); + struct exynos_drm_plane *plane); void (*win_commit)(struct exynos_drm_manager *mgr, int zpos); void (*win_enable)(struct exynos_drm_manager *mgr, int zpos); void (*win_disable)(struct exynos_drm_manager *mgr, int zpos); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index e5810d13bf9c..abd2ca912bb2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -518,44 +518,44 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr) } static void fimd_win_mode_set(struct exynos_drm_manager *mgr, - struct exynos_drm_overlay *overlay) + struct exynos_drm_plane *plane) { struct fimd_context *ctx = mgr_to_fimd(mgr); struct fimd_win_data *win_data; int win; unsigned long offset; - if (!overlay) { - DRM_ERROR("overlay is NULL\n"); + if (!plane) { + DRM_ERROR("plane is NULL\n"); return; } - win = overlay->zpos; + win = plane->zpos; if (win == DEFAULT_ZPOS) win = ctx->default_win; if (win < 0 || win >= WINDOWS_NR) return; - offset = overlay->fb_x * (overlay->bpp >> 3); - offset += overlay->fb_y * overlay->pitch; + offset = plane->fb_x * (plane->bpp >> 3); + offset += plane->fb_y * plane->pitch; - DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, overlay->pitch); + DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, plane->pitch); win_data = &ctx->win_data[win]; - win_data->offset_x = overlay->crtc_x; - win_data->offset_y = overlay->crtc_y; - win_data->ovl_width = overlay->crtc_width; - win_data->ovl_height = overlay->crtc_height; - win_data->fb_width = overlay->fb_width; - win_data->fb_height = overlay->fb_height; - win_data->dma_addr = overlay->dma_addr[0] + offset; - win_data->bpp = overlay->bpp; - win_data->pixel_format = overlay->pixel_format; - win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * - (overlay->bpp >> 3); - win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3); + win_data->offset_x = plane->crtc_x; + win_data->offset_y = plane->crtc_y; + win_data->ovl_width = plane->crtc_width; + win_data->ovl_height = plane->crtc_height; + win_data->fb_width = plane->fb_width; + win_data->fb_height = plane->fb_height; + win_data->dma_addr = plane->dma_addr[0] + offset; + win_data->bpp = plane->bpp; + win_data->pixel_format = plane->pixel_format; + win_data->buf_offsize = (plane->fb_width - plane->crtc_width) * + (plane->bpp >> 3); + win_data->line_size = plane->crtc_width * (plane->bpp >> 3); DRM_DEBUG_KMS("offset_x = %d, offset_y = %d\n", win_data->offset_x, win_data->offset_y); @@ -563,7 +563,7 @@ static void fimd_win_mode_set(struct exynos_drm_manager *mgr, win_data->ovl_width, win_data->ovl_height); DRM_DEBUG_KMS("paddr = 0x%lx\n", (unsigned long)win_data->dma_addr); DRM_DEBUG_KMS("fb_width = %d, crtc_width = %d\n", - overlay->fb_width, overlay->crtc_width); + plane->fb_width, plane->crtc_width); } static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win) @@ -623,8 +623,8 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win) /* * In case of exynos, setting dma-burst to 16Word causes permanent * tearing for very small buffers, e.g. cursor buffer. Burst Mode - * switching which is based on overlay size is not recommended as - * overlay size varies alot towards the end of the screen and rapid + * switching which is based on plane size is not recommended as + * plane size varies alot towards the end of the screen and rapid * movement causes unstable DMA which results into iommu crash/tear. */ diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 7d768612e567..843f74175094 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -18,14 +18,6 @@ #include "exynos_drm_gem.h" #include "exynos_drm_plane.h" -#define to_exynos_plane(x) container_of(x, struct exynos_plane, base) - -struct exynos_plane { - struct drm_plane base; - struct exynos_drm_overlay overlay; - bool enabled; -}; - static const uint32_t formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_ARGB8888, @@ -75,9 +67,8 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h) { - struct exynos_plane *exynos_plane = to_exynos_plane(plane); + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; - struct exynos_drm_overlay *overlay = &exynos_plane->overlay; unsigned int actual_w; unsigned int actual_h; int nr; @@ -92,10 +83,10 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, return -EFAULT; } - overlay->dma_addr[i] = buffer->dma_addr; + exynos_plane->dma_addr[i] = buffer->dma_addr; DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n", - i, (unsigned long)overlay->dma_addr[i]); + i, (unsigned long)exynos_plane->dma_addr[i]); } actual_w = exynos_plane_get_size(crtc_x, crtc_w, crtc->mode.hdisplay); @@ -114,54 +105,52 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, } /* set drm framebuffer data. */ - overlay->fb_x = src_x; - overlay->fb_y = src_y; - overlay->fb_width = fb->width; - overlay->fb_height = fb->height; - overlay->src_width = src_w; - overlay->src_height = src_h; - overlay->bpp = fb->bits_per_pixel; - overlay->pitch = fb->pitches[0]; - overlay->pixel_format = fb->pixel_format; - - /* set overlay range to be displayed. */ - overlay->crtc_x = crtc_x; - overlay->crtc_y = crtc_y; - overlay->crtc_width = actual_w; - overlay->crtc_height = actual_h; + exynos_plane->fb_x = src_x; + exynos_plane->fb_y = src_y; + exynos_plane->fb_width = fb->width; + exynos_plane->fb_height = fb->height; + exynos_plane->src_width = src_w; + exynos_plane->src_height = src_h; + exynos_plane->bpp = fb->bits_per_pixel; + exynos_plane->pitch = fb->pitches[0]; + exynos_plane->pixel_format = fb->pixel_format; + + /* set plane range to be displayed. */ + exynos_plane->crtc_x = crtc_x; + exynos_plane->crtc_y = crtc_y; + exynos_plane->crtc_width = actual_w; + exynos_plane->crtc_height = actual_h; /* set drm mode data. */ - overlay->mode_width = crtc->mode.hdisplay; - overlay->mode_height = crtc->mode.vdisplay; - overlay->refresh = crtc->mode.vrefresh; - overlay->scan_flag = crtc->mode.flags; + exynos_plane->mode_width = crtc->mode.hdisplay; + exynos_plane->mode_height = crtc->mode.vdisplay; + exynos_plane->refresh = crtc->mode.vrefresh; + exynos_plane->scan_flag = crtc->mode.flags; - DRM_DEBUG_KMS("overlay : offset_x/y(%d,%d), width/height(%d,%d)", - overlay->crtc_x, overlay->crtc_y, - overlay->crtc_width, overlay->crtc_height); + DRM_DEBUG_KMS("plane : offset_x/y(%d,%d), width/height(%d,%d)", + exynos_plane->crtc_x, exynos_plane->crtc_y, + exynos_plane->crtc_width, exynos_plane->crtc_height); plane->crtc = crtc; if (manager->ops->win_mode_set) - manager->ops->win_mode_set(manager, overlay); + manager->ops->win_mode_set(manager, exynos_plane); return 0; } void exynos_plane_commit(struct drm_plane *plane) { - struct exynos_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_overlay *overlay = &exynos_plane->overlay; + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_manager *manager = to_exynos_crtc(plane->crtc)->manager; if (manager->ops->win_commit) - manager->ops->win_commit(manager, overlay->zpos); + manager->ops->win_commit(manager, exynos_plane->zpos); } void exynos_plane_dpms(struct drm_plane *plane, int mode) { - struct exynos_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_overlay *overlay = &exynos_plane->overlay; + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_manager *manager; if (mode == DRM_MODE_DPMS_ON) { @@ -170,7 +159,7 @@ void exynos_plane_dpms(struct drm_plane *plane, int mode) manager = to_exynos_crtc(plane->crtc)->manager; if (manager->ops->win_enable) - manager->ops->win_enable(manager, overlay->zpos); + manager->ops->win_enable(manager, exynos_plane->zpos); exynos_plane->enabled = true; } else { @@ -179,7 +168,7 @@ void exynos_plane_dpms(struct drm_plane *plane, int mode) manager = to_exynos_crtc(plane->crtc)->manager; if (manager->ops->win_disable) - manager->ops->win_disable(manager, overlay->zpos); + manager->ops->win_disable(manager, exynos_plane->zpos); exynos_plane->enabled = false; } @@ -215,7 +204,7 @@ static int exynos_disable_plane(struct drm_plane *plane) static void exynos_plane_destroy(struct drm_plane *plane) { - struct exynos_plane *exynos_plane = to_exynos_plane(plane); + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); exynos_disable_plane(plane); drm_plane_cleanup(plane); @@ -227,11 +216,11 @@ static int exynos_plane_set_property(struct drm_plane *plane, uint64_t val) { struct drm_device *dev = plane->dev; - struct exynos_plane *exynos_plane = to_exynos_plane(plane); + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); struct exynos_drm_private *dev_priv = dev->dev_private; if (property == dev_priv->plane_zpos_property) { - exynos_plane->overlay.zpos = val; + exynos_plane->zpos = val; return 0; } @@ -268,10 +257,10 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev, unsigned long possible_crtcs, enum drm_plane_type type) { - struct exynos_plane *exynos_plane; + struct exynos_drm_plane *exynos_plane; int err; - exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); + exynos_plane = kzalloc(sizeof(struct exynos_drm_plane), GFP_KERNEL); if (!exynos_plane) return ERR_PTR(-ENOMEM); @@ -285,7 +274,7 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev, } if (type == DRM_PLANE_TYPE_PRIMARY) - exynos_plane->overlay.zpos = DEFAULT_ZPOS; + exynos_plane->zpos = DEFAULT_ZPOS; else exynos_plane_attach_zpos_property(&exynos_plane->base); diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 45899fb63272..ff194be5ebf0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -162,43 +162,43 @@ static void vidi_disable_vblank(struct exynos_drm_manager *mgr) } static void vidi_win_mode_set(struct exynos_drm_manager *mgr, - struct exynos_drm_overlay *overlay) + struct exynos_drm_plane *plane) { struct vidi_context *ctx = manager_to_vidi(mgr); struct vidi_win_data *win_data; int win; unsigned long offset; - if (!overlay) { - DRM_ERROR("overlay is NULL\n"); + if (!plane) { + DRM_ERROR("plane is NULL\n"); return; } - win = overlay->zpos; + win = plane->zpos; if (win == DEFAULT_ZPOS) win = ctx->default_win; if (win < 0 || win >= WINDOWS_NR) return; - offset = overlay->fb_x * (overlay->bpp >> 3); - offset += overlay->fb_y * overlay->pitch; + offset = plane->fb_x * (plane->bpp >> 3); + offset += plane->fb_y * plane->pitch; - DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, overlay->pitch); + DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, plane->pitch); win_data = &ctx->win_data[win]; - win_data->offset_x = overlay->crtc_x; - win_data->offset_y = overlay->crtc_y; - win_data->ovl_width = overlay->crtc_width; - win_data->ovl_height = overlay->crtc_height; - win_data->fb_width = overlay->fb_width; - win_data->fb_height = overlay->fb_height; - win_data->dma_addr = overlay->dma_addr[0] + offset; - win_data->bpp = overlay->bpp; - win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * - (overlay->bpp >> 3); - win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3); + win_data->offset_x = plane->crtc_x; + win_data->offset_y = plane->crtc_y; + win_data->ovl_width = plane->crtc_width; + win_data->ovl_height = plane->crtc_height; + win_data->fb_width = plane->fb_width; + win_data->fb_height = plane->fb_height; + win_data->dma_addr = plane->dma_addr[0] + offset; + win_data->bpp = plane->bpp; + win_data->buf_offsize = (plane->fb_width - plane->crtc_width) * + (plane->bpp >> 3); + win_data->line_size = plane->crtc_width * (plane->bpp >> 3); /* * some parts of win_data should be transferred to user side @@ -211,7 +211,7 @@ static void vidi_win_mode_set(struct exynos_drm_manager *mgr, win_data->ovl_width, win_data->ovl_height); DRM_DEBUG_KMS("paddr = 0x%lx\n", (unsigned long)win_data->dma_addr); DRM_DEBUG_KMS("fb_width = %d, crtc_width = %d\n", - overlay->fb_width, overlay->crtc_width); + plane->fb_width, plane->crtc_width); } static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 064ed6597def..8a7d832ca9a5 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -922,24 +922,24 @@ static void mixer_disable_vblank(struct exynos_drm_manager *mgr) } static void mixer_win_mode_set(struct exynos_drm_manager *mgr, - struct exynos_drm_overlay *overlay) + struct exynos_drm_plane *plane) { struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); struct hdmi_win_data *win_data; int win; - if (!overlay) { - DRM_ERROR("overlay is NULL\n"); + if (!plane) { + DRM_ERROR("plane is NULL\n"); return; } DRM_DEBUG_KMS("set [%d]x[%d] at (%d,%d) to [%d]x[%d] at (%d,%d)\n", - overlay->fb_width, overlay->fb_height, - overlay->fb_x, overlay->fb_y, - overlay->crtc_width, overlay->crtc_height, - overlay->crtc_x, overlay->crtc_y); + plane->fb_width, plane->fb_height, + plane->fb_x, plane->fb_y, + plane->crtc_width, plane->crtc_height, + plane->crtc_x, plane->crtc_y); - win = overlay->zpos; + win = plane->zpos; if (win == DEFAULT_ZPOS) win = MIXER_DEFAULT_WIN; @@ -950,27 +950,27 @@ static void mixer_win_mode_set(struct exynos_drm_manager *mgr, win_data = &mixer_ctx->win_data[win]; - win_data->dma_addr = overlay->dma_addr[0]; - win_data->chroma_dma_addr = overlay->dma_addr[1]; - win_data->pixel_format = overlay->pixel_format; - win_data->bpp = overlay->bpp; + win_data->dma_addr = plane->dma_addr[0]; + win_data->chroma_dma_addr = plane->dma_addr[1]; + win_data->pixel_format = plane->pixel_format; + win_data->bpp = plane->bpp; - win_data->crtc_x = overlay->crtc_x; - win_data->crtc_y = overlay->crtc_y; - win_data->crtc_width = overlay->crtc_width; - win_data->crtc_height = overlay->crtc_height; + win_data->crtc_x = plane->crtc_x; + win_data->crtc_y = plane->crtc_y; + win_data->crtc_width = plane->crtc_width; + win_data->crtc_height = plane->crtc_height; - win_data->fb_x = overlay->fb_x; - win_data->fb_y = overlay->fb_y; - win_data->fb_width = overlay->fb_width; - win_data->fb_height = overlay->fb_height; - win_data->src_width = overlay->src_width; - win_data->src_height = overlay->src_height; + win_data->fb_x = plane->fb_x; + win_data->fb_y = plane->fb_y; + win_data->fb_width = plane->fb_width; + win_data->fb_height = plane->fb_height; + win_data->src_width = plane->src_width; + win_data->src_height = plane->src_height; - win_data->mode_width = overlay->mode_width; - win_data->mode_height = overlay->mode_height; + win_data->mode_width = plane->mode_width; + win_data->mode_height = plane->mode_height; - win_data->scan_flags = overlay->scan_flag; + win_data->scan_flags = plane->scan_flag; } static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos) From fe42cfb4908602f2fb6db7b849e170d2fa26fea1 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Mon, 3 Nov 2014 18:56:57 -0200 Subject: [PATCH 05/22] drm/exynos/fimd: don't initialize 'ret' variable in fimd_probe() We set it in the beginning of the function, thus no need to set it at initialization. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index abd2ca912bb2..863e98f48d2c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -1108,7 +1108,7 @@ static int fimd_probe(struct platform_device *pdev) struct fimd_context *ctx; struct device_node *i80_if_timings; struct resource *res; - int ret = -EINVAL; + int ret; if (!dev->of_node) return -ENODEV; From d6d008584e965f560119f657ab43f0344792a666 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 6 Nov 2014 18:15:01 -0200 Subject: [PATCH 06/22] drm/exynos/vidi: remove useless ops->commit() vidi_commit does nothing, remove it and its callers. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index ff194be5ebf0..7f9ce73f872c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -115,17 +115,6 @@ static void vidi_apply(struct exynos_drm_manager *mgr) if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) mgr_ops->win_commit(mgr, i); } - - if (mgr_ops && mgr_ops->commit) - mgr_ops->commit(mgr); -} - -static void vidi_commit(struct exynos_drm_manager *mgr) -{ - struct vidi_context *ctx = manager_to_vidi(mgr); - - if (ctx->suspended) - return; } static int vidi_enable_vblank(struct exynos_drm_manager *mgr) @@ -320,7 +309,6 @@ static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, static struct exynos_drm_manager_ops vidi_manager_ops = { .dpms = vidi_dpms, - .commit = vidi_commit, .enable_vblank = vidi_enable_vblank, .disable_vblank = vidi_disable_vblank, .win_mode_set = vidi_win_mode_set, From e7cd81111041e3fbec00999f5629080989090031 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 30 Oct 2014 12:00:54 +0000 Subject: [PATCH 07/22] drm/exynos: Don't touch DPMS when updating overlay planes DPMS settings should only be changed by a full modeset. exynos_plane_update() should only care about updating the planes itself and nothing else. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_plane.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 843f74175094..4fe3c2b555b1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -190,7 +190,6 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, return ret; exynos_plane_commit(plane); - exynos_plane_dpms(plane, DRM_MODE_DPMS_ON); return 0; } From ea8802d3ddde245e8b8a56a19d70e9b97737880f Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 13 Nov 2014 22:27:20 -0200 Subject: [PATCH 08/22] drm/exynos: don't do any DPMS operation while updating planes DPMS only makes sense when the mode changes, for plane update changes do not perform any dpms operation. This move places the win_commit() and commit() calls directly in the code instead of calling exynos_drm_crtc_commit() thus avoiding DPMS operations. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 13c7ba5d5d5d..e946b5f5e3ac 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -115,6 +115,8 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *old_fb) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); + struct exynos_drm_manager *manager = exynos_crtc->manager; + struct exynos_drm_plane *exynos_plane = to_exynos_plane(crtc->primary); struct drm_framebuffer *fb = crtc->primary->fb; unsigned int crtc_w; unsigned int crtc_h; @@ -134,7 +136,11 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, if (ret) return ret; - exynos_drm_crtc_commit(crtc); + if (manager->ops->win_commit) + manager->ops->win_commit(manager, exynos_plane->zpos); + + if (manager->ops->commit) + manager->ops->commit(manager); return 0; } From 9d5310c024691cadb2dcab1a74b5ab067255f1be Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 13 Nov 2014 22:17:46 -0200 Subject: [PATCH 09/22] drm/exynos: remove exynos_plane_commit() wrapper It's doing nothing but calling exynos_crtc->ops->win_commit(), so let's call this directly to avoid extra layers of abstraction. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 4 +++- drivers/gpu/drm/exynos/exynos_drm_plane.c | 15 +++++---------- drivers/gpu/drm/exynos/exynos_drm_plane.h | 1 - 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index e946b5f5e3ac..a43e25d57a02 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -59,10 +59,12 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); struct exynos_drm_manager *manager = exynos_crtc->manager; + struct exynos_drm_plane *exynos_plane = to_exynos_plane(crtc->primary); exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON); - exynos_plane_commit(crtc->primary); + if (manager->ops->win_commit) + manager->ops->win_commit(manager, exynos_plane->zpos); if (manager->ops->commit) manager->ops->commit(manager); diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 4fe3c2b555b1..aa9cc9a0a033 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -139,15 +139,6 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, return 0; } -void exynos_plane_commit(struct drm_plane *plane) -{ - struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_manager *manager = to_exynos_crtc(plane->crtc)->manager; - - if (manager->ops->win_commit) - manager->ops->win_commit(manager, exynos_plane->zpos); -} - void exynos_plane_dpms(struct drm_plane *plane, int mode) { struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); @@ -181,6 +172,9 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h) { + + struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); int ret; ret = exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, @@ -189,7 +183,8 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, if (ret < 0) return ret; - exynos_plane_commit(plane); + if (manager->ops->win_commit) + manager->ops->win_commit(manager, exynos_plane->zpos); return 0; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h index 0d1986b115f8..3c239891926e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.h +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h @@ -14,7 +14,6 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, unsigned int crtc_w, unsigned int crtc_h, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h); -void exynos_plane_commit(struct drm_plane *plane); void exynos_plane_dpms(struct drm_plane *plane, int mode); struct drm_plane *exynos_plane_init(struct drm_device *dev, unsigned long possible_crtcs, From 0e0a649faa27333efea9cce14bff9bab75230f25 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 25 Nov 2014 11:21:17 -0200 Subject: [PATCH 10/22] drm/exynos: unify plane update on exynos_update_plane() We can safely use the exynos_update_plane() to update the plane framebuffer for both the overlay and primary planes. Note that this patch removes a call to manager->ops->commit() in exynos_drm_crtc_mode_set_commit(). The commit() call is used only by the fimd driver to set underlying timings and need only in full modeset operations. For plane update only win_commit is needed. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 17 ++--------------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_plane.h | 5 +++++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index a43e25d57a02..4c8bd4d1e861 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -117,12 +117,9 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *old_fb) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - struct exynos_drm_manager *manager = exynos_crtc->manager; - struct exynos_drm_plane *exynos_plane = to_exynos_plane(crtc->primary); struct drm_framebuffer *fb = crtc->primary->fb; unsigned int crtc_w; unsigned int crtc_h; - int ret; /* when framebuffer changing is requested, crtc's dpms should be on */ if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) { @@ -133,18 +130,8 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, crtc_w = fb->width - x; crtc_h = fb->height - y; - ret = exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0, - crtc_w, crtc_h, x, y, crtc_w, crtc_h); - if (ret) - return ret; - - if (manager->ops->win_commit) - manager->ops->win_commit(manager, exynos_plane->zpos); - - if (manager->ops->commit) - manager->ops->commit(manager); - - return 0; + return exynos_update_plane(crtc->primary, crtc, fb, 0, 0, + crtc_w, crtc_h, x, y, crtc_w, crtc_h); } static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index aa9cc9a0a033..dadd30631c18 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -165,7 +165,7 @@ void exynos_plane_dpms(struct drm_plane *plane, int mode) } } -static int +int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y, unsigned int crtc_w, unsigned int crtc_h, diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h index 3c239891926e..d25c079a3f44 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.h +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h @@ -14,6 +14,11 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, unsigned int crtc_w, unsigned int crtc_h, uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h); +int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, + struct drm_framebuffer *fb, int crtc_x, int crtc_y, + unsigned int crtc_w, unsigned int crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h); void exynos_plane_dpms(struct drm_plane *plane, int mode); struct drm_plane *exynos_plane_init(struct drm_device *dev, unsigned long possible_crtcs, From 8b9c45050348ba2dc2d74b2755bf2cb629a42a8f Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 25 Nov 2014 16:18:34 -0200 Subject: [PATCH 11/22] drm/exynos: call exynos_update_plane() directly on page flips Avoid an extra call to exynos_drm_crtc_mode_set_commit() that only calls exynos_update_plane(). Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 4c8bd4d1e861..185dabe4e2b7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -176,6 +176,7 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, struct exynos_drm_private *dev_priv = dev->dev_private; struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); struct drm_framebuffer *old_fb = crtc->primary->fb; + unsigned int crtc_w, crtc_h; int ret = -EINVAL; /* when the page flip is requested, crtc's dpms should be on */ @@ -207,8 +208,11 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, spin_unlock_irq(&dev->event_lock); crtc->primary->fb = fb; - ret = exynos_drm_crtc_mode_set_commit(crtc, crtc->x, crtc->y, - NULL); + crtc_w = fb->width - crtc->x; + crtc_h = fb->height - crtc->y; + ret = exynos_update_plane(crtc->primary, crtc, fb, 0, 0, + crtc_w, crtc_h, crtc->x, crtc->y, + crtc_w, crtc_h); if (ret) { crtc->primary->fb = old_fb; From fd092d7a11a237393f633bdc5b93a3624e872ea6 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 13 Nov 2014 22:30:00 -0200 Subject: [PATCH 12/22] drm/exynos: remove exynos_drm_crtc_mode_set_commit() This was just as extra chain in the call stack. We just rename it to _set_base() and let it do everything alone. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 185dabe4e2b7..5b3d18225fd6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -113,7 +113,7 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, crtc_w, crtc_h, x, y, crtc_w, crtc_h); } -static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, +static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *old_fb) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); @@ -134,12 +134,6 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y, crtc_w, crtc_h, x, y, crtc_w, crtc_h); } -static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, - struct drm_framebuffer *old_fb) -{ - return exynos_drm_crtc_mode_set_commit(crtc, x, y, old_fb); -} - static void exynos_drm_crtc_disable(struct drm_crtc *crtc) { struct drm_plane *plane; From 357193cd782e0716027c1b1ae5bae79e1db7d4ca Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Mon, 3 Nov 2014 18:20:29 -0200 Subject: [PATCH 13/22] drm/exynos: rename base object of struct exynos_drm_crtc to 'base' 'base' is more widely used name in the drm subsystem for the base object. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 4 ++-- drivers/gpu/drm/exynos/exynos_drm_drv.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 5b3d18225fd6..1cdf7050ee89 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -324,8 +324,8 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager) goto err_plane; } - manager->crtc = &exynos_crtc->drm_crtc; - crtc = &exynos_crtc->drm_crtc; + manager->crtc = &exynos_crtc->base; + crtc = &exynos_crtc->base; private->crtc[manager->pipe] = crtc; diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 187dde53625c..0a565f83be4d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -23,8 +23,7 @@ #define MAX_FB_BUFFER 4 #define DEFAULT_ZPOS -1 -#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ - drm_crtc) +#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) /* This enumerates device type. */ @@ -229,7 +228,7 @@ enum exynos_crtc_mode { /* * Exynos specific crtc structure. * - * @drm_crtc: crtc object. + * @base: crtc object. * @manager: the manager associated with this crtc * @pipe: a crtc index created at load() with a new crtc object creation * and the crtc object would be set to private->crtc array @@ -242,7 +241,7 @@ enum exynos_crtc_mode { * @mode: store the crtc mode value */ struct exynos_drm_crtc { - struct drm_crtc drm_crtc; + struct drm_crtc base; struct exynos_drm_manager *manager; unsigned int pipe; unsigned int dpms; From e09f2b0d953235f886e190c5057dae5c5f678b2e Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 4 Nov 2014 18:25:27 -0200 Subject: [PATCH 14/22] drm/exynos: add pipe param to exynos_drm_crtc_create() Get the pipe value from a parameter instead of getting it from manager->pipe. We are removing manager->pipe. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 ++++---- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 +- drivers/gpu/drm/exynos/exynos_mixer.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 1cdf7050ee89..68aae38b2cf9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -299,7 +299,7 @@ static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc) drm_object_attach_property(&crtc->base, prop, 0); } -int exynos_drm_crtc_create(struct exynos_drm_manager *manager) +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe) { struct exynos_drm_crtc *exynos_crtc; struct drm_plane *plane; @@ -316,8 +316,8 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager) exynos_crtc->dpms = DRM_MODE_DPMS_OFF; exynos_crtc->manager = manager; - exynos_crtc->pipe = manager->pipe; - plane = exynos_plane_init(manager->drm_dev, 1 << manager->pipe, + exynos_crtc->pipe = pipe; + plane = exynos_plane_init(manager->drm_dev, 1 << pipe, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(plane)) { ret = PTR_ERR(plane); @@ -327,7 +327,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager) manager->crtc = &exynos_crtc->base; crtc = &exynos_crtc->base; - private->crtc[manager->pipe] = crtc; + private->crtc[pipe] = crtc; ret = drm_crtc_init_with_planes(manager->drm_dev, crtc, plane, NULL, &exynos_crtc_funcs); diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index dbd42270dbc4..f1bee8453041 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -17,7 +17,7 @@ #include "exynos_drm_drv.h" -int exynos_drm_crtc_create(struct exynos_drm_manager *manager); +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe); int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 863e98f48d2c..f1f3b3498297 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -1076,7 +1076,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm_dev = data; fimd_mgr_initialize(&ctx->manager, drm_dev); - exynos_drm_crtc_create(&ctx->manager); + exynos_drm_crtc_create(&ctx->manager, ctx->pipe); if (ctx->display) exynos_drm_create_enc_conn(drm_dev, ctx->display); diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 7f9ce73f872c..e78764f800de 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -558,7 +558,7 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) vidi_mgr_initialize(&ctx->manager, drm_dev); - ret = exynos_drm_crtc_create(&ctx->manager); + ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe); if (ret) { DRM_ERROR("failed to create crtc.\n"); return ret; diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 8a7d832ca9a5..16197a627c47 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -1261,7 +1261,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) if (ret) return ret; - ret = exynos_drm_crtc_create(&ctx->manager); + ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe); if (ret) { mixer_mgr_remove(&ctx->manager); return ret; From 8a326edda468c4c6972c39594366bcb5c109e526 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 4 Nov 2014 18:44:47 -0200 Subject: [PATCH 15/22] drm/exynos: remove pipe member of struct exynos_drm_manager It is not longer used. This is part of the process of removing struct exynos_drm_manager entirely. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 -- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 +- drivers/gpu/drm/exynos/exynos_mixer.c | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 68aae38b2cf9..0fe981bc693b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -436,7 +436,7 @@ int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, exynos_crtc = to_exynos_crtc(crtc); if (exynos_crtc->manager->type == out_type) - return exynos_crtc->manager->pipe; + return exynos_crtc->pipe; } return -EPERM; diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 0a565f83be4d..1d024c0421a8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -207,7 +207,6 @@ struct exynos_drm_manager_ops { * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI. * @drm_dev: pointer to the drm device * @crtc: crtc object. - * @pipe: the pipe number for this crtc/manager * @ops: pointer to callbacks for exynos drm specific functionality * @ctx: A pointer to the manager's implementation specific context */ @@ -216,7 +215,6 @@ struct exynos_drm_manager { enum exynos_drm_output_type type; struct drm_device *drm_dev; struct drm_crtc *crtc; - int pipe; struct exynos_drm_manager_ops *ops; }; diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index f1f3b3498297..4df151ca74f3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -299,7 +299,7 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, priv = drm_dev->dev_private; mgr->drm_dev = ctx->drm_dev = drm_dev; - mgr->pipe = ctx->pipe = priv->pipe++; + ctx->pipe = priv->pipe++; /* attach this sub driver to iommu mapping if supported. */ if (is_drm_iommu_supported(ctx->drm_dev)) { diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index e78764f800de..785d2fe47fe0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -302,7 +302,7 @@ static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, struct exynos_drm_private *priv = drm_dev->dev_private; mgr->drm_dev = ctx->drm_dev = drm_dev; - mgr->pipe = ctx->pipe = priv->pipe++; + ctx->pipe = priv->pipe++; return 0; } diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 16197a627c47..57c4622f9d41 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -863,7 +863,7 @@ static int mixer_initialize(struct exynos_drm_manager *mgr, priv = drm_dev->dev_private; mgr->drm_dev = mixer_ctx->drm_dev = drm_dev; - mgr->pipe = mixer_ctx->pipe = priv->pipe++; + mixer_ctx->pipe = priv->pipe++; /* acquire resources: regs, irqs, clocks */ ret = mixer_resources_init(mixer_ctx); From 5d1741ad4b61bc5a7fbc783199aa2b8805877e76 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Wed, 5 Nov 2014 19:51:35 -0200 Subject: [PATCH 16/22] drm/exynos: move 'type' from manager to crtc struct 'type' is now part of the struct exynos_drm_crtc. This is just another step in the struct exynos_drm_manager removal. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 6 ++++-- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 3 ++- drivers/gpu/drm/exynos/exynos_drm_drv.h | 4 ++-- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 6 +++--- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 6 +++--- drivers/gpu/drm/exynos/exynos_mixer.c | 6 +++--- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 0fe981bc693b..224b9af70224 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -299,7 +299,8 @@ static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc) drm_object_attach_property(&crtc->base, prop, 0); } -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe) +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, + enum exynos_drm_output_type type) { struct exynos_drm_crtc *exynos_crtc; struct drm_plane *plane; @@ -317,6 +318,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe) exynos_crtc->dpms = DRM_MODE_DPMS_OFF; exynos_crtc->manager = manager; exynos_crtc->pipe = pipe; + exynos_crtc->type = type; plane = exynos_plane_init(manager->drm_dev, 1 << pipe, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(plane)) { @@ -435,7 +437,7 @@ int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, struct exynos_drm_crtc *exynos_crtc; exynos_crtc = to_exynos_crtc(crtc); - if (exynos_crtc->manager->type == out_type) + if (exynos_crtc->type == out_type) return exynos_crtc->pipe; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index f1bee8453041..a705941527d1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -17,7 +17,8 @@ #include "exynos_drm_drv.h" -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe); +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, + enum exynos_drm_output_type type); int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 1d024c0421a8..a3ae95f1a40b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -204,7 +204,6 @@ struct exynos_drm_manager_ops { * Exynos drm common manager structure, maps 1:1 with a crtc * * @list: the list entry for this manager - * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI. * @drm_dev: pointer to the drm device * @crtc: crtc object. * @ops: pointer to callbacks for exynos drm specific functionality @@ -212,7 +211,6 @@ struct exynos_drm_manager_ops { */ struct exynos_drm_manager { struct list_head list; - enum exynos_drm_output_type type; struct drm_device *drm_dev; struct drm_crtc *crtc; struct exynos_drm_manager_ops *ops; @@ -228,6 +226,7 @@ enum exynos_crtc_mode { * * @base: crtc object. * @manager: the manager associated with this crtc + * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI. * @pipe: a crtc index created at load() with a new crtc object creation * and the crtc object would be set to private->crtc array * to get a crtc object corresponding to this pipe from private->crtc @@ -241,6 +240,7 @@ enum exynos_crtc_mode { struct exynos_drm_crtc { struct drm_crtc base; struct exynos_drm_manager *manager; + enum exynos_drm_output_type type; unsigned int pipe; unsigned int dpms; enum exynos_crtc_mode mode; diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 4df151ca74f3..1a6e354a9f2d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -1076,7 +1076,8 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm_dev = data; fimd_mgr_initialize(&ctx->manager, drm_dev); - exynos_drm_crtc_create(&ctx->manager, ctx->pipe); + exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + EXYNOS_DISPLAY_TYPE_LCD); if (ctx->display) exynos_drm_create_enc_conn(drm_dev, ctx->display); @@ -1117,11 +1118,10 @@ static int fimd_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - ctx->manager.type = EXYNOS_DISPLAY_TYPE_LCD; ctx->manager.ops = &fimd_manager_ops; ret = exynos_drm_component_add(dev, EXYNOS_DEVICE_TYPE_CRTC, - ctx->manager.type); + EXYNOS_DISPLAY_TYPE_LCD); if (ret) return ret; diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 785d2fe47fe0..3cee0fd8f626 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -558,7 +558,8 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) vidi_mgr_initialize(&ctx->manager, drm_dev); - ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe); + ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + EXYNOS_DISPLAY_TYPE_VIDI); if (ret) { DRM_ERROR("failed to create crtc.\n"); return ret; @@ -593,7 +594,6 @@ static int vidi_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - ctx->manager.type = EXYNOS_DISPLAY_TYPE_VIDI; ctx->manager.ops = &vidi_manager_ops; ctx->display.type = EXYNOS_DISPLAY_TYPE_VIDI; ctx->display.ops = &vidi_display_ops; @@ -601,7 +601,7 @@ static int vidi_probe(struct platform_device *pdev) ctx->pdev = pdev; ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, - ctx->manager.type); + EXYNOS_DISPLAY_TYPE_VIDI); if (ret) return ret; diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 57c4622f9d41..50ae1e3d9578 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -1261,7 +1261,8 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) if (ret) return ret; - ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe); + ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + EXYNOS_DISPLAY_TYPE_HDMI); if (ret) { mixer_mgr_remove(&ctx->manager); return ret; @@ -1297,7 +1298,6 @@ static int mixer_probe(struct platform_device *pdev) mutex_init(&ctx->mixer_mutex); - ctx->manager.type = EXYNOS_DISPLAY_TYPE_HDMI; ctx->manager.ops = &mixer_manager_ops; if (dev->of_node) { @@ -1321,7 +1321,7 @@ static int mixer_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CRTC, - ctx->manager.type); + EXYNOS_DISPLAY_TYPE_HDMI); if (ret) return ret; From eb88e422c502a7a1628cc919020e2ebf59450d4d Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Wed, 26 Nov 2014 16:43:27 -0200 Subject: [PATCH 17/22] drm/exynos: remove drm_dev from struct exynos_drm_manager manager-drm_dev is only accessed by exynos_drm_crtc_create() so this patch pass drm_dev as argument on exynos_drm_crtc_create() and remove it from struct exynos_drm_manager. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 9 +++++---- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 3 ++- drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 - drivers/gpu/drm/exynos/exynos_drm_fimd.c | 4 ++-- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 4 ++-- drivers/gpu/drm/exynos/exynos_mixer.c | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 224b9af70224..1eb5750a59c9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -299,12 +299,13 @@ static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc) drm_object_attach_property(&crtc->base, prop, 0); } -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, + struct drm_device *drm_dev, int pipe, enum exynos_drm_output_type type) { struct exynos_drm_crtc *exynos_crtc; struct drm_plane *plane; - struct exynos_drm_private *private = manager->drm_dev->dev_private; + struct exynos_drm_private *private = drm_dev->dev_private; struct drm_crtc *crtc; int ret; @@ -319,7 +320,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, exynos_crtc->manager = manager; exynos_crtc->pipe = pipe; exynos_crtc->type = type; - plane = exynos_plane_init(manager->drm_dev, 1 << pipe, + plane = exynos_plane_init(drm_dev, 1 << pipe, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(plane)) { ret = PTR_ERR(plane); @@ -331,7 +332,7 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, private->crtc[pipe] = crtc; - ret = drm_crtc_init_with_planes(manager->drm_dev, crtc, plane, NULL, + ret = drm_crtc_init_with_planes(drm_dev, crtc, plane, NULL, &exynos_crtc_funcs); if (ret < 0) goto err_crtc; diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index a705941527d1..d7690e9e3e20 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -17,7 +17,8 @@ #include "exynos_drm_drv.h" -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, int pipe, +int exynos_drm_crtc_create(struct exynos_drm_manager *manager, + struct drm_device *drm_dev, int pipe, enum exynos_drm_output_type type); int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index a3ae95f1a40b..2d801a8402d2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -211,7 +211,6 @@ struct exynos_drm_manager_ops { */ struct exynos_drm_manager { struct list_head list; - struct drm_device *drm_dev; struct drm_crtc *crtc; struct exynos_drm_manager_ops *ops; }; diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 1a6e354a9f2d..f67f11c702ca 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -298,7 +298,7 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, struct exynos_drm_private *priv; priv = drm_dev->dev_private; - mgr->drm_dev = ctx->drm_dev = drm_dev; + ctx->drm_dev = drm_dev; ctx->pipe = priv->pipe++; /* attach this sub driver to iommu mapping if supported. */ @@ -1076,7 +1076,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm_dev = data; fimd_mgr_initialize(&ctx->manager, drm_dev); - exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, EXYNOS_DISPLAY_TYPE_LCD); if (ctx->display) exynos_drm_create_enc_conn(drm_dev, ctx->display); diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 3cee0fd8f626..03687db8f565 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -301,7 +301,7 @@ static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, struct vidi_context *ctx = manager_to_vidi(mgr); struct exynos_drm_private *priv = drm_dev->dev_private; - mgr->drm_dev = ctx->drm_dev = drm_dev; + ctx->drm_dev = drm_dev; ctx->pipe = priv->pipe++; return 0; @@ -558,7 +558,7 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) vidi_mgr_initialize(&ctx->manager, drm_dev); - ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + ret = exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, EXYNOS_DISPLAY_TYPE_VIDI); if (ret) { DRM_ERROR("failed to create crtc.\n"); diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 50ae1e3d9578..c8adcf2d9d23 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -862,7 +862,7 @@ static int mixer_initialize(struct exynos_drm_manager *mgr, struct exynos_drm_private *priv; priv = drm_dev->dev_private; - mgr->drm_dev = mixer_ctx->drm_dev = drm_dev; + mixer_ctx->drm_dev = drm_dev; mixer_ctx->pipe = priv->pipe++; /* acquire resources: regs, irqs, clocks */ @@ -1261,7 +1261,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) if (ret) return ret; - ret = exynos_drm_crtc_create(&ctx->manager, ctx->pipe, + ret = exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, EXYNOS_DISPLAY_TYPE_HDMI); if (ret) { mixer_mgr_remove(&ctx->manager); From 93bca243ec96f0acb949d4aa2306f07467e89985 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Sun, 18 Jan 2015 18:16:23 +0900 Subject: [PATCH 18/22] drm/exynos: remove struct exynos_drm_manager exynos_drm_manager was just a redundant struct to represent the crtc as well. In this commit we merge exynos_drm_manager into exynos_drm_crtc to remove an unnecessary level of indirection easing the understand of the flow on exynos. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 67 ++++++------ drivers/gpu/drm/exynos/exynos_drm_crtc.h | 8 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 51 ++++----- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 121 +++++++++++----------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 26 ++--- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 79 +++++++------- drivers/gpu/drm/exynos/exynos_mixer.c | 103 +++++++++--------- 7 files changed, 211 insertions(+), 244 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 1eb5750a59c9..9e8ed5fd60ae 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -23,7 +23,6 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - struct exynos_drm_manager *manager = exynos_crtc->manager; DRM_DEBUG_KMS("crtc[%d] mode[%d]\n", crtc->base.id, mode); @@ -41,8 +40,8 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) drm_crtc_vblank_off(crtc); } - if (manager->ops->dpms) - manager->ops->dpms(manager, mode); + if (exynos_crtc->ops->dpms) + exynos_crtc->ops->dpms(exynos_crtc, mode); exynos_crtc->dpms = mode; @@ -58,16 +57,15 @@ static void exynos_drm_crtc_prepare(struct drm_crtc *crtc) static void exynos_drm_crtc_commit(struct drm_crtc *crtc) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - struct exynos_drm_manager *manager = exynos_crtc->manager; struct exynos_drm_plane *exynos_plane = to_exynos_plane(crtc->primary); exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON); - if (manager->ops->win_commit) - manager->ops->win_commit(manager, exynos_plane->zpos); + if (exynos_crtc->ops->win_commit) + exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos); - if (manager->ops->commit) - manager->ops->commit(manager); + if (exynos_crtc->ops->commit) + exynos_crtc->ops->commit(exynos_crtc); exynos_plane_dpms(crtc->primary, DRM_MODE_DPMS_ON); } @@ -78,10 +76,10 @@ exynos_drm_crtc_mode_fixup(struct drm_crtc *crtc, struct drm_display_mode *adjusted_mode) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - struct exynos_drm_manager *manager = exynos_crtc->manager; - if (manager->ops->mode_fixup) - return manager->ops->mode_fixup(manager, mode, adjusted_mode); + if (exynos_crtc->ops->mode_fixup) + return exynos_crtc->ops->mode_fixup(exynos_crtc, mode, + adjusted_mode); return true; } @@ -92,7 +90,6 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_framebuffer *old_fb) { struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - struct exynos_drm_manager *manager = exynos_crtc->manager; struct drm_framebuffer *fb = crtc->primary->fb; unsigned int crtc_w; unsigned int crtc_h; @@ -106,8 +103,8 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, crtc_w = fb->width - x; crtc_h = fb->height - y; - if (manager->ops->mode_set) - manager->ops->mode_set(manager, &crtc->mode); + if (exynos_crtc->ops->mode_set) + exynos_crtc->ops->mode_set(exynos_crtc, &crtc->mode); return exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0, crtc_w, crtc_h, x, y, crtc_w, crtc_h); @@ -299,9 +296,11 @@ static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc) drm_object_attach_property(&crtc->base, prop, 0); } -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, - struct drm_device *drm_dev, int pipe, - enum exynos_drm_output_type type) +struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, + int pipe, + enum exynos_drm_output_type type, + struct exynos_drm_crtc_ops *ops, + void *ctx) { struct exynos_drm_crtc *exynos_crtc; struct drm_plane *plane; @@ -311,15 +310,16 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL); if (!exynos_crtc) - return -ENOMEM; + return ERR_PTR(-ENOMEM); init_waitqueue_head(&exynos_crtc->pending_flip_queue); atomic_set(&exynos_crtc->pending_flip, 0); exynos_crtc->dpms = DRM_MODE_DPMS_OFF; - exynos_crtc->manager = manager; exynos_crtc->pipe = pipe; exynos_crtc->type = type; + exynos_crtc->ops = ops; + exynos_crtc->ctx = ctx; plane = exynos_plane_init(drm_dev, 1 << pipe, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(plane)) { @@ -327,7 +327,6 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, goto err_plane; } - manager->crtc = &exynos_crtc->base; crtc = &exynos_crtc->base; private->crtc[pipe] = crtc; @@ -341,13 +340,13 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager, exynos_drm_crtc_attach_mode_property(crtc); - return 0; + return exynos_crtc; err_crtc: plane->funcs->destroy(plane); err_plane: kfree(exynos_crtc); - return ret; + return ERR_PTR(ret); } int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe) @@ -355,13 +354,12 @@ int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe) struct exynos_drm_private *private = dev->dev_private; struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(private->crtc[pipe]); - struct exynos_drm_manager *manager = exynos_crtc->manager; if (exynos_crtc->dpms != DRM_MODE_DPMS_ON) return -EPERM; - if (manager->ops->enable_vblank) - manager->ops->enable_vblank(manager); + if (exynos_crtc->ops->enable_vblank) + exynos_crtc->ops->enable_vblank(exynos_crtc); return 0; } @@ -371,13 +369,12 @@ void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe) struct exynos_drm_private *private = dev->dev_private; struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(private->crtc[pipe]); - struct exynos_drm_manager *manager = exynos_crtc->manager; if (exynos_crtc->dpms != DRM_MODE_DPMS_ON) return; - if (manager->ops->disable_vblank) - manager->ops->disable_vblank(manager); + if (exynos_crtc->ops->disable_vblank) + exynos_crtc->ops->disable_vblank(exynos_crtc); } void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe) @@ -408,7 +405,7 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe) void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb) { - struct exynos_drm_manager *manager; + struct exynos_drm_crtc *exynos_crtc; struct drm_device *dev = fb->dev; struct drm_crtc *crtc; @@ -417,15 +414,15 @@ void exynos_drm_crtc_complete_scanout(struct drm_framebuffer *fb) * for all encoders. */ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - manager = to_exynos_crtc(crtc)->manager; + exynos_crtc = to_exynos_crtc(crtc); /* * wait for vblank interrupt * - this makes sure that overlay data are updated to * real hardware. */ - if (manager->ops->wait_for_vblank) - manager->ops->wait_for_vblank(manager); + if (exynos_crtc->ops->wait_for_vblank) + exynos_crtc->ops->wait_for_vblank(exynos_crtc); } } @@ -447,8 +444,8 @@ int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev, void exynos_drm_crtc_te_handler(struct drm_crtc *crtc) { - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - if (manager->ops->te_handler) - manager->ops->te_handler(manager); + if (exynos_crtc->ops->te_handler) + exynos_crtc->ops->te_handler(exynos_crtc); } diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h index d7690e9e3e20..6258b800aab8 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h @@ -17,9 +17,11 @@ #include "exynos_drm_drv.h" -int exynos_drm_crtc_create(struct exynos_drm_manager *manager, - struct drm_device *drm_dev, int pipe, - enum exynos_drm_output_type type); +struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, + int pipe, + enum exynos_drm_output_type type, + struct exynos_drm_crtc_ops *ops, + void *context); int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int pipe); void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 2d801a8402d2..4c930d066196 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -163,7 +163,7 @@ struct exynos_drm_display { }; /* - * Exynos drm manager ops + * Exynos drm crtc ops * * @dpms: control device power. * @mode_fixup: fix mode data before applying it @@ -180,39 +180,24 @@ struct exynos_drm_display { * @te_handler: trigger to transfer video image at the tearing effect * synchronization signal if there is a page flip request. */ -struct exynos_drm_manager; -struct exynos_drm_manager_ops { - void (*dpms)(struct exynos_drm_manager *mgr, int mode); - bool (*mode_fixup)(struct exynos_drm_manager *mgr, +struct exynos_drm_crtc; +struct exynos_drm_crtc_ops { + void (*dpms)(struct exynos_drm_crtc *crtc, int mode); + bool (*mode_fixup)(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); - void (*mode_set)(struct exynos_drm_manager *mgr, + void (*mode_set)(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode); - void (*commit)(struct exynos_drm_manager *mgr); - int (*enable_vblank)(struct exynos_drm_manager *mgr); - void (*disable_vblank)(struct exynos_drm_manager *mgr); - void (*wait_for_vblank)(struct exynos_drm_manager *mgr); - void (*win_mode_set)(struct exynos_drm_manager *mgr, + void (*commit)(struct exynos_drm_crtc *crtc); + int (*enable_vblank)(struct exynos_drm_crtc *crtc); + void (*disable_vblank)(struct exynos_drm_crtc *crtc); + void (*wait_for_vblank)(struct exynos_drm_crtc *crtc); + void (*win_mode_set)(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane); - void (*win_commit)(struct exynos_drm_manager *mgr, int zpos); - void (*win_enable)(struct exynos_drm_manager *mgr, int zpos); - void (*win_disable)(struct exynos_drm_manager *mgr, int zpos); - void (*te_handler)(struct exynos_drm_manager *mgr); -}; - -/* - * Exynos drm common manager structure, maps 1:1 with a crtc - * - * @list: the list entry for this manager - * @drm_dev: pointer to the drm device - * @crtc: crtc object. - * @ops: pointer to callbacks for exynos drm specific functionality - * @ctx: A pointer to the manager's implementation specific context - */ -struct exynos_drm_manager { - struct list_head list; - struct drm_crtc *crtc; - struct exynos_drm_manager_ops *ops; + void (*win_commit)(struct exynos_drm_crtc *crtc, int zpos); + void (*win_enable)(struct exynos_drm_crtc *crtc, int zpos); + void (*win_disable)(struct exynos_drm_crtc *crtc, int zpos); + void (*te_handler)(struct exynos_drm_crtc *crtc); }; enum exynos_crtc_mode { @@ -224,7 +209,6 @@ enum exynos_crtc_mode { * Exynos specific crtc structure. * * @base: crtc object. - * @manager: the manager associated with this crtc * @type: one of EXYNOS_DISPLAY_TYPE_LCD and HDMI. * @pipe: a crtc index created at load() with a new crtc object creation * and the crtc object would be set to private->crtc array @@ -235,16 +219,19 @@ enum exynos_crtc_mode { * this pipe value. * @dpms: store the crtc dpms value * @mode: store the crtc mode value + * @ops: pointer to callbacks for exynos drm specific functionality + * @ctx: A pointer to the crtc's implementation specific context */ struct exynos_drm_crtc { struct drm_crtc base; - struct exynos_drm_manager *manager; enum exynos_drm_output_type type; unsigned int pipe; unsigned int dpms; enum exynos_crtc_mode mode; wait_queue_head_t pending_flip_queue; atomic_t pending_flip; + struct exynos_drm_crtc_ops *ops; + void *ctx; }; struct exynos_drm_g2d_private { diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index f67f11c702ca..9acd6890a3d6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -157,9 +157,9 @@ struct fimd_win_data { }; struct fimd_context { - struct exynos_drm_manager manager; struct device *dev; struct drm_device *drm_dev; + struct exynos_drm_crtc *crtc; struct clk *bus_clk; struct clk *lcd_clk; void __iomem *regs; @@ -185,11 +185,6 @@ struct fimd_context { struct exynos_drm_display *display; }; -static inline struct fimd_context *mgr_to_fimd(struct exynos_drm_manager *mgr) -{ - return container_of(mgr, struct fimd_context, manager); -} - static const struct of_device_id fimd_driver_dt_match[] = { { .compatible = "samsung,s3c6400-fimd", .data = &s3c64xx_fimd_driver_data }, @@ -214,9 +209,9 @@ static inline struct fimd_driver_data *drm_fimd_get_driver_data( return (struct fimd_driver_data *)of_id->data; } -static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr) +static void fimd_wait_for_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; if (ctx->suspended) return; @@ -259,9 +254,9 @@ static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, int win, writel(val, ctx->regs + SHADOWCON); } -static void fimd_clear_channel(struct exynos_drm_manager *mgr) +static void fimd_clear_channel(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; int win, ch_enabled = 0; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -286,15 +281,14 @@ static void fimd_clear_channel(struct exynos_drm_manager *mgr) unsigned int state = ctx->suspended; ctx->suspended = 0; - fimd_wait_for_vblank(mgr); + fimd_wait_for_vblank(crtc); ctx->suspended = state; } } -static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, +static int fimd_ctx_initialize(struct fimd_context *ctx, struct drm_device *drm_dev) { - struct fimd_context *ctx = mgr_to_fimd(mgr); struct exynos_drm_private *priv; priv = drm_dev->dev_private; @@ -307,17 +301,15 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, * If any channel is already active, iommu will throw * a PAGE FAULT when enabled. So clear any channel if enabled. */ - fimd_clear_channel(mgr); + fimd_clear_channel(ctx->crtc); drm_iommu_attach_device(ctx->drm_dev, ctx->dev); } return 0; } -static void fimd_mgr_remove(struct exynos_drm_manager *mgr) +static void fimd_ctx_remove(struct fimd_context *ctx) { - struct fimd_context *ctx = mgr_to_fimd(mgr); - /* detach this sub driver from iommu mapping if supported. */ if (is_drm_iommu_supported(ctx->drm_dev)) drm_iommu_detach_device(ctx->drm_dev, ctx->dev); @@ -343,7 +335,7 @@ static u32 fimd_calc_clkdiv(struct fimd_context *ctx, return (clkdiv < 0x100) ? clkdiv : 0xff; } -static bool fimd_mode_fixup(struct exynos_drm_manager *mgr, +static bool fimd_mode_fixup(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { @@ -353,17 +345,17 @@ static bool fimd_mode_fixup(struct exynos_drm_manager *mgr, return true; } -static void fimd_mode_set(struct exynos_drm_manager *mgr, +static void fimd_mode_set(struct exynos_drm_crtc *crtc, const struct drm_display_mode *in_mode) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; drm_mode_copy(&ctx->mode, in_mode); } -static void fimd_commit(struct exynos_drm_manager *mgr) +static void fimd_commit(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct drm_display_mode *mode = &ctx->mode; struct fimd_driver_data *driver_data = ctx->driver_data; void *timing_base = ctx->regs + driver_data->timing_base; @@ -461,9 +453,9 @@ static void fimd_commit(struct exynos_drm_manager *mgr) writel(val, ctx->regs + VIDCON0); } -static int fimd_enable_vblank(struct exynos_drm_manager *mgr) +static int fimd_enable_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; u32 val; if (ctx->suspended) @@ -493,9 +485,9 @@ static int fimd_enable_vblank(struct exynos_drm_manager *mgr) return 0; } -static void fimd_disable_vblank(struct exynos_drm_manager *mgr) +static void fimd_disable_vblank(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; u32 val; if (ctx->suspended) @@ -517,10 +509,10 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr) } } -static void fimd_win_mode_set(struct exynos_drm_manager *mgr, +static void fimd_win_mode_set(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int win; unsigned long offset; @@ -676,9 +668,9 @@ static void fimd_shadow_protect_win(struct fimd_context *ctx, writel(val, ctx->regs + reg); } -static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos) +static void fimd_win_commit(struct exynos_drm_crtc *crtc, int zpos) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int win = zpos; unsigned long val, alpha, size; @@ -799,9 +791,9 @@ static void fimd_win_commit(struct exynos_drm_manager *mgr, int zpos) atomic_set(&ctx->win_updated, 1); } -static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos) +static void fimd_win_disable(struct exynos_drm_crtc *crtc, int zpos) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int win = zpos; @@ -833,9 +825,9 @@ static void fimd_win_disable(struct exynos_drm_manager *mgr, int zpos) win_data->enabled = false; } -static void fimd_window_suspend(struct exynos_drm_manager *mgr) +static void fimd_window_suspend(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int i; @@ -843,13 +835,13 @@ static void fimd_window_suspend(struct exynos_drm_manager *mgr) win_data = &ctx->win_data[i]; win_data->resume = win_data->enabled; if (win_data->enabled) - fimd_win_disable(mgr, i); + fimd_win_disable(crtc, i); } } -static void fimd_window_resume(struct exynos_drm_manager *mgr) +static void fimd_window_resume(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int i; @@ -860,26 +852,26 @@ static void fimd_window_resume(struct exynos_drm_manager *mgr) } } -static void fimd_apply(struct exynos_drm_manager *mgr) +static void fimd_apply(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; struct fimd_win_data *win_data; int i; for (i = 0; i < WINDOWS_NR; i++) { win_data = &ctx->win_data[i]; if (win_data->enabled) - fimd_win_commit(mgr, i); + fimd_win_commit(crtc, i); else - fimd_win_disable(mgr, i); + fimd_win_disable(crtc, i); } - fimd_commit(mgr); + fimd_commit(crtc); } -static int fimd_poweron(struct exynos_drm_manager *mgr) +static int fimd_poweron(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; int ret; if (!ctx->suspended) @@ -903,16 +895,16 @@ static int fimd_poweron(struct exynos_drm_manager *mgr) /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) { - ret = fimd_enable_vblank(mgr); + ret = fimd_enable_vblank(crtc); if (ret) { DRM_ERROR("Failed to re-enable vblank [%d]\n", ret); goto enable_vblank_err; } } - fimd_window_resume(mgr); + fimd_window_resume(crtc); - fimd_apply(mgr); + fimd_apply(crtc); return 0; @@ -925,9 +917,9 @@ static int fimd_poweron(struct exynos_drm_manager *mgr) return ret; } -static int fimd_poweroff(struct exynos_drm_manager *mgr) +static int fimd_poweroff(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; if (ctx->suspended) return 0; @@ -937,7 +929,7 @@ static int fimd_poweroff(struct exynos_drm_manager *mgr) * suspend that connector. Otherwise we might try to scan from * a destroyed buffer later. */ - fimd_window_suspend(mgr); + fimd_window_suspend(crtc); clk_disable_unprepare(ctx->lcd_clk); clk_disable_unprepare(ctx->bus_clk); @@ -948,18 +940,18 @@ static int fimd_poweroff(struct exynos_drm_manager *mgr) return 0; } -static void fimd_dpms(struct exynos_drm_manager *mgr, int mode) +static void fimd_dpms(struct exynos_drm_crtc *crtc, int mode) { DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode); switch (mode) { case DRM_MODE_DPMS_ON: - fimd_poweron(mgr); + fimd_poweron(crtc); break; case DRM_MODE_DPMS_STANDBY: case DRM_MODE_DPMS_SUSPEND: case DRM_MODE_DPMS_OFF: - fimd_poweroff(mgr); + fimd_poweroff(crtc); break; default: DRM_DEBUG_KMS("unspecified mode %d\n", mode); @@ -996,9 +988,9 @@ static void fimd_trigger(struct device *dev) atomic_set(&ctx->triggering, 0); } -static void fimd_te_handler(struct exynos_drm_manager *mgr) +static void fimd_te_handler(struct exynos_drm_crtc *crtc) { - struct fimd_context *ctx = mgr_to_fimd(mgr); + struct fimd_context *ctx = crtc->ctx; /* Checks the crtc is detached already from encoder */ if (ctx->pipe < 0 || !ctx->drm_dev) @@ -1021,7 +1013,7 @@ static void fimd_te_handler(struct exynos_drm_manager *mgr) drm_handle_vblank(ctx->drm_dev, ctx->pipe); } -static struct exynos_drm_manager_ops fimd_manager_ops = { +static struct exynos_drm_crtc_ops fimd_crtc_ops = { .dpms = fimd_dpms, .mode_fixup = fimd_mode_fixup, .mode_set = fimd_mode_set, @@ -1075,9 +1067,14 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) struct fimd_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - fimd_mgr_initialize(&ctx->manager, drm_dev); - exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, - EXYNOS_DISPLAY_TYPE_LCD); + ctx->crtc = exynos_drm_crtc_create(drm_dev, ctx->pipe, + EXYNOS_DISPLAY_TYPE_LCD, + &fimd_crtc_ops, ctx); + if (IS_ERR(ctx->crtc)) + return PTR_ERR(ctx->crtc); + + fimd_ctx_initialize(ctx, drm_dev); + if (ctx->display) exynos_drm_create_enc_conn(drm_dev, ctx->display); @@ -1090,12 +1087,12 @@ static void fimd_unbind(struct device *dev, struct device *master, { struct fimd_context *ctx = dev_get_drvdata(dev); - fimd_dpms(&ctx->manager, DRM_MODE_DPMS_OFF); + fimd_dpms(ctx->crtc, DRM_MODE_DPMS_OFF); if (ctx->display) exynos_dpi_remove(ctx->display); - fimd_mgr_remove(&ctx->manager); + fimd_ctx_remove(ctx); } static const struct component_ops fimd_component_ops = { @@ -1118,8 +1115,6 @@ static int fimd_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - ctx->manager.ops = &fimd_manager_ops; - ret = exynos_drm_component_add(dev, EXYNOS_DEVICE_TYPE_CRTC, EXYNOS_DISPLAY_TYPE_LCD); if (ret) diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index dadd30631c18..95442e69db75 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -68,7 +68,7 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_w, uint32_t src_h) { struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); unsigned int actual_w; unsigned int actual_h; int nr; @@ -133,8 +133,8 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, plane->crtc = crtc; - if (manager->ops->win_mode_set) - manager->ops->win_mode_set(manager, exynos_plane); + if (exynos_crtc->ops->win_mode_set) + exynos_crtc->ops->win_mode_set(exynos_crtc, exynos_plane); return 0; } @@ -142,24 +142,24 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, void exynos_plane_dpms(struct drm_plane *plane, int mode) { struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_manager *manager; + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(plane->crtc); if (mode == DRM_MODE_DPMS_ON) { if (exynos_plane->enabled) return; - manager = to_exynos_crtc(plane->crtc)->manager; - if (manager->ops->win_enable) - manager->ops->win_enable(manager, exynos_plane->zpos); + if (exynos_crtc->ops->win_enable) + exynos_crtc->ops->win_enable(exynos_crtc, + exynos_plane->zpos); exynos_plane->enabled = true; } else { if (!exynos_plane->enabled) return; - manager = to_exynos_crtc(plane->crtc)->manager; - if (manager->ops->win_disable) - manager->ops->win_disable(manager, exynos_plane->zpos); + if (exynos_crtc->ops->win_disable) + exynos_crtc->ops->win_disable(exynos_crtc, + exynos_plane->zpos); exynos_plane->enabled = false; } @@ -173,7 +173,7 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_w, uint32_t src_h) { - struct exynos_drm_manager *manager = to_exynos_crtc(crtc)->manager; + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); int ret; @@ -183,8 +183,8 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, if (ret < 0) return ret; - if (manager->ops->win_commit) - manager->ops->win_commit(manager, exynos_plane->zpos); + if (exynos_crtc->ops->win_commit) + exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos); return 0; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c index 03687db8f565..9c8300edd348 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c @@ -47,11 +47,10 @@ struct vidi_win_data { }; struct vidi_context { - struct exynos_drm_manager manager; struct exynos_drm_display display; struct platform_device *pdev; struct drm_device *drm_dev; - struct drm_crtc *crtc; + struct exynos_drm_crtc *crtc; struct drm_encoder *encoder; struct drm_connector connector; struct vidi_win_data win_data[WINDOWS_NR]; @@ -68,11 +67,6 @@ struct vidi_context { int pipe; }; -static inline struct vidi_context *manager_to_vidi(struct exynos_drm_manager *m) -{ - return container_of(m, struct vidi_context, manager); -} - static inline struct vidi_context *display_to_vidi(struct exynos_drm_display *d) { return container_of(d, struct vidi_context, display); @@ -103,23 +97,23 @@ static const char fake_edid_info[] = { 0x00, 0x00, 0x00, 0x06 }; -static void vidi_apply(struct exynos_drm_manager *mgr) +static void vidi_apply(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = manager_to_vidi(mgr); - struct exynos_drm_manager_ops *mgr_ops = mgr->ops; + struct vidi_context *ctx = crtc->ctx; + struct exynos_drm_crtc_ops *crtc_ops = crtc->ops; struct vidi_win_data *win_data; int i; for (i = 0; i < WINDOWS_NR; i++) { win_data = &ctx->win_data[i]; - if (win_data->enabled && (mgr_ops && mgr_ops->win_commit)) - mgr_ops->win_commit(mgr, i); + if (win_data->enabled && (crtc_ops && crtc_ops->win_commit)) + crtc_ops->win_commit(crtc, i); } } -static int vidi_enable_vblank(struct exynos_drm_manager *mgr) +static int vidi_enable_vblank(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; if (ctx->suspended) return -EPERM; @@ -132,16 +126,16 @@ static int vidi_enable_vblank(struct exynos_drm_manager *mgr) /* * in case of page flip request, vidi_finish_pageflip function * will not be called because direct_vblank is true and then - * that function will be called by manager_ops->win_commit callback + * that function will be called by crtc_ops->win_commit callback */ schedule_work(&ctx->work); return 0; } -static void vidi_disable_vblank(struct exynos_drm_manager *mgr) +static void vidi_disable_vblank(struct exynos_drm_crtc *crtc) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; if (ctx->suspended) return; @@ -150,10 +144,10 @@ static void vidi_disable_vblank(struct exynos_drm_manager *mgr) ctx->vblank_on = false; } -static void vidi_win_mode_set(struct exynos_drm_manager *mgr, +static void vidi_win_mode_set(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; struct vidi_win_data *win_data; int win; unsigned long offset; @@ -203,9 +197,9 @@ static void vidi_win_mode_set(struct exynos_drm_manager *mgr, plane->fb_width, plane->crtc_width); } -static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos) +static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; struct vidi_win_data *win_data; int win = zpos; @@ -228,9 +222,9 @@ static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos) schedule_work(&ctx->work); } -static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos) +static void vidi_win_disable(struct exynos_drm_crtc *crtc, int zpos) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; struct vidi_win_data *win_data; int win = zpos; @@ -246,9 +240,9 @@ static void vidi_win_disable(struct exynos_drm_manager *mgr, int zpos) /* TODO. */ } -static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable) +static int vidi_power_on(struct exynos_drm_crtc *crtc, bool enable) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -260,9 +254,9 @@ static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable) /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) - vidi_enable_vblank(mgr); + vidi_enable_vblank(crtc); - vidi_apply(mgr); + vidi_apply(crtc); } else { ctx->suspended = true; } @@ -270,9 +264,9 @@ static int vidi_power_on(struct exynos_drm_manager *mgr, bool enable) return 0; } -static void vidi_dpms(struct exynos_drm_manager *mgr, int mode) +static void vidi_dpms(struct exynos_drm_crtc *crtc, int mode) { - struct vidi_context *ctx = manager_to_vidi(mgr); + struct vidi_context *ctx = crtc->ctx; DRM_DEBUG_KMS("%d\n", mode); @@ -280,12 +274,12 @@ static void vidi_dpms(struct exynos_drm_manager *mgr, int mode) switch (mode) { case DRM_MODE_DPMS_ON: - vidi_power_on(mgr, true); + vidi_power_on(crtc, true); break; case DRM_MODE_DPMS_STANDBY: case DRM_MODE_DPMS_SUSPEND: case DRM_MODE_DPMS_OFF: - vidi_power_on(mgr, false); + vidi_power_on(crtc, false); break; default: DRM_DEBUG_KMS("unspecified mode %d\n", mode); @@ -295,10 +289,9 @@ static void vidi_dpms(struct exynos_drm_manager *mgr, int mode) mutex_unlock(&ctx->lock); } -static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, +static int vidi_ctx_initialize(struct vidi_context *ctx, struct drm_device *drm_dev) { - struct vidi_context *ctx = manager_to_vidi(mgr); struct exynos_drm_private *priv = drm_dev->dev_private; ctx->drm_dev = drm_dev; @@ -307,7 +300,7 @@ static int vidi_mgr_initialize(struct exynos_drm_manager *mgr, return 0; } -static struct exynos_drm_manager_ops vidi_manager_ops = { +static struct exynos_drm_crtc_ops vidi_crtc_ops = { .dpms = vidi_dpms, .enable_vblank = vidi_enable_vblank, .disable_vblank = vidi_disable_vblank, @@ -553,22 +546,21 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) { struct vidi_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct drm_crtc *crtc = ctx->crtc; int ret; - vidi_mgr_initialize(&ctx->manager, drm_dev); - - ret = exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, - EXYNOS_DISPLAY_TYPE_VIDI); - if (ret) { + ctx->crtc = exynos_drm_crtc_create(drm_dev, ctx->pipe, + EXYNOS_DISPLAY_TYPE_VIDI, + &vidi_crtc_ops, ctx); + if (IS_ERR(ctx->crtc)) { DRM_ERROR("failed to create crtc.\n"); - return ret; + return PTR_ERR(ctx->crtc); } + vidi_ctx_initialize(ctx, drm_dev); + ret = exynos_drm_create_enc_conn(drm_dev, &ctx->display); if (ret) { - crtc->funcs->destroy(crtc); - DRM_ERROR("failed to create encoder and connector.\n"); + ctx->crtc->base.funcs->destroy(&ctx->crtc->base); return ret; } @@ -594,7 +586,6 @@ static int vidi_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; - ctx->manager.ops = &vidi_manager_ops; ctx->display.type = EXYNOS_DISPLAY_TYPE_VIDI; ctx->display.ops = &vidi_display_ops; ctx->default_win = 0; diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index c8adcf2d9d23..ed44cd4f01f7 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -84,10 +84,10 @@ enum mixer_version_id { }; struct mixer_context { - struct exynos_drm_manager manager; struct platform_device *pdev; struct device *dev; struct drm_device *drm_dev; + struct exynos_drm_crtc *crtc; int pipe; bool interlace; bool powered; @@ -103,11 +103,6 @@ struct mixer_context { atomic_t wait_vsync_event; }; -static inline struct mixer_context *mgr_to_mixer(struct exynos_drm_manager *mgr) -{ - return container_of(mgr, struct mixer_context, manager); -} - struct mixer_drv_data { enum mixer_version_id version; bool is_vp_enabled; @@ -854,11 +849,10 @@ static int vp_resources_init(struct mixer_context *mixer_ctx) return 0; } -static int mixer_initialize(struct exynos_drm_manager *mgr, +static int mixer_initialize(struct mixer_context *mixer_ctx, struct drm_device *drm_dev) { int ret; - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); struct exynos_drm_private *priv; priv = drm_dev->dev_private; @@ -887,17 +881,15 @@ static int mixer_initialize(struct exynos_drm_manager *mgr, return drm_iommu_attach_device(mixer_ctx->drm_dev, mixer_ctx->dev); } -static void mixer_mgr_remove(struct exynos_drm_manager *mgr) +static void mixer_ctx_remove(struct mixer_context *mixer_ctx) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); - if (is_drm_iommu_supported(mixer_ctx->drm_dev)) drm_iommu_detach_device(mixer_ctx->drm_dev, mixer_ctx->dev); } -static int mixer_enable_vblank(struct exynos_drm_manager *mgr) +static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_resources *res = &mixer_ctx->mixer_res; if (!mixer_ctx->powered) { @@ -912,19 +904,19 @@ static int mixer_enable_vblank(struct exynos_drm_manager *mgr) return 0; } -static void mixer_disable_vblank(struct exynos_drm_manager *mgr) +static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_resources *res = &mixer_ctx->mixer_res; /* disable vsync interrupt */ mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC); } -static void mixer_win_mode_set(struct exynos_drm_manager *mgr, +static void mixer_win_mode_set(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; struct hdmi_win_data *win_data; int win; @@ -973,9 +965,9 @@ static void mixer_win_mode_set(struct exynos_drm_manager *mgr, win_data->scan_flags = plane->scan_flag; } -static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos) +static void mixer_win_commit(struct exynos_drm_crtc *crtc, int zpos) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos; DRM_DEBUG_KMS("win: %d\n", win); @@ -995,9 +987,9 @@ static void mixer_win_commit(struct exynos_drm_manager *mgr, int zpos) mixer_ctx->win_data[win].enabled = true; } -static void mixer_win_disable(struct exynos_drm_manager *mgr, int zpos) +static void mixer_win_disable(struct exynos_drm_crtc *crtc, int zpos) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_resources *res = &mixer_ctx->mixer_res; int win = zpos == DEFAULT_ZPOS ? MIXER_DEFAULT_WIN : zpos; unsigned long flags; @@ -1023,9 +1015,9 @@ static void mixer_win_disable(struct exynos_drm_manager *mgr, int zpos) mixer_ctx->win_data[win].enabled = false; } -static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr) +static void mixer_wait_for_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = mgr_to_mixer(mgr); + struct mixer_context *mixer_ctx = crtc->ctx; int err; mutex_lock(&mixer_ctx->mixer_mutex); @@ -1035,7 +1027,7 @@ static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr) } mutex_unlock(&mixer_ctx->mixer_mutex); - err = drm_vblank_get(mgr->crtc->dev, mixer_ctx->pipe); + err = drm_vblank_get(mixer_ctx->drm_dev, mixer_ctx->pipe); if (err < 0) { DRM_DEBUG_KMS("failed to acquire vblank counter\n"); return; @@ -1052,26 +1044,26 @@ static void mixer_wait_for_vblank(struct exynos_drm_manager *mgr) HZ/20)) DRM_DEBUG_KMS("vblank wait timed out.\n"); - drm_vblank_put(mgr->crtc->dev, mixer_ctx->pipe); + drm_vblank_put(mixer_ctx->drm_dev, mixer_ctx->pipe); } -static void mixer_window_suspend(struct exynos_drm_manager *mgr) +static void mixer_window_suspend(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = mgr_to_mixer(mgr); + struct mixer_context *ctx = crtc->ctx; struct hdmi_win_data *win_data; int i; for (i = 0; i < MIXER_WIN_NR; i++) { win_data = &ctx->win_data[i]; win_data->resume = win_data->enabled; - mixer_win_disable(mgr, i); + mixer_win_disable(crtc, i); } - mixer_wait_for_vblank(mgr); + mixer_wait_for_vblank(crtc); } -static void mixer_window_resume(struct exynos_drm_manager *mgr) +static void mixer_window_resume(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = mgr_to_mixer(mgr); + struct mixer_context *ctx = crtc->ctx; struct hdmi_win_data *win_data; int i; @@ -1080,13 +1072,13 @@ static void mixer_window_resume(struct exynos_drm_manager *mgr) win_data->enabled = win_data->resume; win_data->resume = false; if (win_data->enabled) - mixer_win_commit(mgr, i); + mixer_win_commit(crtc, i); } } -static void mixer_poweron(struct exynos_drm_manager *mgr) +static void mixer_poweron(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = mgr_to_mixer(mgr); + struct mixer_context *ctx = crtc->ctx; struct mixer_resources *res = &ctx->mixer_res; mutex_lock(&ctx->mixer_mutex); @@ -1115,12 +1107,12 @@ static void mixer_poweron(struct exynos_drm_manager *mgr) mixer_reg_write(res, MXR_INT_EN, ctx->int_en); mixer_win_reset(ctx); - mixer_window_resume(mgr); + mixer_window_resume(crtc); } -static void mixer_poweroff(struct exynos_drm_manager *mgr) +static void mixer_poweroff(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = mgr_to_mixer(mgr); + struct mixer_context *ctx = crtc->ctx; struct mixer_resources *res = &ctx->mixer_res; mutex_lock(&ctx->mixer_mutex); @@ -1131,7 +1123,7 @@ static void mixer_poweroff(struct exynos_drm_manager *mgr) mutex_unlock(&ctx->mixer_mutex); mixer_stop(ctx); - mixer_window_suspend(mgr); + mixer_window_suspend(crtc); ctx->int_en = mixer_reg_read(res, MXR_INT_EN); @@ -1149,16 +1141,16 @@ static void mixer_poweroff(struct exynos_drm_manager *mgr) pm_runtime_put_sync(ctx->dev); } -static void mixer_dpms(struct exynos_drm_manager *mgr, int mode) +static void mixer_dpms(struct exynos_drm_crtc *crtc, int mode) { switch (mode) { case DRM_MODE_DPMS_ON: - mixer_poweron(mgr); + mixer_poweron(crtc); break; case DRM_MODE_DPMS_STANDBY: case DRM_MODE_DPMS_SUSPEND: case DRM_MODE_DPMS_OFF: - mixer_poweroff(mgr); + mixer_poweroff(crtc); break; default: DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode); @@ -1186,7 +1178,7 @@ int mixer_check_mode(struct drm_display_mode *mode) return -EINVAL; } -static struct exynos_drm_manager_ops mixer_manager_ops = { +static struct exynos_drm_crtc_ops mixer_crtc_ops = { .dpms = mixer_dpms, .enable_vblank = mixer_enable_vblank, .disable_vblank = mixer_disable_vblank, @@ -1257,25 +1249,30 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) struct drm_device *drm_dev = data; int ret; - ret = mixer_initialize(&ctx->manager, drm_dev); - if (ret) - return ret; - - ret = exynos_drm_crtc_create(&ctx->manager, drm_dev, ctx->pipe, - EXYNOS_DISPLAY_TYPE_HDMI); - if (ret) { - mixer_mgr_remove(&ctx->manager); - return ret; + ctx->crtc = exynos_drm_crtc_create(drm_dev, ctx->pipe, + EXYNOS_DISPLAY_TYPE_HDMI, + &mixer_crtc_ops, ctx); + if (IS_ERR(ctx->crtc)) { + ret = PTR_ERR(ctx->crtc); + goto free_ctx; } + ret = mixer_initialize(ctx, drm_dev); + if (ret) + goto free_ctx; + return 0; + +free_ctx: + devm_kfree(dev, ctx); + return ret; } static void mixer_unbind(struct device *dev, struct device *master, void *data) { struct mixer_context *ctx = dev_get_drvdata(dev); - mixer_mgr_remove(&ctx->manager); + mixer_ctx_remove(ctx); } static const struct component_ops mixer_component_ops = { @@ -1298,8 +1295,6 @@ static int mixer_probe(struct platform_device *pdev) mutex_init(&ctx->mixer_mutex); - ctx->manager.ops = &mixer_manager_ops; - if (dev->of_node) { const struct of_device_id *match; From a8dc5ed67f94030b72daece4e5e433fa6fae3e3e Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 27 Nov 2014 16:28:44 -0200 Subject: [PATCH 19/22] drm/exynos: don't duplicate drm_display_mode in fimd context We can safely use the mode stored in the crtc. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 5 ----- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 12 +----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 9e8ed5fd60ae..357fcd59aa48 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -89,7 +89,6 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode, int x, int y, struct drm_framebuffer *old_fb) { - struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); struct drm_framebuffer *fb = crtc->primary->fb; unsigned int crtc_w; unsigned int crtc_h; @@ -102,10 +101,6 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, crtc_w = fb->width - x; crtc_h = fb->height - y; - - if (exynos_crtc->ops->mode_set) - exynos_crtc->ops->mode_set(exynos_crtc, &crtc->mode); - return exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0, crtc_w, crtc_h, x, y, crtc_w, crtc_h); } diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 9acd6890a3d6..d54ca07658c9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -164,7 +164,6 @@ struct fimd_context { struct clk *lcd_clk; void __iomem *regs; struct regmap *sysreg; - struct drm_display_mode mode; struct fimd_win_data win_data[WINDOWS_NR]; unsigned int default_win; unsigned long irq_flags; @@ -345,18 +344,10 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc *crtc, return true; } -static void fimd_mode_set(struct exynos_drm_crtc *crtc, - const struct drm_display_mode *in_mode) -{ - struct fimd_context *ctx = crtc->ctx; - - drm_mode_copy(&ctx->mode, in_mode); -} - static void fimd_commit(struct exynos_drm_crtc *crtc) { struct fimd_context *ctx = crtc->ctx; - struct drm_display_mode *mode = &ctx->mode; + struct drm_display_mode *mode = &crtc->base.mode; struct fimd_driver_data *driver_data = ctx->driver_data; void *timing_base = ctx->regs + driver_data->timing_base; u32 val, clkdiv; @@ -1016,7 +1007,6 @@ static void fimd_te_handler(struct exynos_drm_crtc *crtc) static struct exynos_drm_crtc_ops fimd_crtc_ops = { .dpms = fimd_dpms, .mode_fixup = fimd_mode_fixup, - .mode_set = fimd_mode_set, .commit = fimd_commit, .enable_vblank = fimd_enable_vblank, .disable_vblank = fimd_disable_vblank, From dc81252ff50d7ededc3dfd2c8236efb5c110a14e Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 27 Nov 2014 16:30:45 -0200 Subject: [PATCH 20/22] drm/exynos: remove mode_set() ops from exynos_crtc It is no longer used anywhere. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_drv.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 4c930d066196..d490b49f71c9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -167,7 +167,6 @@ struct exynos_drm_display { * * @dpms: control device power. * @mode_fixup: fix mode data before applying it - * @mode_set: set the given mode to the manager * @commit: set current hw specific display mode to hw. * @enable_vblank: specific driver callback for enabling vblank interrupt. * @disable_vblank: specific driver callback for disabling vblank interrupt. @@ -186,8 +185,6 @@ struct exynos_drm_crtc_ops { bool (*mode_fixup)(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); - void (*mode_set)(struct exynos_drm_crtc *crtc, - const struct drm_display_mode *mode); void (*commit)(struct exynos_drm_crtc *crtc); int (*enable_vblank)(struct exynos_drm_crtc *crtc); void (*disable_vblank)(struct exynos_drm_crtc *crtc); From adf5691c333620560fb90f2c551a42da8ed14f15 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Thu, 27 Nov 2014 14:56:09 -0200 Subject: [PATCH 21/22] drm/exynos: create exynos_check_plane() Split update plane in two parts, an initial check part that can fail and the update part that can't fail. This is a important step for the upcoming atomic modesetting support. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 11 ++++++-- drivers/gpu/drm/exynos/exynos_drm_plane.c | 34 ++++++++++++++--------- drivers/gpu/drm/exynos/exynos_drm_plane.h | 11 ++++---- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 357fcd59aa48..a85c451ba392 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -92,6 +92,7 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_framebuffer *fb = crtc->primary->fb; unsigned int crtc_w; unsigned int crtc_h; + int ret; /* * copy the mode data adjusted by mode_fixup() into crtc->mode @@ -99,10 +100,16 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, */ memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode)); + ret = exynos_check_plane(crtc->primary, fb); + if (ret < 0) + return ret; + crtc_w = fb->width - x; crtc_h = fb->height - y; - return exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0, - crtc_w, crtc_h, x, y, crtc_w, crtc_h); + exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0, + crtc_w, crtc_h, x, y, crtc_w, crtc_h); + + return 0; } static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 95442e69db75..358cff67e5ce 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -12,6 +12,7 @@ #include #include +#include #include "exynos_drm_drv.h" #include "exynos_drm_crtc.h" #include "exynos_drm_fb.h" @@ -61,16 +62,9 @@ static int exynos_plane_get_size(int start, unsigned length, unsigned last) return size; } -int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, - struct drm_framebuffer *fb, int crtc_x, int crtc_y, - unsigned int crtc_w, unsigned int crtc_h, - uint32_t src_x, uint32_t src_y, - uint32_t src_w, uint32_t src_h) +int exynos_check_plane(struct drm_plane *plane, struct drm_framebuffer *fb) { struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); - struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); - unsigned int actual_w; - unsigned int actual_h; int nr; int i; @@ -89,6 +83,20 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, i, (unsigned long)exynos_plane->dma_addr[i]); } + return 0; +} + +void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, + struct drm_framebuffer *fb, int crtc_x, int crtc_y, + unsigned int crtc_w, unsigned int crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h) +{ + struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); + unsigned int actual_w; + unsigned int actual_h; + actual_w = exynos_plane_get_size(crtc_x, crtc_w, crtc->mode.hdisplay); actual_h = exynos_plane_get_size(crtc_y, crtc_h, crtc->mode.vdisplay); @@ -135,8 +143,6 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, if (exynos_crtc->ops->win_mode_set) exynos_crtc->ops->win_mode_set(exynos_crtc, exynos_plane); - - return 0; } void exynos_plane_dpms(struct drm_plane *plane, int mode) @@ -177,12 +183,14 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); int ret; - ret = exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, - crtc_w, crtc_h, src_x >> 16, src_y >> 16, - src_w >> 16, src_h >> 16); + ret = exynos_check_plane(plane, fb); if (ret < 0) return ret; + exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, + crtc_w, crtc_h, src_x >> 16, src_y >> 16, + src_w >> 16, src_h >> 16); + if (exynos_crtc->ops->win_commit) exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos); diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h index d25c079a3f44..59d40755095b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.h +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h @@ -9,11 +9,12 @@ * */ -int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, - struct drm_framebuffer *fb, int crtc_x, int crtc_y, - unsigned int crtc_w, unsigned int crtc_h, - uint32_t src_x, uint32_t src_y, - uint32_t src_w, uint32_t src_h); +int exynos_check_plane(struct drm_plane *plane, struct drm_framebuffer *fb); +void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, + struct drm_framebuffer *fb, int crtc_x, int crtc_y, + unsigned int crtc_w, unsigned int crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h); int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y, unsigned int crtc_w, unsigned int crtc_h, From efa75bcdad59fc796152a4c73bb65ae2ab7ce035 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Mon, 12 Jan 2015 01:57:07 +0900 Subject: [PATCH 22/22] drm/exynos: fimd: check error status for drm_iommu_attach_device check error status for drm_iommu_attach_device() and make sure it propagates till the caller. Signed-off-by: Ajay Kumar Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index d54ca07658c9..682806ef4d33 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -296,12 +296,19 @@ static int fimd_ctx_initialize(struct fimd_context *ctx, /* attach this sub driver to iommu mapping if supported. */ if (is_drm_iommu_supported(ctx->drm_dev)) { + int ret; + /* * If any channel is already active, iommu will throw * a PAGE FAULT when enabled. So clear any channel if enabled. */ fimd_clear_channel(ctx->crtc); - drm_iommu_attach_device(ctx->drm_dev, ctx->dev); + ret = drm_iommu_attach_device(ctx->drm_dev, ctx->dev); + if (ret) { + DRM_ERROR("drm_iommu_attach failed.\n"); + return ret; + } + } return 0; @@ -1056,6 +1063,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) { struct fimd_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; + int ret; ctx->crtc = exynos_drm_crtc_create(drm_dev, ctx->pipe, EXYNOS_DISPLAY_TYPE_LCD, @@ -1063,7 +1071,12 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) if (IS_ERR(ctx->crtc)) return PTR_ERR(ctx->crtc); - fimd_ctx_initialize(ctx, drm_dev); + ret = fimd_ctx_initialize(ctx, drm_dev); + if (ret) { + DRM_ERROR("fimd_ctx_initialize failed.\n"); + return ret; + } + if (ctx->display) exynos_drm_create_enc_conn(drm_dev, ctx->display);