From patchwork Thu Sep 8 22:11:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Jiang X-Patchwork-Id: 1129362 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p88AD9Xt026772 for ; Thu, 8 Sep 2011 10:13:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758194Ab1IHKNH (ORCPT ); Thu, 8 Sep 2011 06:13:07 -0400 Received: from ch1ehsobe004.messaging.microsoft.com ([216.32.181.184]:15489 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758189Ab1IHKNG (ORCPT ); Thu, 8 Sep 2011 06:13:06 -0400 Received: from mail118-ch1-R.bigfish.com (216.32.181.171) by CH1EHSOBE018.bigfish.com (10.43.70.68) with Microsoft SMTP Server id 14.1.225.22; Thu, 8 Sep 2011 10:13:04 +0000 Received: from mail118-ch1 (localhost.localdomain [127.0.0.1]) by mail118-ch1-R.bigfish.com (Postfix) with ESMTP id D59272E009A; Thu, 8 Sep 2011 10:13:04 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzz8275bhz2ei87h2a8h668h839h63h) X-Spam-TCS-SCL: 2:0 X-Forefront-Antispam-Report: CIP:137.71.25.57; KIP:(null); UIP:(null); IPVD:NLI; H:nwd2mta2.analog.com; RD:nwd2mail11.analog.com; EFVD:NLI Received-SPF: neutral (mail118-ch1: 137.71.25.57 is neither permitted nor denied by domain of gmail.com) client-ip=137.71.25.57; envelope-from=scott.jiang.linux@gmail.com; helo=nwd2mta2.analog.com ; 2.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail118-ch1 (localhost.localdomain [127.0.0.1]) by mail118-ch1 (MessageSwitch) id 1315476784649115_17816; Thu, 8 Sep 2011 10:13:04 +0000 (UTC) Received: from CH1EHSMHS031.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.245]) by mail118-ch1.bigfish.com (Postfix) with ESMTP id 83CF21920055; Thu, 8 Sep 2011 10:13:04 +0000 (UTC) Received: from nwd2mta2.analog.com (137.71.25.57) by CH1EHSMHS031.bigfish.com (10.43.70.31) with Microsoft SMTP Server (TLS) id 14.1.225.22; Thu, 8 Sep 2011 10:12:59 +0000 Received: from NWD2HUBCAS2.ad.analog.com (nwd2hubcas2.ad.analog.com [10.64.73.30]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id p88AR36X009450 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 8 Sep 2011 06:27:03 -0400 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS2.ad.analog.com (10.64.73.30) with Microsoft SMTP Server id 8.3.83.0; Thu, 8 Sep 2011 06:12:40 -0400 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.1/8.14.1) with ESMTP id p88ACuC6025177; Thu, 8 Sep 2011 06:12:56 -0400 (EDT) Received: from localhost.localdomain (unknown [10.99.24.69]) by linux.site (Postfix) with ESMTP id 6626E41F7143; Wed, 7 Sep 2011 20:28:52 -0600 (MDT) From: Scott Jiang To: Hans Verkuil , Marek Szyprowski CC: , , Scott Jiang Subject: [PATCH] v4l2: add vb2_get_unmapped_area in vb2 core Date: Thu, 8 Sep 2011 18:11:32 -0400 Message-ID: <1315519892-15641-1-git-send-email-scott.jiang.linux@gmail.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 08 Sep 2011 10:13:10 +0000 (UTC) no mmu system needs get_unmapped_area file operations to do mmap Signed-off-by: Scott Jiang --- drivers/media/video/videobuf2-core.c | 31 +++++++++++++++++++++++++++++++ include/media/videobuf2-core.h | 7 +++++++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 3015e60..02a0ec6 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -1344,6 +1344,37 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) } EXPORT_SYMBOL_GPL(vb2_mmap); +#ifndef CONFIG_MMU +unsigned long vb2_get_unmapped_area(struct vb2_queue *q, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags) +{ + unsigned long off = pgoff << PAGE_SHIFT; + struct vb2_buffer *vb; + unsigned int buffer, plane; + int ret; + + if (q->memory != V4L2_MEMORY_MMAP) { + dprintk(1, "Queue is not currently set up for mmap\n"); + return -EINVAL; + } + + /* + * Find the plane corresponding to the offset passed by userspace. + */ + ret = __find_plane_by_offset(q, off, &buffer, &plane); + if (ret) + return ret; + + vb = q->bufs[buffer]; + + return (unsigned long)vb2_plane_vaddr(vb, plane); +} +EXPORT_SYMBOL_GPL(vb2_get_unmapped_area); +#endif + static int __vb2_init_fileio(struct vb2_queue *q, int read); static int __vb2_cleanup_fileio(struct vb2_queue *q); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index f87472a..5c7b5b4 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -302,6 +302,13 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type); int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type); int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); +#ifndef CONFIG_MMU +unsigned long vb2_get_unmapped_area(struct vb2_queue *q, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags); +#endif unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait); size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblock);