Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4012241ybd; Tue, 25 Jun 2019 12:25:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNro2M2W65wDYq75wmjFlRaxZpR7nhk+tmgKM0DDI23RL7WI7LczvH+Eu1fFx+eYKoSEf1 X-Received: by 2002:a63:e90b:: with SMTP id i11mr16428965pgh.351.1561490702614; Tue, 25 Jun 2019 12:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561490702; cv=none; d=google.com; s=arc-20160816; b=IavfAYxYZKZN6ZM7Kn2shxm677gVBhm3eEyrum0fDnf1AM7BimXa/b8UsQG8N1pMEU 4FQmTNbGd8EIVBVAymWhsrIzEUHMapE+fLuiuVIh5DDOn4tgxNcTIVPvhet+46AhB7KC IQumsIeGdXWLSKZaEL7YiUFDhFYmB28rC31Dv9XnkamgU3rkztqRbJDJ7estToNGtaeq BzL5Lw7RkRdc2L02xSgYFP+Bl1GvZFzFAmioQrL37Y7JbaDZHx4U5hspxuz9KR0iAY4b gv09tDWxeli6vty7AKFFAtBVd7ozcEN4jkOS9qbd/gxoQZehSQ/hch7KFYeSvZLKIMbk ncxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature; bh=j6cTqe94cPjsE5AAiOwyaz33Y90ji4DVdnxVOHLgpvQ=; b=souhj1Kp37qUmJWi4qMP2p8nT5aN+75u6wRm5VbgwPC6rE7xwIp6+wPF6Vq94ECdfy FYcSGdEMcBxiRIFqthP8/8Vzb+TbUEa3tm6IgeRCgYfmH+XmNkGpzEbMF4dmjE4eYbmN yI3yDH0ULl/P62akPaDQ7tG9YSY0X6mdxl+UjF5q1UFH5Pg91J9xBxAEg8sPJlN3Sma3 N4XvFpDWCXYBBmx1+eN983Zp5tk7E2z6hXmCjrsdUTcihr3hgrQSSU05/i1QCJk2Anny P0SIRT0We8l9nOkjDr0WyObTY8BYFIt/xj9W1vQ9kMMf5rTUmuFseYZ0gafks1ZSFA6r dlDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="ehVNie/N"; dkim=pass header.i=@codeaurora.org header.s=default header.b=PG1kOt3e; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si972611plz.109.2019.06.25.12.24.46; Tue, 25 Jun 2019 12:25:02 -0700 (PDT) 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=@codeaurora.org header.s=default header.b="ehVNie/N"; dkim=pass header.i=@codeaurora.org header.s=default header.b=PG1kOt3e; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729598AbfFYQ1v (ORCPT + 99 others); Tue, 25 Jun 2019 12:27:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:32898 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbfFYQ1u (ORCPT ); Tue, 25 Jun 2019 12:27:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9CF81607CA; Tue, 25 Jun 2019 16:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561480068; bh=7+1Icjbymq8L1qx+h70wKmmvDiODKS+bu+cfp+Bnwg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ehVNie/NIyDOCmREyDP9Blk+x8W0SsK5yxyNtrFlNcqZvfYBVxONSI++QLhfszFLr b6yIlXd3fInSOScyxZ/1sbr1bV5fm2iwyY0h6GmwkUn7Y3RMOgi9PsfoGeeubcwv8h LdYkzkjOxdG4S0lax7mzDdGWPbWh7j1BOL6pa/iw= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from amasule-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: amasule@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DE13160909; Tue, 25 Jun 2019 16:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561480064; bh=7+1Icjbymq8L1qx+h70wKmmvDiODKS+bu+cfp+Bnwg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PG1kOt3eQJQRl7lUCI3P/vKClDdZ+1GZra2/ErLm3MydLc5xuIKXLkBOARwWWXI8A dR8UcDevnhCRnPZfr+NK/TKWU63Z9Vqdg4o1Tx9vn/W+EMJn89vS+UAIN2xkVeCmXO YdjydDhLi8fRpKWysFisfUAIkbyvgzWP1SCOXRUU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DE13160909 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=amasule@codeaurora.org From: Aniket Masule To: linux-media@vger.kernel.org, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, Aniket Masule Subject: [PATCH v3 1/4] media: venus: Add codec data table Date: Tue, 25 Jun 2019 21:57:21 +0530 Message-Id: <1561480044-11834-2-git-send-email-amasule@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1561480044-11834-1-git-send-email-amasule@codeaurora.org> References: <1561480044-11834-1-git-send-email-amasule@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add vpp cycles for for different types of codec It indicates the cycles required by video hardware to process each macroblock. Initialize the codec data with core resources. Signed-off-by: Aniket Masule --- drivers/media/platform/qcom/venus/core.c | 13 +++++++++++++ drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++ drivers/media/platform/qcom/venus/helpers.c | 30 +++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 1 + drivers/media/platform/qcom/venus/vdec.c | 4 ++++ drivers/media/platform/qcom/venus/venc.c | 4 ++++ 6 files changed, 67 insertions(+) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 7393667..f1597d6 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -473,9 +473,22 @@ static __maybe_unused int venus_runtime_resume(struct device *dev) { 244800, 100000000 }, /* 1920x1080@30 */ }; +static struct codec_freq_data sdm845_codec_freq_data[] = { + { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675 }, + { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675 }, + { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675 }, + { V4L2_PIX_FMT_MPEG2, VIDC_SESSION_TYPE_DEC, 200 }, + { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_DEC, 200 }, + { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_DEC, 200 }, + { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_DEC, 200 }, + { V4L2_PIX_FMT_VP9, VIDC_SESSION_TYPE_DEC, 200 }, +}; + static const struct venus_resources sdm845_res = { .freq_tbl = sdm845_freq_table, .freq_tbl_size = ARRAY_SIZE(sdm845_freq_table), + .codec_freq_data = sdm845_codec_freq_data, + .codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data), .clks = {"core", "iface", "bus" }, .clks_num = 3, .max_load = 2563200, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 7a3feb5..2ed6496 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -35,12 +35,20 @@ struct reg_val { u32 value; }; +struct codec_freq_data { + u32 pixfmt; + u32 session_type; + unsigned int vpp_freq; +}; + struct venus_resources { u64 dma_mask; const struct freq_tbl *freq_tbl; unsigned int freq_tbl_size; const struct reg_val *reg_tbl; unsigned int reg_tbl_size; + const struct codec_freq_data *codec_freq_data; + unsigned int codec_freq_data_size; const char * const clks[VIDC_CLKS_NUM_MAX]; unsigned int clks_num; enum hfi_version hfi_version; @@ -216,6 +224,12 @@ struct venus_buffer { struct list_head ref_list; }; +struct clock_data { + u32 core_id; + unsigned long freq; + struct codec_freq_data *codec_freq_data; +}; + #define to_venus_buffer(ptr) container_of(ptr, struct venus_buffer, vb) /** @@ -275,6 +289,7 @@ struct venus_inst { struct list_head list; struct mutex lock; struct venus_core *core; + struct clock_data clk_data; struct list_head dpbbufs; struct list_head internalbufs; struct list_head registeredbufs; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 5cad601..f7f724b 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -715,6 +715,36 @@ int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage) } EXPORT_SYMBOL_GPL(venus_helper_set_core_usage); +int venus_helper_init_codec_data(struct venus_inst *inst) +{ + const struct codec_data *codec_data; + unsigned int i, codec_data_size; + u32 pixfmt; + int ret = 0; + + if (!IS_V4(inst->core)) + return 0; + + codec_data = inst->core->res->codec_data; + codec_data_size = inst->core->res->codec_data_size; + pixfmt = inst->session_type == VIDC_SESSION_TYPE_DEC ? + inst->fmt_out->pixfmt : inst->fmt_cap->pixfmt; + + for (i = 0; i < codec_data_size; i++) { + if (codec_data[i].pixfmt == pixfmt && + codec_data[i].session_type == inst->session_type) { + inst->clk_data.codec_data = &codec_data[i]; + break; + } + } + + if (!inst->clk_data.codec_data) + ret = -EINVAL; + + return ret; +} +EXPORT_SYMBOL_GPL(venus_helper_init_codec_data); + int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, unsigned int output_bufs, unsigned int output2_bufs) diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 2475f284..f9360a8 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -41,6 +41,7 @@ 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_init_codec_data(struct venus_inst *inst); int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage); 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 282de21..51795fd 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -660,6 +660,10 @@ static int vdec_init_session(struct venus_inst *inst) if (ret) goto deinit; + ret = venus_helper_init_codec_data(inst); + if (ret) + goto deinit; + return 0; deinit: hfi_session_deinit(inst); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 32cff29..792cdce 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -847,6 +847,10 @@ static int venc_init_session(struct venus_inst *inst) if (ret) goto deinit; + ret = venus_helper_init_codec_data(inst); + if (ret) + goto deinit; + ret = venc_set_properties(inst); if (ret) goto deinit; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project