From patchwork Thu Jun 26 01:05:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 4425211 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B2BA99F2C8 for ; Thu, 26 Jun 2014 01:08:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA0D72037B for ; Thu, 26 Jun 2014 01:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAD5520377 for ; Thu, 26 Jun 2014 01:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932397AbaFZBIE (ORCPT ); Wed, 25 Jun 2014 21:08:04 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:41501 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932176AbaFZBH2 (ORCPT ); Wed, 25 Jun 2014 21:07:28 -0400 Received: by mail-pb0-f45.google.com with SMTP id rr13so2399616pbb.18 for ; Wed, 25 Jun 2014 18:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T7GfZI7nNDYOATU8T058AX5Qxe/r/lon0uQdShje2+k=; b=01yxUHoe+QZ5ZKnRWF1pUTrRFY/dCzlJxc1v5UOEoYE1xObEYhbP1iyL9CZlUaZkkr aymkA5Jy33u21fwQYC9/NgXRh9NjoSD4gouDNvmVPVMp+G1uD9QDboDJZSpu+IxND1lZ MetUQwNA32LPWg3UyM/st0QAMjm4eWg3UMzHovUxj2lvm2Nr6QaNg4qWFcWRwzElSFnv GykwUn66sdE1UnNoJ8ZT6+zerOFECzZzJd4BfUFS03XKuS+ylV2/sz3jLP/356hMQIWL 9+3pGUlnJRwOdXuRmm6jJSNkVMl4jkYlK1B66B49M5ZDTAkCLuNOA8Ua2rmYtRFoPyZT ArrA== X-Received: by 10.66.158.10 with SMTP id wq10mr17013065pab.32.1403744848013; Wed, 25 Jun 2014 18:07:28 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id gg3sm7139010pbc.34.2014.06.25.18.07.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Jun 2014 18:07:27 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 16/28] gpu: ipu-v3: Add ipu_stride_to_bytes() Date: Wed, 25 Jun 2014 18:05:43 -0700 Message-Id: <1403744755-24944-17-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1403744755-24944-1-git-send-email-steve_longerbeam@mentor.com> References: <1403744755-24944-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds ipu_stride_to_bytes(), which converts a pixel stride to bytes, suitable for passing to cpmem. Signed-off-by: Steve Longerbeam --- drivers/gpu/ipu-v3/ipu-common.c | 30 ++++++++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 7701974..30afef4 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -576,6 +576,36 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code) } EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace); +int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) +{ + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + /* + * for the planar YUV formats, the stride passed to + * cpmem must be the stride in bytes of the Y plane. + * And all the planar YUV formats have an 8-bit + * Y component. + */ + return (8 * pixel_stride) >> 3; + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + return (16 * pixel_stride) >> 3; + case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_RGB24: + return (24 * pixel_stride) >> 3; + case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_RGB32: + return (32 * pixel_stride) >> 3; + default: + break; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(ipu_stride_to_bytes); + int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip) { diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index 9ed1c75..17a0bb8 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -480,6 +480,7 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem, enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code); +int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat); bool ipu_pixelformat_is_planar(u32 pixelformat); int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip);