From patchwork Fri Jul 23 11:22:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 484894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C8CBC4320A for ; Fri, 23 Jul 2021 11:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 561AB60E75 for ; Fri, 23 Jul 2021 11:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234102AbhGWKmL (ORCPT ); Fri, 23 Jul 2021 06:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232657AbhGWKmL (ORCPT ); Fri, 23 Jul 2021 06:42:11 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1464AC061575 for ; Fri, 23 Jul 2021 04:22:45 -0700 (PDT) Received: from perceval.ideasonboard.com (unknown [103.251.226.103]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A7862885; Fri, 23 Jul 2021 13:22:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627039363; bh=ftX9QVrpqRPkwwZDC6EZFxog/v2aUTQrh0HjXGjTriY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HniKeMM2nVl6oXfgfmEiZpauI4g5yq4uxYULb+vyxjDhzGa6OgAd5dDOzr6rf9Upq 2YgxTpFlWjWs/PRwMU4CoUFAM/1/TyEx+JLdpixqCaekBWjI3eeEmefkQpuWSNmVms dEazLi1Crkj8nHLOL5EJwRGuWpMKjiPa0tXwy+vw= From: Umang Jain To: linux-media@vger.kernel.org Cc: libcamera-devel@lists.libcamera.org, Laurent Pinchart , Umang Jain Subject: [PATCH 1/2] media: imx258: Rectify mismatch of VTS value Date: Fri, 23 Jul 2021 16:52:32 +0530 Message-Id: <20210723112233.1361319-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723112233.1361319-1-umang.jain@ideasonboard.com> References: <20210723112233.1361319-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The frame_length_lines (0x0340) registers are hard-coded as follows: - 4208x3118 frame_length_lines = 0x0c50 - 2104x1560 frame_length_lines = 0x0638 - 1048x780 frame_length_lines = 0x034c The driver exposes the V4L2_CID_VBLANK control in read-only mode and sets its value to vts_def - height, where vts_def is a mode-dependent value coming from the supported_modes array. It is set using one of the following macros defined in the driver: #define IMX258_VTS_30FPS 0x0c98 #define IMX258_VTS_30FPS_2K 0x0638 #define IMX258_VTS_30FPS_VGA 0x034c There's a clear mismatch in the value for the full resolution mode i.e. IMX258_VTS_30FPS. Fix it by rectifying the macro with the value set for the frame_length_lines register as stated above. Signed-off-by: Laurent Pinchart Signed-off-by: Umang Jain Reviewed-by: Bingbu Cao --- 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 7ab9e5f9f267..4e695096e5d0 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -23,7 +23,7 @@ #define IMX258_CHIP_ID 0x0258 /* V_TIMING internal */ -#define IMX258_VTS_30FPS 0x0c98 +#define IMX258_VTS_30FPS 0x0c50 #define IMX258_VTS_30FPS_2K 0x0638 #define IMX258_VTS_30FPS_VGA 0x034c #define IMX258_VTS_MAX 0xffff From patchwork Fri Jul 23 11:22:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 485490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F11C4338F for ; Fri, 23 Jul 2021 11:22:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6BF9608FE for ; Fri, 23 Jul 2021 11:22:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234175AbhGWKmQ (ORCPT ); Fri, 23 Jul 2021 06:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232657AbhGWKmP (ORCPT ); Fri, 23 Jul 2021 06:42:15 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F895C061575 for ; Fri, 23 Jul 2021 04:22:49 -0700 (PDT) Received: from perceval.ideasonboard.com (unknown [103.251.226.103]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 433C056B; Fri, 23 Jul 2021 13:22:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627039368; bh=CC5F2wiPZj5TjrGGlK+tG8+gcD3f2SeeVIW/I7P3EAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g4ioskTVdaAACAtzmm2tIo74/tcSijJQrUgypfgEyr40hpCoOdTA3HrmIcyU0mQIp QLH6GMdFWXKBL08KV32A6hz7t7R3eZqNi6Wn+2OpuBVuTUSv/vYQSdKy6u0hy2ja5i +XvOHvg2kOvjKp3t0loGVE1+ttlk5x/Jk9rcBVZI= From: Umang Jain To: linux-media@vger.kernel.org Cc: libcamera-devel@lists.libcamera.org, Umang Jain Subject: [PATCH 2/2] media: imx258: Limit the max analogue gain to 480 Date: Fri, 23 Jul 2021 16:52:33 +0530 Message-Id: <20210723112233.1361319-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723112233.1361319-1-umang.jain@ideasonboard.com> References: <20210723112233.1361319-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- 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