int nv04[sizeof(nv04_graph_ctx_regs)/sizeof(nv04_graph_ctx_regs[0])];
};
-/* TODO dynamic allocation ??? */
-static struct graph_state graph_state[16];
-
void nouveau_nv04_context_switch(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
}
int nv04_graph_create_context(struct nouveau_channel *chan) {
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx;
DRM_DEBUG("nv04_graph_context_create %d\n", chan->id);
- memset(pgraph_ctx, 0, sizeof(*pgraph_ctx));
+ chan->pgraph_ctx = pgraph_ctx = drm_calloc(1, sizeof(*pgraph_ctx),
+ DRM_MEM_DRIVER);
+
+ if (pgraph_ctx == NULL)
+ return -ENOMEM;
//dev_priv->fifos[channel].pgraph_ctx_user = channel << 24;
pgraph_ctx->nv04[0] = 0x0001ffff;
void nv04_graph_destroy_context(struct nouveau_channel *chan)
{
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
+
+ drm_free(pgraph_ctx, sizeof(*pgraph_ctx), DRM_MEM_DRIVER);
+ chan->pgraph_ctx = NULL;
}
int nv04_graph_load_context(struct nouveau_channel *chan)
{
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
int i;
for (i = 0; i < sizeof(nv04_graph_ctx_regs)/sizeof(nv04_graph_ctx_regs[0]); i++)
{
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
int i;
for (i = 0; i < sizeof(nv04_graph_ctx_regs)/sizeof(nv04_graph_ctx_regs[0]); i++)
struct graph_state {
int nv10[sizeof(nv10_graph_ctx_regs)/sizeof(nv10_graph_ctx_regs[0])];
int nv17[sizeof(nv17_graph_ctx_regs)/sizeof(nv17_graph_ctx_regs[0])];
+ struct pipe_state pipe_state;
};
-/* TODO dynamic allocation ??? */
-static struct pipe_state pipe_state[NV10_FIFO_NUMBER];
-static struct graph_state graph_state[NV10_FIFO_NUMBER];
-
-
static void nv10_graph_save_pipe(struct nouveau_channel *chan) {
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct pipe_state *fifo_pipe_state = pipe_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
+ struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state;
int i;
#define PIPE_SAVE(addr) \
do { \
static void nv10_graph_load_pipe(struct nouveau_channel *chan) {
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct pipe_state *fifo_pipe_state = pipe_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
+ struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state;
int i;
uint32_t xfmode0, xfmode1;
#define PIPE_RESTORE(addr) \
}
static void nv10_graph_create_pipe(struct nouveau_channel *chan) {
- struct pipe_state *fifo_pipe_state = pipe_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
+ struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state;
uint32_t *fifo_pipe_state_addr;
int i;
#define PIPE_INIT(addr) \
{
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
int i;
for (i = 0; i < sizeof(nv10_graph_ctx_regs)/sizeof(nv10_graph_ctx_regs[0]); i++)
{
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
int i;
for (i = 0; i < sizeof(nv10_graph_ctx_regs)/sizeof(nv10_graph_ctx_regs[0]); i++)
int nv10_graph_create_context(struct nouveau_channel *chan) {
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct graph_state* pgraph_ctx = graph_state + chan->id;
+ struct graph_state* pgraph_ctx;
DRM_DEBUG("nv10_graph_context_create %d\n", chan->id);
- memset(pgraph_ctx, 0, sizeof(*pgraph_ctx));
+ chan->pgraph_ctx = pgraph_ctx = drm_calloc(1, sizeof(*pgraph_ctx),
+ DRM_MEM_DRIVER);
+
+ if (pgraph_ctx == NULL)
+ return -ENOMEM;
/* mmio trace suggest that should be done in ddx with methods/objects */
#if 0
{
struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct graph_state* pgraph_ctx = chan->pgraph_ctx;
int chid;
+
+ drm_free(pgraph_ctx, sizeof(*pgraph_ctx), DRM_MEM_DRIVER);
+ chan->pgraph_ctx = NULL;
+
chid = (NV_READ(NV10_PGRAPH_CTX_USER) >> 24) & (nouveau_fifo_number(dev)-1);
/* This code seems to corrupt the 3D pipe, but blob seems to do similar things ????
DRM_INFO("cleanning a channel with graph in current context\n");
nouveau_wait_for_idle(dev);
DRM_INFO("reseting current graph context\n");
- nv10_graph_create_context(chan);
+ /* can't be call here because of dynamic mem alloc */
+ //nv10_graph_create_context(chan);
nv10_graph_load_context(chan);
}
NV_WRITE(NV04_PGRAPH_FIFO, 0x1);