1 | /* $NetBSD: nouveau_engine_software_nv10.c,v 1.1.1.1 2014/08/06 12:36:27 riastradh Exp $ */ |
2 | |
3 | /* |
4 | * Copyright 2012 Red Hat Inc. |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the |
11 | * Software is furnished to do so, subject to the following conditions: |
12 | * |
13 | * The above copyright notice and this permission notice shall be included in |
14 | * all copies or substantial portions of the Software. |
15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * |
24 | * Authors: Ben Skeggs |
25 | */ |
26 | |
27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_engine_software_nv10.c,v 1.1.1.1 2014/08/06 12:36:27 riastradh Exp $" ); |
29 | |
30 | #include <core/os.h> |
31 | #include <core/class.h> |
32 | #include <core/engctx.h> |
33 | |
34 | #include <engine/software.h> |
35 | |
36 | struct nv10_software_priv { |
37 | struct nouveau_software base; |
38 | }; |
39 | |
40 | struct nv10_software_chan { |
41 | struct nouveau_software_chan base; |
42 | }; |
43 | |
44 | /******************************************************************************* |
45 | * software object classes |
46 | ******************************************************************************/ |
47 | |
48 | static int |
49 | nv10_software_flip(struct nouveau_object *object, u32 mthd, |
50 | void *args, u32 size) |
51 | { |
52 | struct nv10_software_chan *chan = (void *)nv_engctx(object->parent); |
53 | if (chan->base.flip) |
54 | return chan->base.flip(chan->base.flip_data); |
55 | return -EINVAL; |
56 | } |
57 | |
58 | static struct nouveau_omthds |
59 | nv10_software_omthds[] = { |
60 | { 0x0500, 0x0500, nv10_software_flip }, |
61 | {} |
62 | }; |
63 | |
64 | static struct nouveau_oclass |
65 | nv10_software_sclass[] = { |
66 | { 0x016e, &nouveau_object_ofuncs, nv10_software_omthds }, |
67 | {} |
68 | }; |
69 | |
70 | /******************************************************************************* |
71 | * software context |
72 | ******************************************************************************/ |
73 | |
74 | static int |
75 | nv10_software_context_ctor(struct nouveau_object *parent, |
76 | struct nouveau_object *engine, |
77 | struct nouveau_oclass *oclass, void *data, u32 size, |
78 | struct nouveau_object **pobject) |
79 | { |
80 | struct nv10_software_chan *chan; |
81 | int ret; |
82 | |
83 | ret = nouveau_software_context_create(parent, engine, oclass, &chan); |
84 | *pobject = nv_object(chan); |
85 | if (ret) |
86 | return ret; |
87 | |
88 | return 0; |
89 | } |
90 | |
91 | static struct nouveau_oclass |
92 | nv10_software_cclass = { |
93 | .handle = NV_ENGCTX(SW, 0x04), |
94 | .ofuncs = &(struct nouveau_ofuncs) { |
95 | .ctor = nv10_software_context_ctor, |
96 | .dtor = _nouveau_software_context_dtor, |
97 | .init = _nouveau_software_context_init, |
98 | .fini = _nouveau_software_context_fini, |
99 | }, |
100 | }; |
101 | |
102 | /******************************************************************************* |
103 | * software engine/subdev functions |
104 | ******************************************************************************/ |
105 | |
106 | static int |
107 | nv10_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
108 | struct nouveau_oclass *oclass, void *data, u32 size, |
109 | struct nouveau_object **pobject) |
110 | { |
111 | struct nv10_software_priv *priv; |
112 | int ret; |
113 | |
114 | ret = nouveau_software_create(parent, engine, oclass, &priv); |
115 | *pobject = nv_object(priv); |
116 | if (ret) |
117 | return ret; |
118 | |
119 | nv_engine(priv)->cclass = &nv10_software_cclass; |
120 | nv_engine(priv)->sclass = nv10_software_sclass; |
121 | nv_subdev(priv)->intr = nv04_software_intr; |
122 | return 0; |
123 | } |
124 | |
125 | struct nouveau_oclass * |
126 | nv10_software_oclass = &(struct nouveau_oclass) { |
127 | .handle = NV_ENGINE(SW, 0x10), |
128 | .ofuncs = &(struct nouveau_ofuncs) { |
129 | .ctor = nv10_software_ctor, |
130 | .dtor = _nouveau_software_dtor, |
131 | .init = _nouveau_software_init, |
132 | .fini = _nouveau_software_fini, |
133 | }, |
134 | }; |
135 | |