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.
25 #include <engine/disp.h>
27 #include <core/event.h>
28 #include <core/class.h>
30 struct nv04_disp_priv
{
31 struct nouveau_disp base
;
35 nv04_disp_scanoutpos(struct nouveau_object
*object
, u32 mthd
,
38 struct nv04_disp_priv
*priv
= (void *)object
->engine
;
39 struct nv04_display_scanoutpos
*args
= data
;
40 const int head
= (mthd
& NV04_DISP_MTHD_HEAD
);
43 if (size
< sizeof(*args
))
46 args
->vblanks
= nv_rd32(priv
, 0x680800 + (head
* 0x2000)) & 0xffff;
47 args
->vtotal
= nv_rd32(priv
, 0x680804 + (head
* 0x2000)) & 0xffff;
48 args
->vblanke
= args
->vtotal
- 1;
50 args
->hblanks
= nv_rd32(priv
, 0x680820 + (head
* 0x2000)) & 0xffff;
51 args
->htotal
= nv_rd32(priv
, 0x680824 + (head
* 0x2000)) & 0xffff;
52 args
->hblanke
= args
->htotal
- 1;
54 args
->time
[0] = ktime_to_ns(ktime_get());
55 line
= nv_rd32(priv
, 0x600868 + (head
* 0x2000));
56 args
->time
[1] = ktime_to_ns(ktime_get());
57 args
->hline
= (line
& 0xffff0000) >> 16;
58 args
->vline
= (line
& 0x0000ffff);
62 #define HEAD_MTHD(n) (n), (n) + 0x01
64 static struct nouveau_omthds
65 nv04_disp_omthds
[] = {
66 { HEAD_MTHD(NV04_DISP_SCANOUTPOS
), nv04_disp_scanoutpos
},
70 static struct nouveau_oclass
71 nv04_disp_sclass
[] = {
72 { NV04_DISP_CLASS
, &nouveau_object_ofuncs
, nv04_disp_omthds
},
76 /*******************************************************************************
77 * Display engine implementation
78 ******************************************************************************/
81 nv04_disp_vblank_enable(struct nouveau_event
*event
, int head
)
83 nv_wr32(event
->priv
, 0x600140 + (head
* 0x2000) , 0x00000001);
87 nv04_disp_vblank_disable(struct nouveau_event
*event
, int head
)
89 nv_wr32(event
->priv
, 0x600140 + (head
* 0x2000) , 0x00000000);
93 nv04_disp_intr(struct nouveau_subdev
*subdev
)
95 struct nv04_disp_priv
*priv
= (void *)subdev
;
96 u32 crtc0
= nv_rd32(priv
, 0x600100);
97 u32 crtc1
= nv_rd32(priv
, 0x602100);
100 if (crtc0
& 0x00000001) {
101 nouveau_event_trigger(priv
->base
.vblank
, 0);
102 nv_wr32(priv
, 0x600100, 0x00000001);
105 if (crtc1
& 0x00000001) {
106 nouveau_event_trigger(priv
->base
.vblank
, 1);
107 nv_wr32(priv
, 0x602100, 0x00000001);
110 if (nv_device(priv
)->chipset
>= 0x10 &&
111 nv_device(priv
)->chipset
<= 0x40) {
112 pvideo
= nv_rd32(priv
, 0x8100);
114 nv_info(priv
, "PVIDEO intr: %08x\n", pvideo
);
115 nv_wr32(priv
, 0x8100, pvideo
);
120 nv04_disp_ctor(struct nouveau_object
*parent
, struct nouveau_object
*engine
,
121 struct nouveau_oclass
*oclass
, void *data
, u32 size
,
122 struct nouveau_object
**pobject
)
124 struct nv04_disp_priv
*priv
;
127 ret
= nouveau_disp_create(parent
, engine
, oclass
, 2, "DISPLAY",
129 *pobject
= nv_object(priv
);
133 nv_engine(priv
)->sclass
= nv04_disp_sclass
;
134 nv_subdev(priv
)->intr
= nv04_disp_intr
;
135 priv
->base
.vblank
->priv
= priv
;
136 priv
->base
.vblank
->enable
= nv04_disp_vblank_enable
;
137 priv
->base
.vblank
->disable
= nv04_disp_vblank_disable
;
141 struct nouveau_oclass
143 .handle
= NV_ENGINE(DISP
, 0x04),
144 .ofuncs
= &(struct nouveau_ofuncs
) {
145 .ctor
= nv04_disp_ctor
,
146 .dtor
= _nouveau_disp_dtor
,
147 .init
= _nouveau_disp_init
,
148 .fini
= _nouveau_disp_fini
,
This page took 0.2002 seconds and 5 git commands to generate.