Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 1 | /* |
Rob Clark | 8bb0daf | 2013-02-11 12:43:09 -0500 | [diff] [blame] | 2 | * drivers/gpu/drm/omapdrm/omap_irq.c |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2012 Texas Instruments |
| 5 | * Author: Rob Clark <rob.clark@linaro.org> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | * more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "omap_drv.h" |
| 21 | |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 22 | struct omap_irq_wait { |
| 23 | struct list_head node; |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 24 | wait_queue_head_t wq; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 25 | uint32_t irqmask; |
| 26 | int count; |
| 27 | }; |
| 28 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 29 | /* call with wait_lock and dispc runtime held */ |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 30 | static void omap_irq_update(struct drm_device *dev) |
| 31 | { |
| 32 | struct omap_drm_private *priv = dev->dev_private; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 33 | struct omap_irq_wait *wait; |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 34 | uint32_t irqmask = priv->irq_mask; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 35 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 36 | assert_spin_locked(&priv->wait_lock); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 37 | |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 38 | list_for_each_entry(wait, &priv->wait_list, node) |
| 39 | irqmask |= wait->irqmask; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 40 | |
| 41 | DBG("irqmask=%08x", irqmask); |
| 42 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 43 | priv->dispc_ops->write_irqenable(irqmask); |
| 44 | priv->dispc_ops->read_irqenable(); /* flush posted write */ |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 45 | } |
| 46 | |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 47 | static void omap_irq_wait_handler(struct omap_irq_wait *wait) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 48 | { |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 49 | wait->count--; |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 50 | wake_up(&wait->wq); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev, |
| 54 | uint32_t irqmask, int count) |
| 55 | { |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 56 | struct omap_drm_private *priv = dev->dev_private; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 57 | struct omap_irq_wait *wait = kzalloc(sizeof(*wait), GFP_KERNEL); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 58 | unsigned long flags; |
| 59 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 60 | init_waitqueue_head(&wait->wq); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 61 | wait->irqmask = irqmask; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 62 | wait->count = count; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 63 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 64 | spin_lock_irqsave(&priv->wait_lock, flags); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 65 | list_add(&wait->node, &priv->wait_list); |
| 66 | omap_irq_update(dev); |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 67 | spin_unlock_irqrestore(&priv->wait_lock, flags); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 68 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 69 | return wait; |
| 70 | } |
| 71 | |
| 72 | int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait, |
| 73 | unsigned long timeout) |
| 74 | { |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 75 | struct omap_drm_private *priv = dev->dev_private; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 76 | unsigned long flags; |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 77 | int ret; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 78 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 79 | ret = wait_event_timeout(wait->wq, (wait->count <= 0), timeout); |
| 80 | |
| 81 | spin_lock_irqsave(&priv->wait_lock, flags); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 82 | list_del(&wait->node); |
| 83 | omap_irq_update(dev); |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 84 | spin_unlock_irqrestore(&priv->wait_lock, flags); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 85 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 86 | kfree(wait); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 87 | |
| 88 | return ret == 0 ? -1 : 0; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
| 92 | * enable_vblank - enable vblank interrupt events |
| 93 | * @dev: DRM device |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 94 | * @pipe: which irq to enable |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 95 | * |
| 96 | * Enable vblank interrupts for @crtc. If the device doesn't have |
| 97 | * a hardware vblank counter, this routine should be a no-op, since |
| 98 | * interrupts will have to stay on to keep the count accurate. |
| 99 | * |
| 100 | * RETURNS |
| 101 | * Zero on success, appropriate errno if the given @crtc's vblank |
| 102 | * interrupt cannot be enabled. |
| 103 | */ |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 104 | int omap_irq_enable_vblank(struct drm_crtc *crtc) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 105 | { |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 106 | struct drm_device *dev = crtc->dev; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 107 | struct omap_drm_private *priv = dev->dev_private; |
| 108 | unsigned long flags; |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 109 | enum omap_channel channel = omap_crtc_channel(crtc); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 110 | |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 111 | DBG("dev=%p, crtc=%u", dev, channel); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 112 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 113 | spin_lock_irqsave(&priv->wait_lock, flags); |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 114 | priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(channel); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 115 | omap_irq_update(dev); |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 116 | spin_unlock_irqrestore(&priv->wait_lock, flags); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * disable_vblank - disable vblank interrupt events |
| 123 | * @dev: DRM device |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 124 | * @pipe: which irq to enable |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 125 | * |
| 126 | * Disable vblank interrupts for @crtc. If the device doesn't have |
| 127 | * a hardware vblank counter, this routine should be a no-op, since |
| 128 | * interrupts will have to stay on to keep the count accurate. |
| 129 | */ |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 130 | void omap_irq_disable_vblank(struct drm_crtc *crtc) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 131 | { |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 132 | struct drm_device *dev = crtc->dev; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 133 | struct omap_drm_private *priv = dev->dev_private; |
| 134 | unsigned long flags; |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 135 | enum omap_channel channel = omap_crtc_channel(crtc); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 136 | |
Tomi Valkeinen | 0396162 | 2017-02-08 13:26:00 +0200 | [diff] [blame] | 137 | DBG("dev=%p, crtc=%u", dev, channel); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 138 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 139 | spin_lock_irqsave(&priv->wait_lock, flags); |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 140 | priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(channel); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 141 | omap_irq_update(dev); |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 142 | spin_unlock_irqrestore(&priv->wait_lock, flags); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 143 | } |
| 144 | |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 145 | static void omap_irq_fifo_underflow(struct omap_drm_private *priv, |
| 146 | u32 irqstatus) |
| 147 | { |
| 148 | static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL, |
| 149 | DEFAULT_RATELIMIT_BURST); |
| 150 | static const struct { |
| 151 | const char *name; |
| 152 | u32 mask; |
| 153 | } sources[] = { |
| 154 | { "gfx", DISPC_IRQ_GFX_FIFO_UNDERFLOW }, |
| 155 | { "vid1", DISPC_IRQ_VID1_FIFO_UNDERFLOW }, |
| 156 | { "vid2", DISPC_IRQ_VID2_FIFO_UNDERFLOW }, |
| 157 | { "vid3", DISPC_IRQ_VID3_FIFO_UNDERFLOW }, |
| 158 | }; |
| 159 | |
| 160 | const u32 mask = DISPC_IRQ_GFX_FIFO_UNDERFLOW |
| 161 | | DISPC_IRQ_VID1_FIFO_UNDERFLOW |
| 162 | | DISPC_IRQ_VID2_FIFO_UNDERFLOW |
| 163 | | DISPC_IRQ_VID3_FIFO_UNDERFLOW; |
| 164 | unsigned int i; |
| 165 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 166 | spin_lock(&priv->wait_lock); |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 167 | irqstatus &= priv->irq_mask & mask; |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 168 | spin_unlock(&priv->wait_lock); |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 169 | |
| 170 | if (!irqstatus) |
| 171 | return; |
| 172 | |
| 173 | if (!__ratelimit(&_rs)) |
| 174 | return; |
| 175 | |
| 176 | DRM_ERROR("FIFO underflow on "); |
| 177 | |
| 178 | for (i = 0; i < ARRAY_SIZE(sources); ++i) { |
| 179 | if (sources[i].mask & irqstatus) |
| 180 | pr_cont("%s ", sources[i].name); |
| 181 | } |
| 182 | |
| 183 | pr_cont("(0x%08x)\n", irqstatus); |
| 184 | } |
| 185 | |
Laurent Pinchart | 6b5538d | 2015-05-28 01:05:20 +0300 | [diff] [blame] | 186 | static void omap_irq_ocp_error_handler(u32 irqstatus) |
| 187 | { |
| 188 | if (!(irqstatus & DISPC_IRQ_OCP_ERR)) |
| 189 | return; |
| 190 | |
| 191 | DRM_ERROR("OCP error\n"); |
| 192 | } |
| 193 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 194 | static irqreturn_t omap_irq_handler(int irq, void *arg) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 195 | { |
| 196 | struct drm_device *dev = (struct drm_device *) arg; |
| 197 | struct omap_drm_private *priv = dev->dev_private; |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 198 | struct omap_irq_wait *wait, *n; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 199 | unsigned long flags; |
| 200 | unsigned int id; |
| 201 | u32 irqstatus; |
| 202 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 203 | irqstatus = priv->dispc_ops->read_irqstatus(); |
| 204 | priv->dispc_ops->clear_irqstatus(irqstatus); |
| 205 | priv->dispc_ops->read_irqstatus(); /* flush posted write */ |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 206 | |
| 207 | VERB("irqs: %08x", irqstatus); |
| 208 | |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 209 | for (id = 0; id < priv->num_crtcs; id++) { |
| 210 | struct drm_crtc *crtc = priv->crtcs[id]; |
Laurent Pinchart | e0519af | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 211 | enum omap_channel channel = omap_crtc_channel(crtc); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 212 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 213 | if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(channel)) { |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 214 | drm_handle_vblank(dev, id); |
Laurent Pinchart | 14389a3 | 2016-04-19 01:43:03 +0300 | [diff] [blame] | 215 | omap_crtc_vblank_irq(crtc); |
| 216 | } |
Laurent Pinchart | e0519af | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 217 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 218 | if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(channel)) |
Laurent Pinchart | e0519af | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 219 | omap_crtc_error_irq(crtc, irqstatus); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 220 | } |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 221 | |
Laurent Pinchart | 6b5538d | 2015-05-28 01:05:20 +0300 | [diff] [blame] | 222 | omap_irq_ocp_error_handler(irqstatus); |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 223 | omap_irq_fifo_underflow(priv, irqstatus); |
| 224 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 225 | spin_lock_irqsave(&priv->wait_lock, flags); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 226 | list_for_each_entry_safe(wait, n, &priv->wait_list, node) { |
| 227 | if (wait->irqmask & irqstatus) |
| 228 | omap_irq_wait_handler(wait); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 229 | } |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 230 | spin_unlock_irqrestore(&priv->wait_lock, flags); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 231 | |
| 232 | return IRQ_HANDLED; |
| 233 | } |
| 234 | |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 235 | static const u32 omap_underflow_irqs[] = { |
| 236 | [OMAP_DSS_GFX] = DISPC_IRQ_GFX_FIFO_UNDERFLOW, |
| 237 | [OMAP_DSS_VIDEO1] = DISPC_IRQ_VID1_FIFO_UNDERFLOW, |
| 238 | [OMAP_DSS_VIDEO2] = DISPC_IRQ_VID2_FIFO_UNDERFLOW, |
| 239 | [OMAP_DSS_VIDEO3] = DISPC_IRQ_VID3_FIFO_UNDERFLOW, |
| 240 | }; |
| 241 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 242 | /* |
| 243 | * We need a special version, instead of just using drm_irq_install(), |
| 244 | * because we need to register the irq via omapdss. Once omapdss and |
| 245 | * omapdrm are merged together we can assign the dispc hwmod data to |
| 246 | * ourselves and drop these and just use drm_irq_{install,uninstall}() |
| 247 | */ |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 248 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 249 | int omap_drm_irq_install(struct drm_device *dev) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 250 | { |
| 251 | struct omap_drm_private *priv = dev->dev_private; |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 252 | unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs(); |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 253 | unsigned int max_planes; |
| 254 | unsigned int i; |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 255 | int ret; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 256 | |
Laurent Pinchart | 84e1d45 | 2016-04-19 03:07:59 +0300 | [diff] [blame] | 257 | spin_lock_init(&priv->wait_lock); |
Laurent Pinchart | 80f91bf | 2016-04-19 02:47:02 +0300 | [diff] [blame] | 258 | INIT_LIST_HEAD(&priv->wait_list); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 259 | |
Laurent Pinchart | 6b5538d | 2015-05-28 01:05:20 +0300 | [diff] [blame] | 260 | priv->irq_mask = DISPC_IRQ_OCP_ERR; |
Laurent Pinchart | 728ae8d | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 261 | |
| 262 | max_planes = min(ARRAY_SIZE(priv->planes), |
| 263 | ARRAY_SIZE(omap_underflow_irqs)); |
| 264 | for (i = 0; i < max_planes; ++i) { |
| 265 | if (priv->planes[i]) |
| 266 | priv->irq_mask |= omap_underflow_irqs[i]; |
| 267 | } |
| 268 | |
Laurent Pinchart | e0519af | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 269 | for (i = 0; i < num_mgrs; ++i) |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 270 | priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(i); |
Laurent Pinchart | e0519af | 2015-05-28 00:21:29 +0300 | [diff] [blame] | 271 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 272 | priv->dispc_ops->runtime_get(); |
| 273 | priv->dispc_ops->clear_irqstatus(0xffffffff); |
| 274 | priv->dispc_ops->runtime_put(); |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 275 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 276 | ret = priv->dispc_ops->request_irq(omap_irq_handler, dev); |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 277 | if (ret < 0) |
| 278 | return ret; |
| 279 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 280 | dev->irq_enabled = true; |
| 281 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 282 | return 0; |
| 283 | } |
| 284 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 285 | void omap_drm_irq_uninstall(struct drm_device *dev) |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 286 | { |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 287 | struct omap_drm_private *priv = dev->dev_private; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 288 | unsigned long irqflags; |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 289 | int i; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 290 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 291 | if (!dev->irq_enabled) |
| 292 | return; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 293 | |
Laurent Pinchart | f13ab00 | 2015-01-25 22:06:45 +0200 | [diff] [blame] | 294 | dev->irq_enabled = false; |
| 295 | |
| 296 | /* Wake up any waiters so they don't hang. */ |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 297 | if (dev->num_crtcs) { |
| 298 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
| 299 | for (i = 0; i < dev->num_crtcs; i++) { |
Daniel Vetter | 57ed0f7 | 2013-12-11 11:34:43 +0100 | [diff] [blame] | 300 | wake_up(&dev->vblank[i].queue); |
Ville Syrjälä | 5380e92 | 2013-10-04 14:53:36 +0300 | [diff] [blame] | 301 | dev->vblank[i].enabled = false; |
| 302 | dev->vblank[i].last = |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 303 | dev->driver->get_vblank_counter(dev, i); |
| 304 | } |
| 305 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
| 306 | } |
| 307 | |
Tomi Valkeinen | 9f75922 | 2015-11-05 18:39:52 +0200 | [diff] [blame^] | 308 | priv->dispc_ops->free_irq(dev); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 309 | } |