Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216600imu; Sat, 24 Nov 2018 00:19:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/XpY/tYOhh+MdpbwOAIRdqhiJPY098jSJ2aT4PboNHl7P6hyWzPFSETEAQV/Zfb1lSmpEKi X-Received: by 2002:a65:514c:: with SMTP id g12mr16985796pgq.169.1543047561478; Sat, 24 Nov 2018 00:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047561; cv=none; d=google.com; s=arc-20160816; b=pBalQoUcY7z4mWIhQWi3wg+5Chx25QBB5zIE1gQAoIi+wvEy3/t3jxxHep8nwGX50j 2LPRpWU3712ae9KEE1HpHQwoNAzzJtHE5BZY5rDSDa7cLEQG8laikx35qOQHRBCid8fX MWFYFWcp27xRNm6jlozFETE92Unm16TKtpXBOggRTS7SrVSpGpc2BJ6GVclK/uEU6Y/s SbuAC16lImafq3a/HUitCkVEFDfVZITd/SAhf5DJpZvKesXbpGH2tkovH2bs+Kz6F5fs pCyxrk8wM3WSG23cUhnPTAd7WrkOiInv9ZLYpANwWO9rozRAKAa7w591BJwWMTATs3Rl sovQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1vLlYOR3uHZdIAjkhRPGK48bqTBk2wZ2ydDd8Ddh4NI=; b=B4f0Ru9Onn34/hFGGscRtzzDEKmH4EJPUz/5IyH9Nl+DAnLtTK/udC4O6QCuDgpnvs rxUhX8TQrWYsPgH4YM5clbYD6dwxFjNsATwRAI1Mx7YzLR5miN8qHJtfxitMXDzJfgqc GjKTbkUnCKLKG48orQO1PATYfWa1/M8Cdt5bF4ZHhCHRL6ch1i9yslPGeCdk/2Wsx9BA mrB7bH+2IjACFMHz9YA5ubZLlUmzqug6CM7tzHt3DEmpwMcPwdKzctOhPtbzoRsLN4jg QXMoHt4R+RDtDJTP2CZCbKT7Te7bgFpg2sg1vsgAVE0YM91tCgjDpmXOXL7llBZXdahY hd3w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si34713462pgw.364.2018.11.24.00.19.07; Sat, 24 Nov 2018 00:19:21 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408922AbeKWUMJ (ORCPT + 99 others); Fri, 23 Nov 2018 15:12:09 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49420 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408926AbeKWUK3 (ORCPT ); Fri, 23 Nov 2018 15:10:29 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id F1D852160C; Fri, 23 Nov 2018 10:26:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 6F06A20F10; Fri, 23 Nov 2018 10:26:36 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski Subject: [PATCH v2 34/43] drm/sun4i: Add buffer stride and offset configuration for tiling mode Date: Fri, 23 Nov 2018 10:25:06 +0100 Message-Id: <20181123092515.2511-35-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This introduces stride and offset configuration for the VPU tiling mode. Stride is calculated differently than it is for linear formats and an offset is calculated, for which new register definitions are introduced. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_frontend.c | 54 ++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_frontend.h | 7 ++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c index efa1ff0802bd..3f76a5572449 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c @@ -125,21 +125,69 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; + unsigned int strides[3] = {}; + dma_addr_t paddr; bool swap; + if (fb->modifier == DRM_FORMAT_MOD_ALLWINNER_TILED) { + unsigned int width = state->src_w >> 16; + unsigned int offset; + + /* + * In MB32 tiled mode, the stride is defined as the distance + * between the start of the end line of the current tile and + * the start of the first line in the next vertical tile. + * + * Tiles are represented in row-major order, thus the end line + * of current tile starts at: 31 * 32 (31 lines of 32 cols), + * the next vertical tile starts at: 32-bit-aligned-width * 32 + * and the distance is: 32 * (32-bit-aligned-width - 31). + */ + + strides[0] = (fb->pitches[0] - 31) * 32; + + /* Offset of the bottom-right point in the end tile. */ + offset = (width + (32 - 1)) & (32 - 1); + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF0_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + + if (fb->format->num_planes > 1) { + strides[1] = (fb->pitches[1] - 31) * 32; + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF1_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + } + + if (fb->format->num_planes > 2) { + strides[2] = (fb->pitches[2] - 31) * 32; + + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF2_REG, + SUN4I_FRONTEND_TB_OFF_X1(offset)); + } + } else { + strides[0] = fb->pitches[0]; + + if (fb->format->num_planes > 1) + strides[1] = fb->pitches[1]; + + if (fb->format->num_planes > 2) + strides[2] = fb->pitches[2]; + } + /* Set the line width */ DRM_DEBUG_DRIVER("Frontend stride: %d bytes\n", fb->pitches[0]); regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD0_REG, - fb->pitches[0]); + strides[0]); if (fb->format->num_planes > 1) regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD1_REG, - fb->pitches[1]); + strides[1]); if (fb->format->num_planes > 2) regmap_write(frontend->regs, SUN4I_FRONTEND_LINESTRD2_REG, - fb->pitches[2]); + strides[2]); /* Some planar formats require chroma channel swapping by hand. */ swap = sun4i_frontend_format_chroma_requires_swap(fb->format->format); diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h index ae53ee644694..822d39ca4b8e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_frontend.h +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h @@ -25,6 +25,13 @@ #define SUN4I_FRONTEND_BUF_ADDR1_REG 0x024 #define SUN4I_FRONTEND_BUF_ADDR2_REG 0x028 +#define SUN4I_FRONTEND_TB_OFF0_REG 0x030 +#define SUN4I_FRONTEND_TB_OFF1_REG 0x034 +#define SUN4I_FRONTEND_TB_OFF2_REG 0x038 +#define SUN4I_FRONTEND_TB_OFF_X1(x1) ((x1) << 16) +#define SUN4I_FRONTEND_TB_OFF_Y0(y0) ((y0) << 8) +#define SUN4I_FRONTEND_TB_OFF_X0(x0) (x0) + #define SUN4I_FRONTEND_LINESTRD0_REG 0x040 #define SUN4I_FRONTEND_LINESTRD1_REG 0x044 #define SUN4I_FRONTEND_LINESTRD2_REG 0x048 -- 2.19.1