Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7248174imu; Tue, 22 Jan 2019 02:54:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5od/5r9FIYMmegpOvJarbP/aNAMpM9l62KNcG1CRhc2RvJdp3QHeZvf8h7ItTmy3Kl7iIv X-Received: by 2002:a62:c42:: with SMTP id u63mr32478553pfi.73.1548154499910; Tue, 22 Jan 2019 02:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548154499; cv=none; d=google.com; s=arc-20160816; b=b3yQbY0k9pHq5o1lKGbZ9CUti6AxUPMjKII63xEel7jucvkzQlJacRfnY5fjSfmnJh fqiMeYctO3oQi8Fw0O/w+mHqCJvopbLV/MJTQEoCHg7hoFHxRyvQY5XoWWQUVNdrw0P3 jiBU2fVRli1jSTq4UVCKBrQDWGP5unD/Feqcktw1bBs/0FVqdE/dvr0FO6sSzA8O25It 7n+qXa/AzQKicHg6m4rfsWYpTixIU2vfnRgzCAA30z0+Unu4t9NgU2CD5W+rXcONEnpG PZB0GnQ8ycJmWn4/0b6VGcFySc9DNB1d8WMgERz5EFG+8aPvufHwJNNVfeD2F++Znqrk 8e0Q== 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=rM33faaWOnnEbA4hE/AGEkPGi0NvXGI2Z2jymwyY8WG3KrEZZJEWjkb625eCaVcmx0 dmzxx6QBZ7xf7H+LjLpQggW4fEjGNt+765acOfJfjLJt1di52n/v4G8lsId96W/6iXV/ DXe3zKkPPi72YacpbS0Ga1vrr8rPUOTzDXNztXjbAECR0djeEtxcg2i//jSNMFQ8M3P5 5xgP5S8OQ8PT7wlfekOc3NrVFAMTIfJnSHxybPb80AoqgvFgMmx5iibL4Uo5xziYDShC rIdgC+qAIrVBbEQVgeIkrRdTDxn16rtKVmknteRON5Hwcn7SvOrU97ohiaeeFGeSDqTp I8Hg== 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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 w10si14850246pgj.214.2019.01.22.02.54.43; Tue, 22 Jan 2019 02:54:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Ui1d49Ds; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbfAVKxi (ORCPT + 99 others); Tue, 22 Jan 2019 05:53:38 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33070 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbfAVKxi (ORCPT ); Tue, 22 Jan 2019 05:53:38 -0500 Received: by mail-wm1-f65.google.com with SMTP id r24so8263931wmh.0 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=YsQ9IIf1JoXsDs67JbGHsPmALG2CKsQvV7bxZKx7y9YkJK/+hh4YV3hUzh9MAg3F8m U4S1YjUMDIO6R7g0oHQ7DQFVafbs3/UpJ02caO4ZMzXhwa85MYbfge27S0C+ds4a7LA2 5Uv/CuFhTGQMgndzO5QcG6eLeWhQ/rVB/Otwug0E+FY9YT0rBNC/dJtWxYld/xsZNpss sjpyOIQlonrXX6lpNXnZz1dfVt45rFjZJP38jUTRURTaWXy8bUeFDHjgJkeS4gZH6ujX +RyH/qy59A1GdBukRPoq4Yzn9BOyoK6J/unaD2QmVzHKapJQ2btLcb7CoT/NZepHXxNA p/xA== X-Gm-Message-State: AJcUuke+Nnr7v6tP5XryLqJADbiy2BENy4t3334rZIsw5h/guQu/j9g0 xSla0GJDsVF9Qkz3ThavVrsRRA== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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) -- 2.17.1