From patchwork Fri Jun 1 08:28:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 11558 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SaNEG-0007P5-48 for patchwork@linuxtv.org; Fri, 01 Jun 2012 10:29:04 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1SaNEE-0004J2-B6; Fri, 01 Jun 2012 10:29:03 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758924Ab2FAI2Y (ORCPT ); Fri, 1 Jun 2012 04:28:24 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:39126 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756479Ab2FAI2V (ORCPT ); Fri, 1 Jun 2012 04:28:21 -0400 Received: by weyu7 with SMTP id u7so1194873wey.19 for ; Fri, 01 Jun 2012 01:28:20 -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=CJycjyGy6SKi9oz9FJYRmoKdJMDVIaO3LysgqTTZeoQ=; b=HHTrGQRgm3pE3hHvoafY2VanBHMT5cweDPDC7FLHddvDUeILtWq0Zv0eH2ZviKRgDV ABLfXzTS1Ssm2BCr+DK8QeZVnubV3vYm9UwaC4n4IH9DSjybeZE10/EJSGzjdlxXRoHf Q0GwsKXgpOOmKssHDWisoVJC5s+WLI+LMMULTSrK5hdEVihEp1laNnQMfaqX0jZys3Bo vMEYKgskQ0VM2MIViW7vp9iBFARgHd+0mWjCJnMjzssBHpW4BywadAfuEtebXYftzIb/ ss8mzg7xtzkrVWbIGeLw1F9xo3ijP0QtNNcO9DSiXx+Ev/pKkXkPjUmY/J82L6lWkiBE HgoA== Received: by 10.216.144.201 with SMTP id n51mr1682328wej.73.1338539299828; Fri, 01 Jun 2012 01:28:19 -0700 (PDT) Received: from localhost.localdomain (96.252.106.212.dynamic.jazztel.es. [212.106.252.96]) by mx.google.com with ESMTPS id fo7sm9421311wib.9.2012.06.01.01.28.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Jun 2012 01:28:18 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, fabio.estevam@freescale.com, g.liakhovetski@gmx.de, mchehab@infradead.org, kernel@pengutronix.de, Javier Martin Subject: [PATCH v2][for_v3.5] media: mx2_camera: Fix mbus format handling Date: Fri, 1 Jun 2012 10:28:08 +0200 Message-Id: <1338539288-14328-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQl3qNplXf6+wvAfj5TSAWqhwgjTy05hYi9D0KNeo+tImp1gQtwrlHZmNhziLvwu9Y/Q/u/P Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.6.1.81814 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' 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. Signed-off-by: Javier Martin --- Previous version of this patch was requested to be reverted by Guennadi. I'm sending a new version which fixes the issue; when mbus fmt is not found let the driver use default pass-through mode. Could this patch replace the old version in for_v3.5? It is part of the following series where patches 1 and 2 have been applied: [PATCH v2 1/3] media: tvp5150: Fix mbus format. [PATCH v2 2/3] i.MX27: visstrim_m10: Remove use of MX2_CAMERA_SWAP16. [PATCH v2 3/3] media: mx2_camera: Fix mbus format handling. --- arch/arm/plat-mxc/include/mach/mx2_cam.h | 2 - drivers/media/video/mx2_camera.c | 49 ++++++++++++++++++++++++++--- 2 files changed, 44 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 18afaee..bdbb7c9 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -344,6 +344,19 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { PRP_INTR_CH2OVF, } }, + { + .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, + } + }, }; static struct mx2_fmt_cfg *mx27_emma_prp_get_format( @@ -980,6 +993,7 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx2_camera_dev *pcdev = ici->priv; struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,}; + const struct soc_camera_format_xlate *xlate; unsigned long common_flags; int ret; int bytesperline; @@ -1024,14 +1038,28 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) return ret; } + xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); + if (!xlate) { + dev_warn(icd->parent, "Format %x not found\n", pixfmt); + return -EINVAL; + } + + if (xlate->code == V4L2_MBUS_FMT_YUYV8_2X8) { + csicr1 |= CSICR1_PACK_DIR; + csicr1 &= ~CSICR1_SWAP16_EN; + dev_dbg(icd->parent, "already yuyv format, don't convert\n"); + } else if (xlate->code == V4L2_MBUS_FMT_UYVY8_2X8) { + csicr1 &= ~CSICR1_PACK_DIR; + csicr1 |= CSICR1_SWAP16_EN; + dev_dbg(icd->parent, "convert uyvy mbus format into yuyv\n"); + } + 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) @@ -1042,8 +1070,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; @@ -1118,7 +1144,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) { /* @@ -1134,6 +1161,18 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, } } + if (code == V4L2_MBUS_FMT_UYVY8_2X8) { + formats++; + if (xlate) { + xlate->host_fmt = + soc_mbus_get_fmtdesc(V4L2_MBUS_FMT_YUYV8_2X8); + xlate->code = code; + dev_dbg(dev, "Providing host format %s for sensor code %d\n", + xlate->host_fmt->name, code); + xlate++; + } + } + /* Generic pass-trough */ formats++; if (xlate) {