From patchwork Tue Jan 22 10:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 156291 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7426361jaa; Tue, 22 Jan 2019 02:53:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN7EhjDdaECCEdNIkUS0/HZRs+GIz44+NnE/XLSO8tW6HZ2yXy+NxUt6iqG5kk7sRJTdtXSj X-Received: by 2002:a17:902:6113:: with SMTP id t19mr32753901plj.248.1548154420419; Tue, 22 Jan 2019 02:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548154420; cv=none; d=google.com; s=arc-20160816; b=QgBMfF8wQu6cY5Q2jUC912dQ0fe61O6Up+imNzKe0A52YPiFo1bhOTAB3EDq59agWp 66pq+NTzf48dOz2BVbaby2EKyuIkkTy7TqqIyl4uJuJrkngaUdNGy/PUfRiMQCM3O12q JKLxeeTBJeREpjcUCM63Cli3G3rsOhZ9VC0g+T2t/KOuQHPBwnl0xHKr5AvzZnvsq5X0 aClZbhcTgR0L9t0UH1lr46kLcSHyRGnMBUnVF7oCGn4kJ/TE68CRXhUnDeXXZRFk6DDf m3jFwyy/z+bieEkIr8XRfjNiPlLsdvaacOutP58GDHn+Wu+qg5tIIXc4buhKMcfZANtJ /o1A== 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=NnQIyDGoOvvLQyT3SOkwKzSCHWkztHfCr+VWK1pMgUM=; b=JzJrg1THCG+5ZPR6gaamPolskc/eI3REahGfZO7xglWWvv5HulR7hRSo+AmDBiryo9 i0HX/4cxGRcH+rY5pbOhjXASadBbGsZW9uKKaByynGk36XhYpPjDDhPqhMxvfB3MhNGT h01SnQBjEbQ90iW41TVuC4c3K6T37hjBsrr53KBidxXvgw8IqJQG9z3V3RZcMdIgDEv/ j57c0OM9XengPn9cgaqzGXa9YA0USGBbAxLZTr1YOV/RS8OLklbDdjq91zoTzGcnlmYs yhcmyN2UwmKoKddMJhMA4W8PoGpfU75oH9s1pqasyLhYh0+T4JW2TWgt70JJTjYp+VaW QxFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ui1d49Ds; 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 r2si12932834pgo.483.2019.01.22.02.53.40; Tue, 22 Jan 2019 02:53:40 -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=Ui1d49Ds; 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 S1727048AbfAVKxj (ORCPT + 15 others); Tue, 22 Jan 2019 05:53:39 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34646 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbfAVKxi (ORCPT ); Tue, 22 Jan 2019 05:53:38 -0500 Received: by mail-wm1-f66.google.com with SMTP id y185so8262349wmd.1 for ; Tue, 22 Jan 2019 02:53:37 -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=NnQIyDGoOvvLQyT3SOkwKzSCHWkztHfCr+VWK1pMgUM=; b=Ui1d49Dsvt6j1/x9JbmxE7/pRmDOuhot9VgNrZ6fTCdIrwi3Bvl8TU7fZjMTl0fVob LkqqoivCQ/kUk5U7t3z1urLA5twFbzmbMgJ1PKrRNfezCr4SgBPNXb043xTsFU5tPSKe 8z0NcKhGlnclhzTJXNhhsC4IDTOv2NXUj8M80= 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=NnQIyDGoOvvLQyT3SOkwKzSCHWkztHfCr+VWK1pMgUM=; b=lfTqR+VsVwv2Fw5DRqFIPL6PEZXe+LJTgRhD0p0F8wwJzvrOCSovl/7aJrS+aBvSIC vIJ4c7bdqikDTZfpkLFE15pnYvF8W8pzMtefRdlq79GohUXFCQi8DlNU/yyVfqjMMwTY LUiVM3wgOjlyBBGL2cmiXmex0BP7FgMMl/74DyISmwXl/WZ9gB35tjxWg59VHqJVWniH xLGWbbl3rGnfLEaoQfNZMFyV5NaqrXIQ5W+TNsV9USHyjLyrRp27M80VsTn4nioCWoRF yUIWOT2aw2r2l4Awi6ce92Q4/zEa2RfsaI72+k/a7gqmBxDu9/l5SWUAWVNFOiyDUk4C //KQ== X-Gm-Message-State: AJcUukea+wXUeVzx+xFXBzERwkuEzinMyN3kTnO4hX0vZ/7JxvyCvaUJ wz6jYsTb3h3Xgxv5lEbNMbv8Bg== X-Received: by 2002:a1c:1a8a:: with SMTP id a132mr3273922wma.109.1548154416363; Tue, 22 Jan 2019 02:53:36 -0800 (PST) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id b18sm74256820wrr.43.2019.01.22.02.53.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 02:53:35 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org Cc: Hans Verkuil , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Dufresne , Stanimir Varbanov Subject: [PATCH v2] venus: enc: fix enum_frameintervals Date: Tue, 22 Jan 2019 12:53:22 +0200 Message-Id: <20190122105322.22096-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 --- v2: replace DIV_ROUND_UP with do_div and make roundup manually drivers/media/platform/qcom/venus/venc.c | 19 ++++++++++++++----- 1 file changed, 14 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..99c94b155b46 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,16 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; + framerate = inst->timeperframe.denominator * FRAMERATE_FACTOR; + /* next line is to round up */ + framerate += inst->timeperframe.numerator - 1; + do_div(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)