/* * Copyright (C) 2007 Ben Skeggs. * 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. * */ #include "drmP.h" #include "drm.h" #include "nouveau_drv.h" /* The sizes are taken from the difference between the start of two * grctx addresses while running the nvidia driver. Probably slightly * larger than they actually are, because of other objects being created * between the contexts */ #define NV40_GRCTX_SIZE (175*1024) #define NV41_GRCTX_SIZE (92*1024) #define NV43_GRCTX_SIZE (70*1024) #define NV46_GRCTX_SIZE (70*1024) /* probably ~64KiB */ #define NV47_GRCTX_SIZE (125*1024) #define NV49_GRCTX_SIZE (164640) #define NV4A_GRCTX_SIZE (64*1024) #define NV4B_GRCTX_SIZE (164640) #define NV4C_GRCTX_SIZE (25*1024) #define NV4E_GRCTX_SIZE (25*1024) /*TODO: deciper what each offset in the context represents. The below * contexts are taken from dumps just after the 3D object is * created. */ static void nv40_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx) { struct drm_nouveau_private *dev_priv = dev->dev_private; int i; /* Always has the "instance address" of itself at offset 0 */ INSTANCE_WR(ctx, 0x00000/4, ctx->im_pramin->start); /* unknown */ INSTANCE_WR(ctx, 0x00024/4, 0x0000ffff); INSTANCE_WR(ctx, 0x00028/4, 0x0000ffff); INSTANCE_WR(ctx, 0x00030/4, 0x00000001); INSTANCE_WR(ctx, 0x0011c/4, 0x20010001); INSTANCE_WR(ctx, 0x00120/4, 0x0f73ef00); INSTANCE_WR(ctx, 0x00128/4, 0x02008821); INSTANCE_WR(ctx, 0x0016c/4, 0x00000040); INSTANCE_WR(ctx, 0x00170/4, 0x00000040); INSTANCE_WR(ctx, 0x00174/4, 0x00000040); INSTANCE_WR(ctx, 0x0017c/4, 0x80000000); INSTANCE_WR(ctx, 0x00180/4, 0x80000000); INSTANCE_WR(ctx, 0x00184/4, 0x80000000); INSTANCE_WR(ctx, 0x00188/4, 0x80000000); INSTANCE_WR(ctx, 0x0018c/4, 0x80000000); INSTANCE_WR(ctx, 0x0019c/4, 0x00000040); INSTANCE_WR(ctx, 0x001a0/4, 0x80000000); INSTANCE_WR(ctx, 0x001b0/4, 0x80000000); INSTANCE_WR(ctx, 0x001c0/4, 0x80000000); INSTANCE_WR(ctx, 0x001d0/4, 0x0b0b0b0c); INSTAN