Commit 7ee14cdc authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Inki Dae

drm/exynos: remove struct *_win_data abstraction on planes

struct {fimd,mixer,vidi}_win_data was just keeping the same data
as struct exynos_drm_plane thus get ride of it and use exynos_drm_plane
directly.

It changes how planes are created and remove .win_mode_set() callback
that was only filling all *_win_data structs.

v2: check for return of exynos_plane_init()
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent 1be4b7ee
This diff is collapsed.
...@@ -239,13 +239,13 @@ static struct drm_crtc_funcs exynos_crtc_funcs = { ...@@ -239,13 +239,13 @@ static struct drm_crtc_funcs exynos_crtc_funcs = {
}; };
struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
struct drm_plane *plane,
int pipe, int pipe,
enum exynos_drm_output_type type, enum exynos_drm_output_type type,
struct exynos_drm_crtc_ops *ops, struct exynos_drm_crtc_ops *ops,
void *ctx) void *ctx)
{ {
struct exynos_drm_crtc *exynos_crtc; struct exynos_drm_crtc *exynos_crtc;
struct drm_plane *plane;
struct exynos_drm_private *private = drm_dev->dev_private; struct exynos_drm_private *private = drm_dev->dev_private;
struct drm_crtc *crtc; struct drm_crtc *crtc;
int ret; int ret;
...@@ -262,12 +262,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, ...@@ -262,12 +262,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
exynos_crtc->type = type; exynos_crtc->type = type;
exynos_crtc->ops = ops; exynos_crtc->ops = ops;
exynos_crtc->ctx = ctx; exynos_crtc->ctx = ctx;
plane = exynos_plane_init(drm_dev, 1 << pipe,
DRM_PLANE_TYPE_PRIMARY);
if (IS_ERR(plane)) {
ret = PTR_ERR(plane);
goto err_plane;
}
crtc = &exynos_crtc->base; crtc = &exynos_crtc->base;
...@@ -284,7 +278,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, ...@@ -284,7 +278,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
err_crtc: err_crtc:
plane->funcs->destroy(plane); plane->funcs->destroy(plane);
err_plane:
kfree(exynos_crtc); kfree(exynos_crtc);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "exynos_drm_drv.h" #include "exynos_drm_drv.h"
struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev, struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
struct drm_plane *plane,
int pipe, int pipe,
enum exynos_drm_output_type type, enum exynos_drm_output_type type,
struct exynos_drm_crtc_ops *ops, struct exynos_drm_crtc_ops *ops,
......
...@@ -55,7 +55,6 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -55,7 +55,6 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
{ {
struct exynos_drm_private *private; struct exynos_drm_private *private;
int ret; int ret;
int nr;
private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL); private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
if (!private) if (!private)
...@@ -81,19 +80,6 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -81,19 +80,6 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
exynos_drm_mode_config_init(dev); exynos_drm_mode_config_init(dev);
for (nr = 0; nr < MAX_PLANE; nr++) {
struct drm_plane *plane;
unsigned long possible_crtcs = (1 << MAX_CRTC) - 1;
plane = exynos_plane_init(dev, possible_crtcs,
DRM_PLANE_TYPE_OVERLAY);
if (!IS_ERR(plane))
continue;
ret = PTR_ERR(plane);
goto err_mode_config_cleanup;
}
/* setup possible_clones. */ /* setup possible_clones. */
exynos_drm_encoder_setup(dev); exynos_drm_encoder_setup(dev);
......
...@@ -78,6 +78,7 @@ enum exynos_drm_output_type { ...@@ -78,6 +78,7 @@ enum exynos_drm_output_type {
* @transparency: transparency on or off. * @transparency: transparency on or off.
* @activated: activated or not. * @activated: activated or not.
* @enabled: enabled or not. * @enabled: enabled or not.
* @resume: to resume or not.
* *
* this structure is common to exynos SoC and its contents would be copied * this structure is common to exynos SoC and its contents would be copied
* to hardware specific overlay info. * to hardware specific overlay info.
...@@ -112,6 +113,7 @@ struct exynos_drm_plane { ...@@ -112,6 +113,7 @@ struct exynos_drm_plane {
bool transparency:1; bool transparency:1;
bool activated:1; bool activated:1;
bool enabled:1; bool enabled:1;
bool resume:1;
}; };
/* /*
...@@ -172,7 +174,6 @@ struct exynos_drm_display { ...@@ -172,7 +174,6 @@ struct exynos_drm_display {
* @disable_vblank: specific driver callback for disabling vblank interrupt. * @disable_vblank: specific driver callback for disabling vblank interrupt.
* @wait_for_vblank: wait for vblank interrupt to make sure that * @wait_for_vblank: wait for vblank interrupt to make sure that
* hardware overlay is updated. * hardware overlay is updated.
* @win_mode_set: copy drm overlay info to hw specific overlay info.
* @win_commit: apply hardware specific overlay data to registers. * @win_commit: apply hardware specific overlay data to registers.
* @win_disable: disable hardware specific overlay. * @win_disable: disable hardware specific overlay.
* @te_handler: trigger to transfer video image at the tearing effect * @te_handler: trigger to transfer video image at the tearing effect
...@@ -188,8 +189,6 @@ struct exynos_drm_crtc_ops { ...@@ -188,8 +189,6 @@ struct exynos_drm_crtc_ops {
int (*enable_vblank)(struct exynos_drm_crtc *crtc); int (*enable_vblank)(struct exynos_drm_crtc *crtc);
void (*disable_vblank)(struct exynos_drm_crtc *crtc); void (*disable_vblank)(struct exynos_drm_crtc *crtc);
void (*wait_for_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_crtc *crtc, int zpos); void (*win_commit)(struct exynos_drm_crtc *crtc, int zpos);
void (*win_disable)(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); void (*te_handler)(struct exynos_drm_crtc *crtc);
......
This diff is collapsed.
...@@ -92,7 +92,6 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -92,7 +92,6 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); 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_w;
unsigned int actual_h; unsigned int actual_h;
...@@ -139,9 +138,6 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -139,9 +138,6 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
exynos_plane->crtc_width, exynos_plane->crtc_height); exynos_plane->crtc_width, exynos_plane->crtc_height);
plane->crtc = crtc; plane->crtc = crtc;
if (exynos_crtc->ops->win_mode_set)
exynos_crtc->ops->win_mode_set(exynos_crtc, exynos_plane);
} }
int int
...@@ -184,11 +180,8 @@ static int exynos_disable_plane(struct drm_plane *plane) ...@@ -184,11 +180,8 @@ static int exynos_disable_plane(struct drm_plane *plane)
static void exynos_plane_destroy(struct drm_plane *plane) static void exynos_plane_destroy(struct drm_plane *plane)
{ {
struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
exynos_disable_plane(plane); exynos_disable_plane(plane);
drm_plane_cleanup(plane); drm_plane_cleanup(plane);
kfree(exynos_plane);
} }
static int exynos_plane_set_property(struct drm_plane *plane, static int exynos_plane_set_property(struct drm_plane *plane,
...@@ -233,24 +226,18 @@ static void exynos_plane_attach_zpos_property(struct drm_plane *plane) ...@@ -233,24 +226,18 @@ static void exynos_plane_attach_zpos_property(struct drm_plane *plane)
drm_object_attach_property(&plane->base, prop, 0); drm_object_attach_property(&plane->base, prop, 0);
} }
struct drm_plane *exynos_plane_init(struct drm_device *dev, int exynos_plane_init(struct drm_device *dev,
unsigned long possible_crtcs, struct exynos_drm_plane *exynos_plane,
enum drm_plane_type type) unsigned long possible_crtcs, enum drm_plane_type type)
{ {
struct exynos_drm_plane *exynos_plane;
int err; int err;
exynos_plane = kzalloc(sizeof(struct exynos_drm_plane), GFP_KERNEL);
if (!exynos_plane)
return ERR_PTR(-ENOMEM);
err = drm_universal_plane_init(dev, &exynos_plane->base, possible_crtcs, err = drm_universal_plane_init(dev, &exynos_plane->base, possible_crtcs,
&exynos_plane_funcs, formats, &exynos_plane_funcs, formats,
ARRAY_SIZE(formats), type); ARRAY_SIZE(formats), type);
if (err) { if (err) {
DRM_ERROR("failed to initialize plane\n"); DRM_ERROR("failed to initialize plane\n");
kfree(exynos_plane); return err;
return ERR_PTR(err);
} }
if (type == DRM_PLANE_TYPE_PRIMARY) if (type == DRM_PLANE_TYPE_PRIMARY)
...@@ -258,5 +245,5 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev, ...@@ -258,5 +245,5 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev,
else else
exynos_plane_attach_zpos_property(&exynos_plane->base); exynos_plane_attach_zpos_property(&exynos_plane->base);
return &exynos_plane->base; return 0;
} }
...@@ -20,6 +20,6 @@ int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -20,6 +20,6 @@ int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
unsigned int crtc_w, unsigned int crtc_h, unsigned int crtc_w, unsigned int crtc_h,
uint32_t src_x, uint32_t src_y, uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h); uint32_t src_w, uint32_t src_h);
struct drm_plane *exynos_plane_init(struct drm_device *dev, int exynos_plane_init(struct drm_device *dev,
unsigned long possible_crtcs, struct exynos_drm_plane *exynos_plane,
enum drm_plane_type type); unsigned long possible_crtcs, enum drm_plane_type type);
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "exynos_drm_drv.h" #include "exynos_drm_drv.h"
#include "exynos_drm_crtc.h" #include "exynos_drm_crtc.h"
#include "exynos_drm_plane.h"
#include "exynos_drm_encoder.h" #include "exynos_drm_encoder.h"
#include "exynos_drm_vidi.h" #include "exynos_drm_vidi.h"
...@@ -32,20 +33,6 @@ ...@@ -32,20 +33,6 @@
#define ctx_from_connector(c) container_of(c, struct vidi_context, \ #define ctx_from_connector(c) container_of(c, struct vidi_context, \
connector) connector)
struct vidi_win_data {
unsigned int offset_x;
unsigned int offset_y;
unsigned int ovl_width;
unsigned int ovl_height;
unsigned int fb_width;
unsigned int fb_height;
unsigned int bpp;
dma_addr_t dma_addr;
unsigned int buf_offsize;
unsigned int line_size; /* bytes */
bool enabled;
};
struct vidi_context { struct vidi_context {
struct exynos_drm_display display; struct exynos_drm_display display;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -53,7 +40,7 @@ struct vidi_context { ...@@ -53,7 +40,7 @@ struct vidi_context {
struct exynos_drm_crtc *crtc; struct exynos_drm_crtc *crtc;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_connector connector; struct drm_connector connector;
struct vidi_win_data win_data[WINDOWS_NR]; struct exynos_drm_plane planes[WINDOWS_NR];
struct edid *raw_edid; struct edid *raw_edid;
unsigned int clkdiv; unsigned int clkdiv;
unsigned int default_win; unsigned int default_win;
...@@ -97,19 +84,6 @@ static const char fake_edid_info[] = { ...@@ -97,19 +84,6 @@ static const char fake_edid_info[] = {
0x00, 0x00, 0x00, 0x06 0x00, 0x00, 0x00, 0x06
}; };
static void vidi_apply(struct vidi_context *ctx)
{
struct exynos_drm_crtc_ops *crtc_ops = ctx->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 && (crtc_ops && crtc_ops->win_commit))
crtc_ops->win_commit(ctx->crtc, i);
}
}
static int vidi_enable_vblank(struct exynos_drm_crtc *crtc) static int vidi_enable_vblank(struct exynos_drm_crtc *crtc)
{ {
struct vidi_context *ctx = crtc->ctx; struct vidi_context *ctx = crtc->ctx;
...@@ -143,63 +117,10 @@ static void vidi_disable_vblank(struct exynos_drm_crtc *crtc) ...@@ -143,63 +117,10 @@ static void vidi_disable_vblank(struct exynos_drm_crtc *crtc)
ctx->vblank_on = false; ctx->vblank_on = false;
} }
static void vidi_win_mode_set(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane *plane)
{
struct vidi_context *ctx = crtc->ctx;
struct vidi_win_data *win_data;
int win;
unsigned long offset;
if (!plane) {
DRM_ERROR("plane is NULL\n");
return;
}
win = plane->zpos;
if (win == DEFAULT_ZPOS)
win = ctx->default_win;
if (win < 0 || win >= WINDOWS_NR)
return;
offset = plane->fb_x * (plane->bpp >> 3);
offset += plane->fb_y * plane->pitch;
DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, plane->pitch);
win_data = &ctx->win_data[win];
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
* through specific ioctl.
*/
DRM_DEBUG_KMS("offset_x = %d, offset_y = %d\n",
win_data->offset_x, win_data->offset_y);
DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
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",
plane->fb_width, plane->crtc_width);
}
static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos) static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos)
{ {
struct vidi_context *ctx = crtc->ctx; struct vidi_context *ctx = crtc->ctx;
struct vidi_win_data *win_data; struct exynos_drm_plane *plane;
int win = zpos; int win = zpos;
if (ctx->suspended) if (ctx->suspended)
...@@ -211,11 +132,11 @@ static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos) ...@@ -211,11 +132,11 @@ static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos)
if (win < 0 || win >= WINDOWS_NR) if (win < 0 || win >= WINDOWS_NR)
return; return;
win_data = &ctx->win_data[win]; plane = &ctx->planes[win];
win_data->enabled = true; plane->enabled = true;
DRM_DEBUG_KMS("dma_addr = %pad\n", &win_data->dma_addr); DRM_DEBUG_KMS("dma_addr = %pad\n", plane->dma_addr);
if (ctx->vblank_on) if (ctx->vblank_on)
schedule_work(&ctx->work); schedule_work(&ctx->work);
...@@ -224,7 +145,7 @@ static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos) ...@@ -224,7 +145,7 @@ static void vidi_win_commit(struct exynos_drm_crtc *crtc, int zpos)
static void vidi_win_disable(struct exynos_drm_crtc *crtc, int zpos) static void vidi_win_disable(struct exynos_drm_crtc *crtc, int zpos)
{ {
struct vidi_context *ctx = crtc->ctx; struct vidi_context *ctx = crtc->ctx;
struct vidi_win_data *win_data; struct exynos_drm_plane *plane;
int win = zpos; int win = zpos;
if (win == DEFAULT_ZPOS) if (win == DEFAULT_ZPOS)
...@@ -233,14 +154,17 @@ static void vidi_win_disable(struct exynos_drm_crtc *crtc, int zpos) ...@@ -233,14 +154,17 @@ static void vidi_win_disable(struct exynos_drm_crtc *crtc, int zpos)
if (win < 0 || win >= WINDOWS_NR) if (win < 0 || win >= WINDOWS_NR)
return; return;
win_data = &ctx->win_data[win]; plane = &ctx->planes[win];
win_data->enabled = false; plane->enabled = false;
/* TODO. */ /* TODO. */
} }
static int vidi_power_on(struct vidi_context *ctx, bool enable) static int vidi_power_on(struct vidi_context *ctx, bool enable)
{ {
struct exynos_drm_plane *plane;
int i;
DRM_DEBUG_KMS("%s\n", __FILE__); DRM_DEBUG_KMS("%s\n", __FILE__);
if (enable != false && enable != true) if (enable != false && enable != true)
...@@ -253,7 +177,11 @@ static int vidi_power_on(struct vidi_context *ctx, bool enable) ...@@ -253,7 +177,11 @@ static int vidi_power_on(struct vidi_context *ctx, bool enable)
if (test_and_clear_bit(0, &ctx->irq_flags)) if (test_and_clear_bit(0, &ctx->irq_flags))
vidi_enable_vblank(ctx->crtc); vidi_enable_vblank(ctx->crtc);
vidi_apply(ctx); for (i = 0; i < WINDOWS_NR; i++) {
plane = &ctx->planes[i];
if (plane->enabled)
vidi_win_commit(ctx->crtc, i);
}
} else { } else {
ctx->suspended = true; ctx->suspended = true;
} }
...@@ -301,7 +229,6 @@ static struct exynos_drm_crtc_ops vidi_crtc_ops = { ...@@ -301,7 +229,6 @@ static struct exynos_drm_crtc_ops vidi_crtc_ops = {
.dpms = vidi_dpms, .dpms = vidi_dpms,
.enable_vblank = vidi_enable_vblank, .enable_vblank = vidi_enable_vblank,
.disable_vblank = vidi_disable_vblank, .disable_vblank = vidi_disable_vblank,
.win_mode_set = vidi_win_mode_set,
.win_commit = vidi_win_commit, .win_commit = vidi_win_commit,
.win_disable = vidi_win_disable, .win_disable = vidi_win_disable,
}; };
...@@ -543,12 +470,24 @@ static int vidi_bind(struct device *dev, struct device *master, void *data) ...@@ -543,12 +470,24 @@ static int vidi_bind(struct device *dev, struct device *master, void *data)
{ {
struct vidi_context *ctx = dev_get_drvdata(dev); struct vidi_context *ctx = dev_get_drvdata(dev);
struct drm_device *drm_dev = data; struct drm_device *drm_dev = data;
int ret; struct exynos_drm_plane *exynos_plane;
enum drm_plane_type type;
int zpos, ret;
vidi_ctx_initialize(ctx, drm_dev); vidi_ctx_initialize(ctx, drm_dev);
ctx->crtc = exynos_drm_crtc_create(drm_dev, ctx->pipe, for (zpos = 0; zpos < WINDOWS_NR; zpos++) {
EXYNOS_DISPLAY_TYPE_VIDI, type = (zpos == ctx->default_win) ? DRM_PLANE_TYPE_PRIMARY :
DRM_PLANE_TYPE_OVERLAY;
ret = exynos_plane_init(drm_dev, &ctx->planes[zpos],
1 << ctx->pipe, type);
if (ret)
return ret;
}
exynos_plane = &ctx->planes[ctx->default_win];
ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base,
ctx->pipe, EXYNOS_DISPLAY_TYPE_VIDI,
&vidi_crtc_ops, ctx); &vidi_crtc_ops, ctx);
if (IS_ERR(ctx->crtc)) { if (IS_ERR(ctx->crtc)) {
DRM_ERROR("failed to create crtc.\n"); DRM_ERROR("failed to create crtc.\n");
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment