From patchwork Fri Aug 19 08:39:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9289859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB6A9600CB for ; Fri, 19 Aug 2016 08:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A18E2933C for ; Fri, 19 Aug 2016 08:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EC202933B; Fri, 19 Aug 2016 08:39:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31E1629333 for ; Fri, 19 Aug 2016 08:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755102AbcHSIjd (ORCPT ); Fri, 19 Aug 2016 04:39:33 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:51092 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755069AbcHSIjc (ORCPT ); Fri, 19 Aug 2016 04:39:32 -0400 Received: from localhost.localdomain (227.178-201-80.adsl-dyn.isp.belgacom.be [80.201.178.227]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 9EC1E208C6; Fri, 19 Aug 2016 10:39:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1471595947; bh=j3RGZ7afIwlYEmfek8BDNvJknHakbJv/KAJegrPhacs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AfEtTDwfAV7WdfuFwu3WHMaZlUGf37HittpLYVRVZT1Lj3wlvo4Ytk2Zb9We7D78i 8tS4ldtjudyDs9SHOGmwiD2m9nm0fpQHty343sarfm4BNraXpkOgvhLAojWwBaMr66 P2xquD/G3lLVc91BaPc/Iu5CH1tGhF1J2m+a2K6I= From: Laurent Pinchart To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org Subject: [PATCH 5/6] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP Date: Fri, 19 Aug 2016 11:39:33 +0300 Message-Id: <1471595974-28960-6-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1471595974-28960-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1471595974-28960-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The display buffers must be mapped for DMA through the device that performs memory access. Expose an API to map and unmap memory through the VSP device to be used by the DU. Signed-off-by: Laurent Pinchart --- drivers/media/platform/vsp1/vsp1_drm.c | 24 ++++++++++++++++++++++++ include/media/vsp1.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c index f76131b192a4..0472cb4bc2e4 100644 --- a/drivers/media/platform/vsp1/vsp1_drm.c +++ b/drivers/media/platform/vsp1/vsp1_drm.c @@ -12,9 +12,11 @@ */ #include +#include #include #include +#include #include #include @@ -521,6 +523,28 @@ void vsp1_du_atomic_flush(struct device *dev) } EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush); +int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt) +{ + struct vsp1_device *vsp1 = dev_get_drvdata(dev); + struct device *map_dev; + + map_dev = vsp1->fcp ? rcar_fcp_get_device(vsp1->fcp) : dev; + + return dma_map_sg(map_dev, sgt->sgl, sgt->nents, DMA_TO_DEVICE); +} +EXPORT_SYMBOL_GPL(vsp1_du_map_sg); + +void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt) +{ + struct vsp1_device *vsp1 = dev_get_drvdata(dev); + struct device *map_dev; + + map_dev = vsp1->fcp ? rcar_fcp_get_device(vsp1->fcp) : dev; + + dma_unmap_sg(map_dev, sgt->sgl, sgt->nents, DMA_TO_DEVICE); +} +EXPORT_SYMBOL_GPL(vsp1_du_unmap_sg); + /* ----------------------------------------------------------------------------- * Initialization */ diff --git a/include/media/vsp1.h b/include/media/vsp1.h index 458b400373d4..8d3d07a3715e 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -13,6 +13,7 @@ #ifndef __MEDIA_VSP1_H__ #define __MEDIA_VSP1_H__ +#include #include #include @@ -37,5 +38,7 @@ void vsp1_du_atomic_begin(struct device *dev); int vsp1_du_atomic_update(struct device *dev, unsigned int rpf, const struct vsp1_du_atomic_config *cfg); void vsp1_du_atomic_flush(struct device *dev); +int vsp1_du_map_sg(struct device *dev, struct sg_table *sgt); +void vsp1_du_unmap_sg(struct device *dev, struct sg_table *sgt); #endif /* __MEDIA_VSP1_H__ */