Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1462760rdb; Tue, 30 Jan 2024 21:54:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMauvrqKXp6RWy4OH92Kvw+fqFHXdC0GTdcCw+ihPu8xWPNzt8YeujVpJahHUx9Z7vypWK X-Received: by 2002:a17:906:d0c9:b0:a36:6c96:3161 with SMTP id bq9-20020a170906d0c900b00a366c963161mr367503ejb.32.1706680494057; Tue, 30 Jan 2024 21:54:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680494; cv=pass; d=google.com; s=arc-20160816; b=Zgy7eYOtSFeYMM13stdq6pQVz19r3Rdz72nTJWP8xrV1faC31ezVLtcB8QAbyJ5lCh MMD4nccUozfyiEpc/HbeL98QuEl04y8VT8hdDqpXVtEi3NKVReXIHI7NDiQqJfjGqOqT ihTssBldZsN21v2OUseJMgczAlXQLmSVigCsI3iZDeSjwdLc3lqM2TjKFrY8phheZRK6 bfmjky/dMwFC/Eucih8qNWRNpPNvuqUi83IblxKGoMnaCNu4qsqKpTsDQ84sM+ucpfcy 1BptIx5i73q2GjcCuHXDQyEnNyOvEz5aCePmpdXDfCvvX3BOWQ6D9ZpYZFleWw2YWBwL HOJQ== 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=ftbLP5hAGtYHA2CennUXgBypmGvFUddMtohhylnbJ9I=; fh=eksM51JMLJhi9u7wWGwAP2PC5+mu9EVnnTOkOVGBbFI=; b=aidVYyLIwRUF5ySiB/ihZYLPg3U8zJWX8SxuJZr3+GtNHn+bA31zyAGabbtHlFRVbi iVI1e3Ii97AY+z1PR8tv1kDszmVnuUtYsP4FqfFlY3iXPzXL7DOId64ENeA/+MXG3MbT KSH0uGCXExohg6k7SngUaNtQZiYZYT8s9fhCnXZlV0oZtBrxX56ohERnLXmH9eOXU0/6 +391BZUoNjlTTHMP85kEJ+JJXb4CC6a4R5zClgT4V6lK7PPzTdCQXLqr6d0JsVdAteSS mTsUFP6FKOhHmkfeWYKe48sSCH6YqI1FSibbppgvnehy5OHUKy9j2Rq0GMOMNZbUrY5w E5wA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Q6A6S9nu; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45794-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45794-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUncRW1LH5fAMCJW+pYJ/4YqKn8sECzaNrjf++PvjNja99MfijP6CzmldHaNabSkoL8kz0DxDgqhfSj/hdeyAKybYkKXTea61tF+qrmTg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oq26-20020a170906cc9a00b00a34ac15e352si5183161ejb.812.2024.01.30.21.54.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:54:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45794-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Q6A6S9nu; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45794-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45794-linux.lists.archive=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 C90A01F2767C for ; Wed, 31 Jan 2024 05:54:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4AD9B4174F; Wed, 31 Jan 2024 05:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Q6A6S9nu" 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 DC0B43FB14; Wed, 31 Jan 2024 05:52: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=1706680352; cv=none; b=qKWf1PNmilGFaFmtF8GZ+T991mHMlGZqhA1dffCiAfLyXqsi+qOA8Tj7QAYIsD51g0zB8tclC+jhLQ7JylRVkIt7lGpZ3gZhihOX0YiVcPcubLEh6x3PqgN7NqB5tL2jsjTuSUHgtYFy6wyORpEeP9mg1HYPsiRMyO1UrAuramg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680352; c=relaxed/simple; bh=vdKoqMvA7LSgk/e2WNUBvI9QcKVaD8d7AAKwOmSxsjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DagYPte9GoseZmiakUi2PPZAHjXfXtYsXc/2VjtdiCwT1Wai6myK+yDTZ2KfC2q9JIgXAjxAowdzSs8pummhoV5E3iNALqmnpFlO7mDy5ssyzHframuGxzghPNwpg0vFRhJYWL4/obJ2PAm5FZNxbWyLHdLntvZU8DKwhfUVfWs= 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=Q6A6S9nu; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 716C6613C; Wed, 31 Jan 2024 06:51:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680266; bh=vdKoqMvA7LSgk/e2WNUBvI9QcKVaD8d7AAKwOmSxsjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6A6S9nu04THOw1LPI+7w0Haoocb3VyKrhOGuNiOodzrEKkipxJdhFtg/1GIJtbH4 LeXABsvHztmnAh/JuJRIVxFPmbCieK/VL8ci02cmAyvimeL5hjhjedlSV5EYIfdkBI s7dl5dYzU4UqR3r5xtT6eLSvAtlgKkoJ9d3VfhAc= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH v2 4/5] media: i2c: imx335: Refactor power sequence to set controls Date: Wed, 31 Jan 2024 11:22:07 +0530 Message-ID: <20240131055208.170934-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 Content-Transfer-Encoding: 8bit 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 | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index ca3eab50f714..250b7136048d 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -526,26 +526,31 @@ 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", imx335->vblank, imx335->vblank + imx335->cur_mode->height); - ret = __v4l2_ctrl_modify_range(imx335->exp_ctrl, - IMX335_EXPOSURE_MIN, - imx335->vblank + - 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; + return __v4l2_ctrl_modify_range(imx335->exp_ctrl, + IMX335_EXPOSURE_MIN, + imx335->vblank + + imx335->cur_mode->height - + IMX335_EXPOSURE_OFFSET, + 1, IMX335_EXPOSURE_DEFAULT); + } + + /* + * 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; @@ -554,14 +559,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; } -- 2.41.0