Commit 8dcb96b628a0749184bbcc5e6c94463f89405c58

Authored by Seung-Woo Kim
Committed by Inki Dae
1 parent 0d8071ee11

drm/exynos: added vp scaling feature for hdmi

This patch adds vp scaling feature for exynos hdmi. Scaling ratio
between source and destination is used for width and height.
Also meaningless variables to set registers are cleaned.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

Showing 1 changed file with 33 additions and 55 deletions Side-by-side Diff

drivers/gpu/drm/exynos/exynos_mixer.c
... ... @@ -54,6 +54,8 @@
54 54 unsigned int fb_y;
55 55 unsigned int fb_width;
56 56 unsigned int fb_height;
  57 + unsigned int src_width;
  58 + unsigned int src_height;
57 59 unsigned int mode_width;
58 60 unsigned int mode_height;
59 61 unsigned int scan_flags;
60 62  
... ... @@ -351,10 +353,7 @@
351 353 struct mixer_resources *res = &ctx->mixer_res;
352 354 unsigned long flags;
353 355 struct hdmi_win_data *win_data;
354   - unsigned int full_width, full_height, width, height;
355 356 unsigned int x_ratio, y_ratio;
356   - unsigned int src_x_offset, src_y_offset, dst_x_offset, dst_y_offset;
357   - unsigned int mode_width, mode_height;
358 357 unsigned int buf_num;
359 358 dma_addr_t luma_addr[2], chroma_addr[2];
360 359 bool tiled_mode = false;
361 360  
362 361  
363 362  
... ... @@ -381,29 +380,17 @@
381 380 return;
382 381 }
383 382  
384   - full_width = win_data->fb_width;
385   - full_height = win_data->fb_height;
386   - width = win_data->crtc_width;
387   - height = win_data->crtc_height;
388   - mode_width = win_data->mode_width;
389   - mode_height = win_data->mode_height;
390   -
391 383 /* scaling feature: (src << 16) / dst */
392   - x_ratio = (width << 16) / width;
393   - y_ratio = (height << 16) / height;
  384 + x_ratio = (win_data->src_width << 16) / win_data->crtc_width;
  385 + y_ratio = (win_data->src_height << 16) / win_data->crtc_height;
394 386  
395   - src_x_offset = win_data->fb_x;
396   - src_y_offset = win_data->fb_y;
397   - dst_x_offset = win_data->crtc_x;
398   - dst_y_offset = win_data->crtc_y;
399   -
400 387 if (buf_num == 2) {
401 388 luma_addr[0] = win_data->dma_addr;
402 389 chroma_addr[0] = win_data->chroma_dma_addr;
403 390 } else {
404 391 luma_addr[0] = win_data->dma_addr;
405 392 chroma_addr[0] = win_data->dma_addr
406   - + (full_width * full_height);
  393 + + (win_data->fb_width * win_data->fb_height);
407 394 }
408 395  
409 396 if (win_data->scan_flags & DRM_MODE_FLAG_INTERLACE) {
... ... @@ -412,8 +399,8 @@
412 399 luma_addr[1] = luma_addr[0] + 0x40;
413 400 chroma_addr[1] = chroma_addr[0] + 0x40;
414 401 } else {
415   - luma_addr[1] = luma_addr[0] + full_width;
416   - chroma_addr[1] = chroma_addr[0] + full_width;
  402 + luma_addr[1] = luma_addr[0] + win_data->fb_width;
  403 + chroma_addr[1] = chroma_addr[0] + win_data->fb_width;
417 404 }
418 405 } else {
419 406 ctx->interlace = false;
420 407  
421 408  
422 409  
423 410  
424 411  
425 412  
... ... @@ -434,26 +421,26 @@
434 421 vp_reg_writemask(res, VP_MODE, val, VP_MODE_FMT_MASK);
435 422  
436 423 /* setting size of input image */
437   - vp_reg_write(res, VP_IMG_SIZE_Y, VP_IMG_HSIZE(full_width) |
438   - VP_IMG_VSIZE(full_height));
  424 + vp_reg_write(res, VP_IMG_SIZE_Y, VP_IMG_HSIZE(win_data->fb_width) |
  425 + VP_IMG_VSIZE(win_data->fb_height));
439 426 /* chroma height has to reduced by 2 to avoid chroma distorions */
440   - vp_reg_write(res, VP_IMG_SIZE_C, VP_IMG_HSIZE(full_width) |
441   - VP_IMG_VSIZE(full_height / 2));
  427 + vp_reg_write(res, VP_IMG_SIZE_C, VP_IMG_HSIZE(win_data->fb_width) |
  428 + VP_IMG_VSIZE(win_data->fb_height / 2));
442 429  
443   - vp_reg_write(res, VP_SRC_WIDTH, width);
444   - vp_reg_write(res, VP_SRC_HEIGHT, height);
  430 + vp_reg_write(res, VP_SRC_WIDTH, win_data->src_width);
  431 + vp_reg_write(res, VP_SRC_HEIGHT, win_data->src_height);
445 432 vp_reg_write(res, VP_SRC_H_POSITION,
446   - VP_SRC_H_POSITION_VAL(src_x_offset));
447   - vp_reg_write(res, VP_SRC_V_POSITION, src_y_offset);
  433 + VP_SRC_H_POSITION_VAL(win_data->fb_x));
  434 + vp_reg_write(res, VP_SRC_V_POSITION, win_data->fb_y);
