/*
* Copyright 2012 Red Hat Inc.
*
* 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 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 HOLDER(S) OR AUTHOR(S) 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.
*
* Authors: Ben Skeggs
*/
#include <core/os.h>
#include <core/class.h>
#include <core/client.h>
#include <core/handle.h>
#include <core/engctx.h>
#include <core/enum.h>
#include <subdev/fb.h>
#include <subdev/vm.h>
#include <subdev/timer.h>
#include <engine/fifo.h>
#include <engine/graph.h>
#include "nv50.h"
struct nv50_graph_priv {
struct nouveau_graph base;
spinlock_t lock;
u32 size;
};
struct nv50_graph_chan {
struct nouveau_graph_chan base;
};
static u64
nv50_graph_units(struct nouveau_graph *graph)
{
struct nv50_graph_priv *priv = (void *)graph;
return nv_rd32(priv, 0x1540);
}
/*******************************************************************************
* Graphics object classes
******************************************************************************/
static int
nv50_graph_object_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nouveau_gpuobj *obj;
int ret;
ret = nouveau_gpuobj_create(parent, engine, oclass, 0, parent,
16, 16, 0, &obj);
*pobject = nv_object(obj);
if (ret)
return ret;
nv_wo32(obj, 0x00, nv_mclass(obj));
nv_wo32(obj, 0x04, 0x00000000);
nv_wo32(obj, 0x08, 0x00000000);
nv_wo32(obj, 0x0c, 0x00000000);
return 0;
}
static struct nouveau_ofuncs
nv50_graph_ofuncs = {
.ctor = nv50_graph_object_ctor,
.dtor = _nouveau_gpuobj_dtor,
.init = _nouveau_gpuobj_init,
.fini = _nouveau_gpuobj_fini,
.rd32 = _nouveau_gpuobj_rd32,
.wr32 = _nouveau_gpuobj_wr32,
};
static struct nouveau_oclass
nv50_graph_sclass[] = {
{ 0x0030, &nv50_graph_ofuncs },
{ 0x502d, &nv50_graph_ofuncs },
{ 0x5039, &nv50_graph_ofuncs },
{ 0x5097, &nv50_graph_ofuncs },
{ 0x50c0, &nv50_graph_ofuncs },
{}
};
static struct nouveau_oclass
nv84_graph_sclass[] = {
{ 0x0030, &nv50_graph_ofuncs },
{ 0x502d, &nv50_graph_ofuncs },
{ 0x5039, &nv50_graph_ofuncs },
{ 0x50c0, &nv50_graph_ofuncs },
{ 0x8297, &nv50_graph_ofuncs },
{}
};
static struct nouveau_oclass
nva0_graph_sclass[] = {
{ 0x0030, &nv50_graph_ofuncs },
{ 0x502d, &nv50_graph_ofuncs },
{ 0x5039, &nv50_graph_ofuncs },
{ 0x50c0, &nv50_graph_ofuncs },
{ 0x8397, &nv50_graph_ofuncs },
{}
};
static struct nouveau_oclass
nva3_graph_sclass[] = {
{ 0x0030, &nv50_graph_ofuncs },
{ 0x502d, &nv50_graph_ofuncs },
{ 0x5039, &nv50_graph_ofuncs },
{ 0x50c0, &nv50_graph_ofuncs },
{ 0x8597, &nv50_graph_ofuncs },
{ 0x85c0, &nv50_graph_ofuncs },
{}
};
static struct nouveau_oclass
nvaf_graph_sclass[] = {
{ 0x0030, &nv50_graph_ofuncs },
{ 0x502d, &nv50_graph_ofuncs },
{ 0x5039, &nv50_graph_ofuncs },
{ 0x50c0, &nv50_graph_ofuncs },
{ 0x85c0, &nv50_graph_ofuncs },
{ 0x8697, &nv50_graph_ofuncs },
{}
};
/*******************************************************************************
* PGRAPH context
******************************************************************************/
static int
nv50_graph_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv50_graph_priv *priv = (void *)engine;
struct nv50_graph_chan *chan;
int ret;
ret = nouveau_graph_context_create(parent,