blob: 1fe12ab5c5ea9a133d7cf379f06cf37345c9349d [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/**
85 * radeon_driver_irq_preinstall_kms - drm irq preinstall callback
86 *
87 * @dev: drm dev pointer
88 *
89 * Gets the hw ready to enable irqs (all asics).
90 * This function disables all interrupt sources on the GPU.
91 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +020092void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
93{
94 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +020095 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +020096 unsigned i;
97
Christian Koenigfb982572012-05-17 01:33:30 +020098 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +020099 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500100 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200101 atomic_set(&rdev->irq.ring_int[i], 0);
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400102 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Alex Deucher9e7b4142010-03-16 17:08:06 -0400103 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400104 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
105 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200106 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400107 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500108 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200109 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200110 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200111 /* Clear bits */
112 radeon_irq_process(rdev);
113}
114
Alex Deucherb73ba982012-07-17 14:02:35 -0400115/**
116 * radeon_driver_irq_postinstall_kms - drm irq preinstall callback
117 *
118 * @dev: drm dev pointer
119 *
120 * Handles stuff to be done after enabling irqs (all asics).
121 * Returns 0 on success.
122 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200123int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
124{
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200125 dev->max_vblank_count = 0x001fffff;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200126 return 0;
127}
128
Alex Deucherb73ba982012-07-17 14:02:35 -0400129/**
130 * radeon_driver_irq_uninstall_kms - drm irq uninstall callback
131 *
132 * @dev: drm dev pointer
133 *
134 * This function disables all interrupt sources on the GPU (all asics).
135 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200136void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
137{
138 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200139 unsigned long irqflags;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200140 unsigned i;
141
142 if (rdev == NULL) {
143 return;
144 }
Christian Koenigfb982572012-05-17 01:33:30 +0200145 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200146 /* Disable *all* interrupts */
Alex Deucher1b370782011-11-17 20:13:28 -0500147 for (i = 0; i < RADEON_NUM_RINGS; i++)
Christian Koenig736fc372012-05-17 19:52:00 +0200148 atomic_set(&rdev->irq.ring_int[i], 0);
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400149 for (i = 0; i < RADEON_MAX_HPD_PINS; i++)
Jerome Glisse003e69f2010-01-07 15:39:14 +0100150 rdev->irq.hpd[i] = false;
Ilija Hadzic54bd5202011-10-26 15:43:58 -0400151 for (i = 0; i < RADEON_MAX_CRTCS; i++) {
152 rdev->irq.crtc_vblank_int[i] = false;
Christian Koenig736fc372012-05-17 19:52:00 +0200153 atomic_set(&rdev->irq.pflip[i], 0);
Alex Deucherf122c612012-03-30 08:59:57 -0400154 rdev->irq.afmt[i] = false;
Alex Deucher6f34be52010-11-21 10:59:01 -0500155 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200156 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200157 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200158}
159
Alex Deucherb73ba982012-07-17 14:02:35 -0400160/**
161 * radeon_msi_ok - asic specific msi checks
162 *
163 * @rdev: radeon device pointer
164 *
165 * Handles asic specific MSI checks to determine if
166 * MSIs should be enabled on a particular chip (all asics).
167 * Returns true if MSIs should be enabled, false if MSIs
168 * should not be enabled.
169 */
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400170static bool radeon_msi_ok(struct radeon_device *rdev)
171{
172 /* RV370/RV380 was first asic with MSI support */
173 if (rdev->family < CHIP_RV380)
174 return false;
175
176 /* MSIs don't work on AGP */
177 if (rdev->flags & RADEON_IS_AGP)
178 return false;
179
Alex Deuchera18cee12011-11-01 14:20:30 -0400180 /* force MSI on */
181 if (radeon_msi == 1)
182 return true;
183 else if (radeon_msi == 0)
184 return false;
185
Alex Deucherb3621052011-10-25 15:11:08 -0400186 /* Quirks */
187 /* HP RS690 only seems to work with MSIs. */
188 if ((rdev->pdev->device == 0x791f) &&
189 (rdev->pdev->subsystem_vendor == 0x103c) &&
190 (rdev->pdev->subsystem_device == 0x30c2))
191 return true;
192
Alex Deucher01e718e2011-11-01 14:14:18 -0400193 /* Dell RS690 only seems to work with MSIs. */
194 if ((rdev->pdev->device == 0x791f) &&
195 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher44517c42012-01-15 08:51:12 -0500196 (rdev->pdev->subsystem_device == 0x01fc))
197 return true;
198
199 /* Dell RS690 only seems to work with MSIs. */
200 if ((rdev->pdev->device == 0x791f) &&
201 (rdev->pdev->subsystem_vendor == 0x1028) &&
Alex Deucher01e718e2011-11-01 14:14:18 -0400202 (rdev->pdev->subsystem_device == 0x01fd))
203 return true;
204
Alex Deucher3a6d59d2012-09-26 12:31:45 -0400205 /* Gateway RS690 only seems to work with MSIs. */
206 if ((rdev->pdev->device == 0x791f) &&
207 (rdev->pdev->subsystem_vendor == 0x107b) &&
208 (rdev->pdev->subsystem_device == 0x0185))
209 return true;
210
Alex Deucherfb6ca6d2012-09-26 12:40:45 -0400211 /* try and enable MSIs by default on all RS690s */
212 if (rdev->family == CHIP_RS690)
213 return true;
214
Dave Airlie16a5e322012-04-13 11:14:50 +0100215 /* RV515 seems to have MSI issues where it loses
216 * MSI rearms occasionally. This leads to lockups and freezes.
217 * disable it by default.
218 */
219 if (rdev->family == CHIP_RV515)
220 return false;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400221 if (rdev->flags & RADEON_IS_IGP) {
222 /* APUs work fine with MSIs */
223 if (rdev->family >= CHIP_PALM)
224 return true;
225 /* lots of IGPs have problems with MSIs */
226 return false;
227 }
228
229 return true;
230}
231
Alex Deucherb73ba982012-07-17 14:02:35 -0400232/**
233 * radeon_irq_kms_init - init driver interrupt info
234 *
235 * @rdev: radeon device pointer
236 *
237 * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics).
238 * Returns 0 for success, error for failure.
239 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200240int radeon_irq_kms_init(struct radeon_device *rdev)
241{
242 int r = 0;
243
Christian Koenigfb982572012-05-17 01:33:30 +0200244 spin_lock_init(&rdev->irq.lock);
Alex Deucher9e7b4142010-03-16 17:08:06 -0400245 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200246 if (r) {
247 return r;
248 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400249 /* enable msi */
250 rdev->msi_enabled = 0;
Alex Deucher8f6c25c2011-10-25 14:58:49 -0400251
252 if (radeon_msi_ok(rdev)) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400253 int ret = pci_enable_msi(rdev->pdev);
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500254 if (!ret) {
Alex Deucher3e5cb982009-10-16 12:21:24 -0400255 rdev->msi_enabled = 1;
Alex Deucherda7be682010-08-12 18:05:34 -0400256 dev_info(rdev->dev, "radeon: using MSI.\n");
Alex Deucherd8f60cf2009-12-01 13:43:46 -0500257 }
Alex Deucher3e5cb982009-10-16 12:21:24 -0400258 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200259 rdev->irq.installed = true;
Jerome Glisse003e69f2010-01-07 15:39:14 +0100260 r = drm_irq_install(rdev->ddev);
261 if (r) {
262 rdev->irq.installed = false;
263 return r;
264 }
Sergey Senozhatsky6655d762013-07-14 14:03:27 +0300265
266 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
267 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
268
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200269 DRM_INFO("radeon: irq initialized.\n");
270 return 0;
271}
272
Alex Deucherb73ba982012-07-17 14:02:35 -0400273/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900274 * radeon_irq_kms_fini - tear down driver interrupt info
Alex Deucherb73ba982012-07-17 14:02:35 -0400275 *
276 * @rdev: radeon device pointer
277 *
278 * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics).
279 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200280void radeon_irq_kms_fini(struct radeon_device *rdev)
281{
Jerome Glisse003e69f2010-01-07 15:39:14 +0100282 drm_vblank_cleanup(rdev->ddev);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200283 if (rdev->irq.installed) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200284 drm_irq_uninstall(rdev->ddev);
Jerome Glisse003e69f2010-01-07 15:39:14 +0100285 rdev->irq.installed = false;
Alex Deucher3e5cb982009-10-16 12:21:24 -0400286 if (rdev->msi_enabled)
287 pci_disable_msi(rdev->pdev);
Sergey Senozhatsky6655d762013-07-14 14:03:27 +0300288 flush_work(&rdev->hotplug_work);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200289 }
290}
Dave Airlie1614f8b2009-12-01 16:04:56 +1000291
Alex Deucherb73ba982012-07-17 14:02:35 -0400292/**
293 * radeon_irq_kms_sw_irq_get - enable software interrupt
294 *
295 * @rdev: radeon device pointer
296 * @ring: ring whose interrupt you want to enable
297 *
298 * Enables the software interrupt for a specific ring (all asics).
299 * The software interrupt is generally used to signal a fence on
300 * a particular ring.
301 */
Alex Deucher1b370782011-11-17 20:13:28 -0500302void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring)
Dave Airlie1614f8b2009-12-01 16:04:56 +1000303{
304 unsigned long irqflags;
305
Christian Koenig736fc372012-05-17 19:52:00 +0200306 if (!rdev->ddev->irq_enabled)
307 return;
308
309 if (atomic_inc_return(&rdev->irq.ring_int[ring]) == 1) {
310 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000311 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200312 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Dave Airlie1614f8b2009-12-01 16:04:56 +1000313 }
Dave Airlie1614f8b2009-12-01 16:04:56 +1000314}
315
Alex Deucherb73ba982012-07-17 14:02:35 -0400316/**
317 * radeon_irq_kms_sw_irq_put - disable software interrupt
318 *
319 * @rdev: radeon device pointer
320 * @ring: ring whose interrupt you want to disable
321 *
322 * Disables 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_put(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_dec_and_test(&rdev->irq.ring_int[ring])) {
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/**
341 * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt
342 *
343 * @rdev: radeon device pointer
344 * @crtc: crtc whose interrupt you want to enable
345 *
346 * Enables the pageflip interrupt for a specific crtc (all asics).
347 * For pageflips we use the vblank interrupt source.
348 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500349void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc)
350{
351 unsigned long irqflags;
352
353 if (crtc < 0 || crtc >= rdev->num_crtc)
354 return;
355
Christian Koenig736fc372012-05-17 19:52:00 +0200356 if (!rdev->ddev->irq_enabled)
357 return;
358
359 if (atomic_inc_return(&rdev->irq.pflip[crtc]) == 1) {
360 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500361 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200362 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500363 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500364}
365
Alex Deucherb73ba982012-07-17 14:02:35 -0400366/**
367 * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt
368 *
369 * @rdev: radeon device pointer
370 * @crtc: crtc whose interrupt you want to disable
371 *
372 * Disables the pageflip interrupt for a specific crtc (all asics).
373 * For pageflips we use the vblank interrupt source.
374 */
Alex Deucher6f34be52010-11-21 10:59:01 -0500375void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc)
376{
377 unsigned long irqflags;
378
379 if (crtc < 0 || crtc >= rdev->num_crtc)
380 return;
381
Christian Koenig736fc372012-05-17 19:52:00 +0200382 if (!rdev->ddev->irq_enabled)
383 return;
384
385 if (atomic_dec_and_test(&rdev->irq.pflip[crtc])) {
386 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500387 radeon_irq_set(rdev);
Christian Koenig736fc372012-05-17 19:52:00 +0200388 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Alex Deucher6f34be52010-11-21 10:59:01 -0500389 }
Alex Deucher6f34be52010-11-21 10:59:01 -0500390}
391
Alex Deucherb73ba982012-07-17 14:02:35 -0400392/**
393 * radeon_irq_kms_enable_afmt - enable audio format change interrupt
394 *
395 * @rdev: radeon device pointer
396 * @block: afmt block whose interrupt you want to enable
397 *
398 * Enables the afmt change interrupt for a specific afmt block (all asics).
399 */
Christian Koenigfb982572012-05-17 01:33:30 +0200400void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block)
401{
402 unsigned long irqflags;
403
Alex Deuchercc9945b2013-02-26 16:17:33 -0500404 if (!rdev->ddev->irq_enabled)
405 return;
406
Christian Koenigfb982572012-05-17 01:33:30 +0200407 spin_lock_irqsave(&rdev->irq.lock, irqflags);
408 rdev->irq.afmt[block] = true;
409 radeon_irq_set(rdev);
410 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
411
412}
413
Alex Deucherb73ba982012-07-17 14:02:35 -0400414/**
415 * radeon_irq_kms_disable_afmt - disable audio format change interrupt
416 *
417 * @rdev: radeon device pointer
418 * @block: afmt block whose interrupt you want to disable
419 *
420 * Disables the afmt change interrupt for a specific afmt block (all asics).
421 */
Christian Koenigfb982572012-05-17 01:33:30 +0200422void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block)
423{
424 unsigned long irqflags;
425
Alex Deuchercc9945b2013-02-26 16:17:33 -0500426 if (!rdev->ddev->irq_enabled)
427 return;
428
Christian Koenigfb982572012-05-17 01:33:30 +0200429 spin_lock_irqsave(&rdev->irq.lock, irqflags);
430 rdev->irq.afmt[block] = false;
431 radeon_irq_set(rdev);
432 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
433}
434
Alex Deucherb73ba982012-07-17 14:02:35 -0400435/**
436 * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt
437 *
438 * @rdev: radeon device pointer
439 * @hpd_mask: mask of hpd pins you want to enable.
440 *
441 * Enables the hotplug detect interrupt for a specific hpd pin (all asics).
442 */
Christian Koenigfb982572012-05-17 01:33:30 +0200443void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
444{
445 unsigned long irqflags;
446 int i;
447
Alex Deuchercc9945b2013-02-26 16:17:33 -0500448 if (!rdev->ddev->irq_enabled)
449 return;
450
Christian Koenigfb982572012-05-17 01:33:30 +0200451 spin_lock_irqsave(&rdev->irq.lock, irqflags);
452 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
453 rdev->irq.hpd[i] |= !!(hpd_mask & (1 << i));
454 radeon_irq_set(rdev);
455 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
456}
457
Alex Deucherb73ba982012-07-17 14:02:35 -0400458/**
459 * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt
460 *
461 * @rdev: radeon device pointer
462 * @hpd_mask: mask of hpd pins you want to disable.
463 *
464 * Disables the hotplug detect interrupt for a specific hpd pin (all asics).
465 */
Christian Koenigfb982572012-05-17 01:33:30 +0200466void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask)
467{
468 unsigned long irqflags;
469 int i;
470
Alex Deuchercc9945b2013-02-26 16:17:33 -0500471 if (!rdev->ddev->irq_enabled)
472 return;
473
Christian Koenigfb982572012-05-17 01:33:30 +0200474 spin_lock_irqsave(&rdev->irq.lock, irqflags);
475 for (i = 0; i < RADEON_MAX_HPD_PINS; ++i)
476 rdev->irq.hpd[i] &= !(hpd_mask & (1 << i));
477 radeon_irq_set(rdev);
478 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
479}
480