From patchwork Thu Jan 25 15:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 192150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp66241dyb; Thu, 25 Jan 2024 07:50:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGICNmO1XDmq5mBno/S1JY7Bsr1goPSg5gOreBHex1crNiavcY19e4lx6vtAbN7UP7epND5 X-Received: by 2002:a2e:9b88:0:b0:2cc:87d7:a8e7 with SMTP id z8-20020a2e9b88000000b002cc87d7a8e7mr988257lji.102.1706197841250; Thu, 25 Jan 2024 07:50:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706197841; cv=pass; d=google.com; s=arc-20160816; b=nnTu1kyLR9D7XX+kgcLkefUvh12U3d+QPg5t0C1E0b198maHQ4OQTrzTHxrTaCdj1Q AGV7hkjE47nIwAf9hK8DdMIVY45Nd5dcAYNZ0MzqAC+5oaVueQK65dDnGlRio9pD8rZA fAqjHT/8y/ixhFxMtEU+f5Vs1Lu3sGfV8TKwx3xaFLoxh3Mdm5ZqHOsm/J4OZrKsR1Qc 9OTyLuCUrCUNZgsI7Ov4ImrFNePDCEGVaokW8tCFs62MhMD59u/ANRngzPvAx7GWkWoI M+QF76E938Xx8lc8Ene3qvFgIShZm68mVjd1lFJkLmgWcZ6PQi3bMO8cIgS3+5D2IB0D 521w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=skkgt8nN96I9B92yud8opQD7+W98tLYnFuxLW2qQn8s=; fh=6f/5I72Sv/UY+cHLlGttfBgvh/IGbPGmmEwVFdv7piE=; b=iOda+G5IUztKMf3gAuZAhQfyzQlae4BUkIJKyevLC7DMHllSoK9OJHw9K0dvD4n3vg aVehRKf2qISw4Lype4Rj+SA36ZLpd92SMcwyYl0/XEHByjoVGRfnZrwBhSUZNm9KG8Ue IjfXc+EF2SaZPGwfPSMX6diIqhRR5+xFlirQDx+zLYC7xquArkQ5wfB84vGbWWZ9rV21 llNU3PbKF0J8BErr3NZDusKrcuXrIeE4qqsGpbUEoJKpmS+bBbFIsy3xuAHA0DbWSeEE z0vait3Yx7eAHDbIW4B4YzBbpgLe++uL8+fEtwUYsukMK3BTHekKsxxkJKwESGkdAL8T 9R8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=n3I6TOoN; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-38851-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38851-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i12-20020a50fc0c000000b0055c6587138dsi3620351edr.407.2024.01.25.07.50.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 07:50:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38851-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=n3I6TOoN; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-38851-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38851-ouuuleilei=gmail.com@vger.kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D0C9B1F2622A for ; Thu, 25 Jan 2024 15:50:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB23176901; Thu, 25 Jan 2024 15:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="n3I6TOoN" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 D21F674E2E; Thu, 25 Jan 2024 15:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706197773; cv=none; b=m8XURXG4V1mbPeq6Za5zYJSkCYWrlqHCawoNhd7sRC5PLRMHPqeylFFbzOkOrZ8Mq1Zehs3w4OJq2fR1tr1SbVVqRZf4NL4YD5ODyjbsyFEcbN3s35h5QoT1L8SZFJrAZMLH4X0rRWytinoOVrIYuKKcWSsqi1ynPIeF7Dq2KMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706197773; c=relaxed/simple; bh=qPG6O3t7fXsKr/KZeQDHeleOcdDGSiCC1BklX+oeDXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NeXdVlxVQ9+/JxyS34vE2MXP98VLbyBRpx8iqCFijzv+t2IWpWowedu3n+/UU4LANi0GJIscbvVN0qQtGX+q/efLfCuwM89kUfTzf/VjsNQS3bL3kFdCAIr29vdS8sNATHUvPjjtvYvsj3aSPA7Y1DvXPsDxq8XT9JCoJe3El/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=n3I6TOoN; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from umang.jain (unknown [103.86.18.175]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 159F4A9A; Thu, 25 Jan 2024 16:48:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706197689; bh=qPG6O3t7fXsKr/KZeQDHeleOcdDGSiCC1BklX+oeDXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3I6TOoN5Dqf99Xt1f/VSRpZ8GoNR7RFildvHv3YiTQ72UpzY1MoeV66bzoLcL132 h491vhqDv3+HOU5rk1VJ4tPP93LC6rMsc3ou4OPCo7vsPbgjyWuY2OhElcn4tEZpSv WW4I3+fZwZ81DFpsILUGNdYRiofw5gak2P+AIDaM= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH 2/4] media: i2c: imx335: Refactor power sequence to set controls Date: Thu, 25 Jan 2024 21:19:06 +0530 Message-ID: <20240125154908.465191-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240125154908.465191-1-umang.jain@ideasonboard.com> References: <20240125154908.465191-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789078107398955378 X-GMAIL-MSGID: 1789078107398955378 Additional controls might require the sensor to be powered up to set the control value. Currently, only the exposure control powers up the sensor. Move the power up sequence out of the switch-case block. In a subsequent patch, test pattern control will be added that needs the sensor to be powered up. Hence, refactor the power sequence to be present outside the switch-case block. The VBLANK control is also moved out of the switch-case in order to be handled early on, to propagate the changes to other controls. Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 0df9ea189fff..5add50af20e6 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -475,8 +475,8 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) u32 exposure; int ret; - switch (ctrl->id) { - case V4L2_CID_VBLANK: + /* Propagate change of current control to all related controls */ + if (ctrl->id == V4L2_CID_VBLANK) { imx335->vblank = imx335->vblank_ctrl->val; dev_dbg(imx335->dev, "Received vblank %u, new lpfr %u\n", @@ -489,12 +489,17 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) imx335->cur_mode->height - IMX335_EXPOSURE_OFFSET, 1, IMX335_EXPOSURE_DEFAULT); - break; - case V4L2_CID_EXPOSURE: - /* Set controls only if sensor is in power on state */ - if (!pm_runtime_get_if_in_use(imx335->dev)) - return 0; + } + + /* + * Applying V4L2 control value only happens + * when power is up for streaming. + */ + if (pm_runtime_get_if_in_use(imx335->dev) == 0) + return 0; + switch (ctrl->id) { + case V4L2_CID_EXPOSURE: exposure = ctrl->val; analog_gain = imx335->again_ctrl->val; @@ -503,14 +508,14 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) ret = imx335_update_exp_gain(imx335, exposure, analog_gain); - pm_runtime_put(imx335->dev); - break; default: dev_err(imx335->dev, "Invalid control %d\n", ctrl->id); ret = -EINVAL; } + pm_runtime_put(imx335->dev); + return ret; }