blob: e82ae819fc102c6afdb3ab7f9e0196cb093e732c [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
Dave Airliede6284a2015-02-24 09:23:56 +100090static void radeon_dp_work_func(struct work_struct *work)
91{
92}
Alex Deucherb73ba982012-07-17 14:02:35 -040093/**
94 * radeon_driver_irq_preinstall_kms - drm irq preinstall callback
95 *
96 * @dev: drm dev pointer
97 *
98 * Gets the hw ready to enable irqs (all asics).
99 * This function disables all interrupt sources on the GPU.
100 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200101void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
102{
103 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200104 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200105 unsigned i;
106
Christian Koenigfb982572012-05-17 01:33:30 +0200107 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200108 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500109 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200110 atomic_set(&rdev->irq.ring_int[i], 0);
Alex Deucher4a6369e2013-04-12 14:04:10 -0400111 rdev->irq.dpm_thermal = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400112 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Alex Deucher9e7b4142010-03-16 17:08:06 -0400113 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400114 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
115 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200116 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400117 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500118 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200119 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200120 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200121 /* Clear bits */
122 radeon_irq_process(rdev);
123}
124
Alex Deucherb73ba982012-07-17 14:02:35 -0400125/**
126 * radeon_driver_irq_postinstall_kms - drm irq preinstall callback
127 *
128 * @dev: drm dev pointer
129 *
130 * Handles stuff to be done after enabling irqs (all asics).
131 * Returns 0 on success.
132 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200133int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
134{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200135 dev->max_vblank_count = 0x001fffff;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200136 return 0;
137}
138
Alex Deucherb73ba982012-07-17 14:02:35 -0400139/**
140 * radeon_driver_irq_uninstall_kms - drm irq uninstall callback
141 *
142 * @dev: drm dev pointer
143 *
144 * This function disables all interrupt sources on the GPU (all asics).
145 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200146void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
147{
148 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200149 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200150 unsigned i;
151
152 if (rdev == NULL) {
153 return;
154 }
Christian Koenigfb982572012-05-17 01:33:30 +0200155 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200156 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500157 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200158 atomic_set(&rdev->irq.ring_int[i], 0);
Alex Deucher4a6369e2013-04-12 14:04:10 -0400159 rdev->irq.dpm_thermal = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400160 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Jerome Glisse003e69f2010-01-07 15:39:14 +0100161 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400162 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
163 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200164 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400165 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500166 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200167 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200168 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200169}
170
Alex Deucherb73ba982012-07-17 14:02:35 -0400171/**
172 * radeon_msi_ok - asic specific msi checks
173 *
174 * @rdev: radeon device pointer
175 *
176 * Handles asic specific MSI checks to determine if
177 * MSIs should be enabled on a particular chip (all asics).
178 * Returns true if MSIs should be enabled, false if MSIs
179 * should not be enabled.
180 */
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400181static bool radeon_msi_ok(struct radeon_device *rdev)
182{
183 /* RV370/RV380 was first asic with MSI support */
184 if (rdev->family < CHIP_RV380)
185 return false;
186
187 /* MSIs don't work on AGP */
188 if (rdev->flags & RADEON_IS_AGP)
189 return false;
190
Benjamin Herrenschmidt91ed6fd2014-10-03 15:18:59 +1000191 /*
192 * Older chips have a HW limitation, they can only generate 40 bits
193 * of address for "64-bit" MSIs which breaks on some platforms, notably
194 * IBM POWER servers, so we limit them
195 */
196 if (rdev->family < CHIP_BONAIRE) {
197 dev_info(rdev->dev, "radeon: MSI limited to 32-bit\n");
198 rdev->pdev->no_64bit_msi = 1;
199 }
200
Alex Deuchera18cee12011-11-01 14:20:30 -0400201 /* force MSI on */
202 if (radeon_msi == 1)
203 return true;
204 else if (radeon_msi == 0)
205 return false;
206
Alex Deucherb3621052011-10-25 15:11:08 -0400207 /* Quirks */
208 /* HP RS690 only seems to work with MSIs. */
209 if ((rdev->pdev->device == 0x791f) &&
210 (rdev->pdev->subsystem_vendor == 0x103c) &&
211 (rdev->pdev->subsystem_device == 0x30c2))
212 return true;
213
Alex Deucher01e718e2011-11-01 14:14:18 -0400214 /* Dell RS690 only seems to work with MSIs. */
215 if ((rdev->pdev->device == 0x791f) &&
216 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher44517c42012-01-15 08:51:12 -0500217 (rdev->pdev->subsystem_device == 0x01fc))
218 return true;
219
220 /* Dell RS690 only seems to work with MSIs. */
221 if ((rdev->pdev->device == 0x791f) &&
222 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher01e718e2011-11-01 14:14:18 -0400223 (rdev->pdev->subsystem_device == 0x01fd))
224 return true;
225
Alex Deucher3a6d59d2012-09-26 12:31:45 -0400226 /* Gateway RS690 only seems to work with MSIs. */
227 if ((rdev->pdev->device == 0x791f) &&
228 (rdev->pdev->subsystem_vendor == 0x107b) &&
229 (rdev->pdev->subsystem_device == 0x0185))
230 return true;
231
Alex Deucherfb6ca6d2012-09-26 12:40:45 -0400232 /* try and enable MSIs by default on all RS690s */
233 if (rdev->family == CHIP_RS690)
234 return true;
235
Dave Airlie16a5e322012-04-13 11:14:50 +0100236 /* RV515 seems to have MSI issues where it loses
237 * MSI rearms occasionally. This leads to lockups and freezes.
238 * disable it by default.
239 */
240 if (rdev->family == CHIP_RV515)
241 return false;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400242 if (rdev->flags & RADEON_IS_IGP) {
243 /* APUs work fine with MSIs */
244 if (rdev->family >= CHIP_PALM)
245 return true;
246 /* lots of IGPs have problems with MSIs */
247 return false;
248 }
249
250 return true;
251}
252
Alex Deucherb73ba982012-07-17 14:02:35 -0400253/**
254 * radeon_irq_kms_init - init driver interrupt info
255 *
256 * @rdev: radeon device pointer
257 *
258 * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics).
259 * Returns 0 for success, error for failure.
260 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200261int radeon_irq_kms_init(struct radeon_device *rdev)
262{
263 int r = 0;
264
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 }
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300280
281 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
Dave Airliede6284a2015-02-24 09:23:56 +1000282 INIT_WORK(&rdev->dp_work, radeon_dp_work_func);
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300283 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300284
Sergey Senozhatsky27c505c2013-08-29 12:29:35 +0300285 rdev->irq.installed = true;
Daniel Vetterbb0f1b52013-11-03 21:09:27 +0100286 r = drm_irq_install(rdev->ddev, rdev->ddev->pdev->irq);
Sergey Senozhatsky27c505c2013-08-29 12:29:35 +0300287 if (r) {
288 rdev->irq.installed = false;
289 flush_work(&rdev->hotplug_work);
290 return r;
291 }
292
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200293 DRM_INFO("radeon: irq initialized.\n");
294 return 0;
295}
296
Alex Deucherb73ba982012-07-17 14:02:35 -0400297/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900298 * radeon_irq_kms_fini - tear down driver interrupt info
Alex Deucherb73ba982012-07-17 14:02:35 -0400299 *
300 * @rdev: radeon device pointer
301 *
302 * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics).
303 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200304void radeon_irq_kms_fini(struct radeon_device *rdev)
305{
Jerome Glisse003e69f2010-01-07 15:39:14 +0100306 drm_vblank_cleanup(rdev->ddev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200307 if (rdev->irq.installed) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200308 drm_irq_uninstall(rdev->ddev);
Jerome Glisse003e69f2010-01-07 15:39:14 +0100309 rdev->irq.installed = false;
Alex Deucher3e5cb982009-10-16 12:21:24 -0400310 if (rdev->msi_enabled)
311 pci_disable_msi(rdev->pdev);
Sergey Senozhatskya01c34f2013-07-14 14:03:27 +0300312 flush_work(&rdev->hotplug_work);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200313 }
314}
Dave Airlie1614f8b2009-12-01 16:04:56 +1000315
Alex Deucherb73ba982012-07-17 14:02:35 -0400316/**
317 * radeon_irq_kms_sw_irq_get - enable software interrupt
318 *
319 * @rdev: radeon device pointer
320 * @ring: ring whose interrupt you want to enable
321 *
322 * Enables the software interrupt for a specific ring (all asics).
323 * The software interrupt is generally used to signal a fence on
324 * a particular ring.
325 */
Alex Deucher1b370782011-11-17 20:13:28 -0500326void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000327{
328 unsigned long irqflags;
329
Christian Koenig736fc372012-05-17 19:52:00 +0200330 if (!rdev->ddev->irq_enabled)
331 return;
332
333 if (atomic_inc_return(&rdev->irq.ring_int[ring]) == 1) {
334 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000335 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200336 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000337 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000338}
339
Alex Deucherb73ba982012-07-17 14:02:35 -0400340/**
Maarten Lankhorst954605c2014-01-09 11:03:12 +0100341 * radeon_irq_kms_sw_irq_get_delayed - enable software interrupt
342 *
343 * @rdev: radeon device pointer
344 * @ring: ring whose interrupt you want to enable
345 *
346 * Enables the software interrupt for a specific ring (all asics).
347 * The software interrupt is generally used to signal a fence on
348 * a particular ring.
349 */
350bool radeon_irq_kms_sw_irq_get_delayed(struct radeon_device *rdev, int ring)
351{
352 return atomic_inc_return(&rdev->irq.ring_int[ring]) == 1;
353}
354
355/**
Alex Deucherb73ba982012-07-17 14:02:35 -0400356 * radeon_irq_kms_sw_irq_put - disable software interrupt
357 *
358 * @rdev: radeon device pointer
359 * @ring: ring whose interrupt you want to disable
360 *
361 * Disables the software interrupt for a specific ring (all asics).
362 * The software interrupt is generally used to signal a fence on
363 * a particular ring.
364 */
Alex Deucher1b370782011-11-17 20:13:28 -0500365void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000366{
367 unsigned long irqflags;
368
Christian Koenig736fc372012-05-17 19:52:00 +0200369 if (!rdev->ddev->irq_enabled)
370 return;
371
372 if (atomic_dec_and_test(&rdev->irq.ring_int[ring])) {
373 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000374 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200375 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000376 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000377}
378
Alex Deucherb73ba982012-07-17 14:02:35 -0400379/**
380 * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt
381 *
382 * @rdev: radeon device pointer
383 * @crtc: crtc whose interrupt you want to enable
384 *
385 * Enables the pageflip interrupt for a specific crtc (all asics).
386 * For pageflips we use the vblank interrupt source.
387 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500388void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc)
389{
390 unsigned long irqflags;
391
392 if (crtc < 0 || crtc >= rdev->num_crtc)
393 return;
394
Christian Koenig736fc372012-05-17 19:52:00 +0200395 if (!rdev->ddev->irq_enabled)
396 return;
397
398 if (atomic_inc_return(&rdev->irq.pflip[crtc]) == 1) {
399 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500400 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200401 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500402 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500403}
404
Alex Deucherb73ba982012-07-17 14:02:35 -0400405/**
406 * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt
407 *
408 * @rdev: radeon device pointer
409 * @crtc: crtc whose interrupt you want to disable
410 *
411 * Disables the pageflip interrupt for a specific crtc (all asics).
412 * For pageflips we use the vblank interrupt source.
413 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500414void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc)
415{
416 unsigned long irqflags;
417
418 if (crtc < 0 || crtc >= rdev->num_crtc)
419 return;
420
Christian Koenig736fc372012-05-17 19:52:00 +0200421 if (!rdev->ddev->irq_enabled)
422 return;
423
424 if (atomic_dec_and_test(&rdev->irq.pflip[crtc])) {
425 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500426 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200427 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500428 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500429}
430
Alex Deucherb73ba982012-07-17 14:02:35 -0400431/**
432 * radeon_irq_kms_enable_afmt - enable audio format change interrupt
433 *
434 * @rdev: radeon device pointer
435 * @block: afmt block whose interrupt you want to enable
436 *
437 * Enables the afmt change interrupt for a specific afmt block (all asics).
438 */
Christian Koenigfb982572012-05-17 01:33:30 +0200439void radeon_irq_kms_enable_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] = true;
448 radeon_irq_set(rdev);
449 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
450
451}
452
Alex Deucherb73ba982012-07-17 14:02:35 -0400453/**
454 * radeon_irq_kms_disable_afmt - disable audio format change interrupt
455 *
456 * @rdev: radeon device pointer
457 * @block: afmt block whose interrupt you want to disable
458 *
459 * Disables the afmt change interrupt for a specific afmt block (all asics).
460 */
Christian Koenigfb982572012-05-17 01:33:30 +0200461void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block)
462{
463 unsigned long irqflags;
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 rdev->irq.afmt[block] = false;
470 radeon_irq_set(rdev);
471 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
472}
473
Alex Deucherb73ba982012-07-17 14:02:35 -0400474/**
475 * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt
476 *
477 * @rdev: radeon device pointer
478 * @hpd_mask: mask of hpd pins you want to enable.
479 *
480 * Enables the hotplug detect interrupt for a specific hpd pin (all asics).
481 */
Christian Koenigfb982572012-05-17 01:33:30 +0200482void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
483{
484 unsigned long irqflags;
485 int i;
486
Alex Deuchercc9945b2013-02-26 16:17:33 -0500487 if (!rdev->ddev->irq_enabled)
488 return;
489
Christian Koenigfb982572012-05-17 01:33:30 +0200490 spin_lock_irqsave(&rdev->irq.lock, irqflags);
491 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
492 rdev->irq.hpd[i] |= !!(hpd_mask & (1 << i));
493 radeon_irq_set(rdev);
494 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
495}
496
Alex Deucherb73ba982012-07-17 14:02:35 -0400497/**
498 * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt
499 *
500 * @rdev: radeon device pointer
501 * @hpd_mask: mask of hpd pins you want to disable.
502 *
503 * Disables the hotplug detect interrupt for a specific hpd pin (all asics).
504 */
Christian Koenigfb982572012-05-17 01:33:30 +0200505void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
506{
507 unsigned long irqflags;
508 int i;
509
Alex Deuchercc9945b2013-02-26 16:17:33 -0500510 if (!rdev->ddev->irq_enabled)
511 return;
512
Christian Koenigfb982572012-05-17 01:33:30 +0200513 spin_lock_irqsave(&rdev->irq.lock, irqflags);
514 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
515 rdev->irq.hpd[i] &= !(hpd_mask & (1 << i));
516 radeon_irq_set(rdev);
517 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
518}
519