summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2009-03-18 19:21:57 +1000
committerBen Skeggs <bskeggs@redhat.com>2009-03-18 19:21:57 +1000
commitec5abde7b330ce944a9639dbbc039cdb331755ad (patch)
tree4220fd0316d68470e77c31c2c234121042ab2b7e
parent06d9eff137979c8579d27e143a0f999192539bc0 (diff)
nv50: kill off nv50_cursor
-rw-r--r--linux-core/nouveau_crtc.h12
-rw-r--r--linux-core/nv50_crtc.c43
-rw-r--r--linux-core/nv50_cursor.c175
-rw-r--r--linux-core/nv50_cursor.h45
4 files changed, 91 insertions, 184 deletions
diff --git a/linux-core/nouveau_crtc.h b/linux-core/nouveau_crtc.h
index 53b95840..5104431c 100644
--- a/linux-core/nouveau_crtc.h
+++ b/linux-core/nouveau_crtc.h
@@ -41,7 +41,15 @@ struct nouveau_crtc {
uint32_t offset;
} fb;
- struct nv50_cursor *cursor;
+ struct {
+ struct drm_gem_object *gem;
+ bool visible;
+ uint32_t offset;
+ void (*set_offset)(struct nouveau_crtc *, uint32_t offset);
+ void (*set_pos)(struct nouveau_crtc *, int x, int y);
+ void (*hide)(struct nouveau_crtc *, bool update);
+ void (*show)(struct nouveau_crtc *, bool update);
+ } cursor;
struct {
struct mem_block *mem;
@@ -60,5 +68,7 @@ struct nouveau_crtc {
#define to_nouveau_crtc(x) container_of((x), struct nouveau_crtc, base)
int nv50_crtc_create(struct drm_device *dev, int index);
+int nv50_cursor_init(struct nouveau_crtc *);
+void nv50_cursor_fini(struct nouveau_crtc *);
#endif /* __NOUVEAU_CRTC_H__ */
diff --git a/linux-core/nv50_crtc.c b/linux-core/nv50_crtc.c
index 95b5fc96..f4e704e4 100644
--- a/linux-core/nv50_crtc.c
+++ b/linux-core/nv50_crtc.c
@@ -34,7 +34,6 @@
#include "nouveau_fb.h"
#include "nouveau_fbcon.h"
#include "nouveau_connector.h"
-#include "nv50_cursor.h"
#define NV50_LUT_INDEX(val, w) ((val << (8 - w)) | (val >> ((w << 1) - 8)))
static int
@@ -95,7 +94,7 @@ nv50_crtc_blank(struct nouveau_crtc *crtc, bool blanked)
DRM_DEBUG("%s\n", blanked ? "blanked" : "unblanked");
if (blanked) {
- crtc->cursor->hide(crtc, false);
+ crtc->cursor.hide(crtc, false);
OUT_MODE(NV50_CRTC0_CLUT_MODE + offset,
NV50_CRTC0_CLUT_MODE_BLANK);
@@ -107,11 +106,11 @@ nv50_crtc_blank(struct nouveau_crtc *crtc, bool blanked)
OUT_MODE(NV50_CRTC0_BLANK_CTRL + offset,
NV50_CRTC0_BLANK_CTRL_BLANK);
} else {
- crtc->cursor->set_offset(crtc);
- if (crtc->cursor->visible)
- crtc->cursor->show(crtc, false);
+ crtc->cursor.set_offset(crtc, crtc->cursor.offset);
+ if (crtc->cursor.visible)
+ crtc->cursor.show(crtc, false);
else
- crtc->cursor->hide(crtc, false);
+ crtc->cursor.hide(crtc, false);
OUT_MODE(NV50_CRTC0_CLUT_MODE + offset, crtc->lut.depth == 8 ?
NV50_CRTC0_CLUT_MODE_OFF : NV50_CRTC0_CLUT_MODE_ON);
@@ -410,7 +409,7 @@ static void nv50_crtc_destroy(struct drm_crtc *drm_crtc)
drm_crtc_cleanup(&crtc->base);
- nv50_cursor_destroy(crtc);
+ nv50_cursor_fini(crtc);
if (crtc->lut.mem)
nouveau_mem_free(drm_crtc->dev, crtc->lut.mem);
@@ -431,10 +430,21 @@ static int nv50_crtc_cursor_set(struct drm_crtc *drm_crtc,
if (width != 64 || height != 64)
return -EINVAL;
+ if (crtc->cursor.gem) {
+ mutex_lock(&dev->struct_mutex);
+ drm_gem_object_unreference(crtc->cursor.gem);
+ mutex_unlock(&dev->struct_mutex);
+ crtc->cursor.gem = NULL;
+ }
+
if (buffer_handle) {
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_gem_object *ngem;
+
gem = drm_gem_object_lookup(dev, file_priv, buffer_handle);
if (!gem)
return -EINVAL;
+ ngem = gem->driver_private;
ret = nouveau_gem_pin(gem, NOUVEAU_GEM_DOMAIN_VRAM);
if (ret) {
@@ -444,22 +454,25 @@ static int nv50_crtc_cursor_set(struct drm_crtc *drm_crtc,
return ret;
}
- crtc->cursor->set_bo(crtc, gem);
- crtc->cursor->set_offset(crtc);
- ret = crtc->cursor->show(crtc, true);
+ crtc->cursor.offset = ngem->bo->offset -
+ dev_priv->vm_vram_base;
+ crtc->cursor.set_offset(crtc, crtc->cursor.offset);
+ crtc->cursor.show(crtc, true);
+ crtc->cursor.gem = gem;
} else {
- crtc->cursor->set_bo(crtc, NULL);
- crtc->cursor->hide(crtc, true);
+ crtc->cursor.hide(crtc, true);
}
return ret;
}
-static int nv50_crtc_cursor_move(struct drm_crtc *drm_crtc, int x, int y)
+static int
+nv50_crtc_cursor_move(struct drm_crtc *drm_crtc, int x, int y)
{
struct nouveau_crtc *crtc = to_nouveau_crtc(drm_crtc);
- return crtc->cursor->set_pos(crtc, x, y);
+ crtc->cursor.set_pos(crtc, x, y);
+ return 0;
}
void
@@ -756,6 +769,6 @@ int nv50_crtc_create(struct drm_device *dev, int index)
drm_crtc_helper_add(&crtc->base, &nv50_crtc_helper_funcs);
drm_mode_crtc_set_gamma_size(&crtc->base, 256);
- nv50_cursor_create(crtc);
+ nv50_cursor_init(crtc);
return 0;
}
diff --git a/linux-core/nv50_cursor.c b/linux-core/nv50_cursor.c
index 10736de6..61cf3042 100644
--- a/linux-core/nv50_cursor.c
+++ b/linux-core/nv50_cursor.c
@@ -29,62 +29,10 @@
#include "nouveau_reg.h"
#include "nouveau_drv.h"
#include "nouveau_crtc.h"
-#include "nv50_cursor.h"
#include "nv50_display.h"
-static int nv50_cursor_enable(struct nouveau_crtc *crtc)
-{
- struct drm_device *dev = crtc->base.dev;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- int idx = crtc->index;
-
- DRM_DEBUG("\n");
-
- nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0x2000);
- if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
- NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_MASK, 0)) {
- DRM_ERROR("timeout: CURSOR_CTRL2_STATUS == 0\n");
- DRM_ERROR("CURSOR_CTRL2 = 0x%08x\n",
- nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
- return -EBUSY;
- }
-
- nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(crtc->index),
- NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_ON);
- if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
- NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE,
- NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE)) {
- DRM_ERROR("timeout: CURSOR_CTRL2_STATUS_ACTIVE(%d)\n", idx);
- DRM_ERROR("CURSOR_CTRL2(%d) = 0x%08x\n", idx,
- nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
- return -EBUSY;
- }
-
- return 0;
-}
-
-static int nv50_cursor_disable(struct nouveau_crtc *crtc)
-{
- struct drm_device *dev = crtc->base.dev;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- int idx = crtc->index;
-
- DRM_DEBUG("\n");
-
- nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0);
- if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
- NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_MASK, 0)) {
- DRM_ERROR("timeout: CURSOR_CTRL2_STATUS == 0\n");
- DRM_ERROR("CURSOR_CTRL2 = 0x%08x\n",
- nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
- return -EBUSY;
- }
-
- return 0;
-}
-
-/* Calling update or changing the stored cursor state is left to the higher level ioctl's. */
-static int nv50_cursor_show(struct nouveau_crtc *crtc, bool update)
+static void
+nv50_cursor_show(struct nouveau_crtc *crtc, bool update)
{
struct drm_nouveau_private *dev_priv = crtc->base.dev->dev_private;
struct drm_device *dev = crtc->base.dev;
@@ -92,13 +40,6 @@ static int nv50_cursor_show(struct nouveau_crtc *crtc, bool update)
DRM_DEBUG("\n");
- /* Better not show the cursor when we have none. */
- /* TODO: is cursor offset actually set? */
- if (!crtc->cursor->gem) {
- DRM_ERROR("No cursor available on crtc %d\n", crtc->index);
- return -EINVAL;
- }
-
if (dev_priv->chipset != 0x50)
OUT_MODE(NV84_CRTC0_CURSOR_DMA + offset,
NV84_CRTC0_CURSOR_DMA_LOCAL);
@@ -106,13 +47,12 @@ static int nv50_cursor_show(struct nouveau_crtc *crtc, bool update)
if (update) {
OUT_MODE(NV50_UPDATE_DISPLAY, 0);
- crtc->cursor->visible = true;
+ crtc->cursor.visible = true;
}
-
- return 0;
}
-static int nv50_cursor_hide(struct nouveau_crtc *crtc, bool update)
+static void
+nv50_cursor_hide(struct nouveau_crtc *crtc, bool update)
{
struct drm_nouveau_private *dev_priv = crtc->base.dev->dev_private;
struct drm_device *dev = crtc->base.dev;
@@ -127,91 +67,80 @@ static int nv50_cursor_hide(struct nouveau_crtc *crtc, bool update)
if (update) {
OUT_MODE(NV50_UPDATE_DISPLAY, 0);
- crtc->cursor->visible = false;
+ crtc->cursor.visible = false;
}
-
- return 0;
}
-static int nv50_cursor_set_pos(struct nouveau_crtc *crtc, int x, int y)
+static void
+nv50_cursor_set_pos(struct nouveau_crtc *crtc, int x, int y)
{
struct drm_nouveau_private *dev_priv = crtc->base.dev->dev_private;
- nv_wr32(NV50_HW_CURSOR_POS(crtc->index), ((y & 0xFFFF) << 16) | (x & 0xFFFF));
+ nv_wr32(NV50_HW_CURSOR_POS(crtc->index),
+ ((y & 0xFFFF) << 16) | (x & 0xFFFF));
/* Needed to make the cursor move. */
nv_wr32(NV50_HW_CURSOR_POS_CTRL(crtc->index), 0);
-
- return 0;
}
-static int nv50_cursor_set_offset(struct nouveau_crtc *crtc)
+static void
+nv50_cursor_set_offset(struct nouveau_crtc *crtc, uint32_t offset)
{
struct drm_device *dev = crtc->base.dev;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct nouveau_gem_object *ngem = nouveau_gem_object(crtc->cursor->gem);
DRM_DEBUG("\n");
- if (ngem) {
- OUT_MODE(NV50_CRTC0_CURSOR_OFFSET + crtc->index * 0x400,
- (ngem->bo->offset - dev_priv->vm_vram_base) >> 8);
- } else {
- OUT_MODE(NV50_CRTC0_CURSOR_OFFSET + crtc->index * 0x400, 0);
- }
-
- return 0;
+ OUT_MODE(NV50_CRTC0_CURSOR_OFFSET + crtc->index * 0x0400, offset >> 8);
}
-static int
-nv50_cursor_set_bo(struct nouveau_crtc *crtc, struct drm_gem_object *gem)
+int
+nv50_cursor_init(struct nouveau_crtc *crtc)
{
- struct nv50_cursor *cursor = crtc->cursor;
+ struct drm_device *dev = crtc->base.dev;
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ int idx = crtc->index;
- if (cursor->gem) {
- mutex_lock(&crtc->base.dev->struct_mutex);
- drm_gem_object_unreference(cursor->gem);
- mutex_unlock(&crtc->base.dev->struct_mutex);
+ nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0x2000);
+ if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
+ NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_MASK, 0)) {
+ DRM_ERROR("timeout: CURSOR_CTRL2_STATUS == 0\n");
+ DRM_ERROR("CURSOR_CTRL2 = 0x%08x\n",
+ nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
+ return -EBUSY;
+ }
- cursor->gem = NULL;
+ nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(crtc->index),
+ NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_ON);
+ if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
+ NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE,
+ NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_ACTIVE)) {
+ DRM_ERROR("timeout: CURSOR_CTRL2_STATUS_ACTIVE(%d)\n", idx);
+ DRM_ERROR("CURSOR_CTRL2(%d) = 0x%08x\n", idx,
+ nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
+ return -EBUSY;
}
- cursor->gem = gem;
+ crtc->cursor.set_offset = nv50_cursor_set_offset;
+ crtc->cursor.set_pos = nv50_cursor_set_pos;
+ crtc->cursor.hide = nv50_cursor_hide;
+ crtc->cursor.show = nv50_cursor_show;
return 0;
}
-int nv50_cursor_create(struct nouveau_crtc *crtc)
+void
+nv50_cursor_fini(struct nouveau_crtc *crtc)
{
- DRM_DEBUG("\n");
-
- if (!crtc || crtc->cursor)
- return -EINVAL;
-
- crtc->cursor = kzalloc(sizeof(struct nv50_cursor), GFP_KERNEL);
- if (!crtc->cursor)
- return -ENOMEM;
-
- nv50_cursor_enable(crtc);
-
- /* function pointers */
- crtc->cursor->show = nv50_cursor_show;
- crtc->cursor->hide = nv50_cursor_hide;
- crtc->cursor->set_pos = nv50_cursor_set_pos;
- crtc->cursor->set_offset = nv50_cursor_set_offset;
- crtc->cursor->set_bo = nv50_cursor_set_bo;
- return 0;
-}
+ struct drm_device *dev = crtc->base.dev;
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ int idx = crtc->index;
-int nv50_cursor_destroy(struct nouveau_crtc *crtc)
-{
DRM_DEBUG("\n");
- if (!crtc || !crtc->cursor)
- return -EINVAL;
-
- nv50_cursor_disable(crtc);
-
- kfree(crtc->cursor);
- crtc->cursor = NULL;
-
- return 0;
+ nv_wr32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0);
+ if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
+ NV50_PDISPLAY_CURSOR_CURSOR_CTRL2_STATUS_MASK, 0)) {
+ DRM_ERROR("timeout: CURSOR_CTRL2_STATUS == 0\n");
+ DRM_ERROR("CURSOR_CTRL2 = 0x%08x\n",
+ nv_rd32(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx)));
+ }
}
+
diff --git a/linux-core/nv50_cursor.h b/linux-core/nv50_cursor.h
deleted file mode 100644
index 089a69c9..00000000
--- a/linux-core/nv50_cursor.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2008 Maarten Maathuis.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#ifndef __NV50_CURSOR_H__
-#define __NV50_CURSOR_H__
-
-struct nv50_cursor {
- struct drm_gem_object *gem;
- int x, y;
- bool visible;
-
- int (*show) (struct nouveau_crtc *crtc, bool update);
- int (*hide) (struct nouveau_crtc *crtc, bool update);
- int (*set_pos) (struct nouveau_crtc *crtc, int x, int y);
- int (*set_offset) (struct nouveau_crtc *crtc);
- int (*set_bo) (struct nouveau_crtc *crtc, struct drm_gem_object *gem);
-};
-
-int nv50_cursor_create(struct nouveau_crtc *crtc);
-int nv50_cursor_destroy(struct nouveau_crtc *crtc);
-
-#endif /* __NV50_CURSOR_H__ */