From patchwork Thu May 17 16:30:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 11301 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SV3b6-0005az-Vh for patchwork@linuxtv.org; Thu, 17 May 2012 18:30:41 +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-2) with esmtp for id 1SV3b6-0004rV-H0; Thu, 17 May 2012 18:30:40 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762199Ab2EQQag (ORCPT ); Thu, 17 May 2012 12:30:36 -0400 Received: from smtp.nokia.com ([147.243.1.47]:30305 "EHLO mgw-sa01.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762194Ab2EQQae (ORCPT ); Thu, 17 May 2012 12:30:34 -0400 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.199.25]) by mgw-sa01.nokia.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4HGUW8s029805 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 17 May 2012 19:30:33 +0300 Received: from lanttu (lanttu-o.localdomain [192.168.239.74]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 600021F4C5A for ; Thu, 17 May 2012 19:30:32 +0300 (EEST) Received: from sakke by lanttu with local (Exim 4.72) (envelope-from ) id 1SV3at-000871-7H for linux-media@vger.kernel.org; Thu, 17 May 2012 19:30:27 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [PATCH 07/10] smiapp: Use non-binning limits if the binning limit is zero Date: Thu, 17 May 2012 19:30:06 +0300 Message-Id: <1337272209-31061-7-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <4FB52770.9000400@maxwell.research.nokia.com> References: <4FB52770.9000400@maxwell.research.nokia.com> X-Nokia-AV: Clean 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.5.17.162121 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __DATE_TZ_RU 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Some sensors do use binning but do not have valid limits in binning registers. Use non-binning limits in that case. Signed-off-by: Sakari Ailus --- drivers/media/video/smiapp/smiapp-core.c | 31 +++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/smiapp/smiapp-core.c b/drivers/media/video/smiapp/smiapp-core.c index 6524091..47d6901 100644 --- a/drivers/media/video/smiapp/smiapp-core.c +++ b/drivers/media/video/smiapp/smiapp-core.c @@ -653,6 +653,7 @@ static int smiapp_get_all_limits(struct smiapp_sensor *sensor) static int smiapp_get_limits_binning(struct smiapp_sensor *sensor) { + struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); static u32 const limits[] = { SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES_BIN, SMIAPP_LIMIT_MAX_FRAME_LENGTH_LINES_BIN, @@ -671,11 +672,11 @@ static int smiapp_get_limits_binning(struct smiapp_sensor *sensor) SMIAPP_LIMIT_FINE_INTEGRATION_TIME_MIN, SMIAPP_LIMIT_FINE_INTEGRATION_TIME_MAX_MARGIN, }; + unsigned int i; + int rval; if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY] == SMIAPP_BINNING_CAPABILITY_NO) { - unsigned int i; - for (i = 0; i < ARRAY_SIZE(limits); i++) sensor->limits[limits[i]] = sensor->limits[limits_replace[i]]; @@ -683,7 +684,31 @@ static int smiapp_get_limits_binning(struct smiapp_sensor *sensor) return 0; } - return smiapp_get_limits(sensor, limits, ARRAY_SIZE(limits)); + rval = smiapp_get_limits(sensor, limits, ARRAY_SIZE(limits)); + if (rval < 0) + return rval; + + /* + * Sanity check whether the binning limits are valid. If not, + * use the non-binning ones. + */ + if (sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES_BIN] + && sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN] + && sensor->limits[SMIAPP_LIMIT_MIN_LINE_BLANKING_PCK_BIN]) + return 0; + + for (i = 0; i < ARRAY_SIZE(limits); i++) { + dev_dbg(&client->dev, + "replace limit 0x%8.8x \"%s\" = %d, 0x%x\n", + smiapp_reg_limits[limits[i]].addr, + smiapp_reg_limits[limits[i]].what, + sensor->limits[limits_replace[i]], + sensor->limits[limits_replace[i]]); + sensor->limits[limits[i]] = + sensor->limits[limits_replace[i]]; + } + + return 0; } static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)