Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp465845lqo; Wed, 8 May 2024 05:35:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFCsPzipdVjlfzRtsNnH5ox4hfrU9luawKrLA6deK18jF0Lnol84DOKJXRraFRU+GhhIBjjNxt/3gkoPYZ0CgSRdAqzmmHNEcdfoXkdA== X-Google-Smtp-Source: AGHT+IFDnsqoZ07bw+xj5Ga29zjptlnnJWiDAaU2n1l6WTQpAJHnzRkwip0820Crxrcwqcv2psXU X-Received: by 2002:a17:90b:94f:b0:2b0:9544:59e7 with SMTP id 98e67ed59e1d1-2b5bc2c9156mr7592612a91.23.1715171719152; Wed, 08 May 2024 05:35:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715171719; cv=pass; d=google.com; s=arc-20160816; b=0oTSio2ltzQnwaybirhMBczf1dr2nkTDJcF43p6hRxDuflOG4jUvIdmbEO/M/HNsKj mJFwQ+pib8CPr3dRDBbNCV8AFwq0vl3Scux4q2JD+1BJ1FtJyVbflRXz6xwRNez3CpJt /3qoxwmy1f66sC+qzNjYP7YUEk3e/hG5dHJGdvmMGjV6BlMz/UXwUxbzfTMR/aK/iDza GgGYgz+eQCH/GC4bzzAvYH2JUYoBajjhNe/aXY0iyi+N0lOFqJ4k5o2z2P44Ax/FfmH8 B4a7aJmm0FBxqRgx+kHt/fSkBBKyLiuI1ZUlDAxKQiySMsYNT3tTOFxkB384q2tW4H/N qoBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=YYrKVOxVHFjhu1hOKK81DsZdjrvks2E1EPLM+0mit2E=; fh=kC3mWW84Pgx/Ooj0B7m3pZn4hXnRpUdWF5CwGMFsHkI=; b=BCVuKEo4MZoGO7nS6EtM0Irea599QWJlkeps/wz/6SeZTlFLYlaSid2JT26jUJPkSt qdpvNt6Z5OYji+3dUaXzwTyX1GFBkelDfClZWCupYk7dFQU6iyoniSNhAkVQjQbuAH2s X2ndYLtnT3zd8gF4YlLqRvykY81elT8ZFxGX7mMQhxE+ceQnBWTcRk7ybSXHxjTX2445 Z2n/0t4++kQvAFSSXxNmqEuFqb8qGas5YiKnIxhjGdhsorNsKJtajcnD+0uK9KWVtEJ9 b96ZCLk1wVbKeoq89z6HB+A2QMF88wVfRM0q9G+bf+OkAwq/wj0AmvDjJKktmhQMvzup +8Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PQi4T/AR"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-173214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173214-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y9-20020a17090a1f4900b002a4a80f2d6bsi1286879pjy.112.2024.05.08.05.35.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 05:35:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PQi4T/AR"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-173214-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173214-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5E673B22D84 for ; Wed, 8 May 2024 12:30:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 548C05577E; Wed, 8 May 2024 12:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PQi4T/AR" Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A72E58F40 for ; Wed, 8 May 2024 12:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715171437; cv=none; b=tBkGk2GJkHXHSYmeinz71bDnsHqA4zZWrUZ99tObxQNAQzdB0eS1oUz7oplNHV3atsCTheK7UG7tx52rG3ZXfL/y6SGZGk5galuBeFT0bgpmEmJ52AMnc/gUADX6Blhr4X6ChwZQWyr1xB9w92+FaW66B0jrl2koJb46ua0XWy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715171437; c=relaxed/simple; bh=TqVEqH1q0bDGKE0x+2yoDuOpG9nNPgui+nNL00aF/uI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QQUPeM7CRORebhgeyc4m9PI4bBrPPWrjIcgRMlqKn6x9rfLMDjCuzsDKW9ayxxEIiOSDxWrjB/fMUkaeWjjqWG+8ulYZcMZt4N05gIPkzqZaQ+lmCLzyFE9Mso66qwaz2m9Et+mD9wni7/gLoZoRRpwLa31t91KrpnhaEVy4VeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PQi4T/AR; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-34e667905d2so3244847f8f.1 for ; Wed, 08 May 2024 05:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715171433; x=1715776233; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YYrKVOxVHFjhu1hOKK81DsZdjrvks2E1EPLM+0mit2E=; b=PQi4T/AROhdnBwPvab+UgUX+n+e6okCPFBjUNFujIUafxj+NATgrOe9zZVra2wAeWy EEqid6O6qxf1Upil4PatFngkjXrp1QEO/lZGYjxknyxxHoKYhbmdvQA2I2cNwOPdDLsN EUbzC4JeUV7O/Zp3bPZp3TgA09MrJW2pXFrK7F1aCeZ4IqH97hUaWrWmldUQehEWW+sF GEwYHjPOLoNy1VcqbOsq+6F4r565+qUX/65VFM41yXL6ynZp3o0qZGL997AKHC+pjjTK 8XqAIymTaEoRYpoxDnL7TPdjnaQcVMjwOAbxPQKN8gtr+W+bMHL62dW1UVr29OJYEkvQ bLRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715171433; x=1715776233; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YYrKVOxVHFjhu1hOKK81DsZdjrvks2E1EPLM+0mit2E=; b=JD+OCy54vqSS/Hx/Xbdzzh86hTp0br3vDDC23cQp4X/tIRkWLTnPV65D+P4MdTXN5w ojOGyA90zOQFTbXIpfU0HppNKr+E9IQ551Rhwk+oLPr6LJxatwjpRHMpTeuCrPj5FWjN 4ZpdOZTBDchNrdj1YOfRz14NeGV5H4e+cG1jaVaH3UTdwmTP1ndCPVRnPe8omT4Ia1hT J0DerAUoDN9CWQOp74c9KbipzqjfKf5x1a7/bF04yzK1lNSvQ8vp95H6c4inFx3PYkkZ Ksu6bw+LuJiXIBmLIIohmNjtzA5PDjVOOQngx0qWQkSuJ8ihxJzr2kX4zmkZouzgACzu j2oA== X-Forwarded-Encrypted: i=1; AJvYcCUxLJTw+zDHr0DTN6aYT+0d9K6v1Ab3JvTqT/lMF01FK4jHqp8nLey1tgxMNC+KFfr0lPc39cL/tUtD6/ii3kuQlFsQf5GVQhujrHRc X-Gm-Message-State: AOJu0YwEsRxH8Mb1fQil7sS/pA9kdqfEDrEJ1OPOgzT9sJQ/DOziA7pY ++hk7fPl1lHM98hEoGJacheXM+j3E/jNaBKPbApkPW63ZpdVna1rUI4VgdC8hX0= X-Received: by 2002:a5d:69ca:0:b0:34e:182f:62ed with SMTP id ffacd0b85a97d-34fcb3abb03mr2290407f8f.61.1715171432974; Wed, 08 May 2024 05:30:32 -0700 (PDT) Received: from [192.168.0.3] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id t3-20020a05600001c300b0034df7313bf1sm15406607wrx.0.2024.05.08.05.30.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 May 2024 05:30:32 -0700 (PDT) Message-ID: <20a0300a-ac16-456c-840a-e272f49050a8@linaro.org> Date: Wed, 8 May 2024 13:30:31 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] media: i2c: Fix imx412 exposure control To: Jacopo Mondi Cc: Sakari Ailus , Mauro Carvalho Chehab , "Paul J. Murphy" , Martina Krasteva , Daniele Alessandrelli , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240506-b4-linux-next-camss-x13s-mmsol-integration-in-test-imx577-fix-v2-1-2e665f072f8f@linaro.org> Content-Language: en-US From: Bryan O'Donoghue In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 08/05/2024 09:02, Jacopo Mondi wrote: > Hi Bryan > > On Mon, May 06, 2024 at 11:38:26PM GMT, Bryan O'Donoghue wrote: >> Currently we have the following algorithm to calculate what value should be >> written to the exposure control of imx412. >> >> lpfr = imx412->vblank + imx412->cur_mode->height; >> shutter = lpfr - exposure; >> >> The 'shutter' value is given to IMX412_REG_EXPOSURE_CIT however, the above >> algorithm will result in the value given to IMX412_REG_EXPOSURE_CIT >> decreasing as the requested exposure value from user-space goes up. >> >> e.g. >> [ 2255.713989] imx412 20-001a: Received exp 1608, analog gain 0 >> [ 2255.714002] imx412 20-001a: Set exp 1608, analog gain 0, shutter 1938, lpfr 3546 >> [ 2256.302770] imx412 20-001a: Received exp 2586, analog gain 100 >> [ 2256.302800] imx412 20-001a: Set exp 2586, analog gain 100, shutter 960, lpfr 3546 >> [ 2256.753755] imx412 20-001a: Received exp 3524, analog gain 110 >> [ 2256.753772] imx412 20-001a: Set exp 3524, analog gain 110, shutter 22, lpfr 3546 >> >> This behaviour results in the image having less exposure as the requested >> exposure value from user-space increases. >> >> Other sensor drivers such as ov5675, imx218, hid556 and others take the >> requested exposure value and directly. > > has the phrase been truncated or is it me reading it wrong ? Sod's law says no matter how many times you send yourself a patch before sending it to LKML you'll find a typo ~ 2 seconds after reading your patch on LKML. >> Looking at the range of imx sensors, it appears this particular error has >> been replicated a number of times but, I haven't so far really drilled into >> each sensor. > > Ouch, what other driver have the same issue ? So without data sheet or sensor its hard to say if these are correct or incorrect, it's the same basic calculation though. drivers/media/i2c/imx334.c::imx334_update_exp_gain() lpfr = imx334->vblank + imx334->cur_mode->height; shutter = lpfr - exposure; ret = imx334_write_reg(imx334, IMX334_REG_SHUTTER, 3, shutter); drivers/media/i2c/imx335.c::imx335_update_exp_gain() lpfr = imx335->vblank + imx335->cur_mode->height; shutter = lpfr - exposure; ret = imx335_write_reg(imx335, IMX334_REG_SHUTTER, 3, shutter); Looking again I'm inclined to believe the imx334/imx335 stuff is probably correct for those sensors, got copied to imx412/imx577 and misapplied to the EXPOSURE control in imx412. >> - ret = imx412_write_reg(imx412, IMX412_REG_EXPOSURE_CIT, 2, shutter); >> + ret = imx412_write_reg(imx412, IMX412_REG_EXPOSURE_CIT, 2, exposure); > > No datasheet here, can you confirm the IMX412_REG_EXPOSURE_CIT > register is actually in lines ? Looks like. From downstream "coarseIntgTimeAddr" imx577_sensor.xml 0x0202 imx586/imx586_sensor.cpp pRegSettingsInfo->regSetting[regCount].registerAddr = pExposureData->pRegInfo->coarseIntgTimeAddr + 1; pRegSettingsInfo->regSetting[regCount].registerData = (lineCount & 0xFF); > Apart from that, as the CID_EXPOSURE control limit are correctly > updated when a new VBLANK is set by taking into account the exposure > margins, I think writing the control value to the register is the > right thing to do (if the register is in lines of course) > > Reviewed-by: Jacopo Mondi > > Thanks > j > If that's good enough I'll fix the typo and apply your RB. --- bod