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_chsw_load(struct nvkm_engine
*engine
)
31 struct nvkm_gr
*gr
= nvkm_gr(engine
);
32 if (gr
->func
->chsw_load
)
33 return gr
->func
->chsw_load(gr
);
38 nvkm_gr_tile(struct nvkm_engine
*engine
, int region
, struct nvkm_fb_tile
*tile
)
40 struct nvkm_gr
*gr
= nvkm_gr(engine
);
42 gr
->func
->tile(gr
, region
, tile
);
46 nvkm_gr_units(struct nvkm_gr
*gr
)
49 return gr
->func
->units(gr
);
54 nvkm_gr_tlb_flush(struct nvkm_gr
*gr
)
56 if (gr
->func
->tlb_flush
)
57 return gr
->func
->tlb_flush(gr
);
62 nvkm_gr_oclass_get(struct nvkm_oclass
*oclass
, int index
)
64 struct nvkm_gr
*gr
= nvkm_gr(oclass
->engine
);
67 if (gr
->func
->object_get
) {
68 int ret
= gr
->func
->object_get(gr
, index
, &oclass
->base
);
69 if (oclass
->base
.oclass
)
74 while (gr
->func
->sclass
[c
].oclass
) {
76 oclass
->base
= gr
->func
->sclass
[index
];
85 nvkm_gr_cclass_new(struct nvkm_fifo_chan
*chan
,
86 const struct nvkm_oclass
*oclass
,
87 struct nvkm_object
**pobject
)
89 struct nvkm_gr
*gr
= nvkm_gr(oclass
->engine
);
90 if (gr
->func
->chan_new
)
91 return gr
->func
->chan_new(gr
, chan
, oclass
, pobject
);
96 nvkm_gr_intr(struct nvkm_engine
*engine
)
98 struct nvkm_gr
*gr
= nvkm_gr(engine
);
103 nvkm_gr_oneinit(struct nvkm_engine
*engine
)
105 struct nvkm_gr
*gr
= nvkm_gr(engine
);
106 if (gr
->func
->oneinit
)
107 return gr
->func
->oneinit(gr
);
112 nvkm_gr_init(struct nvkm_engine
*engine
)
114 struct nvkm_gr
*gr
= nvkm_gr(engine
);
115 return gr
->func
->init(gr
);
119 nvkm_gr_fini(struct nvkm_engine
*engine
, bool suspend
)
121 struct nvkm_gr
*gr
= nvkm_gr(engine
);
123 return gr
->func
->fini(gr
, suspend
);
128 nvkm_gr_dtor(struct nvkm_engine
*engine
)
130 struct nvkm_gr
*gr
= nvkm_gr(engine
);
132 return gr
->func
->dtor(gr
);
136 static const struct nvkm_engine_func
138 .dtor
= nvkm_gr_dtor
,
139 .oneinit
= nvkm_gr_oneinit
,
140 .init
= nvkm_gr_init
,
141 .fini
= nvkm_gr_fini
,
142 .intr
= nvkm_gr_intr
,
143 .tile
= nvkm_gr_tile
,
144 .chsw_load
= nvkm_gr_chsw_load
,
145 .fifo
.cclass
= nvkm_gr_cclass_new
,
146 .fifo
.sclass
= nvkm_gr_oclass_get
,
150 nvkm_gr_ctor(const struct nvkm_gr_func
*func
, struct nvkm_device
*device
,
151 int index
, bool enable
, struct nvkm_gr
*gr
)
154 return nvkm_engine_ctor(&nvkm_gr
, device
, index
, enable
, &gr
->engine
);