From patchwork Sat Feb 16 10:19:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Fritz X-Patchwork-Id: 2151541 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 517B83FDF1 for ; Sat, 16 Feb 2013 10:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752949Ab3BPKTa (ORCPT ); Sat, 16 Feb 2013 05:19:30 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:48393 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895Ab3BPKT3 (ORCPT ); Sat, 16 Feb 2013 05:19:29 -0500 Received: by mail-wg0-f42.google.com with SMTP id 12so1525217wgh.3 for ; Sat, 16 Feb 2013 02:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:subject:from:to:cc:in-reply-to:references:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=pS6lfOnGmTk+lPqQQV89p4VX9hbpivHZp3iMZw2sNvA=; b=PGisGKeMqTAnhhMlpUebCeuQrFhwqCwG4756DVSdzrv1hApFscSrGU6jmQD3vpKmuN 2Vy2sCZ77rfOPPDZbse1luTcWYK0PDPka9rMUt5+ODwRqwC0uYvfK5nLt/fid8EK6lyM /osNpx672tLxmRDzVY8WH0BQkMKIAivTnTpQsdFEkdoKLO+wmGkXcA/0lYto6QrvJ/MU 9ACpza4tA4Piioc8x5qz3wxD519FQFDli6lUn9Oks3h7cxfwzCqxnnxHfJQhhEnyTWqA uy1xdRYQXj7DOmSh5XuIPiaKxzzaJ12DC/64gJjCZZQUut9aMUrgWEOn+YSSUVKeUyD/ zX5A== X-Received: by 10.194.238.226 with SMTP id vn2mr9095748wjc.23.1361009967626; Sat, 16 Feb 2013 02:19:27 -0800 (PST) Received: from [192.168.1.12] (p4FD82490.dip.t-dialin.net. [79.216.36.144]) by mx.google.com with ESMTPS id j4sm7256979wiz.10.2013.02.16.02.19.25 (version=SSLv3 cipher=RC4-SHA bits=128/128); Sat, 16 Feb 2013 02:19:26 -0800 (PST) Subject: [PATCH v2] media: i.MX27 camera: fix picture source width From: Christoph Fritz To: Greg KH , Guennadi Liakhovetski , Mauro Carvalho Chehab , Javier Martin , Shawn Guo , "Hans J. Koch" Cc: linux-media In-Reply-To: <20130215172452.GA27113@kroah.com> References: <1360948121.29406.15.camel@mars> <20130215172452.GA27113@kroah.com> Date: Sat, 16 Feb 2013 11:19:24 +0100 Message-ID: <1361009964.5028.3.camel@mars> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org While using a mt9m001 (monochrome) camera the final output falsely gets horizontally divided into two pictures. The issue was git bisected to commit f410991dcf1f | [media] i.MX27 camera: add support for YUV420 format | | This patch uses channel 2 of the eMMa-PrP to convert | format provided by the sensor to YUV420. | | This format is very useful since it is used by the | internal H.264 encoder. It sets PICTURE_X_SIZE in register PRP_SRC_FRAME_SIZE to its full width while before that commit it was divided by two: - writel(((bytesperline >> 1) << 16) | icd->user_height, + writel((icd->user_width << 16) | icd->user_height, pcdev->base_emma + PRP_SRC_FRAME_SIZE); i.mx27 reference manual (41.6.12 PrP Source Frame Size Register) says: PICTURE_X_SIZE. These bits set the frame width to be processed in number of pixels. In YUV 4:2:0 mode, Cb and Cr widths are taken as PICTURE_X_SIZE/2 pixels. In YUV 4:2:0 mode, this value should be a multiple of 8-pixels. In other modes (RGB, YUV 4:2:2 and YUV 4:4:4) it should be a multiple of 4 pixels. This patch reverts to PICTURE_X_SIZE/2 for channel 1. Tested on Kernel 3.4, merged to 3.8rc. Signed-off-by: Christoph Fritz --- drivers/media/platform/soc_camera/mx2_camera.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 8bda2c9..795bd3f 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c @@ -778,11 +778,11 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, struct mx2_camera_dev *pcdev = ici->priv; struct mx2_fmt_cfg *prp = pcdev->emma_prp; - writel((pcdev->s_width << 16) | pcdev->s_height, - pcdev->base_emma + PRP_SRC_FRAME_SIZE); writel(prp->cfg.src_pixel, pcdev->base_emma + PRP_SRC_PIXEL_FORMAT_CNTL); if (prp->cfg.channel == 1) { + writel(((bytesperline >> 1) << 16) | pcdev->s_height, + pcdev->base_emma + PRP_SRC_FRAME_SIZE); writel((icd->user_width << 16) | icd->user_height, pcdev->base_emma + PRP_CH1_OUT_IMAGE_SIZE); writel(bytesperline, @@ -790,6 +790,8 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, writel(prp->cfg.ch1_pixel, pcdev->base_emma + PRP_CH1_PIXEL_FORMAT_CNTL); } else { /* channel 2 */ + writel((pcdev->s_width << 16) | pcdev->s_height, + pcdev->base_emma + PRP_SRC_FRAME_SIZE); writel((icd->user_width << 16) | icd->user_height, pcdev->base_emma + PRP_CH2_OUT_IMAGE_SIZE); }