Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp840212pxv; Thu, 22 Jul 2021 13:40:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+SsPfHv61+ewlquBaUwIh3tFVojM6p0V8TvmgiZZdLcIMeGcmsVTzoA1evvSzArjEtkCC X-Received: by 2002:a50:ed89:: with SMTP id h9mr1649088edr.106.1626986415251; Thu, 22 Jul 2021 13:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626986415; cv=none; d=google.com; s=arc-20160816; b=HCYuuN3I3nA87SvKhxV7vcD7x2AZfHAJ1Wgi6WD7yBQjycm/esAnW05wFvzg9rnBNR GJ8XvMymE5UMVz+xngu7PwSwj4qvmqciWCf2Scv64YPvAAQfbVr/0xJ5raHP+2Y4d+N4 X0/ftIpZkwZCf/P/+XsOE2zhQ5/+zqBIYxmr2JraFw69UBst7hbb2zes0twtHZ/G+EcA 5vG76ztcdji2CD7ov3Rzx4tvDV5VsOW2DVen5i2NUYuTMuclsatVRWOmO1d3a8lqa7i4 QWACaLeXjhNmh8IqahNg5mqYLfhvsfRPrLE8GbYdWDBUDglO9/g/gJ6ID4tcWQaWJaSG QGUg== 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=cGfNPzr1gE/pmw2DJmPe2VzUTwaf4gzOMzWZ5kc+WcA=; b=RL55JuZvh0Y7mQvCEtKhP2tJxGjJBy5kBjndVe5E9WX25MMxaADVgAsycmaL8Qf9CY DcYhOBkC5RfkuI299S6HVJ5Whwemeg2mwd6JrPGXPlAeTc9XZdjyQbniz/EzELBwX8KV +04FZtsBEIX5Vc5JD19zXQH+dRehBTonpmfGM5uSXMOsT+W17ZQFVw3t1Ym5yveKLiBd Bi2ABF7PXpWqhfjhjjaIISsMkPz6vAdLIPFagUuqhOhjErZbZxuc1ycvs7XLddvg6T3g 9aMzsgVYcb6sFk8b0GLSwNX8k6GyY9uDHXYkcU86dJ9J9OtMSR6EAslr2oDeR07i0gf3 3nhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pohVws68; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si31018427edy.181.2021.07.22.13.39.52; Thu, 22 Jul 2021 13:40:15 -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=@gmail.com header.s=20161025 header.b=pohVws68; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231531AbhGVTy1 (ORCPT + 99 others); Thu, 22 Jul 2021 15:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231152AbhGVTyB (ORCPT ); Thu, 22 Jul 2021 15:54:01 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3021DC061575; Thu, 22 Jul 2021 13:34:36 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id d12so7210132wre.13; Thu, 22 Jul 2021 13:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cGfNPzr1gE/pmw2DJmPe2VzUTwaf4gzOMzWZ5kc+WcA=; b=pohVws68g8dDugN+8Ckyic30nOcpw662cgNlg2LoOUWpLq9W7/b5cpcYlBCa6wANtI diU5M/mXeCRdX1N7tKzBYSsgzZGoShl6Sd37uYA5xeV+TJzdIZPgKG90fKXjSDLrxUd4 Jsshw/jMg1MpZaM1GJJr8gPfZLIZZFAwkMkyDQXB9YVDGRHGhKSPk6DrXKv7HSYSxTgx TBA8kPTawYh14y+qBjiLv7t+58N5Mf4VDDA0/a0S8DzeSmRc/3MuMUtf/msEGBzC4BCn D9aVBm/QhVagaG20zkBcqbOVY7kBNXu7uvfaPGrfiuERlJnsiADeySX0jZhv4mtqQzYA 4rrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cGfNPzr1gE/pmw2DJmPe2VzUTwaf4gzOMzWZ5kc+WcA=; b=CfzhzVDLHg814qfxUGUWaE58tekuO5d2Qcd9b4Z4lxUX0i39ymBWetpqcjlfbLBofK 1xLy2iA/nCr5Lmy+PGz7sXxkYzyR/vtF7im25pvqDInhiN+zx081yTfqP+HfHFa1POfN AvbyPNKneqKworXpIVFDLr659I2r8f7HfYPVSdKLLB8dmwijhDunTr++zrkd6Gw3FM3N WfNr7ob+B8wvJS6MPscH/oSIU1CVl78NZ/J3+5fGyNVdxN2TWHQCqIeNy1jesuEidFuM y0Bj9+GCuUv2bP9eVWZ8vh2IUvvqGJfnxHHs5Cm3WawN5eV+oqvI73E1bDPKngYSI2hb lKfw== X-Gm-Message-State: AOAM533m3sF43ZXosoirZZ0wnDgs0kuOiZGecxJCG1ntfJfhg0tInYoI /6X9+aQQlntcl54xnanF3UU= X-Received: by 2002:a5d:456d:: with SMTP id a13mr1738806wrc.255.1626986074884; Thu, 22 Jul 2021 13:34:34 -0700 (PDT) Received: from valhalla.home ([2.29.20.106]) by smtp.gmail.com with ESMTPSA id b16sm31036455wrw.46.2021.07.22.13.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 13:34:34 -0700 (PDT) From: Daniel Scally To: Daniel Scally , Mauro Carvalho Chehab , Sakari Ailus , Paul Kocialkowski , Ezequiel Garcia , Hans Verkuil , Yang Li , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-kernel@vger.kernel.org (open list) Cc: Yong Zhi , Bingbu Cao , Tianshu Qiu , Colin Ian King , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH 09/13] media: i2c: cap exposure at height + vblank in ov8865 Date: Thu, 22 Jul 2021 21:34:03 +0100 Message-Id: <20210722203407.3588046-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722203407.3588046-1-djrscally@gmail.com> References: <20210722203407.3588046-1-djrscally@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Exposure limits depend on the total height; when vblank is altered (and thus the total height is altered), change the exposure limits to reflect the new cap. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index e1d3c0d50fdc..941b0f94f249 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -662,6 +662,7 @@ struct ov8865_ctrls { struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *hblank; struct v4l2_ctrl *vblank; + struct v4l2_ctrl *exposure; struct v4l2_ctrl_handler handler; }; @@ -2455,6 +2456,18 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl) unsigned int index; int ret; + /* If VBLANK is altered we need to update exposure to compensate */ + if (ctrl->id == V4L2_CID_VBLANK) { + int exposure_max; + + exposure_max = sensor->state.mode->output_size_y + ctrl->val; + __v4l2_ctrl_modify_range(sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, + exposure_max, + sensor->ctrls.exposure->step, + min(sensor->ctrls.exposure->val, exposure_max)); + } + /* Wait for the sensor to be on before setting controls. */ if (pm_runtime_suspended(sensor->dev)) return 0; @@ -2511,8 +2524,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Exposure */ - v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, 1048575, 16, - 512); + ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, + 1048575, 16, 512); /* Gain */ @@ -2693,6 +2706,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, u32 mbus_code = 0; unsigned int hblank; unsigned int index; + int exposure_max; int ret = 0; mutex_lock(&sensor->mutex); @@ -2740,6 +2754,12 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, hblank); + exposure_max = mode->vts; + __v4l2_ctrl_modify_range(sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, exposure_max, + sensor->ctrls.exposure->step, + min(sensor->ctrls.exposure->val, exposure_max)); + complete: mutex_unlock(&sensor->mutex); -- 2.25.1