2 * Copyright 2015 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
26 #include <engine/fifo.h>
29 nvkm_gr_tile(struct nvkm_engine
*engine
, int region
, struct nvkm_fb_tile
*tile
)
31 struct nvkm_gr
*gr
= nvkm_gr(engine
);
33 gr
->func
->tile(gr
, region
, tile
);
37 nvkm_gr_units(struct nvkm_gr
*gr
)
40 return gr
->func
->units(gr
);
45 nvkm_gr_tlb_flush(struct nvkm_gr
*gr
)
47 if (gr
->func
->tlb_flush
)
48 return gr
->func
->tlb_flush(gr
);
53 nvkm_gr_oclass_get(struct nvkm_oclass
*oclass
, int index
)
55 struct nvkm_gr
*gr
= nvkm_gr(oclass
->engine
);
58 if (gr
->func
->object_get
) {
59 int ret
= gr
->func
->object_get(gr
, index
, &oclass
->base
);
60 if (oclass
->base
.oclass
)
65 while (gr
->func
->sclass
[c
].oclass
) {
67 oclass
->base
= gr
->func
->sclass
[index
];
76 nvkm_gr_cclass_new(struct nvkm_fifo_chan
*chan
,
77 const struct nvkm_oclass
*oclass
,
78 struct nvkm_object
**pobject
)
80 struct nvkm_gr
*gr
= nvkm_gr(oclass
->engine
);
81 if (gr
->func
->chan_new
)
82 return gr
->func
->chan_new(gr
, chan
, oclass
, pobject
);
87 nvkm_gr_intr(struct nvkm_engine
*engine
)
89 struct nvkm_gr
*gr
= nvkm_gr(engine
);
94 nvkm_gr_oneinit(struct nvkm_engine
*engine
)
96 struct nvkm_gr
*gr
= nvkm_gr(engine
);
97 if (gr
->func
->oneinit
)
98 return gr
->func
->oneinit(gr
);
103 nvkm_gr_init(struct nvkm_engine
*engine
)
105 struct nvkm_gr
*gr
= nvkm_gr(engine
);
106 return gr
->func
->init(gr
);
110 nvkm_gr_dtor(struct nvkm_engine
*engine
)
112 struct nvkm_gr
*gr
= nvkm_gr(engine
);
114 return gr
->func
->dtor(gr
);
118 static const struct nvkm_engine_func
120 .dtor
= nvkm_gr_dtor
,
121 .oneinit
= nvkm_gr_oneinit
,
122 .init
= nvkm_gr_init
,
123 .intr
= nvkm_gr_intr
,
124 .tile
= nvkm_gr_tile
,
125 .fifo
.cclass
= nvkm_gr_cclass_new
,
126 .fifo
.sclass
= nvkm_gr_oclass_get
,
130 nvkm_gr_ctor(const struct nvkm_gr_func
*func
, struct nvkm_device
*device
,
131 int index
, u32 pmc_enable
, bool enable
, struct nvkm_gr
*gr
)
134 return nvkm_engine_ctor(&nvkm_gr
, device
, index
, pmc_enable
,
135 enable
, &gr
->engine
);