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

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