From patchwork Wed Apr 9 19:25:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 3957311 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13536BFF02 for ; Wed, 9 Apr 2014 19:26:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CFAE206B1 for ; Wed, 9 Apr 2014 19:26:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13B9D20166 for ; Wed, 9 Apr 2014 19:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934352AbaDITZ4 (ORCPT ); Wed, 9 Apr 2014 15:25:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:50019 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934297AbaDITZA (ORCPT ); Wed, 9 Apr 2014 15:25:00 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 09 Apr 2014 12:24:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,828,1389772800"; d="scan'208";a="517739165" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga002.fm.intel.com with ESMTP; 09 Apr 2014 12:24:55 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id A39BE21177 for ; Wed, 9 Apr 2014 22:24:53 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 7AB0D201DA; Wed, 9 Apr 2014 22:25:15 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [PATCH 08/17] smiapp: Limits can be 64 bits Date: Wed, 9 Apr 2014 22:25:00 +0300 Message-Id: <1397071509-2071-9-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1397071509-2071-1-git-send-email-sakari.ailus@linux.intel.com> References: <1397071509-2071-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Limits may exceed the value range of 32 bit unsigned integers. Thus use 64 bits instead. Use typed min/max/clamp macros. Debug printing changes as well. Signed-off-by: Sakari Ailus --- drivers/media/i2c/smiapp/smiapp-core.c | 30 ++++++++++++++++-------------- drivers/media/i2c/smiapp/smiapp-quirk.c | 4 ++-- drivers/media/i2c/smiapp/smiapp-quirk.h | 2 +- drivers/media/i2c/smiapp/smiapp.h | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 3af8df8..6d940f0 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -502,7 +502,8 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) V4L2_CID_ANALOGUE_GAIN, sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN], sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MAX], - max(sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_STEP], 1U), + max_t(uint32_t, + sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_STEP], 1U), sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN]); /* Exposure limits will be updated soon, use just something here. */ @@ -679,7 +680,7 @@ static int smiapp_get_limits_binning(struct smiapp_sensor *sensor) for (i = 0; i < ARRAY_SIZE(limits); i++) { dev_dbg(&client->dev, - "replace limit 0x%8.8x \"%s\" = %d, 0x%x\n", + "replace limit 0x%8.8x \"%s\" = %llu, 0x%llx\n", smiapp_reg_limits[limits[i]].addr, smiapp_reg_limits[limits[i]].what, sensor->limits[limits_replace[i]], @@ -1689,13 +1690,13 @@ static int smiapp_set_format(struct v4l2_subdev *subdev, fmt->format.height &= ~1; fmt->format.width = - clamp(fmt->format.width, - sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], - sensor->limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]); + clamp_t(uint32_t, fmt->format.width, + sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], + sensor->limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]); fmt->format.height = - clamp(fmt->format.height, - sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE], - sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]); + clamp_t(uint32_t, fmt->format.height, + sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE], + sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]); smiapp_get_crop_compose(subdev, fh, crops, NULL, fmt->which); @@ -1834,12 +1835,13 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN] / sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE]; - a = clamp(a, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); - b = clamp(b, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); - max_m = clamp(max_m, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); + a = clamp_t(uint32_t, a, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], + sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); + b = clamp_t(uint32_t, b, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], + sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); + max_m = clamp_t(uint32_t, max_m, + sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], + sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); dev_dbg(&client->dev, "scaling: a %d b %d max_m %d\n", a, b, max_m); diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c b/drivers/media/i2c/smiapp/smiapp-quirk.c index 20e62c1..580132d 100644 --- a/drivers/media/i2c/smiapp/smiapp-quirk.c +++ b/drivers/media/i2c/smiapp/smiapp-quirk.c @@ -51,11 +51,11 @@ static int smiapp_write_8s(struct smiapp_sensor *sensor, } void smiapp_replace_limit(struct smiapp_sensor *sensor, - u32 limit, u32 val) + u32 limit, u64 val) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - dev_dbg(&client->dev, "quirk: 0x%8.8x \"%s\" = %d, 0x%x\n", + dev_dbg(&client->dev, "quirk: 0x%8.8x \"%s\" = %llu, 0x%llx\n", smiapp_reg_limits[limit].addr, smiapp_reg_limits[limit].what, val, val); sensor->limits[limit] = val; diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h b/drivers/media/i2c/smiapp/smiapp-quirk.h index a6b3183..15ef0af6 100644 --- a/drivers/media/i2c/smiapp/smiapp-quirk.h +++ b/drivers/media/i2c/smiapp/smiapp-quirk.h @@ -54,7 +54,7 @@ struct smiapp_reg_8 { }; void smiapp_replace_limit(struct smiapp_sensor *sensor, - u32 limit, u32 val); + u32 limit, u64 val); bool smiapp_quirk_reg(struct smiapp_sensor *sensor, u32 reg, u32 *val); diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h index 7cc5aae..0a26487 100644 --- a/drivers/media/i2c/smiapp/smiapp.h +++ b/drivers/media/i2c/smiapp/smiapp.h @@ -199,7 +199,7 @@ struct smiapp_sensor { struct smiapp_platform_data *platform_data; struct regulator *vana; struct clk *ext_clk; - u32 limits[SMIAPP_LIMIT_LAST]; + u64 limits[SMIAPP_LIMIT_LAST]; u8 nbinning_subtypes; struct smiapp_binning_subtype binning_subtypes[SMIAPP_BINNING_SUBTYPES]; u32 mbus_frame_fmts;