From patchwork Fri Jan 18 15:56:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 155991 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3412124jaa; Fri, 18 Jan 2019 07:56:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mcSwlxLi4x/R3kDdR42gxiSLYhM4w1H1BUr1Qa9Eb5eM8EPm49nLw+/xy0JouAX9w0/cu X-Received: by 2002:a17:902:47aa:: with SMTP id r39mr19470474pld.219.1547826986402; Fri, 18 Jan 2019 07:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547826986; cv=none; d=google.com; s=arc-20160816; b=Ef/qlsQj00/8NODObph/SZ9ZnNW6e87iqsv2PerxEYQLQSUZFH+tFOKmORrldJxyKr XHVbRW+ve6udGmCPKdcgras6XJ0U8HNepdcMOVfTX7OiGCrgM9D+EtCQC4zULyXOVIHy uDaRZIOq5hJ21xFY2IJS2Ya1GvXceXjYgspFIlsypIa/hYgk0Ok88tM9aVM4282rz4QI sRWqQfdRGu8IfuWO20h9XGyrM/dHPVZseNGby8/68nNfbUCF/eoHfqVyESq6H1OcpMWj d5YNuPMCpmnrfvMqsOb6xO+II+eIS+3q059St/+pW+/GL73EzzzKvnc1HnilJjk5i46L PARQ== 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 :dkim-signature; bh=IlhRlfE+Zj+QzMvvfaa9gaqWOjCT6FCHLtgklD5DeaI=; b=Ypz4KiGsCIYc47rjC0UtzVTMKXHlV7Zm3JLXF2exCGHrV4OcCHM6KOQEPsDfMTtXYV KGAFo9JxdC8k5GFzeTadvccD+LfF7fSZ7bVT5DguyxmpXRtaTdI3+I4ObVDCNyydrIAj UDsMisOV64lX9PtSNmV3v76TfpW4q5yymmpL5poT2W1vwtmr8Z54Drs9bFbkmd/XAezi X89ctjRpv9XO5qYes4m9EeYbmpfy8hWZC9Ntrw+cobuIaPYjm3zd1n1WcYN/Aj9Nq3rO w/0tPelB8GQmWOskRfUlUWfKzC7O8CROHaN+SkSAQxQoHXjtGgXuo19a9Vx3zuv9Obw8 zbdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I4lXJ3Od; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (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 d8si4981349pln.128.2019.01.18.07.56.25; Fri, 18 Jan 2019 07:56:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I4lXJ3Od; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfARP4Z (ORCPT + 15 others); Fri, 18 Jan 2019 10:56:25 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38767 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbfARP4Z (ORCPT ); Fri, 18 Jan 2019 10:56:25 -0500 Received: by mail-wr1-f67.google.com with SMTP id v13so15669856wrw.5 for ; Fri, 18 Jan 2019 07:56:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=IlhRlfE+Zj+QzMvvfaa9gaqWOjCT6FCHLtgklD5DeaI=; b=I4lXJ3OdiEBZv8daCMy3wONl/mhjKPP2EWdUYYZQz1UGTSV+vyV5H3mt1SK16cVUDe Ruzbk1DO1SQTLEikNjpVwFXBxNQ+vE7wxwkPOsxc7UYHvQ3UGL63IaIXJyLGH9uR2hGy wALyH3Gdj4ZJHVBvnNj6IrauZz5hZMJtAL1Ms= 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; bh=IlhRlfE+Zj+QzMvvfaa9gaqWOjCT6FCHLtgklD5DeaI=; b=hmb/03xa653anuvjhii+GvVOXLW2yVdqugVb9Ma9fW/cR//JjVBuyA0IG7f1KIF/hT qpRwIqs7Kb2D9li5hCv7PnRvSYYxOxUtnNNLSPPRupcjx30AvLg7mFRwMKwoFoDp17HP BS90aZADQZrLDlodUFhVhONUSzvRuXvnMadaUVAfeiqh+DNc0p20hDwbY/PeoWkHMGtt zzTp4q4NkOr0mnHfFJZ9v7x48+U7ku243cQE5EYXI4xzRw+u7W8HBDcgOma+8EYjSehS dsA9LSVCDfW2wPODaMaQgyy1i4usZDFH/IvcyMmOC9DS795B93w66cdCd313mWMnQH23 fx6A== X-Gm-Message-State: AJcUukd35HAkTSvTKdR9LkPULRHgzeLjEDE7UgboAJywj7Q51UdL9Kjm kAaXeGsxfWwaZUMEqkLGKu7Bsg== X-Received: by 2002:a5d:4586:: with SMTP id p6mr16606884wrq.69.1547826983364; Fri, 18 Jan 2019 07:56:23 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id p12sm45656324wmi.5.2019.01.18.07.56.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 07:56:22 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Nicolas Dufresne , Hans Verkuil , Stanimir Varbanov Subject: [PATCH] venus: enc: fix enum_frameintervals Date: Fri, 18 Jan 2019 17:56:06 +0200 Message-Id: <20190118155606.21798-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This ixes an issue when setting the encoder framerate because of missing precision. Now the frameinterval type is changed to TYPE_CONTINUOUS and step = 1. Also the math is changed when framerate property is called - the firmware side expects that the framerate one is 1 << 16 units. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 32cff294582f..8c939af0a1f6 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -31,6 +31,7 @@ #include "venc.h" #define NUM_B_FRAMES_MAX 4 +#define FRAMERATE_FACTOR (1 << 16) /* * Three resons to keep MPLANE formats (despite that the number of planes @@ -581,7 +582,7 @@ static int venc_enum_frameintervals(struct file *file, void *fh, struct venus_inst *inst = to_inst(file); const struct venus_format *fmt; - fival->type = V4L2_FRMIVAL_TYPE_STEPWISE; + fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; fmt = find_format(inst, fival->pixel_format, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); @@ -604,12 +605,12 @@ static int venc_enum_frameintervals(struct file *file, void *fh, fival->height < frame_height_min(inst)) return -EINVAL; - fival->stepwise.min.numerator = 1; + fival->stepwise.min.numerator = FRAMERATE_FACTOR; fival->stepwise.min.denominator = frate_max(inst); - fival->stepwise.max.numerator = 1; + fival->stepwise.max.numerator = FRAMERATE_FACTOR; fival->stepwise.max.denominator = frate_min(inst); fival->stepwise.step.numerator = 1; - fival->stepwise.step.denominator = frate_max(inst); + fival->stepwise.step.denominator = 1; return 0; } @@ -654,6 +655,7 @@ static int venc_set_properties(struct venus_inst *inst) struct hfi_quantization quant; struct hfi_quantization_range quant_range; u32 ptype, rate_control, bitrate, profile = 0, level = 0; + u64 framerate; int ret; ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); @@ -664,9 +666,14 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; + framerate = inst->timeperframe.denominator * FRAMERATE_FACTOR; + framerate = DIV_ROUND_UP(framerate, inst->timeperframe.numerator); + ptype = HFI_PROPERTY_CONFIG_FRAME_RATE; frate.buffer_type = HFI_BUFFER_OUTPUT; - frate.framerate = inst->fps * (1 << 16); + frate.framerate = framerate; + if (frate.framerate > frate_max(inst)) + frate.framerate = frate_max(inst); ret = hfi_session_set_property(inst, ptype, &frate); if (ret)