Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux

Pull Exynos DRM changes from Dave Airlie:
"So I totally missed Inki's pull request for -next, its fully exynos
self contained."

(I took just the actual commits, not Dave's two extraneous merges)

* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (30 commits)
drm/exynos: fixed exception to page allocation failure
drm/exynos: use __free_page() to deallocate memory
drm/exynos: fixed a comment to gem size.
drm/exynos: removed unnecessary variable
drm/exynos: do not release memory region from exporter.
drm/exynos: set buffer type from exporter.
drm/exynos: use alloc_page() to allocate pages.
drm/exynos: fixed build warning.
drm/exynos: fixed edid data setting at vidi connection request
drm/exynos: check if raw edid data is fake or not for test
drm/exynos: set edid fake data only for test.
drm/exynos: removed unnecessary declaration.
drm/exynos: fix buffer pitch calculation
drm/exynos: check for null in return value of dma_buf_map_attachment()
drm/exynos: return NULL if exynos_pages_to_sg fails
drm/exynos: Use devm_* functions in exynos_mixer.c
drm/exynos: Use devm_* functions in exynos_hdmi.c
drm/exynos: Use devm_* functions in exynos_drm_fimd.c
drm/exynos: Add missing static storage class specifier
drm/exynos: add property for crtc mode
...

+503 -527
+2 -1
drivers/gpu/drm/exynos/exynos_drm_connector.c
··· 196 196 return ret; 197 197 } 198 198 199 - struct drm_encoder *exynos_drm_best_encoder(struct drm_connector *connector) 199 + static struct drm_encoder *exynos_drm_best_encoder( 200 + struct drm_connector *connector) 200 201 { 201 202 struct drm_device *dev = connector->dev; 202 203 struct exynos_drm_connector *exynos_connector =
-5
drivers/gpu/drm/exynos/exynos_drm_core.c
··· 33 33 #include "exynos_drm_fbdev.h" 34 34 35 35 static LIST_HEAD(exynos_drm_subdrv_list); 36 - static struct drm_device *drm_dev; 37 36 38 37 static int exynos_drm_subdrv_probe(struct drm_device *dev, 39 38 struct exynos_drm_subdrv *subdrv) ··· 119 120 if (!dev) 120 121 return -EINVAL; 121 122 122 - drm_dev = dev; 123 - 124 123 list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) { 125 124 subdrv->drm_dev = dev; 126 125 err = exynos_drm_subdrv_probe(dev, subdrv); ··· 145 148 146 149 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) 147 150 exynos_drm_subdrv_remove(dev, subdrv); 148 - 149 - drm_dev = NULL; 150 151 151 152 return 0; 152 153 }
+129 -167
drivers/gpu/drm/exynos/exynos_drm_crtc.c
··· 29 29 #include "drmP.h" 30 30 #include "drm_crtc_helper.h" 31 31 32 - #include "exynos_drm_crtc.h" 33 32 #include "exynos_drm_drv.h" 34 - #include "exynos_drm_fb.h" 35 33 #include "exynos_drm_encoder.h" 36 - #include "exynos_drm_gem.h" 34 + #include "exynos_drm_plane.h" 37 35 38 36 #define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ 39 37 drm_crtc) 38 + 39 + enum exynos_crtc_mode { 40 + CRTC_MODE_NORMAL, /* normal mode */ 41 + CRTC_MODE_BLANK, /* The private plane of crtc is blank */ 42 + }; 40 43 41 44 /* 42 45 * Exynos specific crtc structure. 43 46 * 44 47 * @drm_crtc: crtc object. 45 - * @overlay: contain information common to display controller and hdmi and 46 - * contents of this overlay object would be copied to sub driver size. 48 + * @drm_plane: pointer of private plane object for this crtc 47 49 * @pipe: a crtc index created at load() with a new crtc object creation 48 50 * and the crtc object would be set to private->crtc array 49 51 * to get a crtc object corresponding to this pipe from private->crtc ··· 54 52 * we can refer to the crtc to current hardware interrupt occured through 55 53 * this pipe value. 56 54 * @dpms: store the crtc dpms value 55 + * @mode: store the crtc mode value 57 56 */ 58 57 struct exynos_drm_crtc { 59 58 struct drm_crtc drm_crtc; 60 - struct exynos_drm_overlay overlay; 59 + struct drm_plane *plane; 61 60 unsigned int pipe; 62 61 unsigned int dpms; 62 + enum exynos_crtc_mode mode; 63 63 }; 64 - 65 - static void exynos_drm_crtc_apply(struct drm_crtc *crtc) 66 - { 67 - struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 68 - struct exynos_drm_overlay *overlay = &exynos_crtc->overlay; 69 - 70 - exynos_drm_fn_encoder(crtc, overlay, 71 - exynos_drm_encoder_crtc_mode_set); 72 - exynos_drm_fn_encoder(crtc, &exynos_crtc->pipe, 73 - exynos_drm_encoder_crtc_commit); 74 - } 75 - 76 - int exynos_drm_overlay_update(struct exynos_drm_overlay *overlay, 77 - struct drm_framebuffer *fb, 78 - struct drm_display_mode *mode, 79 - struct exynos_drm_crtc_pos *pos) 80 - { 81 - struct exynos_drm_gem_buf *buffer; 82 - unsigned int actual_w; 83 - unsigned int actual_h; 84 - int nr = exynos_drm_format_num_buffers(fb->pixel_format); 85 - int i; 86 - 87 - for (i = 0; i < nr; i++) { 88 - buffer = exynos_drm_fb_buffer(fb, i); 89 - if (!buffer) { 90 - DRM_LOG_KMS("buffer is null\n"); 91 - return -EFAULT; 92 - } 93 - 94 - overlay->dma_addr[i] = buffer->dma_addr; 95 - overlay->vaddr[i] = buffer->kvaddr; 96 - 97 - DRM_DEBUG_KMS("buffer: %d, vaddr = 0x%lx, dma_addr = 0x%lx\n", 98 - i, (unsigned long)overlay->vaddr[i], 99 - (unsigned long)overlay->dma_addr[i]); 100 - } 101 - 102 - actual_w = min((mode->hdisplay - pos->crtc_x), pos->crtc_w); 103 - actual_h = min((mode->vdisplay - pos->crtc_y), pos->crtc_h); 104 - 105 - /* set drm framebuffer data. */ 106 - overlay->fb_x = pos->fb_x; 107 - overlay->fb_y = pos->fb_y; 108 - overlay->fb_width = fb->width; 109 - overlay->fb_height = fb->height; 110 - overlay->src_width = pos->src_w; 111 - overlay->src_height = pos->src_h; 112 - overlay->bpp = fb->bits_per_pixel; 113 - overlay->pitch = fb->pitches[0]; 114 - overlay->pixel_format = fb->pixel_format; 115 - 116 - /* set overlay range to be displayed. */ 117 - overlay->crtc_x = pos->crtc_x; 118 - overlay->crtc_y = pos->crtc_y; 119 - overlay->crtc_width = actual_w; 120 - overlay->crtc_height = actual_h; 121 - 122 - /* set drm mode data. */ 123 - overlay->mode_width = mode->hdisplay; 124 - overlay->mode_height = mode->vdisplay; 125 - overlay->refresh = mode->vrefresh; 126 - overlay->scan_flag = mode->flags; 127 - 128 - DRM_DEBUG_KMS("overlay : offset_x/y(%d,%d), width/height(%d,%d)", 129 - overlay->crtc_x, overlay->crtc_y, 130 - overlay->crtc_width, overlay->crtc_height); 131 - 132 - return 0; 133 - } 134 - 135 - static int exynos_drm_crtc_update(struct drm_crtc *crtc) 136 - { 137 - struct exynos_drm_crtc *exynos_crtc; 138 - struct exynos_drm_overlay *overlay; 139 - struct exynos_drm_crtc_pos pos; 140 - struct drm_display_mode *mode = &crtc->mode; 141 - struct drm_framebuffer *fb = crtc->fb; 142 - 143 - if (!mode || !fb) 144 - return -EINVAL; 145 - 146 - exynos_crtc = to_exynos_crtc(crtc); 147 - overlay = &exynos_crtc->overlay; 148 - 149 - memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos)); 150 - 151 - /* it means the offset of framebuffer to be displayed. */ 152 - pos.fb_x = crtc->x; 153 - pos.fb_y = crtc->y; 154 - 155 - /* OSD position to be displayed. */ 156 - pos.crtc_x = 0; 157 - pos.crtc_y = 0; 158 - pos.crtc_w = fb->width - crtc->x; 159 - pos.crtc_h = fb->height - crtc->y; 160 - pos.src_w = pos.crtc_w; 161 - pos.src_h = pos.crtc_h; 162 - 163 - return exynos_drm_overlay_update(overlay, crtc->fb, mode, &pos); 164 - } 165 64 166 65 static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) 167 66 { ··· 78 175 79 176 mutex_lock(&dev->struct_mutex); 80 177 81 - switch (mode) { 82 - case DRM_MODE_DPMS_ON: 83 - exynos_drm_fn_encoder(crtc, &mode, 84 - exynos_drm_encoder_crtc_dpms); 85 - exynos_crtc->dpms = mode; 86 - break; 87 - case DRM_MODE_DPMS_STANDBY: 88 - case DRM_MODE_DPMS_SUSPEND: 89 - case DRM_MODE_DPMS_OFF: 90 - exynos_drm_fn_encoder(crtc, &mode, 91 - exynos_drm_encoder_crtc_dpms); 92 - exynos_crtc->dpms = mode; 93 - break; 94 - default: 95 - DRM_ERROR("unspecified mode %d\n", mode); 96 - break; 97 - } 178 + exynos_drm_fn_encoder(crtc, &mode, exynos_drm_encoder_crtc_dpms); 179 + exynos_crtc->dpms = mode; 98 180 99 181 mutex_unlock(&dev->struct_mutex); 100 182 } ··· 97 209 98 210 DRM_DEBUG_KMS("%s\n", __FILE__); 99 211 100 - /* 101 - * when set_crtc is requested from user or at booting time, 102 - * crtc->commit would be called without dpms call so if dpms is 103 - * no power on then crtc->dpms should be called 104 - * with DRM_MODE_DPMS_ON for the hardware power to be on. 105 - */ 106 - if (exynos_crtc->dpms != DRM_MODE_DPMS_ON) { 107 - int mode = DRM_MODE_DPMS_ON; 108 - 109 - /* 110 - * enable hardware(power on) to all encoders hdmi connected 111 - * to current crtc. 112 - */ 113 - exynos_drm_crtc_dpms(crtc, mode); 114 - /* 115 - * enable dma to all encoders connected to current crtc and 116 - * lcd panel. 117 - */ 118 - exynos_drm_fn_encoder(crtc, &mode, 119 - exynos_drm_encoder_dpms_from_crtc); 120 - } 121 - 122 - exynos_drm_fn_encoder(crtc, &exynos_crtc->pipe, 123 - exynos_drm_encoder_crtc_commit); 212 + exynos_plane_commit(exynos_crtc->plane); 213 + exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON); 124 214 } 125 215 126 216 static bool ··· 117 251 struct drm_display_mode *adjusted_mode, int x, int y, 118 252 struct drm_framebuffer *old_fb) 119 253 { 254 + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 255 + struct drm_plane *plane = exynos_crtc->plane; 256 + unsigned int crtc_w; 257 + unsigned int crtc_h; 258 + int pipe = exynos_crtc->pipe; 259 + int ret; 260 + 120 261 DRM_DEBUG_KMS("%s\n", __FILE__); 262 + 263 + exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON); 121 264 122 265 /* 123 266 * copy the mode data adjusted by mode_fixup() into crtc->mode ··· 134 259 */ 135 260 memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode)); 136 261 137 - return exynos_drm_crtc_update(crtc); 262 + crtc_w = crtc->fb->width - x; 263 + crtc_h = crtc->fb->height - y; 264 + 265 + ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h, 266 + x, y, crtc_w, crtc_h); 267 + if (ret) 268 + return ret; 269 + 270 + plane->crtc = crtc; 271 + plane->fb = crtc->fb; 272 + 273 + exynos_drm_fn_encoder(crtc, &pipe, exynos_drm_encoder_crtc_pipe); 274 + 275 + return 0; 138 276 } 139 277 140 278 static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, 141 279 struct drm_framebuffer *old_fb) 142 280 { 281 + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 282 + struct drm_plane *plane = exynos_crtc->plane; 283 + unsigned int crtc_w; 284 + unsigned int crtc_h; 143 285 int ret; 144 286 145 287 DRM_DEBUG_KMS("%s\n", __FILE__); 146 288 147 - ret = exynos_drm_crtc_update(crtc); 289 + crtc_w = crtc->fb->width - x; 290 + crtc_h = crtc->fb->height - y; 291 + 292 + ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h, 293 + x, y, crtc_w, crtc_h); 148 294 if (ret) 149 295 return ret; 150 296 151 - exynos_drm_crtc_apply(crtc); 297 + exynos_drm_crtc_commit(crtc); 152 298 153 - return ret; 299 + return 0; 154 300 } 155 301 156 302 static void exynos_drm_crtc_load_lut(struct drm_crtc *crtc) 157 303 { 158 304 DRM_DEBUG_KMS("%s\n", __FILE__); 159 305 /* drm framework doesn't check NULL */ 306 + } 307 + 308 + static void exynos_drm_crtc_disable(struct drm_crtc *crtc) 309 + { 310 + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 311 + 312 + DRM_DEBUG_KMS("%s\n", __FILE__); 313 + 314 + exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_OFF); 315 + exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); 160 316 } 161 317 162 318 static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = { ··· 198 292 .mode_set = exynos_drm_crtc_mode_set, 199 293 .mode_set_base = exynos_drm_crtc_mode_set_base, 200 294 .load_lut = exynos_drm_crtc_load_lut, 295 + .disable = exynos_drm_crtc_disable, 201 296 }; 202 297 203 298 static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, ··· 234 327 &dev_priv->pageflip_event_list); 235 328 236 329 crtc->fb = fb; 237 - ret = exynos_drm_crtc_update(crtc); 330 + ret = exynos_drm_crtc_mode_set_base(crtc, crtc->x, crtc->y, 331 + NULL); 238 332 if (ret) { 239 333 crtc->fb = old_fb; 240 334 drm_vblank_put(dev, exynos_crtc->pipe); ··· 243 335 244 336 goto out; 245 337 } 246 - 247 - /* 248 - * the values related to a buffer of the drm framebuffer 249 - * to be applied should be set at here. because these values 250 - * first, are set to shadow registers and then to 251 - * real registers at vsync front porch period. 252 - */ 253 - exynos_drm_crtc_apply(crtc); 254 338 } 255 339 out: 256 340 mutex_unlock(&dev->struct_mutex); ··· 262 362 kfree(exynos_crtc); 263 363 } 264 364 365 + static int exynos_drm_crtc_set_property(struct drm_crtc *crtc, 366 + struct drm_property *property, 367 + uint64_t val) 368 + { 369 + struct drm_device *dev = crtc->dev; 370 + struct exynos_drm_private *dev_priv = dev->dev_private; 371 + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 372 + 373 + DRM_DEBUG_KMS("%s\n", __func__); 374 + 375 + if (property == dev_priv->crtc_mode_property) { 376 + enum exynos_crtc_mode mode = val; 377 + 378 + if (mode == exynos_crtc->mode) 379 + return 0; 380 + 381 + exynos_crtc->mode = mode; 382 + 383 + switch (mode) { 384 + case CRTC_MODE_NORMAL: 385 + exynos_drm_crtc_commit(crtc); 386 + break; 387 + case CRTC_MODE_BLANK: 388 + exynos_plane_dpms(exynos_crtc->plane, 389 + DRM_MODE_DPMS_OFF); 390 + break; 391 + default: 392 + break; 393 + } 394 + 395 + return 0; 396 + } 397 + 398 + return -EINVAL; 399 + } 400 + 265 401 static struct drm_crtc_funcs exynos_crtc_funcs = { 266 402 .set_config = drm_crtc_helper_set_config, 267 403 .page_flip = exynos_drm_crtc_page_flip, 268 404 .destroy = exynos_drm_crtc_destroy, 405 + .set_property = exynos_drm_crtc_set_property, 269 406 }; 270 407 271 - struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev, 272 - struct drm_crtc *crtc) 273 - { 274 - struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 408 + static const struct drm_prop_enum_list mode_names[] = { 409 + { CRTC_MODE_NORMAL, "normal" }, 410 + { CRTC_MODE_BLANK, "blank" }, 411 + }; 275 412 276 - return &exynos_crtc->overlay; 413 + static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc) 414 + { 415 + struct drm_device *dev = crtc->dev; 416 + struct exynos_drm_private *dev_priv = dev->dev_private; 417 + struct drm_property *prop; 418 + 419 + DRM_DEBUG_KMS("%s\n", __func__); 420 + 421 + prop = dev_priv->crtc_mode_property; 422 + if (!prop) { 423 + prop = drm_property_create_enum(dev, 0, "mode", mode_names, 424 + ARRAY_SIZE(mode_names)); 425 + if (!prop) 426 + return; 427 + 428 + dev_priv->crtc_mode_property = prop; 429 + } 430 + 431 + drm_object_attach_property(&crtc->base, prop, 0); 277 432 } 278 433 279 434 int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr) ··· 347 392 348 393 exynos_crtc->pipe = nr; 349 394 exynos_crtc->dpms = DRM_MODE_DPMS_OFF; 350 - exynos_crtc->overlay.zpos = DEFAULT_ZPOS; 395 + exynos_crtc->plane = exynos_plane_init(dev, 1 << nr, true); 396 + if (!exynos_crtc->plane) { 397 + kfree(exynos_crtc); 398 + return -ENOMEM; 399 + } 400 + 351 401 crtc = &exynos_crtc->drm_crtc; 352 402 353 403 private->crtc[nr] = crtc; 354 404 355 405 drm_crtc_init(dev, crtc, &exynos_crtc_funcs); 356 406 drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs); 407 + 408 + exynos_drm_crtc_attach_mode_property(crtc); 357 409 358 410 return 0; 359 411 }
-31
drivers/gpu/drm/exynos/exynos_drm_crtc.h
··· 29 29 #ifndef _EXYNOS_DRM_CRTC_H_ 30 30 #define _EXYNOS_DRM_CRTC_H_ 31 31 32 - struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev, 33 - struct drm_crtc *crtc); 34 32 int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr); 35 33 int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int crtc); 36 34 void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int crtc); 37 35 38 - /* 39 - * Exynos specific crtc postion structure. 40 - * 41 - * @fb_x: offset x on a framebuffer to be displyed 42 - * - the unit is screen coordinates. 43 - * @fb_y: offset y on a framebuffer to be displayed 44 - * - the unit is screen coordinates. 45 - * @src_w: width of source area to be displayed from a framebuffer. 46 - * @src_h: height of source area to be displayed from a framebuffer. 47 - * @crtc_x: offset x on hardware screen. 48 - * @crtc_y: offset y on hardware screen. 49 - * @crtc_w: width of hardware screen. 50 - * @crtc_h: height of hardware screen. 51 - */ 52 - struct exynos_drm_crtc_pos { 53 - unsigned int fb_x; 54 - unsigned int fb_y; 55 - unsigned int src_w; 56 - unsigned int src_h; 57 - unsigned int crtc_x; 58 - unsigned int crtc_y; 59 - unsigned int crtc_w; 60 - unsigned int crtc_h; 61 - }; 62 - 63 - int exynos_drm_overlay_update(struct exynos_drm_overlay *overlay, 64 - struct drm_framebuffer *fb, 65 - struct drm_display_mode *mode, 66 - struct exynos_drm_crtc_pos *pos); 67 36 #endif
+25 -8
drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
··· 25 25 26 26 #include "drmP.h" 27 27 #include "drm.h" 28 + #include "exynos_drm.h" 28 29 #include "exynos_drm_drv.h" 29 30 #include "exynos_drm_gem.h" 30 31 ··· 87 86 npages = buf->size / buf->page_size; 88 87 89 88 sgt = exynos_pages_to_sg(buf->pages, npages, buf->page_size); 89 + if (!sgt) { 90 + DRM_DEBUG_PRIME("exynos_pages_to_sg returned NULL!\n"); 91 + goto err_unlock; 92 + } 90 93 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir); 91 94 92 95 DRM_DEBUG_PRIME("npages = %d buffer size = 0x%lx page_size = 0x%lx\n", ··· 191 186 struct exynos_drm_gem_obj *exynos_gem_obj; 192 187 struct exynos_drm_gem_buf *buffer; 193 188 struct page *page; 194 - int ret, i = 0; 189 + int ret; 195 190 196 191 DRM_DEBUG_PRIME("%s\n", __FILE__); 197 192 ··· 215 210 216 211 217 212 sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); 218 - if (IS_ERR(sgt)) { 213 + if (IS_ERR_OR_NULL(sgt)) { 219 214 ret = PTR_ERR(sgt); 220 215 goto err_buf_detach; 221 216 } ··· 241 236 } 242 237 243 238 sgl = sgt->sgl; 244 - buffer->dma_addr = sg_dma_address(sgl); 245 239 246 - while (i < sgt->nents) { 247 - buffer->pages[i] = sg_page(sgl); 248 - buffer->size += sg_dma_len(sgl); 249 - sgl = sg_next(sgl); 250 - i++; 240 + if (sgt->nents == 1) { 241 + buffer->dma_addr = sg_dma_address(sgt->sgl); 242 + buffer->size = sg_dma_len(sgt->sgl); 243 + 244 + /* always physically continuous memory if sgt->nents is 1. */ 245 + exynos_gem_obj->flags |= EXYNOS_BO_CONTIG; 246 + } else { 247 + unsigned int i = 0; 248 + 249 + buffer->dma_addr = sg_dma_address(sgl); 250 + while (i < sgt->nents) { 251 + buffer->pages[i] = sg_page(sgl); 252 + buffer->size += sg_dma_len(sgl); 253 + sgl = sg_next(sgl); 254 + i++; 255 + } 256 + 257 + exynos_gem_obj->flags |= EXYNOS_BO_NONCONTIG; 251 258 } 252 259 253 260 exynos_gem_obj->buffer = buffer;
+5 -4
drivers/gpu/drm/exynos/exynos_drm_drv.c
··· 85 85 } 86 86 87 87 for (nr = 0; nr < MAX_PLANE; nr++) { 88 - ret = exynos_plane_init(dev, nr); 89 - if (ret) 88 + struct drm_plane *plane; 89 + unsigned int possible_crtcs = (1 << MAX_CRTC) - 1; 90 + 91 + plane = exynos_plane_init(dev, possible_crtcs, false); 92 + if (!plane) 90 93 goto err_crtc; 91 94 } 92 95 ··· 224 221 exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH), 225 222 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, 226 223 exynos_drm_gem_get_ioctl, DRM_UNLOCKED), 227 - DRM_IOCTL_DEF_DRV(EXYNOS_PLANE_SET_ZPOS, exynos_plane_set_zpos_ioctl, 228 - DRM_UNLOCKED | DRM_AUTH), 229 224 DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, 230 225 vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH), 231 226 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER,
+4
drivers/gpu/drm/exynos/exynos_drm_drv.h
··· 59 59 * 60 60 * @mode_set: copy drm overlay info to hw specific overlay info. 61 61 * @commit: apply hardware specific overlay data to registers. 62 + * @enable: enable hardware specific overlay. 62 63 * @disable: disable hardware specific overlay. 63 64 */ 64 65 struct exynos_drm_overlay_ops { 65 66 void (*mode_set)(struct device *subdrv_dev, 66 67 struct exynos_drm_overlay *overlay); 67 68 void (*commit)(struct device *subdrv_dev, int zpos); 69 + void (*enable)(struct device *subdrv_dev, int zpos); 68 70 void (*disable)(struct device *subdrv_dev, int zpos); 69 71 }; 70 72 ··· 237 235 * this array is used to be aware of which crtc did it request vblank. 238 236 */ 239 237 struct drm_crtc *crtc[MAX_CRTC]; 238 + struct drm_property *plane_zpos_property; 239 + struct drm_property *crtc_mode_property; 240 240 }; 241 241 242 242 /*
+59 -72
drivers/gpu/drm/exynos/exynos_drm_encoder.c
··· 30 30 #include "drm_crtc_helper.h" 31 31 32 32 #include "exynos_drm_drv.h" 33 - #include "exynos_drm_crtc.h" 34 33 #include "exynos_drm_encoder.h" 35 34 36 35 #define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder,\ ··· 135 136 struct drm_connector *connector; 136 137 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder); 137 138 struct exynos_drm_manager_ops *manager_ops = manager->ops; 138 - struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 139 - struct exynos_drm_overlay *overlay = get_exynos_drm_overlay(dev, 140 - encoder->crtc); 141 139 142 140 DRM_DEBUG_KMS("%s\n", __FILE__); 143 141 142 + exynos_drm_encoder_dpms(encoder, DRM_MODE_DPMS_ON); 143 + 144 144 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 145 - if (connector->encoder == encoder) { 145 + if (connector->encoder == encoder) 146 146 if (manager_ops && manager_ops->mode_set) 147 147 manager_ops->mode_set(manager->dev, 148 148 adjusted_mode); 149 - 150 - if (overlay_ops && overlay_ops->mode_set) 151 - overlay_ops->mode_set(manager->dev, overlay); 152 - } 153 149 } 154 150 } 155 151 ··· 304 310 struct exynos_drm_manager_ops *manager_ops = manager->ops; 305 311 int crtc = *(int *)data; 306 312 307 - if (manager->pipe == -1) 308 - manager->pipe = crtc; 313 + if (manager->pipe != crtc) 314 + return; 309 315 310 316 if (manager_ops->enable_vblank) 311 317 manager_ops->enable_vblank(manager->dev); ··· 318 324 struct exynos_drm_manager_ops *manager_ops = manager->ops; 319 325 int crtc = *(int *)data; 320 326 321 - if (manager->pipe == -1) 322 - manager->pipe = crtc; 327 + if (manager->pipe != crtc) 328 + return; 323 329 324 330 if (manager_ops->disable_vblank) 325 331 manager_ops->disable_vblank(manager->dev); 326 332 } 327 333 328 - void exynos_drm_encoder_crtc_plane_commit(struct drm_encoder *encoder, 329 - void *data) 330 - { 331 - struct exynos_drm_manager *manager = 332 - to_exynos_encoder(encoder)->manager; 333 - struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 334 - int zpos = DEFAULT_ZPOS; 335 - 336 - if (data) 337 - zpos = *(int *)data; 338 - 339 - if (overlay_ops && overlay_ops->commit) 340 - overlay_ops->commit(manager->dev, zpos); 341 - } 342 - 343 - void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data) 344 - { 345 - struct exynos_drm_manager *manager = 346 - to_exynos_encoder(encoder)->manager; 347 - int crtc = *(int *)data; 348 - int zpos = DEFAULT_ZPOS; 349 - 350 - DRM_DEBUG_KMS("%s\n", __FILE__); 351 - 352 - /* 353 - * when crtc is detached from encoder, this pipe is used 354 - * to select manager operation 355 - */ 356 - manager->pipe = crtc; 357 - 358 - exynos_drm_encoder_crtc_plane_commit(encoder, &zpos); 359 - } 360 - 361 - void exynos_drm_encoder_dpms_from_crtc(struct drm_encoder *encoder, void *data) 362 - { 363 - struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); 364 - int mode = *(int *)data; 365 - 366 - DRM_DEBUG_KMS("%s\n", __FILE__); 367 - 368 - exynos_drm_encoder_dpms(encoder, mode); 369 - 370 - exynos_encoder->dpms = mode; 371 - } 372 - 373 334 void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data) 374 335 { 375 - struct drm_device *dev = encoder->dev; 376 336 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); 377 337 struct exynos_drm_manager *manager = exynos_encoder->manager; 378 338 struct exynos_drm_manager_ops *manager_ops = manager->ops; 379 - struct drm_connector *connector; 380 339 int mode = *(int *)data; 381 340 382 341 DRM_DEBUG_KMS("%s\n", __FILE__); 383 342 384 343 if (manager_ops && manager_ops->dpms) 385 344 manager_ops->dpms(manager->dev, mode); 386 - 387 - /* 388 - * set current dpms mode to the connector connected to 389 - * current encoder. connector->dpms would be checked 390 - * at drm_helper_connector_dpms() 391 - */ 392 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) 393 - if (connector->encoder == encoder) 394 - connector->dpms = mode; 395 345 396 346 /* 397 347 * if this condition is ok then it means that the crtc is already ··· 348 410 } 349 411 } 350 412 351 - void exynos_drm_encoder_crtc_mode_set(struct drm_encoder *encoder, void *data) 413 + void exynos_drm_encoder_crtc_pipe(struct drm_encoder *encoder, void *data) 414 + { 415 + struct exynos_drm_manager *manager = 416 + to_exynos_encoder(encoder)->manager; 417 + int pipe = *(int *)data; 418 + 419 + DRM_DEBUG_KMS("%s\n", __FILE__); 420 + 421 + /* 422 + * when crtc is detached from encoder, this pipe is used 423 + * to select manager operation 424 + */ 425 + manager->pipe = pipe; 426 + } 427 + 428 + void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data) 352 429 { 353 430 struct exynos_drm_manager *manager = 354 431 to_exynos_encoder(encoder)->manager; 355 432 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 356 433 struct exynos_drm_overlay *overlay = data; 357 434 435 + DRM_DEBUG_KMS("%s\n", __FILE__); 436 + 358 437 if (overlay_ops && overlay_ops->mode_set) 359 438 overlay_ops->mode_set(manager->dev, overlay); 360 439 } 361 440 362 - void exynos_drm_encoder_crtc_disable(struct drm_encoder *encoder, void *data) 441 + void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data) 363 442 { 364 443 struct exynos_drm_manager *manager = 365 444 to_exynos_encoder(encoder)->manager; 366 445 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 367 446 int zpos = DEFAULT_ZPOS; 368 447 369 - DRM_DEBUG_KMS("\n"); 448 + DRM_DEBUG_KMS("%s\n", __FILE__); 449 + 450 + if (data) 451 + zpos = *(int *)data; 452 + 453 + if (overlay_ops && overlay_ops->commit) 454 + overlay_ops->commit(manager->dev, zpos); 455 + } 456 + 457 + void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data) 458 + { 459 + struct exynos_drm_manager *manager = 460 + to_exynos_encoder(encoder)->manager; 461 + struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 462 + int zpos = DEFAULT_ZPOS; 463 + 464 + DRM_DEBUG_KMS("%s\n", __FILE__); 465 + 466 + if (data) 467 + zpos = *(int *)data; 468 + 469 + if (overlay_ops && overlay_ops->enable) 470 + overlay_ops->enable(manager->dev, zpos); 471 + } 472 + 473 + void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data) 474 + { 475 + struct exynos_drm_manager *manager = 476 + to_exynos_encoder(encoder)->manager; 477 + struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 478 + int zpos = DEFAULT_ZPOS; 479 + 480 + DRM_DEBUG_KMS("%s\n", __FILE__); 370 481 371 482 if (data) 372 483 zpos = *(int *)data;
+5 -7
drivers/gpu/drm/exynos/exynos_drm_encoder.h
··· 40 40 void (*fn)(struct drm_encoder *, void *)); 41 41 void exynos_drm_enable_vblank(struct drm_encoder *encoder, void *data); 42 42 void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data); 43 - void exynos_drm_encoder_crtc_plane_commit(struct drm_encoder *encoder, 44 - void *data); 45 - void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data); 46 - void exynos_drm_encoder_dpms_from_crtc(struct drm_encoder *encoder, 47 - void *data); 48 43 void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data); 49 - void exynos_drm_encoder_crtc_mode_set(struct drm_encoder *encoder, void *data); 50 - void exynos_drm_encoder_crtc_disable(struct drm_encoder *encoder, void *data); 44 + void exynos_drm_encoder_crtc_pipe(struct drm_encoder *encoder, void *data); 45 + void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data); 46 + void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data); 47 + void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data); 48 + void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data); 51 49 52 50 #endif
+8 -32
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 78 78 struct drm_crtc *crtc; 79 79 struct clk *bus_clk; 80 80 struct clk *lcd_clk; 81 - struct resource *regs_res; 82 81 void __iomem *regs; 83 82 struct fimd_win_data win_data[WINDOWS_NR]; 84 83 unsigned int clkdiv; ··· 812 813 return -EINVAL; 813 814 } 814 815 815 - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 816 + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 816 817 if (!ctx) 817 818 return -ENOMEM; 818 819 ··· 837 838 goto err_clk; 838 839 } 839 840 840 - ctx->regs_res = request_mem_region(res->start, resource_size(res), 841 - dev_name(dev)); 842 - if (!ctx->regs_res) { 843 - dev_err(dev, "failed to claim register region\n"); 844 - ret = -ENOENT; 845 - goto err_clk; 846 - } 847 - 848 - ctx->regs = ioremap(res->start, resource_size(res)); 841 + ctx->regs = devm_request_and_ioremap(&pdev->dev, res); 849 842 if (!ctx->regs) { 850 843 dev_err(dev, "failed to map registers\n"); 851 844 ret = -ENXIO; 852 - goto err_req_region_io; 845 + goto err_clk; 853 846 } 854 847 855 848 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 856 849 if (!res) { 857 850 dev_err(dev, "irq request failed.\n"); 858 - goto err_req_region_irq; 851 + goto err_clk; 859 852 } 860 853 861 854 ctx->irq = res->start; 862 855 863 - ret = request_irq(ctx->irq, fimd_irq_handler, 0, "drm_fimd", ctx); 864 - if (ret < 0) { 856 + ret = devm_request_irq(&pdev->dev, ctx->irq, fimd_irq_handler, 857 + 0, "drm_fimd", ctx); 858 + if (ret) { 865 859 dev_err(dev, "irq request failed.\n"); 866 - goto err_req_irq; 860 + goto err_clk; 867 861 } 868 862 869 863 ctx->vidcon0 = pdata->vidcon0; ··· 891 899 892 900 return 0; 893 901 894 - err_req_irq: 895 - err_req_region_irq: 896 - iounmap(ctx->regs); 897 - 898 - err_req_region_io: 899 - release_resource(ctx->regs_res); 900 - kfree(ctx->regs_res); 901 - 902 902 err_clk: 903 903 clk_disable(ctx->lcd_clk); 904 904 clk_put(ctx->lcd_clk); ··· 900 916 clk_put(ctx->bus_clk); 901 917 902 918 err_clk_get: 903 - kfree(ctx); 904 919 return ret; 905 920 } 906 921 ··· 926 943 927 944 clk_put(ctx->lcd_clk); 928 945 clk_put(ctx->bus_clk); 929 - 930 - iounmap(ctx->regs); 931 - release_resource(ctx->regs_res); 932 - kfree(ctx->regs_res); 933 - free_irq(ctx->irq, ctx); 934 - 935 - kfree(ctx); 936 946 937 947 return 0; 938 948 }
+21 -28
drivers/gpu/drm/exynos/exynos_drm_gem.c
··· 99 99 struct page **exynos_gem_get_pages(struct drm_gem_object *obj, 100 100 gfp_t gfpmask) 101 101 { 102 - struct inode *inode; 103 - struct address_space *mapping; 104 102 struct page *p, **pages; 105 103 int i, npages; 106 - 107 - /* This is the shared memory object that backs the GEM resource */ 108 - inode = obj->filp->f_path.dentry->d_inode; 109 - mapping = inode->i_mapping; 110 104 111 105 npages = obj->size >> PAGE_SHIFT; 112 106 ··· 108 114 if (pages == NULL) 109 115 return ERR_PTR(-ENOMEM); 110 116 111 - gfpmask |= mapping_gfp_mask(mapping); 112 - 113 117 for (i = 0; i < npages; i++) { 114 - p = shmem_read_mapping_page_gfp(mapping, i, gfpmask); 118 + p = alloc_page(gfpmask); 115 119 if (IS_ERR(p)) 116 120 goto fail; 117 121 pages[i] = p; ··· 118 126 return pages; 119 127 120 128 fail: 121 - while (i--) 122 - page_cache_release(pages[i]); 129 + while (--i) 130 + __free_page(pages[i]); 123 131 124 132 drm_free_large(pages); 125 133 return ERR_PTR(PTR_ERR(p)); 126 134 } 127 135 128 136 static void exynos_gem_put_pages(struct drm_gem_object *obj, 129 - struct page **pages, 130 - bool dirty, bool accessed) 137 + struct page **pages) 131 138 { 132 - int i, npages; 139 + int npages; 133 140 134 141 npages = obj->size >> PAGE_SHIFT; 135 142 136 - for (i = 0; i < npages; i++) { 137 - if (dirty) 138 - set_page_dirty(pages[i]); 139 - 140 - if (accessed) 141 - mark_page_accessed(pages[i]); 142 - 143 - /* Undo the reference we took when populating the table */ 144 - page_cache_release(pages[i]); 145 - } 143 + while (--npages >= 0) 144 + __free_page(pages[npages]); 146 145 147 146 drm_free_large(pages); 148 147 } ··· 172 189 return -EINVAL; 173 190 } 174 191 175 - pages = exynos_gem_get_pages(obj, GFP_KERNEL); 192 + pages = exynos_gem_get_pages(obj, GFP_HIGHUSER_MOVABLE); 176 193 if (IS_ERR(pages)) { 177 194 DRM_ERROR("failed to get pages.\n"); 178 195 return PTR_ERR(pages); ··· 213 230 kfree(buf->sgt); 214 231 buf->sgt = NULL; 215 232 err: 216 - exynos_gem_put_pages(obj, pages, true, false); 233 + exynos_gem_put_pages(obj, pages); 217 234 return ret; 218 235 219 236 } ··· 231 248 kfree(buf->sgt); 232 249 buf->sgt = NULL; 233 250 234 - exynos_gem_put_pages(obj, buf->pages, true, false); 251 + exynos_gem_put_pages(obj, buf->pages); 235 252 buf->pages = NULL; 236 253 237 254 /* add some codes for UNCACHED type here. TODO */ ··· 274 291 if (!buf->pages) 275 292 return; 276 293 294 + /* 295 + * do not release memory region from exporter. 296 + * 297 + * the region will be released by exporter 298 + * once dmabuf's refcount becomes 0. 299 + */ 300 + if (obj->import_attach) 301 + goto out; 302 + 277 303 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) 278 304 exynos_drm_gem_put_pages(obj); 279 305 else 280 306 exynos_drm_free_buf(obj->dev, exynos_gem_obj->flags, buf); 281 307 308 + out: 282 309 exynos_drm_fini_buf(obj->dev, buf); 283 310 exynos_gem_obj->buffer = NULL; 284 311 ··· 661 668 * with DRM_IOCTL_MODE_CREATE_DUMB command. 662 669 */ 663 670 664 - args->pitch = args->width * args->bpp >> 3; 671 + args->pitch = args->width * ((args->bpp + 7) / 8); 665 672 args->size = PAGE_ALIGN(args->pitch * args->height); 666 673 667 674 exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size);
+2 -1
drivers/gpu/drm/exynos/exynos_drm_gem.h
··· 63 63 * by user request or at framebuffer creation. 64 64 * continuous memory region allocated by user request 65 65 * or at framebuffer creation. 66 - * @size: total memory size to physically non-continuous memory region. 66 + * @size: size requested from user, in bytes and this size is aligned 67 + * in page unit. 67 68 * @flags: indicate memory type to allocated buffer and cache attruibute. 68 69 * 69 70 * P.S. this object would be transfered to user as kms_bo.handle so
+172 -84
drivers/gpu/drm/exynos/exynos_drm_plane.c
··· 12 12 #include "drmP.h" 13 13 14 14 #include "exynos_drm.h" 15 - #include "exynos_drm_crtc.h" 16 15 #include "exynos_drm_drv.h" 17 16 #include "exynos_drm_encoder.h" 17 + #include "exynos_drm_fb.h" 18 + #include "exynos_drm_gem.h" 19 + 20 + #define to_exynos_plane(x) container_of(x, struct exynos_plane, base) 18 21 19 22 struct exynos_plane { 20 23 struct drm_plane base; ··· 33 30 DRM_FORMAT_NV12MT, 34 31 }; 35 32 33 + int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, 34 + struct drm_framebuffer *fb, int crtc_x, int crtc_y, 35 + unsigned int crtc_w, unsigned int crtc_h, 36 + uint32_t src_x, uint32_t src_y, 37 + uint32_t src_w, uint32_t src_h) 38 + { 39 + struct exynos_plane *exynos_plane = to_exynos_plane(plane); 40 + struct exynos_drm_overlay *overlay = &exynos_plane->overlay; 41 + unsigned int actual_w; 42 + unsigned int actual_h; 43 + int nr; 44 + int i; 45 + 46 + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 47 + 48 + nr = exynos_drm_format_num_buffers(fb->pixel_format); 49 + for (i = 0; i < nr; i++) { 50 + struct exynos_drm_gem_buf *buffer = exynos_drm_fb_buffer(fb, i); 51 + 52 + if (!buffer) { 53 + DRM_LOG_KMS("buffer is null\n"); 54 + return -EFAULT; 55 + } 56 + 57 + overlay->dma_addr[i] = buffer->dma_addr; 58 + overlay->vaddr[i] = buffer->kvaddr; 59 + 60 + DRM_DEBUG_KMS("buffer: %d, vaddr = 0x%lx, dma_addr = 0x%lx\n", 61 + i, (unsigned long)overlay->vaddr[i], 62 + (unsigned long)overlay->dma_addr[i]); 63 + } 64 + 65 + actual_w = min((unsigned)(crtc->mode.hdisplay - crtc_x), crtc_w); 66 + actual_h = min((unsigned)(crtc->mode.vdisplay - crtc_y), crtc_h); 67 + 68 + /* set drm framebuffer data. */ 69 + overlay->fb_x = src_x; 70 + overlay->fb_y = src_y; 71 + overlay->fb_width = fb->width; 72 + overlay->fb_height = fb->height; 73 + overlay->src_width = src_w; 74 + overlay->src_height = src_h; 75 + overlay->bpp = fb->bits_per_pixel; 76 + overlay->pitch = fb->pitches[0]; 77 + overlay->pixel_format = fb->pixel_format; 78 + 79 + /* set overlay range to be displayed. */ 80 + overlay->crtc_x = crtc_x; 81 + overlay->crtc_y = crtc_y; 82 + overlay->crtc_width = actual_w; 83 + overlay->crtc_height = actual_h; 84 + 85 + /* set drm mode data. */ 86 + overlay->mode_width = crtc->mode.hdisplay; 87 + overlay->mode_height = crtc->mode.vdisplay; 88 + overlay->refresh = crtc->mode.vrefresh; 89 + overlay->scan_flag = crtc->mode.flags; 90 + 91 + DRM_DEBUG_KMS("overlay : offset_x/y(%d,%d), width/height(%d,%d)", 92 + overlay->crtc_x, overlay->crtc_y, 93 + overlay->crtc_width, overlay->crtc_height); 94 + 95 + exynos_drm_fn_encoder(crtc, overlay, exynos_drm_encoder_plane_mode_set); 96 + 97 + return 0; 98 + } 99 + 100 + void exynos_plane_commit(struct drm_plane *plane) 101 + { 102 + struct exynos_plane *exynos_plane = to_exynos_plane(plane); 103 + struct exynos_drm_overlay *overlay = &exynos_plane->overlay; 104 + 105 + exynos_drm_fn_encoder(plane->crtc, &overlay->zpos, 106 + exynos_drm_encoder_plane_commit); 107 + } 108 + 109 + void exynos_plane_dpms(struct drm_plane *plane, int mode) 110 + { 111 + struct exynos_plane *exynos_plane = to_exynos_plane(plane); 112 + struct exynos_drm_overlay *overlay = &exynos_plane->overlay; 113 + 114 + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 115 + 116 + if (mode == DRM_MODE_DPMS_ON) { 117 + if (exynos_plane->enabled) 118 + return; 119 + 120 + exynos_drm_fn_encoder(plane->crtc, &overlay->zpos, 121 + exynos_drm_encoder_plane_enable); 122 + 123 + exynos_plane->enabled = true; 124 + } else { 125 + if (!exynos_plane->enabled) 126 + return; 127 + 128 + exynos_drm_fn_encoder(plane->crtc, &overlay->zpos, 129 + exynos_drm_encoder_plane_disable); 130 + 131 + exynos_plane->enabled = false; 132 + } 133 + } 134 + 36 135 static int 37 136 exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, 38 137 struct drm_framebuffer *fb, int crtc_x, int crtc_y, ··· 142 37 uint32_t src_x, uint32_t src_y, 143 38 uint32_t src_w, uint32_t src_h) 144 39 { 145 - struct exynos_plane *exynos_plane = 146 - container_of(plane, struct exynos_plane, base); 147 - struct exynos_drm_overlay *overlay = &exynos_plane->overlay; 148 - struct exynos_drm_crtc_pos pos; 149 40 int ret; 150 41 151 42 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 152 43 153 - memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos)); 154 - pos.crtc_x = crtc_x; 155 - pos.crtc_y = crtc_y; 156 - pos.crtc_w = crtc_w; 157 - pos.crtc_h = crtc_h; 158 - 159 - /* considering 16.16 fixed point of source values */ 160 - pos.fb_x = src_x >> 16; 161 - pos.fb_y = src_y >> 16; 162 - pos.src_w = src_w >> 16; 163 - pos.src_h = src_h >> 16; 164 - 165 - ret = exynos_drm_overlay_update(overlay, fb, &crtc->mode, &pos); 44 + ret = exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, 45 + crtc_w, crtc_h, src_x >> 16, src_y >> 16, 46 + src_w >> 16, src_h >> 16); 166 47 if (ret < 0) 167 48 return ret; 168 49 169 - exynos_drm_fn_encoder(crtc, overlay, 170 - exynos_drm_encoder_crtc_mode_set); 171 - exynos_drm_fn_encoder(crtc, &overlay->zpos, 172 - exynos_drm_encoder_crtc_plane_commit); 50 + plane->crtc = crtc; 51 + plane->fb = crtc->fb; 173 52 174 - exynos_plane->enabled = true; 53 + exynos_plane_commit(plane); 54 + exynos_plane_dpms(plane, DRM_MODE_DPMS_ON); 175 55 176 56 return 0; 177 57 } 178 58 179 59 static int exynos_disable_plane(struct drm_plane *plane) 180 60 { 181 - struct exynos_plane *exynos_plane = 182 - container_of(plane, struct exynos_plane, base); 183 - struct exynos_drm_overlay *overlay = &exynos_plane->overlay; 184 - 185 61 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 186 62 187 - if (!exynos_plane->enabled) 188 - return 0; 189 - 190 - exynos_drm_fn_encoder(plane->crtc, &overlay->zpos, 191 - exynos_drm_encoder_crtc_disable); 192 - 193 - exynos_plane->enabled = false; 194 - exynos_plane->overlay.zpos = DEFAULT_ZPOS; 63 + exynos_plane_dpms(plane, DRM_MODE_DPMS_OFF); 195 64 196 65 return 0; 197 66 } 198 67 199 68 static void exynos_plane_destroy(struct drm_plane *plane) 200 69 { 201 - struct exynos_plane *exynos_plane = 202 - container_of(plane, struct exynos_plane, base); 70 + struct exynos_plane *exynos_plane = to_exynos_plane(plane); 203 71 204 72 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 205 73 ··· 181 103 kfree(exynos_plane); 182 104 } 183 105 106 + static int exynos_plane_set_property(struct drm_plane *plane, 107 + struct drm_property *property, 108 + uint64_t val) 109 + { 110 + struct drm_device *dev = plane->dev; 111 + struct exynos_plane *exynos_plane = to_exynos_plane(plane); 112 + struct exynos_drm_private *dev_priv = dev->dev_private; 113 + 114 + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 115 + 116 + if (property == dev_priv->plane_zpos_property) { 117 + exynos_plane->overlay.zpos = val; 118 + return 0; 119 + } 120 + 121 + return -EINVAL; 122 + } 123 + 184 124 static struct drm_plane_funcs exynos_plane_funcs = { 185 125 .update_plane = exynos_update_plane, 186 126 .disable_plane = exynos_disable_plane, 187 127 .destroy = exynos_plane_destroy, 128 + .set_property = exynos_plane_set_property, 188 129 }; 189 130 190 - int exynos_plane_init(struct drm_device *dev, unsigned int nr) 131 + static void exynos_plane_attach_zpos_property(struct drm_plane *plane) 191 132 { 192 - struct exynos_plane *exynos_plane; 193 - uint32_t possible_crtcs; 194 - 195 - exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); 196 - if (!exynos_plane) 197 - return -ENOMEM; 198 - 199 - /* all CRTCs are available */ 200 - possible_crtcs = (1 << MAX_CRTC) - 1; 201 - 202 - exynos_plane->overlay.zpos = DEFAULT_ZPOS; 203 - 204 - return drm_plane_init(dev, &exynos_plane->base, possible_crtcs, 205 - &exynos_plane_funcs, formats, ARRAY_SIZE(formats), 206 - false); 207 - } 208 - 209 - int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 210 - struct drm_file *file_priv) 211 - { 212 - struct drm_exynos_plane_set_zpos *zpos_req = data; 213 - struct drm_mode_object *obj; 214 - struct drm_plane *plane; 215 - struct exynos_plane *exynos_plane; 216 - int ret = 0; 133 + struct drm_device *dev = plane->dev; 134 + struct exynos_drm_private *dev_priv = dev->dev_private; 135 + struct drm_property *prop; 217 136 218 137 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 219 138 220 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 221 - return -EINVAL; 139 + prop = dev_priv->plane_zpos_property; 140 + if (!prop) { 141 + prop = drm_property_create_range(dev, 0, "zpos", 0, 142 + MAX_PLANE - 1); 143 + if (!prop) 144 + return; 222 145 223 - if (zpos_req->zpos < 0 || zpos_req->zpos >= MAX_PLANE) { 224 - if (zpos_req->zpos != DEFAULT_ZPOS) { 225 - DRM_ERROR("zpos not within limits\n"); 226 - return -EINVAL; 227 - } 146 + dev_priv->plane_zpos_property = prop; 228 147 } 229 148 230 - mutex_lock(&dev->mode_config.mutex); 149 + drm_object_attach_property(&plane->base, prop, 0); 150 + } 231 151 232 - obj = drm_mode_object_find(dev, zpos_req->plane_id, 233 - DRM_MODE_OBJECT_PLANE); 234 - if (!obj) { 235 - DRM_DEBUG_KMS("Unknown plane ID %d\n", 236 - zpos_req->plane_id); 237 - ret = -EINVAL; 238 - goto out; 152 + struct drm_plane *exynos_plane_init(struct drm_device *dev, 153 + unsigned int possible_crtcs, bool priv) 154 + { 155 + struct exynos_plane *exynos_plane; 156 + int err; 157 + 158 + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 159 + 160 + exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); 161 + if (!exynos_plane) { 162 + DRM_ERROR("failed to allocate plane\n"); 163 + return NULL; 239 164 } 240 165 241 - plane = obj_to_plane(obj); 242 - exynos_plane = container_of(plane, struct exynos_plane, base); 166 + err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs, 167 + &exynos_plane_funcs, formats, ARRAY_SIZE(formats), 168 + priv); 169 + if (err) { 170 + DRM_ERROR("failed to initialize plane\n"); 171 + kfree(exynos_plane); 172 + return NULL; 173 + } 243 174 244 - exynos_plane->overlay.zpos = zpos_req->zpos; 175 + if (priv) 176 + exynos_plane->overlay.zpos = DEFAULT_ZPOS; 177 + else 178 + exynos_plane_attach_zpos_property(&exynos_plane->base); 245 179 246 - out: 247 - mutex_unlock(&dev->mode_config.mutex); 248 - return ret; 180 + return &exynos_plane->base; 249 181 }
+9 -3
drivers/gpu/drm/exynos/exynos_drm_plane.h
··· 9 9 * 10 10 */ 11 11 12 - int exynos_plane_init(struct drm_device *dev, unsigned int nr); 13 - int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 14 - struct drm_file *file_priv); 12 + int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, 13 + struct drm_framebuffer *fb, int crtc_x, int crtc_y, 14 + unsigned int crtc_w, unsigned int crtc_h, 15 + uint32_t src_x, uint32_t src_y, 16 + uint32_t src_w, uint32_t src_h); 17 + void exynos_plane_commit(struct drm_plane *plane); 18 + void exynos_plane_dpms(struct drm_plane *plane, int mode); 19 + struct drm_plane *exynos_plane_init(struct drm_device *dev, 20 + unsigned int possible_crtcs, bool priv);
+41 -12
drivers/gpu/drm/exynos/exynos_drm_vidi.c
··· 85 85 0x00, 0x00, 0x00, 0x06 86 86 }; 87 87 88 - static void vidi_fake_vblank_handler(struct work_struct *work); 89 - 90 88 static bool vidi_display_is_connected(struct device *dev) 91 89 { 92 90 struct vidi_context *ctx = get_vidi_context(dev); ··· 529 531 if (ctx->connected > 1) 530 532 return -EINVAL; 531 533 534 + /* use fake edid data for test. */ 535 + if (!ctx->raw_edid) 536 + ctx->raw_edid = (struct edid *)fake_edid_info; 537 + 538 + /* if raw_edid isn't same as fake data then it can't be tested. */ 539 + if (ctx->raw_edid != (struct edid *)fake_edid_info) { 540 + DRM_DEBUG_KMS("edid data is not fake data.\n"); 541 + return -EINVAL; 542 + } 543 + 532 544 DRM_DEBUG_KMS("requested connection.\n"); 533 545 534 546 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev); ··· 557 549 struct exynos_drm_manager *manager; 558 550 struct exynos_drm_display_ops *display_ops; 559 551 struct drm_exynos_vidi_connection *vidi = data; 552 + struct edid *raw_edid; 553 + int edid_len; 560 554 561 555 DRM_DEBUG_KMS("%s\n", __FILE__); 562 556 563 557 if (!vidi) { 564 558 DRM_DEBUG_KMS("user data for vidi is null.\n"); 565 - return -EINVAL; 566 - } 567 - 568 - if (!vidi->edid) { 569 - DRM_DEBUG_KMS("edid data is null.\n"); 570 559 return -EINVAL; 571 560 } 572 561 ··· 593 588 return -EINVAL; 594 589 } 595 590 596 - if (vidi->connection) 597 - ctx->raw_edid = (struct edid *)vidi->edid; 591 + if (vidi->connection) { 592 + if (!vidi->edid) { 593 + DRM_DEBUG_KMS("edid data is null.\n"); 594 + return -EINVAL; 595 + } 596 + raw_edid = (struct edid *)(uint32_t)vidi->edid; 597 + edid_len = (1 + raw_edid->extensions) * EDID_LENGTH; 598 + ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL); 599 + if (!ctx->raw_edid) { 600 + DRM_DEBUG_KMS("failed to allocate raw_edid.\n"); 601 + return -ENOMEM; 602 + } 603 + memcpy(ctx->raw_edid, raw_edid, edid_len); 604 + } else { 605 + /* 606 + * with connection = 0, free raw_edid 607 + * only if raw edid data isn't same as fake data. 608 + */ 609 + if (ctx->raw_edid && ctx->raw_edid != 610 + (struct edid *)fake_edid_info) { 611 + kfree(ctx->raw_edid); 612 + ctx->raw_edid = NULL; 613 + } 614 + } 598 615 599 616 ctx->connected = vidi->connection; 600 617 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev); ··· 640 613 ctx->default_win = 0; 641 614 642 615 INIT_WORK(&ctx->work, vidi_fake_vblank_handler); 643 - 644 - /* for test */ 645 - ctx->raw_edid = (struct edid *)fake_edid_info; 646 616 647 617 subdrv = &ctx->subdrv; 648 618 subdrv->dev = dev; ··· 667 643 DRM_DEBUG_KMS("%s\n", __FILE__); 668 644 669 645 exynos_drm_subdrv_unregister(&ctx->subdrv); 646 + 647 + if (ctx->raw_edid != (struct edid *)fake_edid_info) { 648 + kfree(ctx->raw_edid); 649 + ctx->raw_edid = NULL; 650 + } 670 651 671 652 kfree(ctx); 672 653
+7 -29
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 63 63 bool dvi_mode; 64 64 struct mutex hdmi_mutex; 65 65 66 - struct resource *regs_res; 67 66 void __iomem *regs; 68 67 unsigned int external_irq; 69 68 unsigned int internal_irq; ··· 2279 2280 return -EINVAL; 2280 2281 } 2281 2282 2282 - drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); 2283 + drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx), 2284 + GFP_KERNEL); 2283 2285 if (!drm_hdmi_ctx) { 2284 2286 DRM_ERROR("failed to allocate common hdmi context.\n"); 2285 2287 return -ENOMEM; 2286 2288 } 2287 2289 2288 - hdata = kzalloc(sizeof(struct hdmi_context), GFP_KERNEL); 2290 + hdata = devm_kzalloc(&pdev->dev, sizeof(struct hdmi_context), 2291 + GFP_KERNEL); 2289 2292 if (!hdata) { 2290 2293 DRM_ERROR("out of memory\n"); 2291 - kfree(drm_hdmi_ctx); 2292 2294 return -ENOMEM; 2293 2295 } 2294 2296 ··· 2318 2318 goto err_resource; 2319 2319 } 2320 2320 2321 - hdata->regs_res = request_mem_region(res->start, resource_size(res), 2322 - dev_name(dev)); 2323 - if (!hdata->regs_res) { 2324 - DRM_ERROR("failed to claim register region\n"); 2325 - ret = -ENOENT; 2326 - goto err_resource; 2327 - } 2328 - 2329 - hdata->regs = ioremap(res->start, resource_size(res)); 2321 + hdata->regs = devm_request_and_ioremap(&pdev->dev, res); 2330 2322 if (!hdata->regs) { 2331 2323 DRM_ERROR("failed to map registers\n"); 2332 2324 ret = -ENXIO; 2333 - goto err_req_region; 2325 + goto err_resource; 2334 2326 } 2335 2327 2336 2328 /* DDC i2c driver */ 2337 2329 if (i2c_add_driver(&ddc_driver)) { 2338 2330 DRM_ERROR("failed to register ddc i2c driver\n"); 2339 2331 ret = -ENOENT; 2340 - goto err_iomap; 2332 + goto err_resource; 2341 2333 } 2342 2334 2343 2335 hdata->ddc_port = hdmi_ddc; ··· 2390 2398 i2c_del_driver(&hdmiphy_driver); 2391 2399 err_ddc: 2392 2400 i2c_del_driver(&ddc_driver); 2393 - err_iomap: 2394 - iounmap(hdata->regs); 2395 - err_req_region: 2396 - release_mem_region(hdata->regs_res->start, 2397 - resource_size(hdata->regs_res)); 2398 2401 err_resource: 2399 2402 hdmi_resources_cleanup(hdata); 2400 2403 err_data: 2401 - kfree(hdata); 2402 - kfree(drm_hdmi_ctx); 2403 2404 return ret; 2404 2405 } 2405 2406 ··· 2410 2425 2411 2426 hdmi_resources_cleanup(hdata); 2412 2427 2413 - iounmap(hdata->regs); 2414 - 2415 - release_mem_region(hdata->regs_res->start, 2416 - resource_size(hdata->regs_res)); 2417 - 2418 2428 /* hdmiphy i2c driver */ 2419 2429 i2c_del_driver(&hdmiphy_driver); 2420 2430 /* DDC i2c driver */ 2421 2431 i2c_del_driver(&ddc_driver); 2422 - 2423 - kfree(hdata); 2424 2432 2425 2433 return 0; 2426 2434 }
+14 -34
drivers/gpu/drm/exynos/exynos_mixer.c
··· 956 956 957 957 clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi); 958 958 959 - mixer_res->mixer_regs = ioremap(res->start, resource_size(res)); 959 + mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start, 960 + resource_size(res)); 960 961 if (mixer_res->mixer_regs == NULL) { 961 962 dev_err(dev, "register mapping failed.\n"); 962 963 ret = -ENXIO; ··· 968 967 if (res == NULL) { 969 968 dev_err(dev, "get memory resource failed.\n"); 970 969 ret = -ENXIO; 971 - goto fail_mixer_regs; 970 + goto fail; 972 971 } 973 972 974 - mixer_res->vp_regs = ioremap(res->start, resource_size(res)); 973 + mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start, 974 + resource_size(res)); 975 975 if (mixer_res->vp_regs == NULL) { 976 976 dev_err(dev, "register mapping failed.\n"); 977 977 ret = -ENXIO; 978 - goto fail_mixer_regs; 978 + goto fail; 979 979 } 980 980 981 981 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); 982 982 if (res == NULL) { 983 983 dev_err(dev, "get interrupt resource failed.\n"); 984 984 ret = -ENXIO; 985 - goto fail_vp_regs; 985 + goto fail; 986 986 } 987 987 988 - ret = request_irq(res->start, mixer_irq_handler, 0, "drm_mixer", ctx); 988 + ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler, 989 + 0, "drm_mixer", ctx); 989 990 if (ret) { 990 991 dev_err(dev, "request interrupt failed.\n"); 991 - goto fail_vp_regs; 992 + goto fail; 992 993 } 993 994 mixer_res->irq = res->start; 994 995 995 996 return 0; 996 - 997 - fail_vp_regs: 998 - iounmap(mixer_res->vp_regs); 999 - 1000 - fail_mixer_regs: 1001 - iounmap(mixer_res->mixer_regs); 1002 997 1003 998 fail: 1004 999 if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) ··· 1010 1013 return ret; 1011 1014 } 1012 1015 1013 - static void mixer_resources_cleanup(struct mixer_context *ctx) 1014 - { 1015 - struct mixer_resources *res = &ctx->mixer_res; 1016 - 1017 - free_irq(res->irq, ctx); 1018 - 1019 - iounmap(res->vp_regs); 1020 - iounmap(res->mixer_regs); 1021 - } 1022 - 1023 1016 static int __devinit mixer_probe(struct platform_device *pdev) 1024 1017 { 1025 1018 struct device *dev = &pdev->dev; ··· 1019 1032 1020 1033 dev_info(dev, "probe start\n"); 1021 1034 1022 - drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); 1035 + drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx), 1036 + GFP_KERNEL); 1023 1037 if (!drm_hdmi_ctx) { 1024 1038 DRM_ERROR("failed to allocate common hdmi context.\n"); 1025 1039 return -ENOMEM; 1026 1040 } 1027 1041 1028 - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 1042 + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 1029 1043 if (!ctx) { 1030 1044 DRM_ERROR("failed to alloc mixer context.\n"); 1031 - kfree(drm_hdmi_ctx); 1032 1045 return -ENOMEM; 1033 1046 } 1034 1047 ··· 1059 1072 1060 1073 static int mixer_remove(struct platform_device *pdev) 1061 1074 { 1062 - struct device *dev = &pdev->dev; 1063 - struct exynos_drm_hdmi_context *drm_hdmi_ctx = 1064 - platform_get_drvdata(pdev); 1065 - struct mixer_context *ctx = drm_hdmi_ctx->ctx; 1066 - 1067 - dev_info(dev, "remove successful\n"); 1075 + dev_info(&pdev->dev, "remove successful\n"); 1068 1076 1069 1077 pm_runtime_disable(&pdev->dev); 1070 - 1071 - mixer_resources_cleanup(ctx); 1072 1078 1073 1079 return 0; 1074 1080 }
-9
include/drm/exynos_drm.h
··· 107 107 uint64_t edid; 108 108 }; 109 109 110 - struct drm_exynos_plane_set_zpos { 111 - __u32 plane_id; 112 - __s32 zpos; 113 - }; 114 - 115 110 /* memory type definitions. */ 116 111 enum e_drm_exynos_gem_mem_type { 117 112 /* Physically Continuous memory and used as default. */ ··· 159 164 #define DRM_EXYNOS_GEM_MMAP 0x02 160 165 /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */ 161 166 #define DRM_EXYNOS_GEM_GET 0x04 162 - #define DRM_EXYNOS_PLANE_SET_ZPOS 0x06 163 167 #define DRM_EXYNOS_VIDI_CONNECTION 0x07 164 168 165 169 /* G2D */ ··· 177 183 178 184 #define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ 179 185 DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info) 180 - 181 - #define DRM_IOCTL_EXYNOS_PLANE_SET_ZPOS DRM_IOWR(DRM_COMMAND_BASE + \ 182 - DRM_EXYNOS_PLANE_SET_ZPOS, struct drm_exynos_plane_set_zpos) 183 186 184 187 #define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \ 185 188 DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)