From patchwork Thu Jul 7 12:21:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amber Jain X-Patchwork-Id: 7412 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Thu, 07 Jul 2011 12:52:43 -0300 Received: from mchehab by infradead.org with local (Exim 4.72) (envelope-from ) id 1Qeqsc-00067V-9n for mchehab@infradead.org; Thu, 07 Jul 2011 12:52:43 -0300 Received: from casper.infradead.org [85.118.1.10] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Thu, 07 Jul 2011 12:52:42 -0300 (BRT) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QeqqO-0002wy-HM for mchehab@casper.infradead.org; Thu, 07 Jul 2011 15:50:27 +0000 Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QenjK-0003Ap-Nt; Thu, 07 Jul 2011 12:30:54 +0000 Received: from vger.kernel.org ([209.132.180.67]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qenig-0002IV-A3; Thu, 07 Jul 2011 12:30:14 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756215Ab1GGMVb (ORCPT + 1 other); Thu, 7 Jul 2011 08:21:31 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:35408 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755675Ab1GGMVa (ORCPT ); Thu, 7 Jul 2011 08:21:30 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p67CLTMq022123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 07:21:29 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep33.itg.ti.com (8.13.7/8.13.8) with ESMTP id p67CLT5m006865 for ; Thu, 7 Jul 2011 07:21:29 -0500 (CDT) Received: from dlee74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p67CLThY007588 for ; Thu, 7 Jul 2011 07:21:29 -0500 (CDT) Received: from dlelxv23.itg.ti.com (172.17.1.198) by dlee74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 8.3.106.1; Thu, 7 Jul 2011 07:21:29 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id p67CLTrg027429; Thu, 7 Jul 2011 07:21:29 -0500 Received: from localhost (a0393674u.apr.dhcp.ti.com [172.24.137.179]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id p67CLRf14400; Thu, 7 Jul 2011 07:21:27 -0500 (CDT) From: Amber Jain To: CC: hvaibhav@ti.com, Amber Jain Subject: [PATCH v2 2/3] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf Date: Thu, 7 Jul 2011 17:51:17 +0530 Message-ID: <1310041278-8810-3-git-send-email-amber@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1310041278-8810-1-git-send-email-amber@ti.com> References: <1310041278-8810-1-git-send-email-amber@ti.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_165024_884725_0F5BD4A7 X-CRM114-Status: GOOD ( 17.95 ) X-Spam-Score: 2.0 (++) X-Spam-Report: SpamAssassin version 3.3.2-r929478 on casper.infradead.org summary: Content analysis details: (2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.8 KB_DATE_CONTAINS_TAB KB_DATE_CONTAINS_TAB 1.2 TAB_IN_FROM From starts with a tab -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: Add support to map the buffer using dma_map_single during qbuf which inturn calls cache flush and unmap the same during dqbuf. This is done to prevent the artifacts seen because of cache-coherency issues on OMAP4 Signed-off-by: Amber Jain --- Changes from v1: - Changed the definition of address variables to be u32 instead of int. - Removed extra typedef for size variable. drivers/media/video/omap/omap_vout.c | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c index 6cd3622..7d3410a 100644 --- a/drivers/media/video/omap/omap_vout.c +++ b/drivers/media/video/omap/omap_vout.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -778,6 +779,17 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q, vout->queued_buf_addr[vb->i] = (u8 *) omap_vout_uservirt_to_phys(vb->baddr); } else { + u32 addr, dma_addr; + unsigned long size; + + addr = (unsigned long) vout->buf_virt_addr[vb->i]; + size = (unsigned long) vb->size; + + dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr, + size, DMA_TO_DEVICE); + if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr)) + v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single failed\n"); + vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i]; } @@ -1567,15 +1579,28 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) struct omap_vout_device *vout = fh; struct videobuf_queue *q = &vout->vbq; + int ret; + u32 addr; + unsigned long size; + struct videobuf_buffer *vb; + + vb = q->bufs[b->index]; + if (!vout->streaming) return -EINVAL; if (file->f_flags & O_NONBLOCK) /* Call videobuf_dqbuf for non blocking mode */ - return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1); + ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1); else /* Call videobuf_dqbuf for blocking mode */ - return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0); + ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0); + + addr = (unsigned long) vout->buf_phy_addr[vb->i]; + size = (unsigned long) vb->size; + dma_unmap_single(vout->vid_dev->v4l2_dev.dev, addr, + size, DMA_TO_DEVICE); + return ret; } static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)