Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2869353imm; Mon, 16 Jul 2018 16:04:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc5shXzIbWV6HZO8JTlEk3M1ylylWBnhBD1y6uo0boIdZdEZubXr/5kaBg/wK3dDckE6Z/n X-Received: by 2002:a63:4763:: with SMTP id w35-v6mr16979129pgk.140.1531782265545; Mon, 16 Jul 2018 16:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531782265; cv=none; d=google.com; s=arc-20160816; b=Aeev4iOIXgFWWQn56bWVHVG3he+PtdacUXf/GeWVGeyMOKjISfUqv01UbP7WzxYEPo lTe/4ajpCuvX0AbPl5vlhbrk8jx7Yz4sx0U2gAmzbr9oxhmFoGWoLttNsOFMqahI5d5J bpjusNh98rBK/FSXGPqVnpw7Aj4ytRRqO1hh6WtTPS7vGYG5XtZDz9FtZ8LNt1tR15WY JQqgv/OG0h5zVcZ7k5nKHUPdwVhspHXHtuWNtd432IJ5JO74+/vAoC07Va8j+RTG6F33 mr8nwHemmAe5l2JxoX+EhX/UiaqJQoEDzTbHv6T423tXPzoOO9pMMRMBElNTvcRfNQ+F hN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=vfC0slHfjJ/bG581+iAy+InJEd/e/sJMf57IPi8PysU=; b=PdQmN6dfpxluTerUOSB6J+XHwAFGod4HBho7kxtldPHEN0BwXF9Jy5eNGZZO8CZ6pV eu15jJztIGT827pdnrnHzfM8fYj8sPSmw6Ua6AN727AwJ7K2dnUssg6iRLbW8qOLVL23 Q8/ulO633zslCrhsWbqn45B8IIxYrmur0WoFCtK4BLLX9dCwxWI344ThpKmWhweSaBh8 P7ukBx0ybEuaI/UEpt9QMsQEKujJQA3z6f9PT06LefVADHraiDGltagGmRVBL7CLzIk+ dHcQ8Sc/lCUgtd1btAsv9rAVcTYJqwvteKvz/vAMhDLcMzPpJxEIb50Hp2DdM+1HCw6V u70g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@googlemail.com header.s=20161025 header.b=IY7cxvV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6-v6si22020813pgv.508.2018.07.16.16.04.10; Mon, 16 Jul 2018 16:04:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@googlemail.com header.s=20161025 header.b=IY7cxvV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbeGPXc7 (ORCPT + 99 others); Mon, 16 Jul 2018 19:32:59 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46739 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729350AbeGPXc7 (ORCPT ); Mon, 16 Jul 2018 19:32:59 -0400 Received: by mail-wr1-f65.google.com with SMTP id s11-v6so33464821wra.13; Mon, 16 Jul 2018 16:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vfC0slHfjJ/bG581+iAy+InJEd/e/sJMf57IPi8PysU=; b=IY7cxvV1EX9Z0q8Ij+XasGV4mEs7GCJOTU3Sb5IbDSS9tLcRfg3n+2qIkWIeTIsugW mPukaCYpenaIoQKay9xEZZUeaNwF73cludig/WbujXko0iNQZ6M90btaJ2pfp79v426A SJPHXD+eTF6g9SNJPh5vZ+hS7thWXRaVyhpsUgz4z76FhCjMo55VEwvsbS3g95chwJjs PlksGxlblTv9Dagyk80WUtfbMM0hMwGczSIs0kMdF3zB1dg3O4c0cvx6Fxy1jTwzd0Jq BQKNDktFrn2RCZfQMQOow69UXwDmPX/1Jb8h30rNZkJ2gKiIRLPUXAhYGax+8WggXKin wKxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vfC0slHfjJ/bG581+iAy+InJEd/e/sJMf57IPi8PysU=; b=lFiw0Ty/pNp+G07KvgBp/hn3sT7aXAcliJbKvsYGMDxgfgiaPGftLF8LGbwYK9MpBu Gig4LmnjTh8Py5Av73H1k83Bi3oSm6RBNvMoD00bJMRfCc4o8JFTKrEqqhAWf0g19rPw zkRiyH8ddmp8AO7WfvZLU7hIDe8PG+g1uNberJDltfcWYcMQemZxiQck59gS/szyZlf9 Cc6Jp33g8nYtp2rzHw2b+PXf10vS6UDvWK0KIier6SJ9LKTagqTUoRc8TqNvqEPxBQXv yUKirL0TX4D2L1CQgO4oHfMYYGPsr9k8I8+dtLV3S/b/2FlZUvUWJJaPNXgu+HlFG2HR d8tw== X-Gm-Message-State: AOUpUlE/ZVoS6OcbMe3Mxtvr9kDtFlGqASxLADgJzeNCuPGPHgMKGiIS jAJvypw5WeVOHGh5A+tAew7Jf8S4 X-Received: by 2002:adf:bc03:: with SMTP id s3-v6mr14390615wrg.211.1531782203104; Mon, 16 Jul 2018 16:03:23 -0700 (PDT) Received: from homedesk.Speedport_W_724V_09011603_05_013 (p2003006B0F046B23B14570EF68C4BDBB.dip0.t-ipconnect.de. [2003:6b:f04:6b23:b145:70ef:68c4:bdbb]) by smtp.gmail.com with ESMTPSA id u135-v6sm15324761wmf.2.2018.07.16.16.03.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 16:03:22 -0700 (PDT) From: Carsten Behling X-Google-Original-From: Carsten Behling Cc: Carsten Behling , Rob Clark , David Airlie , Archit Taneja , Sean Paul , Daniel Vetter , Maarten Lankhorst , Steve Kowalik , Viresh Kumar , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/msm/display: negative x/y in cursor move Date: Tue, 17 Jul 2018 01:03:11 +0200 Message-Id: <20180716230314.3527-1-carsten.behling@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <201807170504.KBRX6Bew%fengguang.wu@intel.com> References: <201807170504.KBRX6Bew%fengguang.wu@intel.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org modesetting X11 driver may provide negative x/y cordinates in mdp5_crtc_cursor_move call when rotation is enabled. Cursor buffer can overlap down to its negative width/height. ROI has to be recalculated for negative x/y indicating using the lower/right corner of the cursor buffer and hotspot must be set in MDP5_LM_CURSOR_XY_SRC_Y MDP5_LM_CURSOR_XY_SRC_X. Signed-off-by: Carsten Behling --- Changes in v2: - fixed format specifier in debug message drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 51 ++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c index 10271359789e..a7f4a6688fec 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c @@ -65,7 +65,7 @@ struct mdp5_crtc { struct drm_gem_object *scanout_bo; uint64_t iova; uint32_t width, height; - uint32_t x, y; + int x, y; } cursor; }; #define to_mdp5_crtc(x) container_of(x, struct mdp5_crtc, base) @@ -760,20 +760,31 @@ static void get_roi(struct drm_crtc *crtc, uint32_t *roi_w, uint32_t *roi_h) * Cursor Region Of Interest (ROI) is a plane read from cursor * buffer to render. The ROI region is determined by the visibility of * the cursor point. In the default Cursor image the cursor point will - * be at the top left of the cursor image, unless it is specified - * otherwise using hotspot feature. + * be at the top left of the cursor image. * + * Without rotation: * If the cursor point reaches the right (xres - x < cursor.width) or * bottom (yres - y < cursor.height) boundary of the screen, then ROI * width and ROI height need to be evaluated to crop the cursor image * accordingly. * (xres-x) will be new cursor width when x > (xres - cursor.width) * (yres-y) will be new cursor height when y > (yres - cursor.height) + * + * With rotation: + * We get negative x and/or y coordinates. + * (cursor.width - abs(x)) will be new cursor width when x < 0 + * (cursor.height - abs(y)) will be new cursor width when y < 0 */ - *roi_w = min(mdp5_crtc->cursor.width, xres - + if (mdp5_crtc->cursor.x >= 0) + *roi_w = min(mdp5_crtc->cursor.width, xres - mdp5_crtc->cursor.x); - *roi_h = min(mdp5_crtc->cursor.height, yres - + else + *roi_w = mdp5_crtc->cursor.width - abs(mdp5_crtc->cursor.x); + if (mdp5_crtc->cursor.y >= 0) + *roi_h = min(mdp5_crtc->cursor.height, yres - mdp5_crtc->cursor.y); + else + *roi_h = mdp5_crtc->cursor.height - abs(mdp5_crtc->cursor.y); } static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc) @@ -783,7 +794,7 @@ static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc) struct mdp5_kms *mdp5_kms = get_kms(crtc); const enum mdp5_cursor_alpha cur_alpha = CURSOR_ALPHA_PER_PIXEL; uint32_t blendcfg, stride; - uint32_t x, y, width, height; + uint32_t x, y, src_x, src_y, width, height; uint32_t roi_w, roi_h; int lm; @@ -800,6 +811,26 @@ static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc) get_roi(crtc, &roi_w, &roi_h); + /* If cusror buffer overlaps due to rotation on the + * upper or left screen border the pixel offset inside + * the cursor buffer of the ROI is the positive overlap + * distance. + */ + if (mdp5_crtc->cursor.x < 0) { + src_x = abs(mdp5_crtc->cursor.x); + x = 0; + } else { + src_x = 0; + } + if (mdp5_crtc->cursor.y < 0) { + src_y = abs(mdp5_crtc->cursor.y); + y = 0; + } else { + src_y = 0; + } + DBG("%s: x=%u, y=%u roi_w=%u roi_h=%u src_x=%u src_y=%u", + crtc->name, x, y, roi_w, roi_h, src_x, src_y); + mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_STRIDE(lm), stride); mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_FORMAT(lm), MDP5_LM_CURSOR_FORMAT_FORMAT(CURSOR_FMT_ARGB8888)); @@ -812,6 +843,9 @@ static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc) mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_START_XY(lm), MDP5_LM_CURSOR_START_XY_Y_START(y) | MDP5_LM_CURSOR_START_XY_X_START(x)); + mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_XY(lm), + MDP5_LM_CURSOR_XY_SRC_Y(src_y) | + MDP5_LM_CURSOR_XY_SRC_X(src_x)); mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_BASE_ADDR(lm), mdp5_crtc->cursor.iova); @@ -932,8 +966,9 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) if (unlikely(!crtc->state->enable)) return 0; - mdp5_crtc->cursor.x = x = max(x, 0); - mdp5_crtc->cursor.y = y = max(y, 0); + /* accept negative x/y coordinates up to maximum cursor overlap */ + mdp5_crtc->cursor.x = x = max(x, -(int)mdp5_crtc->cursor.width); + mdp5_crtc->cursor.y = y = max(y, -(int)mdp5_crtc->cursor.height); get_roi(crtc, &roi_w, &roi_h); -- 2.14.1