From patchwork Tue Nov 13 14:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 150972 Delivered-To: patch@linaro.org Received: by 2002:aa7:da0f:0:0:0:0:0 with SMTP id r15csp4819866eds; Tue, 13 Nov 2018 06:06:44 -0800 (PST) X-Google-Smtp-Source: AJdET5eVnbZQBQQAL+Z01h4mALfY+Cl1kRwVyddMdq3YkPL6HIFPChGh+GOJH7kziqs7vBy7Gk1j X-Received: by 2002:a62:e044:: with SMTP id f65mr877042pfh.208.1542118004138; Tue, 13 Nov 2018 06:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542118004; cv=none; d=google.com; s=arc-20160816; b=m3sv37xmgU8N/RBwqg2ltjHXAkbe2XjkVD78pC+d7K6LtNe4Qc2lzGarnLMeOhOdc7 qRLFjmaxSiHD1cUZ4zvygUlt8PpmDA8O4nmNwLcamtAYsXbNhw684NKWC454c3e8nI4c FjaGCv+6uqCstt8h0dVMv1zGzdRbW1TFRQhzMmXJp5H18k70LtpTTL4V4pC9IVm2aTKU T3rRp2xV0i5CpEpyPouwIdiHbHufGGR6NTyUxAP6CP1U4T9a7Aetlpoq/ufK9u/t8zA9 wGG2nT3gH0/a1bgc0nAKp82Po9N20AAPy8jiVCw4E+UKwLyhvEGIJdnHYejJwLAVIZa/ j+fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=uUB7iIsskGQZilRMOpQcwztFYEsl0pZtq6Bk9TVl020=; b=gsVFbreVtGJ2+Oo7XZSY9XLV6eDbKJZF91K4akp8mFOMAO5cFgM+JyddseNT1pUZ0T ikJCES2WB0YjQWg+B06/7xJ/asQKU1tPOW3fA6J2lado3FVpCFlxTAC2qzXftb1Q+HJY wIPdvf1TK4ekcTBS6AYmdkCoKnTyUbPL9/5yiGa5UxKyHVCJl+1As2fKOZgyEwpkd7b0 wZLBFhWg3NBNB5pguGx6lvm+QCSSL+wwmV6CK/ZFe9mqMdNZaCDLKxlzE9i/Kgg+BUZ+ SZaZPZZIpPQBbZAkLga5jGbQ9bcSq3ulbMtE3PrO7Xj/V7PG3vqldRKp5ZBiFJB0CLsT ANEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si16890025plh.157.2018.11.13.06.06.35; Tue, 13 Nov 2018 06:06:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388250AbeKNABg (ORCPT + 32 others); Tue, 13 Nov 2018 19:01:36 -0500 Received: from ns.mm-sol.com ([37.157.136.199]:60905 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387500AbeKNABf (ORCPT ); Tue, 13 Nov 2018 19:01:35 -0500 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 726CDCDCF; Tue, 13 Nov 2018 16:03:16 +0200 (EET) From: Todor Tomov To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Todor Tomov Subject: [PATCH] media: camss: Take in account sensor skip frames Date: Tue, 13 Nov 2018 16:03:07 +0200 Message-Id: <1542117787-24155-1-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When streaming is starting ask the sensor for its skip frames value. Max supported frame skip is 29 frames, so clip it if it is higher. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss/camss-vfe.c | 23 ++++++++++++++++++----- drivers/media/platform/qcom/camss/camss.c | 2 +- drivers/media/platform/qcom/camss/camss.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index ed6a557..a8c542fa 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -37,9 +37,9 @@ /* VFE halt timeout */ #define VFE_HALT_TIMEOUT_MS 100 /* Max number of frame drop updates per frame */ -#define VFE_FRAME_DROP_UPDATES 5 -/* Frame drop value. NOTE: VAL + UPDATES should not exceed 31 */ -#define VFE_FRAME_DROP_VAL 20 +#define VFE_FRAME_DROP_UPDATES 2 +/* Frame drop value. VAL + UPDATES - 1 should not exceed 31 */ +#define VFE_FRAME_DROP_VAL 30 #define VFE_NEXT_SOF_MS 500 @@ -659,7 +659,9 @@ static int vfe_enable_output(struct vfe_line *line) struct vfe_device *vfe = to_vfe(line); struct vfe_output *output = &line->output; const struct vfe_hw_ops *ops = vfe->ops; + struct media_entity *sensor; unsigned long flags; + unsigned int frame_skip = 0; unsigned int i; u16 ub_size; @@ -667,6 +669,17 @@ static int vfe_enable_output(struct vfe_line *line) if (!ub_size) return -EINVAL; + sensor = camss_find_sensor(&line->subdev.entity); + if (sensor) { + struct v4l2_subdev *subdev = + media_entity_to_v4l2_subdev(sensor); + + v4l2_subdev_call(subdev, sensor, g_skip_frames, &frame_skip); + /* Max frame skip is 29 frames */ + if (frame_skip > VFE_FRAME_DROP_VAL - 1) + frame_skip = VFE_FRAME_DROP_VAL - 1; + } + spin_lock_irqsave(&vfe->output_lock, flags); ops->reg_update_clear(vfe, line->id); @@ -695,10 +708,10 @@ static int vfe_enable_output(struct vfe_line *line) switch (output->state) { case VFE_OUTPUT_SINGLE: - vfe_output_frame_drop(vfe, output, 1); + vfe_output_frame_drop(vfe, output, 1 << frame_skip); break; case VFE_OUTPUT_CONTINUOUS: - vfe_output_frame_drop(vfe, output, 3); + vfe_output_frame_drop(vfe, output, 3 << frame_skip); break; default: vfe_output_frame_drop(vfe, output, 0); diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index 669615f..b307f6e 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -346,7 +346,7 @@ void camss_disable_clocks(int nclocks, struct camss_clock *clock) * * Return a pointer to sensor media entity or NULL if not found */ -static struct media_entity *camss_find_sensor(struct media_entity *entity) +struct media_entity *camss_find_sensor(struct media_entity *entity) { struct media_pad *pad; diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 418996d..c488f63 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -107,6 +107,7 @@ void camss_add_clock_margin(u64 *rate); int camss_enable_clocks(int nclocks, struct camss_clock *clock, struct device *dev); void camss_disable_clocks(int nclocks, struct camss_clock *clock); +struct media_entity *camss_find_sensor(struct media_entity *entity); int camss_get_pixel_clock(struct media_entity *entity, u32 *pixel_clock); int camss_pm_domain_on(struct camss *camss, int id); void camss_pm_domain_off(struct camss *camss, int id);