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 <engine/disp.h>
26 
29 };
30 
31 static struct nouveau_oclass
32 nv04_disp_sclass[] = {
33  {},
34 };
35 
36 static void
37 nv04_disp_intr_vblank(struct nv04_disp_priv *priv, int crtc)
38 {
39  struct nouveau_disp *disp = &priv->base;
40  if (disp->vblank.notify)
41  disp->vblank.notify(disp->vblank.data, crtc);
42 }
43 
44 static void
45 nv04_disp_intr(struct nouveau_subdev *subdev)
46 {
47  struct nv04_disp_priv *priv = (void *)subdev;
48  u32 crtc0 = nv_rd32(priv, 0x600100);
49  u32 crtc1 = nv_rd32(priv, 0x602100);
50 
51  if (crtc0 & 0x00000001) {
52  nv04_disp_intr_vblank(priv, 0);
53  nv_wr32(priv, 0x600100, 0x00000001);
54  }
55 
56  if (crtc1 & 0x00000001) {
57  nv04_disp_intr_vblank(priv, 1);
58  nv_wr32(priv, 0x602100, 0x00000001);
59  }
60 }
61 
62 static int
63 nv04_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
64  struct nouveau_oclass *oclass, void *data, u32 size,
65  struct nouveau_object **pobject)
66 {
67  struct nv04_disp_priv *priv;
68  int ret;
69 
70  ret = nouveau_disp_create(parent, engine, oclass, "DISPLAY",
71  "display", &priv);
72  *pobject = nv_object(priv);
73  if (ret)
74  return ret;
75 
76  nv_engine(priv)->sclass = nv04_disp_sclass;
77  nv_subdev(priv)->intr = nv04_disp_intr;
78  return 0;
79 }
80 
81 struct nouveau_oclass
83  .handle = NV_ENGINE(DISP, 0x04),
84  .ofuncs = &(struct nouveau_ofuncs) {
85  .ctor = nv04_disp_ctor,
86  .dtor = _nouveau_disp_dtor,
87  .init = _nouveau_disp_init,
88  .fini = _nouveau_disp_fini,
89  },
90 };