]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/rockchip: Use temporary variables
authorDaniel Stone <daniels@collabora.com>
Wed, 15 Oct 2025 11:00:34 +0000 (12:00 +0100)
committerHeiko Stuebner <heiko@sntech.de>
Mon, 20 Oct 2025 13:56:13 +0000 (15:56 +0200)
Brevity is good.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20251015110042.41273-6-daniels@collabora.com
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

index e2bf2dbd882b632d86977f4743b2350f60fae476..284c8a04803473398fe20457d65d5c03b051d3c1 100644 (file)
@@ -1003,6 +1003,8 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
        struct drm_rect *src = &pstate->src;
        int min_scale = FRAC_16_16(1, 8);
        int max_scale = FRAC_16_16(8, 1);
+       int src_x, src_w, src_h;
+       int dest_w, dest_h;
        int format;
        int ret;
 
@@ -1030,19 +1032,23 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
        if (format < 0)
                return format;
 
-       if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
-           drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) {
+       /* Co-ordinates have now been clipped */
+       src_x = src->x1 >> 16;
+       src_w = drm_rect_width(src) >> 16;
+       src_h = drm_rect_height(src) >> 16;
+       dest_w = drm_rect_width(dest);
+       dest_h = drm_rect_height(dest);
+
+       if (src_w < 4 || src_h < 4 || dest_w < 4 || dest_h < 4) {
                drm_dbg_kms(vop2->drm, "Invalid size: %dx%d->%dx%d, min size is 4x4\n",
-                           drm_rect_width(src) >> 16, drm_rect_height(src) >> 16,
-                           drm_rect_width(dest), drm_rect_height(dest));
+                           src_w, src_h, dest_w, dest_h);
                return -EINVAL;
        }
 
-       if (drm_rect_width(src) >> 16 > vop2_data->max_input.width ||
-           drm_rect_height(src) >> 16 > vop2_data->max_input.height) {
+       if (src_w > vop2_data->max_input.width ||
+           src_h > vop2_data->max_input.height) {
                drm_dbg_kms(vop2->drm, "Invalid source: %dx%d. max input: %dx%d\n",
-                           drm_rect_width(src) >> 16,
-                           drm_rect_height(src) >> 16,
+                           src_w, src_h,
                            vop2_data->max_input.width,
                            vop2_data->max_input.height);
                return -EINVAL;
@@ -1052,7 +1058,7 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
         * Src.x1 can be odd when do clip, but yuv plane start point
         * need align with 2 pixel.
         */
-       if (fb->format->is_yuv && ((pstate->src.x1 >> 16) % 2)) {
+       if (fb->format->is_yuv && src_x % 2) {
                drm_dbg_kms(vop2->drm, "Invalid Source: Yuv format not support odd xpos\n");
                return -EINVAL;
        }