From patchwork Wed Jan 30 11:40:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2067231 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 645F23FD2B for ; Wed, 30 Jan 2013 11:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755293Ab3A3Lk6 (ORCPT ); Wed, 30 Jan 2013 06:40:58 -0500 Received: from moutng.kundenserver.de ([212.227.126.187]:62953 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754213Ab3A3Lk6 (ORCPT ); Wed, 30 Jan 2013 06:40:58 -0500 Received: from axis700.grange (dslb-094-221-120-108.pools.arcor-ip.net [94.221.120.108]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0M3OD6-1UrWA40Qca-00rPTO; Wed, 30 Jan 2013 12:40:56 +0100 Received: by axis700.grange (Postfix, from userid 1000) id A69EF40B99; Wed, 30 Jan 2013 12:40:55 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id A3FB840B98; Wed, 30 Jan 2013 12:40:55 +0100 (CET) Date: Wed, 30 Jan 2013 12:40:55 +0100 (CET) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List cc: Magnus Damm , Kuninori Morimoto , Simon Horman Subject: [PATCH] mt9t112: mt9t111 format set up differs from mt9t112 Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:+CWQuvyKEUdYR4Tththf9os8mCaUO6Y6YHlk0m04sZq GwKGNPXEvYJxbJFTmq7nkfgqbE/W5himrNVgXVYg2jGoQ/Wgl0 dZRJeEQYXp+l4oUOFAT/Si+mCkJaYQym4/VmowWL0gKDytKxNM mmMJwGGvn8jTwwGYLLyccAihZY5kSHP+jh+4eHn8PFyv5IfLs2 jeUashabuK2/QCbFoRhrUcbIXp7mjBekO7aWhcQM/BOQyYiXB8 VOBqpcB7Q+kG9EUTxxkb4h72enryZybXX+Xpjk0JfnMpTyKkRg 53/C5RObynVYYA05TgICJmX4OpuAnyd00S4W9u50mqLrVNlbg5 ZdmmXN9tKgFByRX7NJigdqN8DubGjg7K+vxRzVIaXZdyL+DLx7 7UO0bXM8/uS4A== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The original commit, adding the mt9t112 driver said, that mt9t111 and mt9t112 had identical register layouts. This however doesn't seem to be the case. At least pixel format selection in the mt9t111 datasheet is different from the driver implementation. So far only the default YUYV format has been verified to work with mt9t111. Limit the driver to only report one supported format with mt9t111 until more formats are implemented. Signed-off-by: Guennadi Liakhovetski --- drivers/media/i2c/soc_camera/mt9t112.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c index de7cd83..58f3509 100644 --- a/drivers/media/i2c/soc_camera/mt9t112.c +++ b/drivers/media/i2c/soc_camera/mt9t112.c @@ -92,6 +92,7 @@ struct mt9t112_priv { struct v4l2_rect frame; const struct mt9t112_format *format; int model; + int num_formats; u32 flags; /* for flags */ #define INIT_DONE (1 << 0) @@ -859,11 +860,11 @@ static int mt9t112_set_params(struct mt9t112_priv *priv, /* * get color format */ - for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++) + for (i = 0; i < priv->num_formats; i++) if (mt9t112_cfmts[i].code == code) break; - if (i == ARRAY_SIZE(mt9t112_cfmts)) + if (i == priv->num_formats) return -EINVAL; priv->frame = *rect; @@ -955,14 +956,16 @@ static int mt9t112_s_fmt(struct v4l2_subdev *sd, static int mt9t112_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { + struct i2c_client *client = v4l2_get_subdevdata(sd); + struct mt9t112_priv *priv = to_mt9t112(client); unsigned int top, left; int i; - for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++) + for (i = 0; i < priv->num_formats; i++) if (mt9t112_cfmts[i].code == mf->code) break; - if (i == ARRAY_SIZE(mt9t112_cfmts)) { + if (i == priv->num_formats) { mf->code = V4L2_MBUS_FMT_UYVY8_2X8; mf->colorspace = V4L2_COLORSPACE_JPEG; } else { @@ -979,7 +982,10 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd, static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index, enum v4l2_mbus_pixelcode *code) { - if (index >= ARRAY_SIZE(mt9t112_cfmts)) + struct i2c_client *client = v4l2_get_subdevdata(sd); + struct mt9t112_priv *priv = to_mt9t112(client); + + if (index >= priv->num_formats) return -EINVAL; *code = mt9t112_cfmts[index].code; @@ -1056,10 +1062,12 @@ static int mt9t112_camera_probe(struct i2c_client *client) case 0x2680: devname = "mt9t111"; priv->model = V4L2_IDENT_MT9T111; + priv->num_formats = 1; break; case 0x2682: devname = "mt9t112"; priv->model = V4L2_IDENT_MT9T112; + priv->num_formats = ARRAY_SIZE(mt9t112_cfmts); break; default: dev_err(&client->dev, "Product ID error %04x\n", chipid);