Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3214508imu; Sat, 24 Nov 2018 00:16:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vf9e01xWBeyp7sn32mf4IXevaGqZUstS7KAHwqwU9/l09ru/Nx/uxk67xqQxo5TdyfXtc3 X-Received: by 2002:a63:5a08:: with SMTP id o8mr17038636pgb.185.1543047386617; Sat, 24 Nov 2018 00:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047386; cv=none; d=google.com; s=arc-20160816; b=o6DMxcNHOw/619RGkaQmBkvtU3NRaen6FU/xaej0312in6tQZCLjUTGeyjzE2D4C9D im7gr2OexH+35QsBHDUXMKKRFXG6QXN1NX/rWBgpwVArVJatHiIkd0oNAOynx52rktOG 4J6CXo1uVhLMJAXKOJ0kGED5EYtseXWbKKMbNj10TrqCUWt6H7axmSR57klrEFw6kMpT 3uI07TOVX/TriMYFTHrDdh7ScAB+ult3OOta2ZLjJrPtlLeo4y/Ca65vVbNrEpUvyclA wgqlrUFSBtikHjd/g102AOWd/gEnX9goDERfilzg1b3GN/7eM0KaGUMsI1Fbgbcoy1fS X1nw== 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=ROtS7LYUu29YHaE2ZCPLNtKDBtEAoABvtSUe06zQspc=; b=u7qxquZugSTrsZE34rH9Z1j5h88MalK+5iC8qHKEJ+NU8iFhCA8EyO1VEH+oLrJ72I 3zKhN1i1bHtvJhoC3mQIa0cpnxMjGxzuxi4pANj7gUgGeyoxFuNoFiZQDx0apaLwBvoM StENUruksgd1syvnJSCEIYTGgPOXaH5Z7y6ODDX53v6QjrBAnAP5aTfCl1EC3jHc8EOj 1kOxX66xDnSR870hhyE57G2QSrXmXe3hnN8BBntU4YOCFt2+V6BvMrm3XWq21SirBpZl 7ioaDYZbwgaMzumYdKVowsctLhAIU8n4SvFK4jB3M7/AuNRITSZEQcFwLw5V45F3aCC/ 1dYg== 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 g22si49137369pfj.222.2018.11.24.00.16.12; Sat, 24 Nov 2018 00:16:26 -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 S2502783AbeKWUK3 (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:29 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49429 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390556AbeKWUK1 (ORCPT ); Fri, 23 Nov 2018 15:10:27 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id AAD6920E13; 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 1A5CC20EB0; Fri, 23 Nov 2018 10:26:35 +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 29/43] drm/sun4i: Make pitch even for GEM dumb alloc as per hardware constraint Date: Fri, 23 Nov 2018 10:25:01 +0100 Message-Id: <20181123092515.2511-30-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 Our hardware requires the pitch to be an even number when using YUV formats with the frontend. Implement a driver-specific callback for GEM dumb allocation that sets the pitch accordingly. Since only the bpp is passed (and not the format), we cannot really distinguish if this alignment is really required. Since it doesn't hurt to align the pitch anyway, always do it. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_drv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index ef773d36baf0..ccdeae6299eb 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -28,6 +28,16 @@ #include "sun4i_tcon.h" #include "sun8i_tcon_top.h" +static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, + struct drm_device *drm, + struct drm_mode_create_dumb *args) +{ + /* The hardware only allows even pitches for YUV buffers. */ + args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), 2); + + return drm_gem_cma_dumb_create_internal(file_priv, drm, args); +} + DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops); static struct drm_driver sun4i_drv_driver = { @@ -42,7 +52,7 @@ static struct drm_driver sun4i_drv_driver = { .minor = 0, /* GEM Operations */ - .dumb_create = drm_gem_cma_dumb_create, + .dumb_create = drm_sun4i_gem_dumb_create, .gem_free_object_unlocked = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, -- 2.19.1