0280-drm-vc4-Fix-which-value-is-being-used-for-source-ima.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From dd89447cbae60a723e7192f4c176eb62672dfb2b Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Mon, 28 Dec 2015 14:45:25 -0800
  4. Subject: [PATCH] drm/vc4: Fix which value is being used for source image size.
  5. This doesn't matter yet since we only allow 1:1 scaling, but the
  6. comment clearly says we should be using the source size.
  7. Signed-off-by: Eric Anholt <eric@anholt.net>
  8. (cherry picked from commit f863e356013d628fa65b1cd89aa298eed26fc936)
  9. ---
  10. drivers/gpu/drm/vc4/vc4_plane.c | 23 ++++++++++++++---------
  11. 1 file changed, 14 insertions(+), 9 deletions(-)
  12. --- a/drivers/gpu/drm/vc4/vc4_plane.c
  13. +++ b/drivers/gpu/drm/vc4/vc4_plane.c
  14. @@ -47,6 +47,8 @@ struct vc4_plane_state {
  15. /* Clipped coordinates of the plane on the display. */
  16. int crtc_x, crtc_y, crtc_w, crtc_h;
  17. + /* Clipped size of the area scanned from in the FB. */
  18. + u32 src_w, src_h;
  19. /* Offset to start scanning out from the start of the plane's
  20. * BO.
  21. @@ -186,11 +188,6 @@ static int vc4_plane_setup_clipping_and_
  22. vc4_state->offset = fb->offsets[0];
  23. - vc4_state->crtc_x = state->crtc_x;
  24. - vc4_state->crtc_y = state->crtc_y;
  25. - vc4_state->crtc_w = state->crtc_w;
  26. - vc4_state->crtc_h = state->crtc_h;
  27. -
  28. if (state->crtc_w << 16 != state->src_w ||
  29. state->crtc_h << 16 != state->src_h) {
  30. /* We don't support scaling yet, which involves
  31. @@ -201,17 +198,25 @@ static int vc4_plane_setup_clipping_and_
  32. return -EINVAL;
  33. }
  34. + vc4_state->src_w = state->src_w >> 16;
  35. + vc4_state->src_h = state->src_h >> 16;
  36. +
  37. + vc4_state->crtc_x = state->crtc_x;
  38. + vc4_state->crtc_y = state->crtc_y;
  39. + vc4_state->crtc_w = state->crtc_w;
  40. + vc4_state->crtc_h = state->crtc_h;
  41. +
  42. if (vc4_state->crtc_x < 0) {
  43. vc4_state->offset += (drm_format_plane_cpp(fb->pixel_format,
  44. 0) *
  45. -vc4_state->crtc_x);
  46. - vc4_state->crtc_w += vc4_state->crtc_x;
  47. + vc4_state->src_w += vc4_state->crtc_x;
  48. vc4_state->crtc_x = 0;
  49. }
  50. if (vc4_state->crtc_y < 0) {
  51. vc4_state->offset += fb->pitches[0] * -vc4_state->crtc_y;
  52. - vc4_state->crtc_h += vc4_state->crtc_y;
  53. + vc4_state->src_h += vc4_state->crtc_y;
  54. vc4_state->crtc_y = 0;
  55. }
  56. @@ -260,8 +265,8 @@ static int vc4_plane_mode_set(struct drm
  57. SCALER_POS2_ALPHA_MODE_PIPELINE :
  58. SCALER_POS2_ALPHA_MODE_FIXED,
  59. SCALER_POS2_ALPHA_MODE) |
  60. - VC4_SET_FIELD(vc4_state->crtc_w, SCALER_POS2_WIDTH) |
  61. - VC4_SET_FIELD(vc4_state->crtc_h, SCALER_POS2_HEIGHT));
  62. + VC4_SET_FIELD(vc4_state->src_w, SCALER_POS2_WIDTH) |
  63. + VC4_SET_FIELD(vc4_state->src_h, SCALER_POS2_HEIGHT));
  64. /* Position Word 3: Context. Written by the HVS. */
  65. vc4_dlist_write(vc4_state, 0xc0c0c0c0);