2 * Copyright 2012 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.
26 #include <core/class.h>
27 #include <core/engctx.h>
28 #include <core/namedb.h>
29 #include <core/handle.h>
30 #include <core/gpuobj.h>
32 #include <engine/software.h>
33 #include <engine/disp.h>
35 struct nv50_software_priv
{
36 struct nouveau_software base
;
39 struct nv50_software_chan
{
40 struct nouveau_software_chan base
;
43 /*******************************************************************************
44 * software object classes
45 ******************************************************************************/
48 nv50_software_mthd_dma_vblsem(struct nouveau_object
*object
, u32 mthd
,
51 struct nv50_software_chan
*chan
= (void *)nv_engctx(object
->parent
);
52 struct nouveau_fifo_chan
*fifo
= (void *)nv_object(chan
)->parent
;
53 struct nouveau_handle
*handle
;
56 handle
= nouveau_namedb_get(nv_namedb(fifo
), *(u32
*)args
);
60 if (nv_iclass(handle
->object
, NV_GPUOBJ_CLASS
)) {
61 struct nouveau_gpuobj
*gpuobj
= nv_gpuobj(handle
->object
);
62 chan
->base
.vblank
.ctxdma
= gpuobj
->node
->offset
>> 4;
65 nouveau_namedb_put(handle
);
70 nv50_software_mthd_vblsem_offset(struct nouveau_object
*object
, u32 mthd
,
73 struct nv50_software_chan
*chan
= (void *)nv_engctx(object
->parent
);
74 chan
->base
.vblank
.offset
= *(u32
*)args
;
79 nv50_software_mthd_vblsem_value(struct nouveau_object
*object
, u32 mthd
,
82 struct nv50_software_chan
*chan
= (void *)nv_engctx(object
->parent
);
83 chan
->base
.vblank
.value
= *(u32
*)args
;
88 nv50_software_mthd_vblsem_release(struct nouveau_object
*object
, u32 mthd
,
91 struct nv50_software_chan
*chan
= (void *)nv_engctx(object
->parent
);
92 struct nouveau_disp
*disp
= nouveau_disp(object
);
94 u32 crtc
= *(u32
*)args
;
99 disp
->vblank
.get(disp
->vblank
.data
, crtc
);
101 spin_lock_irqsave(&disp
->vblank
.lock
, flags
);
102 list_add(&chan
->base
.vblank
.head
, &disp
->vblank
.list
);
103 chan
->base
.vblank
.crtc
= crtc
;
104 spin_unlock_irqrestore(&disp
->vblank
.lock
, flags
);
109 nv50_software_mthd_flip(struct nouveau_object
*object
, u32 mthd
,
110 void *args
, u32 size
)
112 struct nv50_software_chan
*chan
= (void *)nv_engctx(object
->parent
);
114 return chan
->base
.flip(chan
->base
.flip_data
);
118 static struct nouveau_omthds
119 nv50_software_omthds
[] = {
120 { 0x018c, nv50_software_mthd_dma_vblsem
},
121 { 0x0400, nv50_software_mthd_vblsem_offset
},
122 { 0x0404, nv50_software_mthd_vblsem_value
},
123 { 0x0408, nv50_software_mthd_vblsem_release
},
124 { 0x0500, nv50_software_mthd_flip
},
128 static struct nouveau_oclass
129 nv50_software_sclass
[] = {
130 { 0x506e, &nouveau_object_ofuncs
, nv50_software_omthds
},
134 /*******************************************************************************
136 ******************************************************************************/
139 nv50_software_context_ctor(struct nouveau_object
*parent
,
140 struct nouveau_object
*engine
,
141 struct nouveau_oclass
*oclass
, void *data
, u32 size
,
142 struct nouveau_object
**pobject
)
144 struct nv50_software_chan
*chan
;
147 ret
= nouveau_software_context_create(parent
, engine
, oclass
, &chan
);
148 *pobject
= nv_object(chan
);
152 chan
->base
.vblank
.channel
= nv_gpuobj(parent
->parent
)->addr
>> 12;
156 static struct nouveau_oclass
157 nv50_software_cclass
= {
158 .handle
= NV_ENGCTX(SW
, 0x50),
159 .ofuncs
= &(struct nouveau_ofuncs
) {
160 .ctor
= nv50_software_context_ctor
,
161 .dtor
= _nouveau_software_context_dtor
,
162 .init
= _nouveau_software_context_init
,
163 .fini
= _nouveau_software_context_fini
,
167 /*******************************************************************************
168 * software engine/subdev functions
169 ******************************************************************************/
172 nv50_software_ctor(struct nouveau_object
*parent
, struct nouveau_object
*engine
,
173 struct nouveau_oclass
*oclass
, void *data
, u32 size
,
174 struct nouveau_object
**pobject
)
176 struct nv50_software_priv
*priv
;
179 ret
= nouveau_software_create(parent
, engine
, oclass
, &priv
);
180 *pobject
= nv_object(priv
);
184 nv_engine(priv
)->cclass
= &nv50_software_cclass
;
185 nv_engine(priv
)->sclass
= nv50_software_sclass
;
189 struct nouveau_oclass
190 nv50_software_oclass
= {
191 .handle
= NV_ENGINE(SW
, 0x50),
192 .ofuncs
= &(struct nouveau_ofuncs
) {
193 .ctor
= nv50_software_ctor
,
194 .dtor
= _nouveau_software_dtor
,
195 .init
= _nouveau_software_init
,
196 .fini
= _nouveau_software_fini
,