Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nv04.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 #include <engine/fifo.h>
31 
34 };
35 
38 };
39 
40 /*******************************************************************************
41  * software object classes
42  ******************************************************************************/
43 
44 static int
45 nv04_software_set_ref(struct nouveau_object *object, u32 mthd,
46  void *data, u32 size)
47 {
48  struct nouveau_object *channel = (void *)nv_engctx(object->parent);
49  struct nouveau_fifo_chan *fifo = (void *)channel->parent;
50  atomic_set(&fifo->refcnt, *(u32*)data);
51  return 0;
52 }
53 
54 static int
55 nv04_software_flip(struct nouveau_object *object, u32 mthd,
56  void *args, u32 size)
57 {
58  struct nv04_software_chan *chan = (void *)nv_engctx(object->parent);
59  if (chan->base.flip)
60  return chan->base.flip(chan->base.flip_data);
61  return -EINVAL;
62 }
63 
64 static struct nouveau_omthds
65 nv04_software_omthds[] = {
66  { 0x0150, nv04_software_set_ref },
67  { 0x0500, nv04_software_flip },
68  {}
69 };
70 
71 static struct nouveau_oclass
72 nv04_software_sclass[] = {
73  { 0x006e, &nouveau_object_ofuncs, nv04_software_omthds },
74  {}
75 };
76 
77 /*******************************************************************************
78  * software context
79  ******************************************************************************/
80 
81 static int
82 nv04_software_context_ctor(struct nouveau_object *parent,
83  struct nouveau_object *engine,
84  struct nouveau_oclass *oclass, void *data, u32 size,
85  struct nouveau_object **pobject)
86 {
87  struct nv04_software_chan *chan;
88  int ret;
89 
90  ret = nouveau_software_context_create(parent, engine, oclass, &chan);
91  *pobject = nv_object(chan);
92  if (ret)
93  return ret;
94 
95  return 0;
96 }
97 
98 static struct nouveau_oclass
99 nv04_software_cclass = {
100  .handle = NV_ENGCTX(SW, 0x04),
101  .ofuncs = &(struct nouveau_ofuncs) {
102  .ctor = nv04_software_context_ctor,
106  },
107 };
108 
109 /*******************************************************************************
110  * software engine/subdev functions
111  ******************************************************************************/
112 
113 void
115 {
116  nv_mask(subdev, 0x000100, 0x80000000, 0x00000000);
117 }
118 
119 static int
120 nv04_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
121  struct nouveau_oclass *oclass, void *data, u32 size,
122  struct nouveau_object **pobject)
123 {
124  struct nv04_software_priv *priv;
125  int ret;
126 
127  ret = nouveau_software_create(parent, engine, oclass, &priv);
128  *pobject = nv_object(priv);
129  if (ret)
130  return ret;
131 
132  nv_engine(priv)->cclass = &nv04_software_cclass;
133  nv_engine(priv)->sclass = nv04_software_sclass;
134  nv_subdev(priv)->intr = nv04_software_intr;
135  return 0;
136 }
137 
138 struct nouveau_oclass
140  .handle = NV_ENGINE(SW, 0x04),
141  .ofuncs = &(struct nouveau_ofuncs) {
142  .ctor = nv04_software_ctor,
143  .dtor = _nouveau_software_dtor,
144  .init = _nouveau_software_init,
145  .fini = _nouveau_software_fini,
146  },
147 };