drm/nouveau/sw: turn flip completion into an event
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / sw / nv10.c
CommitLineData
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 object classes
32 ******************************************************************************/
33
34static int
f84aff4e 35nv10_sw_flip(struct nvkm_object *object, u32 mthd, void *args, u32 size)
ebb945a9 36{
226dcefe 37 struct nvkm_sw_chan *chan = (void *)nv_engctx(object->parent);
898a2b32
BS
38 nvkm_event_send(&chan->event, 1, 0, NULL, 0);
39 return 0;
ebb945a9
BS
40}
41
f84aff4e 42static struct nvkm_omthds
8700287b
BS
43nv10_sw_omthds[] = {
44 { 0x0500, 0x0500, nv10_sw_flip },
ebb945a9
BS
45 {}
46};
47
f84aff4e 48static struct nvkm_oclass
8700287b 49nv10_sw_sclass[] = {
898a2b32 50 { NVIF_IOCTL_NEW_V0_SW_NV10, &nvkm_nvsw_ofuncs, nv10_sw_omthds },
ebb945a9
BS
51 {}
52};
53
54/*******************************************************************************
55 * software context
56 ******************************************************************************/
57
58static int
f84aff4e
BS
59nv10_sw_context_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
60 struct nvkm_oclass *oclass, void *data, u32 size,
61 struct nvkm_object **pobject)
ebb945a9 62{
226dcefe 63 struct nvkm_sw_chan *chan;
ebb945a9
BS
64 int ret;
65
f84aff4e 66 ret = nvkm_sw_context_create(parent, engine, oclass, &chan);
ebb945a9
BS
67 *pobject = nv_object(chan);
68 if (ret)
69 return ret;
70
71 return 0;
72}
73
f84aff4e 74static struct nvkm_oclass
8700287b 75nv10_sw_cclass = {
ebb945a9 76 .handle = NV_ENGCTX(SW, 0x04),
f84aff4e 77 .ofuncs = &(struct nvkm_ofuncs) {
8700287b 78 .ctor = nv10_sw_context_ctor,
f84aff4e
BS
79 .dtor = _nvkm_sw_context_dtor,
80 .init = _nvkm_sw_context_init,
81 .fini = _nvkm_sw_context_fini,
ebb945a9
BS
82 },
83};
84
85/*******************************************************************************
86 * software engine/subdev functions
87 ******************************************************************************/
88
89static int
f84aff4e
BS
90nv10_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
91 struct nvkm_oclass *oclass, void *data, u32 size,
92 struct nvkm_object **pobject)
ebb945a9 93{
226dcefe 94 struct nvkm_sw *sw;
ebb945a9
BS
95 int ret;
96
226dcefe
BS
97 ret = nvkm_sw_create(parent, engine, oclass, &sw);
98 *pobject = nv_object(sw);
ebb945a9
BS
99 if (ret)
100 return ret;
101
226dcefe
BS
102 nv_engine(sw)->cclass = &nv10_sw_cclass;
103 nv_engine(sw)->sclass = nv10_sw_sclass;
104 nv_subdev(sw)->intr = nv04_sw_intr;
ebb945a9
BS
105 return 0;
106}
107
f84aff4e
BS
108struct nvkm_oclass *
109nv10_sw_oclass = &(struct nvkm_oclass) {
ebb945a9 110 .handle = NV_ENGINE(SW, 0x10),
f84aff4e 111 .ofuncs = &(struct nvkm_ofuncs) {
8700287b 112 .ctor = nv10_sw_ctor,
f84aff4e
BS
113 .dtor = _nvkm_sw_dtor,
114 .init = _nvkm_sw_init,
115 .fini = _nvkm_sw_fini,
ebb945a9
BS
116 },
117};
This page took 0.207143 seconds and 5 git commands to generate.