From patchwork Wed Jan 4 09:12:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 89789 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8399193qgi; Wed, 4 Jan 2017 01:13:16 -0800 (PST) X-Received: by 10.84.218.197 with SMTP id g5mr144432563plm.173.1483521196913; Wed, 04 Jan 2017 01:13:16 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id w190si71903059pfb.30.2017.01.04.01.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2017 01:13:16 -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 311F46E6B4; Wed, 4 Jan 2017 09:13:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32FEE6E6B2 for ; Wed, 4 Jan 2017 09:13:11 +0000 (UTC) Received: by mail-wm0-x22b.google.com with SMTP id k184so255158463wme.1 for ; Wed, 04 Jan 2017 01:13:11 -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=ASnYFXbO9BXLVL/2LwgTkdlP8Mmeq1hKATAWJsoYPjA=; b=Dx1fJNDnCszvFmTER5lkpeKypg5LLaVHp9vyoJYTxV6XE9M9MGb0wP4wT3ln8Mkr5r xptbYACaKqtDs/o567W3bvIyp+vOSt9RoziYk78eZjo8AQ3+/KCG6cHBGY2DrYKvgqxW 98cJr2W207lV7IU78GSD2hBpxFFpEuZsZrb+8= 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=ASnYFXbO9BXLVL/2LwgTkdlP8Mmeq1hKATAWJsoYPjA=; b=fFnwyVizcgmby2bp5LSLDY8nItJV7WrFcPRUDGGc+Kf5FDrcKlsoIUedPboNHBOMhZ xD4i9YAubIoOqQoqkoGhVSppwx8czKOw+Ar7IHGEKzeLddwIsOf6kv1WvXuhKY4CJC18 dSXz/G11Sza4rnD9LfnPytxr2fYbOHAaXzq5E/NcRRbHzjJxIfgDdAgks7EGNI9dOEaD Y7ADwxd/WU/+zXGD2AavIQczzgWUT8dFruErnD6xiqEvixsK4w+AjLI7hzzrzmBMFzeL Wgbrxz88IGUKBhBmq3X4ipByF7DGb/BGH70YaxyGWIqtMoFpTZeKVeyplzRJPE+gMmUx SYLg== X-Gm-Message-State: AIkVDXLtN9ku9WGvsdL1Q5Z+WOkybtf3dh/Mn9TjVFgJADqD7zCofVog3qCX8Zzm6K4wuBQv X-Received: by 10.28.191.219 with SMTP id o88mr52519416wmi.30.1483521189414; Wed, 04 Jan 2017 01:13:09 -0800 (PST) Received: from lmenx321.st.com. ([80.214.127.177]) by smtp.gmail.com with ESMTPSA id i10sm97411895wjd.15.2017.01.04.01.13.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jan 2017 01:13:09 -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 v5 1/3] fbmem: add a default get_fb_unmapped_area function Date: Wed, 4 Jan 2017 10:12:55 +0100 Message-Id: <1483521177-21794-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483521177-21794-1-git-send-email-benjamin.gaignard@linaro.org> References: <1483521177-21794-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 5: - set get_unmapped_area field if FB_PROVIDE_GET_FB_UNMAPPED_AREA is defined 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 | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) 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..069fe79 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, @@ -1503,7 +1518,8 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, .mmap = fb_mmap, .open = fb_open, .release = fb_release, -#ifdef HAVE_ARCH_FB_UNMAPPED_AREA +#if defined(HAVE_ARCH_FB_UNMAPPED_AREA) || \ + defined(CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA) .get_unmapped_area = get_fb_unmapped_area, #endif #ifdef CONFIG_FB_DEFERRED_IO