Commit | Line | Data |
---|---|---|
ebb945a9 BS |
1 | /* |
2 | * Copyright 2012 Red Hat Inc. | |
3 | * | |
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: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
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. | |
21 | * | |
22 | * Authors: Ben Skeggs | |
23 | */ | |
898a2b32 BS |
24 | #include "priv.h" |
25 | #include "chan.h" | |
26 | #include "nvsw.h" | |
ebb945a9 | 27 | |
f58ddf95 BS |
28 | #include <nvif/ioctl.h> |
29 | ||
ebb945a9 BS |
30 | /******************************************************************************* |
31 | * software context | |
32 | ******************************************************************************/ | |
33 | ||
61570911 | 34 | static const struct nvkm_sw_chan_func |
07b9e6cc | 35 | nv10_sw_chan = { |
61570911 BS |
36 | }; |
37 | ||
ebb945a9 | 38 | static int |
07b9e6cc BS |
39 | nv10_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifo, |
40 | const struct nvkm_oclass *oclass, struct nvkm_object **pobject) | |
ebb945a9 | 41 | { |
226dcefe | 42 | struct nvkm_sw_chan *chan; |
ebb945a9 | 43 | |
07b9e6cc BS |
44 | if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL))) |
45 | return -ENOMEM; | |
46 | *pobject = &chan->object; | |
ebb945a9 | 47 | |
07b9e6cc | 48 | return nvkm_sw_chan_ctor(&nv10_sw_chan, sw, fifo, oclass, chan); |
ebb945a9 BS |
49 | } |
50 | ||
ebb945a9 BS |
51 | /******************************************************************************* |
52 | * software engine/subdev functions | |
53 | ******************************************************************************/ | |
54 | ||
07b9e6cc BS |
55 | static const struct nvkm_sw_func |
56 | nv10_sw = { | |
57 | .chan_new = nv10_sw_chan_new, | |
58 | .sclass = { | |
59 | { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV10 } }, | |
60 | {} | |
61 | } | |
62 | }; | |
63 | ||
ebb945a9 | 64 | static int |
f84aff4e BS |
65 | nv10_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine, |
66 | struct nvkm_oclass *oclass, void *data, u32 size, | |
67 | struct nvkm_object **pobject) | |
ebb945a9 | 68 | { |
226dcefe | 69 | struct nvkm_sw *sw; |
ebb945a9 BS |
70 | int ret; |
71 | ||
226dcefe BS |
72 | ret = nvkm_sw_create(parent, engine, oclass, &sw); |
73 | *pobject = nv_object(sw); | |
ebb945a9 BS |
74 | if (ret) |
75 | return ret; | |
76 | ||
07b9e6cc | 77 | sw->func = &nv10_sw; |
226dcefe | 78 | nv_subdev(sw)->intr = nv04_sw_intr; |
ebb945a9 BS |
79 | return 0; |
80 | } | |
81 | ||
f84aff4e BS |
82 | struct nvkm_oclass * |
83 | nv10_sw_oclass = &(struct nvkm_oclass) { | |
ebb945a9 | 84 | .handle = NV_ENGINE(SW, 0x10), |
f84aff4e | 85 | .ofuncs = &(struct nvkm_ofuncs) { |
8700287b | 86 | .ctor = nv10_sw_ctor, |
f84aff4e BS |
87 | .dtor = _nvkm_sw_dtor, |
88 | .init = _nvkm_sw_init, | |
89 | .fini = _nvkm_sw_fini, | |
ebb945a9 BS |
90 | }, |
91 | }; |