blob: dbffecad5a4c50ebf167ae292a6aba2fc4f8def8 [file] [log] [blame]
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001/*
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 */
David Howells760285e2012-10-02 18:01:07 +010028#include <drm/drmP.h>
29#include <drm/drm_crtc_helper.h>
30#include <drm/radeon_drm.h>
Jerome Glisse771fe6b2009-06-05 14:42:42 +020031#include "radeon_reg.h"
Jerome Glisse771fe6b2009-06-05 14:42:42 +020032#include "radeon.h"
33#include "atom.h"
34
Christian Koenigfb982572012-05-17 01:33:30 +020035#define RADEON_WAIT_IDLE_TIMEOUT 200
36
Alex Deucherb73ba982012-07-17 14:02:35 -040037/**
38 * radeon_driver_irq_handler_kms - irq handler for KMS
39 *
40 * @DRM_IRQ_ARGS: args
41 *
42 * This is the irq handler for the radeon KMS driver (all asics).
43 * radeon_irq_process is a macro that points to the per-asic
44 * irq handler callback.
45 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +020046irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
47{
48 struct drm_device *dev = (struct drm_device *) arg;
49 struct radeon_device *rdev = dev->dev_private;
50
51 return radeon_irq_process(rdev);
52}
53
Alex Deucherd4877cf2009-12-04 16:56:37 -050054/*
55 * Handle hotplug events outside the interrupt handler proper.
56 */
Alex Deucherb73ba982012-07-17 14:02:35 -040057/**
58 * radeon_hotplug_work_func - display hotplug work handler
59 *
60 * @work: work struct
61 *
62 * This is the hot plug event work handler (all asics).
63 * The work gets scheduled from the irq handler if there
64 * was a hot plug interrupt. It walks the connector table
65 * and calls the hotplug handler for each one, then sends
66 * a drm hotplug event to alert userspace.
67 */
Alex Deucherd4877cf2009-12-04 16:56:37 -050068static void radeon_hotplug_work_func(struct work_struct *work)
69{
70 struct radeon_device *rdev = container_of(work, struct radeon_device,
71 hotplug_work);
72 struct drm_device *dev = rdev->ddev;
73 struct drm_mode_config *mode_config = &dev->mode_config;
74 struct drm_connector *connector;
75
76 if (mode_config->num_connector) {
77 list_for_each_entry(connector, &mode_config->connector_list, head)
78 radeon_connector_hotplug(connector);
79 }
80 /* Just fire off a uevent and let userspace tell us what to do */
Dave Airlieeb1f8e42010-05-07 06:42:51 +000081 drm_helper_hpd_irq_event(dev);
Alex Deucherd4877cf2009-12-04 16:56:37 -050082}
83
Alex Deucherb73ba982012-07-17 14:02:35 -040084/**
Alex Deucher8f61b342013-06-14 09:13:52 -040085 * radeon_irq_reset_work_func - execute gpu reset
86 *
87 * @work: work struct
88 *
89 * Execute scheduled gpu reset (cayman+).
90 * This function is called when the irq handler
91 * thinks we need a gpu reset.
92 */
93static void radeon_irq_reset_work_func(struct work_struct *work)
94{
95 struct radeon_device *rdev = container_of(work, struct radeon_device,
96 reset_work);
97
98 radeon_gpu_reset(rdev);
99}
100
101/**
Alex Deucherb73ba982012-07-17 14:02:35 -0400102 * radeon_driver_irq_preinstall_kms - drm irq preinstall callback
103 *
104 * @dev: drm dev pointer
105 *
106 * Gets the hw ready to enable irqs (all asics).
107 * This function disables all interrupt sources on the GPU.
108 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200109void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
110{
111 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200112 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200113 unsigned i;
114
Christian Koenigfb982572012-05-17 01:33:30 +0200115 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200116 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500117 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200118 atomic_set(&rdev->irq.ring_int[i], 0);
Ilija Hadzic54bd52062011-10-26 15:43:58 -0400119 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Alex Deucher9e7b4142010-03-16 17:08:06 -0400120 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd52062011-10-26 15:43:58 -0400121 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
122 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200123 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400124 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500125 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200126 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200127 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200128 /* Clear bits */
129 radeon_irq_process(rdev);
130}
131
Alex Deucherb73ba982012-07-17 14:02:35 -0400132/**
133 * radeon_driver_irq_postinstall_kms - drm irq preinstall callback
134 *
135 * @dev: drm dev pointer
136 *
137 * Handles stuff to be done after enabling irqs (all asics).
138 * Returns 0 on success.
139 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200140int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
141{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200142 dev->max_vblank_count = 0x001fffff;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200143 return 0;
144}
145
Alex Deucherb73ba982012-07-17 14:02:35 -0400146/**
147 * radeon_driver_irq_uninstall_kms - drm irq uninstall callback
148 *
149 * @dev: drm dev pointer
150 *
151 * This function disables all interrupt sources on the GPU (all asics).
152 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200153void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
154{
155 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200156 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200157 unsigned i;
158
159 if (rdev == NULL) {
160 return;
161 }
Christian Koenigfb982572012-05-17 01:33:30 +0200162 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200163 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500164 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200165 atomic_set(&rdev->irq.ring_int[i], 0);
Ilija Hadzic54bd52062011-10-26 15:43:58 -0400166 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Jerome Glisse003e69f2010-01-07 15:39:14 +0100167 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd52062011-10-26 15:43:58 -0400168 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
169 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200170 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400171 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500172 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200173 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200174 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200175}
176
Alex Deucherb73ba982012-07-17 14:02:35 -0400177/**
178 * radeon_msi_ok - asic specific msi checks
179 *
180 * @rdev: radeon device pointer
181 *
182 * Handles asic specific MSI checks to determine if
183 * MSIs should be enabled on a particular chip (all asics).
184 * Returns true if MSIs should be enabled, false if MSIs
185 * should not be enabled.
186 */
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400187static bool radeon_msi_ok(struct radeon_device *rdev)
188{
189 /* RV370/RV380 was first asic with MSI support */
190 if (rdev->family < CHIP_RV380)
191 return false;
192
193 /* MSIs don't work on AGP */
194 if (rdev->flags & RADEON_IS_AGP)
195 return false;
196
Alex Deuchera18cee12011-11-01 14:20:30 -0400197 /* force MSI on */
198 if (radeon_msi == 1)
199 return true;
200 else if (radeon_msi == 0)
201 return false;
202
Alex Deucherb3621052011-10-25 15:11:08 -0400203 /* Quirks */
204 /* HP RS690 only seems to work with MSIs. */
205 if ((rdev->pdev->device == 0x791f) &&
206 (rdev->pdev->subsystem_vendor == 0x103c) &&
207 (rdev->pdev->subsystem_device == 0x30c2))
208 return true;
209
Alex Deucher01e718e2011-11-01 14:14:18 -0400210 /* Dell RS690 only seems to work with MSIs. */
211 if ((rdev->pdev->device == 0x791f) &&
212 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher44517c42012-01-15 08:51:12 -0500213 (rdev->pdev->subsystem_device == 0x01fc))
214 return true;
215
216 /* Dell RS690 only seems to work with MSIs. */
217 if ((rdev->pdev->device == 0x791f) &&
218 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher01e718e2011-11-01 14:14:18 -0400219 (rdev->pdev->subsystem_device == 0x01fd))
220 return true;
221
Alex Deucher3a6d59d2012-09-26 12:31:45 -0400222 /* Gateway RS690 only seems to work with MSIs. */
223 if ((rdev->pdev->device == 0x791f) &&
224 (rdev->pdev->subsystem_vendor == 0x107b) &&
225 (rdev->pdev->subsystem_device == 0x0185))
226 return true;
227
Alex Deucherfb6ca6d2012-09-26 12:40:45 -0400228 /* try and enable MSIs by default on all RS690s */
229 if (rdev->family == CHIP_RS690)
230 return true;
231
Dave Airlie16a5e322012-04-13 11:14:50 +0100232 /* RV515 seems to have MSI issues where it loses
233 * MSI rearms occasionally. This leads to lockups and freezes.
234 * disable it by default.
235 */
236 if (rdev->family == CHIP_RV515)
237 return false;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400238 if (rdev->flags & RADEON_IS_IGP) {
239 /* APUs work fine with MSIs */
240 if (rdev->family >= CHIP_PALM)
241 return true;
242 /* lots of IGPs have problems with MSIs */
243 return false;
244 }
245
246 return true;
247}
248
Alex Deucherb73ba982012-07-17 14:02:35 -0400249/**
250 * radeon_irq_kms_init - init driver interrupt info
251 *
252 * @rdev: radeon device pointer
253 *
254 * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics).
255 * Returns 0 for success, error for failure.
256 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200257int radeon_irq_kms_init(struct radeon_device *rdev)
258{
259 int r = 0;
260
Tejun Heo32c87fc2011-01-03 14:49:32 +0100261 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
Alex Deucherf122c612012-03-30 08:59:57 -0400262 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
Alex Deucher8f61b342013-06-14 09:13:52 -0400263 INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
Tejun Heo32c87fc2011-01-03 14:49:32 +0100264
Christian Koenigfb982572012-05-17 01:33:30 +0200265 spin_lock_init(&rdev->irq.lock);
Alex Deucher9e7b4142010-03-16 17:08:06 -0400266 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200267 if (r) {
268 return r;
269 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400270 /* enable msi */
271 rdev->msi_enabled = 0;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400272
273 if (radeon_msi_ok(rdev)) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400274 int ret = pci_enable_msi(rdev->pdev);
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500275 if (!ret) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400276 rdev->msi_enabled = 1;
Alex Deucherda7be682010-08-12 18:05:34 -0400277 dev_info(rdev->dev, "radeon: using MSI.\n");
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500278 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400279 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200280 rdev->irq.installed = true;
Jerome Glisse003e69f2010-01-07 15:39:14 +0100281 r = drm_irq_install(rdev->ddev);
282 if (r) {
283 rdev->irq.installed = false;
284 return r;
285 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200286 DRM_INFO("radeon: irq initialized.\n");
287 return 0;
288}
289
Alex Deucherb73ba982012-07-17 14:02:35 -0400290/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900291 * radeon_irq_kms_fini - tear down driver interrupt info
Alex Deucherb73ba982012-07-17 14:02:35 -0400292 *
293 * @rdev: radeon device pointer
294 *
295 * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics).
296 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200297void radeon_irq_kms_fini(struct radeon_device *rdev)
298{
Jerome Glisse003e69f2010-01-07 15:39:14 +0100299 drm_vblank_cleanup(rdev->ddev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200300 if (rdev->irq.installed) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200301 drm_irq_uninstall(rdev->ddev);
Jerome Glisse003e69f2010-01-07 15:39:14 +0100302 rdev->irq.installed = false;
Alex Deucher3e5cb982009-10-16 12:21:24 -0400303 if (rdev->msi_enabled)
304 pci_disable_msi(rdev->pdev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200305 }
Tejun Heo43829732012-08-20 14:51:24 -0700306 flush_work(&rdev->hotplug_work);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200307}
Dave Airlie1614f8b2009-12-01 16:04:56 +1000308
Alex Deucherb73ba982012-07-17 14:02:35 -0400309/**
310 * radeon_irq_kms_sw_irq_get - enable software interrupt
311 *
312 * @rdev: radeon device pointer
313 * @ring: ring whose interrupt you want to enable
314 *
315 * Enables the software interrupt for a specific ring (all asics).
316 * The software interrupt is generally used to signal a fence on
317 * a particular ring.
318 */
Alex Deucher1b370782011-11-17 20:13:28 -0500319void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000320{
321 unsigned long irqflags;
322
Christian Koenig736fc372012-05-17 19:52:00 +0200323 if (!rdev->ddev->irq_enabled)
324 return;
325
326 if (atomic_inc_return(&rdev->irq.ring_int[ring]) == 1) {
327 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000328 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200329 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000330 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000331}
332
Alex Deucherb73ba982012-07-17 14:02:35 -0400333/**
334 * radeon_irq_kms_sw_irq_put - disable software interrupt
335 *
336 * @rdev: radeon device pointer
337 * @ring: ring whose interrupt you want to disable
338 *
339 * Disables the software interrupt for a specific ring (all asics).
340 * The software interrupt is generally used to signal a fence on
341 * a particular ring.
342 */
Alex Deucher1b370782011-11-17 20:13:28 -0500343void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000344{
345 unsigned long irqflags;
346
Christian Koenig736fc372012-05-17 19:52:00 +0200347 if (!rdev->ddev->irq_enabled)
348 return;
349
350 if (atomic_dec_and_test(&rdev->irq.ring_int[ring])) {
351 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000352 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200353 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000354 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000355}
356
Alex Deucherb73ba982012-07-17 14:02:35 -0400357/**
358 * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt
359 *
360 * @rdev: radeon device pointer
361 * @crtc: crtc whose interrupt you want to enable
362 *
363 * Enables the pageflip interrupt for a specific crtc (all asics).
364 * For pageflips we use the vblank interrupt source.
365 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500366void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc)
367{
368 unsigned long irqflags;
369
370 if (crtc < 0 || crtc >= rdev->num_crtc)
371 return;
372
Christian Koenig736fc372012-05-17 19:52:00 +0200373 if (!rdev->ddev->irq_enabled)
374 return;
375
376 if (atomic_inc_return(&rdev->irq.pflip[crtc]) == 1) {
377 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500378 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200379 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500380 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500381}
382
Alex Deucherb73ba982012-07-17 14:02:35 -0400383/**
384 * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt
385 *
386 * @rdev: radeon device pointer
387 * @crtc: crtc whose interrupt you want to disable
388 *
389 * Disables the pageflip interrupt for a specific crtc (all asics).
390 * For pageflips we use the vblank interrupt source.
391 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500392void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc)
393{
394 unsigned long irqflags;
395
396 if (crtc < 0 || crtc >= rdev->num_crtc)
397 return;
398
Christian Koenig736fc372012-05-17 19:52:00 +0200399 if (!rdev->ddev->irq_enabled)
400 return;
401
402 if (atomic_dec_and_test(&rdev->irq.pflip[crtc])) {
403 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500404 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200405 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500406 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500407}
408
Alex Deucherb73ba982012-07-17 14:02:35 -0400409/**
410 * radeon_irq_kms_enable_afmt - enable audio format change interrupt
411 *
412 * @rdev: radeon device pointer
413 * @block: afmt block whose interrupt you want to enable
414 *
415 * Enables the afmt change interrupt for a specific afmt block (all asics).
416 */
Christian Koenigfb982572012-05-17 01:33:30 +0200417void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block)
418{
419 unsigned long irqflags;
420
Alex Deuchercc9945b2013-02-26 16:17:33 -0500421 if (!rdev->ddev->irq_enabled)
422 return;
423
Christian Koenigfb982572012-05-17 01:33:30 +0200424 spin_lock_irqsave(&rdev->irq.lock, irqflags);
425 rdev->irq.afmt[block] = true;
426 radeon_irq_set(rdev);
427 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
428
429}
430
Alex Deucherb73ba982012-07-17 14:02:35 -0400431/**
432 * radeon_irq_kms_disable_afmt - disable audio format change interrupt
433 *
434 * @rdev: radeon device pointer
435 * @block: afmt block whose interrupt you want to disable
436 *
437 * Disables the afmt change interrupt for a specific afmt block (all asics).
438 */
Christian Koenigfb982572012-05-17 01:33:30 +0200439void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block)
440{
441 unsigned long irqflags;
442
Alex Deuchercc9945b2013-02-26 16:17:33 -0500443 if (!rdev->ddev->irq_enabled)
444 return;
445
Christian Koenigfb982572012-05-17 01:33:30 +0200446 spin_lock_irqsave(&rdev->irq.lock, irqflags);
447 rdev->irq.afmt[block] = false;
448 radeon_irq_set(rdev);
449 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
450}
451
Alex Deucherb73ba982012-07-17 14:02:35 -0400452/**
453 * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt
454 *
455 * @rdev: radeon device pointer
456 * @hpd_mask: mask of hpd pins you want to enable.
457 *
458 * Enables the hotplug detect interrupt for a specific hpd pin (all asics).
459 */
Christian Koenigfb982572012-05-17 01:33:30 +0200460void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
461{
462 unsigned long irqflags;
463 int i;
464
Alex Deuchercc9945b2013-02-26 16:17:33 -0500465 if (!rdev->ddev->irq_enabled)
466 return;
467
Christian Koenigfb982572012-05-17 01:33:30 +0200468 spin_lock_irqsave(&rdev->irq.lock, irqflags);
469 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
470 rdev->irq.hpd[i] |= !!(hpd_mask & (1 << i));
471 radeon_irq_set(rdev);
472 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
473}
474
Alex Deucherb73ba982012-07-17 14:02:35 -0400475/**
476 * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt
477 *
478 * @rdev: radeon device pointer
479 * @hpd_mask: mask of hpd pins you want to disable.
480 *
481 * Disables the hotplug detect interrupt for a specific hpd pin (all asics).
482 */
Christian Koenigfb982572012-05-17 01:33:30 +0200483void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
484{
485 unsigned long irqflags;
486 int i;
487
Alex Deuchercc9945b2013-02-26 16:17:33 -0500488 if (!rdev->ddev->irq_enabled)
489 return;
490
Christian Koenigfb982572012-05-17 01:33:30 +0200491 spin_lock_irqsave(&rdev->irq.lock, irqflags);
492 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
493 rdev->irq.hpd[i] &= !(hpd_mask & (1 << i));
494 radeon_irq_set(rdev);
495 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
496}
497