diff options
author | Patrice Mandin <pmandin@caramail.com> | 2008-08-26 22:25:23 +0200 |
---|---|---|
committer | Patrice Mandin <pmandin@caramail.com> | 2008-08-26 22:25:23 +0200 |
commit | 4dbe6cfa1aca9ba81a3285975ce47e3ead21fc84 (patch) | |
tree | 87badf519b486db38f5ed5e757fe491e0209ca83 | |
parent | e1520747d8a8cdacfdefdd212da285f36403f493 (diff) |
Add more objects
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | clip_rectangle.c | 22 | ||||
-rw-r--r-- | clip_rectangle.h | 6 | ||||
-rw-r--r-- | context_surface_2d.c | 31 | ||||
-rw-r--r-- | context_surface_2d.h | 6 | ||||
-rw-r--r-- | imageblit.c | 13 | ||||
-rw-r--r-- | object.c | 23 | ||||
-rw-r--r-- | object.h | 1 | ||||
-rw-r--r-- | screen.c | 3 | ||||
-rw-r--r-- | screen.h | 3 | ||||
-rw-r--r-- | tcl_init.c | 36 |
11 files changed, 118 insertions, 33 deletions
@@ -1,8 +1,9 @@ SOURCES = main.c screen.c fifo.c object.c test_nops.c \ - tcl_init.c tcl_triangle.c imageblit.c + tcl_init.c tcl_triangle.c imageblit.c context_surface_2d.c \ + clip_rectangle.c HEADERS = screen.h fifo.h object.h test_nops.h \ - tcl_init.h tcl_triangle.h imageblit.h \ - nv30_fpinst.h + tcl_init.h tcl_triangle.h imageblit.h context_surface_2d.h \ + clip_rectangle.h nv30_fpinst.h OBJECTS = $(SOURCES:%.c=%.o) diff --git a/clip_rectangle.c b/clip_rectangle.c new file mode 100644 index 0000000..0671ce5 --- /dev/null +++ b/clip_rectangle.c @@ -0,0 +1,22 @@ +#include <stdio.h> + +#include "screen.h" +#include "object.h" +#include "fifo.h" +#include "nouveau_class.h" + +void clip_rectangle_init(void) +{ + printf("-- Clip rectangle, init\n"); + + SetSubchannel(NvSubClipRect, NvClipRect); + + BEGIN_RING(NvSubClipRect, NV01_CONTEXT_CLIP_RECTANGLE_DMA_NOTIFY, 1); + OUT_RING(NvSyncNotify); + + BEGIN_RING(NvSubClipRect, NV01_CONTEXT_CLIP_RECTANGLE_POINT, 2); + OUT_RING ((viewport_y<<16) | viewport_x); + OUT_RING ((viewport_h<<16) | viewport_w); + + FIRE_RING(); +} diff --git a/clip_rectangle.h b/clip_rectangle.h new file mode 100644 index 0000000..a4eab18 --- /dev/null +++ b/clip_rectangle.h @@ -0,0 +1,6 @@ +#ifndef CLIP_RECTANGLE_H +#define CLIP_RECTANGLE_H + +void clip_rectangle_init(void); + +#endif diff --git a/context_surface_2d.c b/context_surface_2d.c new file mode 100644 index 0000000..accc6f1 --- /dev/null +++ b/context_surface_2d.c @@ -0,0 +1,31 @@ +#include <stdio.h> + +#include "screen.h" +#include "object.h" +#include "fifo.h" +#include "nouveau_class.h" + +void context_surface_2d_init(void) +{ + printf("-- Context surface 2D, init\n"); + + SetSubchannel(NvSubCtxSurf2D, NvCtxSurf2D); + + BEGIN_RING(NvSubCtxSurf2D, NV04_CONTEXT_SURFACES_2D_DMA_NOTIFY, 1); + OUT_RING (NvSyncNotify); + + BEGIN_RING(NvSubCtxSurf2D, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2); + OUT_RING (NvDmaFB); + OUT_RING (NvDmaFB); + + BEGIN_RING(NvSubCtxSurf2D, NV04_CONTEXT_SURFACES_2D_FORMAT, 4); + OUT_RING( (screen_bpp==32) + ? NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8 + : NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5 + ); + OUT_RING ((screen_pitch<<16)|screen_pitch); + OUT_RING (screen_offset); /* src */ + OUT_RING (screen_offset); /* dst */ + + FIRE_RING(); +} diff --git a/context_surface_2d.h b/context_surface_2d.h new file mode 100644 index 0000000..5becd22 --- /dev/null +++ b/context_surface_2d.h @@ -0,0 +1,6 @@ +#ifndef CONTEXT_SURFACE_2D_H +#define CONTEXT_SURFACE_2D_H + +void context_surface_2d_init(void); + +#endif diff --git a/imageblit.c b/imageblit.c index af8d54a..f09fb69 100644 --- a/imageblit.c +++ b/imageblit.c @@ -11,26 +11,31 @@ void imageblit_init(void) SetSubchannel(NvSubImageBlit, NvImageBlit); + BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_NOTIFY, 1); + OUT_RING(NvSyncNotify); + BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_SURFACE, 1); OUT_RING(NvCtxSurf2D); BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_CLIP_RECTANGLE, 1); OUT_RING(NvClipRect); - BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_PATTERN, 1); + /*BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_PATTERN, 1); OUT_RING(NvImagePattern); BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_ROP, 1); OUT_RING(NvRasterOp); BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_OPERATION, 1); - OUT_RING(NV04_IMAGE_BLIT_OPERATION_SRCCOPY); + OUT_RING(NV04_IMAGE_BLIT_OPERATION_SRCCOPY);*/ FIRE_RING(); } void imageblit_copy(int sx,int sy, int dx,int dy, int w,int h) { + printf("--ImageBlit, copy\n"); + SetSubchannel(NvSubImageBlit, NvImageBlit); - BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_SURFACE, 1); - OUT_RING (NvCtxSurf2D); + /*BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_SURFACE, 1); + OUT_RING (NvCtxSurf2D);*/ BEGIN_RING(NvSubImageBlit, NV04_IMAGE_BLIT_OPERATION, 1); OUT_RING (NV04_IMAGE_BLIT_OPERATION_SRCCOPY); @@ -7,6 +7,8 @@ #include "object.h" #include "nouveau_class.h" +struct drm_nouveau_notifierobj_alloc o_nvsyncnotify; + static int object_create(int handle, int num_class) { int ret; @@ -18,10 +20,22 @@ static int object_create(int handle, int num_class) ret = drmCommandWrite(drm_fd, DRM_NOUVEAU_GROBJ_ALLOC, &o_ctx, sizeof(o_ctx)); if (ret) { fprintf(stderr, "Failed to create object, handle 0x%08x, class 0x%08x\n", handle, num_class); - return 1; } + return ret; +} - return 0; +static int notifier_obj_create(struct drm_nouveau_notifierobj_alloc *o_ctx, int handle, int count) +{ + int ret; + + o_ctx->channel = init.channel; + o_ctx->handle = handle; + o_ctx->count = count; + ret = drmCommandWriteRead(drm_fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC, o_ctx, sizeof(*o_ctx)); + if (ret) { + fprintf(stderr, "failed to create handle=0x%08x, class 0x%08x\n", handle, count); + } + return ret; } int object_list_create(int class_3d) @@ -44,5 +58,10 @@ int object_list_create(int class_3d) if (object_create(NvClipRect, NV01_CONTEXT_CLIP_RECTANGLE)!=0) { return 1; } + + if (notifier_obj_create(&o_nvsyncnotify, NvSyncNotify, 1)!=0) { + return 1; + } + return 0; } @@ -4,6 +4,7 @@ /* Defines */ enum Objects { + NvSyncNotify = 0xD0000001, NvDmaFB = 0xD0FB0001, NvDmaTT = 0xD0AA0001, Nv3D = 0x80970001, @@ -14,6 +14,9 @@ int screen_offset; int screen_pitch; +int viewport_x=0, viewport_y=0; +int viewport_w=512, viewport_h=512; + uint32_t vram_base_phys = 0; uint32_t vram_size = 0; uint32_t tt_base_phys = 0; @@ -12,6 +12,9 @@ extern int screen_offset; 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; @@ -5,9 +5,6 @@ #include "nouveau_class.h" #include "nv30_fpinst.h" -#define VIEWPORT_WIDTH 512 -#define VIEWPORT_HEIGHT 512 - static void tcl_fp_color(void) { volatile unsigned int *fragprog_map; @@ -82,14 +79,10 @@ void tcl_init(void) BEGIN_RING(NvSub3D, NV34TCL_DMA_IN_MEMORY7, 1); OUT_RING(NvDmaFB); /* beef0201 1ac */ - BEGIN_RING(NvSub3D, NV34TCL_RT_HORIZ, 2); - OUT_RING(VIEWPORT_WIDTH<<16); - OUT_RING(VIEWPORT_HEIGHT<<16); - BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING((VIEWPORT_WIDTH-1)<<16); + OUT_RING((viewport_w-1)<<16); BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING((VIEWPORT_HEIGHT-1)<<16); + OUT_RING((viewport_h-1)<<16); for (i=1; i<8; i++) { BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1); OUT_RING(0); @@ -136,21 +129,16 @@ void tcl_init(void) OUT_RING(2); BEGIN_RING(NvSub3D, NV34TCL_RT_HORIZ, 2); - OUT_RING(VIEWPORT_WIDTH<<16); - OUT_RING(VIEWPORT_HEIGHT<<16); + OUT_RING(viewport_w<<16); + OUT_RING(viewport_h<<16); BEGIN_RING(NvSub3D, 0x1d88, 1); OUT_RING(0x1200); BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_HORIZ, 2); - OUT_RING(VIEWPORT_WIDTH<<16); - OUT_RING(VIEWPORT_HEIGHT<<16); + OUT_RING(viewport_w<<16); + OUT_RING(viewport_h<<16); BEGIN_RING(NvSub3D, NV34TCL_SCISSOR_HORIZ, 2); - OUT_RING(VIEWPORT_WIDTH<<16); - OUT_RING(VIEWPORT_HEIGHT<<16); - BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf(0.0); - OUT_RINGf(VIEWPORT_WIDTH * 1.0); - OUT_RINGf(0.0); - OUT_RINGf(0.0); + OUT_RING(viewport_w<<16); + OUT_RING(viewport_h<<16); BEGIN_RING(NvSub3D, NV34TCL_RT_FORMAT, 1); OUT_RING(NV34TCL_RT_FORMAT_TYPE_LINEAR | NV34TCL_RT_FORMAT_ZETA_Z24S8 | NV34TCL_RT_FORMAT_COLOR_A8R8G8B8); BEGIN_RING(NvSub3D, 0x1da4, 1); @@ -330,13 +318,13 @@ void tcl_init(void) OUT_RING(NV34TCL_ENGINE_FIXED); BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_TRANSLATE_X, 4); - OUT_RINGf(VIEWPORT_WIDTH / 2.0); - OUT_RINGf(VIEWPORT_HEIGHT / 2.0); + OUT_RINGf(viewport_w / 2.0); + OUT_RINGf(viewport_h / 2.0); OUT_RINGf(0.5); OUT_RINGf(0.0); BEGIN_RING(NvSub3D, NV34TCL_VIEWPORT_SCALE_X, 4); - OUT_RINGf(VIEWPORT_WIDTH / 2.0); - OUT_RINGf(VIEWPORT_HEIGHT / -2.0); + OUT_RINGf(viewport_w / 2.0); + OUT_RINGf(viewport_h / -2.0); OUT_RINGf(0.5); OUT_RINGf(0.0); |