Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp502009pxb; Thu, 9 Sep 2021 06:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoevuOeb9qkFRjdTY5GYHzp+DkDiJlQME5tiYpOfjFRaZH6qR7a2HwY9cN1ChliK05d8/F X-Received: by 2002:a17:907:9602:: with SMTP id gb2mr3374547ejc.119.1631192451755; Thu, 09 Sep 2021 06:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192451; cv=none; d=google.com; s=arc-20160816; b=tYoTF4QitgqDsXvtTwG0zEsJIjZxjVp8TgiBJoqKJYRfhS/K5M8XpofcG/Y4CpfroV kj5vDXnuCp+96kFwFXCBLJ4M3l4tzt/CW+2uzSxOylreoZ8X0XYvUZSkxCMta/eFgpnc ojZYrQ8p7zoxExxQ7iXFdzodJ0x9LCDorvKguFUqBceeKs3WNBZ6mjbFC0pnCkxHmypG ONE/RaqbTjGMX1thus+EZWIwsvB3OQQg6GMWEardZlmfE7paNLTdnK/t8yxjXkVJvz5Y nQqyv3SZpJPtEPtMaazLmjV2oIkG+ZB1q0P8YNGtjQ+xzrxUfxpbl9su2nFvkR0YPIJX NpPA== 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=UPjPNOFdhg6Fi3+XJo1kVo2McbOgNZN4FQrR+iYEYWw=; b=IfDx/li/aFPFbN+CSRGfl7lsY2nK5Eu/Xntc8sCtGNtcvVRlck1YHCRefU4ptB8keb WAm6PDUTJjy5AQyGDOlFl12Kei/yfZSjgV6BECsZjyXBM4BtJYwRvX+gcJ9/hi+AQmOP Wl5ZfVlzoomEz65IucjMDfgtle1ysMCB+mAvCLKFjMgsd1hW2FsUNPONUpQMHUq6IhG4 arBOdSISv1Sx8p2F/pQ7mErnRXIBsdVFM7N2ixz17chUzHIiFnuKFT5/OdUMVRGj6Gf6 vk7MOUEJ35uQ70lazLmxLWjmMvp3ps/ULZ3mJWF46Uq2WwLu0MXFHhw+dLwSmPPbWhbD MhYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g2KYWx4n; 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 qf39si1748755ejc.644.2021.09.09.06.00.21; Thu, 09 Sep 2021 06:00:51 -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=g2KYWx4n; 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 S1356967AbhIIM4K (ORCPT + 99 others); Thu, 9 Sep 2021 08:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355436AbhIIMpo (ORCPT ); Thu, 9 Sep 2021 08:45:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6782613B5; Thu, 9 Sep 2021 11:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188570; bh=jNfagrwBB6tBxwk5PwVadgQlBB9yK8VvqcvtDl0vPX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2KYWx4nG4nZ9RQgbwvSiacPn6yS4el9tTkZGqdA0+OtShxCtUq8CrTpjuae1rojK PRUpWSCvuiSsYQErKy7twaSAsTH+lklGgsgcZ+nnJTsO8f+OUiH/JJ4gA7HkkLu/N4 cr5wITLzpRwiB2hyq+bKD+VZxE4repHxL+KpsSojmnvMqaxremxxKd5fPm8kwxaZYv cyCCq6vPzesFRWANPnyv4EmM5g8k4wbG0bUC2FI+PYo7c+GmCvUIlqjRvDNuUid3uR R8cHoOn2ss68jrmEhBxFAF/QfK5TObRGUefSqSqJKvo9YMegbmxZiGSKRDKcLLziru thbU3NpXogsiQ== 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.4 050/109] media: imx258: Limit the max analogue gain to 480 Date: Thu, 9 Sep 2021 07:54:07 -0400 Message-Id: <20210909115507.147917-50-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-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 5f5e50c01b12..ffaa4a91e571 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