From patchwork Fri Apr 2 10:06:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 414349 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1285275jai; Fri, 2 Apr 2021 03:08:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMnMFxFZwyU9aSYn1gs7cVV2NTQH9f6b8nN/fG8lrKc1yCDtLYJQagVfb0DCtZTE3/HLYx X-Received: by 2002:a92:7b05:: with SMTP id w5mr10173336ilc.232.1617358082265; Fri, 02 Apr 2021 03:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617358082; cv=none; d=google.com; s=arc-20160816; b=J95WWQwdxVEbU1Xxz/IXJDgDh8oLPOE0zmVOkmypnwpPk/t6OoOIcPMTALvd84dHkv fsXKaJIp9Rod1eEAYHroHfhCJ0UYwxKhy5kSg4OOMPP0YCbrYBeWGSMnFkGVZCSY4qC2 2slSyx/ZJCaCbWzE+Fe/N7zR4mKhARxt57LFdMflGd31lee6W4ltsiQevXhxFaAK7H7J BZARuO9Y1/BSTnJQKAzdGAV8v2qfCv7MzHCiAyyJMZOH9VYjjH5xoapPLyvgPgGw9xAY IwhhoiygtPXYo6cTELd0gDrJ/m6l4d22INKl4iQ76CaSWQ55qI+MjqijrR3cVjWpTCqh c64g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sHcyq6p4bV6JWtCYk8/oVqJVtf84Wh6rvRJgeAjFSgk=; b=pSgrTD76vMb3rtREgjyulBV5ncjPx688XE2xPqDn7irmLAnAZ1LT7WmXVyGNDpCtpS pZ/H/tUyTNUuiz+TgnVvSXLme48OwHy+EZbxWqhHD1SYT3PEx+Cgb6rkIkaHEptY8C9H yC7HdsOWFQdOqhinkkNNf4SlVBRlNBwpQorGd4VuPTA0r5yM5rcJ6QlAjZdNit2x7/Cv 9HGFl7VfWf2P50pct52XfySMVvbhb1+8yaswwjjd9y2oTl9YyFmlElx4Cys7hnp3WfXA xJx6abyCy27H0xm/0d3Qy2/EiJQzlpg53GuepAUCTmcPwS2xrp4MfIfhoV6m8i1uN6US KFNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ioxqiwum; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g2si6942838ile.30.2021.04.02.03.08.02; Fri, 02 Apr 2021 03:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ioxqiwum; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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 S235043AbhDBKFq (ORCPT + 17 others); Fri, 2 Apr 2021 06:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234902AbhDBKFn (ORCPT ); Fri, 2 Apr 2021 06:05:43 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91488C061788 for ; Fri, 2 Apr 2021 03:05:42 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id k8so4317705wrc.3 for ; Fri, 02 Apr 2021 03:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sHcyq6p4bV6JWtCYk8/oVqJVtf84Wh6rvRJgeAjFSgk=; b=ioxqiwumFisDjG9W10J1nRHr4V5Sjv0Ig7dZ8dMe5fgWudPhkAt999c1/aTEnRIBeQ R55XJsQqHKtb6enFV8ZTC7nL4MXH3yjWYZ6MBo/cdIyTvYkfRE0uZvwxq5NqHa4LeKzJ k0lbPU71c8n9HQ3L0fZCgEoY+qM+nL1T6PmpqmleObBbOytBSGVRwtqIuznEMZwTixL2 uo5sharzYNGQf97gS+AunD9FgAwjB5n+JAyRI5kmfbjQ+Oh3Q4hAoqGfvfMZYzd4mAYy n3YJPppo/tp6Lwb8ZlJlvAeMQ4ftgF7h/1lsEolZXHM9Qr/4NE2lJwHGzZfDdNl9E8OD rrag== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sHcyq6p4bV6JWtCYk8/oVqJVtf84Wh6rvRJgeAjFSgk=; b=akWdv5iaTExRUzGZC1ejtP4n1D9SH3JkHCX6kob69HHGvQXwEqTRYenA+irE0skkbT z/1I8mDodjfD4e716tfoxlkqyGgvsD6pePY4uFi43Y9SWsPmW7f2pg6aj/RWXEAFuWxC k0gJDQOfvUyOVG38hRT7ZkQhaWBHEdh4iRIh3s/haLCfKpgFG8jG3kCrvWb+I2ztUP2A lzCb9JmYvd8B/DQfQHKOS6HIXltvjeMKrVws8ZeTirCAQXq0nQELS6JoLnhNVjuzaRKK LFh841VNoM+ZJaXzUz+3i0fC81wvJ8Uxtwak0MD51FMErlLGDLoDc2ymp8jW5yd7jJQo 4kDA== X-Gm-Message-State: AOAM531skuxW8DmDDpO5oj7JhuGW15wvaPqzCfR0GgQCjhgDXO9/hlES Hg+oCxvUp+UdWOUj4aF0t4gwsg== X-Received: by 2002:a5d:6cd2:: with SMTP id c18mr14499212wrc.330.1617357941362; Fri, 02 Apr 2021 03:05:41 -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 v18sm15466618wrf.41.2021.04.02.03.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 03:05:41 -0700 (PDT) From: Bryan O'Donoghue To: stanimir.varbanov@linaro.org, agross@kernel.org, bjorn.andersson@linaro.org, mchehab@kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: bryan.odonoghue@linaro.org, dikshita@codeaurora.org, jonathan@marek.ca, vgarodia@codeaurora.org Subject: [PATCH v3 24/25] media: venus: helper: Decide work mode Date: Fri, 2 Apr 2021 11:06:47 +0100 Message-Id: <20210402100648.1815854-25-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210402100648.1815854-1-bryan.odonoghue@linaro.org> References: <20210402100648.1815854-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Dikshita Agarwal Decide work mode for encoder and decoder based on different use-cases. Signed-off-by: Dikshita Agarwal Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/helpers.c | 29 ++++++++++++++++++++- drivers/media/platform/qcom/venus/helpers.h | 2 +- drivers/media/platform/qcom/venus/vdec.c | 2 +- drivers/media/platform/qcom/venus/venc.c | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) -- 2.30.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 77ffb8fbb47f..b813d6dba481 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -18,6 +18,9 @@ #include "hfi_platform.h" #include "hfi_parser.h" +#define NUM_MBS_720P (((1280 + 15) >> 4) * ((720 + 15) >> 4)) +#define NUM_MBS_4K (((4096 + 15) >> 4) * ((2304 + 15) >> 4)) + struct intbuf { struct list_head list; u32 type; @@ -1090,14 +1093,38 @@ int venus_helper_set_output_resolution(struct venus_inst *inst, } EXPORT_SYMBOL_GPL(venus_helper_set_output_resolution); -int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode) +static u32 venus_helper_get_work_mode(struct venus_inst *inst) +{ + u32 mode; + u32 num_mbs; + + mode = VIDC_WORK_MODE_2; + if (inst->session_type == VIDC_SESSION_TYPE_DEC) { + num_mbs = (ALIGN(inst->height, 16) * ALIGN(inst->width, 16)) / 256; + if (inst->hfi_codec == HFI_VIDEO_CODEC_MPEG2 || + inst->pic_struct != HFI_INTERLACE_FRAME_PROGRESSIVE || + num_mbs <= NUM_MBS_720P) + mode = VIDC_WORK_MODE_1; + } else { + num_mbs = (ALIGN(inst->out_height, 16) * ALIGN(inst->out_width, 16)) / 256; + if (inst->hfi_codec == HFI_VIDEO_CODEC_VP8 && + num_mbs <= NUM_MBS_4K) + mode = VIDC_WORK_MODE_1; + } + + return mode; +} + +int venus_helper_set_work_mode(struct venus_inst *inst) { const u32 ptype = HFI_PROPERTY_PARAM_WORK_MODE; struct hfi_video_work_mode wm; + u32 mode; if (!IS_V4(inst->core) && !IS_V6(inst->core)) return 0; + mode = venus_helper_get_work_mode(inst); wm.video_work_mode = mode; return hfi_session_set_property(inst, ptype, &wm); } diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 98106e6eee85..e6269b4be3af 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -32,7 +32,7 @@ int venus_helper_set_input_resolution(struct venus_inst *inst, int venus_helper_set_output_resolution(struct venus_inst *inst, unsigned int width, unsigned int height, u32 buftype); -int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode); +int venus_helper_set_work_mode(struct venus_inst *inst); int venus_helper_set_format_constraints(struct venus_inst *inst); int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, unsigned int output_bufs, diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index fdc9984acb70..0fe4863371e2 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -655,7 +655,7 @@ static int vdec_output_conf(struct venus_inst *inst) u32 ptype; int ret; - ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); + ret = venus_helper_set_work_mode(inst); if (ret) return ret; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 505d092dc433..83425fa8df2d 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -550,7 +550,7 @@ static int venc_set_properties(struct venus_inst *inst) u32 profile, level; int ret; - ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); + ret = venus_helper_set_work_mode(inst); if (ret) return ret;