448 435  
449   - vp_reg_write(res, VP_DST_WIDTH, width);
450   - vp_reg_write(res, VP_DST_H_POSITION, dst_x_offset);
  436 + vp_reg_write(res, VP_DST_WIDTH, win_data->crtc_width);
  437 + vp_reg_write(res, VP_DST_H_POSITION, win_data->crtc_x);
451 438 if (ctx->interlace) {
452   - vp_reg_write(res, VP_DST_HEIGHT, height / 2);
453   - vp_reg_write(res, VP_DST_V_POSITION, dst_y_offset / 2);
  439 + vp_reg_write(res, VP_DST_HEIGHT, win_data->crtc_height / 2);
  440 + vp_reg_write(res, VP_DST_V_POSITION, win_data->crtc_y / 2);
454 441 } else {
455   - vp_reg_write(res, VP_DST_HEIGHT, height);
456   - vp_reg_write(res, VP_DST_V_POSITION, dst_y_offset);
  442 + vp_reg_write(res, VP_DST_HEIGHT, win_data->crtc_height);
  443 + vp_reg_write(res, VP_DST_V_POSITION, win_data->crtc_y);
457 444 }
458 445  
459 446 vp_reg_write(res, VP_H_RATIO, x_ratio);
... ... @@ -467,8 +454,8 @@
467 454 vp_reg_write(res, VP_TOP_C_PTR, chroma_addr[0]);
468 455 vp_reg_write(res, VP_BOT_C_PTR, chroma_addr[1]);
469 456  
470   - mixer_cfg_scan(ctx, mode_height);
471   - mixer_cfg_rgb_fmt(ctx, mode_height);
  457 + mixer_cfg_scan(ctx, win_data->mode_height);
  458 + mixer_cfg_rgb_fmt(ctx, win_data->mode_height);
472 459 mixer_cfg_layer(ctx, win, true);
473 460 mixer_run(ctx);
474 461  
475 462  
... ... @@ -483,10 +470,8 @@
483 470 struct mixer_resources *res = &ctx->mixer_res;
484 471 unsigned long flags;
485 472 struct hdmi_win_data *win_data;
486   - unsigned int full_width, width, height;
487 473 unsigned int x_ratio, y_ratio;
488 474 unsigned int src_x_offset, src_y_offset, dst_x_offset, dst_y_offset;
489   - unsigned int mode_width, mode_height;
490 475 dma_addr_t dma_addr;
491 476 unsigned int fmt;
492 477 u32 val;
493 478  
494 479  
... ... @@ -509,26 +494,17 @@
509 494 fmt = ARGB8888;
510 495 }
511 496  
512   - dma_addr = win_data->dma_addr;
513   - full_width = win_data->fb_width;
514   - width = win_data->crtc_width;
515   - height = win_data->crtc_height;
516   - mode_width = win_data->mode_width;
517   - mode_height = win_data->mode_height;
518   -
519 497 /* 2x scaling feature */
520 498 x_ratio = 0;
521 499 y_ratio = 0;
522 500  
523   - src_x_offset = win_data->fb_x;
524   - src_y_offset = win_data->fb_y;
525 501 dst_x_offset = win_data->crtc_x;
526 502 dst_y_offset = win_data->crtc_y;
527 503  
528 504 /* converting dma address base and source offset */
529   - dma_addr = dma_addr
530   - + (src_x_offset * win_data->bpp >> 3)
531   - + (src_y_offset * full_width * win_data->bpp >> 3);
  505 + dma_addr = win_data->dma_addr
  506 + + (win_data->fb_x * win_data->bpp >> 3)
  507 + + (win_data->fb_y * win_data->fb_width * win_data->bpp >> 3);
532 508 src_x_offset = 0;
533 509 src_y_offset = 0;
534 510  
535 511  
... ... @@ -545,10 +521,10 @@
545 521 MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK);
546 522  
547 523 /* setup geometry */
548   - mixer_reg_write(res, MXR_GRAPHIC_SPAN(win), full_width);
  524 + mixer_reg_write(res, MXR_GRAPHIC_SPAN(win), win_data->fb_width);
549 525  
550   - val = MXR_GRP_WH_WIDTH(width);
551   - val |= MXR_GRP_WH_HEIGHT(height);
  526 + val = MXR_GRP_WH_WIDTH(win_data->crtc_width);
  527 + val |= MXR_GRP_WH_HEIGHT(win_data->crtc_height);
552 528 val |= MXR_GRP_WH_H_SCALE(x_ratio);
553 529 val |= MXR_GRP_WH_V_SCALE(y_ratio);
554 530 mixer_reg_write(res, MXR_GRAPHIC_WH(win), val);
... ... @@ -566,8 +542,8 @@
566 542 /* set buffer address to mixer */
567 543 mixer_reg_write(res, MXR_GRAPHIC_BASE(win), dma_addr);
568 544  
569   - mixer_cfg_scan(ctx, mode_height);
570   - mixer_cfg_rgb_fmt(ctx, mode_height);
  545 + mixer_cfg_scan(ctx, win_data->mode_height);
  546 + mixer_cfg_rgb_fmt(ctx, win_data->mode_height);
571 547 mixer_cfg_layer(ctx, win, true);
572 548 mixer_run(ctx);
573 549  
... ... @@ -795,6 +771,8 @@
795 771 win_data->fb_y = overlay->fb_y;
796 772 win_data->fb_width = overlay->fb_width;
797 773 win_data->fb_height = overlay->fb_height;
  774 + win_data->src_width = overlay->src_width;
  775 + win_data->src_height = overlay->src_height;
798 776  
799 777 win_data->mode_width = overlay->mode_width;
800 778 win_data->mode_height = overlay->mode_height;