From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B5913385B2 for ; Sun, 7 Jun 2026 21:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780869268; cv=none; b=rnga/sRdpFiMpcRaWWpVQ7zaUn+CdLqlE1z91clpMhvt8tT526LgREZLueRWIDM51vsZyDqaC36bkhQ2lIbLt8mkp5eNotnA41xeRqiGaFSNs/7js34RWysZgFlWCxXrm3yhrlU0MHHOouEAQzO77WEgRId2StDBBAHEWSxSReY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780869268; c=relaxed/simple; bh=150ioZ0LLEZLHcSe199xLc1uTWcTa0hHZNNniUOr8uE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HDzfcz+AzjxvR79MxvPxrVPs1J1MGmS1DY7rX8gfT3+YwRjnkFrvcd6So+VIMyB7fVqtd/9yxnHIu0f0aGKYFXBbyAIpXh3nyXuYSa9MeTdr6VVrB/i5+T0Atc+3lJCz0J3hsr2UVEaX3rZrqQyfdpuXQChlfSrVmFhgNMtUxQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LceKN8jN; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LceKN8jN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780869266; x=1812405266; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=150ioZ0LLEZLHcSe199xLc1uTWcTa0hHZNNniUOr8uE=; b=LceKN8jNLa6Y8lO3iC4+a3HFG4J6S8mGp7hHl8TvvMIXIoDFXABbyCbR 3gdt7cwlZ6Pz+U07QTqFGFt740Zg4KPauycIhbTJ0XhOdkDyUaWWxYnoa KSVBj7mhRkUWyh+eqrzrrIcOIvtvUbq6SIUZm8/CFZdbMGUYNzfs1AePN f/dhKKC2/Wfk8A2XjjmgWrlNJoMC6ckRjlesQtDrjfBhB4NFgaztFu6TF Ik0CvNzhjrTrrlFl63ZNn4ppx57YTpBrdXEDXV8oYNZEAIag7++BqWlTu FlwGg7HLzLRCrwTQgIdhCy8VziqTebmHEh0aFTKwmvhLld1/SGFAPd9NI Q==; X-CSE-ConnectionGUID: HWxoCuxMRGWA9HjgAZDSqA== X-CSE-MsgGUID: tMig2JTuR1qfmiEzaam3dQ== X-IronPort-AV: E=McAfee;i="6800,10657,11810"; a="107048328" X-IronPort-AV: E=Sophos;i="6.24,193,1774335600"; d="scan'208";a="107048328" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2026 14:54:24 -0700 X-CSE-ConnectionGUID: wot2kF/QQhCU+kmSlADobQ== X-CSE-MsgGUID: g0SuLo+9SpeXGBZ63v+EyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,193,1774335600"; d="scan'208";a="245490508" Received: from amilburn-desk.amilburn-desk (HELO kekkonen.fi.intel.com) ([10.245.244.101]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2026 14:54:18 -0700 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id B1598121CA0; Mon, 08 Jun 2026 00:54:07 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1wWLRM-00000003XIZ-0ybU; Mon, 08 Jun 2026 00:53:56 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hans@jjverkuil.nl, laurent.pinchart@ideasonboard.com, Prabhakar , Kate Hsuan , Dave Stevenson , Tommaso Merciai , Benjamin Mugnier , Sylvain Petinot , Christophe JAILLET , Julien Massot , Naushir Patuck , "Yan, Dongcheng" , Stefan Klug , Mirela Rabulea , =?UTF-8?q?Andr=C3=A9=20Apitzsch?= , Heimir Thor Sverrisson , Kieran Bingham , Mehdi Djait , Ricardo Ribalda Delgado , Hans de Goede , Jacopo Mondi , Tomi Valkeinen , David Plowman , "Yu, Ong Hock" , "Ng, Khai Wen" , Jai Luthra , Rishikesh Donadkar Subject: [PATCH v5 06/10] media: imx219: Fix vertical blanking and exposure for analogue binning Date: Mon, 8 Jun 2026 00:53:52 +0300 Message-ID: <20260607215356.842932-7-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260607215356.842932-1-sakari.ailus@linux.intel.com> References: <20260607215356.842932-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When vertical analogue binning is in use, the minimum frame length in lines decreases to around half of the normal. In relation to the sensor's output size this means vertical blanking can be negative but that's not an issue as control values are signed. Remove the workaround for this non-issue that doubled the pixel rate, frame length in lines and exposure time. The resulting change also fixes the minimum, the maximum and the step values for the control. Fixes: f513997119f4 ("media: i2c: imx219: Scale the pixel rate for analog binning") Signed-off-by: Sakari Ailus --- drivers/media/i2c/imx219.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 3aebcbaa3fcd..3cee31758b7e 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -420,15 +420,6 @@ static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h, } -static inline u32 imx219_get_rate_factor(struct v4l2_subdev_state *state) -{ - u8 bin_h, bin_v; - - imx219_get_binning(state, &bin_h, &bin_v); - - return (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ? 2 : 1; -} - /* ----------------------------------------------------------------------------- * Controls */ @@ -440,19 +431,17 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl) struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd); const struct v4l2_mbus_framefmt *format; struct v4l2_subdev_state *state; - u32 rate_factor; int ret = 0; state = v4l2_subdev_get_locked_active_state(&imx219->sd); format = v4l2_subdev_state_get_format(state, 0); - rate_factor = imx219_get_rate_factor(state); if (ctrl->id == V4L2_CID_VBLANK) { int exposure_max, exposure_def; /* Update max exposure while meeting expected vblanking */ exposure_max = format->height + ctrl->val - - IMX219_EXPOSURE_OFFSET * rate_factor; + IMX219_EXPOSURE_OFFSET; exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ? exposure_max : IMX219_EXPOSURE_DEFAULT; ret = __v4l2_ctrl_modify_range(imx219->exposure, @@ -479,7 +468,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_EXPOSURE: cci_write(imx219->regmap, IMX219_REG_EXPOSURE, - ctrl->val / rate_factor, &ret); + ctrl->val, &ret); break; case V4L2_CID_DIGITAL_GAIN: cci_write(imx219->regmap, IMX219_REG_DIGITAL_GAIN, @@ -496,7 +485,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_VBLANK: cci_write(imx219->regmap, IMX219_REG_FRM_LENGTH_A, - (format->height + ctrl->val) / rate_factor, &ret); + format->height + ctrl->val, &ret); break; case V4L2_CID_HBLANK: cci_write(imx219->regmap, IMX219_REG_LINE_LENGTH_A, @@ -837,8 +826,8 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, const struct imx219_mode *mode; struct v4l2_mbus_framefmt *format; struct v4l2_rect *crop; - u8 bin_h, bin_v, bin_hv; - int ret; + u8 bin_h, bin_v; + int ret, bin_hv; format = v4l2_subdev_state_get_format(state, 0); @@ -879,23 +868,25 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, crop->top = (IMX219_NATIVE_HEIGHT - crop->height) / 2; if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { - unsigned int rate_factor = imx219_get_rate_factor(state); int exposure_max; int exposure_def; int llp_min; int pixel_rate; /* Update limits and set FPS to default */ + int vblank_min = ((int)mode->height * (1 - bin_hv) / bin_hv) + + IMX219_VBLANK_MIN; ret = __v4l2_ctrl_modify_range(imx219->vblank, - IMX219_VBLANK_MIN * rate_factor, - (IMX219_FLL_MAX - mode->height) * - rate_factor, rate_factor, - mode->fll_def - mode->height); + vblank_min, + IMX219_FLL_MAX - mode->height, 1, + (int)(mode->fll_def / bin_hv) - + (int)mode->height); if (ret) return ret; ret = __v4l2_ctrl_s_ctrl(imx219->vblank, - mode->fll_def - mode->height); + (int)(mode->fll_def / bin_hv) - + (int)mode->height); if (ret) return ret; @@ -932,7 +923,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, return ret; /* Scale the pixel rate based on the mode specific factor */ - pixel_rate = imx219_get_pixel_rate(imx219) * rate_factor; + pixel_rate = imx219_get_pixel_rate(imx219); ret = __v4l2_ctrl_modify_range(imx219->pixel_rate, pixel_rate, pixel_rate, 1, pixel_rate); if (ret) -- 2.47.3