Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp451323pxb; Thu, 9 Sep 2021 04:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwhdx9eENmwdkLKR2HG+pGe9Xbi1dPZGe3v+37nvCXDtsEIDoGCNl/2vWTKPJYRgJJgW/O X-Received: by 2002:a17:906:4dc1:: with SMTP id f1mr3056662ejw.288.1631188499631; Thu, 09 Sep 2021 04:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188499; cv=none; d=google.com; s=arc-20160816; b=CTYAm57ahoj9d5uGdOkNnsBorkpsle/GjfbD63pG5WpqAJ4HZtzL6HMvpy/xR5Ay9x JEVlcl18zBRijBP37ty2fzx3q4gBlK5GJNP9IksTt8GBSW+D2iCPxwWWjKGHoB57PGkw HhUxUwyGrsaFAK1+qI8AWra+gJUM08DEHTVNri3xJol31f01bPzIPrc+EsMy9OKZiHn1 9MaQ3D21vHHBNyDMo9hE/HBDnJzqdHzUh/4UpG7U+wXZ1UQmwjWdnSqFv2eiY22wtB2s rEH2XFDjeVnjPkoBSVU/th+S8lEQdjhDLX/RcUx+Znd4wVIRDSKydm5ojvTAZzjG+40k XnhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kkO5GH3JI2ovkyb9vt2oDr3M2sL0hEvRll99Y8V1YsM=; b=ipE9gk42YKZ6uoOrjY5aom3Umz6hazXll59/zZZdyWEAFwDzOnYWT3T7up4/tgcLoY FWhFiZOoLJnUGNJVCGv/Vesi20s0HXC+eOqjgD1d/CD8ajhix9o1wttNYjaVt07lGHoV RZ2AxPZyLTC/kEX+pzP6yWAHAh3JVfuqMRTDbfNMccNdRrG68PGRcqKo0XvnrkNZCwEG iB9eUhHo3QBp8QkzuLC+TQ/tQJx4FW1byvqcOyAEhNrIw5qH0UfnNaqeVKl+GDyleped 478DHd7DK/cdUinuRM2zYdUOwqZ55bbYAIQGygu6es4FDuwHyeVK6ENBeTkBLLij30Oa 8xMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mAF4khmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id aq27si1646060ejc.548.2021.09.09.04.54.34; Thu, 09 Sep 2021 04:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mAF4khmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238514AbhIILvI (ORCPT + 99 others); Thu, 9 Sep 2021 07:51:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:54736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242214AbhIILse (ORCPT ); Thu, 9 Sep 2021 07:48:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0794B61206; Thu, 9 Sep 2021 11:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187803; bh=FkXCrBHyxq0hGuRyOSF1iQfp1/fAS0OjE1l6GxYEsVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAF4khmqA1jtiw4ITIphfZhjokDpM7DRc/YTjbsiiI0EGqV0U25SYnI9NU7NfeTde JkF4aCBEsmWax7LfoXDq/CmggmmCplZRK9sl+ej8YI3vSm/Gv4WnraLQ3aoQ+yw6S9 aa/1wsoXxOzTcJbIUCQN0x0xgFSpAb9VjFIX8ISfEJo9v3X/C1l8WXZJx43iiQxCBH e6BVKMHxHRlHHt8g432GUGZB0tOuYLdaZ1uJBcPwyRodZOFhofcXq2mIM6uGEQ5opU GL/F9zywS4ZaKoU9V7XTjI1n9D75MFsFNNDnhuT5sHZ5NFovOYhzo1zlkTYtxZSKbx EVq4n53/nT32g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Umang Jain , Laurent Pinchart , Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 106/252] media: imx258: Limit the max analogue gain to 480 Date: Thu, 9 Sep 2021 07:38:40 -0400 Message-Id: <20210909114106.141462-106-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Umang Jain [ Upstream commit f809665ee75fff3f4ea8907f406a66d380aeb184 ] The range for analog gain mentioned in the datasheet is [0, 480]. The real gain formula mentioned in the datasheet is: Gain = 512 / (512 – X) Hence, values larger than 511 clearly makes no sense. The gain register field is also documented to be of 9-bits in the datasheet. Certainly, it is enough to infer that, the kernel driver currently advertises an arbitrary analog gain max. Fix it by rectifying the value as per the data sheet i.e. 480. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Dave Stevenson Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/imx258.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index 4e695096e5d0..81cdf37216ca 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -47,7 +47,7 @@ /* Analog gain control */ #define IMX258_REG_ANALOG_GAIN 0x0204 #define IMX258_ANA_GAIN_MIN 0 -#define IMX258_ANA_GAIN_MAX 0x1fff +#define IMX258_ANA_GAIN_MAX 480 #define IMX258_ANA_GAIN_STEP 1 #define IMX258_ANA_GAIN_DEFAULT 0x0 -- 2.30.2