Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1538770pxb; Thu, 16 Sep 2021 09:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXZkBPSj//D2LPFCy1EZHbS7vFPvCxSyqzIwWeEPfnXGdsS+FlmpyBfEG8Ks4DR/OEk9y0 X-Received: by 2002:a05:6402:1241:: with SMTP id l1mr7329503edw.123.1631809793116; Thu, 16 Sep 2021 09:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809793; cv=none; d=google.com; s=arc-20160816; b=DXQ8tQImpWvSeortB5NgJzcQWZOOSzArAxASCS2p0wMFjIYKsom5KBTa82lluK1OQY tfZGZdx3cxCk9iM6pSUjCwjxLnOxXkxVu2XQxHkVPXHt7XnLpnrKUtJL7rdjt48kd5Su daMuJ4UblrHPuvXoCllOuTQN181drsvnBdMfK1qNZDy4HSfkKDNznq8RCOzTiCG1RQOi BO0mDu/t7B0BKoBbTwO9gBJMhBLRRcdNqaD87e3WAgY2ZjoINQ0x4X+5fsUItmrs0G/w p3uGg0eYDwhJ1nshgiANeqt4GLjhMTE5F2eEsMcy1p14dAfAZYXpeNeKqHcAmByzujl1 lnsQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ylmR9Pm2Jjpfwk+UQ614YEAC4kRJ/qsUCgogQ3bwl4M=; b=YLT0AbbGamnRkHW/w5yRgZT3vU7cs6KgqPkqbrTeLyhHpdO0VSJFNV8GmtFdBmdE/y gNRcuYiImzFrXtHXjQcPsCWr1sNerFe0W/7LheL2l/SAZujgWYdIb4A0CtDeVwegjF8o i+j/SCshk6Hilwzc5Xo0MmJnmVeI1H2XhxRDxZDfhrsRUOsmVOfSe0kX+f84669UdQ3B krqFhNZKv2bILAEItGjkEzEksDFZu/hk10Lsb/Q2l+cnI5sQ1Sfjep6scowT/uM9G7tE C5xIQjn2iTestQRkkpI09hwP4naaNZv43b2uxUpBZJIL16yA2PK/ZYMUCakc1T6ztwBN zt5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xEeH+Hje; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si4035237ejy.256.2021.09.16.09.29.24; Thu, 16 Sep 2021 09:29:53 -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=@linuxfoundation.org header.s=korg header.b=xEeH+Hje; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241790AbhIPQZ5 (ORCPT + 99 others); Thu, 16 Sep 2021 12:25:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235171AbhIPQSQ (ORCPT ); Thu, 16 Sep 2021 12:18:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C6F361355; Thu, 16 Sep 2021 16:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808762; bh=FV5zm2F1vM97RGgqT2SFLaNiWF0Id1j+xbU6FBbSKQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xEeH+HjeHhYsF+h3mUrpg6USSJqJt9R21Jtw+QJlW9KsgwJhQ4gcbdQWr5hW6JA4i OLCcvsJpvGT0ppmJxPcoj8Oio7nKgKjWIP9Kw3ZFRlXSSiNdRqvheFuEpIQv6gX9SD YPo4j3L4QvHUH8O7xyOEsI3GBn6o0FrInIjcEGsk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Umang Jain , Laurent Pinchart , Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 180/306] media: imx258: Limit the max analogue gain to 480 Date: Thu, 16 Sep 2021 17:58:45 +0200 Message-Id: <20210916155800.219522100@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 c0a691a73ec9..e6104ee97ed2 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -46,7 +46,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