Merge branch 'topic/oss' into for-linus
[linux-2.6-block.git] / drivers / gpu / drm / radeon / radeon_irq_kms.c
CommitLineData
771fe6b9
JG
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 "radeon_drm.h"
30#include "radeon_reg.h"
31#include "radeon_microcode.h"
32#include "radeon.h"
33#include "atom.h"
34
771fe6b9
JG
35irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
36{
37 struct drm_device *dev = (struct drm_device *) arg;
38 struct radeon_device *rdev = dev->dev_private;
39
40 return radeon_irq_process(rdev);
41}
42
43void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
44{
45 struct radeon_device *rdev = dev->dev_private;
46 unsigned i;
47
48 /* Disable *all* interrupts */
49 rdev->irq.sw_int = false;
50 for (i = 0; i < 2; i++) {
51 rdev->irq.crtc_vblank_int[i] = false;
52 }
53 radeon_irq_set(rdev);
54 /* Clear bits */
55 radeon_irq_process(rdev);
56}
57
58int radeon_driver_irq_postinstall_kms(struct drm_device *dev)
59{
60 struct radeon_device *rdev = dev->dev_private;
61
62 dev->max_vblank_count = 0x001fffff;
63 rdev->irq.sw_int = true;
64 radeon_irq_set(rdev);
65 return 0;
66}
67
68void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
69{
70 struct radeon_device *rdev = dev->dev_private;
71 unsigned i;
72
73 if (rdev == NULL) {
74 return;
75 }
76 /* Disable *all* interrupts */
77 rdev->irq.sw_int = false;
78 for (i = 0; i < 2; i++) {
79 rdev->irq.crtc_vblank_int[i] = false;
80 }
81 radeon_irq_set(rdev);
82}
83
84int radeon_irq_kms_init(struct radeon_device *rdev)
85{
86 int r = 0;
87
88 r = drm_vblank_init(rdev->ddev, 2);
89 if (r) {
90 return r;
91 }
92 drm_irq_install(rdev->ddev);
93 rdev->irq.installed = true;
94 DRM_INFO("radeon: irq initialized.\n");
95 return 0;
96}
97
98void radeon_irq_kms_fini(struct radeon_device *rdev)
99{
100 if (rdev->irq.installed) {
101 rdev->irq.installed = false;
102 drm_irq_uninstall(rdev->ddev);
103 }
104}