From patchwork Thu Jun 14 13:37:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 9294 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6CF0823E1B for ; Thu, 14 Jun 2012 13:38:34 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3C66AA189DA for ; Thu, 14 Jun 2012 13:38:34 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so1434559ghb.11 for ; Thu, 14 Jun 2012 06:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :in-reply-to:to:message-id:x-mailer:references:x-tm-as-mml:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:sender :errors-to:x-gm-message-state; bh=bIjacF2QigIJu2Lo0GLNHTCMuUzYPEohiO2iPfRJPjA=; b=mVGAMfldBHMaSBMJ1M4wyXKCEN+i7a7VrtKxu8X5gpva0dw4kW6jlYTilif1V848iE IjUGybFjAboY66QJQR/4C2su+NOM5wGO6PeRsb8nsUUb1QIJtBvyMRfs5ltwJ857TlGA n53bbsUYBkzO7B2VjeUuJXJiskdOUVQ5PZSAS+1A97+aL4gnp20Prg2ed1PvKLEgyEnV 0QyMPBY5BGSlg8KVVsluA160p8EwGa8p3mp2WJOQ5FgbPNTkP4PDxd+LK8IdV6uNXG/x 9OJ6CIytGsBV5kUWY394wzn7Iqg+IUPhmXo6IRS5ob9BYslEQ/H+B5Hsi1b32gccmEGb 9VJw== Received: by 10.50.87.227 with SMTP id bb3mr767878igb.57.1339681113933; Thu, 14 Jun 2012 06:38:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp85273ibb; Thu, 14 Jun 2012 06:38:30 -0700 (PDT) Received: by 10.204.156.155 with SMTP id x27mr1096194bkw.84.1339681109026; Thu, 14 Jun 2012 06:38:29 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id hg14si4968652bkc.4.2012.06.14.06.38.27; Thu, 14 Jun 2012 06:38:28 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SfAFm-0006wN-JE; Thu, 14 Jun 2012 13:38:26 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SfAFZ-0006q9-TP for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 13:38:13 +0000 Received: from euspt1 (mailout2.w1.samsung.com [210.118.77.12]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M5M001HY0KH0S60@mailout2.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 14:38:41 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M5M00IO20JMBI@spt1.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 14 Jun 2012 14:38:10 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id 6E2E427016D; Thu, 14 Jun 2012 15:42:38 +0200 (CEST) Date: Thu, 14 Jun 2012 15:37:44 +0200 From: Tomasz Stanislawski In-reply-to: <1339681069-8483-1-git-send-email-t.stanislaws@samsung.com> To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Message-id: <1339681069-8483-11-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 References: <1339681069-8483-1-git-send-email-t.stanislaws@samsung.com> X-TM-AS-MML: No Cc: pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCHv7 10/15] v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQlTfDWwSzPCEXDVP8APbhJHa9poGSMg2PrZVfhsSt2YE6tEHUoNoRWflFQNWC7AJqsPyEfd From: Marek Szyprowski Add prepare/finish callbacks to vb2-dma-contig allocator. Signed-off-by: Marek Szyprowski Acked-by: Laurent Pinchart --- drivers/media/video/videobuf2-dma-contig.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 94f0874..f9286d7 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -103,6 +103,28 @@ static unsigned int vb2_dc_num_users(void *buf_priv) return atomic_read(&buf->refcount); } +static void vb2_dc_prepare(void *buf_priv) +{ + struct vb2_dc_buf *buf = buf_priv; + struct sg_table *sgt = buf->dma_sgt; + + if (!sgt) + return; + + dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); +} + +static void vb2_dc_finish(void *buf_priv) +{ + struct vb2_dc_buf *buf = buf_priv; + struct sg_table *sgt = buf->dma_sgt; + + if (!sgt) + return; + + dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); +} + /*********************************************/ /* callbacks for MMAP buffers */ /*********************************************/ @@ -369,6 +391,8 @@ const struct vb2_mem_ops vb2_dma_contig_memops = { .mmap = vb2_dc_mmap, .get_userptr = vb2_dc_get_userptr, .put_userptr = vb2_dc_put_userptr, + .prepare = vb2_dc_prepare, + .finish = vb2_dc_finish, .num_users = vb2_dc_num_users, }; EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);