Rev 2004 | Rev 2007 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2004 | serge | 1 | /* |
2 | * Copyright 2008 Advanced Micro Devices, Inc. |
||
3 | * Copyright 2008 Red Hat Inc. |
||
4 | * Copyright 2009 Jerome Glisse. |
||
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: Dave Airlie |
||
25 | * Alex Deucher |
||
26 | * Jerome Glisse |
||
27 | */ |
||
28 | #include "drmP.h" |
||
29 | #include "drm_crtc_helper.h" |
||
30 | #include "radeon_drm.h" |
||
31 | #include "radeon_reg.h" |
||
32 | #include "radeon.h" |
||
33 | #include "atom.h" |
||
34 | |||
35 | static struct radeon_device *main_device; |
||
36 | |||
37 | #if 0 |
||
38 | |||
39 | irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS) |
||
40 | { |
||
41 | struct drm_device *dev = (struct drm_device *) arg; |
||
42 | struct radeon_device *rdev = dev->dev_private; |
||
43 | |||
44 | return radeon_irq_process(rdev); |
||
45 | } |
||
46 | |||
47 | /* |
||
48 | * Handle hotplug events outside the interrupt handler proper. |
||
49 | */ |
||
50 | static void radeon_hotplug_work_func(struct work_struct *work) |
||
51 | { |
||
52 | struct radeon_device *rdev = container_of(work, struct radeon_device, |
||
53 | hotplug_work); |
||
54 | struct drm_device *dev = rdev->ddev; |
||
55 | struct drm_mode_config *mode_config = &dev->mode_config; |
||
56 | struct drm_connector *connector; |
||
57 | |||
58 | if (mode_config->num_connector) { |
||
59 | list_for_each_entry(connector, &mode_config->connector_list, head) |
||
60 | radeon_connector_hotplug(connector); |
||
61 | } |
||
62 | /* Just fire off a uevent and let userspace tell us what to do */ |
||
63 | drm_helper_hpd_irq_event(dev); |
||
64 | } |
||
65 | |||
66 | |||
67 | void radeon_driver_irq_uninstall_kms(struct drm_device *dev) |
||
68 | { |
||
69 | struct radeon_device *rdev = dev->dev_private; |
||
70 | unsigned i; |
||
71 | |||
72 | if (rdev == NULL) { |
||
73 | return; |
||
74 | } |
||
75 | /* Disable *all* interrupts */ |
||
76 | rdev->irq.sw_int = false; |
||
77 | rdev->irq.gui_idle = false; |
||
78 | for (i = 0; i < rdev->num_crtc; i++) |
||
79 | rdev->irq.crtc_vblank_int[i] = false; |
||
80 | for (i = 0; i < 6; i++) { |
||
81 | rdev->irq.hpd[i] = false; |
||
82 | rdev->irq.pflip[i] = false; |
||
83 | } |
||
84 | radeon_irq_set(rdev); |
||
85 | } |
||
86 | |||
87 | #endif |
||
88 | |||
89 | void irq_handler_kms() |
||
90 | { |
||
2005 | serge | 91 | // dbgprintf("%s\n",__FUNCTION__); |
2004 | serge | 92 | radeon_irq_process(main_device); |
93 | } |
||
94 | |||
95 | |||
96 | static void radeon_irq_preinstall(struct radeon_device *rdev) |
||
97 | { |
||
98 | unsigned i; |
||
99 | |||
100 | /* Disable *all* interrupts */ |
||
101 | rdev->irq.sw_int = false; |
||
102 | rdev->irq.gui_idle = false; |
||
103 | for (i = 0; i < rdev->num_crtc; i++) |
||
104 | rdev->irq.crtc_vblank_int[i] = false; |
||
105 | for (i = 0; i < 6; i++) { |
||
106 | rdev->irq.hpd[i] = false; |
||
107 | rdev->irq.pflip[i] = false; |
||
108 | } |
||
109 | radeon_irq_set(rdev); |
||
110 | /* Clear bits */ |
||
111 | radeon_irq_process(rdev); |
||
112 | } |
||
113 | |||
114 | int radeon_driver_irq_postinstall(struct radeon_device *rdev) |
||
115 | { |
||
116 | // struct radeon_device *rdev = dev->dev_private; |
||
117 | |||
118 | // dev->max_vblank_count = 0x001fffff; |
||
119 | rdev->irq.sw_int = true; |
||
120 | radeon_irq_set(rdev); |
||
121 | return 0; |
||
122 | } |
||
123 | |||
124 | int radeon_irq_kms_init(struct radeon_device *rdev) |
||
125 | { |
||
126 | int i; |
||
127 | int irq_line; |
||
128 | int r = 0; |
||
129 | |||
130 | ENTER(); |
||
131 | |||
132 | // INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); |
||
133 | |||
134 | spin_lock_init(&rdev->irq.sw_lock); |
||
135 | for (i = 0; i < rdev->num_crtc; i++) |
||
136 | spin_lock_init(&rdev->irq.pflip_lock[i]); |
||
137 | // r = drm_vblank_init(rdev->ddev, rdev->num_crtc); |
||
138 | // if (r) { |
||
139 | // return r; |
||
140 | // } |
||
141 | |||
142 | rdev->msi_enabled = 0; |
||
143 | rdev->irq.installed = true; |
||
144 | main_device = rdev; |
||
145 | |||
146 | radeon_irq_preinstall(rdev); |
||
147 | |||
148 | irq_line = rdev->pdev->irq; |
||
149 | |||
150 | dbgprintf("%s install irq %d\n", __FUNCTION__, irq_line); |
||
151 | |||
152 | AttachIntHandler(irq_line, irq_handler_kms, 2); |
||
153 | |||
154 | // r = drm_irq_install(rdev->ddev); |
||
155 | |||
156 | r = radeon_driver_irq_postinstall(rdev); |
||
157 | if (r) { |
||
158 | rdev->irq.installed = false; |
||
159 | LEAVE(); |
||
160 | return r; |
||
161 | } |
||
162 | |||
163 | DRM_INFO("radeon: irq initialized.\n"); |
||
164 | return 0; |
||
165 | } |
||
166 | |||
167 | |||
168 | void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev) |
||
169 | { |
||
170 | unsigned long irqflags; |
||
171 | |||
172 | spin_lock_irqsave(&rdev->irq.sw_lock, irqflags); |
||
173 | if (rdev->ddev->irq_enabled && (++rdev->irq.sw_refcount == 1)) { |
||
174 | rdev->irq.sw_int = true; |
||
175 | radeon_irq_set(rdev); |
||
176 | } |
||
177 | spin_unlock_irqrestore(&rdev->irq.sw_lock, irqflags); |
||
178 | } |
||
179 | |||
180 | void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev) |
||
181 | { |
||
182 | unsigned long irqflags; |
||
183 | |||
184 | spin_lock_irqsave(&rdev->irq.sw_lock, irqflags); |
||
185 | BUG_ON(rdev->ddev->irq_enabled && rdev->irq.sw_refcount <= 0); |
||
186 | if (rdev->ddev->irq_enabled && (--rdev->irq.sw_refcount == 0)) { |
||
187 | rdev->irq.sw_int = false; |
||
188 | radeon_irq_set(rdev); |
||
189 | } |
||
190 | spin_unlock_irqrestore(&rdev->irq.sw_lock, irqflags); |
||
191 | } |
||
192 | |||
193 | #if 0 |
||
194 | void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc) |
||
195 | { |
||
196 | unsigned long irqflags; |
||
197 | |||
198 | if (crtc < 0 || crtc >= rdev->num_crtc) |
||
199 | return; |
||
200 | |||
201 | spin_lock_irqsave(&rdev->irq.pflip_lock[crtc], irqflags); |
||
202 | if (rdev->ddev->irq_enabled && (++rdev->irq.pflip_refcount[crtc] == 1)) { |
||
203 | rdev->irq.pflip[crtc] = true; |
||
204 | radeon_irq_set(rdev); |
||
205 | } |
||
206 | spin_unlock_irqrestore(&rdev->irq.pflip_lock[crtc], irqflags); |
||
207 | } |
||
208 | |||
209 | void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc) |
||
210 | { |
||
211 | unsigned long irqflags; |
||
212 | |||
213 | if (crtc < 0 || crtc >= rdev->num_crtc) |
||
214 | return; |
||
215 | |||
216 | spin_lock_irqsave(&rdev->irq.pflip_lock[crtc], irqflags); |
||
217 | BUG_ON(rdev->ddev->irq_enabled && rdev->irq.pflip_refcount[crtc] <= 0); |
||
218 | if (rdev->ddev->irq_enabled && (--rdev->irq.pflip_refcount[crtc] == 0)) { |
||
219 | rdev->irq.pflip[crtc] = false; |
||
220 | radeon_irq_set(rdev); |
||
221 | } |
||
222 | spin_unlock_irqrestore(&rdev->irq.pflip_lock[crtc], irqflags); |
||
223 | } |
||
224 | |||
225 | #endif=>>>=>>>>>> |