blob: 7784911d78ef6fc54d6aeea23950f4585d3c74c4 [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
Dave Airlie10ebc0b2012-09-17 14:40:31 +100035#include <linux/pm_runtime.h>
36
Christian Koenigfb982572012-05-17 01:33:30 +020037#define RADEON_WAIT_IDLE_TIMEOUT 200
38
Alex Deucherb73ba982012-07-17 14:02:35 -040039/**
40 * radeon_driver_irq_handler_kms - irq handler for KMS
41 *
Daniel Vettere9f0d762013-12-11 11:34:42 +010042 * @int irq, void *arg: args
Alex Deucherb73ba982012-07-17 14:02:35 -040043 *
44 * This is the irq handler for the radeon KMS driver (all asics).
45 * radeon_irq_process is a macro that points to the per-asic
46 * irq handler callback.
47 */
Daniel Vettere9f0d762013-12-11 11:34:42 +010048irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg)
Jerome Glisse771fe6b2009-06-05 14:42:42 +020049{
50 struct drm_device *dev = (struct drm_device *) arg;
51 struct radeon_device *rdev = dev->dev_private;
Dave Airlie10ebc0b2012-09-17 14:40:31 +100052 irqreturn_t ret;
Jerome Glisse771fe6b2009-06-05 14:42:42 +020053
Dave Airlie10ebc0b2012-09-17 14:40:31 +100054 ret = radeon_irq_process(rdev);
55 if (ret == IRQ_HANDLED)
56 pm_runtime_mark_last_busy(dev->dev);
57 return ret;
Jerome Glisse771fe6b2009-06-05 14:42:42 +020058}
59
Alex Deucherd4877cf2009-12-04 16:56:37 -050060/*
61 * Handle hotplug events outside the interrupt handler proper.
62 */
Alex Deucherb73ba982012-07-17 14:02:35 -040063/**
64 * radeon_hotplug_work_func - display hotplug work handler
65 *
66 * @work: work struct
67 *
68 * This is the hot plug event work handler (all asics).
69 * The work gets scheduled from the irq handler if there
70 * was a hot plug interrupt. It walks the connector table
71 * and calls the hotplug handler for each one, then sends
72 * a drm hotplug event to alert userspace.
73 */
Alex Deucherd4877cf2009-12-04 16:56:37 -050074static void radeon_hotplug_work_func(struct work_struct *work)
75{
76 struct radeon_device *rdev = container_of(work, struct radeon_device,
77 hotplug_work);
78 struct drm_device *dev = rdev->ddev;
79 struct drm_mode_config *mode_config = &dev->mode_config;
80 struct drm_connector *connector;
81
82 if (mode_config->num_connector) {
83 list_for_each_entry(connector, &mode_config->connector_list, head)
84 radeon_connector_hotplug(connector);
85 }
86 /* Just fire off a uevent and let userspace tell us what to do */
Dave Airlieeb1f8e42010-05-07 06:42:51 +000087 drm_helper_hpd_irq_event(dev);
Alex Deucherd4877cf2009-12-04 16:56:37 -050088}
89
Alex Deucherb73ba982012-07-17 14:02:35 -040090/**
91 * radeon_driver_irq_preinstall_kms - drm irq preinstall callback
92 *
93 * @dev: drm dev pointer
94 *
95 * Gets the hw ready to enable irqs (all asics).
96 * This function disables all interrupt sources on the GPU.
97 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +020098void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
99{
100 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200101 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200102 unsigned i;
103
Christian Koenigfb982572012-05-17 01:33:30 +0200104 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200105 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500106 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200107 atomic_set(&rdev->irq.ring_int[i], 0);
Alex Deucher4a6369e2013-04-12 14:04:10 -0400108 rdev->irq.dpm_thermal = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400109 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Alex Deucher9e7b4142010-03-16 17:08:06 -0400110 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400111 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
112 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200113 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400114 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500115 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200116 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200117 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200118 /* Clear bits */
119 radeon_irq_process(rdev);
120}
121
Alex Deucherb73ba982012-07-17 14:02:35 -0400122/**
123 * radeon_driver_irq_postinstall_kms - drm irq preinstall callback
124 *
125 * @dev: drm dev pointer
126 *
127 * Handles stuff to be done after enabling irqs (all asics).
128 * Returns 0 on success.
129 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200130int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
131{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200132 dev->max_vblank_count = 0x001fffff;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200133 return 0;
134}
135
Alex Deucherb73ba982012-07-17 14:02:35 -0400136/**
137 * radeon_driver_irq_uninstall_kms - drm irq uninstall callback
138 *
139 * @dev: drm dev pointer
140 *
141 * This function disables all interrupt sources on the GPU (all asics).
142 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200143void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
144{
145 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200146 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200147 unsigned i;
148
149 if (rdev == NULL) {
150 return;
151 }
Christian Koenigfb982572012-05-17 01:33:30 +0200152 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200153 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500154 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200155 atomic_set(&rdev->irq.ring_int[i], 0);
Alex Deucher4a6369e2013-04-12 14:04:10 -0400156 rdev->irq.dpm_thermal = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400157 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Jerome Glisse003e69f2010-01-07 15:39:14 +0100158 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400159 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
160 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200161 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400162 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500163 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200164 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200165 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200166}
167
Alex Deucherb73ba982012-07-17 14:02:35 -0400168/**
169 * radeon_msi_ok - asic specific msi checks
170 *
171 * @rdev: radeon device pointer
172 *
173 * Handles asic specific MSI checks to determine if
174 * MSIs should be enabled on a particular chip (all asics).
175 * Returns true if MSIs should be enabled, false if MSIs
176 * should not be enabled.
177 */
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400178static bool radeon_msi_ok(struct radeon_device *rdev)
179{
180 /* RV370/RV380 was first asic with MSI support */
181 if (rdev->family < CHIP_RV380)
182 return false;
183
184 /* MSIs don't work on AGP */
185 if (rdev->flags & RADEON_IS_AGP)
186 return false;
187
Alex Deuchera18cee12011-11-01 14:20:30 -0400188 /* force MSI on */
189 if (radeon_msi == 1)
190 return true;
191 else if (radeon_msi == 0)
192 return false;
193
Alex Deucherb3621052011-10-25 15:11:08 -0400194 /* Quirks */
195 /* HP RS690 only seems to work with MSIs. */
196 if ((rdev->pdev->device == 0x791f) &&
197 (rdev->pdev->subsystem_vendor == 0x103c) &&
198 (rdev->pdev->subsystem_device == 0x30c2))
199 return true;
200
Alex Deucher01e718e2011-11-01 14:14:18 -0400201 /* Dell RS690 only seems to work with MSIs. */
202 if ((rdev->pdev->device == 0x791f) &&
203 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher44517c42012-01-15 08:51:12 -0500204 (rdev->pdev->subsystem_device == 0x01fc))
205 return true;
206
207 /* Dell RS690 only seems to work with MSIs. */
208 if ((rdev->pdev->device == 0x791f) &&
209 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher01e718e2011-11-01 14:14:18 -0400210 (rdev->pdev->subsystem_device == 0x01fd))
211 return true;
212
Alex Deucher3a6d59d2012-09-26 12:31:45 -0400213 /* Gateway RS690 only seems to work with MSIs. */
214 if ((rdev->pdev->device == 0x791f) &&
215 (rdev->pdev->subsystem_vendor == 0x107b) &&
216 (rdev->pdev->subsystem_device == 0x0185))
217 return true;
218
Alex Deucherfb6ca6d2012-09-26 12:40:45 -0400219 /* try and enable MSIs by default on all RS690s */
220 if (rdev->family == CHIP_RS690)
221 return true;
222
Dave Airlie16a5e322012-04-13 11:14:50 +0100223 /* RV515 seems to have MSI issues where it loses
224 * MSI rearms occasionally. This leads to lockups and freezes.
225 * disable it by default.
226 */
227 if (rdev->family == CHIP_RV515)
228 return false;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400229 if (rdev->flags & RADEON_IS_IGP) {
230 /* APUs work fine with MSIs */
231 if (rdev->family >= CHIP_PALM)
232 return true;
233 /* lots of IGPs have problems with MSIs */
234 return false;
235 }
236
237 return true;
238}
239
Alex Deucherb73ba982012-07-17 14:02:35 -0400240/**
241 * radeon_irq_kms_init - init driver interrupt info
242 *
243 * @rdev: radeon device pointer
244 *
245 * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics).
246 * Returns 0 for success, error for failure.
247 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200248int radeon_irq_kms_init(struct radeon_device *rdev)
249{
250 int r = 0;
251
Christian Koenigfb982572012-05-17 01:33:30 +0200252 spin_lock_init(&rdev->irq.lock);
Alex Deucher9e7b4142010-03-16 17:08:06 -0400253 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200254 if (r) {
255 return r;
256 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400257 /* enable msi */
258 rdev->msi_enabled = 0;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400259
260 if (radeon_msi_ok(rdev)) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400261 int ret = pci_enable_msi(rdev->pdev);
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500262 if (!ret) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400263 rdev->msi_enabled = 1;
Alex Deucherda7be682010-08-12 18:05:34 -0400264 dev_info(rdev->dev, "radeon: using MSI.\n");
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500265 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400266 }
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300267
268 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
269 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300270
Sergey Senozhatsky27c505c2013-08-29 12:29:35 +0300271 rdev->irq.installed = true;
Daniel Vetterbb0f1b52013-11-03 21:09:27 +0100272 r = drm_irq_install(rdev->ddev, rdev->ddev->pdev->irq);
Sergey Senozhatsky27c505c2013-08-29 12:29:35 +0300273 if (r) {
274 rdev->irq.installed = false;
275 flush_work(&rdev->hotplug_work);
276 return r;
277 }
278
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200279 DRM_INFO("radeon: irq initialized.\n");
280 return 0;
281}
282
Alex Deucherb73ba982012-07-17 14:02:35 -0400283/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900284 * radeon_irq_kms_fini - tear down driver interrupt info
Alex Deucherb73ba982012-07-17 14:02:35 -0400285 *
286 * @rdev: radeon device pointer
287 *
288 * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics).
289 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200290void radeon_irq_kms_fini(struct radeon_device *rdev)
291{
Jerome Glisse003e69f2010-01-07 15:39:14 +0100292 drm_vblank_cleanup(rdev->ddev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200293 if (rdev->irq.installed) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200294 drm_irq_uninstall(rdev->ddev);
Jerome Glisse003e69f2010-01-07 15:39:14 +0100295 rdev->irq.installed = false;
Alex Deucher3e5cb982009-10-16 12:21:24 -0400296 if (rdev->msi_enabled)
297 pci_disable_msi(rdev->pdev);
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300298 flush_work(&rdev->hotplug_work);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200299 }
300}
Dave Airlie1614f8b2009-12-01 16:04:56 +1000301
Alex Deucherb73ba982012-07-17 14:02:35 -0400302/**
303 * radeon_irq_kms_sw_irq_get - enable software interrupt
304 *
305 * @rdev: radeon device pointer
306 * @ring: ring whose interrupt you want to enable
307 *
308 * Enables the software interrupt for a specific ring (all asics).
309 * The software interrupt is generally used to signal a fence on
310 * a particular ring.
311 */
Alex Deucher1b370782011-11-17 20:13:28 -0500312void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000313{
314 unsigned long irqflags;
315
Christian Koenig736fc372012-05-17 19:52:00 +0200316 if (!rdev->ddev->irq_enabled)
317 return;
318
319 if (atomic_inc_return(&rdev->irq.ring_int[ring]) == 1) {
320 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000321 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200322 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000323 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000324}
325
Alex Deucherb73ba982012-07-17 14:02:35 -0400326/**
Maarten Lankhorst954605c2014-01-09 11:03:12 +0100327 * radeon_irq_kms_sw_irq_get_delayed - enable software interrupt
328 *
329 * @rdev: radeon device pointer
330 * @ring: ring whose interrupt you want to enable
331 *
332 * Enables the software interrupt for a specific ring (all asics).
333 * The software interrupt is generally used to signal a fence on
334 * a particular ring.
335 */
336bool radeon_irq_kms_sw_irq_get_delayed(struct radeon_device *rdev, int ring)
337{
338 return atomic_inc_return(&rdev->irq.ring_int[ring]) == 1;
339}
340
341/**
Alex Deucherb73ba982012-07-17 14:02:35 -0400342 * radeon_irq_kms_sw_irq_put - disable software interrupt
343 *
344 * @rdev: radeon device pointer
345 * @ring: ring whose interrupt you want to disable
346 *
347 * Disables the software interrupt for a specific ring (all asics).
348 * The software interrupt is generally used to signal a fence on
349 * a particular ring.
350 */
Alex Deucher1b370782011-11-17 20:13:28 -0500351void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000352{
353 unsigned long irqflags;
354
Christian Koenig736fc372012-05-17 19:52:00 +0200355 if (!rdev->ddev->irq_enabled)
356 return;
357
358 if (atomic_dec_and_test(&rdev->irq.ring_int[ring])) {
359 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000360 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200361 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000362 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000363}
364
Alex Deucherb73ba982012-07-17 14:02:35 -0400365/**
366 * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt
367 *
368 * @rdev: radeon device pointer
369 * @crtc: crtc whose interrupt you want to enable
370 *
371 * Enables the pageflip interrupt for a specific crtc (all asics).
372 * For pageflips we use the vblank interrupt source.
373 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500374void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc)
375{
376 unsigned long irqflags;
377
378 if (crtc < 0 || crtc >= rdev->num_crtc)
379 return;
380
Christian Koenig736fc372012-05-17 19:52:00 +0200381 if (!rdev->ddev->irq_enabled)
382 return;
383
384 if (atomic_inc_return(&rdev->irq.pflip[crtc]) == 1) {
385 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500386 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200387 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500388 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500389}
390
Alex Deucherb73ba982012-07-17 14:02:35 -0400391/**
392 * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt
393 *
394 * @rdev: radeon device pointer
395 * @crtc: crtc whose interrupt you want to disable
396 *
397 * Disables the pageflip interrupt for a specific crtc (all asics).
398 * For pageflips we use the vblank interrupt source.
399 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500400void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc)
401{
402 unsigned long irqflags;
403
404 if (crtc < 0 || crtc >= rdev->num_crtc)
405 return;
406
Christian Koenig736fc372012-05-17 19:52:00 +0200407 if (!rdev->ddev->irq_enabled)
408 return;
409
410 if (atomic_dec_and_test(&rdev->irq.pflip[crtc])) {
411 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500412 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200413 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500414 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500415}
416
Alex Deucherb73ba982012-07-17 14:02:35 -0400417/**
418 * radeon_irq_kms_enable_afmt - enable audio format change interrupt
419 *
420 * @rdev: radeon device pointer
421 * @block: afmt block whose interrupt you want to enable
422 *
423 * Enables the afmt change interrupt for a specific afmt block (all asics).
424 */
Christian Koenigfb982572012-05-17 01:33:30 +0200425void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block)
426{
427 unsigned long irqflags;
428
Alex Deuchercc9945b2013-02-26 16:17:33 -0500429 if (!rdev->ddev->irq_enabled)
430 return;
431
Christian Koenigfb982572012-05-17 01:33:30 +0200432 spin_lock_irqsave(&rdev->irq.lock, irqflags);
433 rdev->irq.afmt[block] = true;
434 radeon_irq_set(rdev);
435 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
436
437}
438
Alex Deucherb73ba982012-07-17 14:02:35 -0400439/**
440 * radeon_irq_kms_disable_afmt - disable audio format change interrupt
441 *
442 * @rdev: radeon device pointer
443 * @block: afmt block whose interrupt you want to disable
444 *
445 * Disables the afmt change interrupt for a specific afmt block (all asics).
446 */
Christian Koenigfb982572012-05-17 01:33:30 +0200447void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block)
448{
449 unsigned long irqflags;
450
Alex Deuchercc9945b2013-02-26 16:17:33 -0500451 if (!rdev->ddev->irq_enabled)
452 return;
453
Christian Koenigfb982572012-05-17 01:33:30 +0200454 spin_lock_irqsave(&rdev->irq.lock, irqflags);
455 rdev->irq.afmt[block] = false;
456 radeon_irq_set(rdev);
457 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
458}
459
Alex Deucherb73ba982012-07-17 14:02:35 -0400460/**
461 * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt
462 *
463 * @rdev: radeon device pointer
464 * @hpd_mask: mask of hpd pins you want to enable.
465 *
466 * Enables the hotplug detect interrupt for a specific hpd pin (all asics).
467 */
Christian Koenigfb982572012-05-17 01:33:30 +0200468void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
469{
470 unsigned long irqflags;
471 int i;
472
Alex Deuchercc9945b2013-02-26 16:17:33 -0500473 if (!rdev->ddev->irq_enabled)
474 return;
475
Christian Koenigfb982572012-05-17 01:33:30 +0200476 spin_lock_irqsave(&rdev->irq.lock, irqflags);
477 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
478 rdev->irq.hpd[i] |= !!(hpd_mask & (1 << i));
479 radeon_irq_set(rdev);
480 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
481}
482
Alex Deucherb73ba982012-07-17 14:02:35 -0400483/**
484 * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt
485 *
486 * @rdev: radeon device pointer
487 * @hpd_mask: mask of hpd pins you want to disable.
488 *
489 * Disables the hotplug detect interrupt for a specific hpd pin (all asics).
490 */
Christian Koenigfb982572012-05-17 01:33:30 +0200491void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
492{
493 unsigned long irqflags;
494 int i;
495
Alex Deuchercc9945b2013-02-26 16:17:33 -0500496 if (!rdev->ddev->irq_enabled)
497 return;
498
Christian Koenigfb982572012-05-17 01:33:30 +0200499 spin_lock_irqsave(&rdev->irq.lock, irqflags);
500 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
501 rdev->irq.hpd[i] &= !(hpd_mask & (1 << i));
502 radeon_irq_set(rdev);
503 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
504}
505