summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Mandin <patmandin@gmail.com>2009-11-29 09:25:11 +0100
committerPatrice Mandin <patmandin@gmail.com>2009-11-29 09:25:11 +0100
commit4171c3885428662d989efb93b9e858fa3801042c (patch)
treebd6d18265a179f6eddfe593e500ea247f1c46bcd
parente5cecb2501a6528e660b09e65fe25bc07b800c32 (diff)
More cleanup
-rw-r--r--fifo.c2
-rw-r--r--fifo.h3
-rw-r--r--object.c11
-rw-r--r--screen.c42
-rw-r--r--screen.h5
5 files changed, 19 insertions, 44 deletions
diff --git a/fifo.c b/fifo.c
index 5cc2c0a..fb62d1a 100644
--- a/fifo.c
+++ b/fifo.c
@@ -2,7 +2,6 @@
#include <stdio.h>
#include <stdint.h>
-#include <xf86drm.h>
#include <nouveau_drm.h>
#include <nouveau_channel.h>
@@ -24,5 +23,6 @@ void fifo_close(void)
{
if (chan) {
nouveau_channel_free(&chan);
+ chan = NULL;
}
}
diff --git a/fifo.h b/fifo.h
index 95b9a4c..134403d 100644
--- a/fifo.h
+++ b/fifo.h
@@ -1,9 +1,6 @@
#ifndef FIFO_H
#define FIFO_H
-#include <xf86drm.h>
-#include <nouveau_drm.h>
-
/* Defines */
#define METHOD_CONSTANT (1<<30)
diff --git a/object.c b/object.c
index c650e0e..a69290e 100644
--- a/object.c
+++ b/object.c
@@ -1,5 +1,5 @@
#include <stdio.h>
-#include <xf86drm.h>
+#include <stdint.h>
#include <nouveau_drm.h>
#include <nouveau_class.h>
#include <nouveau_notifier.h>
@@ -19,25 +19,32 @@ struct nouveau_grobj *grobj[6]={
int object_list_create(int class_3d)
{
if (nouveau_grobj_alloc(chan, Nv3D, class_3d, &grobj[NvSub3D])) {
+ object_list_close();
return 1;
}
if (nouveau_grobj_alloc(chan, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D, &grobj[NvSubCtxSurf2D])) {
+ object_list_close();
return 1;
}
if (nouveau_grobj_alloc(chan, NvImageBlit, NV12_IMAGE_BLIT, &grobj[NvSubImageBlit])) {
+ object_list_close();
return 1;
}
if (nouveau_grobj_alloc(chan, NvImagePattern, NV04_IMAGE_PATTERN, &grobj[NvSubImagePattern])) {
+ object_list_close();
return 1;
}
if (nouveau_grobj_alloc(chan, NvRasterOp, NV03_CONTEXT_ROP, &grobj[NvSubRasterOp])) {
+ object_list_close();
return 1;
}
if (nouveau_grobj_alloc(chan, NvClipRect, NV01_CONTEXT_CLIP_RECTANGLE, &grobj[NvSubClipRect])) {
+ object_list_close();
return 1;
}
if (nouveau_notifier_alloc(chan, NvSyncNotify, 1, &notifier)!=0) {
+ object_list_close();
return 1;
}
@@ -51,10 +58,12 @@ void object_list_close(void)
for (i=0; i<6; i++) {
if (grobj[i]) {
nouveau_grobj_free(&grobj[i]);
+ grobj[i] = NULL;
}
}
if (notifier) {
nouveau_notifier_free(&notifier);
+ notifier = NULL;
}
}
diff --git a/screen.c b/screen.c
index 23d2549..71dfde8 100644
--- a/screen.c
+++ b/screen.c
@@ -2,11 +2,10 @@
#include <stdio.h>
#include <stdint.h>
-#include <xf86drm.h>
-
#include <nouveau_drm.h>
#include <nouveau_drmif.h>
+#include "screen.h"
#include "object.h"
/* Global variables */
@@ -24,11 +23,6 @@ int viewport_w=512, viewport_h=512;
int drm_fd = -1;
struct nouveau_device *dev = NULL;
-/* Local variables */
-
-static int drm_ready = 0;
-/*static drm_context_t drm_context;*/
-
/* Functions */
int screen_open(int width, int height, int bpp)
@@ -43,31 +37,16 @@ int screen_open(int width, int height, int bpp)
}
ret = nouveau_device_open_existing(&dev, 0, drm_fd, 0);
- if (ret)
+ if (ret) {
+ screen_close();
return 1;
+ }
printf("screen: chipset: 0x%08x\n", dev->chipset);
printf("screen: vm_vram_base: 0x%lx\n", dev->vm_vram_base);
printf("screen: vm_vram_size: %d MB\n", (int) (dev->vm_vram_size >> 20));
printf("screen: vm_gart_size: %d MB\n", (int) (dev->vm_gart_size >> 20));
-#if 0
- int ret;
-
- drm_fd = drmOpen("nouveau", 0);
- if (drm_fd < 0) {
- drmError(drm_fd, __func__);
- fprintf(stderr, "failed to open drm\n");
- return 1;
- }
-
- ret=drmCreateContext(drm_fd, &drm_context);
- if (ret) {
- drmError(ret, __func__);
- fprintf(stderr, "failed to create context: %d\n", ret);
- return 1;
- }
-
screen_width = width;
screen_height = height;
screen_bpp = bpp;
@@ -77,20 +56,13 @@ int screen_open(int width, int height, int bpp)
screen_pitch = (screen_pitch | 255)+1; /* Align on 256 bytes boundary */
}
- printf("Screen: %dx%dx%d, pitch=%d, offset=0x%08x\n",
+ printf("screen: %dx%dx%d, pitch=%d, offset=0x%08x\n",
screen_width, screen_height, screen_bpp,
screen_pitch, screen_offset
);
- vram_base_phys = (uint32_t) get_param(NOUVEAU_GETPARAM_FB_PHYSICAL);
- vram_size = (uint32_t) get_param(NOUVEAU_GETPARAM_FB_SIZE);
- printf("VRAM:\t%p 0x%08x\n", vram_base_phys, vram_size);
+ /* TODO: if running with X, try to find front buffer offset and resolution */
- tt_base_phys = (uint32_t) get_param(NOUVEAU_GETPARAM_AGP_PHYSICAL);
- tt_size = (uint32_t) get_param(NOUVEAU_GETPARAM_AGP_SIZE);
- printf("TT:\t%p 0x%08x\n", tt_base_phys, tt_size);
-#endif
- drm_ready=1;
return 0;
}
@@ -98,9 +70,11 @@ void screen_close(void)
{
if (dev) {
nouveau_device_close(&dev);
+ dev = NULL;
}
if (drm_fd>=0) {
drmClose(drm_fd);
+ drm_fd = -1;
}
}
diff --git a/screen.h b/screen.h
index 1524dde..7813a02 100644
--- a/screen.h
+++ b/screen.h
@@ -13,11 +13,6 @@ extern int screen_pitch;
extern int viewport_x, viewport_y;
extern int viewport_w, viewport_h;
-/*extern uint32_t vram_base_phys;
-extern uint32_t vram_size;
-extern uint32_t tt_base_phys;
-extern uint32_t tt_size;*/
-
extern int drm_fd;
extern struct nouveau_device *dev;