From patchwork Mon Sep 11 13:14:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 721611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C92B4EEB59B for ; Mon, 11 Sep 2023 20:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbjIKUte (ORCPT ); Mon, 11 Sep 2023 16:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237825AbjIKNOh (ORCPT ); Mon, 11 Sep 2023 09:14:37 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B08EE for ; Mon, 11 Sep 2023 06:14:31 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9a6190af24aso554648366b.0 for ; Mon, 11 Sep 2023 06:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694438070; x=1695042870; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tmmIFS2GsvUhYHjMDD0wvEsdZNEsSt4tmle0ldKlqCs=; b=gyncj+wwTzKmikglWPWnSN1r5bA9Dg6TDQzB7R0J90ZrUR2URW1kXrfMoZ8/qqKTef /Q3kXtzGbelh+lqb2k6CjPRKS31MHWnYfukoJ0NmNVLMPx/oUzpjQKG5ZjcAzgyT1Szh D6Dm/bf7Np2fmBLy+tLPCqQ1UdhtsY+heF+PPrV/0EcCnBuDFkMt7sqkIFeycBi4+p1l e6Sv0fdrP9AWriUgmOVa1hfddIs9nSLGed7cJoxGmNzZEPthQxt0D8qBmrGpVXX7I3Td 78ZQasDFD6TMg8vSq5HFN5QTnsMV+Bf0OiVbtDTytOmG831uTOaWPZ9PapWILgjPVbTc 1xpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694438070; x=1695042870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tmmIFS2GsvUhYHjMDD0wvEsdZNEsSt4tmle0ldKlqCs=; b=pXHApBFN0VmXEgo1sM37rhkvT0nF1f6zhUYDQjCfrOmTSJSf9OGaaYwAIFnH1jlMfr 1nppeAZpc8AxW9VDjhPPeuYe2v8q8O9SiXoeWnrty0UFvc5VdZIVIm6zEK2xsl0R0r9B RW9qWFhBfVXN7pYZT1TV1+IlHvdkGrXcGRusBpSdR91bx8OlGBNTR8m4A8J0ZH5gyGP1 lIwIjA8tebOeLm7x9neM/Yw9rHlHZNl6mELRoUlnJMvqc585q7akigYlkuv2vb7InqFd bOGe/ODmR3LR6BJLYAO7rlcE2MW+7W+UVchKetbmONubKC/kiPtxY74nqkVQAoqLVY4e BuAw== X-Gm-Message-State: AOJu0Yzw9D6iHUBXU1q7YMrmAnLv1AhWzy0iN+R6TDGj50w7zllY7ie3 in63tZoi2vs0NmeNQa9rjr2dOA== X-Google-Smtp-Source: AGHT+IGhuxr4vSNK9pUHdEX30IVpyboInhXL/zX02dW6lafZlOonCKHjvpQJlDfg5snir97qcrUiGw== X-Received: by 2002:a17:906:6411:b0:9a2:295a:9bc5 with SMTP id d17-20020a170906641100b009a2295a9bc5mr7839683ejm.21.1694438070402; Mon, 11 Sep 2023 06:14:30 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id kt8-20020a170906aac800b00988e953a586sm5313648ejb.61.2023.09.11.06.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 06:14:29 -0700 (PDT) From: Bryan O'Donoghue To: rfoss@kernel.org, todor.too@gmail.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 15/17] media: qcom: camss: Move vfe_disable into a common routine where applicable Date: Mon, 11 Sep 2023 14:14:09 +0100 Message-ID: <20230911131411.196033-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911131411.196033-1-bryan.odonoghue@linaro.org> References: <20230911131411.196033-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We can move vfe_disable() into a common routine in the core VFE file provided we make wm_stop() a VFE specific callback. The callback is required to capture the case where VFE 17x currently isn't VC enabled where as VFE 480 is. Suggested-by: Laurent Pinchart Signed-off-by: Bryan O'Donoghue --- .../media/platform/qcom/camss/camss-vfe-170.c | 40 +------------------ .../media/platform/qcom/camss/camss-vfe-480.c | 40 +------------------ drivers/media/platform/qcom/camss/camss-vfe.c | 39 ++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.h | 9 +++++ 4 files changed, 50 insertions(+), 78 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-170.c b/drivers/media/platform/qcom/camss/camss-vfe-170.c index a5aa799501861..0b211fed12760 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-170.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-170.c @@ -494,22 +494,6 @@ static int vfe_enable_output(struct vfe_line *line) return 0; } -static void vfe_disable_output(struct vfe_line *line) -{ - struct vfe_device *vfe = to_vfe(line); - struct vfe_output *output = &line->output; - unsigned long flags; - unsigned int i; - - spin_lock_irqsave(&vfe->output_lock, flags); - for (i = 0; i < output->wm_num; i++) - vfe_wm_stop(vfe, output->wm_idx[i]); - output->gen2.active_num = 0; - spin_unlock_irqrestore(&vfe->output_lock, flags); - - vfe_reset(vfe); -} - /* * vfe_enable - Enable streaming on VFE line * @line: VFE line @@ -555,29 +539,6 @@ static int vfe_enable(struct vfe_line *line) return ret; } -/* - * vfe_disable - Disable streaming on VFE line - * @line: VFE line - * - * Return 0 on success or a negative error code otherwise - */ -static int vfe_disable(struct vfe_line *line) -{ - struct vfe_device *vfe = to_vfe(line); - - vfe_disable_output(line); - - vfe_put_output(line); - - mutex_lock(&vfe->stream_lock); - - vfe->stream_count--; - - mutex_unlock(&vfe->stream_lock); - - return 0; -} - /* * vfe_isr_sof - Process start of frame interrupt * @vfe: VFE Device @@ -770,4 +731,5 @@ const struct vfe_hw_ops vfe_ops_170 = { .vfe_enable = vfe_enable, .vfe_halt = vfe_halt, .violation_read = vfe_violation_read, + .vfe_wm_stop = vfe_wm_stop, }; diff --git a/drivers/media/platform/qcom/camss/camss-vfe-480.c b/drivers/media/platform/qcom/camss/camss-vfe-480.c index 43a2964121f22..f2368b77fc6d6 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-480.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-480.c @@ -327,22 +327,6 @@ static int vfe_enable_output(struct vfe_line *line) return 0; } -static void vfe_disable_output(struct vfe_line *line) -{ - struct vfe_device *vfe = to_vfe(line); - struct vfe_output *output = &line->output; - unsigned long flags; - unsigned int i; - - spin_lock_irqsave(&vfe->output_lock, flags); - for (i = 0; i < output->wm_num; i++) - vfe_wm_stop(vfe, output->wm_idx[i]); - output->gen2.active_num = 0; - spin_unlock_irqrestore(&vfe->output_lock, flags); - - vfe_reset(vfe); -} - /* * vfe_enable - Enable streaming on VFE line * @line: VFE line @@ -390,29 +374,6 @@ static int vfe_enable(struct vfe_line *line) return ret; } -/* - * vfe_disable - Disable streaming on VFE line - * @line: VFE line - * - * Return 0 on success or a negative error code otherwise - */ -static int vfe_disable(struct vfe_line *line) -{ - struct vfe_device *vfe = to_vfe(line); - - vfe_disable_output(line); - - vfe_put_output(line); - - mutex_lock(&vfe->stream_lock); - - vfe->stream_count--; - - mutex_unlock(&vfe->stream_lock); - - return 0; -} - /* * vfe_isr_reg_update - Process reg update interrupt * @vfe: VFE Device @@ -581,4 +542,5 @@ const struct vfe_hw_ops vfe_ops_480 = { .vfe_disable = vfe_disable, .vfe_enable = vfe_enable, .vfe_halt = vfe_halt, + .vfe_wm_stop = vfe_wm_stop, }; diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index f3cf387e4907e..3d542ac93b1c2 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -410,6 +410,45 @@ int vfe_put_output(struct vfe_line *line) return 0; } +static int vfe_disable_output(struct vfe_line *line) +{ + struct vfe_device *vfe = to_vfe(line); + struct vfe_output *output = &line->output; + unsigned long flags; + unsigned int i; + + spin_lock_irqsave(&vfe->output_lock, flags); + for (i = 0; i < output->wm_num; i++) + vfe->ops->vfe_wm_stop(vfe, output->wm_idx[i]); + output->gen2.active_num = 0; + spin_unlock_irqrestore(&vfe->output_lock, flags); + + return vfe_reset(vfe); +} + +/* + * vfe_disable - Disable streaming on VFE line + * @line: VFE line + * + * Return 0 on success or a negative error code otherwise + */ +int vfe_disable(struct vfe_line *line) +{ + struct vfe_device *vfe = to_vfe(line); + + vfe_disable_output(line); + + vfe_put_output(line); + + mutex_lock(&vfe->stream_lock); + + vfe->stream_count--; + + mutex_unlock(&vfe->stream_lock); + + return 0; +} + /** * vfe_isr_comp_done() - Process composite image done interrupt * @vfe: VFE Device diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h index 4783afa73a365..09baded0dcdd6 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.h +++ b/drivers/media/platform/qcom/camss/camss-vfe.h @@ -114,6 +114,7 @@ struct vfe_hw_ops { int (*vfe_enable)(struct vfe_line *line); int (*vfe_halt)(struct vfe_device *vfe); void (*violation_read)(struct vfe_device *vfe); + void (*vfe_wm_stop)(struct vfe_device *vfe, u8 wm); }; struct vfe_isr_ops { @@ -192,6 +193,14 @@ int vfe_reserve_wm(struct vfe_device *vfe, enum vfe_line_id line_id); */ int vfe_reset(struct vfe_device *vfe); +/* + * vfe_disable - Disable streaming on VFE line + * @line: VFE line + * + * Return 0 on success or a negative error code otherwise + */ +int vfe_disable(struct vfe_line *line); + extern const struct vfe_hw_ops vfe_ops_4_1; extern const struct vfe_hw_ops vfe_ops_4_7; extern const struct vfe_hw_ops vfe_ops_4_8;