drm/nouveau/copy: remove nouveau_copy base class
[deliverable/linux.git] / drivers / gpu / drm / nouveau / core / engine / copy / nve0.c
CommitLineData
4f32656d
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 */
24
25#include <core/os.h>
26#include <core/enum.h>
27#include <core/class.h>
28#include <core/engctx.h>
29
30#include <engine/copy.h>
31
32struct nve0_copy_priv {
3cb0ebdd 33 struct nouveau_engine base;
4f32656d
BS
34};
35
36struct nve0_copy_chan {
3cb0ebdd 37 struct nouveau_engctx base;
4f32656d
BS
38};
39
40/*******************************************************************************
41 * Copy object classes
42 ******************************************************************************/
43
44static struct nouveau_oclass
45nve0_copy_sclass[] = {
46 { 0xa0b5, &nouveau_object_ofuncs },
47 {},
48};
49
50/*******************************************************************************
51 * PCOPY context
52 ******************************************************************************/
53
54static int
55nve0_copy_context_ctor(struct nouveau_object *parent,
56 struct nouveau_object *engine,
57 struct nouveau_oclass *oclass, void *data, u32 size,
58 struct nouveau_object **pobject)
59{
60 struct nve0_copy_chan *priv;
61 int ret;
62
3cb0ebdd
BS
63 ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256,
64 256, NVOBJ_FLAG_ZERO_ALLOC, &priv);
4f32656d
BS
65 *pobject = nv_object(priv);
66 if (ret)
67 return ret;
68
69 return 0;
70}
71
72static struct nouveau_ofuncs
73nve0_copy_context_ofuncs = {
74 .ctor = nve0_copy_context_ctor,
3cb0ebdd
BS
75 .dtor = _nouveau_engctx_dtor,
76 .init = _nouveau_engctx_init,
77 .fini = _nouveau_engctx_fini,
78 .rd32 = _nouveau_engctx_rd32,
79 .wr32 = _nouveau_engctx_wr32,
4f32656d
BS
80};
81
82static struct nouveau_oclass
83nve0_copy_cclass = {
84 .handle = NV_ENGCTX(COPY0, 0xc0),
85 .ofuncs = &nve0_copy_context_ofuncs,
86};
87
88/*******************************************************************************
89 * PCOPY engine/subdev functions
90 ******************************************************************************/
91
92static int
93nve0_copy0_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
94 struct nouveau_oclass *oclass, void *data, u32 size,
95 struct nouveau_object **pobject)
96{
97 struct nve0_copy_priv *priv;
98 int ret;
99
100 if (nv_rd32(parent, 0x022500) & 0x00000100)
101 return -ENODEV;
102
3cb0ebdd
BS
103 ret = nouveau_engine_create(parent, engine, oclass, true,
104 "PCE0", "copy0", &priv);
4f32656d
BS
105 *pobject = nv_object(priv);
106 if (ret)
107 return ret;
108
109 nv_subdev(priv)->unit = 0x00000040;
110 nv_engine(priv)->cclass = &nve0_copy_cclass;
111 nv_engine(priv)->sclass = nve0_copy_sclass;
112 return 0;
113}
114
115static int
116nve0_copy1_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
117 struct nouveau_oclass *oclass, void *data, u32 size,
118 struct nouveau_object **pobject)
119{
120 struct nve0_copy_priv *priv;
121 int ret;
122
123 if (nv_rd32(parent, 0x022500) & 0x00000200)
124 return -ENODEV;
125
3cb0ebdd
BS
126 ret = nouveau_engine_create(parent, engine, oclass, true,
127 "PCE1", "copy1", &priv);
4f32656d
BS
128 *pobject = nv_object(priv);
129 if (ret)
130 return ret;
131
132 nv_subdev(priv)->unit = 0x00000080;
133 nv_engine(priv)->cclass = &nve0_copy_cclass;
134 nv_engine(priv)->sclass = nve0_copy_sclass;
135 return 0;
136}
137
138struct nouveau_oclass
139nve0_copy0_oclass = {
140 .handle = NV_ENGINE(COPY0, 0xe0),
141 .ofuncs = &(struct nouveau_ofuncs) {
142 .ctor = nve0_copy0_ctor,
3cb0ebdd
BS
143 .dtor = _nouveau_engine_dtor,
144 .init = _nouveau_engine_init,
145 .fini = _nouveau_engine_fini,
4f32656d
BS
146 },
147};
148
149struct nouveau_oclass
150nve0_copy1_oclass = {
151 .handle = NV_ENGINE(COPY1, 0xe0),
152 .ofuncs = &(struct nouveau_ofuncs) {
153 .ctor = nve0_copy1_ctor,
3cb0ebdd
BS
154 .dtor = _nouveau_engine_dtor,
155 .init = _nouveau_engine_init,
156 .fini = _nouveau_engine_fini,
4f32656d
BS
157 },
158};
This page took 0.056795 seconds and 5 git commands to generate.