From patchwork Tue Jul 10 11:56:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 1177231 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 64D24DFF34 for ; Tue, 10 Jul 2012 11:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755338Ab2GJL40 (ORCPT ); Tue, 10 Jul 2012 07:56:26 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:36868 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755321Ab2GJL4Z (ORCPT ); Tue, 10 Jul 2012 07:56:25 -0400 Received: by wgbdr13 with SMTP id dr13so12431525wgb.1 for ; Tue, 10 Jul 2012 04:56:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=kiAB+tN06KXcwWWKb5R0fXr/sCk/BNGLrNyJ4Ny3yyg=; b=FzvSmlgrM2HZsCP25dUWRHJyk6brE9CdreCaM4h01vmXPcxcvcyxSCk4GmTarOjslC wK+IChlilA704Cqk/DNmzplGpfo6OjGQoNuBxvETTC7PzosUC2iGRsSejN338jiyaKOC pAPbqol1lFuyVGKv5tDyhOy7TXVONNmc2A0gDmQQnKtRwRJp4xHMjyeJ7RmpYRWyXp/M GlJeSIDlyrRsWZ/6lFizj9tzc981jwPfMKSy3cvNWd0WUqUZO830MVJ/Lj9kjtOoRSJs lteZ1LgZjmN722nqt9af6kb94a2H6/2/eVL3ZdC4GuEAQlY7d4Rq2hlrizRD7fzO0Obr L21w== Received: by 10.180.100.131 with SMTP id ey3mr37649203wib.15.1341921383841; Tue, 10 Jul 2012 04:56:23 -0700 (PDT) Received: from piscis.vsilicon.net (96.252.106.212.dynamic.jazztel.es. [212.106.252.96]) by mx.google.com with ESMTPS id y2sm28552352wix.7.2012.07.10.04.56.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 04:56:22 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Cc: fabio.estevam@freescale.com, laurent.pinchart@ideasonboard.com, g.liakhovetski@gmx.de, mchehab@infradead.org, kernel@pengutronix.de, Javier Martin Subject: [PATCH v4] media: mx2_camera: Fix mbus format handling Date: Tue, 10 Jul 2012 13:56:13 +0200 Message-Id: <1341921373-14570-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQn4Da3TOfHBWSU2Z6ZSnF31RDCJqcp+5UYPiqU0Jp0ctT+/HpCm4z4Wt3jVuf57szhIW0I/ Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Remove MX2_CAMERA_SWAP16 and MX2_CAMERA_PACK_DIR_MSB flags so that the driver can negotiate with the attached sensor whether the mbus format needs convertion from UYUV to YUYV or not. --- Changes since v3: - Remove conversion from UYVY to YUYV. - Add 'csicr1' to emma-PrP format structure. --- arch/arm/plat-mxc/include/mach/mx2_cam.h | 2 -- drivers/media/video/mx2_camera.c | 27 ++++++++++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/arch/arm/plat-mxc/include/mach/mx2_cam.h b/arch/arm/plat-mxc/include/mach/mx2_cam.h index 3c080a3..7ded6f1 100644 --- a/arch/arm/plat-mxc/include/mach/mx2_cam.h +++ b/arch/arm/plat-mxc/include/mach/mx2_cam.h @@ -23,7 +23,6 @@ #ifndef __MACH_MX2_CAM_H_ #define __MACH_MX2_CAM_H_ -#define MX2_CAMERA_SWAP16 (1 << 0) #define MX2_CAMERA_EXT_VSYNC (1 << 1) #define MX2_CAMERA_CCIR (1 << 2) #define MX2_CAMERA_CCIR_INTERLACE (1 << 3) @@ -31,7 +30,6 @@ #define MX2_CAMERA_GATED_CLOCK (1 << 5) #define MX2_CAMERA_INV_DATA (1 << 6) #define MX2_CAMERA_PCLK_SAMPLE_RISING (1 << 7) -#define MX2_CAMERA_PACK_DIR_MSB (1 << 8) /** * struct mx2_camera_platform_data - optional platform data for mx2_camera diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 11a9353..8adef0f 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -119,6 +119,7 @@ #define CSISR_DRDY (1 << 0) #define CSICR1 0x00 +#define CSICR1_FMT_MASK (CSICR1_PACK_DIR | CSICR1_SWAP16_EN) #define CSICR2 0x04 #define CSISR (cpu_is_mx27() ? 0x08 : 0x18) #define CSISTATFIFO 0x0c @@ -230,6 +231,7 @@ struct mx2_prp_cfg { u32 src_pixel; u32 ch1_pixel; u32 irq_flags; + u32 csicr1; }; /* prp resizing parameters */ @@ -330,6 +332,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { .ch1_pixel = 0x2ca00565, /* RGB565 */ .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH1WERR | PRP_INTR_CH1FC | PRP_INTR_LBOVF, + .csicr1 = 0, } }, { @@ -343,6 +346,21 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR | PRP_INTR_CH2FC | PRP_INTR_LBOVF | PRP_INTR_CH2OVF, + .csicr1 = CSICR1_PACK_DIR, + } + }, + { + .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8, + .out_fmt = V4L2_PIX_FMT_YUV420, + .cfg = { + .channel = 2, + .in_fmt = PRP_CNTL_DATA_IN_YUV422, + .out_fmt = PRP_CNTL_CH2_OUT_YUV420, + .src_pixel = 0x22000888, /* YUV422 (YUYV) */ + .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR | + PRP_INTR_CH2FC | PRP_INTR_LBOVF | + PRP_INTR_CH2OVF, + .csicr1 = CSICR1_SWAP16_EN, } }, }; @@ -1018,14 +1036,14 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) return ret; } + csicr1 = (csicr1 & ~CSICR1_FMT_MASK) | pcdev->emma_prp->cfg.csicr1; + if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) csicr1 |= CSICR1_REDGE; if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) csicr1 |= CSICR1_SOF_POL; if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) csicr1 |= CSICR1_HSYNC_POL; - if (pcdev->platform_flags & MX2_CAMERA_SWAP16) - csicr1 |= CSICR1_SWAP16_EN; if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC) csicr1 |= CSICR1_EXT_VSYNC; if (pcdev->platform_flags & MX2_CAMERA_CCIR) @@ -1036,8 +1054,6 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) csicr1 |= CSICR1_GCLK_MODE; if (pcdev->platform_flags & MX2_CAMERA_INV_DATA) csicr1 |= CSICR1_INV_DATA; - if (pcdev->platform_flags & MX2_CAMERA_PACK_DIR_MSB) - csicr1 |= CSICR1_PACK_DIR; pcdev->csicr1 = csicr1; @@ -1112,7 +1128,8 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, return 0; } - if (code == V4L2_MBUS_FMT_YUYV8_2X8) { + if (code == V4L2_MBUS_FMT_YUYV8_2X8 || + code == V4L2_MBUS_FMT_UYVY8_2X8) { formats++; if (xlate) { /*