1 | /* $NetBSD: nouveau_subdev_fb_nv04.c,v 1.1.1.1 2014/08/06 12:36:30 riastradh Exp $ */ |
2 | |
3 | /* |
4 | * Copyright 2012 Red Hat Inc. |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the "Software"), |
8 | * to deal in the Software without restriction, including without limitation |
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 | * and/or sell copies of the Software, and to permit persons to whom the |
11 | * Software is furnished to do so, subject to the following conditions: |
12 | * |
13 | * The above copyright notice and this permission notice shall be included in |
14 | * all copies or substantial portions of the Software. |
15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * |
24 | * Authors: Ben Skeggs |
25 | */ |
26 | |
27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_fb_nv04.c,v 1.1.1.1 2014/08/06 12:36:30 riastradh Exp $" ); |
29 | |
30 | #include "nv04.h" |
31 | |
32 | #define NV04_PFB_CFG0 0x00100200 |
33 | |
34 | bool |
35 | nv04_fb_memtype_valid(struct nouveau_fb *pfb, u32 tile_flags) |
36 | { |
37 | if (!(tile_flags & 0xff00)) |
38 | return true; |
39 | |
40 | return false; |
41 | } |
42 | |
43 | static int |
44 | nv04_fb_init(struct nouveau_object *object) |
45 | { |
46 | struct nv04_fb_priv *priv = (void *)object; |
47 | int ret; |
48 | |
49 | ret = nouveau_fb_init(&priv->base); |
50 | if (ret) |
51 | return ret; |
52 | |
53 | /* This is what the DDX did for NV_ARCH_04, but a mmio-trace shows |
54 | * nvidia reading PFB_CFG_0, then writing back its original value. |
55 | * (which was 0x701114 in this case) |
56 | */ |
57 | nv_wr32(priv, NV04_PFB_CFG0, 0x1114); |
58 | return 0; |
59 | } |
60 | |
61 | int |
62 | nv04_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
63 | struct nouveau_oclass *oclass, void *data, u32 size, |
64 | struct nouveau_object **pobject) |
65 | { |
66 | struct nv04_fb_impl *impl = (void *)oclass; |
67 | struct nv04_fb_priv *priv; |
68 | int ret; |
69 | |
70 | ret = nouveau_fb_create(parent, engine, oclass, &priv); |
71 | *pobject = nv_object(priv); |
72 | if (ret) |
73 | return ret; |
74 | |
75 | priv->base.tile.regions = impl->tile.regions; |
76 | priv->base.tile.init = impl->tile.init; |
77 | priv->base.tile.comp = impl->tile.comp; |
78 | priv->base.tile.fini = impl->tile.fini; |
79 | priv->base.tile.prog = impl->tile.prog; |
80 | return 0; |
81 | } |
82 | |
83 | struct nouveau_oclass * |
84 | nv04_fb_oclass = &(struct nv04_fb_impl) { |
85 | .base.base.handle = NV_SUBDEV(FB, 0x04), |
86 | .base.base.ofuncs = &(struct nouveau_ofuncs) { |
87 | .ctor = nv04_fb_ctor, |
88 | .dtor = _nouveau_fb_dtor, |
89 | .init = nv04_fb_init, |
90 | .fini = _nouveau_fb_fini, |
91 | }, |
92 | .base.memtype = nv04_fb_memtype_valid, |
93 | .base.ram = &nv04_ram_oclass, |
94 | }.base.base; |
95 | |