From patchwork Sat Jun 7 21:56:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 4316311 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E8B5EBEEAA for ; Sat, 7 Jun 2014 21:58:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F09B20265 for ; Sat, 7 Jun 2014 21:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 670282025A for ; Sat, 7 Jun 2014 21:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbaFGV6P (ORCPT ); Sat, 7 Jun 2014 17:58:15 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:46297 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753324AbaFGV5W (ORCPT ); Sat, 7 Jun 2014 17:57:22 -0400 Received: by mail-pb0-f47.google.com with SMTP id rp16so3919239pbb.34 for ; Sat, 07 Jun 2014 14:57:21 -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=9fkH+KTO0jNVPmpHUDlq4mdBsrZ0Fqzy5CReRXyGf2U=; b=oIAZonVAT8TwpOOhKgp5HDZoVSWgS04VrAoJMDoWJKqB+2YkYFfM478MlIRpTrUZId T5tjJS6JdBTCzYgAVMPPmyjPMSaDv9j1hGbeh1OdgIe/wytVTkiCsI1mM0OgPffFr990 aOCr+h2C8krKCzNw/uAYMCcU4I2vbGo2H5n8peyo8LZEKEko2tpm3ON0UJwahfDVKk/R qVlBxvanzHE65Uf/CP5RrqepCLOrwLFTgUZW1az/7/zYBnNrKQFvKy3kKE0RrZyaGmY6 /DMiedS3izydcswHMNcMrnsiXub2RiPJvJw4WsC6vvruCTEwYny8fDbdjiUwC1d47+ZR MS5g== X-Received: by 10.68.233.37 with SMTP id tt5mr2517951pbc.154.1402178241810; Sat, 07 Jun 2014 14:57:21 -0700 (PDT) Received: from slongerb-fremont-linux.mgc.mentorg.com (c-98-248-118-71.hsd1.ca.comcast.net. [98.248.118.71]) by mx.google.com with ESMTPSA id fx5sm52769595pbb.62.2014.06.07.14.57.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 07 Jun 2014 14:57:21 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 21/43] imx-drm: ipu-v3: Add ipu_bits_per_pixel() Date: Sat, 7 Jun 2014 14:56:23 -0700 Message-Id: <1402178205-22697-22-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402178205-22697-1-git-send-email-steve_longerbeam@mentor.com> References: <1402178205-22697-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=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Add simple conversion from pixelformat to total bits-per-pixel. Signed-off-by: Steve Longerbeam --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 27 +++++++++++++++++++++++++++ include/linux/platform_data/imx-ipu-v3.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index de66d02..8a03ad2 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -606,6 +606,33 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) } EXPORT_SYMBOL_GPL(ipu_stride_to_bytes); +/* + * Standard bpp from pixel format. + */ +int ipu_bits_per_pixel(u32 pixelformat) +{ + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + return 12; + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + return 16; + case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_RGB24: + return 24; + case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_RGB32: + return 32; + default: + break; + } + + return 0; +} +EXPORT_SYMBOL_GPL(ipu_bits_per_pixel); + int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip) { diff --git a/include/linux/platform_data/imx-ipu-v3.h b/include/linux/platform_data/imx-ipu-v3.h index 75a6a5d..49e69a9 100644 --- a/include/linux/platform_data/imx-ipu-v3.h +++ b/include/linux/platform_data/imx-ipu-v3.h @@ -510,6 +510,7 @@ 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); +int ipu_bits_per_pixel(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);