Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nv10.c
Go to the documentation of this file.
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  */
24 
25 #include <core/os.h>
26 #include <core/class.h>
27 #include <core/engctx.h>
28 
29 #include <engine/software.h>
30 
33 };
34 
37 };
38 
39 /*******************************************************************************
40  * software object classes
41  ******************************************************************************/
42 
43 static int
44 nv10_software_flip(struct nouveau_object *object, u32 mthd,
45  void *args, u32 size)
46 {
47  struct nv10_software_chan *chan = (void *)nv_engctx(object->parent);
48  if (chan->base.flip)
49  return chan->base.flip(chan->base.flip_data);
50  return -EINVAL;
51 }
52 
53 static struct nouveau_omthds
54 nv10_software_omthds[] = {
55  { 0x0500, nv10_software_flip },
56  {}
57 };
58 
59 static struct nouveau_oclass
60 nv10_software_sclass[] = {
61  { 0x016e, &nouveau_object_ofuncs, nv10_software_omthds },
62  {}
63 };
64 
65 /*******************************************************************************
66  * software context
67  ******************************************************************************/
68 
69 static int
70 nv10_software_context_ctor(struct nouveau_object *parent,
71  struct nouveau_object *engine,
72  struct nouveau_oclass *oclass, void *data, u32 size,
73  struct nouveau_object **pobject)
74 {
75  struct nv10_software_chan *chan;
76  int ret;
77 
78  ret = nouveau_software_context_create(parent, engine, oclass, &chan);
79  *pobject = nv_object(chan);
80  if (ret)
81  return ret;
82 
83  return 0;
84 }
85 
86 static struct nouveau_oclass
87 nv10_software_cclass = {
88  .handle = NV_ENGCTX(SW, 0x04),
89  .ofuncs = &(struct nouveau_ofuncs) {
90  .ctor = nv10_software_context_ctor,
94  },
95 };
96 
97 /*******************************************************************************
98  * software engine/subdev functions
99  ******************************************************************************/
100 
101 static int
102 nv10_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
103  struct nouveau_oclass *oclass, void *data, u32 size,
104  struct nouveau_object **pobject)
105 {
106  struct nv10_software_priv *priv;
107  int ret;
108 
109  ret = nouveau_software_create(parent, engine, oclass, &priv);
110  *pobject = nv_object(priv);
111  if (ret)
112  return ret;
113 
114  nv_engine(priv)->cclass = &nv10_software_cclass;
115  nv_engine(priv)->sclass = nv10_software_sclass;
116  nv_subdev(priv)->intr = nv04_software_intr;
117  return 0;
118 }
119 
120 struct nouveau_oclass
122  .handle = NV_ENGINE(SW, 0x10),
123  .ofuncs = &(struct nouveau_ofuncs) {
124  .ctor = nv10_software_ctor,
125  .dtor = _nouveau_software_dtor,
126  .init = _nouveau_software_init,
127  .fini = _nouveau_software_fini,
128  },
129 };