Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Texas Instruments |
| 3 | * Author: Rob Clark <robdclark@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 18 | #include "drm_flip_work.h" |
Daniel Vetter | 3cb9ae4 | 2014-10-29 10:03:57 +0100 | [diff] [blame] | 19 | #include <drm/drm_plane_helper.h> |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 20 | |
| 21 | #include "tilcdc_drv.h" |
| 22 | #include "tilcdc_regs.h" |
| 23 | |
| 24 | struct tilcdc_crtc { |
| 25 | struct drm_crtc base; |
| 26 | |
| 27 | const struct tilcdc_panel_info *info; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 28 | struct drm_pending_vblank_event *event; |
| 29 | int dpms; |
| 30 | wait_queue_head_t frame_done_wq; |
| 31 | bool frame_done; |
| 32 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 33 | struct drm_framebuffer *curr_fb; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 34 | |
| 35 | /* for deferred fb unref's: */ |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 36 | struct drm_flip_work unref_work; |
Jyri Sarha | 103cd8b | 2015-02-10 14:13:23 +0200 | [diff] [blame] | 37 | |
| 38 | /* Only set if an external encoder is connected */ |
| 39 | bool simulate_vesa_sync; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 40 | }; |
| 41 | #define to_tilcdc_crtc(x) container_of(x, struct tilcdc_crtc, base) |
| 42 | |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 43 | static void unref_worker(struct drm_flip_work *work, void *val) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 44 | { |
Darren Etheridge | f7b4575 | 2013-06-21 13:52:26 -0500 | [diff] [blame] | 45 | struct tilcdc_crtc *tilcdc_crtc = |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 46 | container_of(work, struct tilcdc_crtc, unref_work); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 47 | struct drm_device *dev = tilcdc_crtc->base.dev; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 48 | |
| 49 | mutex_lock(&dev->mode_config.mutex); |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 50 | drm_framebuffer_unreference(val); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 51 | mutex_unlock(&dev->mode_config.mutex); |
| 52 | } |
| 53 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 54 | static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 55 | { |
| 56 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 57 | struct drm_device *dev = crtc->dev; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 58 | struct drm_gem_cma_object *gem; |
| 59 | unsigned int depth, bpp; |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 60 | dma_addr_t start, end; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 61 | |
| 62 | drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp); |
| 63 | gem = drm_fb_cma_get_gem_obj(fb, 0); |
| 64 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 65 | start = gem->paddr + fb->offsets[0] + |
| 66 | crtc->y * fb->pitches[0] + |
| 67 | crtc->x * bpp / 8; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 68 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 69 | end = start + (crtc->mode.vdisplay * fb->pitches[0]); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 70 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 71 | tilcdc_write(dev, LCDC_DMA_FB_BASE_ADDR_0_REG, start); |
| 72 | tilcdc_write(dev, LCDC_DMA_FB_CEILING_ADDR_0_REG, end); |
| 73 | |
| 74 | if (tilcdc_crtc->curr_fb) |
| 75 | drm_flip_work_queue(&tilcdc_crtc->unref_work, |
| 76 | tilcdc_crtc->curr_fb); |
| 77 | |
| 78 | tilcdc_crtc->curr_fb = fb; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 79 | } |
| 80 | |
Tomi Valkeinen | 2efec4f | 2015-10-20 09:37:27 +0300 | [diff] [blame] | 81 | static void reset(struct drm_crtc *crtc) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 82 | { |
| 83 | struct drm_device *dev = crtc->dev; |
| 84 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 85 | |
Tomi Valkeinen | 2efec4f | 2015-10-20 09:37:27 +0300 | [diff] [blame] | 86 | if (priv->rev != 2) |
| 87 | return; |
| 88 | |
| 89 | tilcdc_set(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET); |
| 90 | usleep_range(250, 1000); |
| 91 | tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET); |
| 92 | } |
| 93 | |
| 94 | static void start(struct drm_crtc *crtc) |
| 95 | { |
| 96 | struct drm_device *dev = crtc->dev; |
| 97 | |
| 98 | reset(crtc); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 99 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 100 | tilcdc_clear(dev, LCDC_DMA_CTRL_REG, LCDC_DUAL_FRAME_BUFFER_ENABLE); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 101 | tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_PALETTE_LOAD_MODE(DATA_ONLY)); |
| 102 | tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); |
| 103 | } |
| 104 | |
| 105 | static void stop(struct drm_crtc *crtc) |
| 106 | { |
| 107 | struct drm_device *dev = crtc->dev; |
| 108 | |
| 109 | tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); |
| 110 | } |
| 111 | |
| 112 | static void tilcdc_crtc_destroy(struct drm_crtc *crtc) |
| 113 | { |
| 114 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 115 | |
Jyri Sarha | de9cb5f | 2015-02-26 10:12:41 +0200 | [diff] [blame] | 116 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 117 | |
| 118 | drm_crtc_cleanup(crtc); |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 119 | drm_flip_work_cleanup(&tilcdc_crtc->unref_work); |
| 120 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 121 | kfree(tilcdc_crtc); |
| 122 | } |
| 123 | |
Tomi Valkeinen | 6f206e9 | 2014-02-07 17:37:07 +0000 | [diff] [blame] | 124 | static int tilcdc_verify_fb(struct drm_crtc *crtc, struct drm_framebuffer *fb) |
| 125 | { |
| 126 | struct drm_device *dev = crtc->dev; |
| 127 | unsigned int depth, bpp; |
| 128 | |
| 129 | drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp); |
| 130 | |
| 131 | if (fb->pitches[0] != crtc->mode.hdisplay * bpp / 8) { |
| 132 | dev_err(dev->dev, |
| 133 | "Invalid pitch: fb and crtc widths must be the same"); |
| 134 | return -EINVAL; |
| 135 | } |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 140 | static int tilcdc_crtc_page_flip(struct drm_crtc *crtc, |
| 141 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 142 | struct drm_pending_vblank_event *event, |
| 143 | uint32_t page_flip_flags) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 144 | { |
| 145 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 146 | struct drm_device *dev = crtc->dev; |
Tomi Valkeinen | 6f206e9 | 2014-02-07 17:37:07 +0000 | [diff] [blame] | 147 | int r; |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 148 | unsigned long flags; |
Tomi Valkeinen | 6f206e9 | 2014-02-07 17:37:07 +0000 | [diff] [blame] | 149 | |
| 150 | r = tilcdc_verify_fb(crtc, fb); |
| 151 | if (r) |
| 152 | return r; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 153 | |
| 154 | if (tilcdc_crtc->event) { |
| 155 | dev_err(dev->dev, "already pending page flip!\n"); |
| 156 | return -EBUSY; |
| 157 | } |
| 158 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 159 | drm_framebuffer_reference(fb); |
| 160 | |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 161 | crtc->primary->fb = fb; |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 162 | |
| 163 | pm_runtime_get_sync(dev->dev); |
| 164 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 165 | |
| 166 | set_scanout(crtc, fb); |
| 167 | |
| 168 | spin_lock_irqsave(&dev->event_lock, flags); |
| 169 | tilcdc_crtc->event = event; |
| 170 | spin_unlock_irqrestore(&dev->event_lock, flags); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 171 | |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 172 | pm_runtime_put_sync(dev->dev); |
| 173 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | |
Darren Etheridge | 614b3cfe | 2014-09-25 00:59:32 +0000 | [diff] [blame] | 177 | void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 178 | { |
| 179 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 180 | struct drm_device *dev = crtc->dev; |
| 181 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 182 | |
| 183 | /* we really only care about on or off: */ |
| 184 | if (mode != DRM_MODE_DPMS_ON) |
| 185 | mode = DRM_MODE_DPMS_OFF; |
| 186 | |
| 187 | if (tilcdc_crtc->dpms == mode) |
| 188 | return; |
| 189 | |
| 190 | tilcdc_crtc->dpms = mode; |
| 191 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 192 | if (mode == DRM_MODE_DPMS_ON) { |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 193 | pm_runtime_get_sync(dev->dev); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 194 | start(crtc); |
| 195 | } else { |
| 196 | tilcdc_crtc->frame_done = false; |
| 197 | stop(crtc); |
| 198 | |
Darren Etheridge | f7b4575 | 2013-06-21 13:52:26 -0500 | [diff] [blame] | 199 | /* |
| 200 | * if necessary wait for framedone irq which will still come |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 201 | * before putting things to sleep.. |
| 202 | */ |
| 203 | if (priv->rev == 2) { |
| 204 | int ret = wait_event_timeout( |
| 205 | tilcdc_crtc->frame_done_wq, |
| 206 | tilcdc_crtc->frame_done, |
| 207 | msecs_to_jiffies(50)); |
| 208 | if (ret == 0) |
| 209 | dev_err(dev->dev, "timeout waiting for framedone\n"); |
| 210 | } |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 211 | |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 212 | pm_runtime_put_sync(dev->dev); |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 213 | |
| 214 | if (tilcdc_crtc->curr_fb) { |
| 215 | drm_flip_work_queue(&tilcdc_crtc->unref_work, |
| 216 | tilcdc_crtc->curr_fb); |
| 217 | tilcdc_crtc->curr_fb = NULL; |
| 218 | } |
| 219 | |
| 220 | drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 221 | } |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, |
| 225 | const struct drm_display_mode *mode, |
| 226 | struct drm_display_mode *adjusted_mode) |
| 227 | { |
Jyri Sarha | 103cd8b | 2015-02-10 14:13:23 +0200 | [diff] [blame] | 228 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 229 | |
| 230 | if (!tilcdc_crtc->simulate_vesa_sync) |
| 231 | return true; |
| 232 | |
| 233 | /* |
| 234 | * tilcdc does not generate VESA-compliant sync but aligns |
| 235 | * VS on the second edge of HS instead of first edge. |
| 236 | * We use adjusted_mode, to fixup sync by aligning both rising |
| 237 | * edges and add HSKEW offset to fix the sync. |
| 238 | */ |
| 239 | adjusted_mode->hskew = mode->hsync_end - mode->hsync_start; |
| 240 | adjusted_mode->flags |= DRM_MODE_FLAG_HSKEW; |
| 241 | |
| 242 | if (mode->flags & DRM_MODE_FLAG_NHSYNC) { |
| 243 | adjusted_mode->flags |= DRM_MODE_FLAG_PHSYNC; |
| 244 | adjusted_mode->flags &= ~DRM_MODE_FLAG_NHSYNC; |
| 245 | } else { |
| 246 | adjusted_mode->flags |= DRM_MODE_FLAG_NHSYNC; |
| 247 | adjusted_mode->flags &= ~DRM_MODE_FLAG_PHSYNC; |
| 248 | } |
| 249 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 250 | return true; |
| 251 | } |
| 252 | |
| 253 | static void tilcdc_crtc_prepare(struct drm_crtc *crtc) |
| 254 | { |
| 255 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
| 256 | } |
| 257 | |
| 258 | static void tilcdc_crtc_commit(struct drm_crtc *crtc) |
| 259 | { |
| 260 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_ON); |
| 261 | } |
| 262 | |
| 263 | static int tilcdc_crtc_mode_set(struct drm_crtc *crtc, |
| 264 | struct drm_display_mode *mode, |
| 265 | struct drm_display_mode *adjusted_mode, |
| 266 | int x, int y, |
| 267 | struct drm_framebuffer *old_fb) |
| 268 | { |
| 269 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 270 | struct drm_device *dev = crtc->dev; |
| 271 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 272 | const struct tilcdc_panel_info *info = tilcdc_crtc->info; |
| 273 | uint32_t reg, hbp, hfp, hsw, vbp, vfp, vsw; |
| 274 | int ret; |
| 275 | |
| 276 | ret = tilcdc_crtc_mode_valid(crtc, mode); |
| 277 | if (WARN_ON(ret)) |
| 278 | return ret; |
| 279 | |
| 280 | if (WARN_ON(!info)) |
| 281 | return -EINVAL; |
| 282 | |
Tomi Valkeinen | 6f206e9 | 2014-02-07 17:37:07 +0000 | [diff] [blame] | 283 | ret = tilcdc_verify_fb(crtc, crtc->primary->fb); |
| 284 | if (ret) |
| 285 | return ret; |
| 286 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 287 | pm_runtime_get_sync(dev->dev); |
| 288 | |
| 289 | /* Configure the Burst Size and fifo threshold of DMA: */ |
| 290 | reg = tilcdc_read(dev, LCDC_DMA_CTRL_REG) & ~0x00000770; |
| 291 | switch (info->dma_burst_sz) { |
| 292 | case 1: |
| 293 | reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_1); |
| 294 | break; |
| 295 | case 2: |
| 296 | reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_2); |
| 297 | break; |
| 298 | case 4: |
| 299 | reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_4); |
| 300 | break; |
| 301 | case 8: |
| 302 | reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_8); |
| 303 | break; |
| 304 | case 16: |
| 305 | reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16); |
| 306 | break; |
| 307 | default: |
| 308 | return -EINVAL; |
| 309 | } |
| 310 | reg |= (info->fifo_th << 8); |
| 311 | tilcdc_write(dev, LCDC_DMA_CTRL_REG, reg); |
| 312 | |
| 313 | /* Configure timings: */ |
| 314 | hbp = mode->htotal - mode->hsync_end; |
| 315 | hfp = mode->hsync_start - mode->hdisplay; |
| 316 | hsw = mode->hsync_end - mode->hsync_start; |
| 317 | vbp = mode->vtotal - mode->vsync_end; |
| 318 | vfp = mode->vsync_start - mode->vdisplay; |
| 319 | vsw = mode->vsync_end - mode->vsync_start; |
| 320 | |
| 321 | DBG("%dx%d, hbp=%u, hfp=%u, hsw=%u, vbp=%u, vfp=%u, vsw=%u", |
| 322 | mode->hdisplay, mode->vdisplay, hbp, hfp, hsw, vbp, vfp, vsw); |
| 323 | |
| 324 | /* Configure the AC Bias Period and Number of Transitions per Interrupt: */ |
| 325 | reg = tilcdc_read(dev, LCDC_RASTER_TIMING_2_REG) & ~0x000fff00; |
| 326 | reg |= LCDC_AC_BIAS_FREQUENCY(info->ac_bias) | |
| 327 | LCDC_AC_BIAS_TRANSITIONS_PER_INT(info->ac_bias_intrpt); |
Darren Etheridge | db2b4bd | 2013-06-21 13:52:24 -0500 | [diff] [blame] | 328 | |
| 329 | /* |
| 330 | * subtract one from hfp, hbp, hsw because the hardware uses |
| 331 | * a value of 0 as 1 |
| 332 | */ |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 333 | if (priv->rev == 2) { |
Pantelis Antoniou | c19b3e2 | 2013-06-21 13:52:28 -0500 | [diff] [blame] | 334 | /* clear bits we're going to set */ |
| 335 | reg &= ~0x78000033; |
Darren Etheridge | db2b4bd | 2013-06-21 13:52:24 -0500 | [diff] [blame] | 336 | reg |= ((hfp-1) & 0x300) >> 8; |
| 337 | reg |= ((hbp-1) & 0x300) >> 4; |
| 338 | reg |= ((hsw-1) & 0x3c0) << 21; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 339 | } |
| 340 | tilcdc_write(dev, LCDC_RASTER_TIMING_2_REG, reg); |
| 341 | |
| 342 | reg = (((mode->hdisplay >> 4) - 1) << 4) | |
Darren Etheridge | db2b4bd | 2013-06-21 13:52:24 -0500 | [diff] [blame] | 343 | (((hbp-1) & 0xff) << 24) | |
| 344 | (((hfp-1) & 0xff) << 16) | |
| 345 | (((hsw-1) & 0x3f) << 10); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 346 | if (priv->rev == 2) |
| 347 | reg |= (((mode->hdisplay >> 4) - 1) & 0x40) >> 3; |
| 348 | tilcdc_write(dev, LCDC_RASTER_TIMING_0_REG, reg); |
| 349 | |
| 350 | reg = ((mode->vdisplay - 1) & 0x3ff) | |
| 351 | ((vbp & 0xff) << 24) | |
| 352 | ((vfp & 0xff) << 16) | |
Darren Etheridge | db2b4bd | 2013-06-21 13:52:24 -0500 | [diff] [blame] | 353 | (((vsw-1) & 0x3f) << 10); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 354 | tilcdc_write(dev, LCDC_RASTER_TIMING_1_REG, reg); |
| 355 | |
Darren Etheridge | 6bf02c6 | 2013-06-21 13:52:22 -0500 | [diff] [blame] | 356 | /* |
| 357 | * be sure to set Bit 10 for the V2 LCDC controller, |
| 358 | * otherwise limited to 1024 pixels width, stopping |
| 359 | * 1920x1080 being suppoted. |
| 360 | */ |
| 361 | if (priv->rev == 2) { |
| 362 | if ((mode->vdisplay - 1) & 0x400) { |
| 363 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, |
| 364 | LCDC_LPP_B10); |
| 365 | } else { |
| 366 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, |
| 367 | LCDC_LPP_B10); |
| 368 | } |
| 369 | } |
| 370 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 371 | /* Configure display type: */ |
| 372 | reg = tilcdc_read(dev, LCDC_RASTER_CTRL_REG) & |
| 373 | ~(LCDC_TFT_MODE | LCDC_MONO_8BIT_MODE | LCDC_MONOCHROME_MODE | |
| 374 | LCDC_V2_TFT_24BPP_MODE | LCDC_V2_TFT_24BPP_UNPACK | 0x000ff000); |
| 375 | reg |= LCDC_TFT_MODE; /* no monochrome/passive support */ |
| 376 | if (info->tft_alt_mode) |
| 377 | reg |= LCDC_TFT_ALT_ENABLE; |
| 378 | if (priv->rev == 2) { |
| 379 | unsigned int depth, bpp; |
| 380 | |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 381 | drm_fb_get_bpp_depth(crtc->primary->fb->pixel_format, &depth, &bpp); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 382 | switch (bpp) { |
| 383 | case 16: |
| 384 | break; |
| 385 | case 32: |
| 386 | reg |= LCDC_V2_TFT_24BPP_UNPACK; |
| 387 | /* fallthrough */ |
| 388 | case 24: |
| 389 | reg |= LCDC_V2_TFT_24BPP_MODE; |
| 390 | break; |
| 391 | default: |
| 392 | dev_err(dev->dev, "invalid pixel format\n"); |
| 393 | return -EINVAL; |
| 394 | } |
| 395 | } |
| 396 | reg |= info->fdd < 12; |
| 397 | tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg); |
| 398 | |
| 399 | if (info->invert_pxl_clk) |
| 400 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK); |
| 401 | else |
| 402 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK); |
| 403 | |
| 404 | if (info->sync_ctrl) |
| 405 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL); |
| 406 | else |
| 407 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL); |
| 408 | |
| 409 | if (info->sync_edge) |
| 410 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE); |
| 411 | else |
| 412 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE); |
| 413 | |
Darren Etheridge | a976718 | 2013-08-14 21:43:33 +0200 | [diff] [blame] | 414 | /* |
| 415 | * use value from adjusted_mode here as this might have been |
| 416 | * changed as part of the fixup for slave encoders to solve the |
| 417 | * issue where tilcdc timings are not VESA compliant |
| 418 | */ |
| 419 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 420 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_HSYNC); |
| 421 | else |
| 422 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_HSYNC); |
| 423 | |
| 424 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
| 425 | tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_VSYNC); |
| 426 | else |
| 427 | tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_VSYNC); |
| 428 | |
| 429 | if (info->raster_order) |
| 430 | tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ORDER); |
| 431 | else |
| 432 | tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ORDER); |
| 433 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 434 | drm_framebuffer_reference(crtc->primary->fb); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 435 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 436 | set_scanout(crtc, crtc->primary->fb); |
| 437 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 438 | tilcdc_crtc_update_clk(crtc); |
| 439 | |
| 440 | pm_runtime_put_sync(dev->dev); |
| 441 | |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | static int tilcdc_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, |
| 446 | struct drm_framebuffer *old_fb) |
| 447 | { |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 448 | struct drm_device *dev = crtc->dev; |
Tomi Valkeinen | 6f206e9 | 2014-02-07 17:37:07 +0000 | [diff] [blame] | 449 | int r; |
| 450 | |
| 451 | r = tilcdc_verify_fb(crtc, crtc->primary->fb); |
| 452 | if (r) |
| 453 | return r; |
| 454 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 455 | drm_framebuffer_reference(crtc->primary->fb); |
| 456 | |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 457 | pm_runtime_get_sync(dev->dev); |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 458 | |
| 459 | set_scanout(crtc, crtc->primary->fb); |
| 460 | |
Tomi Valkeinen | 65734a2 | 2015-10-19 12:30:03 +0300 | [diff] [blame] | 461 | pm_runtime_put_sync(dev->dev); |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 462 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 463 | return 0; |
| 464 | } |
| 465 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 466 | static const struct drm_crtc_funcs tilcdc_crtc_funcs = { |
| 467 | .destroy = tilcdc_crtc_destroy, |
| 468 | .set_config = drm_crtc_helper_set_config, |
| 469 | .page_flip = tilcdc_crtc_page_flip, |
| 470 | }; |
| 471 | |
| 472 | static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = { |
| 473 | .dpms = tilcdc_crtc_dpms, |
| 474 | .mode_fixup = tilcdc_crtc_mode_fixup, |
| 475 | .prepare = tilcdc_crtc_prepare, |
| 476 | .commit = tilcdc_crtc_commit, |
| 477 | .mode_set = tilcdc_crtc_mode_set, |
| 478 | .mode_set_base = tilcdc_crtc_mode_set_base, |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 479 | }; |
| 480 | |
| 481 | int tilcdc_crtc_max_width(struct drm_crtc *crtc) |
| 482 | { |
| 483 | struct drm_device *dev = crtc->dev; |
| 484 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 485 | int max_width = 0; |
| 486 | |
| 487 | if (priv->rev == 1) |
| 488 | max_width = 1024; |
| 489 | else if (priv->rev == 2) |
| 490 | max_width = 2048; |
| 491 | |
| 492 | return max_width; |
| 493 | } |
| 494 | |
| 495 | int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode) |
| 496 | { |
| 497 | struct tilcdc_drm_private *priv = crtc->dev->dev_private; |
| 498 | unsigned int bandwidth; |
Darren Etheridge | e1c5d0a | 2013-06-21 13:52:25 -0500 | [diff] [blame] | 499 | uint32_t hbp, hfp, hsw, vbp, vfp, vsw; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 500 | |
Darren Etheridge | e1c5d0a | 2013-06-21 13:52:25 -0500 | [diff] [blame] | 501 | /* |
| 502 | * check to see if the width is within the range that |
| 503 | * the LCD Controller physically supports |
| 504 | */ |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 505 | if (mode->hdisplay > tilcdc_crtc_max_width(crtc)) |
| 506 | return MODE_VIRTUAL_X; |
| 507 | |
| 508 | /* width must be multiple of 16 */ |
| 509 | if (mode->hdisplay & 0xf) |
| 510 | return MODE_VIRTUAL_X; |
| 511 | |
| 512 | if (mode->vdisplay > 2048) |
| 513 | return MODE_VIRTUAL_Y; |
| 514 | |
Darren Etheridge | e1c5d0a | 2013-06-21 13:52:25 -0500 | [diff] [blame] | 515 | DBG("Processing mode %dx%d@%d with pixel clock %d", |
| 516 | mode->hdisplay, mode->vdisplay, |
| 517 | drm_mode_vrefresh(mode), mode->clock); |
| 518 | |
| 519 | hbp = mode->htotal - mode->hsync_end; |
| 520 | hfp = mode->hsync_start - mode->hdisplay; |
| 521 | hsw = mode->hsync_end - mode->hsync_start; |
| 522 | vbp = mode->vtotal - mode->vsync_end; |
| 523 | vfp = mode->vsync_start - mode->vdisplay; |
| 524 | vsw = mode->vsync_end - mode->vsync_start; |
| 525 | |
| 526 | if ((hbp-1) & ~0x3ff) { |
| 527 | DBG("Pruning mode: Horizontal Back Porch out of range"); |
| 528 | return MODE_HBLANK_WIDE; |
| 529 | } |
| 530 | |
| 531 | if ((hfp-1) & ~0x3ff) { |
| 532 | DBG("Pruning mode: Horizontal Front Porch out of range"); |
| 533 | return MODE_HBLANK_WIDE; |
| 534 | } |
| 535 | |
| 536 | if ((hsw-1) & ~0x3ff) { |
| 537 | DBG("Pruning mode: Horizontal Sync Width out of range"); |
| 538 | return MODE_HSYNC_WIDE; |
| 539 | } |
| 540 | |
| 541 | if (vbp & ~0xff) { |
| 542 | DBG("Pruning mode: Vertical Back Porch out of range"); |
| 543 | return MODE_VBLANK_WIDE; |
| 544 | } |
| 545 | |
| 546 | if (vfp & ~0xff) { |
| 547 | DBG("Pruning mode: Vertical Front Porch out of range"); |
| 548 | return MODE_VBLANK_WIDE; |
| 549 | } |
| 550 | |
| 551 | if ((vsw-1) & ~0x3f) { |
| 552 | DBG("Pruning mode: Vertical Sync Width out of range"); |
| 553 | return MODE_VSYNC_WIDE; |
| 554 | } |
| 555 | |
Darren Etheridge | 4e56434 | 2013-06-21 13:52:23 -0500 | [diff] [blame] | 556 | /* |
| 557 | * some devices have a maximum allowed pixel clock |
| 558 | * configured from the DT |
| 559 | */ |
| 560 | if (mode->clock > priv->max_pixelclock) { |
Darren Etheridge | f7b4575 | 2013-06-21 13:52:26 -0500 | [diff] [blame] | 561 | DBG("Pruning mode: pixel clock too high"); |
Darren Etheridge | 4e56434 | 2013-06-21 13:52:23 -0500 | [diff] [blame] | 562 | return MODE_CLOCK_HIGH; |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | * some devices further limit the max horizontal resolution |
| 567 | * configured from the DT |
| 568 | */ |
| 569 | if (mode->hdisplay > priv->max_width) |
| 570 | return MODE_BAD_WIDTH; |
| 571 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 572 | /* filter out modes that would require too much memory bandwidth: */ |
Darren Etheridge | 4e56434 | 2013-06-21 13:52:23 -0500 | [diff] [blame] | 573 | bandwidth = mode->hdisplay * mode->vdisplay * |
| 574 | drm_mode_vrefresh(mode); |
| 575 | if (bandwidth > priv->max_bandwidth) { |
Darren Etheridge | f7b4575 | 2013-06-21 13:52:26 -0500 | [diff] [blame] | 576 | DBG("Pruning mode: exceeds defined bandwidth limit"); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 577 | return MODE_BAD; |
Darren Etheridge | 4e56434 | 2013-06-21 13:52:23 -0500 | [diff] [blame] | 578 | } |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 579 | |
| 580 | return MODE_OK; |
| 581 | } |
| 582 | |
| 583 | void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc, |
| 584 | const struct tilcdc_panel_info *info) |
| 585 | { |
| 586 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 587 | tilcdc_crtc->info = info; |
| 588 | } |
| 589 | |
Jyri Sarha | 103cd8b | 2015-02-10 14:13:23 +0200 | [diff] [blame] | 590 | void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc, |
| 591 | bool simulate_vesa_sync) |
| 592 | { |
| 593 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 594 | |
| 595 | tilcdc_crtc->simulate_vesa_sync = simulate_vesa_sync; |
| 596 | } |
| 597 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 598 | void tilcdc_crtc_update_clk(struct drm_crtc *crtc) |
| 599 | { |
| 600 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 601 | struct drm_device *dev = crtc->dev; |
| 602 | struct tilcdc_drm_private *priv = dev->dev_private; |
| 603 | int dpms = tilcdc_crtc->dpms; |
Darren Etheridge | 3d19306 | 2014-01-15 15:52:36 -0600 | [diff] [blame] | 604 | unsigned long lcd_clk; |
| 605 | const unsigned clkdiv = 2; /* using a fixed divider of 2 */ |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 606 | int ret; |
| 607 | |
| 608 | pm_runtime_get_sync(dev->dev); |
| 609 | |
| 610 | if (dpms == DRM_MODE_DPMS_ON) |
| 611 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
| 612 | |
Darren Etheridge | 3d19306 | 2014-01-15 15:52:36 -0600 | [diff] [blame] | 613 | /* mode.clock is in KHz, set_rate wants parameter in Hz */ |
| 614 | ret = clk_set_rate(priv->clk, crtc->mode.clock * 1000 * clkdiv); |
| 615 | if (ret < 0) { |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 616 | dev_err(dev->dev, "failed to set display clock rate to: %d\n", |
| 617 | crtc->mode.clock); |
| 618 | goto out; |
| 619 | } |
| 620 | |
| 621 | lcd_clk = clk_get_rate(priv->clk); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 622 | |
Darren Etheridge | 3d19306 | 2014-01-15 15:52:36 -0600 | [diff] [blame] | 623 | DBG("lcd_clk=%lu, mode clock=%d, div=%u", |
| 624 | lcd_clk, crtc->mode.clock, clkdiv); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 625 | |
| 626 | /* Configure the LCD clock divisor. */ |
Darren Etheridge | 3d19306 | 2014-01-15 15:52:36 -0600 | [diff] [blame] | 627 | tilcdc_write(dev, LCDC_CTRL_REG, LCDC_CLK_DIVISOR(clkdiv) | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 628 | LCDC_RASTER_MODE); |
| 629 | |
| 630 | if (priv->rev == 2) |
| 631 | tilcdc_set(dev, LCDC_CLK_ENABLE_REG, |
| 632 | LCDC_V2_DMA_CLK_EN | LCDC_V2_LIDD_CLK_EN | |
| 633 | LCDC_V2_CORE_CLK_EN); |
| 634 | |
| 635 | if (dpms == DRM_MODE_DPMS_ON) |
| 636 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_ON); |
| 637 | |
| 638 | out: |
| 639 | pm_runtime_put_sync(dev->dev); |
| 640 | } |
| 641 | |
| 642 | irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc) |
| 643 | { |
| 644 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
| 645 | struct drm_device *dev = crtc->dev; |
| 646 | struct tilcdc_drm_private *priv = dev->dev_private; |
Tomi Valkeinen | 317aae7 | 2015-10-20 12:08:03 +0300 | [diff] [blame] | 647 | uint32_t stat; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 648 | |
Tomi Valkeinen | 317aae7 | 2015-10-20 12:08:03 +0300 | [diff] [blame] | 649 | stat = tilcdc_read_irqstatus(dev); |
| 650 | tilcdc_clear_irqstatus(dev, stat); |
| 651 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 652 | if (stat & LCDC_END_OF_FRAME0) { |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 653 | unsigned long flags; |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 654 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 655 | drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 656 | |
| 657 | drm_handle_vblank(dev, 0); |
| 658 | |
| 659 | spin_lock_irqsave(&dev->event_lock, flags); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 660 | |
Tomi Valkeinen | 2b2080d | 2015-10-20 09:37:27 +0300 | [diff] [blame^] | 661 | if (tilcdc_crtc->event) { |
| 662 | drm_send_vblank_event(dev, 0, tilcdc_crtc->event); |
| 663 | tilcdc_crtc->event = NULL; |
| 664 | } |
| 665 | |
| 666 | spin_unlock_irqrestore(&dev->event_lock, flags); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | if (priv->rev == 2) { |
| 670 | if (stat & LCDC_FRAME_DONE) { |
| 671 | tilcdc_crtc->frame_done = true; |
| 672 | wake_up(&tilcdc_crtc->frame_done_wq); |
| 673 | } |
| 674 | tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0); |
| 675 | } |
| 676 | |
| 677 | return IRQ_HANDLED; |
| 678 | } |
| 679 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 680 | struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev) |
| 681 | { |
| 682 | struct tilcdc_crtc *tilcdc_crtc; |
| 683 | struct drm_crtc *crtc; |
| 684 | int ret; |
| 685 | |
| 686 | tilcdc_crtc = kzalloc(sizeof(*tilcdc_crtc), GFP_KERNEL); |
| 687 | if (!tilcdc_crtc) { |
| 688 | dev_err(dev->dev, "allocation failed\n"); |
| 689 | return NULL; |
| 690 | } |
| 691 | |
| 692 | crtc = &tilcdc_crtc->base; |
| 693 | |
| 694 | tilcdc_crtc->dpms = DRM_MODE_DPMS_OFF; |
| 695 | init_waitqueue_head(&tilcdc_crtc->frame_done_wq); |
| 696 | |
Boris BREZILLON | d7f8db5 | 2014-11-14 19:30:30 +0100 | [diff] [blame] | 697 | drm_flip_work_init(&tilcdc_crtc->unref_work, |
Rob Clark | a464d61 | 2013-08-07 13:41:20 -0400 | [diff] [blame] | 698 | "unref", unref_worker); |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 699 | |
Rob Clark | 16ea975 | 2013-01-08 15:04:28 -0600 | [diff] [blame] | 700 | ret = drm_crtc_init(dev, crtc, &tilcdc_crtc_funcs); |
| 701 | if (ret < 0) |
| 702 | goto fail; |
| 703 | |
| 704 | drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs); |
| 705 | |
| 706 | return crtc; |
| 707 | |
| 708 | fail: |
| 709 | tilcdc_crtc_destroy(crtc); |
| 710 | return NULL; |
| 711 | } |