From patchwork Thu Jul 5 13:03:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141120 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1918392ljj; Thu, 5 Jul 2018 06:05:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe9Ep4F3RyrBeR58JCvVpJwNKofxs9hgDet2yjarnquGKTnD7kT6gIVdszLtxvOMStLvEQ4 X-Received: by 2002:a63:175b:: with SMTP id 27-v6mr2428409pgx.31.1530795916504; Thu, 05 Jul 2018 06:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795916; cv=none; d=google.com; s=arc-20160816; b=UaDBN7qFiz8X6yFIP+qwh1N5UrpWxExnIKLmI5b9rTsew5bJ0rVdgbEoagaT2UmkKI N6995eoNOinT6IflJdd9LdQ4tB0lNCYdnrcqcHHhzcKokM2FMdWiNrdjljYIwjLzQpcm QL1ZNVvfR6Nl6XOkqNoT+7AZZpztKxYttu7IArq8QivcOKfHZ8cx3HTtCPDThepO5BY5 /uOQ4O4tbKu8qThMObczPRp0aFJAfyElBYtTjgXf6HrDOZNQJGuzvtB528F4/Anf3H7O HSno6p2MOd/siW/TW98RP63Aalm3atMVAQr57INZyM5f5IayGFaIo3luVEWIrUbHnoF0 +mLw== 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:dkim-signature:arc-authentication-results; bh=g7vPJ6C9yMPpfGQpi9Z8sz0LII9z4TumPUUp9BsvfwU=; b=trWju4h1j1F0uUK8c+3wqba2dGro6cz0fsCPicYF1XtHQM/uoUGKrof/bvvbUH9D4V C7CiX4zTg+a9Luxhe91Xc24pKj7nGnogAsRKbgWDeFLLvZiJXB0OOztEolLEmJzlyJIr TZUa7l8WduVO4JhcY1iOgG8iB9iqQgifPMf1IhRrfp46+r0/iSbkDCiqg8Lmso62NVa3 h/Tmkh9gAaydY87o+jVsypCTYnxMtYDemcfa23P4llns7dzRmMo6WlP5lNNYUYJ21NTF skWPvYvth2mvJMkyC0mmTbAjNCTYZPq3WJFRWgOQ6Ju5VvEqqbnDTAx2ffkHpLsDL7i+ frvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HbLROi+4; 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 a10-v6si6165265pln.349.2018.07.05.06.05.16; Thu, 05 Jul 2018 06:05:16 -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=@linaro.org header.s=google header.b=HbLROi+4; 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 S1754287AbeGENFN (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:13 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54988 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754172AbeGENFI (ORCPT ); Thu, 5 Jul 2018 09:05:08 -0400 Received: by mail-wm0-f65.google.com with SMTP id i139-v6so10960233wmf.4 for ; Thu, 05 Jul 2018 06:05:07 -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; bh=g7vPJ6C9yMPpfGQpi9Z8sz0LII9z4TumPUUp9BsvfwU=; b=HbLROi+4L0Sw6tgE44gsvKRAAmatlQ8sr/4qOvqYuxgj4yiTm7tmGvzdhPNOCWrwRZ ZiFJxmFclw9ALZPOZANCgljlrMye3QwFzLDGdm4t1bzSR82ozeUz2LRedNy0a5ZVOC63 wlBuW+5pgeOPsfRKsbusJY+/B0iDn2bnjUFyY= 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; bh=g7vPJ6C9yMPpfGQpi9Z8sz0LII9z4TumPUUp9BsvfwU=; b=nQ+idHP+OQ9EUAh3SS2+Psm9nvtpv1McpjovctZYb8VcZmtT57o21kPexamUpXTWW4 ezAUxfWjOCdHR/3+OdNIW3qXrPumhZr/UImFCYVkmrJiCRU44sNOWDzm+k9mJ09bKaae YghOMSx+ZJyiAfshmcFO+ZzUCN90uDyF1ZbW4tcanrTJMi6CxY6EDhkm5+UpW2t2kRAP U3/1zjHICsxw3QML6nL4+DIsRp5M9YHj90BQQc+/LO87ixT0dmzK82CM50fmpgJjZ8Aq 6S+xwl+z6jhDKMVaJTuXL05OIzj5BjJ2xoEmxrfzlNFVGTa/L2U3pyjQ2HKZhJFHgQdx uspQ== X-Gm-Message-State: APt69E2IjwP3yd0r1plz0hN9h5ZmztR8i9MzVqTwWnXFZeR86OCll7rj bxlJ5swiaOMpmS/STlSVEfQ6AQ== X-Received: by 2002:a1c:15ce:: with SMTP id 197-v6mr3807155wmv.99.1530795907043; Thu, 05 Jul 2018 06:05:07 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:06 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 01/27] venus: hfi_msgs: correct pointer increment Date: Thu, 5 Jul 2018 16:03:35 +0300 Message-Id: <20180705130401.24315-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Data pointer should be incremented by size of the structure not the size of a pointer, correct the mistake. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/hfi_msgs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index 90c93d9603dc..589e1a6b36a9 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -60,14 +60,14 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, frame_sz = (struct hfi_framesize *)data_ptr; event.width = frame_sz->width; event.height = frame_sz->height; - data_ptr += sizeof(frame_sz); + data_ptr += sizeof(*frame_sz); break; case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: data_ptr += sizeof(u32); profile_level = (struct hfi_profile_level *)data_ptr; event.profile = profile_level->profile; event.level = profile_level->level; - data_ptr += sizeof(profile_level); + data_ptr += sizeof(*profile_level); break; default: break; From patchwork Thu Jul 5 13:03:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141146 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1929716ljj; Thu, 5 Jul 2018 06:15:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfAmuV4biFO3AVL9RgrZNhE9NetH1qyRkegUibZgT7tx0vCIsRR8HNxCw74dCErUtLe6IL5 X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr5624766pgv.307.1530796520304; Thu, 05 Jul 2018 06:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796520; cv=none; d=google.com; s=arc-20160816; b=zjWn1ee7+HEFofZdnvGF9b/s5mc6I5bJD7kNVIEhZ9hwvqMQab+pRG50yAM6Q4NKlR GxAdeTsT+FV6nY5jZBWgrpSk7c8K4Bgr6RQSLbmt5EIZkoNroXxspNlQu2ngDAvItP29 7vJZVGI8n4W/m07MehIhGdZRsEj8r/zH+LINsoA66euAyLZawwDq5yEGdeXyFDVXknUl NCO2iNLjsSDVpkV+8GCkBwKAKyPTsYJMn3EYzQfNyzRyPsoC7joZF87eHOlZMw0YfNi4 2NGZ62iTstWdcWYUIitS8oxdrn+VYi5XiQwPpsmhvO2Cg2ePIGPpYQAdht3fBXdt85aB W4Hw== 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:dkim-signature:arc-authentication-results; bh=K4nfFwmqq0myRaZLXjTj/33fQADGP40STeZikTfYLbI=; b=rS0xSQWxEmmJVdzIav9up4t2UZoRLNHUH9D4jYxgvcF5a6Cm8j6l2f6ozm3LDEK/Mx BQ1Mm63irL9CLFTUu8dihKsOgRf+ZeUG+gOsCHE3on99TYWHKlfJJ+YqbpYT0mLoWWch qrL73uTB9foSaZvfqqS+/1qP1qssWjEHqiff1r7SjS2kHkbcglS7yLzMrIWJhnHyVXST IdYKB4m46+43HVxarv9HpAUuTn2vQCGWzoqMcFaOLsT7Ty0KLCCrgGYbPMVZZPDz5gpb PeJCpP6MjZt8JRV7u+DOqm0e+TqnlPTGG8sX2VFefGoR3mNJuf+/b5wezgfhg389Ukdp pNqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LSJDE3lj; 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 v12-v6si5892737plo.264.2018.07.05.06.15.19; Thu, 05 Jul 2018 06:15:20 -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=@linaro.org header.s=google header.b=LSJDE3lj; 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 S1754719AbeGENPS (ORCPT + 31 others); Thu, 5 Jul 2018 09:15:18 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40571 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754173AbeGENFJ (ORCPT ); Thu, 5 Jul 2018 09:05:09 -0400 Received: by mail-wm0-f68.google.com with SMTP id z13-v6so10716683wma.5 for ; Thu, 05 Jul 2018 06:05:09 -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; bh=K4nfFwmqq0myRaZLXjTj/33fQADGP40STeZikTfYLbI=; b=LSJDE3ljLj0Z3iP4wEXDLMYDh4QiUkw3M4I6AUslKZmC6Nj/n+UsRctYsc1IOSP7wC aR2EGD7FNAa+Clrt4iOgf8tr9+kLsgYcIvvqR9E0ORuBxxwPxqYuBy+LBJHQ8+zuWOFm /WLoM1VW2vlDHazTzTLpeIL/dknbljHb42uEY= 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; bh=K4nfFwmqq0myRaZLXjTj/33fQADGP40STeZikTfYLbI=; b=bQpAGVov5pNWV42v1xVUpx4d5TIrd9TvEtDkNQRyR2LC9zvD+a4FUfcPQfCqY2v5Lc Y42SDC6o0rgK73Tc0BjWApiXUE7Vz3hAEve1SdXZxvbsyZgqfewW8IOnE1HuFMXRrfnl BC9DUUqolP0DEaeCWVwuzqQmJAT3hqcILNkrkdRxElVp3WFzgX4csDEVk6z+77UNQtGc ylSG82PKO7H0rgjbjE+1fAo3xE4UF7RK60CpP1KFhD3pSt9SVtRimrGUYyyy5Jiq2RGY rm2WY0PP2N8U1nyI9r1x8CWm8e+1oWfRY59/GbiVnUxnY80HwkB5jDuOjqUHQkKLmn6+ tvRQ== X-Gm-Message-State: APt69E2MI/zs42G52WHz1B6h/8dbsJ4pfgwWkgaN2dU0U8FbjHTH+ikg f6j2VRuMEJFQKY4JAjXO0oH/Og== X-Received: by 2002:a1c:ee5d:: with SMTP id m90-v6mr4062714wmh.113.1530795908458; Thu, 05 Jul 2018 06:05:08 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:07 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 02/27] venus: hfi: preparation to support venus 4xx Date: Thu, 5 Jul 2018 16:03:36 +0300 Message-Id: <20180705130401.24315-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This covers the differences between 1xx,3xx and 4xx. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 4 ++ drivers/media/platform/qcom/venus/helpers.c | 56 ++++++++++++++++-------- drivers/media/platform/qcom/venus/hfi_helper.h | 56 +++++++++++++++++++++--- drivers/media/platform/qcom/venus/hfi_venus_io.h | 7 +++ drivers/media/platform/qcom/venus/vdec.c | 5 ++- drivers/media/platform/qcom/venus/venc.c | 5 ++- 6 files changed, 104 insertions(+), 29 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 0360d295f4c8..8d3e150800c9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -305,6 +305,10 @@ struct venus_inst { struct hfi_buffer_requirements bufreq[HFI_BUFFER_TYPE_MAX]; }; +#define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) +#define IS_V3(core) ((core)->res->hfi_version == HFI_VERSION_3XX) +#define IS_V4(core) ((core)->res->hfi_version == HFI_VERSION_4XX) + #define ctrl_to_inst(ctrl) \ container_of((ctrl)->handler, struct venus_inst, ctrl_handler) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 0ce9559a2924..a08ecd263e73 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -166,21 +166,38 @@ static int intbufs_unset_buffers(struct venus_inst *inst) return ret; } -static const unsigned int intbuf_types[] = { - HFI_BUFFER_INTERNAL_SCRATCH, - HFI_BUFFER_INTERNAL_SCRATCH_1, - HFI_BUFFER_INTERNAL_SCRATCH_2, +static const unsigned int intbuf_types_1xx[] = { + HFI_BUFFER_INTERNAL_SCRATCH(HFI_VERSION_1XX), + HFI_BUFFER_INTERNAL_SCRATCH_1(HFI_VERSION_1XX), + HFI_BUFFER_INTERNAL_SCRATCH_2(HFI_VERSION_1XX), + HFI_BUFFER_INTERNAL_PERSIST, + HFI_BUFFER_INTERNAL_PERSIST_1, +}; + +static const unsigned int intbuf_types_4xx[] = { + HFI_BUFFER_INTERNAL_SCRATCH(HFI_VERSION_4XX), + HFI_BUFFER_INTERNAL_SCRATCH_1(HFI_VERSION_4XX), + HFI_BUFFER_INTERNAL_SCRATCH_2(HFI_VERSION_4XX), HFI_BUFFER_INTERNAL_PERSIST, HFI_BUFFER_INTERNAL_PERSIST_1, }; static int intbufs_alloc(struct venus_inst *inst) { - unsigned int i; + const unsigned int *intbuf; + size_t arr_sz, i; int ret; - for (i = 0; i < ARRAY_SIZE(intbuf_types); i++) { - ret = intbufs_set_buffer(inst, intbuf_types[i]); + if (IS_V4(inst->core)) { + arr_sz = ARRAY_SIZE(intbuf_types_4xx); + intbuf = intbuf_types_4xx; + } else { + arr_sz = ARRAY_SIZE(intbuf_types_1xx); + intbuf = intbuf_types_1xx; + } + + for (i = 0; i < arr_sz; i++) { + ret = intbufs_set_buffer(inst, intbuf[i]); if (ret) goto error; } @@ -257,20 +274,23 @@ static int load_scale_clocks(struct venus_core *core) set_freq: - if (core->res->hfi_version == HFI_VERSION_3XX) { - ret = clk_set_rate(clk, freq); - ret |= clk_set_rate(core->core0_clk, freq); - ret |= clk_set_rate(core->core1_clk, freq); - } else { - ret = clk_set_rate(clk, freq); - } + ret = clk_set_rate(clk, freq); + if (ret) + goto err; - if (ret) { - dev_err(dev, "failed to set clock rate %lu (%d)\n", freq, ret); - return ret; - } + ret = clk_set_rate(core->core0_clk, freq); + if (ret) + goto err; + + ret = clk_set_rate(core->core1_clk, freq); + if (ret) + goto err; return 0; + +err: + dev_err(dev, "failed to set clock rate %lu (%d)\n", freq, ret); + return ret; } static void fill_buffer_desc(const struct venus_buffer *buf, diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 55d8eb21403a..f5f1557b1176 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -121,6 +121,7 @@ #define HFI_EXTRADATA_METADATA_FILLER 0x7fe00002 #define HFI_INDEX_EXTRADATA_INPUT_CROP 0x0700000e +#define HFI_INDEX_EXTRADATA_OUTPUT_CROP 0x0700000f #define HFI_INDEX_EXTRADATA_DIGITAL_ZOOM 0x07000010 #define HFI_INDEX_EXTRADATA_ASPECT_RATIO 0x7f100003 @@ -376,13 +377,18 @@ #define HFI_BUFFER_OUTPUT2 0x3 #define HFI_BUFFER_INTERNAL_PERSIST 0x4 #define HFI_BUFFER_INTERNAL_PERSIST_1 0x5 -#define HFI_BUFFER_INTERNAL_SCRATCH 0x1000001 -#define HFI_BUFFER_EXTRADATA_INPUT 0x1000002 -#define HFI_BUFFER_EXTRADATA_OUTPUT 0x1000003 -#define HFI_BUFFER_EXTRADATA_OUTPUT2 0x1000004 -#define HFI_BUFFER_INTERNAL_SCRATCH_1 0x1000005 -#define HFI_BUFFER_INTERNAL_SCRATCH_2 0x1000006 - +#define HFI_BUFFER_INTERNAL_SCRATCH(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0x6 : 0x1000001) +#define HFI_BUFFER_INTERNAL_SCRATCH_1(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0x7 : 0x1000005) +#define HFI_BUFFER_INTERNAL_SCRATCH_2(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0x8 : 0x1000006) +#define HFI_BUFFER_EXTRADATA_INPUT(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0xc : 0x1000002) +#define HFI_BUFFER_EXTRADATA_OUTPUT(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0xa : 0x1000003) +#define HFI_BUFFER_EXTRADATA_OUTPUT2(ver) \ + (((ver) == HFI_VERSION_4XX) ? 0xb : 0x1000004) #define HFI_BUFFER_TYPE_MAX 11 #define HFI_BUFFER_MODE_STATIC 0x1000001 @@ -424,12 +430,14 @@ #define HFI_PROPERTY_PARAM_CODEC_MASK_SUPPORTED 0x100e #define HFI_PROPERTY_PARAM_MVC_BUFFER_LAYOUT 0x100f #define HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED 0x1010 +#define HFI_PROPERTY_PARAM_WORK_MODE 0x1015 /* * HFI_PROPERTY_CONFIG_COMMON_START * HFI_DOMAIN_BASE_COMMON + HFI_ARCH_COMMON_OFFSET + 0x2000 */ #define HFI_PROPERTY_CONFIG_FRAME_RATE 0x2001 +#define HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE 0x2002 /* * HFI_PROPERTY_PARAM_VDEC_COMMON_START @@ -438,6 +446,9 @@ #define HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM 0x1003001 #define HFI_PROPERTY_PARAM_VDEC_CONCEAL_COLOR 0x1003002 #define HFI_PROPERTY_PARAM_VDEC_NONCP_OUTPUT2 0x1003003 +#define HFI_PROPERTY_PARAM_VDEC_PIXEL_BITDEPTH 0x1003007 +#define HFI_PROPERTY_PARAM_VDEC_PIC_STRUCT 0x1003009 +#define HFI_PROPERTY_PARAM_VDEC_COLOUR_SPACE 0x100300a /* * HFI_PROPERTY_CONFIG_VDEC_COMMON_START @@ -518,6 +529,7 @@ enum hfi_version { HFI_VERSION_1XX, HFI_VERSION_3XX, + HFI_VERSION_4XX }; struct hfi_buffer_info { @@ -767,6 +779,22 @@ struct hfi_framesize { u32 height; }; +#define VIDC_CORE_ID_DEFAULT 0 +#define VIDC_CORE_ID_1 1 +#define VIDC_CORE_ID_2 2 +#define VIDC_CORE_ID_3 3 + +struct hfi_videocores_usage_type { + u32 video_core_enable_mask; +}; + +#define VIDC_WORK_MODE_1 1 +#define VIDC_WORK_MODE_2 2 + +struct hfi_video_work_mode { + u32 video_work_mode; +}; + struct hfi_h264_vui_timing_info { u32 enable; u32 fixed_framerate; @@ -961,6 +989,12 @@ struct hfi_buffer_count_actual { u32 count_actual; }; +struct hfi_buffer_count_actual_4xx { + u32 type; + u32 count_actual; + u32 count_min_host; +}; + struct hfi_buffer_size_actual { u32 type; u32 size; @@ -971,6 +1005,14 @@ struct hfi_buffer_display_hold_count_actual { u32 hold_count; }; +/* HFI 4XX reorder the fields, use these macros */ +#define HFI_BUFREQ_HOLD_COUNT(bufreq, ver) \ + ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count) +#define HFI_BUFREQ_COUNT_MIN(bufreq, ver) \ + ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min) +#define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \ + ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0) + struct hfi_buffer_requirements { u32 type; u32 size; diff --git a/drivers/media/platform/qcom/venus/hfi_venus_io.h b/drivers/media/platform/qcom/venus/hfi_venus_io.h index 98cc350113ab..d327b5cea334 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus_io.h +++ b/drivers/media/platform/qcom/venus/hfi_venus_io.h @@ -110,4 +110,11 @@ #define WRAPPER_CPU_STATUS (WRAPPER_BASE + 0x2014) #define WRAPPER_SW_RESET (WRAPPER_BASE + 0x3000) +/* Venus 4xx */ +#define WRAPPER_VCODEC0_MMCC_POWER_STATUS (WRAPPER_BASE + 0x90) +#define WRAPPER_VCODEC0_MMCC_POWER_CONTROL (WRAPPER_BASE + 0x94) + +#define WRAPPER_VCODEC1_MMCC_POWER_STATUS (WRAPPER_BASE + 0x110) +#define WRAPPER_VCODEC1_MMCC_POWER_CONTROL (WRAPPER_BASE + 0x114) + #endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 49bbd1861d3a..261a51adeef2 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -689,6 +689,7 @@ static int vdec_queue_setup(struct vb2_queue *q, static int vdec_verify_conf(struct venus_inst *inst) { + enum hfi_version ver = inst->core->res->hfi_version; struct hfi_buffer_requirements bufreq; int ret; @@ -700,14 +701,14 @@ static int vdec_verify_conf(struct venus_inst *inst) return ret; if (inst->num_output_bufs < bufreq.count_actual || - inst->num_output_bufs < bufreq.count_min) + inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) return -EINVAL; ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); if (ret) return ret; - if (inst->num_input_bufs < bufreq.count_min) + if (inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) return -EINVAL; return 0; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 6b2ce479584e..947001170a77 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -892,6 +892,7 @@ static int venc_queue_setup(struct vb2_queue *q, static int venc_verify_conf(struct venus_inst *inst) { + enum hfi_version ver = inst->core->res->hfi_version; struct hfi_buffer_requirements bufreq; int ret; @@ -903,7 +904,7 @@ static int venc_verify_conf(struct venus_inst *inst) return ret; if (inst->num_output_bufs < bufreq.count_actual || - inst->num_output_bufs < bufreq.count_min) + inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) return -EINVAL; ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); @@ -911,7 +912,7 @@ static int venc_verify_conf(struct venus_inst *inst) return ret; if (inst->num_input_bufs < bufreq.count_actual || - inst->num_input_bufs < bufreq.count_min) + inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver)) return -EINVAL; return 0; From patchwork Thu Jul 5 13:03:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141144 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1929032ljj; Thu, 5 Jul 2018 06:14:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpetUJSqJlbhw2153WA8+y+IPG0iVNA4AGp25yJvps39ZAf11MzwAT1kjlrUBpTxzs5LIdXQ X-Received: by 2002:a63:710d:: with SMTP id m13-v6mr5571748pgc.66.1530796485041; Thu, 05 Jul 2018 06:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796485; cv=none; d=google.com; s=arc-20160816; b=e1W1DGkUg2fevWPa6ZDo7cP+6ib+QvjoUm12MQpW2ovjvuQIGzpc1RxwCceq2aPms7 zjrT5dK9RmPGPqdKBQFVXut/vuFStk42Gnrhl4j7CahukNXf61/BSZBZ+UKeugJzKuho Ii+Mnlk9jXLrU/1UhPpzSAlMpuFg6w9B+EDuDCVkwSK4uK41GLYM12B0Hr2Bv6OJwIct dGcDpSBDiUh3Tk8fxOJUQLuKuEW/uUGTj2ITH7Po2voEB6FSOOQL5GicEaABMOj03AUn TfyFFlv/8vOTxrkH/u3DTCp3Fqgj5LDpPB5L+ebnqoWcoVZHmhNdUlsXNES58Ny/iDmW tXfA== 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:dkim-signature:arc-authentication-results; bh=2Rjs/riZGr/2boEAWhRGcdDD/iS7glDtXPe+puCnQcc=; b=w9PJ+ePhBg/OuVZmrpL9h6bGUaANpeXaCPpNA8MaIrauEPAF9Y8x97RrgAbQG876/y qQTqmVfHI4+/wMAr7CRVrGWWh8J8wwh1ohvDrC7MbhGc0dsFdZOTRPwB7t//0+wTMDHo 0KlLud/M5R2sY/7wgANqWo3fyDQzhQ/Mb+DEn0Uqs26nDrEjL7UicU5/aBtnZJG10ACy YF21Npn7YmI84KjHorLE0moCD7LQUn3WFlNPe6E8rzYnV8Ws7fhyd2XMKGLuccOTruW7 Z+T05baHCMnMJlmMxH+IGTevoeOF4QVULuIO8Tpx3oeK+rEZ5VN9k7FG33vHm4a6VNSq RJGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fI6QMaSX; 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 k20-v6si5570681pgb.115.2018.07.05.06.14.44; Thu, 05 Jul 2018 06:14:45 -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=@linaro.org header.s=google header.b=fI6QMaSX; 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 S1754623AbeGENOl (ORCPT + 31 others); Thu, 5 Jul 2018 09:14:41 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36617 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754195AbeGENFM (ORCPT ); Thu, 5 Jul 2018 09:05:12 -0400 Received: by mail-wm0-f68.google.com with SMTP id s14-v6so10732505wmc.1 for ; Thu, 05 Jul 2018 06:05:11 -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; bh=2Rjs/riZGr/2boEAWhRGcdDD/iS7glDtXPe+puCnQcc=; b=fI6QMaSXVEUj4pi6HST0HtUEy1jU0Txb1l5V5fwAz8pLb+woTfyCHWnmENfX1NYNvS lRFY4DiR0CEB7uGtkBCpErNYQT04hL02RausIn8D4eBw2M2z+d0hzvChjLjILl9XcRx+ z0rjn2B1OQ5XP5vXgyQR1qVR3ryXZJthAwB38= 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; bh=2Rjs/riZGr/2boEAWhRGcdDD/iS7glDtXPe+puCnQcc=; b=fwqbRDphDwn1UXBjY8m7uoQ+Qlk/mZQBq40KRUOTR1pJH0K4k3ZCccxzW2Vi9U5s6l W40XTw/oG+OercOYbg03PYSWwzHVeVzyL/IVgFRetZFogH8Tr0DCHote7RrgjuyUsC6N h1jsAUBz0tcjfLn19RsVAfD5hEVrxYWyRQwVN9vsqUka//6XEFVZAJuJNwIlO1KzrHyi ohXs8GOezEsvCExgj45HwfCZ3l/Oc/R5bvfonBo0cuS+eFZSWdIKl6mqFFq897dG02Wt TIVWCJQ4oxpqfgvDz62OkBwtaAJ8R1QRUJQ/CjK6rYDaBpoOQsprctfzqNK9kSLp6A+Y qfGA== X-Gm-Message-State: APt69E3qNoqw8MZg9a5Ow867byve9zU1kAFfUJ+M2YSZ+H4g7zQ8qJfW 7+6cFwrXxaoqoH1KpCae666+TA== X-Received: by 2002:a1c:aacf:: with SMTP id t198-v6mr3838721wme.109.1530795910894; Thu, 05 Jul 2018 06:05:10 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:10 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 04/27] venus: hfi_cmds: add set_properties for 4xx version Date: Thu, 5 Jul 2018 16:03:38 +0300 Message-Id: <20180705130401.24315-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds set_properties method to handle newer 4xx properties and fall-back to 3xx for the rest. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_cmds.c | 62 +++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index 1cfeb7743041..e8389d8d8c48 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -1166,6 +1166,63 @@ pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, return ret; } +static int +pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, + void *cookie, u32 ptype, void *pdata) +{ + void *prop_data; + + if (!pkt || !cookie || !pdata) + return -EINVAL; + + prop_data = &pkt->data[1]; + + pkt->shdr.hdr.size = sizeof(*pkt); + pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; + pkt->shdr.session_id = hash32_ptr(cookie); + pkt->num_properties = 1; + pkt->data[0] = ptype; + + /* + * Any session set property which is different in 3XX packetization + * should be added as a new case below. All unchanged session set + * properties will be handled in the default case. + */ + switch (ptype) { + case HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL: { + struct hfi_buffer_count_actual *in = pdata; + struct hfi_buffer_count_actual_4xx *count = prop_data; + + count->count_actual = in->count_actual; + count->type = in->type; + count->count_min_host = in->count_actual; + pkt->shdr.hdr.size += sizeof(u32) + sizeof(*count); + break; + } + case HFI_PROPERTY_PARAM_WORK_MODE: { + struct hfi_video_work_mode *in = pdata, *wm = prop_data; + + wm->video_work_mode = in->video_work_mode; + pkt->shdr.hdr.size += sizeof(u32) + sizeof(*wm); + break; + } + case HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE: { + struct hfi_videocores_usage_type *in = pdata, *cu = prop_data; + + cu->video_core_enable_mask = in->video_core_enable_mask; + pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu); + break; + } + case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: + /* not implemented on Venus 4xx */ + break; + default: + return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); + } + + return 0; +} + int pkt_session_get_property(struct hfi_session_get_property_pkt *pkt, void *cookie, u32 ptype) { @@ -1181,7 +1238,10 @@ int pkt_session_set_property(struct hfi_session_set_property_pkt *pkt, if (hfi_ver == HFI_VERSION_1XX) return pkt_session_set_property_1x(pkt, cookie, ptype, pdata); - return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); + if (hfi_ver == HFI_VERSION_3XX) + return pkt_session_set_property_3xx(pkt, cookie, ptype, pdata); + + return pkt_session_set_property_4xx(pkt, cookie, ptype, pdata); } void pkt_set_version(enum hfi_version version) From patchwork Thu Jul 5 13:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141141 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1927751ljj; Thu, 5 Jul 2018 06:13:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3Rxs9f4Z3bJ19ek4QifIVLQUfhzegEAiRD3odNdjG+Wo6olpiC18QUuV4jwOIk7m4CEEz X-Received: by 2002:a65:6614:: with SMTP id w20-v6mr5499762pgv.93.1530796414805; Thu, 05 Jul 2018 06:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796414; cv=none; d=google.com; s=arc-20160816; b=U1kKw/gQMw/EICLipcfJPvo9Z8JJQR/b1pnGxMeRkGyrErJINImA/3Ae+M5B1SDIxU eBFzYoqjE3AulY0UuTqA19f+tBZOVVtq5e8hGeQTU3MoxKnKTZXauwI1ViqLVBfLPJKf LA5bCtDP6lqw2dxCHjOvSyclLzlZhLsmkbwiPdWa6ZgBWV1KpaCuZHsJm9RFZe7ju8Hy jNIo43vx/PvhNF99dAORHoOQwtXESXwFUkDmm5m7HK/L754D7+uQUs7ELWmsKp8VaNFk 0cTnGdxQjdapJZ3Z17ADiwnXwQi0I+CeR8RVIsP31g+qzKbfs3doq/dVQoh28KZxFhU8 jh6A== 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:dkim-signature:arc-authentication-results; bh=zcA1bMzMKszM/ZqPgSXw+wRPd+0JBjNguhSfmeGv3BM=; b=NkkcRArFwvpKqiyELsA0/6v3KnScV2NVpvkX/pbWNX5FsCCZToZyBI44GQYCZzl5VS 2uKM838xewHTBfHnunVTV2hTIKmg/mZkqds/TxShGyuETy8wScK+QoRbPAOvbGBncSeh MoMUyGoFahM4k/SWj0lHHr4nhawHzPXfqM+XUAogQOl2qMklC1VuezFwP0Im7rZ3XMi/ oRSoy1DWbY8u+geXARZH1R/Rn5LRWL1pJyfSm9VlVbFmMCo039P+EOGrn7FVyl6h5UL1 8dTB1drEusqRDyvD3aDYp4YJOzJAQnojSI0Dc/acdxQ1t2xluoR3sjy0thyhFagn1gUK a2jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V1mizovZ; 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 x18-v6si5890894pfh.84.2018.07.05.06.13.34; Thu, 05 Jul 2018 06:13:34 -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=@linaro.org header.s=google header.b=V1mizovZ; 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 S1754341AbeGENFR (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:17 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37989 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754226AbeGENFN (ORCPT ); Thu, 5 Jul 2018 09:05:13 -0400 Received: by mail-wm0-f67.google.com with SMTP id 69-v6so10664076wmf.3 for ; Thu, 05 Jul 2018 06:05:12 -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; bh=zcA1bMzMKszM/ZqPgSXw+wRPd+0JBjNguhSfmeGv3BM=; b=V1mizovZps8cOIMo3Vkh1MqRpu38AyElbafWwbX5Dno/2YEGgXd3rE5HMXpxumutbY 61GasrGuI/RdQSdBHvXqGq+EK6dVRqi6K88Ubx+wf8OTa645+EzK4HuJoY0czEq8Djo4 YKrXpcffA0kMxMxpDO5f/c1O1SrJSIOu9E5Ds= 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; bh=zcA1bMzMKszM/ZqPgSXw+wRPd+0JBjNguhSfmeGv3BM=; b=PjiLsJ6MFVc73chpXJc7dLchMv66ta+MLSQr1ub8Y2DV7tIc8C8uancoo0Z9K7gRHf VwplMyIRwvp2y6cH/fQslCMK/8vPCAdHDWWALwFBKUEwBRk2ALRBGn/Pl5jJb1knxw00 jt/vLjzzxZl75ZI+bSRZU2Eesdm+Uslcytpz73rq8LgMbkSm+Tg7ShOvrW5Lq5VdmphG KAd3kJvClrD5OeGA1qQT0XrYcjCw2oOafZNthM5dkhkxmLMh6YxzgrvIM0DWiIys/1UA ixenWF+Enos2QcILl1N5dWPGzrSEw/uRFjTqNQ6zYfvEY64yco4PYZIv7qWv4jKnjXWz NlyQ== X-Gm-Message-State: APt69E0E0VseT2Tz9bO2c/sq8+kGI6+1lXnGLz7quxLAhUBcY6aZOr9D 7l9OdWpvQt1bGpxU0WHXOsCGY2ECcQQ= X-Received: by 2002:a1c:dc41:: with SMTP id t62-v6mr4206882wmg.42.1530795912008; Thu, 05 Jul 2018 06:05:12 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:11 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 05/27] venus: hfi: support session continue for 4xx version Date: Thu, 5 Jul 2018 16:03:39 +0300 Message-Id: <20180705130401.24315-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes possible to handle session_continue for 4xx as well. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/hfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index bca894a00c07..cbc6fad05e47 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -312,7 +312,7 @@ int hfi_session_continue(struct venus_inst *inst) { struct venus_core *core = inst->core; - if (core->res->hfi_version != HFI_VERSION_3XX) + if (core->res->hfi_version == HFI_VERSION_1XX) return 0; return core->ops->session_continue(inst); From patchwork Thu Jul 5 13:03:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141142 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1927808ljj; Thu, 5 Jul 2018 06:13:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfeIyVvEwiICz4T/s+ryfB/Gu0qQF0dgzJ11Ror981RqoUQKeyjFT1whCxWaWqXCWJoc9pu X-Received: by 2002:a17:902:7086:: with SMTP id z6-v6mr4562253plk.330.1530796417259; Thu, 05 Jul 2018 06:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796417; cv=none; d=google.com; s=arc-20160816; b=NCxWOHVZbtatAPY4dpBU6n/fTB4n+5mqyuruln6ExtK+OOz6zTYAxn5G2HOQJ9ewQ0 GizbjfZ2xA3emIYfNnQC2wKck8Vi8B9/X4DiZ1dj5+TyNjIxEsyY1YWX3xK1oGdDrSVX o2+UFGSMCOgq0fgY0hJm7m+NCxZNTGaTqHzjE+sVHFdE7eHF/wO3gj8YKI9c2w1dFQGl M26EbZL/RJ/cLHRcuBBi2D5aCo4jQ97BmCbhMq0yoGNwEnrXpkV+czrPnB5VzliLP3Gz Kker/hj1nltMjTzYmQkXDe6te7gc+uCNDqfnHnkNmX8GCUum5PakCgXWxz5hBWNpwuH6 6tBg== 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:dkim-signature:arc-authentication-results; bh=g23pTkthDir6WiafxRO9C54UE8+PUxr4OXpPgPQrngc=; b=GoG3W2h0XdALIUbRWXdlg0eQ7vYCOmz0/kHaQ+v9vRmZac3NVz8+oTUhXLrxP5trni 60UwYeFdGAW8SJpAbHMhd78RkVGFJ36Hh5rbh2JFBRXwjvgNuLejl2HXXSnQKV8J0Xis h3lWDdG7OTNRuJ/JXSIHwmFRc1SP4Hx74FwSbHbIAyNSBhd3V9xXHE8rD/BM6LvWCKiG 8JBCVP2xGa19gLeG9xybkfJfN3w7VSbc8HZMtv5MonzLOTc5bBYwxUWgCLr44wSI0SXb cMTZI3EzpEGm7BCUXSAnTPZeKXQSG2/4nkGeuE9oxIzDaje6fJfDI8wh1g3TB0smfAKl gFpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aA1A98sK; 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 x18-v6si5890894pfh.84.2018.07.05.06.13.36; Thu, 05 Jul 2018 06:13:37 -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=@linaro.org header.s=google header.b=aA1A98sK; 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 S1754696AbeGENNe (ORCPT + 31 others); Thu, 5 Jul 2018 09:13:34 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40597 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754319AbeGENFR (ORCPT ); Thu, 5 Jul 2018 09:05:17 -0400 Received: by mail-wm0-f68.google.com with SMTP id z13-v6so10717331wma.5 for ; Thu, 05 Jul 2018 06:05:16 -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; bh=g23pTkthDir6WiafxRO9C54UE8+PUxr4OXpPgPQrngc=; b=aA1A98sKJlU5oj/d+KWTGm94IdY7FQtGWYw5qkP1mFGRuqgGlWlP4fF8N7R8/TG80a jQn9AawpggzvVGbCjR0sHp78xlTQxLO1pRiI1xBJl8khInMH1dMIxOalewou4FK8D31J fOyuYjhoVGbHwAG8Wa+3wDVwrR3R3FLRY8DHs= 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; bh=g23pTkthDir6WiafxRO9C54UE8+PUxr4OXpPgPQrngc=; b=PEE6t5o/67LGGjtiFXyPb43Bkoi+RbZ7JefMFojOiVII502QWfweC8wESW7GXvsdjb F8twk8BixqjIguZ+5pDv2dDJ3kxtPT8czmvtDEJhfRErJ8eO8SXyb4CdgqdVhKq/xzY0 nj3qkhGhaLLFGIwGif8f6uGsLiiPZWIXjSHvDLcpT7hK3xHiXTOZDwokwxMzaGecdnjd l6zbJJNnn+Bm5hDSkeSmre4Q1aLTjW4rmKMA4BtV/VqiYvzkbCqJn1iHukqWWY6JO5II KLqiV8KfA65FYR2aaqrc6KIctaBISdccBvuzYoULcTrwRp2VdvSmJvdzk96RiH6RRSiI 0DdQ== X-Gm-Message-State: APt69E1zhGdnWwFACzjeCpv8T1fz5Lv3ifSMWxtRzK5crAuLjqaxcway QfXMcMMx7raGrJ+dZFfhd8GEPA== X-Received: by 2002:a1c:d9c4:: with SMTP id q187-v6mr3966331wmg.156.1530795915537; Thu, 05 Jul 2018 06:05:15 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:15 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 08/27] venus: hfi_venus: fix suspend function for venus 3xx versions Date: Thu, 5 Jul 2018 16:03:42 +0300 Message-Id: <20180705130401.24315-9-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes the suspend function for Venus 3xx versions by add a check for WFI (wait for interrupt) bit. This bit is on when the ARM9 is idle and entered in low power mode. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 72 ++++++++++++++++-------- drivers/media/platform/qcom/venus/hfi_venus_io.h | 1 + 2 files changed, 51 insertions(+), 22 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 784b3ad1a9f6..72a8547eab39 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1444,13 +1444,40 @@ static int venus_suspend_1xx(struct venus_core *core) return 0; } +static bool venus_cpu_and_video_core_idle(struct venus_hfi_device *hdev) +{ + u32 ctrl_status, cpu_status; + + cpu_status = venus_readl(hdev, WRAPPER_CPU_STATUS); + ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); + + if (cpu_status & WRAPPER_CPU_STATUS_WFI && + ctrl_status & CPU_CS_SCIACMDARG0_INIT_IDLE_MSG_MASK) + return true; + + return false; +} + +static bool venus_cpu_idle_and_pc_ready(struct venus_hfi_device *hdev) +{ + u32 ctrl_status, cpu_status; + + cpu_status = venus_readl(hdev, WRAPPER_CPU_STATUS); + ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); + + if (cpu_status & WRAPPER_CPU_STATUS_WFI && + ctrl_status & CPU_CS_SCIACMDARG0_PC_READY) + return true; + + return false; +} + static int venus_suspend_3xx(struct venus_core *core) { struct venus_hfi_device *hdev = to_hfi_priv(core); struct device *dev = core->dev; - u32 ctrl_status, wfi_status; + bool val; int ret; - int cnt = 100; if (!hdev->power_enabled || hdev->suspended) return 0; @@ -1464,29 +1491,30 @@ static int venus_suspend_3xx(struct venus_core *core) return -EINVAL; } - ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - if (!(ctrl_status & CPU_CS_SCIACMDARG0_PC_READY)) { - wfi_status = venus_readl(hdev, WRAPPER_CPU_STATUS); - ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - - ret = venus_prepare_power_collapse(hdev, false); - if (ret) { - dev_err(dev, "prepare for power collapse fail (%d)\n", - ret); - return ret; - } + /* + * Power collapse sequence for Venus 3xx and 4xx versions: + * 1. Check for ARM9 and video core to be idle by checking WFI bit + * (bit 0) in CPU status register and by checking Idle (bit 30) in + * Control status register for video core. + * 2. Send a command to prepare for power collapse. + * 3. Check for WFI and PC_READY bits. + */ + ret = readx_poll_timeout(venus_cpu_and_video_core_idle, hdev, val, val, + 1500, 100 * 1500); + if (ret) + return ret; - cnt = 100; - while (cnt--) { - wfi_status = venus_readl(hdev, WRAPPER_CPU_STATUS); - ctrl_status = venus_readl(hdev, CPU_CS_SCIACMDARG0); - if (ctrl_status & CPU_CS_SCIACMDARG0_PC_READY && - wfi_status & BIT(0)) - break; - usleep_range(1000, 1500); - } + ret = venus_prepare_power_collapse(hdev, false); + if (ret) { + dev_err(dev, "prepare for power collapse fail (%d)\n", ret); + return ret; } + ret = readx_poll_timeout(venus_cpu_idle_and_pc_ready, hdev, val, val, + 1500, 100 * 1500); + if (ret) + return ret; + mutex_lock(&hdev->lock); ret = venus_power_off(hdev); diff --git a/drivers/media/platform/qcom/venus/hfi_venus_io.h b/drivers/media/platform/qcom/venus/hfi_venus_io.h index c0b18de1e396..def0926a6dee 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus_io.h +++ b/drivers/media/platform/qcom/venus/hfi_venus_io.h @@ -110,6 +110,7 @@ #define WRAPPER_CPU_CGC_DIS (WRAPPER_BASE + 0x2010) #define WRAPPER_CPU_STATUS (WRAPPER_BASE + 0x2014) +#define WRAPPER_CPU_STATUS_WFI BIT(0) #define WRAPPER_SW_RESET (WRAPPER_BASE + 0x3000) /* Venus 4xx */ From patchwork Thu Jul 5 13:03:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141139 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1927000ljj; Thu, 5 Jul 2018 06:12:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd2tId49n6exGxA9praxE5UkOOJts3cTsU+C7ja/AP10dqbvkVjBvnwEdeWMJei2s5JkmmV X-Received: by 2002:a65:60cd:: with SMTP id r13-v6mr5649796pgv.232.1530796373272; Thu, 05 Jul 2018 06:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796373; cv=none; d=google.com; s=arc-20160816; b=JFHf0xvZJRXoGuPtTM/rQ+8z5hAn1b9rID80qzzMXrjDB//xn7fHKCeVHf9DyezLPm C7nQFeE40yXFXTHN7Nn4GC1fBeEGxmofRmMvexNj2v3u7xwstOsZlBpRlbigP7mWvtuC nUVTqXpsCFDhYbk92Rjw1HJO6C8OLV5sgJvBMZp7TP49ChuB6ouC3pRx5rH2OMA4joak tZFOu7wnm63jnKaHLnMMPMncKMxlsNoHoanf46guvYTmcjcsimoEx98hPLUMhqzRaOEc PrM/ZRrvXhZgyPxXXwZiTjCZ0JLDETnXAIQR2GEvfemOYGikzGJx3V4gDYGiC++h73AH LaFQ== 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:dkim-signature:arc-authentication-results; bh=0MKE00JaWerRp2/nQ0l2U1l97a+GwZN1ggGadoc+uKY=; b=j+eEDRqv+De61PdZJg9Gtznb+26Kk7OzKNw5Y3y0xS4gtfTe8PTyjZNa/5nV3dR3/h vkNOqdYojz5K4puzd2c5GX2q7jIT34a2rc7X1m+qPkc0TWKK1daHO+CrykIZUqbvxDel LGbhCI4E7lgLq3U+AbqQROYbuZV1J40OWJ9ZF5zOhc5cyuhN0nd5uPscfhx+qyeP78+B ONKyjpN8u+Z9WkA+bR9Jr+CrMn2BYjZPTz+3WGPudDJobfJtjdjwYncYLO+0+O4lmo+X FVQgq8W7Pan5Vm3DRGhIs8HCOGqklSdQOfIV7v5j+1drg/D2CdGfwDpO9/veOdi3LDpt rDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y+tsa2Kg; 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 i126-v6si6238004pfc.296.2018.07.05.06.12.52; Thu, 05 Jul 2018 06:12:53 -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=@linaro.org header.s=google header.b=Y+tsa2Kg; 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 S1754675AbeGENMv (ORCPT + 31 others); Thu, 5 Jul 2018 09:12:51 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45771 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754342AbeGENFT (ORCPT ); Thu, 5 Jul 2018 09:05:19 -0400 Received: by mail-wr1-f68.google.com with SMTP id u7-v6so1137735wrn.12 for ; Thu, 05 Jul 2018 06:05:18 -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; bh=0MKE00JaWerRp2/nQ0l2U1l97a+GwZN1ggGadoc+uKY=; b=Y+tsa2Kgng9NIpvHg6lzwny2cePlCJmo68eKAkvZ/n6P7oGZ9uglsTSl3c6Psm09ao IaezgHVRYpSiEag/EIiewAtPSsBi1KxExBTPg+/0aQbeaMQH5nukXvWjUVlUHBOcHei7 VCCggFIwfbBCRZcVuE3RTOxtgOPSvjypnkg0k= 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; bh=0MKE00JaWerRp2/nQ0l2U1l97a+GwZN1ggGadoc+uKY=; b=EIC/2y1lfSl0uSlH2DlT+cVi2R68kC0zSy8LdsrwGcl9qwt6gh13JVusjeqdKax4rw F/alnzXkF6ZrQC23N71sDqtN9Tj+H2bFyTNLXxpBj1oEHVH5Ti8tZCxzvJ+ZTIO+m8qq ULY8KqUBqRpZyfWa6a9uuF8Z4D65a9j2aEGga++6rIi1N45CNJhrC4LacaTOVXrSHRFL 7o83BQsiFNNcborA8OF7SBUg8VJvxfdBXr4r3lkI8pGCwZ8DPiynepc1n26tza341HDr d2BmAJPGF24uqtgUgmrg+VJkcAYGv2dXtnN3qfl8unsa/Xltu1FwNV1z86RVvDz4vcMB LHDw== X-Gm-Message-State: APt69E0KMde9fYJDErsmpS0nmi0WvzHtO4RzktaKMg92PTgO7I5y97Du PSECRhZ9wYuFydFWnYaj7081cw== X-Received: by 2002:adf:9f0f:: with SMTP id l15-v6mr4653674wrf.206.1530795917786; Thu, 05 Jul 2018 06:05:17 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:17 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 10/27] venus: hfi_venus: add suspend functionality for Venus 4xx Date: Thu, 5 Jul 2018 16:03:44 +0300 Message-Id: <20180705130401.24315-11-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds suspend (power collapse) functionality by reusing the suspend function for Venus 3xx and also enables idle indicator property for Venus 4xx (where it is disabled by default). Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/hfi_venus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 7a83e967a8ea..124085556b94 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -879,6 +879,14 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev) if (ret) dev_warn(dev, "setting fw debug msg ON failed (%d)\n", ret); + /* + * Idle indicator is disabled by default on some 4xx firmware versions, + * enable it explicitly in order to make suspend functional by checking + * WFI (wait-for-interrupt) bit. + */ + if (IS_V4(hdev->core)) + venus_sys_idle_indicator = true; + ret = venus_sys_set_idle_message(hdev, venus_sys_idle_indicator); if (ret) dev_warn(dev, "setting idle response ON failed (%d)\n", ret); @@ -1533,7 +1541,7 @@ static int venus_suspend_3xx(struct venus_core *core) static int venus_suspend(struct venus_core *core) { - if (core->res->hfi_version == HFI_VERSION_3XX) + if (IS_V3(core) || IS_V4(core)) return venus_suspend_3xx(core); return venus_suspend_1xx(core); From patchwork Thu Jul 5 13:03:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141122 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1918617ljj; Thu, 5 Jul 2018 06:05:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWMIwc7q6sDhnJm0NnjnuywMryia5DXE4CXmQY1hJtXoBYa8155il6nPn0vGJHi/bI+enZ X-Received: by 2002:a65:64c6:: with SMTP id t6-v6mr5568219pgv.223.1530795925534; Thu, 05 Jul 2018 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795925; cv=none; d=google.com; s=arc-20160816; b=QnzYcr0bPcNEfDfUodrQi3L+E/5Uhbr9+Ro3z69nUSV2flNXL3/Pba44Lxjs4hly/q GgaqyGmyvpY8nqBto+vLomBFZxkQjqfzwRSjWdtKRnTMwNdHL8mIXYj8jmCz5I5hFg4u LFiiN47A4Rkamc6thSVBFmoFc9RlQpGWGB9ZqqSrOBK9D4YdDhuCIMsKWbkeArh3u9U6 M3qzjGAgSRCer6vkfrCoxxxUYfrtIr4oDMiDfBo8FtlQWgebzgyHKHl7bY+9MWzx9vZ0 b1OQVl1BXeel/2B23iuzdZeBwhGEMdQq5fXyt6xlFTCWfYrc8rAaHhmVVBYfm7NdLKs/ 3TIA== 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:dkim-signature:arc-authentication-results; bh=4LZFZzSH1cRFIf4n3VOHvIhe79lNAPTHETW3VnI/rv4=; b=dGQB38qO+tSHKfYlwgxGiuTI2kvuOuVkfnsB3Stl/Vk7I/4S8QOHmXpwQOBN8hpPJh KCyI0V0ez0nF1jg7DHsiAwwD1hwpUELKXL/6AeZyLvlvvO4UcctWgDN5xrG5587eUFw7 gLFq89YUjs1EUdcXL8JD26Yzy0IOcf3lfl6eVLrDXVM/tXdWo0m2x3tTJhSh0srsMYJ5 gRApr7Hv9qTCWOQRUAqk9lVorRToWMbQrawmK+uifNOrD3wBFtHnhQCGVUcdEEGLXXkF oBN6vnAqKarIJ/O3mnCBLV0Qq2e6rGyqMQyiOs/elMS8DgAkDOOQbhnSeWdVF8g6DTgy oGng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bo4+9xL9; 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 t10-v6si5738621plh.306.2018.07.05.06.05.25; Thu, 05 Jul 2018 06:05:25 -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=@linaro.org header.s=google header.b=Bo4+9xL9; 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 S1754423AbeGENFX (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37582 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754364AbeGENFU (ORCPT ); Thu, 5 Jul 2018 09:05:20 -0400 Received: by mail-wr1-f65.google.com with SMTP id q10-v6so1140591wrd.4 for ; Thu, 05 Jul 2018 06:05:19 -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; bh=4LZFZzSH1cRFIf4n3VOHvIhe79lNAPTHETW3VnI/rv4=; b=Bo4+9xL91Vm2CkFjAEZIbjab2osn9RgCmHOaB+JWmjs/e/chjsWomctes5hqXI/9ik NFLQRfFtMAnPerbZXjZ/F/7gOXLfBkHHaK5r7RmWQy+uTftaTienZVUWwfUiBbYmLXEj Bg6yAyKuonMWzABrP1ZoXRguevH+XQs+fRreE= 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; bh=4LZFZzSH1cRFIf4n3VOHvIhe79lNAPTHETW3VnI/rv4=; b=FprTjxFprcRih/KcLuxaJDmWkRATyUd0vpXZCUaN+2x0f5qJylntAoX1XqS9j81mvw QZt+8OtyGkUCVfzhTEkFkG/ZwLatjrRf9PsgUAJlHP1NNa5DJpkW7HzCEH48I4zxm1oz bTFoH5vHDOI/yUsfoXXuHXxmc5H9IU4VO6t/lhF9ekxuQhVxFa0Dv2QDsphDgo40FBUN efLDJuwmax3W70bQmSr23/F4e4h0vmscDS3QikN8WKbacTDZ886J3ZMTE3idNTIg5Ch4 QJfwUGftMRK4XPrObG1SX64zuODrYoShuxhp/IcGpR4r5LGZapdLnmL+gWPZ7sBTv07u URCA== X-Gm-Message-State: APt69E23ELG2ANPKdYR4NR0Rn24Rme1cHFVyb+FjHKZv3KdPVD+X/+p6 EmYU6mCtgLG0Zggw5xtGzW8yiQEdlLs= X-Received: by 2002:adf:8895:: with SMTP id f21-v6mr4470733wrf.250.1530795918860; Thu, 05 Jul 2018 06:05:18 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:18 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 11/27] venus: core, helpers: add two more clocks found in Venus 4xx Date: Thu, 5 Jul 2018 16:03:45 +0300 Message-Id: <20180705130401.24315-12-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two more clocks for Venus 4xx in core structure and create a new power enable function to handle it for 3xx/4xx versions. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 4 +++ drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 44 ++++++++++++++++++++----- drivers/media/platform/qcom/venus/venc.c | 44 ++++++++++++++++++++----- 5 files changed, 129 insertions(+), 16 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 8d3e150800c9..2bf8839784fa 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -65,6 +65,8 @@ struct venus_format { * @clks: an array of struct clk pointers * @core0_clk: a struct clk pointer for core0 * @core1_clk: a struct clk pointer for core1 + * @core0_bus_clk: a struct clk pointer for core0 bus clock + * @core1_bus_clk: a struct clk pointer for core1 bus clock * @vdev_dec: a reference to video device structure for decoder instances * @vdev_enc: a reference to video device structure for encoder instances * @v4l2_dev: a holder for v4l2 device structure @@ -94,6 +96,8 @@ struct venus_core { struct clk *clks[VIDC_CLKS_NUM_MAX]; struct clk *core0_clk; struct clk *core1_clk; + struct clk *core0_bus_clk; + struct clk *core1_bus_clk; struct video_device *vdev_dec; struct video_device *vdev_enc; struct v4l2_device v4l2_dev; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index a08ecd263e73..c8c4a4be78e3 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -13,6 +13,7 @@ * */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include "core.h" #include "helpers.h" #include "hfi_helper.h" +#include "hfi_venus_io.h" struct intbuf { struct list_head list; @@ -786,3 +788,52 @@ void venus_helper_init_instance(struct venus_inst *inst) } } EXPORT_SYMBOL_GPL(venus_helper_init_instance); + +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable) +{ + void __iomem *ctrl, *stat; + u32 val; + int ret; + + if (!IS_V3(core) && !IS_V4(core)) + return 0; + + if (IS_V3(core)) { + if (session_type == VIDC_SESSION_TYPE_DEC) + ctrl = core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL; + else + ctrl = core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL; + if (enable) + writel(0, ctrl); + else + writel(1, ctrl); + + return 0; + } + + if (session_type == VIDC_SESSION_TYPE_DEC) { + ctrl = core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; + } else { + ctrl = core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; + stat = core->base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; + } + + if (enable) { + writel(0, ctrl); + + ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100); + if (ret) + return ret; + } else { + writel(1, ctrl); + + ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_power_enable); diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 971392be5df5..0e64aa95624a 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -43,4 +43,6 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); +int venus_helper_power_enable(struct venus_core *core, u32 session_type, + bool enable); #endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 261a51adeef2..d22969d2758a 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1081,12 +1081,18 @@ static int vdec_probe(struct platform_device *pdev) if (!core) return -EPROBE_DEFER; - if (core->res->hfi_version == HFI_VERSION_3XX) { + if (IS_V3(core) || IS_V4(core)) { core->core0_clk = devm_clk_get(dev, "core"); if (IS_ERR(core->core0_clk)) return PTR_ERR(core->core0_clk); } + if (IS_V4(core)) { + core->core0_bus_clk = devm_clk_get(dev, "bus"); + if (IS_ERR(core->core0_bus_clk)) + return PTR_ERR(core->core0_bus_clk); + } + platform_set_drvdata(pdev, core); vdev = video_device_alloc(); @@ -1131,15 +1137,21 @@ static int vdec_remove(struct platform_device *pdev) static __maybe_unused int vdec_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; - if (core->res->hfi_version == HFI_VERSION_1XX) + if (IS_V1(core)) return 0; - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); + if (ret) + return ret; + + if (IS_V4(core)) + clk_disable_unprepare(core->core0_bus_clk); + clk_disable_unprepare(core->core0_clk); - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); - return 0; + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); } static __maybe_unused int vdec_runtime_resume(struct device *dev) @@ -1147,13 +1159,29 @@ static __maybe_unused int vdec_runtime_resume(struct device *dev) struct venus_core *core = dev_get_drvdata(dev); int ret; - if (core->res->hfi_version == HFI_VERSION_1XX) + if (IS_V1(core)) return 0; - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); + if (ret) + return ret; + ret = clk_prepare_enable(core->core0_clk); - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + if (ret) + goto err_power_disable; + + if (IS_V4(core)) + ret = clk_prepare_enable(core->core0_bus_clk); + if (ret) + goto err_unprepare_core0; + + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); + +err_unprepare_core0: + clk_disable_unprepare(core->core0_clk); +err_power_disable: + venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); return ret; } diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 947001170a77..596539d433c9 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1225,12 +1225,18 @@ static int venc_probe(struct platform_device *pdev) if (!core) return -EPROBE_DEFER; - if (core->res->hfi_version == HFI_VERSION_3XX) { + if (IS_V3(core) || IS_V4(core)) { core->core1_clk = devm_clk_get(dev, "core"); if (IS_ERR(core->core1_clk)) return PTR_ERR(core->core1_clk); } + if (IS_V4(core)) { + core->core1_bus_clk = devm_clk_get(dev, "bus"); + if (IS_ERR(core->core1_bus_clk)) + return PTR_ERR(core->core1_bus_clk); + } + platform_set_drvdata(pdev, core); vdev = video_device_alloc(); @@ -1275,15 +1281,21 @@ static int venc_remove(struct platform_device *pdev) static __maybe_unused int venc_runtime_suspend(struct device *dev) { struct venus_core *core = dev_get_drvdata(dev); + int ret; - if (core->res->hfi_version == HFI_VERSION_1XX) + if (IS_V1(core)) return 0; - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); + if (ret) + return ret; + + if (IS_V4(core)) + clk_disable_unprepare(core->core1_bus_clk); + clk_disable_unprepare(core->core1_clk); - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); - return 0; + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); } static __maybe_unused int venc_runtime_resume(struct device *dev) @@ -1291,13 +1303,29 @@ static __maybe_unused int venc_runtime_resume(struct device *dev) struct venus_core *core = dev_get_drvdata(dev); int ret; - if (core->res->hfi_version == HFI_VERSION_1XX) + if (IS_V1(core)) return 0; - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); + if (ret) + return ret; + ret = clk_prepare_enable(core->core1_clk); - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); + if (ret) + goto err_power_disable; + + if (IS_V4(core)) + ret = clk_prepare_enable(core->core1_bus_clk); + if (ret) + goto err_unprepare_core1; + + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); + +err_unprepare_core1: + clk_disable_unprepare(core->core1_clk); +err_power_disable: + venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); return ret; } From patchwork Thu Jul 5 13:03:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141138 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1926234ljj; Thu, 5 Jul 2018 06:12:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYJExfZ0S7+DC8ILlQSAnjWYdY2raPmd5gq7zbTmMntsz8csQtRySJ23RmdmRr3algqAb+ X-Received: by 2002:a62:3a9d:: with SMTP id v29-v6mr6360250pfj.215.1530796329428; Thu, 05 Jul 2018 06:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796329; cv=none; d=google.com; s=arc-20160816; b=XbhPcVPWhXfS+7WqPnJ1vjTTsTI6HWu7+c4gMQox3aUHZjZGu6AtrWeODP3iZNRrmg ArxkOQm/1QWVyYN99oHy7sGmUIHFzvVsTnm2L5RFNGDP2/TPieGGGCs4u7bf7DHTOdkS PcmOyxtihGAqyxNAsNkHUZnLponcJZMe2R+KMCjaJXvyjHUKdPEjtwudg5LkR7+hKI/v 1uvTCWvoWzwJIS/uz+zpfWpKCnG1X/X+JFydjyCy4zWD9WWNdXNgVl6cnjlP9I+8+AMT mBjZxDH44n3ZXL+51/p/wZcnPOa1uf9alkCrrCcMNTiaP5FQVXh+FrLRawBjbCwQZIRB 2jSQ== 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:dkim-signature:arc-authentication-results; bh=RzkTWjhoCxekkPltsvwcXIqmyKOc1RIujqyB8iFCoYg=; b=USCURzsqW+Uwd/VKLZBFlLU00B9kndgmc2xSuAEb582JOM/YWnQLVCgkEonER0UlX+ jqZ1/pMZO+ZOAuHPztMMeszv0oFoY0dZgXhNMrFEWiRZBbIDJEWHn5VVtXwCFNFloisx vOJvmPCOpcdYBoKDHzD99akVe69JqL875sx5gew2nHTXx1zaqxYm7gy008mo4//NSmAk 9OwCxh90g/08z6D0UfXbUApsh30g7o5tbMXGJDycMp/xzXiwX6zdG951fkR3eRM8kUQe umcUaP2Pc7GjZNvcoNky4Hf5wOCba21Fh7y+ItLOniLjnmiF4J7XLfQPcYsg0Vb2deN3 P1ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ra5Z1WAM; 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 q136-v6si5463785pgq.483.2018.07.05.06.12.09; Thu, 05 Jul 2018 06:12:09 -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=@linaro.org header.s=google header.b=Ra5Z1WAM; 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 S1754648AbeGENMH (ORCPT + 31 others); Thu, 5 Jul 2018 09:12:07 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41919 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754390AbeGENFW (ORCPT ); Thu, 5 Jul 2018 09:05:22 -0400 Received: by mail-wr1-f66.google.com with SMTP id h10-v6so1137588wrq.8 for ; Thu, 05 Jul 2018 06:05:21 -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; bh=RzkTWjhoCxekkPltsvwcXIqmyKOc1RIujqyB8iFCoYg=; b=Ra5Z1WAMAL6WUwqCn9Wb79EPgEh0iohvFG3+S7fNlnO6j1FEfCk31BrAKHT188VoFL 1ol+UD3WvY87fNWVtPsn6wrSHS/RdyGmpLeprdUcZ/johHl1he7QQ+Sm0TlHB/AtVfHE MLpBDAdWyhwLKP1RHDeswzZ0Dl9EKKkbVA6Vk= 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; bh=RzkTWjhoCxekkPltsvwcXIqmyKOc1RIujqyB8iFCoYg=; b=foZhe8ClE3qeWuXwSEwqOSERYNVj55jpu9yKdd6+u/2sYjdssZzMlqk25zXm2m9eaW 3wAMjC9aO3yZnk+9vpw1x9JQy6jdauxboZF4ftdsiRCAGDgO8PhzAM9X6Zzjm7j3wlmC /BqdPsHPVHxFDrVOIl22PToBbTXNbLxmilHrCqHaa9ApQVdLgw1UT7ttiygBFn2VNDqL +omghBOZUNx31YbqvqHfxTuHsgXlV+s8FS5cD877DwFvudTtbonIXbGe4e4N6BISOisW UUfoKyN1iGElnBx2c0eV9QuMka5GevBa602CgFA1hAg4dbpk0/vBrNJ4RncqJO0sMIjh ZbVA== X-Gm-Message-State: APt69E2Pf4lrof3YALM75Dn297O0TULE6/P/xaWqkvVkP77TzBPiBcVo MVskMKDzhQLXioBu9L3zaEV3NQ== X-Received: by 2002:adf:f50e:: with SMTP id q14-v6mr4245604wro.241.1530795920211; Thu, 05 Jul 2018 06:05:20 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:19 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 12/27] venus: hfi_parser: add common capability parser Date: Thu, 5 Jul 2018 16:03:46 +0300 Message-Id: <20180705130401.24315-13-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds common capability parser for all supported Venus versions. Having it will help to enumerate better the supported raw formats and codecs and also the capabilities for every codec like max/min width/height, framerate, bitrate and so on. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/Makefile | 3 +- drivers/media/platform/qcom/venus/core.c | 85 ++++++ drivers/media/platform/qcom/venus/core.h | 74 ++--- drivers/media/platform/qcom/venus/hfi.c | 5 +- drivers/media/platform/qcom/venus/hfi_helper.h | 28 +- drivers/media/platform/qcom/venus/hfi_msgs.c | 356 ++----------------------- drivers/media/platform/qcom/venus/hfi_parser.c | 283 ++++++++++++++++++++ drivers/media/platform/qcom/venus/hfi_parser.h | 45 ++++ drivers/media/platform/qcom/venus/vdec.c | 38 +-- drivers/media/platform/qcom/venus/venc.c | 52 ++-- 10 files changed, 525 insertions(+), 444 deletions(-) create mode 100644 drivers/media/platform/qcom/venus/hfi_parser.c create mode 100644 drivers/media/platform/qcom/venus/hfi_parser.h -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/Makefile b/drivers/media/platform/qcom/venus/Makefile index bfd4edf7c83f..b44b11b03e12 100644 --- a/drivers/media/platform/qcom/venus/Makefile +++ b/drivers/media/platform/qcom/venus/Makefile @@ -2,7 +2,8 @@ # Makefile for Qualcomm Venus driver venus-core-objs += core.o helpers.o firmware.o \ - hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o + hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o \ + hfi_parser.o venus-dec-objs += vdec.o vdec_ctrls.o venus-enc-objs += venc.o venc_ctrls.o diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 41eef376eb2d..381bfdd688db 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -152,6 +152,83 @@ static void venus_clks_disable(struct venus_core *core) clk_disable_unprepare(core->clks[i]); } +static u32 to_v4l2_codec_type(u32 codec) +{ + switch (codec) { + case HFI_VIDEO_CODEC_H264: + return V4L2_PIX_FMT_H264; + case HFI_VIDEO_CODEC_H263: + return V4L2_PIX_FMT_H263; + case HFI_VIDEO_CODEC_MPEG1: + return V4L2_PIX_FMT_MPEG1; + case HFI_VIDEO_CODEC_MPEG2: + return V4L2_PIX_FMT_MPEG2; + case HFI_VIDEO_CODEC_MPEG4: + return V4L2_PIX_FMT_MPEG4; + case HFI_VIDEO_CODEC_VC1: + return V4L2_PIX_FMT_VC1_ANNEX_G; + case HFI_VIDEO_CODEC_VP8: + return V4L2_PIX_FMT_VP8; + case HFI_VIDEO_CODEC_VP9: + return V4L2_PIX_FMT_VP9; + case HFI_VIDEO_CODEC_DIVX: + case HFI_VIDEO_CODEC_DIVX_311: + return V4L2_PIX_FMT_XVID; + default: + return 0; + } +} + +static int venus_enumerate_codecs(struct venus_core *core, u32 type) +{ + const struct hfi_inst_ops dummy_ops = {}; + struct venus_inst *inst; + u32 codec, codecs; + unsigned int i; + int ret; + + if (core->res->hfi_version != HFI_VERSION_1XX) + return 0; + + inst = kzalloc(sizeof(*inst), GFP_KERNEL); + if (!inst) + return -ENOMEM; + + mutex_init(&inst->lock); + inst->core = core; + inst->session_type = type; + if (type == VIDC_SESSION_TYPE_DEC) + codecs = core->dec_codecs; + else + codecs = core->enc_codecs; + + ret = hfi_session_create(inst, &dummy_ops); + if (ret) + goto err; + + for (i = 0; i < MAX_CODEC_NUM; i++) { + codec = (1 << i) & codecs; + if (!codec) + continue; + + ret = hfi_session_init(inst, to_v4l2_codec_type(codec)); + if (ret) + goto done; + + ret = hfi_session_deinit(inst); + if (ret) + goto done; + } + +done: + hfi_session_destroy(inst); +err: + mutex_destroy(&inst->lock); + kfree(inst); + + return ret; +} + static int venus_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -219,6 +296,14 @@ static int venus_probe(struct platform_device *pdev) if (ret) goto err_venus_shutdown; + ret = venus_enumerate_codecs(core, VIDC_SESSION_TYPE_DEC); + if (ret) + goto err_venus_shutdown; + + ret = venus_enumerate_codecs(core, VIDC_SESSION_TYPE_ENC); + if (ret) + goto err_venus_shutdown; + ret = v4l2_device_register(dev, &core->v4l2_dev); if (ret) goto err_core_deinit; diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 2bf8839784fa..b995d1601c87 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -57,6 +57,30 @@ struct venus_format { u32 type; }; +#define MAX_PLANES 4 +#define MAX_FMT_ENTRIES 32 +#define MAX_CAP_ENTRIES 32 +#define MAX_ALLOC_MODE_ENTRIES 16 +#define MAX_CODEC_NUM 32 + +struct raw_formats { + u32 buftype; + u32 fmt; +}; + +struct venus_caps { + u32 codec; + u32 domain; + bool cap_bufs_mode_dynamic; + unsigned int num_caps; + struct hfi_capability caps[MAX_CAP_ENTRIES]; + unsigned int num_pl; + struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT]; + unsigned int num_fmts; + struct raw_formats fmts[MAX_FMT_ENTRIES]; + bool valid; /* used only for Venus v1xx */ +}; + /** * struct venus_core - holds core parameters valid for all instances * @@ -113,8 +137,8 @@ struct venus_core { unsigned int error; bool sys_error; const struct hfi_core_ops *core_ops; - u32 enc_codecs; - u32 dec_codecs; + unsigned long enc_codecs; + unsigned long dec_codecs; unsigned int max_sessions_supported; #define ENC_ROTATION_CAPABILITY 0x1 #define ENC_SCALING_CAPABILITY 0x2 @@ -124,6 +148,8 @@ struct venus_core { void *priv; const struct hfi_ops *ops; struct delayed_work work; + struct venus_caps caps[MAX_CODEC_NUM]; + unsigned int codecs_count; }; struct vdec_controls { @@ -216,6 +242,7 @@ struct venus_buffer { * @reconfig: a flag raised by decoder when the stream resolution changed * @reconfig_width: holds the new width * @reconfig_height: holds the new height + * @hfi_codec: current codec for this instance in HFI space * @sequence_cap: a sequence counter for capture queue * @sequence_out: a sequence counter for output queue * @m2m_dev: a reference to m2m device structure @@ -228,22 +255,8 @@ struct venus_buffer { * @priv: a private for HFI operations callbacks * @session_type: the type of the session (decoder or encoder) * @hprop: a union used as a holder by get property - * @cap_width: width capability - * @cap_height: height capability - * @cap_mbs_per_frame: macroblocks per frame capability - * @cap_mbs_per_sec: macroblocks per second capability - * @cap_framerate: framerate capability - * @cap_scale_x: horizontal scaling capability - * @cap_scale_y: vertical scaling capability - * @cap_bitrate: bitrate capability - * @cap_hier_p: hier capability - * @cap_ltr_count: LTR count capability - * @cap_secure_output2_threshold: secure OUTPUT2 threshold capability * @cap_bufs_mode_static: buffers allocation mode capability * @cap_bufs_mode_dynamic: buffers allocation mode capability - * @pl_count: count of supported profiles/levels - * @pl: supported profiles/levels - * @bufreq: holds buffer requirements */ struct venus_inst { struct list_head list; @@ -280,6 +293,7 @@ struct venus_inst { bool reconfig; u32 reconfig_width; u32 reconfig_height; + u32 hfi_codec; u32 sequence_cap; u32 sequence_out; struct v4l2_m2m_dev *m2m_dev; @@ -291,22 +305,8 @@ struct venus_inst { const struct hfi_inst_ops *ops; u32 session_type; union hfi_get_property hprop; - struct hfi_capability cap_width; - struct hfi_capability cap_height; - struct hfi_capability cap_mbs_per_frame; - struct hfi_capability cap_mbs_per_sec; - struct hfi_capability cap_framerate; - struct hfi_capability cap_scale_x; - struct hfi_capability cap_scale_y; - struct hfi_capability cap_bitrate; - struct hfi_capability cap_hier_p; - struct hfi_capability cap_ltr_count; - struct hfi_capability cap_secure_output2_threshold; bool cap_bufs_mode_static; bool cap_bufs_mode_dynamic; - unsigned int pl_count; - struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT]; - struct hfi_buffer_requirements bufreq[HFI_BUFFER_TYPE_MAX]; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) @@ -326,4 +326,18 @@ static inline void *to_hfi_priv(struct venus_core *core) return core->priv; } +static inline struct venus_caps * +venus_caps_by_codec(struct venus_core *core, u32 codec, u32 domain) +{ + unsigned int c; + + for (c = 0; c < core->codecs_count; c++) { + if (core->caps[c].codec == codec && + core->caps[c].domain == domain) + return &core->caps[c]; + } + + return NULL; +} + #endif diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index a570fdad0de0..94ca27b0bb99 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -203,13 +203,12 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt) { struct venus_core *core = inst->core; const struct hfi_ops *ops = core->ops; - u32 codec; int ret; - codec = to_codec_type(pixfmt); + inst->hfi_codec = to_codec_type(pixfmt); reinit_completion(&inst->done); - ret = ops->session_init(inst, inst->session_type, codec); + ret = ops->session_init(inst, inst->session_type, inst->hfi_codec); if (ret) return ret; diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 1bc5aab1ce6b..15804ad7e65d 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -858,10 +858,23 @@ struct hfi_uncompressed_format_select { u32 format; }; +struct hfi_uncompressed_plane_constraints { + u32 stride_multiples; + u32 max_stride; + u32 min_plane_buffer_height_multiple; + u32 buffer_alignment; +}; + +struct hfi_uncompressed_plane_info { + u32 format; + u32 num_planes; + struct hfi_uncompressed_plane_constraints plane_constraints[1]; +}; + struct hfi_uncompressed_format_supported { u32 buffer_type; u32 format_entries; - u32 format_info[1]; + struct hfi_uncompressed_plane_info plane_info[1]; }; struct hfi_uncompressed_plane_actual { @@ -875,19 +888,6 @@ struct hfi_uncompressed_plane_actual_info { struct hfi_uncompressed_plane_actual plane_format[1]; }; -struct hfi_uncompressed_plane_constraints { - u32 stride_multiples; - u32 max_stride; - u32 min_plane_buffer_height_multiple; - u32 buffer_alignment; -}; - -struct hfi_uncompressed_plane_info { - u32 format; - u32 num_planes; - struct hfi_uncompressed_plane_constraints plane_format[1]; -}; - struct hfi_uncompressed_plane_actual_constraints_info { u32 buffer_type; u32 num_planes; diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index c0f3bef8299f..0ecdaa15c296 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -21,6 +21,7 @@ #include "hfi.h" #include "hfi_helper.h" #include "hfi_msgs.h" +#include "hfi_parser.h" static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, struct hfi_msg_event_notify_pkt *pkt) @@ -217,81 +218,28 @@ static void hfi_sys_init_done(struct venus_core *core, struct venus_inst *inst, void *packet) { struct hfi_msg_sys_init_done_pkt *pkt = packet; - u32 rem_bytes, read_bytes = 0, num_properties; - u32 error, ptype; - u8 *data; + int rem_bytes; + u32 error; error = pkt->error_type; if (error != HFI_ERR_NONE) - goto err_no_prop; - - num_properties = pkt->num_properties; + goto done; - if (!num_properties) { + if (!pkt->num_properties) { error = HFI_ERR_SYS_INVALID_PARAMETER; - goto err_no_prop; + goto done; } rem_bytes = pkt->hdr.size - sizeof(*pkt) + sizeof(u32); - - if (!rem_bytes) { + if (rem_bytes <= 0) { /* missing property data */ error = HFI_ERR_SYS_INSUFFICIENT_RESOURCES; - goto err_no_prop; + goto done; } - data = (u8 *)&pkt->data[0]; - - if (core->res->hfi_version == HFI_VERSION_3XX) - goto err_no_prop; - - while (num_properties && rem_bytes >= sizeof(u32)) { - ptype = *((u32 *)data); - data += sizeof(u32); - - switch (ptype) { - case HFI_PROPERTY_PARAM_CODEC_SUPPORTED: { - struct hfi_codec_supported *prop; - - prop = (struct hfi_codec_supported *)data; - - if (rem_bytes < sizeof(*prop)) { - error = HFI_ERR_SYS_INSUFFICIENT_RESOURCES; - break; - } - - read_bytes += sizeof(*prop) + sizeof(u32); - core->dec_codecs = prop->dec_codecs; - core->enc_codecs = prop->enc_codecs; - break; - } - case HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED: { - struct hfi_max_sessions_supported *prop; - - if (rem_bytes < sizeof(*prop)) { - error = HFI_ERR_SYS_INSUFFICIENT_RESOURCES; - break; - } - - prop = (struct hfi_max_sessions_supported *)data; - read_bytes += sizeof(*prop) + sizeof(u32); - core->max_sessions_supported = prop->max_sessions; - break; - } - default: - error = HFI_ERR_SYS_INVALID_PARAMETER; - break; - } - - if (error) - break; + error = hfi_parser(core, inst, pkt->data, rem_bytes); - rem_bytes -= read_bytes; - data += read_bytes; - num_properties--; - } - -err_no_prop: +done: core->error = error; complete(&core->done); } @@ -369,51 +317,6 @@ static void hfi_sys_pc_prepare_done(struct venus_core *core, dev_dbg(core->dev, "pc prepare done (error %x)\n", pkt->error_type); } -static void -hfi_copy_cap_prop(struct hfi_capability *in, struct venus_inst *inst) -{ - if (!in || !inst) - return; - - switch (in->capability_type) { - case HFI_CAPABILITY_FRAME_WIDTH: - inst->cap_width = *in; - break; - case HFI_CAPABILITY_FRAME_HEIGHT: - inst->cap_height = *in; - break; - case HFI_CAPABILITY_MBS_PER_FRAME: - inst->cap_mbs_per_frame = *in; - break; - case HFI_CAPABILITY_MBS_PER_SECOND: - inst->cap_mbs_per_sec = *in; - break; - case HFI_CAPABILITY_FRAMERATE: - inst->cap_framerate = *in; - break; - case HFI_CAPABILITY_SCALE_X: - inst->cap_scale_x = *in; - break; - case HFI_CAPABILITY_SCALE_Y: - inst->cap_scale_y = *in; - break; - case HFI_CAPABILITY_BITRATE: - inst->cap_bitrate = *in; - break; - case HFI_CAPABILITY_HIER_P_NUM_ENH_LAYERS: - inst->cap_hier_p = *in; - break; - case HFI_CAPABILITY_ENC_LTR_COUNT: - inst->cap_ltr_count = *in; - break; - case HFI_CAPABILITY_CP_OUTPUT2_THRESH: - inst->cap_secure_output2_threshold = *in; - break; - default: - break; - } -} - static unsigned int session_get_prop_profile_level(struct hfi_msg_session_property_info_pkt *pkt, struct hfi_profile_level *profile_level) @@ -503,248 +406,27 @@ static void hfi_session_prop_info(struct venus_core *core, complete(&inst->done); } -static u32 init_done_read_prop(struct venus_core *core, struct venus_inst *inst, - struct hfi_msg_session_init_done_pkt *pkt) -{ - struct device *dev = core->dev; - u32 rem_bytes, num_props; - u32 ptype, next_offset = 0; - u32 err; - u8 *data; - - rem_bytes = pkt->shdr.hdr.size - sizeof(*pkt) + sizeof(u32); - if (!rem_bytes) { - dev_err(dev, "%s: missing property info\n", __func__); - return HFI_ERR_SESSION_INSUFFICIENT_RESOURCES; - } - - err = pkt->error_type; - if (err) - return err; - - data = (u8 *)&pkt->data[0]; - num_props = pkt->num_properties; - - while (err == HFI_ERR_NONE && num_props && rem_bytes >= sizeof(u32)) { - ptype = *((u32 *)data); - next_offset = sizeof(u32); - - switch (ptype) { - case HFI_PROPERTY_PARAM_CODEC_MASK_SUPPORTED: { - struct hfi_codec_mask_supported *masks = - (struct hfi_codec_mask_supported *) - (data + next_offset); - - next_offset += sizeof(*masks); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED: { - struct hfi_capabilities *caps; - struct hfi_capability *cap; - u32 num_caps; - - if ((rem_bytes - next_offset) < sizeof(*cap)) { - err = HFI_ERR_SESSION_INVALID_PARAMETER; - break; - } - - caps = (struct hfi_capabilities *)(data + next_offset); - - num_caps = caps->num_capabilities; - cap = &caps->data[0]; - next_offset += sizeof(u32); - - while (num_caps && - (rem_bytes - next_offset) >= sizeof(u32)) { - hfi_copy_cap_prop(cap, inst); - cap++; - next_offset += sizeof(*cap); - num_caps--; - } - num_props--; - break; - } - case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: { - struct hfi_uncompressed_format_supported *prop = - (struct hfi_uncompressed_format_supported *) - (data + next_offset); - u32 num_fmt_entries; - u8 *fmt; - struct hfi_uncompressed_plane_info *inf; - - if ((rem_bytes - next_offset) < sizeof(*prop)) { - err = HFI_ERR_SESSION_INVALID_PARAMETER; - break; - } - - num_fmt_entries = prop->format_entries; - next_offset = sizeof(*prop) - sizeof(u32); - fmt = (u8 *)&prop->format_info[0]; - - dev_dbg(dev, "uncomm format support num entries:%u\n", - num_fmt_entries); - - while (num_fmt_entries) { - struct hfi_uncompressed_plane_constraints *cnts; - u32 bytes_to_skip; - - inf = (struct hfi_uncompressed_plane_info *)fmt; - - if ((rem_bytes - next_offset) < sizeof(*inf)) { - err = HFI_ERR_SESSION_INVALID_PARAMETER; - break; - } - - dev_dbg(dev, "plane info: fmt:%x, planes:%x\n", - inf->format, inf->num_planes); - - cnts = &inf->plane_format[0]; - dev_dbg(dev, "%u %u %u %u\n", - cnts->stride_multiples, - cnts->max_stride, - cnts->min_plane_buffer_height_multiple, - cnts->buffer_alignment); - - bytes_to_skip = sizeof(*inf) - sizeof(*cnts) + - inf->num_planes * sizeof(*cnts); - - fmt += bytes_to_skip; - next_offset += bytes_to_skip; - num_fmt_entries--; - } - num_props--; - break; - } - case HFI_PROPERTY_PARAM_PROPERTIES_SUPPORTED: { - struct hfi_properties_supported *prop = - (struct hfi_properties_supported *) - (data + next_offset); - - next_offset += sizeof(*prop) - sizeof(u32) - + prop->num_properties * sizeof(u32); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED: { - struct hfi_profile_level_supported *prop = - (struct hfi_profile_level_supported *) - (data + next_offset); - struct hfi_profile_level *pl; - unsigned int prop_count = 0; - unsigned int count = 0; - u8 *ptr; - - ptr = (u8 *)&prop->profile_level[0]; - prop_count = prop->profile_count; - - if (prop_count > HFI_MAX_PROFILE_COUNT) - prop_count = HFI_MAX_PROFILE_COUNT; - - while (prop_count) { - ptr++; - pl = (struct hfi_profile_level *)ptr; - - inst->pl[count].profile = pl->profile; - inst->pl[count].level = pl->level; - prop_count--; - count++; - ptr += sizeof(*pl) / sizeof(u32); - } - - inst->pl_count = count; - next_offset += sizeof(*prop) - sizeof(*pl) + - prop->profile_count * sizeof(*pl); - - num_props--; - break; - } - case HFI_PROPERTY_PARAM_INTERLACE_FORMAT_SUPPORTED: { - next_offset += - sizeof(struct hfi_interlace_format_supported); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SUPPORTED: { - struct hfi_nal_stream_format *nal = - (struct hfi_nal_stream_format *) - (data + next_offset); - dev_dbg(dev, "NAL format: %x\n", nal->format); - next_offset += sizeof(*nal); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT: { - next_offset += sizeof(u32); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_MAX_SEQUENCE_HEADER_SIZE: { - u32 *max_seq_sz = (u32 *)(data + next_offset); - - dev_dbg(dev, "max seq header sz: %x\n", *max_seq_sz); - next_offset += sizeof(u32); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH: { - next_offset += sizeof(struct hfi_intra_refresh); - num_props--; - break; - } - case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE_SUPPORTED: { - struct hfi_buffer_alloc_mode_supported *prop = - (struct hfi_buffer_alloc_mode_supported *) - (data + next_offset); - unsigned int i; - - for (i = 0; i < prop->num_entries; i++) { - if (prop->buffer_type == HFI_BUFFER_OUTPUT || - prop->buffer_type == HFI_BUFFER_OUTPUT2) { - switch (prop->data[i]) { - case HFI_BUFFER_MODE_STATIC: - inst->cap_bufs_mode_static = true; - break; - case HFI_BUFFER_MODE_DYNAMIC: - inst->cap_bufs_mode_dynamic = true; - break; - default: - break; - } - } - } - next_offset += sizeof(*prop) - - sizeof(u32) + prop->num_entries * sizeof(u32); - num_props--; - break; - } - default: - dev_dbg(dev, "%s: default case %#x\n", __func__, ptype); - break; - } - - rem_bytes -= next_offset; - data += next_offset; - } - - return err; -} - static void hfi_session_init_done(struct venus_core *core, struct venus_inst *inst, void *packet) { struct hfi_msg_session_init_done_pkt *pkt = packet; - unsigned int error; + int rem_bytes; + u32 error; error = pkt->error_type; if (error != HFI_ERR_NONE) goto done; - if (core->res->hfi_version != HFI_VERSION_1XX) + if (!IS_V1(core)) goto done; - error = init_done_read_prop(core, inst, pkt); + rem_bytes = pkt->shdr.hdr.size - sizeof(*pkt) + sizeof(u32); + if (rem_bytes <= 0) { + error = HFI_ERR_SESSION_INSUFFICIENT_RESOURCES; + goto done; + } + error = hfi_parser(core, inst, pkt->data, rem_bytes); done: inst->error = error; complete(&inst->done); diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c new file mode 100644 index 000000000000..afc0db3b5dc3 --- /dev/null +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Linaro Ltd. + * + * Author: Stanimir Varbanov + */ +#include +#include + +#include "core.h" +#include "hfi_helper.h" +#include "hfi_parser.h" + +typedef void (*func)(struct venus_caps *cap, const void *data, + unsigned int size); + +static void init_codecs(struct venus_core *core) +{ + struct venus_caps *caps = core->caps, *cap; + unsigned long bit; + + for_each_set_bit(bit, &core->dec_codecs, MAX_CODEC_NUM) { + cap = &caps[core->codecs_count++]; + cap->codec = BIT(bit); + cap->domain = VIDC_SESSION_TYPE_DEC; + cap->valid = false; + } + + for_each_set_bit(bit, &core->enc_codecs, MAX_CODEC_NUM) { + cap = &caps[core->codecs_count++]; + cap->codec = BIT(bit); + cap->domain = VIDC_SESSION_TYPE_ENC; + cap->valid = false; + } +} + +static void for_each_codec(struct venus_caps *caps, unsigned int caps_num, + u32 codecs, u32 domain, func cb, void *data, + unsigned int size) +{ + struct venus_caps *cap; + unsigned int i; + + for (i = 0; i < caps_num; i++) { + cap = &caps[i]; + if (cap->valid && cap->domain == domain) + continue; + if (cap->codec & codecs && cap->domain == domain) + cb(cap, data, size); + } +} + +static void +fill_buf_mode(struct venus_caps *cap, const void *data, unsigned int num) +{ + const u32 *type = data; + + if (*type == HFI_BUFFER_MODE_DYNAMIC) + cap->cap_bufs_mode_dynamic = true; +} + +static void +parse_alloc_mode(struct venus_core *core, struct venus_inst *inst, u32 codecs, + u32 domain, void *data) +{ + struct hfi_buffer_alloc_mode_supported *mode = data; + u32 num_entries = mode->num_entries; + u32 *type; + + if (num_entries > MAX_ALLOC_MODE_ENTRIES) + return; + + type = mode->data; + + while (num_entries--) { + if (mode->buffer_type == HFI_BUFFER_OUTPUT || + mode->buffer_type == HFI_BUFFER_OUTPUT2) { + if (*type == HFI_BUFFER_MODE_DYNAMIC && inst) + inst->cap_bufs_mode_dynamic = true; + + for_each_codec(core->caps, ARRAY_SIZE(core->caps), + codecs, domain, fill_buf_mode, type, 1); + } + + type++; + } +} + +static void fill_profile_level(struct venus_caps *cap, const void *data, + unsigned int num) +{ + const struct hfi_profile_level *pl = data; + + memcpy(&cap->pl[cap->num_pl], pl, num * sizeof(*pl)); + cap->num_pl += num; +} + +static void +parse_profile_level(struct venus_core *core, u32 codecs, u32 domain, void *data) +{ + struct hfi_profile_level_supported *pl = data; + struct hfi_profile_level *proflevel = pl->profile_level; + struct hfi_profile_level pl_arr[HFI_MAX_PROFILE_COUNT] = {}; + + if (pl->profile_count > HFI_MAX_PROFILE_COUNT) + return; + + memcpy(pl_arr, proflevel, pl->profile_count * sizeof(*proflevel)); + + for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain, + fill_profile_level, pl_arr, pl->profile_count); +} + +static void +fill_caps(struct venus_caps *cap, const void *data, unsigned int num) +{ + const struct hfi_capability *caps = data; + + memcpy(&cap->caps[cap->num_caps], caps, num * sizeof(*caps)); + cap->num_caps += num; +} + +static void +parse_caps(struct venus_core *core, u32 codecs, u32 domain, void *data) +{ + struct hfi_capabilities *caps = data; + struct hfi_capability *cap = caps->data; + u32 num_caps = caps->num_capabilities; + struct hfi_capability caps_arr[MAX_CAP_ENTRIES] = {}; + + if (num_caps > MAX_CAP_ENTRIES) + return; + + memcpy(caps_arr, cap, num_caps * sizeof(*cap)); + + for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain, + fill_caps, caps_arr, num_caps); +} + +static void fill_raw_fmts(struct venus_caps *cap, const void *fmts, + unsigned int num_fmts) +{ + const struct raw_formats *formats = fmts; + + memcpy(&cap->fmts[cap->num_fmts], formats, num_fmts * sizeof(*formats)); + cap->num_fmts += num_fmts; +} + +static void +parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data) +{ + struct hfi_uncompressed_format_supported *fmt = data; + struct hfi_uncompressed_plane_info *pinfo = fmt->plane_info; + struct hfi_uncompressed_plane_constraints *constr; + struct raw_formats rawfmts[MAX_FMT_ENTRIES] = {}; + u32 entries = fmt->format_entries; + unsigned int i = 0; + u32 num_planes; + + while (entries) { + num_planes = pinfo->num_planes; + + rawfmts[i].fmt = pinfo->format; + rawfmts[i].buftype = fmt->buffer_type; + i++; + + if (pinfo->num_planes > MAX_PLANES) + break; + + pinfo = (void *)pinfo + sizeof(*constr) * num_planes + + 2 * sizeof(u32); + entries--; + } + + for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain, + fill_raw_fmts, rawfmts, i); +} + +static void parse_codecs(struct venus_core *core, void *data) +{ + struct hfi_codec_supported *codecs = data; + + core->dec_codecs = codecs->dec_codecs; + core->enc_codecs = codecs->enc_codecs; + + if (IS_V1(core)) { + core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC; + core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK; + } +} + +static void parse_max_sessions(struct venus_core *core, const void *data) +{ + const struct hfi_max_sessions_supported *sessions = data; + + core->max_sessions_supported = sessions->max_sessions; +} + +static void parse_codecs_mask(u32 *codecs, u32 *domain, void *data) +{ + struct hfi_codec_mask_supported *mask = data; + + *codecs = mask->codecs; + *domain = mask->video_domains; +} + +static void parser_init(struct venus_inst *inst, u32 *codecs, u32 *domain) +{ + if (!inst || !IS_V1(inst->core)) + return; + + *codecs = inst->hfi_codec; + *domain = inst->session_type; +} + +static void parser_fini(struct venus_inst *inst, u32 codecs, u32 domain) +{ + struct venus_caps *caps, *cap; + unsigned int i; + u32 dom; + + if (!inst || !IS_V1(inst->core)) + return; + + caps = inst->core->caps; + dom = inst->session_type; + + for (i = 0; i < MAX_CODEC_NUM; i++) { + cap = &caps[i]; + if (cap->codec & codecs && cap->domain == dom) + cap->valid = true; + } +} + +u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf, + u32 size) +{ + unsigned int words_count = size >> 2; + u32 *word = buf, *data, codecs = 0, domain = 0; + + if (size % 4) + return HFI_ERR_SYS_INSUFFICIENT_RESOURCES; + + parser_init(inst, &codecs, &domain); + + while (words_count) { + data = word + 1; + + switch (*word) { + case HFI_PROPERTY_PARAM_CODEC_SUPPORTED: + parse_codecs(core, data); + init_codecs(core); + break; + case HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED: + parse_max_sessions(core, data); + break; + case HFI_PROPERTY_PARAM_CODEC_MASK_SUPPORTED: + parse_codecs_mask(&codecs, &domain, data); + break; + case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: + parse_raw_formats(core, codecs, domain, data); + break; + case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED: + parse_caps(core, codecs, domain, data); + break; + case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED: + parse_profile_level(core, codecs, domain, data); + break; + case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE_SUPPORTED: + parse_alloc_mode(core, inst, codecs, domain, data); + break; + default: + break; + } + + word++; + words_count--; + } + + parser_fini(inst, codecs, domain); + + return HFI_ERR_NONE; +} diff --git a/drivers/media/platform/qcom/venus/hfi_parser.h b/drivers/media/platform/qcom/venus/hfi_parser.h new file mode 100644 index 000000000000..2fa4a345a3eb --- /dev/null +++ b/drivers/media/platform/qcom/venus/hfi_parser.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2018 Linaro Ltd. */ +#ifndef __VENUS_HFI_PARSER_H__ +#define __VENUS_HFI_PARSER_H__ + +#include "core.h" + +u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, + void *buf, u32 size); + +static inline struct hfi_capability *get_cap(struct venus_inst *inst, u32 type) +{ + struct venus_core *core = inst->core; + struct venus_caps *caps; + unsigned int i; + + caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type); + if (!caps) + return ERR_PTR(-EINVAL); + + for (i = 0; i < caps->num_caps; i++) { + if (caps->caps[i].capability_type == type) + return &caps->caps[i]; + } + + return ERR_PTR(-EINVAL); +} + +#define CAP_MIN(inst, type) ((get_cap(inst, type))->min) +#define CAP_MAX(inst, type) ((get_cap(inst, type))->max) +#define CAP_STEP(inst, type) ((get_cap(inst, type))->step_size) + +#define FRAME_WIDTH_MIN(inst) CAP_MIN(inst, HFI_CAPABILITY_FRAME_WIDTH) +#define FRAME_WIDTH_MAX(inst) CAP_MAX(inst, HFI_CAPABILITY_FRAME_WIDTH) +#define FRAME_WIDTH_STEP(inst) CAP_STEP(inst, HFI_CAPABILITY_FRAME_WIDTH) + +#define FRAME_HEIGHT_MIN(inst) CAP_MIN(inst, HFI_CAPABILITY_FRAME_HEIGHT) +#define FRAME_HEIGHT_MAX(inst) CAP_MAX(inst, HFI_CAPABILITY_FRAME_HEIGHT) +#define FRAME_HEIGHT_STEP(inst) CAP_STEP(inst, HFI_CAPABILITY_FRAME_HEIGHT) + +#define FRATE_MIN(inst) CAP_MIN(inst, HFI_CAPABILITY_FRAMERATE) +#define FRATE_MAX(inst) CAP_MAX(inst, HFI_CAPABILITY_FRAMERATE) +#define FRATE_STEP(inst) CAP_STEP(inst, HFI_CAPABILITY_FRAMERATE) + +#endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index d22969d2758a..95892090e2f3 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -24,6 +24,7 @@ #include #include "hfi_venus_io.h" +#include "hfi_parser.h" #include "core.h" #include "helpers.h" #include "vdec.h" @@ -177,10 +178,10 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) pixmp->height = 720; } - pixmp->width = clamp(pixmp->width, inst->cap_width.min, - inst->cap_width.max); - pixmp->height = clamp(pixmp->height, inst->cap_height.min, - inst->cap_height.max); + pixmp->width = clamp(pixmp->width, FRAME_WIDTH_MIN(inst), + FRAME_WIDTH_MAX(inst)); + pixmp->height = clamp(pixmp->height, FRAME_HEIGHT_MIN(inst), + FRAME_HEIGHT_MAX(inst)); if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) pixmp->height = ALIGN(pixmp->height, 32); @@ -442,12 +443,12 @@ static int vdec_enum_framesizes(struct file *file, void *fh, fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise.min_width = inst->cap_width.min; - fsize->stepwise.max_width = inst->cap_width.max; - fsize->stepwise.step_width = inst->cap_width.step_size; - fsize->stepwise.min_height = inst->cap_height.min; - fsize->stepwise.max_height = inst->cap_height.max; - fsize->stepwise.step_height = inst->cap_height.step_size; + fsize->stepwise.min_width = FRAME_WIDTH_MIN(inst); + fsize->stepwise.max_width = FRAME_WIDTH_MAX(inst); + fsize->stepwise.step_width = FRAME_WIDTH_STEP(inst); + fsize->stepwise.min_height = FRAME_HEIGHT_MIN(inst); + fsize->stepwise.max_height = FRAME_HEIGHT_MAX(inst); + fsize->stepwise.step_height = FRAME_HEIGHT_STEP(inst); return 0; } @@ -902,22 +903,7 @@ static void vdec_inst_init(struct venus_inst *inst) inst->fps = 30; inst->timeperframe.numerator = 1; inst->timeperframe.denominator = 30; - - inst->cap_width.min = 64; - inst->cap_width.max = 1920; - if (inst->core->res->hfi_version == HFI_VERSION_3XX) - inst->cap_width.max = 3840; - inst->cap_width.step_size = 1; - inst->cap_height.min = 64; - inst->cap_height.max = ALIGN(1080, 32); - if (inst->core->res->hfi_version == HFI_VERSION_3XX) - inst->cap_height.max = ALIGN(2160, 32); - inst->cap_height.step_size = 1; - inst->cap_framerate.min = 1; - inst->cap_framerate.max = 30; - inst->cap_framerate.step_size = 1; - inst->cap_mbs_per_frame.min = 16; - inst->cap_mbs_per_frame.max = 8160; + inst->hfi_codec = HFI_VIDEO_CODEC_H264; } static const struct v4l2_m2m_ops vdec_m2m_ops = { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 596539d433c9..df54841c910d 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -24,6 +24,7 @@ #include #include "hfi_venus_io.h" +#include "hfi_parser.h" #include "core.h" #include "helpers.h" #include "venc.h" @@ -301,10 +302,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) pixmp->height = 720; } - pixmp->width = clamp(pixmp->width, inst->cap_width.min, - inst->cap_width.max); - pixmp->height = clamp(pixmp->height, inst->cap_height.min, - inst->cap_height.max); + pixmp->width = clamp(pixmp->width, FRAME_WIDTH_MIN(inst), + FRAME_WIDTH_MAX(inst)); + pixmp->height = clamp(pixmp->height, FRAME_HEIGHT_MIN(inst), + FRAME_HEIGHT_MAX(inst)); if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) pixmp->height = ALIGN(pixmp->height, 32); @@ -553,12 +554,12 @@ static int venc_enum_framesizes(struct file *file, void *fh, if (fsize->index) return -EINVAL; - fsize->stepwise.min_width = inst->cap_width.min; - fsize->stepwise.max_width = inst->cap_width.max; - fsize->stepwise.step_width = inst->cap_width.step_size; - fsize->stepwise.min_height = inst->cap_height.min; - fsize->stepwise.max_height = inst->cap_height.max; - fsize->stepwise.step_height = inst->cap_height.step_size; + fsize->stepwise.min_width = FRAME_WIDTH_MIN(inst); + fsize->stepwise.max_width = FRAME_WIDTH_MAX(inst); + fsize->stepwise.step_width = FRAME_WIDTH_STEP(inst); + fsize->stepwise.min_height = FRAME_HEIGHT_MIN(inst); + fsize->stepwise.max_height = FRAME_HEIGHT_MAX(inst); + fsize->stepwise.step_height = FRAME_HEIGHT_STEP(inst); return 0; } @@ -586,18 +587,18 @@ static int venc_enum_frameintervals(struct file *file, void *fh, if (!fival->width || !fival->height) return -EINVAL; - if (fival->width > inst->cap_width.max || - fival->width < inst->cap_width.min || - fival->height > inst->cap_height.max || - fival->height < inst->cap_height.min) + if (fival->width > FRAME_WIDTH_MAX(inst) || + fival->width < FRAME_WIDTH_MIN(inst) || + fival->height > FRAME_HEIGHT_MAX(inst) || + fival->height < FRAME_HEIGHT_MIN(inst)) return -EINVAL; fival->stepwise.min.numerator = 1; - fival->stepwise.min.denominator = inst->cap_framerate.max; + fival->stepwise.min.denominator = FRATE_MAX(inst); fival->stepwise.max.numerator = 1; - fival->stepwise.max.denominator = inst->cap_framerate.min; + fival->stepwise.max.denominator = FRATE_MIN(inst); fival->stepwise.step.numerator = 1; - fival->stepwise.step.denominator = inst->cap_framerate.max; + fival->stepwise.step.denominator = FRATE_MAX(inst); return 0; } @@ -1091,22 +1092,7 @@ static void venc_inst_init(struct venus_inst *inst) inst->fps = 15; inst->timeperframe.numerator = 1; inst->timeperframe.denominator = 15; - - inst->cap_width.min = 96; - inst->cap_width.max = 1920; - if (inst->core->res->hfi_version == HFI_VERSION_3XX) - inst->cap_width.max = 3840; - inst->cap_width.step_size = 2; - inst->cap_height.min = 64; - inst->cap_height.max = ALIGN(1080, 32); - if (inst->core->res->hfi_version == HFI_VERSION_3XX) - inst->cap_height.max = ALIGN(2160, 32); - inst->cap_height.step_size = 2; - inst->cap_framerate.min = 1; - inst->cap_framerate.max = 30; - inst->cap_framerate.step_size = 1; - inst->cap_mbs_per_frame.min = 24; - inst->cap_mbs_per_frame.max = 8160; + inst->hfi_codec = HFI_VIDEO_CODEC_H264; } static int venc_open(struct file *file) From patchwork Thu Jul 5 13:03:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141124 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1918748ljj; Thu, 5 Jul 2018 06:05:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcTFgcpDW3D/Lad3DI2S2nCESHUvlMVVP5jHYX6SmtBZg+RMS5t2Pb0RLCPvyFlplw5s/Ze X-Received: by 2002:a17:902:b08a:: with SMTP id p10-v6mr6291878plr.0.1530795932316; Thu, 05 Jul 2018 06:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795932; cv=none; d=google.com; s=arc-20160816; b=DjaGjlB9h4pQgECdfdaUmdzyeDSdhOLxtfqu5wdxgY/sOcpp2zZ20cGHZSTpWWuls4 IOcHuNIuvmmPuFsQLAIBhhIhf6lI6xEw0rzQLU2ClZY09Yv7hlpjOc0HVSLwDDrUeGCp 4ue4aMRbroYVH/oced5go9+T4Hk+9zngYcaTg3lEyX7hOMuYeeIyoSjf8/i7iF66gu1e mYs8VbdoR4M4c4t+rJY4Q5SX9obVDCvGIGJWy/eu5o2xIMuz7xET4nJU0GtbolGkxSlj FW3yZAaFKU+GifWZ646EElWOOqLijghPNe0bSyTeWl4fblP10D0vtylNFOy4AtvFyGiV ymXA== 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:dkim-signature:arc-authentication-results; bh=e5wWhN2jYs/ZNqU0dtOSF3cvtPwdzRHe2yaBwOQivks=; b=fbJw3QZ382R+tFjZm0ZD5XlhB7BZ1XZ+wtyd8kKLrARdBhPNua5zkJjR0jU7QLVu1R nJbH8bBosAQsYKbosaAViha+9aLFcxNzWYn2z6QlPkKjJLSgn5pmg4t2V8NQ/2qif87/ /t5U0myYemVEimId1dLPr3wcx1sIqgpIqPpK8s2KaflQc/251LZ+pGR+QV6T7F0LymR0 idGUbUVXwXzIM/vmZ+eRRSC2RjHqyTp9i60YscZiUyKNutlWA4vFymWPZMhZXjBarQpW P0Wr1QXVVTh6BbtjvGVCbG5RImBu48pRo8E1Wy6NbtDRLHovv1SZIXNBQkraWPWNn4Nc qp6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a5Lk6Xyo; 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 p73-v6si6415628pfl.57.2018.07.05.06.05.32; Thu, 05 Jul 2018 06:05:32 -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=@linaro.org header.s=google header.b=a5Lk6Xyo; 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 S1754466AbeGENFa (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:30 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42500 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754416AbeGENFX (ORCPT ); Thu, 5 Jul 2018 09:05:23 -0400 Received: by mail-wr1-f66.google.com with SMTP id p1-v6so1140251wrs.9 for ; Thu, 05 Jul 2018 06:05:22 -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; bh=e5wWhN2jYs/ZNqU0dtOSF3cvtPwdzRHe2yaBwOQivks=; b=a5Lk6Xyoxppfo7CfNnaBtoSzhiIo6gmq1xYEYzgSXWtGTnAOliaJcK5qU8WhddlDn+ qFlyBi1Zgpf/6d4yOtxJTxNk8uTIl08Z33KeU+f6MjN5AC5DREG9nyz71uOc0QWrqdeK ESaO/R0xhk6vmh/yIf8ys6IGg/zohAKcscJZE= 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; bh=e5wWhN2jYs/ZNqU0dtOSF3cvtPwdzRHe2yaBwOQivks=; b=tMrCrXka2PYVCi/c3uW4aYYU3RIIjdOvpMJaeAL732UG5BgWuecbb0Yd3MrPrd6g57 Vzl83chi6CPENV9iEj/loUAnlRtUY8yZOi8y6NIwimv/WCvUE+szu/yeg0zJXlzhdOR6 eBwi4HafEqZQZ7XfuQ9rVzNdXgMp/Dlu6NQezQxLvYBCE9Qmsh3S9a4hYm/860epZm4E ob0mcmpX/e3Ww9bT8UniWWIE2Pwmh1DrBz4NKMzJCvRGfR07PRRg52qkUuNbx8RA/pXH +d2mfuQlhVO4keYF6S1dPMfvw5z7N5/YbEAmyn+5hx01d28pknj42bGOtMqMYwAZB5YJ szgA== X-Gm-Message-State: APt69E1W8L88cZjqCbFJo2LzGmyQ4/ZDfw4Fw8LG8FAQtP18EFCQSZlP I3KNirDI5gWdagTJI7bx6ZloRREYRl4= X-Received: by 2002:adf:9c12:: with SMTP id f18-v6mr4649973wrc.93.1530795922298; Thu, 05 Jul 2018 06:05:22 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:21 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 14/27] venus: helpers: add a helper function to set dynamic buffer mode Date: Thu, 5 Jul 2018 16:03:48 +0300 Message-Id: <20180705130401.24315-15-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds a new helper function to set dynamic buffer mode if it is supported by current HFI version. The dynamic buffer mode is set unconditionally for both decoder outputs. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 22 ++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 1 + drivers/media/platform/qcom/venus/vdec.c | 15 +++------------ 3 files changed, 26 insertions(+), 12 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 27c4a4060c4e..29cc84777125 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -524,6 +524,28 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_set_color_format); +int venus_helper_set_dyn_bufmode(struct venus_inst *inst) +{ + const u32 ptype = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; + struct hfi_buffer_alloc_mode mode; + int ret; + + if (!is_dynamic_bufmode(inst)) + return 0; + + mode.type = HFI_BUFFER_OUTPUT; + mode.mode = HFI_BUFFER_MODE_DYNAMIC; + + ret = hfi_session_set_property(inst, ptype, &mode); + if (ret) + return ret; + + mode.type = HFI_BUFFER_OUTPUT2; + + return hfi_session_set_property(inst, ptype, &mode); +} +EXPORT_SYMBOL_GPL(venus_helper_set_dyn_bufmode); + static void delayed_process_buf_func(struct work_struct *work) { struct venus_buffer *buf, *n; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 0e64aa95624a..52b961ed491e 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -40,6 +40,7 @@ int venus_helper_set_output_resolution(struct venus_inst *inst, int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, unsigned int output_bufs); int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); +int venus_helper_set_dyn_bufmode(struct venus_inst *inst); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 95892090e2f3..c37779d82fec 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -557,18 +557,9 @@ static int vdec_set_properties(struct venus_inst *inst) return ret; } - if (core->res->hfi_version == HFI_VERSION_3XX || - inst->cap_bufs_mode_dynamic) { - struct hfi_buffer_alloc_mode mode; - - ptype = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; - mode.type = HFI_BUFFER_OUTPUT; - mode.mode = HFI_BUFFER_MODE_DYNAMIC; - - ret = hfi_session_set_property(inst, ptype, &mode); - if (ret) - return ret; - } + ret = venus_helper_set_dyn_bufmode(inst); + if (ret) + return ret; if (ctr->post_loop_deb_mode) { ptype = HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER; From patchwork Thu Jul 5 13:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141136 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1922959ljj; Thu, 5 Jul 2018 06:09:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf9V+FfnyLSPSVheTcXbqNFp3dK/vJ15/xqSH1sB/+ys9MSQjjCyx3YYTZUIk5ra53/ESET X-Received: by 2002:a63:714a:: with SMTP id b10-v6mr5418857pgn.73.1530796153871; Thu, 05 Jul 2018 06:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796153; cv=none; d=google.com; s=arc-20160816; b=LDDjLh+lb8PjAokRfXnBsJuZsqdmuYhDI7ra3/kf7rM4dNwHsrbiK7Fv/RhzYKPJ9I C401Jv25FLsF82AjMrJS9ju7j/o5nOkjvIyAkCX6HLm+cGUJ3hnAZsct1pYmoD5/1aFz 2GmzVHIWSsIINH7t5ILao41dQRKITmhJEa4lEaE5aN5nwoQ3pb6vdaa97Tv2vl5E4pLn UWM68051OUX36hP6ovalsiJuhHxXHp3Ohz2/mrRMFIXP7p9wgiCZs7gm20VsZSOwMI8a uVJB/ON5znpzPy1l3JkIucQcy6X59C2EZ9SymUCBHUSJekxuf9c9zhQwvzfzk6nKsSf2 +tjw== 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:dkim-signature:arc-authentication-results; bh=oU/c81CKUJQLLGDhE1U7BJ8H3e590k2PwcQruab6xc0=; b=pesFShFOdOcJs8KGIkEQRTYFQ5kYD1Jal3AfrXvFeTrTJ0R0I7b2oT7EsiyP/brEIH zuhCsdhgilO29/iJvghx+KV7S/eqYahFcIMujZRMD+oJYM5nwyh6Zhfowc1OSacZxirX z0o6uxOnKW1bL4IVq39CvYhNa8B9B+lx8Z+8c4yoNSxAdtTcJNupVZ3de8A8c7FJ20AS XguqeZr41/vV0fpcL7/Ht4KaKUfqdGH41ZmtpvVFksE1BQa3aGWD+DJvv5WCNxQPeSRV aINkreYgX3Sb939mjv7LEEzJcdtPZCQGk4ZV/bWv9V8/RhV5m1ivXIbXz2t35eEgZ9Jk F1UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BkC7iggz; 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 l9-v6si6212270pfe.11.2018.07.05.06.09.13; Thu, 05 Jul 2018 06:09:13 -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=@linaro.org header.s=google header.b=BkC7iggz; 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 S1754668AbeGENJL (ORCPT + 31 others); Thu, 5 Jul 2018 09:09:11 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51971 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754433AbeGENF1 (ORCPT ); Thu, 5 Jul 2018 09:05:27 -0400 Received: by mail-wm0-f65.google.com with SMTP id s12-v6so11040859wmc.1 for ; Thu, 05 Jul 2018 06:05:26 -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; bh=oU/c81CKUJQLLGDhE1U7BJ8H3e590k2PwcQruab6xc0=; b=BkC7iggzUe43eEIW0Tq1j7+eKjDNnNx8Ilx9gfLqBRcUwhT+le/NErI5xEgobr6oS7 L2qA2YB7zCwmAFjJ+pqY+6rlySXjR12KpOTK0Lzff+AlaDu+riLCGt9tds79o+34ACjB jwzHIqiGL4N2ha/gHnAFf8IOMabteet+3NLAM= 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; bh=oU/c81CKUJQLLGDhE1U7BJ8H3e590k2PwcQruab6xc0=; b=kUW3dOhzsbcyZ0s6cNPlU4sZD/usgghuUG2rcn+RHFklQqBUxqW5IFAXn0G0MLcxme sJb9mamLiGqv0pxKVkMbiv5oRrKVb+6pwUS3lbtNXF/mMi5dic0LKFmyr7jitolRI5mn QRZmbNu/ZF4qSWq6WmYGE9BR6tAXEk/AKj8OA0vrQIZ8MatIWqs8XAp/WbQifQT/s4mE s3Sxz11aIiSiZ6xy45xS5fi4rr7cvJCVNMpt+LMzUkA4TMIBq/L+6XjWglhqzkqH9Yiv bJQYfay/a77CttzKGUI1Eb2VGmft/iM5WfGfzNd+TjTrL7BZSaS00vOosjxRUlpNBH/z ePIg== X-Gm-Message-State: APt69E1ltMgWAKo/mimDhTzCzmxSDZosqPCWkorx50TorXXaopXpbLxO RUgqeZrl9PUWrHz+5wiROX4yyw== X-Received: by 2002:adf:8e49:: with SMTP id n67-v6mr4376875wrb.131.1530795925715; Thu, 05 Jul 2018 06:05:25 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:25 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 17/27] venus: helpers: add buffer type argument to a helper Date: Thu, 5 Jul 2018 16:03:51 +0300 Message-Id: <20180705130401.24315-18-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds one more function argument to pass buffer type to set_output_resolution() helper function. That is a preparation to support secondary decoder output. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/helpers.c | 5 +++-- drivers/media/platform/qcom/venus/helpers.h | 3 ++- drivers/media/platform/qcom/venus/venc.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 6fd7458f390a..7e764eeeb07c 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -458,12 +458,13 @@ int venus_helper_set_input_resolution(struct venus_inst *inst, EXPORT_SYMBOL_GPL(venus_helper_set_input_resolution); int venus_helper_set_output_resolution(struct venus_inst *inst, - unsigned int width, unsigned int height) + unsigned int width, unsigned int height, + u32 buftype) { u32 ptype = HFI_PROPERTY_PARAM_FRAME_SIZE; struct hfi_framesize fs; - fs.buffer_type = HFI_BUFFER_OUTPUT; + fs.buffer_type = buftype; fs.width = width; fs.height = height; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index cd306bd8978f..0de9989adcdb 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -36,7 +36,8 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, int venus_helper_set_input_resolution(struct venus_inst *inst, unsigned int width, unsigned int height); int venus_helper_set_output_resolution(struct venus_inst *inst, - unsigned int width, unsigned int height); + unsigned int width, unsigned int height, + u32 buftype); int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, unsigned int output_bufs); int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index df54841c910d..650e6b0a01d2 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -795,7 +795,8 @@ static int venc_init_session(struct venus_inst *inst) goto deinit; ret = venus_helper_set_output_resolution(inst, inst->width, - inst->height); + inst->height, + HFI_BUFFER_OUTPUT); if (ret) goto deinit; From patchwork Thu Jul 5 13:03:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141134 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1922187ljj; Thu, 5 Jul 2018 06:08:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmOu9yjBGcX09pdcSghJvQIZMvbSM48rlKjCARlQe0+Q7JNvVChcILkPSkhOrvQefXN2Gu X-Received: by 2002:a62:21c3:: with SMTP id o64-v6mr6366913pfj.21.1530796110126; Thu, 05 Jul 2018 06:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796110; cv=none; d=google.com; s=arc-20160816; b=MQ2uNpQ2GKaaKkqfSVoAWr5gf2w5eWlOPaDSzVR9MU6mV6Ckz55VyXnzET9V/JoBTF TIv2Kw6gzydC3wBUfeVe9rxl80Zjj4MEkDnrlKyDyVqSDIW68l0QvQV0bOGYGUFkmOo0 oP5lplVZ7xeyZiMxr+bJ/COQEhXz2ouaLkW9Fse5tjTW+QdbSOaql6vqdvhvs/PfFr63 Fgkdaqk6F6jvQUC0zq1ovCtzd9pshTFDxr6s2KDrdowbpvKYh2S9FH4PTfqaDgqc/8Ej kAHVKqSr+e2a7ih5oE12UbGmrPL0yJN/agVh8WZMhjJ226nG4Gwul5hlns/KxgCrCMtH PxtQ== 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:dkim-signature:arc-authentication-results; bh=s6eEw4UbdmaZpmqddL4ZXrgf6lhtP7B9Q+xVZrUXqY4=; b=rVk7x39hakU186B5SGH2fIQt5Nv9iy2gGy1sPfvCsLNwEwyVpjLJ6UpxIRo798R0UG IpXh/LrWvPQ2oFww16PYKvwhQBZTRITZck34sO6DBuY0Od4sQrnV/l35c5D+howL2sIb d7t6z/eDNZj9lGzxBVGMoThUBDSL32a0U1kln+qku7dXHLrztbXBU+8UNsZXPQPF2lrZ uXr9Uw45/CFHzY3WdXLPtIn4LBuYd0D7gXZrP0lEfA8+ChnjoCn3YHsYJ42nN22Oqw0L Hb6i3/eHTcaTtPm/bdxHGcsPiD3lPuOPeB5tWTaKNLxeEDnUh4OWkXoD1Ku2DU7KRCPf 4ZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IaURN6Rb; 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 b59-v6si5946793plc.335.2018.07.05.06.08.29; Thu, 05 Jul 2018 06:08:30 -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=@linaro.org header.s=google header.b=IaURN6Rb; 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 S1754634AbeGENI2 (ORCPT + 31 others); Thu, 5 Jul 2018 09:08:28 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33761 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754364AbeGENF3 (ORCPT ); Thu, 5 Jul 2018 09:05:29 -0400 Received: by mail-wr1-f66.google.com with SMTP id k7-v6so1139336wrq.0 for ; Thu, 05 Jul 2018 06:05:28 -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; bh=s6eEw4UbdmaZpmqddL4ZXrgf6lhtP7B9Q+xVZrUXqY4=; b=IaURN6RbJnr2GMMKhrWMGNQnZ5g5nlbItsW3TZfXDzpsCUf12ZKKQXi6Vbho9q8jYz xWfoJsLTP9EYwUHgT2pA51llZyDBV01W1JzE0mWjr2PE0e+ps5xx59VxsDsEYYwylc+n pO9iZseXRavlF4UHa8WrGI8IDriern4PX0AyE= 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; bh=s6eEw4UbdmaZpmqddL4ZXrgf6lhtP7B9Q+xVZrUXqY4=; b=sFKiL50Mjt52bNPqvf272I1OP1nluGa3u1h4yg61gIw5z817Ggir6WIP+9sfL16e2M EDfBga8rJ4c7t/HxNKwN6WEUKz0ojHi/ty6bvkg9Y9PtQvPTVTBjN8ZYNTXNxWALxL2W 2YjzVHEBm+JlWgLidxSXATTrao/LTlIaQy2YpO/uEEtj522HW2EXbGhFjcRSg7Lw4fgN IV/vmR9JQlne9k8ZFnY99xKVXWVEWsBsEOLvF6pd29G4XCtoiXkO/5+ZiHlzD51t6tBX awSceeMFHvv4LUCX43eCK3y4oLLvbiD367ijnB1K383s/b4KTA8DNZ7dhY22mf0C30Co 315g== X-Gm-Message-State: APt69E2/bQ8xDujEHxrQaDsftR6hIue2bW9+QAe4IgMjQ55smE3WEUFC Slt8KjLwFxbPm9R52/ILn2k9CA== X-Received: by 2002:adf:a015:: with SMTP id k21-v6mr4442731wrk.202.1530795928009; Thu, 05 Jul 2018 06:05:28 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:27 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 19/27] venus: helpers, vdec, venc: add helpers to set work mode and core usage Date: Thu, 5 Jul 2018 16:03:53 +0300 Message-Id: <20180705130401.24315-20-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These are new properties applicable to Venus version 4xx. Add the helpers and call them from decoder and encoder drivers. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/helpers.c | 28 ++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 8 ++++++++ drivers/media/platform/qcom/venus/venc.c | 8 ++++++++ 4 files changed, 46 insertions(+) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 4e4109e80988..3cd25e25aa70 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -486,6 +486,34 @@ 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) +{ + const u32 ptype = HFI_PROPERTY_PARAM_WORK_MODE; + struct hfi_video_work_mode wm; + + if (!IS_V4(inst->core)) + return 0; + + wm.video_work_mode = mode; + + return hfi_session_set_property(inst, ptype, &wm); +} +EXPORT_SYMBOL_GPL(venus_helper_set_work_mode); + +int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage) +{ + const u32 ptype = HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE; + struct hfi_videocores_usage_type cu; + + if (!IS_V4(inst->core)) + return 0; + + cu.video_core_enable_mask = usage; + + return hfi_session_set_property(inst, ptype, &cu); +} +EXPORT_SYMBOL_GPL(venus_helper_set_core_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/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 79af7845efbd..d5e727e1ecab 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -38,6 +38,8 @@ 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_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); int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format, diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index d2a53c0eab86..75f622c73222 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -550,6 +550,14 @@ static int vdec_set_properties(struct venus_inst *inst) u32 ptype; int ret; + ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); + if (ret) + return ret; + + ret = venus_helper_set_core_usage(inst, VIDC_CORE_ID_1); + if (ret) + return ret; + if (core->res->hfi_version == HFI_VERSION_1XX) { ptype = HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER; ret = hfi_session_set_property(inst, ptype, &en); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 650e6b0a01d2..6dc153f16d88 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -643,6 +643,14 @@ static int venc_set_properties(struct venus_inst *inst) u32 ptype, rate_control, bitrate, profile = 0, level = 0; int ret; + ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2); + if (ret) + return ret; + + ret = venus_helper_set_core_usage(inst, VIDC_CORE_ID_2); + if (ret) + return ret; + ptype = HFI_PROPERTY_CONFIG_FRAME_RATE; frate.buffer_type = HFI_BUFFER_OUTPUT; frate.framerate = inst->fps * (1 << 16); From patchwork Thu Jul 5 13:03:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141132 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1921806ljj; Thu, 5 Jul 2018 06:08:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenGtlVRP5Z3kVMa3n9CdR5jwDy7X4+bANocwfKpxUxn4osIF+1sSrh/zUDqDwaA2gkYvAZ X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr5608003pgr.445.1530796090421; Thu, 05 Jul 2018 06:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796090; cv=none; d=google.com; s=arc-20160816; b=hPnR6q3OFHrUTNC66YycOHnHyCTjv7mw/wuXUgS4ErbRLTbu5c+bnIsd8tYp5PfNbG WY06GX0OVBLJ0+rOENYITpHQ7tKMfsSHf2+w+Ax03DzJvynCYYdc9AJ8uUBVjzTmaePn rLeJC/79UjVn4I2TkMJ574FFEBG0owTaK7mCpC+qMNigruOMQk3s2cxQpsDRRkJPNkpn oC1EVjXTJMOQHI5WtA/vEJz1Ym1X+oXwGDLf5o6pa7Wmbx/r6nKxEjLDrQkW6IWpKMVN GJeU9LGRLgGDKJo9yKH8C+BO550z2HTyWFatz6b4xOPnDQuDnA+l2xtRzlqPUV3gVmh1 JxTw== 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:dkim-signature:arc-authentication-results; bh=olV8QCV6OTgGL+a7O+uasLtsP5Ovu74pzCpIsDTiQaA=; b=RDcO39vZYGOcg4/PCWySgeHaEXk4KTBnOxBgtHFiRH1yPhLIp87gfPZDKXmNL4/FcU cBWNE64MvbUHSdTXBm6rLBx/+GqQTjm4h4/z5kjAJNkTRLitnccbB4jUXAUtOdIscd6e QygbFV8Vpgwsc6yVQRmL3N3es6SRzTaF0R3VoWYh1M1FzO/j50gEd4Zc1oJbSomSHayO XZXmXnsOSb/BBttOZX+GIiP7D1DPPN+08Il2d/UDRX6khmAKINBzJmAYjRIJWzZDWnYj Gg+Q075P4yFGZWJVoEr0RU1FoJgI6HF1oeWC7HDZN4Ej1MotMl+0T+5obJPSrecAc2Eh GtTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NXjY1ls9; 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 y23-v6si6581193pfb.284.2018.07.05.06.08.10; Thu, 05 Jul 2018 06:08:10 -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=@linaro.org header.s=google header.b=NXjY1ls9; 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 S1754597AbeGENIH (ORCPT + 31 others); Thu, 5 Jul 2018 09:08:07 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55415 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754478AbeGENFa (ORCPT ); Thu, 5 Jul 2018 09:05:30 -0400 Received: by mail-wm0-f67.google.com with SMTP id v16-v6so11020098wmv.5 for ; Thu, 05 Jul 2018 06:05:29 -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; bh=olV8QCV6OTgGL+a7O+uasLtsP5Ovu74pzCpIsDTiQaA=; b=NXjY1ls9miz/xtVcYPTlpHp55RGPE0LUjpLPfjNGLr0URgaDZg1RlvExour0XmF+lE W2JLYMF6HbpWFtVcBaHURAPSsfp8E16amouYSBYeOfqG41U/ehOuvi/nQ8sNWfilS3ph YoS2GzRw1FjcpSQzP/tJ3rSZygBEOx0RB+xZc= 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; bh=olV8QCV6OTgGL+a7O+uasLtsP5Ovu74pzCpIsDTiQaA=; b=m1XjV8wIOciDMvj7NBvagktMGglmb7BUiEU3e4RX3yATVNu9wv5drEJ2cnQG8hClSa 0me+rs9fx8KfKZf1OQwPGULTbu1NSKNQMufCMx2H19irwJ3lRwI0qEgt6KaloaAPd4pw k9Znm/evd6kBuA3D7tBKaoiXrcIK2nZVwn/If3UP0le89tk0EboPryeI4k0w2iEZ+U7a swcyy+Zu2uIgjcnpHf5vJ4H6PFn2xPbL4kAchRfCExmrzAkNDUxKzZNXOC8CsaK4sVbQ ApODZr9Z3GB0ac/6SxjKTTlUaC9kXAQI3G54Q905TD1qORH/L/yoJEPRNGcPTDHpXZ5C qe7g== X-Gm-Message-State: APt69E1ltH2oFGuylvXqaMEK7o0EAQzVyfCafwFIKMvCHYoi0yDMxm+M j+BFsnjLRaosUpmA7tslInwgRkNVxrE= X-Received: by 2002:a1c:ca0f:: with SMTP id a15-v6mr3966291wmg.102.1530795929111; Thu, 05 Jul 2018 06:05:29 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:28 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 20/27] venus: helpers: extend set_num_bufs helper with one more argument Date: Thu, 5 Jul 2018 16:03:54 +0300 Message-Id: <20180705130401.24315-21-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend venus_helper_set_num_bufs() helper function with one more argument to set number of output buffers for the secondary decoder output. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/helpers.c | 16 ++++++++++++++-- drivers/media/platform/qcom/venus/helpers.h | 3 ++- drivers/media/platform/qcom/venus/vdec.c | 2 +- drivers/media/platform/qcom/venus/venc.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 3cd25e25aa70..13f0bc4e5ffa 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -515,7 +515,8 @@ int venus_helper_set_core_usage(struct venus_inst *inst, u32 usage) EXPORT_SYMBOL_GPL(venus_helper_set_core_usage); int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, - unsigned int output_bufs) + unsigned int output_bufs, + unsigned int output2_bufs) { u32 ptype = HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL; struct hfi_buffer_count_actual buf_count; @@ -531,7 +532,18 @@ int venus_helper_set_num_bufs(struct venus_inst *inst, unsigned int input_bufs, buf_count.type = HFI_BUFFER_OUTPUT; buf_count.count_actual = output_bufs; - return hfi_session_set_property(inst, ptype, &buf_count); + ret = hfi_session_set_property(inst, ptype, &buf_count); + if (ret) + return ret; + + if (output2_bufs) { + buf_count.type = HFI_BUFFER_OUTPUT2; + buf_count.count_actual = output2_bufs; + + ret = hfi_session_set_property(inst, ptype, &buf_count); + } + + return ret; } EXPORT_SYMBOL_GPL(venus_helper_set_num_bufs); diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index d5e727e1ecab..8ff4bd3ef958 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -41,7 +41,8 @@ int venus_helper_set_output_resolution(struct venus_inst *inst, int venus_helper_set_work_mode(struct venus_inst *inst, u32 mode); 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); + unsigned int output_bufs, + unsigned int output2_bufs); int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format, u32 buftype); int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 75f622c73222..3af1fb81cc32 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -758,7 +758,7 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) goto deinit_sess; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - VB2_MAX_FRAME); + VB2_MAX_FRAME, VB2_MAX_FRAME); if (ret) goto deinit_sess; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 6dc153f16d88..cc8049fd8811 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -963,7 +963,7 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) goto deinit_sess; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - inst->num_output_bufs); + inst->num_output_bufs, 0); if (ret) goto deinit_sess; From patchwork Thu Jul 5 13:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141131 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1921424ljj; Thu, 5 Jul 2018 06:07:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHW+E/zOHX+Pt5Lpe9dRDM8awdv1gsSATKJbrJCZoeAcs+0rxusED+QTXFz9UoEwqMpzU+ X-Received: by 2002:a63:743:: with SMTP id 64-v6mr5730968pgh.216.1530796067101; Thu, 05 Jul 2018 06:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530796067; cv=none; d=google.com; s=arc-20160816; b=KZVAX+182mIdgVqkGL4cV+QizjKxkgsScyoNNCVpFmiPfj4hhB9G5GVvbmF3CnjlIZ w+5IidTHLhb7tVoa/QFlBGXkrC3y06DYYvKAPtzqzGCFYZd5keTtYamhv+CX5C7P7FtH FsEhC3zoZEzcG5w0LoMX94gb6UG70iAamJZIkDquEmq9Pj1b54l8tugIcicyVF2mOdtX gbviG5VaQcPF1Bzm3xxAgjNRCDb7y1E9yybkUAez77PtqBEllIichFBVnXsshNWpNE7g ZX3LW8et3TcjU12p6TX5ancTYZd8uBgVn8MXORKfDzpr4UeYvd8JHzZbD9DeRP8P7z/N gS1Q== 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:dkim-signature:arc-authentication-results; bh=VamVn5fSKrK4jIDm67aUg+jNMsWMI46PpJA4aHsLT5c=; b=SgXa3CSDrPJ57fRWPH1Qcks0RIHbyccmspIuHbvr2W7BDW+kKrx+0gYhTki3aI8KuT /6f1n3JWvs8ctqjegDuTIc7uYy76WMF5JRJzU9yHbbEpoMECu76q00HRH3HgU6ZDH/h4 HKiCKRh3dRiyRdjt700Fq6QvZ9BnPWglTXPP2HICLih93VVjVQMUydD5659hjjCdl+wh yhiDouXRcM3KmIcbmwV8FY/UYGF2OxetmkhDSMIEoW1wPzhxz6XxmfmEzgmwQfCc17OG LvXcgECnVth5jMqNbiI+Y/TLruw6shuRkj+vAaUJlxwBSpTW7F/rsIcpElEvTPVLMSVK bc1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ALkgydW9; 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 h21-v6si4017565pgi.430.2018.07.05.06.07.46; Thu, 05 Jul 2018 06:07:47 -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=@linaro.org header.s=google header.b=ALkgydW9; 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 S1754571AbeGENHq (ORCPT + 31 others); Thu, 5 Jul 2018 09:07:46 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53205 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754450AbeGENFb (ORCPT ); Thu, 5 Jul 2018 09:05:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id w16-v6so10970211wmc.2 for ; Thu, 05 Jul 2018 06:05:30 -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; bh=VamVn5fSKrK4jIDm67aUg+jNMsWMI46PpJA4aHsLT5c=; b=ALkgydW9wsSzJuQFxkwBrZrmo5SRODbIFWkta67CEBZlOeDDHcqkUu2Flg2aoO2tI6 rz9Y3VO8tMo4s1qW/fB8Dvctgu4TbDIBD9hb1FwK/b/3a+OSOL930kz6JgaIg3xzOCP6 8tLN5zZLMzQgoWSERoZSmVIBGe/erThRa5sbM= 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; bh=VamVn5fSKrK4jIDm67aUg+jNMsWMI46PpJA4aHsLT5c=; b=cdUv7M7A5p+Rf+l7UbWeI53ocWWQYbl4+Jh++P605Pp6wRt1rqaKUzWvUU/UMaiS94 +br0b3YpFEzILjK/ZSpf5IUfkoYnrcY8IL8QtF0tAg5oEkPymlsIa8sDUuAnP54x4aX8 HZJeiUlr/Lb8P4wAvs4AIHk+vo0oU0iLtV1DhEC+nntm/p5+tu4abnuntSTkzSjU7z2C z71SSXSN7D+xdUmyohJ21oOch5244aswfc4MXihl6um0FGfSN9ZUphjZ95okpU5jL4AB oTIdDICzAG6nH8b8KFiGS8MjnPlGkgaMulLWmmZgdwiwl5Ez0CcLlroR/GMsPCWE8b2K G9IQ== X-Gm-Message-State: APt69E1iD3qsrNybvZqfCUicjGqcG+9L40aexOJuoLKWtq3Pke8Kmv3o wg0/HqZ29l2zVYXJEGwchio/uQ== X-Received: by 2002:adf:c00b:: with SMTP id z11-v6mr4394798wre.268.1530795930265; Thu, 05 Jul 2018 06:05:30 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:29 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 21/27] venus: helpers: add a helper to return opb buffer sizes Date: Thu, 5 Jul 2018 16:03:55 +0300 Message-Id: <20180705130401.24315-22-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper function to return current output picture buffer size. OPB sizes can vary depending on the selected decoder output(s). Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 6 ++++++ drivers/media/platform/qcom/venus/helpers.c | 15 +++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 1 + 3 files changed, 22 insertions(+) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 1d1a59a5d343..f8e4d92ff0e1 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -239,6 +239,9 @@ struct venus_buffer { * @num_output_bufs: holds number of output buffers * @input_buf_size holds input buffer size * @output_buf_size: holds output buffer size + * @output2_buf_size: holds secondary decoder output buffer size + * @opb_buftype: output picture buffer type + * @opb_fmt: output picture buffer raw format * @reconfig: a flag raised by decoder when the stream resolution changed * @reconfig_width: holds the new width * @reconfig_height: holds the new height @@ -288,6 +291,9 @@ struct venus_inst { unsigned int num_output_bufs; unsigned int input_buf_size; unsigned int output_buf_size; + unsigned int output2_buf_size; + u32 opb_buftype; + u32 opb_fmt; bool reconfig; u32 reconfig_width; u32 reconfig_height; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 13f0bc4e5ffa..8d2f4db52e48 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -613,6 +613,21 @@ int venus_helper_set_bufsize(struct venus_inst *inst, u32 bufsize, u32 buftype) } EXPORT_SYMBOL_GPL(venus_helper_set_bufsize); +unsigned int venus_helper_get_opb_size(struct venus_inst *inst) +{ + /* the encoder has only one output */ + if (inst->session_type == VIDC_SESSION_TYPE_ENC) + return inst->output_buf_size; + + if (inst->opb_buftype == HFI_BUFFER_OUTPUT) + return inst->output_buf_size; + else if (inst->opb_buftype == HFI_BUFFER_OUTPUT2) + return inst->output2_buf_size; + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_get_opb_size); + static void delayed_process_buf_func(struct work_struct *work) { struct venus_buffer *buf, *n; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 8ff4bd3ef958..92be45894a69 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -48,6 +48,7 @@ int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format, int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); int venus_helper_set_dyn_bufmode(struct venus_inst *inst); int venus_helper_set_bufsize(struct venus_inst *inst, u32 bufsize, u32 buftype); +unsigned int venus_helper_get_opb_size(struct venus_inst *inst); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); From patchwork Thu Jul 5 13:03:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141125 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1918964ljj; Thu, 5 Jul 2018 06:05:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsOmRtztfQNN/p91qpIrwQBjjZwh8PhbQFM60h5daq7PPJo7vGQIYloxN0ygg9aig8VUU5 X-Received: by 2002:a62:403:: with SMTP id 3-v6mr6341465pfe.28.1530795941458; Thu, 05 Jul 2018 06:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795941; cv=none; d=google.com; s=arc-20160816; b=gajNdJHd420e6B1/ZRahhjIygwkJKGUWH2d7XHixwqkobegHLjRP98aRWZUZN+daGw ODRjRsPgXC2LvPU9d5NHTZxXMRV8dBIZKIUzKVIidTFNzkg01D3WAZQm7Bvpsbpg2QZy cImsG8wzidITZ4tMx4LqA9M0RyiTE2BpLSHADb3Ah+rfbrLIkrYMLQoTsVKRvHUqBis/ n1uVCTEEL/FdqUDkhCuyztsF8RHXdqS0Zkp16+l35RZVHpqjhnFRQNjbY3U7BjPlv9L5 C3IJaomreWUeemAE0+dtCCh7nliYja7NnvESPstCsCRqwtdKSUwfus5YphPU9833gpTY dDUQ== 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:dkim-signature:arc-authentication-results; bh=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=ii0KACVEZW3tElaWWTcOXY845hrJ4Iyb1inUR4tokD+DuN3/gyF3LkqvOZN0z9S9Tt dS1oO40TkSXaV2IwlCDusTGdP8nJgWAvBh2KF05NZP3TC3GbyEwAdjBmzVAF1l10fMrB 6iyxcgPnRcXlxM38JyEyFNpBTpwB1zmLfeYcyuYw6ZfZowGccl2jg4Kl4OlqvZF54dmj 6SCGRydhcgS3UuzRrV4W0UDC2c6yOWD0vSUwy0fZB5cPg8dKV+FZeU5IhLaBjcH9hMVM 1VT60AFYfdNd09XzmPhzH7hjdqu7eh60PCxU1VVFsFkAQQ6piu8KhcSU+jw/eC4zHRzh q4vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7xUd24f; 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 31-v6si5907304plj.216.2018.07.05.06.05.41; Thu, 05 Jul 2018 06:05:41 -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=@linaro.org header.s=google header.b=G7xUd24f; 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 S1754562AbeGENFi (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:38 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37867 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754503AbeGENFc (ORCPT ); Thu, 5 Jul 2018 09:05:32 -0400 Received: by mail-wm0-f65.google.com with SMTP id n17-v6so10744443wmh.2 for ; Thu, 05 Jul 2018 06:05:31 -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; bh=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=G7xUd24fjdUgudFXl/E7d+WwP7Gv/iBVmIZJppkl2QWAtWjvgmzBmAJ9EEOsbPmDX7 853YvZLoxHvtWdTj7R6NS0fstwbKzrleQSAb2DH0Fhn3vsZBsn1hhliXPlWoNN4Ttyjx bOw6+d2U1MK8Y+DMGZraWWjD4yLXlAWRuoRNU= 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; bh=M+oHvhOxeajEleWqY/pKIr12AGkun8DctwS20UTRPoc=; b=py8/x6HmVXg6tLI4I3zIF0nAaJbS5Ld8iDHHgB73G5cBo1zy/2HpMwyrCyUYJtXS00 6PmNt1oZza7XoP8EmSH3yQ+/OJEG1vKcivuc5GrJzc7gluiVHPawsH6ThKtK6PqJdT8o 4fXjgvaIaCRpAQ8Fr/aQ9JhyVPuha/q3vGwz+LdCQ/RCZZsAknmQOppQI4vY6EqYtLdm Rrt00axgVmIHTuAL9azFS/urdFs4kAZcACpT2fti78gwGdDIZD+QWAa9ldnew304cFqD vv9J2djsaYjx1sxPh8DDsrte4Aoj81jZT1d9TbI4div+X5ICSWzhIX1lr88hcKCYYg/M Etyg== X-Gm-Message-State: APt69E1O2qgqylArMPhOTsgmuUy3HPvepkQgYEVGqjUt2LNQ+lE2unZN KeEycLhoqYxUkBLhVtjQ1YGolQ== X-Received: by 2002:a1c:818e:: with SMTP id c136-v6mr4214555wmd.107.1530795931291; Thu, 05 Jul 2018 06:05:31 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:30 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 22/27] venus: vdec: get required input buffers as well Date: Thu, 5 Jul 2018 16:03:56 +0300 Message-Id: <20180705130401.24315-23-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rework and rename vdec_cap_num_buffers() to get the number of input buffers too. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/vdec.c | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 3af1fb81cc32..c98084f51e5e 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -603,19 +603,32 @@ static int vdec_init_session(struct venus_inst *inst) return ret; } -static int vdec_cap_num_buffers(struct venus_inst *inst, unsigned int *num) +static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num, + unsigned int *out_num) { + enum hfi_version ver = inst->core->res->hfi_version; struct hfi_buffer_requirements bufreq; int ret; + *in_num = *out_num = 0; + ret = vdec_init_session(inst); if (ret) return ret; + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); + if (ret) + goto deinit; + + *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + if (ret) + goto deinit; - *num = bufreq.count_actual; + *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); +deinit: hfi_session_deinit(inst); return ret; @@ -626,7 +639,7 @@ static int vdec_queue_setup(struct vb2_queue *q, unsigned int sizes[], struct device *alloc_devs[]) { struct venus_inst *inst = vb2_get_drv_priv(q); - unsigned int p, num; + unsigned int p, in_num, out_num; int ret = 0; if (*num_planes) { @@ -649,35 +662,29 @@ static int vdec_queue_setup(struct vb2_queue *q, return 0; } + ret = vdec_num_buffers(inst, &in_num, &out_num); + if (ret) + return ret; + switch (q->type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: *num_planes = inst->fmt_out->num_planes; sizes[0] = get_framesize_compressed(inst->out_width, inst->out_height); inst->input_buf_size = sizes[0]; + *num_buffers = max(*num_buffers, in_num); inst->num_input_bufs = *num_buffers; - - ret = vdec_cap_num_buffers(inst, &num); - if (ret) - break; - - inst->num_output_bufs = num; + inst->num_output_bufs = out_num; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: *num_planes = inst->fmt_cap->num_planes; - ret = vdec_cap_num_buffers(inst, &num); - if (ret) - break; - - *num_buffers = max(*num_buffers, num); - for (p = 0; p < *num_planes; p++) sizes[p] = get_framesize_uncompressed(p, inst->width, inst->height); - - inst->num_output_bufs = *num_buffers; inst->output_buf_size = sizes[0]; + *num_buffers = max(*num_buffers, out_num); + inst->num_output_bufs = *num_buffers; break; default: ret = -EINVAL; From patchwork Thu Jul 5 13:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141128 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1919825ljj; Thu, 5 Jul 2018 06:06:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpetjsrrslN9wkKVIQ2EuljsVPKRSmJWpGj24ZIVcFGZ/4iCDYZ+GsGymV7SAcDyjul0musW X-Received: by 2002:a17:902:7086:: with SMTP id z6-v6mr4538545plk.330.1530795985165; Thu, 05 Jul 2018 06:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795985; cv=none; d=google.com; s=arc-20160816; b=IHkQfu6Id7O7ijSM1iEOW2ogFde0lP+tNj5p1eiHiuCk/ZYqONQHQmSC8k/dTXj/GZ 9EWaTmQPXE78qnB80DUKteox2nPIeRD4tBJizU7uGrN81cvRA2cbxbRuZ2Ff+xtKbDGb s/CMmZusqIG4POJWw9kXTvC0pLrcQG7fhlgC13D0WHfRnh2ab9LhMgJmfseIpSL8VN+0 gGa/1rSoYl/UEG9A2lT+qy0bxR1+/zsfPOF9wcjuzPhBaiah0bXxNgQxp+yNZwo51xgJ XdTHvVmbu9t73JydlHQSYFNiGs4MdhQH6bqme+A24FXtuouJGhN1y83Aii557CxK4IdG Dsbw== 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:dkim-signature:arc-authentication-results; bh=wWX908pS6EP/SmGEa1X1lzXMFxvJffbhyzxvu6Ya2xY=; b=wJx+FesdqBTtRsxE8X8VtxTHd0WOhNCwfqDphurN4omBy4gyd5msf5i3tBFDyGsMMw PT9VCNNXUMfpryi+SGCjlLNiRo2/FAScXtfoldUyP2+dFYdfnLPz8fX+ZhX1yr/FfV0G yxHJhvzyhv8FTZ4L0MIxIqMgbbyU+p51SNLBInVkFrLbppejnyhH+XxignRlkma2Et6Q E7HBbXM3oIYVRUgg/qXQFeYZKTBbl078ui+Mtmw/oADaznFoikghL/K6SFnsliDQfxAT Rpf9S31Nfl8l/9ogfZEBJPkpSK5fdufYCLpbEe0JPG0D6gGF37vQbnNx2tMlygclXpLt tmGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jXtdOYXC; 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 b3-v6si5297885pgq.387.2018.07.05.06.06.24; Thu, 05 Jul 2018 06:06:25 -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=@linaro.org header.s=google header.b=jXtdOYXC; 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 S1754624AbeGENGW (ORCPT + 31 others); Thu, 5 Jul 2018 09:06:22 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43953 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754519AbeGENFg (ORCPT ); Thu, 5 Jul 2018 09:05:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id b15-v6so1136220wrv.10 for ; Thu, 05 Jul 2018 06:05:35 -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; bh=wWX908pS6EP/SmGEa1X1lzXMFxvJffbhyzxvu6Ya2xY=; b=jXtdOYXCji+oUVF3EzD8Oxq86ozixNGAQVbl3TwKBqhZVkq5xwXZv7Xhu4eRS6EwVo 9ejiIa4n7dgVZFdtwyJYUMuWL46gpH00ySJWECtviNsurE6SW0NxTL7jmO+r2ABsDP7Q FdxhAGCsZ+i52qdAD3xFNm1fYuEm+myE/uhiw= 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; bh=wWX908pS6EP/SmGEa1X1lzXMFxvJffbhyzxvu6Ya2xY=; b=ZM+vgbZDke6a+qATlC8vlkqEDnU8Nb8tuKCH+8vBmWfEkh7bRmZTyZo7QwiamGo6Ys 3DaQ8GMUrA6Z+ouWRdDCPDcjkS4GlFQ/+R2p1iISHRENIHPtSwnJCUOb2uqWOiRT+NRA IwbVmb7i7WLtxAe8rFDzPTuWvI/tE3zJWOmuy73G2DQE2bkpH0CmzaJE5OSpr3osMtpe 0mHfp06GJv0RIU7k9KfTJ2TOc0waznr3GwjsUmxuR6pzDT9z0MnxxjvZEyEzSlZCHTj+ fd6zbrFbz68OSiJ9yMfHy5eQtuUgDcOhqjyvyZ7K3Exgnk87dtye34rGSxvZB2Du2/IL CEbQ== X-Gm-Message-State: APt69E3BHXYs+PsXeDNoyfJRx+X84KP5W5U0Yp0xOZoZ58LIjb2v3nc+ nrU/MStWUQyVznqT1CoufrCTKedcGK8= X-Received: by 2002:adf:8bd7:: with SMTP id w23-v6mr4352763wra.208.1530795934897; Thu, 05 Jul 2018 06:05:34 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:34 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 25/27] venus: implementing multi-stream support Date: Thu, 5 Jul 2018 16:03:59 +0300 Message-Id: <20180705130401.24315-26-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is implementing multi-stream decoder support. The multi-stream will be used to enable/disable the primary/secondary decoder outputs. Depending on formats on both decoder outputs we could implement downscale, dithering and supporting UBWC (universal bandwidth compression) formats. The UBWC compressed raw format is used to optimize interconnect bandwidth for bigger resolutions like 4K and hence we will get some power-saving benefits as well. Both decoder outputs are distinguished by buffer_type field in the HFI packets. For example HFI_BUFFER_OUTPUT is the buffer type for primary decoder output and HFI_BUFFER_OUTPUT2 is for secondary decoder output. Starting from Venus 4xx the DPB buffers format must be UBWC, so the multi-stream becomes mandatory for this Venus version. That means that we need to allocate internally in the driver a set of DPB buffers (with UBWC NV12 format) and give them to the firmware. The other decoder output (we called it OPB) format will be NV12 linear format and with the same resolution (or smaller in case the user wants to downscale). The DPB buffers are used for decoder reference frames and those have to be in a specific format (UBWC). So one decoder output is used to fill those reference buffers while the other output is used to fill the userspace buffers with the user requested format. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 6 + drivers/media/platform/qcom/venus/helpers.c | 198 +++++++++++++++++++++++++++- drivers/media/platform/qcom/venus/helpers.h | 6 + drivers/media/platform/qcom/venus/vdec.c | 93 ++++++++++++- drivers/media/platform/qcom/venus/venc.c | 1 + 5 files changed, 300 insertions(+), 4 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f8e4d92ff0e1..8cc49f30a363 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -215,6 +215,7 @@ struct venus_buffer { * @list: used for attach an instance to the core * @lock: instance lock * @core: a reference to the core struct + * @dpbbufs: a list of decoded picture buffers * @internalbufs: a list of internal bufferes * @registeredbufs: a list of registered capture bufferes * @delayed_process a list of delayed buffers @@ -240,6 +241,8 @@ struct venus_buffer { * @input_buf_size holds input buffer size * @output_buf_size: holds output buffer size * @output2_buf_size: holds secondary decoder output buffer size + * @dpb_buftype: decoded picture buffer type + * @dpb_fmt: decoded picture buffer raw format * @opb_buftype: output picture buffer type * @opb_fmt: output picture buffer raw format * @reconfig: a flag raised by decoder when the stream resolution changed @@ -263,6 +266,7 @@ struct venus_inst { struct list_head list; struct mutex lock; struct venus_core *core; + struct list_head dpbbufs; struct list_head internalbufs; struct list_head registeredbufs; struct list_head delayed_process; @@ -292,6 +296,8 @@ struct venus_inst { unsigned int input_buf_size; unsigned int output_buf_size; unsigned int output2_buf_size; + u32 dpb_buftype; + u32 dpb_fmt; u32 opb_buftype; u32 opb_fmt; bool reconfig; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 1e4d18448f7b..cea5b506dd51 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -85,6 +85,106 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_check_codec); +static int venus_helper_queue_dpb_bufs(struct venus_inst *inst) +{ + struct intbuf *buf; + int ret = 0; + + list_for_each_entry(buf, &inst->dpbbufs, list) { + struct hfi_frame_data fdata; + + memset(&fdata, 0, sizeof(fdata)); + fdata.alloc_len = buf->size; + fdata.device_addr = buf->da; + fdata.buffer_type = buf->type; + + ret = hfi_session_process_buf(inst, &fdata); + if (ret) + goto fail; + } + +fail: + return ret; +} + +int venus_helper_free_dpb_bufs(struct venus_inst *inst) +{ + struct intbuf *buf, *n; + + list_for_each_entry_safe(buf, n, &inst->dpbbufs, list) { + list_del_init(&buf->list); + dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da, + buf->attrs); + kfree(buf); + } + + INIT_LIST_HEAD(&inst->dpbbufs); + + return 0; +} +EXPORT_SYMBOL_GPL(venus_helper_free_dpb_bufs); + +int venus_helper_alloc_dpb_bufs(struct venus_inst *inst) +{ + struct venus_core *core = inst->core; + struct device *dev = core->dev; + enum hfi_version ver = core->res->hfi_version; + struct hfi_buffer_requirements bufreq; + u32 buftype = inst->dpb_buftype; + unsigned int dpb_size = 0; + struct intbuf *buf; + unsigned int i; + u32 count; + int ret; + + /* no need to allocate dpb buffers */ + if (!inst->dpb_fmt) + return 0; + + if (inst->dpb_buftype == HFI_BUFFER_OUTPUT) + dpb_size = inst->output_buf_size; + else if (inst->dpb_buftype == HFI_BUFFER_OUTPUT2) + dpb_size = inst->output2_buf_size; + + if (!dpb_size) + return 0; + + ret = venus_helper_get_bufreq(inst, buftype, &bufreq); + if (ret) + return ret; + + count = HFI_BUFREQ_COUNT_MIN(&bufreq, ver); + + for (i = 0; i < count; i++) { + buf = kzalloc(sizeof(*buf), GFP_KERNEL); + if (!buf) { + ret = -ENOMEM; + goto fail; + } + + buf->type = buftype; + buf->size = dpb_size; + buf->attrs = DMA_ATTR_WRITE_COMBINE | + DMA_ATTR_NO_KERNEL_MAPPING; + buf->va = dma_alloc_attrs(dev, buf->size, &buf->da, GFP_KERNEL, + buf->attrs); + if (!buf->va) { + kfree(buf); + ret = -ENOMEM; + goto fail; + } + + list_add_tail(&buf->list, &inst->dpbbufs); + } + + return 0; + +fail: + venus_helper_free_dpb_bufs(inst); + return ret; +} +EXPORT_SYMBOL_GPL(venus_helper_alloc_dpb_bufs); + static int intbufs_set_buffer(struct venus_inst *inst, u32 type) { struct venus_core *core = inst->core; @@ -347,7 +447,10 @@ session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf) if (vbuf->flags & V4L2_BUF_FLAG_LAST || !fdata.filled_len) fdata.flags |= HFI_BUFFERFLAG_EOS; } else if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { - fdata.buffer_type = HFI_BUFFER_OUTPUT; + if (inst->session_type == VIDC_SESSION_TYPE_ENC) + fdata.buffer_type = HFI_BUFFER_OUTPUT; + else + fdata.buffer_type = inst->opb_buftype; fdata.filled_len = 0; fdata.offset = 0; } @@ -677,6 +780,27 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 pixfmt) } EXPORT_SYMBOL_GPL(venus_helper_set_color_format); +int venus_helper_set_multistream(struct venus_inst *inst, bool out_en, + bool out2_en) +{ + struct hfi_multi_stream multi = {0}; + u32 ptype = HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; + int ret; + + multi.buffer_type = HFI_BUFFER_OUTPUT; + multi.enable = out_en; + + ret = hfi_session_set_property(inst, ptype, &multi); + if (ret) + return ret; + + multi.buffer_type = HFI_BUFFER_OUTPUT2; + multi.enable = out2_en; + + return hfi_session_set_property(inst, ptype, &multi); +} +EXPORT_SYMBOL_GPL(venus_helper_set_multistream); + int venus_helper_set_dyn_bufmode(struct venus_inst *inst) { const u32 ptype = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; @@ -824,9 +948,10 @@ EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_init); int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb) { struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + unsigned int out_buf_size = venus_helper_get_opb_size(inst); if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && - vb2_plane_size(vb, 0) < inst->output_buf_size) + vb2_plane_size(vb, 0) < out_buf_size) return -EINVAL; if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && vb2_plane_size(vb, 0) < inst->input_buf_size) @@ -896,6 +1021,8 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q) if (ret) hfi_session_abort(inst); + venus_helper_free_dpb_bufs(inst); + load_scale_clocks(core); INIT_LIST_HEAD(&inst->registeredbufs); } @@ -934,8 +1061,14 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst) if (ret) goto err_unload_res; + ret = venus_helper_queue_dpb_bufs(inst); + if (ret) + goto err_session_stop; + return 0; +err_session_stop: + hfi_session_stop(inst); err_unload_res: hfi_session_unload_res(inst); err_unreg_bufs: @@ -989,6 +1122,67 @@ void venus_helper_init_instance(struct venus_inst *inst) } EXPORT_SYMBOL_GPL(venus_helper_init_instance); +static bool find_fmt_from_caps(struct venus_caps *caps, u32 buftype, u32 fmt) +{ + unsigned int i; + + for (i = 0; i < caps->num_fmts; i++) { + if (caps->fmts[i].buftype == buftype && + caps->fmts[i].fmt == fmt) + return true; + } + + return false; +} + +int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt, + u32 *out_fmt, u32 *out2_fmt, bool ubwc) +{ + struct venus_core *core = inst->core; + struct venus_caps *caps; + u32 ubwc_fmt, fmt = to_hfi_raw_fmt(v4l2_fmt); + bool found, found_ubwc; + + *out_fmt = *out2_fmt = 0; + + if (!fmt) + return -EINVAL; + + caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type); + if (!caps) + return -EINVAL; + + if (ubwc) { + ubwc_fmt = fmt | HFI_COLOR_FORMAT_UBWC_BASE; + found_ubwc = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT, + ubwc_fmt); + found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT2, fmt); + + if (found_ubwc && found) { + *out_fmt = ubwc_fmt; + *out2_fmt = fmt; + return 0; + } + } + + found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT, fmt); + if (found) { + *out_fmt = fmt; + *out2_fmt = 0; + return 0; + } + + found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT2, fmt); + if (found) { + *out_fmt = 0; + *out2_fmt = fmt; + return 0; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts); + int venus_helper_power_enable(struct venus_core *core, u32 session_type, bool enable) { diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 92b167a47166..2475f284f396 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -50,10 +50,16 @@ int venus_helper_set_raw_format(struct venus_inst *inst, u32 hfi_format, int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); int venus_helper_set_dyn_bufmode(struct venus_inst *inst); int venus_helper_set_bufsize(struct venus_inst *inst, u32 bufsize, u32 buftype); +int venus_helper_set_multistream(struct venus_inst *inst, bool out_en, + bool out2_en); unsigned int venus_helper_get_opb_size(struct venus_inst *inst); void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); void venus_helper_init_instance(struct venus_inst *inst); +int venus_helper_get_out_fmts(struct venus_inst *inst, u32 fmt, u32 *out_fmt, + u32 *out2_fmt, bool ubwc); +int venus_helper_alloc_dpb_bufs(struct venus_inst *inst); +int venus_helper_free_dpb_bufs(struct venus_inst *inst); int venus_helper_power_enable(struct venus_core *core, u32 session_type, bool enable); #endif diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 9c98637e26f6..d53e487e3dfa 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -531,10 +531,16 @@ static int vdec_set_properties(struct venus_inst *inst) return 0; } +#define is_ubwc_fmt(fmt) (!!((fmt) & HFI_COLOR_FORMAT_UBWC_BASE)) + static int vdec_output_conf(struct venus_inst *inst) { struct venus_core *core = inst->core; struct hfi_enable en = { .enable = 1 }; + u32 width = inst->out_width; + u32 height = inst->out_height; + u32 out_fmt, out2_fmt; + bool ubwc = false; u32 ptype; int ret; @@ -553,6 +559,80 @@ static int vdec_output_conf(struct venus_inst *inst) return ret; } + /* Force searching UBWC formats for bigger then HD resolutions */ + if (width > 1920 && height > ALIGN(1080, 32)) + ubwc = true; + + /* For Venus v4 UBWC format is mandatory */ + if (IS_V4(core)) + ubwc = true; + + ret = venus_helper_get_out_fmts(inst, inst->fmt_cap->pixfmt, &out_fmt, + &out2_fmt, ubwc); + if (ret) + return ret; + + inst->output_buf_size = + venus_helper_get_framesz_raw(out_fmt, width, height); + inst->output2_buf_size = + venus_helper_get_framesz_raw(out2_fmt, width, height); + + if (is_ubwc_fmt(out_fmt)) { + inst->opb_buftype = HFI_BUFFER_OUTPUT2; + inst->opb_fmt = out2_fmt; + inst->dpb_buftype = HFI_BUFFER_OUTPUT; + inst->dpb_fmt = out_fmt; + } else if (is_ubwc_fmt(out2_fmt)) { + inst->opb_buftype = HFI_BUFFER_OUTPUT; + inst->opb_fmt = out_fmt; + inst->dpb_buftype = HFI_BUFFER_OUTPUT2; + inst->dpb_fmt = out2_fmt; + } else { + inst->opb_buftype = HFI_BUFFER_OUTPUT; + inst->opb_fmt = out_fmt; + inst->dpb_buftype = 0; + inst->dpb_fmt = 0; + } + + ret = venus_helper_set_raw_format(inst, inst->opb_fmt, + inst->opb_buftype); + if (ret) + return ret; + + if (inst->dpb_fmt) { + ret = venus_helper_set_multistream(inst, false, true); + if (ret) + return ret; + + ret = venus_helper_set_raw_format(inst, inst->dpb_fmt, + inst->dpb_buftype); + if (ret) + return ret; + + ret = venus_helper_set_output_resolution(inst, width, height, + HFI_BUFFER_OUTPUT2); + if (ret) + return ret; + } + + if (IS_V3(core) || IS_V4(core)) { + if (inst->output2_buf_size) { + ret = venus_helper_set_bufsize(inst, + inst->output2_buf_size, + HFI_BUFFER_OUTPUT2); + if (ret) + return ret; + } + + if (inst->output_buf_size) { + ret = venus_helper_set_bufsize(inst, + inst->output_buf_size, + HFI_BUFFER_OUTPUT); + if (ret) + return ret; + } + } + ret = venus_helper_set_dyn_bufmode(inst); if (ret) return ret; @@ -623,6 +703,8 @@ static int vdec_queue_setup(struct vb2_queue *q, int ret = 0; if (*num_planes) { + unsigned int output_buf_size = venus_helper_get_opb_size(inst); + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && *num_planes != inst->fmt_out->num_planes) return -EINVAL; @@ -636,7 +718,7 @@ static int vdec_queue_setup(struct vb2_queue *q, return -EINVAL; if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && - sizes[0] < inst->output_buf_size) + sizes[0] < output_buf_size) return -EINVAL; return 0; @@ -745,6 +827,10 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) if (ret) goto deinit_sess; + ret = venus_helper_alloc_dpb_bufs(inst); + if (ret) + goto deinit_sess; + ret = venus_helper_vb2_start_streaming(inst); if (ret) goto deinit_sess; @@ -796,9 +882,11 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, vbuf->field = V4L2_FIELD_NONE; if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + unsigned int opb_sz = venus_helper_get_opb_size(inst); + vb = &vbuf->vb2_buf; vb->planes[0].bytesused = - max_t(unsigned int, inst->output_buf_size, bytesused); + max_t(unsigned int, opb_sz, bytesused); vb->planes[0].data_offset = data_offset; vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; @@ -936,6 +1024,7 @@ static int vdec_open(struct file *file) if (!inst) return -ENOMEM; + INIT_LIST_HEAD(&inst->dpbbufs); INIT_LIST_HEAD(&inst->registeredbufs); INIT_LIST_HEAD(&inst->internalbufs); INIT_LIST_HEAD(&inst->list); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 6d4cc9e4bac2..5973bf1f8174 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1084,6 +1084,7 @@ static int venc_open(struct file *file) if (!inst) return -ENOMEM; + INIT_LIST_HEAD(&inst->dpbbufs); INIT_LIST_HEAD(&inst->registeredbufs); INIT_LIST_HEAD(&inst->internalbufs); INIT_LIST_HEAD(&inst->list); From patchwork Thu Jul 5 13:04:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141127 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1919433ljj; Thu, 5 Jul 2018 06:06:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5y54p3qM78fsVWaZK+9/8+DIAo2QKT0JR494wCBgteBGN05pM9/IXrTiC4rk1dGvPj4+Z X-Received: by 2002:a17:902:7009:: with SMTP id y9-v6mr6085686plk.217.1530795965083; Thu, 05 Jul 2018 06:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795965; cv=none; d=google.com; s=arc-20160816; b=CQue2UMLPBPSk1xWIvwTuQldXdg34gCM3SvIi4ol8UXkx925bteuTchx0tqZ+mjGLn 657iMqghDwGxzMVPNZB0XMoXMqf6GsXWYvyZY26fmT3dzUWPtO5f8QWfSpj2wuiSiOeg xeaa2ay18VHtoinjA8qhYEAB/5evy8s5j2GNxKRk8CdTgzkYSrSLDDy9yJwV9yoIUgYF gFMhXinCmqMLJuZI9QzN6CB49ieJA3QSpfTYkpcJI1e6WrD7x7d9SmS8PQH2nbJHxfS9 +sTh/6wzasC5Bvj3lcccm/chxm9q/4BRgBsy0R6UpUDxoIzAOqiDR5v75VwvyqZKnW3S lLBA== 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:dkim-signature:arc-authentication-results; bh=/ThhxevIU3epv9lgxlCyqJq5OSMzAnmUAMY3rX7cEds=; b=Io/09gDoT70vFPpgn/zYXwlreP8XgdhsI/K2w02870oORnLGmhitk3EGKUHlUS6XTG 2gjVgraHZKARKy3I1pXdS70BdXLet8MrUHiliSCE6+Hs5sWAiOpnBXPMwzBfdQvJXivH vlzzka9Vb3GvLADejeXMUQlFXrqH5YXSV6jxsoNeNf9i2anp8KYIDOLcJSH9iSSHe9dD BqJdv5vUHcESAmIyZdtz23U67sWGYBGKLZTex/UsMSqLmRljT5ydFIKS8oWUfjdxw7IW OqYgUXkHYeA+YkVHk1RwPOyjL0DzdQZ9SibEONfiUEioX4X6m5BQCmkyU6dNUG/i/OKD eNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jgqxqkXd; 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 b3-v6si5297885pgq.387.2018.07.05.06.06.04; Thu, 05 Jul 2018 06:06:05 -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=@linaro.org header.s=google header.b=jgqxqkXd; 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 S1754607AbeGENGE (ORCPT + 31 others); Thu, 5 Jul 2018 09:06:04 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43955 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754523AbeGENFh (ORCPT ); Thu, 5 Jul 2018 09:05:37 -0400 Received: by mail-wr1-f67.google.com with SMTP id b15-v6so1136256wrv.10 for ; Thu, 05 Jul 2018 06:05:36 -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; bh=/ThhxevIU3epv9lgxlCyqJq5OSMzAnmUAMY3rX7cEds=; b=jgqxqkXdJU6dIeNwID5AYkTWa0npGfEEiYElQwgS3tx/Siu9P0xX2mWthp3kJ+TvH+ y1h4slnHe1fFV2igclZa/RitP51INZB6d6u9GpQFPV8PdG7X0WivGEzILLCwWi2cDstu N8GKlqqS9IDw/cvCBuLGmL+hkDQJHtSLsdUhM= 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; bh=/ThhxevIU3epv9lgxlCyqJq5OSMzAnmUAMY3rX7cEds=; b=G3INeTgs4a2CL20VYcCFbKbOZEu5uTAHCCeSkwSElISSCXVVKcylgrUpALFwA6PTrv aoWIto42WDRdYqQ+agaUVYCHIHmZQFaUum3wM5upYX4qjURzuZanUQfHkGHnX98AT4GO DblfgyuplSTrCOcpC62RyHbYqTq8mYIYrTBppIt6nzxLIAZdyNfmk6xsfIi3OiyubBu+ s1oFRwXIQvfDn0aL+wdzQeyFRX4MHqRwolY1JcCt56W8EcjcnO6eKOD63rgz8JImg9ws WPxDq7jJI0WVQGSLBwzXrkvKSzUqVhrwsifroaUSbRvbn8k1kHoWm0+WgBEr9NEXR6iZ dYWA== X-Gm-Message-State: APt69E2dNrIO52V0qwuY6l2g+JgBdMyef2MHFr8ZxvcbVmtPEFUKChWO QBhzBd7R2YB+YdwbgVdeTm3j+Q== X-Received: by 2002:adf:874b:: with SMTP id 11-v6mr4227776wrz.117.1530795935999; Thu, 05 Jul 2018 06:05:35 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:35 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 26/27] venus: core: add sdm845 DT compatible and resource data Date: Thu, 5 Jul 2018 16:04:00 +0300 Message-Id: <20180705130401.24315-27-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds sdm845 DT compatible string with it's resource data table. Signed-off-by: Stanimir Varbanov Reviewed-by: Rob Herring --- .../devicetree/bindings/media/qcom,venus.txt | 1 + drivers/media/platform/qcom/venus/core.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) -- 2.14.1 diff --git a/Documentation/devicetree/bindings/media/qcom,venus.txt b/Documentation/devicetree/bindings/media/qcom,venus.txt index 2693449daf73..00d0d1bf7647 100644 --- a/Documentation/devicetree/bindings/media/qcom,venus.txt +++ b/Documentation/devicetree/bindings/media/qcom,venus.txt @@ -6,6 +6,7 @@ Definition: Value should contain one of: - "qcom,msm8916-venus" - "qcom,msm8996-venus" + - "qcom,sdm845-venus" - reg: Usage: required Value type: diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 381bfdd688db..bb6add9d340e 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -450,9 +450,31 @@ static const struct venus_resources msm8996_res = { .fwname = "qcom/venus-4.2/venus.mdt", }; +static const struct freq_tbl sdm845_freq_table[] = { + { 1944000, 380000000 }, /* 4k UHD @ 60 */ + { 972000, 320000000 }, /* 4k UHD @ 30 */ + { 489600, 200000000 }, /* 1080p @ 60 */ + { 244800, 100000000 }, /* 1080p @ 30 */ +}; + +static const struct venus_resources sdm845_res = { + .freq_tbl = sdm845_freq_table, + .freq_tbl_size = ARRAY_SIZE(sdm845_freq_table), + .clks = {"core", "iface", "bus" }, + .clks_num = 3, + .max_load = 2563200, + .hfi_version = HFI_VERSION_4XX, + .vmem_id = VIDC_RESOURCE_NONE, + .vmem_size = 0, + .vmem_addr = 0, + .dma_mask = 0xe0000000 - 1, + .fwname = "qcom/venus-5.2/venus.mdt", +}; + static const struct of_device_id venus_dt_match[] = { { .compatible = "qcom,msm8916-venus", .data = &msm8916_res, }, { .compatible = "qcom,msm8996-venus", .data = &msm8996_res, }, + { .compatible = "qcom,sdm845-venus", .data = &sdm845_res, }, { } }; MODULE_DEVICE_TABLE(of, venus_dt_match); From patchwork Thu Jul 5 13:04:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 141126 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1919095ljj; Thu, 5 Jul 2018 06:05:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfA89HO6RBzYJVaDkPvcUd/3Ff0uTda/eg6XOiqwJAWbx8gPO1oppHWsS3PrAxIELJJkMFR X-Received: by 2002:a63:342:: with SMTP id 63-v6mr5428518pgd.290.1530795947653; Thu, 05 Jul 2018 06:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530795947; cv=none; d=google.com; s=arc-20160816; b=D9Vi8q6o8LNB8pAWldEvJSl1kSI/PJNlXaa4vDfxMHLhWYeGEzXJdlsHUXRvtVbzb5 r3xCzVZxsUsaDBpNoAb/VaNDIGwxjBS5bHA7UwlFcAno7OWjBtAeuk5fxmZAcxECHRIa KdGJ6fJm+8lR9xYxjx9z8N6JwPkc4R0P3grtM7Sfi/vhfJ8+bcybLIel1SJsDgjOLKk2 7SaVo9N36PEbUsJLQmEoK7Hma26oeJrtLxSf+yEBFv8F1OHgkcEtnA/P/54PxGMnkn3s i1AAn6jyUPCcV2n4AVKX1esXq3PhnU7qtm/izF2RKh1EihIIQAiqW2MxPVsWMEvYPbkl TXlg== 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:dkim-signature:arc-authentication-results; bh=ydLhI+nILE8mOHyuZRipV0saHGZ9x1tIp4DKcQUt51Q=; b=Xokq2rKx7fJNY64vPeJsB6BGYbIFgEqBLGh9mPdu/z3RuV4oDG51FmU6miG+pdKWNU HV9oo4V5+rpu83VsUoLc/WHp3hUboUisVvWt5duX3uJqnNW6crHP7jKZyufaxn/NVl3S o3+be1UWcHVAk0PPFUCeN1uSjetPp1hNKtWXkEjOTnC6pRl+EfxZrTcovS1y6uGt0uWb IZdFMRpWikbeA9zvw8ZNCRBPkryQfgpXowGa4pcaJKKjd9M81vWu4FcgcEaL118LCLsn wX8owWG2/DyOpPGQAcIDeI+baktBVUe2ClLuQu7md6f2fhYMRV8rmueWGaqv061pEvuc qwHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LgUhGluh; 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 a72-v6si5711148pge.497.2018.07.05.06.05.47; Thu, 05 Jul 2018 06:05:47 -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=@linaro.org header.s=google header.b=LgUhGluh; 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 S1754581AbeGENFp (ORCPT + 31 others); Thu, 5 Jul 2018 09:05:45 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:53792 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754549AbeGENFi (ORCPT ); Thu, 5 Jul 2018 09:05:38 -0400 Received: by mail-wm0-f54.google.com with SMTP id b188-v6so11033403wme.3 for ; Thu, 05 Jul 2018 06:05:37 -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; bh=ydLhI+nILE8mOHyuZRipV0saHGZ9x1tIp4DKcQUt51Q=; b=LgUhGluh6FJY67inoyBmTVUiOoV93QPR72mPK4abcWbyMBwl39Wf64WwyvIIysqP6/ Ofb2zfIMoGYaOQBNxdwrP0UF88iWguY8f1lTBNvUYpTOs1GUrF8WquoF3WGiWroArEvx M/y5LcS5okB0i9lBWba3IyoMuS8zzFz2ZYOQk= 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; bh=ydLhI+nILE8mOHyuZRipV0saHGZ9x1tIp4DKcQUt51Q=; b=WNpJlejbV4c1r39VR6QjtSEX82En2Mv1PjuVwA0mRw9r3hOTjzcmb79+P61ZYdL3sN eEp5jCCwMlN/Q4ew0mlY0buPIooz11GEzp1PLKwYew/D1tWcXWM9Q8lqKSS3Or2+JUhN iMa7aNz+XRHR0f12JCkcw28YW0WqGsKMqGKn82HYhzndRRGAYwkZc+TroBVFKVRfkj+h cpCIYTsjJ8/yXS7EP4WLSh8f6pBKTPRstLK+Lw9lmlOR/2o6EhfwD0MGRgtq4BdgqB9f 5kikWS0+A2Pn0SeKdMdp3CHAERGnSbRYaWQG+AXX4U31IrRotNhz/moO6Uz3NBt3GofX HgHg== X-Gm-Message-State: APt69E0tbWoClHGyBZznFfkFF0Pp0GgAXpm+0XvDN6EUnhpVCE2acPpt eDIEVU2SuSVKG/leSZB8d09MDA== X-Received: by 2002:a1c:ac03:: with SMTP id v3-v6mr3963734wme.100.1530795937180; Thu, 05 Jul 2018 06:05:37 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 11-v6sm2109102wrw.67.2018.07.05.06.05.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 06:05:36 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vikash Garodia , Tomasz Figa , Alexandre Courbot , Stanimir Varbanov Subject: [PATCH v5 27/27] venus: add HEVC codec support Date: Thu, 5 Jul 2018 16:04:01 +0300 Message-Id: <20180705130401.24315-28-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180705130401.24315-1-stanimir.varbanov@linaro.org> References: <20180705130401.24315-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This add HEVC codec support for venus versions 3xx and 4xx. Signed-off-by: Stanimir Varbanov Reviewed-by: Tomasz Figa --- drivers/media/platform/qcom/venus/core.h | 2 ++ drivers/media/platform/qcom/venus/helpers.c | 3 ++ drivers/media/platform/qcom/venus/hfi.c | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 4 +++ drivers/media/platform/qcom/venus/venc.c | 49 +++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 8cc49f30a363..2f02365f4818 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -190,10 +190,12 @@ struct venc_controls { u32 mpeg4; u32 h264; u32 vpx; + u32 hevc; } profile; struct { u32 mpeg4; u32 h264; + u32 hevc; } level; }; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index cea5b506dd51..cd3b96e6f24b 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -71,6 +71,9 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt) case V4L2_PIX_FMT_XVID: codec = HFI_VIDEO_CODEC_DIVX; break; + case V4L2_PIX_FMT_HEVC: + codec = HFI_VIDEO_CODEC_HEVC; + break; default: return false; } diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 94ca27b0bb99..24207829982f 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -49,6 +49,8 @@ static u32 to_codec_type(u32 pixfmt) return HFI_VIDEO_CODEC_VP9; case V4L2_PIX_FMT_XVID: return HFI_VIDEO_CODEC_DIVX; + case V4L2_PIX_FMT_HEVC: + return HFI_VIDEO_CODEC_HEVC; default: return 0; } diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index d53e487e3dfa..eeaf99380e3e 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -77,6 +77,10 @@ static const struct venus_format vdec_formats[] = { .pixfmt = V4L2_PIX_FMT_XVID, .num_planes = 1, .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_HEVC, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, }, }; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 5973bf1f8174..67e895965c93 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -59,6 +59,10 @@ static const struct venus_format venc_formats[] = { .pixfmt = V4L2_PIX_FMT_VP8, .num_planes = 1, .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_HEVC, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, }, }; @@ -220,6 +224,46 @@ static int venc_v4l2_to_hfi(int id, int value) case V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY: return HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY; } + case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE: + switch (value) { + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN: + default: + return HFI_HEVC_PROFILE_MAIN; + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE: + return HFI_HEVC_PROFILE_MAIN_STILL_PIC; + case V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10: + return HFI_HEVC_PROFILE_MAIN10; + } + case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL: + switch (value) { + case V4L2_MPEG_VIDEO_HEVC_LEVEL_1: + default: + return HFI_HEVC_LEVEL_1; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_2: + return HFI_HEVC_LEVEL_2; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1: + return HFI_HEVC_LEVEL_21; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_3: + return HFI_HEVC_LEVEL_3; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1: + return HFI_HEVC_LEVEL_31; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_4: + return HFI_HEVC_LEVEL_4; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1: + return HFI_HEVC_LEVEL_41; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_5: + return HFI_HEVC_LEVEL_5; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1: + return HFI_HEVC_LEVEL_51; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2: + return HFI_HEVC_LEVEL_52; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_6: + return HFI_HEVC_LEVEL_6; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1: + return HFI_HEVC_LEVEL_61; + case V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2: + return HFI_HEVC_LEVEL_62; + } } return 0; @@ -744,6 +788,11 @@ static int venc_set_properties(struct venus_inst *inst) } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H263) { profile = 0; level = 0; + } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { + profile = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_HEVC_PROFILE, + ctr->profile.hevc); + level = venc_v4l2_to_hfi(V4L2_CID_MPEG_VIDEO_HEVC_LEVEL, + ctr->level.hevc); } ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT;