Commit 0dfac1ce authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

gma500: Begin the GEMification of the cursor code

Do a first pass over the cursor code and rework it to use GEM objects for
the cursor buffer as we need.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6a62730c
...@@ -732,39 +732,17 @@ static void psb_setup_outputs(struct drm_device *dev) ...@@ -732,39 +732,17 @@ static void psb_setup_outputs(struct drm_device *dev)
} }
} }
/* FIXME: rewrite these in terms of the gtt_range and GEM objects /* FIXME: rewrite this in terms of the gtt_range and GEM objects
rather than faking them as we do now */ rather than faking them as we do now */
static void *psb_bo_from_handle(struct drm_device *dev, static size_t psb_bo_offset(struct drm_device *dev, void *obj)
struct drm_file *file_priv,
unsigned int handle)
{
return NULL;
}
static size_t psb_bo_size(struct drm_device *dev, void *bof)
{
return 0;
}
static size_t psb_bo_offset(struct drm_device *dev, void *bof)
{ {
struct psb_framebuffer *psbfb struct psb_framebuffer *psbfb
= (struct psb_framebuffer *)bof; = (struct psb_framebuffer *)obj;
return (size_t)psbfb->offset; return (size_t)psbfb->offset;
} }
static int psb_bo_pin_for_scanout(struct drm_device *dev, void *bo)
{
return 0;
}
static int psb_bo_unpin_for_scanout(struct drm_device *dev, void *bo)
{
return 0;
}
void psb_modeset_init(struct drm_device *dev) void psb_modeset_init(struct drm_device *dev)
{ {
struct drm_psb_private *dev_priv = struct drm_psb_private *dev_priv =
...@@ -774,11 +752,7 @@ void psb_modeset_init(struct drm_device *dev) ...@@ -774,11 +752,7 @@ void psb_modeset_init(struct drm_device *dev)
PSB_DEBUG_ENTRY("\n"); PSB_DEBUG_ENTRY("\n");
/* Init mm functions */ /* Init mm functions */
mode_dev->bo_from_handle = psb_bo_from_handle;
mode_dev->bo_size = psb_bo_size;
mode_dev->bo_offset = psb_bo_offset; mode_dev->bo_offset = psb_bo_offset;
mode_dev->bo_pin_for_scanout = psb_bo_pin_for_scanout;
mode_dev->bo_unpin_for_scanout = psb_bo_unpin_for_scanout;
drm_mode_config_init(dev); drm_mode_config_init(dev);
......
...@@ -1014,8 +1014,6 @@ static void psb_intel_crtc_restore(struct drm_crtc *crtc) ...@@ -1014,8 +1014,6 @@ static void psb_intel_crtc_restore(struct drm_crtc *crtc)
REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]); REG_WRITE(paletteReg + (i << 2), crtc_state->savePalette[i]);
} }
#if 0
/* FIXME */
static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
struct drm_file *file_priv, struct drm_file *file_priv,
uint32_t handle, uint32_t handle,
...@@ -1024,17 +1022,14 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1024,17 +1022,14 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_psb_private *dev_priv = struct drm_psb_private *dev_priv =
(struct drm_psb_private *)dev->dev_private; (struct drm_psb_private *)dev->dev_private;
struct psb_gtt *pg = dev_priv->pg;
struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
struct psb_intel_mode_device *mode_dev = psb_intel_crtc->mode_dev;
int pipe = psb_intel_crtc->pipe; int pipe = psb_intel_crtc->pipe;
uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR; uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
uint32_t base = (pipe == 0) ? CURABASE : CURBBASE; uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
uint32_t temp; uint32_t temp;
size_t addr = 0; size_t addr = 0;
uint32_t page_offset; struct gtt_range *gt;
size_t size; struct drm_gem_object *obj;
void *bo;
int ret; int ret;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
...@@ -1043,8 +1038,7 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1043,8 +1038,7 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
if (!handle) { if (!handle) {
DRM_DEBUG("cursor off\n"); DRM_DEBUG("cursor off\n");
/* turn off the cursor */ /* turn off the cursor */
temp = 0; temp = CURSOR_MODE_DISABLE;
temp |= CURSOR_MODE_DISABLE;
if (gma_power_begin(dev, false)) { if (gma_power_begin(dev, false)) {
REG_WRITE(control, temp); REG_WRITE(control, temp);
...@@ -1052,12 +1046,10 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1052,12 +1046,10 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
gma_power_end(dev); gma_power_end(dev);
} }
/* unpin the old bo */ /* Unpin the old GEM object */
if (psb_intel_crtc->cursor_bo) { if (psb_intel_crtc->cursor_obj) {
mode_dev->bo_unpin_for_scanout(dev, drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
psb_intel_crtc-> psb_intel_crtc->cursor_obj = NULL;
cursor_bo);
psb_intel_crtc->cursor_bo = NULL;
} }
return 0; return 0;
...@@ -1069,15 +1061,11 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1069,15 +1061,11 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
return -EINVAL; return -EINVAL;
} }
bo = mode_dev->bo_from_handle(dev, file_priv, handle); obj = drm_gem_object_lookup(dev, file_priv, handle);
if (!bo) if (!obj)
return -ENOENT; return -ENOENT;
ret = mode_dev->bo_pin_for_scanout(dev, bo); if (obj->size < width * height * 4) {
if (ret)
return ret;
size = mode_dev->bo_size(dev, bo);
if (size < width * height * 4) {
DRM_ERROR("buffer is to small\n"); DRM_ERROR("buffer is to small\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1086,15 +1074,15 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1086,15 +1074,15 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
DRM_DEBUG("%s: map meminfo for hw cursor. handle %x\n", DRM_DEBUG("%s: map meminfo for hw cursor. handle %x\n",
__func__, handle); __func__, handle);
ret = psb_gtt_map_meminfo(dev, (void *)handle, &page_offset); /* Pin : FIXME
if (ret) { if (ret) {
DRM_ERROR("Can not map meminfo to GTT. handle 0x%x\n", handle); DRM_ERROR("Can not map meminfo to GTT. handle 0x%x\n", handle);
return ret; return ret;
} }
*/
gt = container_of(obj, struct gtt_range, gem);
addr = page_offset << PAGE_SHIFT; addr = gt->resource.start;
addr += dev_priv->stolen_base;
psb_intel_crtc->cursor_addr = addr; psb_intel_crtc->cursor_addr = addr;
...@@ -1110,9 +1098,9 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -1110,9 +1098,9 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
} }
/* unpin the old bo */ /* unpin the old bo */
if (psb_intel_crtc->cursor_bo && psb_intel_crtc->cursor_bo != bo) { if (psb_intel_crtc->cursor_obj && psb_intel_crtc->cursor_obj != obj) {
mode_dev->bo_unpin_for_scanout(dev, psb_intel_crtc->cursor_bo); drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
psb_intel_crtc->cursor_bo = bo; psb_intel_crtc->cursor_obj = obj;
} }
return 0; return 0;
...@@ -1124,7 +1112,7 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) ...@@ -1124,7 +1112,7 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
int pipe = psb_intel_crtc->pipe; int pipe = psb_intel_crtc->pipe;
uint32_t temp = 0; uint32_t temp = 0;
uint32_t adder; uint32_t addr;
if (x < 0) { if (x < 0) {
...@@ -1139,16 +1127,15 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) ...@@ -1139,16 +1127,15 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT); temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT); temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
adder = psb_intel_crtc->cursor_addr; addr = psb_intel_crtc->cursor_addr;
if (gma_power_begin(dev, false)) { if (gma_power_begin(dev, false)) {
REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp); REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, adder); REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, addr);
gma_power_end(dev); gma_power_end(dev);
} }
return 0; return 0;
} }
#endif
static void psb_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, static void psb_intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
u16 *green, u16 *blue, uint32_t type, uint32_t size) u16 *green, u16 *blue, uint32_t type, uint32_t size)
...@@ -1315,6 +1302,7 @@ static void psb_intel_crtc_destroy(struct drm_crtc *crtc) ...@@ -1315,6 +1302,7 @@ static void psb_intel_crtc_destroy(struct drm_crtc *crtc)
{ {
struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc); struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
/* FIXME: do we need to put the final GEM cursor ? */
kfree(psb_intel_crtc->crtc_state); kfree(psb_intel_crtc->crtc_state);
drm_crtc_cleanup(crtc); drm_crtc_cleanup(crtc);
kfree(psb_intel_crtc); kfree(psb_intel_crtc);
...@@ -1332,10 +1320,8 @@ static const struct drm_crtc_helper_funcs psb_intel_helper_funcs = { ...@@ -1332,10 +1320,8 @@ static const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
const struct drm_crtc_funcs psb_intel_crtc_funcs = { const struct drm_crtc_funcs psb_intel_crtc_funcs = {
.save = psb_intel_crtc_save, .save = psb_intel_crtc_save,
.restore = psb_intel_crtc_restore, .restore = psb_intel_crtc_restore,
/* FIXME
.cursor_set = psb_intel_crtc_cursor_set, .cursor_set = psb_intel_crtc_cursor_set,
.cursor_move = psb_intel_crtc_cursor_move, .cursor_move = psb_intel_crtc_cursor_move,
*/
.gamma_set = psb_intel_crtc_gamma_set, .gamma_set = psb_intel_crtc_gamma_set,
.set_config = psb_crtc_set_config, .set_config = psb_crtc_set_config,
.destroy = psb_intel_crtc_destroy, .destroy = psb_intel_crtc_destroy,
......
...@@ -76,13 +76,7 @@ struct psb_intel_mode_device { ...@@ -76,13 +76,7 @@ struct psb_intel_mode_device {
/* /*
* Abstracted memory manager operations * Abstracted memory manager operations
*/ */
void *(*bo_from_handle) (struct drm_device *dev,
struct drm_file *file_priv,
unsigned int handle);
size_t(*bo_size) (struct drm_device *dev, void *bo);
size_t(*bo_offset) (struct drm_device *dev, void *bo); size_t(*bo_offset) (struct drm_device *dev, void *bo);
int (*bo_pin_for_scanout) (struct drm_device *dev, void *bo);
int (*bo_unpin_for_scanout) (struct drm_device *dev, void *bo);
/* /*
* Cursor * Cursor
...@@ -156,11 +150,8 @@ struct psb_intel_crtc { ...@@ -156,11 +150,8 @@ struct psb_intel_crtc {
/* a mode_set for fbdev users on this crtc */ /* a mode_set for fbdev users on this crtc */
struct drm_mode_set mode_set; struct drm_mode_set mode_set;
/* current bo we scanout from */ /* GEM object that holds our cursor */
void *scanout_bo; struct drm_gem_object *cursor_obj;
/* current bo we cursor from */
void *cursor_bo;
struct drm_display_mode saved_mode; struct drm_display_mode saved_mode;
struct drm_display_mode saved_adjusted_mode; struct drm_display_mode saved_adjusted_mode;
......
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