@@ -138,7 +138,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
int max_scale,
bool can_position,
bool can_update_disabled,
- bool *visible)
+ bool *visible,
+ unsigned int rotation)
{
int hscale, vscale;
@@ -158,9 +159,13 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
return -EINVAL;
}
+ if (fb)
+ drm_rect_rotate(src, fb->width << 16, fb->height << 16,
+ rotation);
+
/* Check scaling */
- hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
- vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
+ hscale = drm_rect_calc_hscale_relaxed(src, dest, min_scale, max_scale);
+ vscale = drm_rect_calc_vscale_relaxed(src, dest, min_scale, max_scale);
if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n");
return -ERANGE;
@@ -182,6 +187,36 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
return -EINVAL;
}
+ if (*visible) {
+ /* check again in case clipping clamped the results */
+ hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
+ if (hscale < 0) {
+ DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n");
+ drm_rect_debug_print(src, true);
+ drm_rect_debug_print(dest, false);
+
+ return hscale;
+ }
+
+ vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
+ if (vscale < 0) {
+ DRM_DEBUG_KMS("Vertical scaling factor out of limits\n");
+ drm_rect_debug_print(src, true);
+ drm_rect_debug_print(dest, false);
+
+ return vscale;
+ }
+
+ /* Make the source viewport size an exact multiple of the scaling factors. */
+ drm_rect_adjust_size(src,
+ drm_rect_width(dest) * hscale - drm_rect_width(src),
+ drm_rect_height(dest) * vscale - drm_rect_height(src));
+
+ drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16,
+ rotation);
+
+ }
+
return 0;
}
EXPORT_SYMBOL(drm_plane_helper_check_update);
@@ -258,7 +293,8 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
&src, &dest, &clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- false, false, &visible);
+ false, false, &visible,
+ DRM_ROTATE_0);
if (ret)
return ret;
@@ -12155,7 +12155,8 @@ intel_check_primary_plane(struct drm_plane *plane,
src, dest, clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- false, true, &state->visible);
+ false, true, &state->visible,
+ to_intel_plane(plane)->rotation);
if (ret)
return ret;
@@ -12429,7 +12430,8 @@ intel_check_cursor_plane(struct drm_plane *plane,
src, dest, clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- true, true, &state->visible);
+ true, true, &state->visible,
+ to_intel_plane(plane)->rotation);
if (ret)
return ret;
@@ -551,7 +551,8 @@ static int vop_update_plane_event(struct drm_plane *plane,
&src, &dest, &clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- can_position, false, &visible);
+ can_position, false, &visible,
+ DRM_ROTATE_0);
if (ret)
return ret;
@@ -84,7 +84,8 @@ extern int drm_plane_helper_check_update(struct drm_plane *plane,
int max_scale,
bool can_position,
bool can_update_disabled,
- bool *visible);
+ bool *visible,
+ unsigned int rotation);
extern int drm_primary_helper_update(struct drm_plane *plane,
struct drm_crtc *crtc,
struct drm_framebuffer *fb,
Taking rotation into account while checking the plane and adjusting the sizes accordingly. v2: Adding parameter in the callers in the same patch(Matt) Removing unnecessary code and allowing scaling(Ville) Signed-off-by: Sonika Jindal <sonika.jindal@intel.com> --- drivers/gpu/drm/drm_plane_helper.c | 44 ++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_display.c | 6 ++-- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +- include/drm/drm_plane_helper.h | 3 +- 4 files changed, 48 insertions(+), 8 deletions(-)