Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1954894pxb; Thu, 16 Sep 2021 21:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHHyjEpwXmvpDy/tDDVA+6GWhJdImCr5RnkWmeOr9tRboqKWnAWupnFBPn7dmdtt9gbdoo X-Received: by 2002:a05:6e02:1a28:: with SMTP id g8mr6842327ile.158.1631852834532; Thu, 16 Sep 2021 21:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631852834; cv=none; d=google.com; s=arc-20160816; b=wxZhIcmrvDfxIc6ZPvNxGn1pifbPnM1E5muH+QWcWf+ucKoVnS+eCvW5nAashEu0aV y9ZZb3DAuqEyxaWFx44pDnMqNVEb/egHx0J0zlRdqiWBE5iR+mmzYarlHA9dd3fLcr6M yyBTonHbOXZXQJotdZpfeyV4ChoAZIOsfEOwEr/5zG/jvkuVOo/dVIh8vXd1BlscCM/F e/cDpUllSQth0wb/S2KNPDTqKBLWCHwJtDC9gNU5V11jCBiPcaER4i2wKg4chQtiVicj Wbyzx1GHC4IiUuHgel9jODMr/A4IfrvmvR0GSnQ98UMGMuL9bM8GFlWRs+7vNwBPsb/p ABkQ== 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=kkO5GH3JI2ovkyb9vt2oDr3M2sL0hEvRll99Y8V1YsM=; b=CA4hdzxvO+xigTQbeTmOWK9y8N/Ih1b/fHZEanTa+MZHh+5LKhtOxwAHg7vi0XqEEq JsoCU0MEqEqZhDqnYePyDGuSYrdwu8XZB8GLyWc6TkPDTzgIfefRqQEdeR9RkuQ2B42d AItR275WZdc7Gf/czCoyeDycWdZ+jEYTfPyMKMw4he3kFQnG/lbLNEeCJM134TZaSLYj w7BvoZPyU40kBqc7XkiV7Dq8XjvxTQFQ7CxS156hx5plIonz8+MyZKBU60xQE2P05pM0 JBshb7DE75MfqPVEFp2YznE6l2R9pxCNTxGTp3dABBvwMZe0Xv7Nzr3W+g4VOoHloWM3 B5nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=crJaHvOV; 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 w18si4417816ilc.63.2021.09.16.21.27.03; Thu, 16 Sep 2021 21:27:14 -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=crJaHvOV; 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 S1353926AbhIPRhd (ORCPT + 99 others); Thu, 16 Sep 2021 13:37:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:47066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352809AbhIPR2l (ORCPT ); Thu, 16 Sep 2021 13:28:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27DCD61C48; Thu, 16 Sep 2021 16:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810757; bh=FkXCrBHyxq0hGuRyOSF1iQfp1/fAS0OjE1l6GxYEsVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crJaHvOVp+3nfmjU7lejX+P0NaoyOjgQe0V3jVg3GNsR64fzl9G6/L42RHi6PwvM4 Y6/9hdK4+KNTleQiJgGMYGL0faIC/7fP2+yIPWqbEUmthNb9ocDU1trvOBpiKUtpf6 bilVDBU7C/PvOyk0XnuIH8Kpe4OLHaIozOujzWmE= 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.14 256/432] media: imx258: Limit the max analogue gain to 480 Date: Thu, 16 Sep 2021 18:00:05 +0200 Message-Id: <20210916155819.500380422@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 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