summaryrefslogtreecommitdiff
path: root/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c42
1 files changed, 8 insertions, 34 deletions
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;
}
}