From patchwork Wed Dec 7 10:06:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 86992 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp233359qgi; Wed, 7 Dec 2016 02:08:15 -0800 (PST) X-Received: by 10.99.120.13 with SMTP id t13mr116545273pgc.17.1481105294976; Wed, 07 Dec 2016 02:08:14 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id u25si13492825pge.31.2016.12.07.02.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 02:08:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 900796E526; Wed, 7 Dec 2016 10:08:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id 348296E18F for ; Wed, 7 Dec 2016 10:07:59 +0000 (UTC) Received: by mail-wm0-x232.google.com with SMTP id t79so158173469wmt.0 for ; Wed, 07 Dec 2016 02:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oxiCMIOpq2Npwd4LT5NO8z332Xl+l9CgEejK8bKGb4k=; b=JqkLnZejSUvV3LWC0/M1Y+Xl/Or2tZhvfzUeMcGAEov/8MPYtCS3v3IAkRgw/aElOA sD+f5+77V+wjiikFH3ueFSkI/RGr8UCQYnrvpKfgoTNAJjAJOWHFUT6qEuaWD31I80gj bI1X4DFy5SmEsJQbqZLYvwvfyMRbb+IzqwPkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oxiCMIOpq2Npwd4LT5NO8z332Xl+l9CgEejK8bKGb4k=; b=TuxzCkG4sc2kZ/4+3Kh8DbXYzwZ5CVmLX7GuRAzR29OKCmlHCJQDQLgJxyNnz5Cks/ ABdVU4uD3PuYjzv90/epX3d0xHgJYxUVzS+KxkRGyxXEox0Q6lmM7/77d2H0iD86nsHp Sk4Ci/Y6jq5BqYjMbmXzScCIri2r0kZOtXzjBSsDLv1ZSdBOwdxefkbEkxC/TkjbC+qo vKt7AgvRPLCT1Ly6oK+NOWaJBuIHneBf56knAYLFa33fjS5b8jd3kdzToweTWB+jAps+ wKUfU5P1ZzYNXcmiFUVKsckjHYmN+1PIgTpD0fzGCoMN+N8D87L4VZyrx1UFiZZD2ZbG d1kA== X-Gm-Message-State: AKaTC02z+GSJ3BCzY4GT7ySxP5zeSyKD9kzztbERlpv18FbJNu+4pcEH9e17hxU7xQlM4OkY X-Received: by 10.28.73.136 with SMTP id w130mr1728864wma.82.1481105277580; Wed, 07 Dec 2016 02:07:57 -0800 (PST) Received: from lmenx321.st.com. ([80.215.165.156]) by smtp.gmail.com with ESMTPSA id x140sm8748561wme.19.2016.12.07.02.07.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 02:07:56 -0800 (PST) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, airlied@redhat.com, daniel@ffwll.ch, laurent.pinchart@ideasonboard.com, michel@daenzer.net Subject: [PATCH v4 2/4] fbmem: add a default get_fb_unmapped_area function Date: Wed, 7 Dec 2016 11:06:49 +0100 Message-Id: <1481105211-18020-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481105211-18020-1-git-send-email-benjamin.gaignard@linaro.org> References: <1481105211-18020-1-git-send-email-benjamin.gaignard@linaro.org> Cc: yannick.fertre@st.com, linaro-kernel@lists.linaro.org, philippe.cornu@st.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Allow generic frame-buffer to provide a default get_fb_unmapped_area function if specific devices need it. Usually this function is defined in architecture directories but define it here may limit code duplication especially for all ARM platforms without MMU. version 4: - introdude a configuration flag to be independent of architecture Signed-off-by: Benjamin Gaignard --- drivers/video/fbdev/Kconfig | 8 ++++++++ drivers/video/fbdev/core/fbmem.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 5d3b0db..922e4ea 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -138,6 +138,14 @@ config FB_SYS_IMAGEBLIT blitting. This is used by drivers that don't provide their own (accelerated) version and the framebuffer is in system RAM. +config FB_PROVIDE_GET_FB_UNMAPPED_AREA + bool + depends on FB + default n + ---help--- + Allow generic frame-buffer to provide get_fb_unmapped_area + function. + menuconfig FB_FOREIGN_ENDIAN bool "Framebuffer foreign endianness support" depends on FB diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 76c1ad9..22321a2 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1492,6 +1492,21 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, return 0; } +#ifdef CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA +unsigned long get_fb_unmapped_area(struct file *filp, + unsigned long addr, unsigned long len, + unsigned long pgoff, unsigned long flags) +{ + struct fb_info * const info = filp->private_data; + unsigned long fb_size = PAGE_ALIGN(info->fix.smem_len); + + if (pgoff > fb_size || len > fb_size - pgoff) + return -EINVAL; + + return (unsigned long)info->screen_base + pgoff; +} +#endif + static const struct file_operations fb_fops = { .owner = THIS_MODULE, .read = fb_read,