From patchwork Tue Apr 24 12:44:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134078 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2190147lji; Tue, 24 Apr 2018 05:45:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+6xnmYd1/1R1S29sk8V7cUxLHNywsatA0IdxfKKuhIyS4/YxtdUF9inX/0gPhUjlibOwLi X-Received: by 10.99.117.71 with SMTP id f7mr11150719pgn.204.1524573914934; Tue, 24 Apr 2018 05:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524573914; cv=none; d=google.com; s=arc-20160816; b=shJ2Knw/w6VxUh4SGqIUw/WryKnHFSUa3Uc7B51Cv/Rtqfpwi+zBsb0+ws6VkFxov0 z4W6adfDw58QgaZHYQHBi65yJx1CaFclRSetVHbDiIAcTjCUprajpU8j1CqD17B77vpQ vfKSPIL2ea05xvgixYDo2k4sEmTTuPh0NXJ8pcpqBhbyOxh22RQazHPpbtQ7yFXkYzv6 +SxL30WhmbohZAzG72FymmlZdZ5XSR8Y7lh4Wsi7y93E6eijLq4y80yA16yMxqCzlqP8 XGSlN5XBO0Rbx5xllyHXGPu991BOFU/An+AzZd2adfUmPkjbZsVAnfpvje8ROU6e2sB9 N7MA== 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=qq5mFuZJ4Yav2DH45SOsMSanfFXAE44rr7On7fvNHsQ=; b=SKn3Q/IKxToxxXzYxcCyERVw0KFb9I4nRT5+33S0+7WTMsXs4ibfH0gFPxieVFoyRL ChzXNuz9tTlUgdl2Eydm5QLqSE+Pew8+wXdgKI7SguYvg1sAzCUOyHPy6CP4Lf6v3tps lSNflqetWOQd1ZDDNOUH9wnOR3iU1/WuP0+cZGWjtC8Tq48KLSmh68N1djZWzm/6mYm6 Bq5rX/xbhtjDTq/7iISVFz/ePiB/mAOgAPpztdldENkuSgvqzT4Ed5yOPY6v96GqBw0s Iv4mp+D/L4wcsh0JUPrAuGZ6aThkx9CTnqvdK+VeB7eKsMx7ewtCAV9CtJVT40DSFhge xaZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GtSe2znh; 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-v6si1574380pli.0.2018.04.24.05.45.14; Tue, 24 Apr 2018 05:45:14 -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=GtSe2znh; 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 S932588AbeDXMpM (ORCPT + 29 others); Tue, 24 Apr 2018 08:45:12 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35538 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757842AbeDXMpF (ORCPT ); Tue, 24 Apr 2018 08:45:05 -0400 Received: by mail-wm0-f67.google.com with SMTP id o78so609969wmg.0 for ; Tue, 24 Apr 2018 05:45:05 -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=qq5mFuZJ4Yav2DH45SOsMSanfFXAE44rr7On7fvNHsQ=; b=GtSe2znhZup4VKqdR2MHI8Euijtl/+vk/K/4jjoFrYOeM1FJNFZjamTDuYxUpYtBUR HQ86B0ieOwu7r+iMBFqxNTSan9tCjgrRFBTApGFQ7MmyGGqFPAWKZUvOiK/+wQW3M7/K PteVjE6XgZfot8cjWvvqoJ3D07cEIBRAGoQV4= 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=qq5mFuZJ4Yav2DH45SOsMSanfFXAE44rr7On7fvNHsQ=; b=nN0YwY03YFycJS0KFc8cO3KKfaIxlrhxsXWi0PPuVCsWFnN6I0yd3A+SbEXEipWcKe pEL2p2UnnZUgBJBaXVjYulFV8jnGBAiBR39S21FQn5eoVeCg4pGnC7sWr2kQ8jkmXBoe KbH8roQJGvpC0hTT8158SJaZUa7s8w2MNV345r3Tso1H7Bs/m+4j0lPmy8je92bgburQ sfpeO0G3xBSZ4FlCB4oCWY3ohfhm2HOmCeVSqdg+aQ4ktCiCd9qPv2BICxcylifPTVxC XtKT0XC2l56geLocTJ7IzAp8utdplkA8/JJckrqaDgPOV0HZNK/7N9ohQqBFFIhM1owh fx/w== X-Gm-Message-State: ALQs6tCHErl0fOll38f4ewgZPj2FpkPe/pBaZKO3KqgKUds3fN9jm68x 3JE+P0yky9rM/vtpvxBhAWBolA== X-Received: by 10.28.182.70 with SMTP id g67mr12585074wmf.88.1524573904050; Tue, 24 Apr 2018 05:45:04 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:03 -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 , Stanimir Varbanov Subject: [PATCH 01/28] venus: hfi_msgs: correct pointer increment Date: Tue, 24 Apr 2018 15:44:09 +0300 Message-Id: <20180424124436.26955-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 --- 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 Tue Apr 24 12:44:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134105 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2201470lji; Tue, 24 Apr 2018 05:56:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqDWPmWuReRfTQveawACMM9o0pii3PSU9xgHUgey+piTMOW+uQhBM9xbWkeg4jwqTiTx81D X-Received: by 2002:a17:902:9688:: with SMTP id n8-v6mr872635plp.366.1524574584882; Tue, 24 Apr 2018 05:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574584; cv=none; d=google.com; s=arc-20160816; b=Ohh7i1Y7IM1N5PbjdBrwfNDeYI45F1vu0JyYHzhWq2Hrn6/QA/KFG0eAX3QV842SvD FCKLIdKlaHGsC9lBqdHDeVPldVUaJQfS7PszKhi9WtWYca+LVaqViLfyjZBQX6VE/exp WbpsNg8ORvqKKujNNbZoGvqW0GYCoZMfjEiSY8dk3zEb/WVUURTUsKk9NoJMj9tI9DiN VmGKgpPXJiFM7CY9Qo3Pi3pyE1QqPb77p/TxcHht1CYNxXQh66JMkfxHlfAE6s1tg5Mr WTNZoynFgbP5jbGBdJlFW1FgLAsKmjDsK1wL08Pv8Kl9mpg25bn4Wypcne7UCb1ESFLD ryxw== 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=VfCYxQLMAq/EqeOKzJDOjJif0LMyIYIiIdWQCn1RamU=; b=Z0YcG3AYvvAFErw9BSZrJ+TU5xUb1x/rUMfiCxXhuxt7NS+HXfkbcyNU8nWBLKSOXT y1V3YH+SN+XREJ31R67W5LaKsOqbUIA/4hpJD5jxTDiB68N+CPLk+o6Uns2ixdL350rE 3gEMUvBLKyHgf+PWhboVcdPf3SwjnHf5LDkqMa1O7DQ2mxCgWsB5VPCC03NBm2IL8gYB Y6lUmN6zNJpbB8tSW0NbUYVF1tiP+Xhmmf49IFnDYeDVYnVxju1634pkHvvXpXDrQlxU MKllr4cs3CT4IJuauIKQdPJFU/7M71D0kvTdXh5ngL4YeY+OzScyI3d8/ofZvuy2W/6H L3aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBe2hvRa; 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 i35-v6si13165383plg.504.2018.04.24.05.56.24; Tue, 24 Apr 2018 05:56:24 -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=WBe2hvRa; 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 S933326AbeDXM4U (ORCPT + 29 others); Tue, 24 Apr 2018 08:56:20 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34154 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757787AbeDXMpI (ORCPT ); Tue, 24 Apr 2018 08:45:08 -0400 Received: by mail-wm0-f66.google.com with SMTP id w2so390664wmw.1 for ; Tue, 24 Apr 2018 05:45: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=VfCYxQLMAq/EqeOKzJDOjJif0LMyIYIiIdWQCn1RamU=; b=WBe2hvRayGP4eUuMmnkxSm3uCzY+sAggaCdCzMlgFjOqXcjbnPfISlxEE8T4yOk4MQ 0sTMKIMUsSDgM1PVe9j4kn14Ae+WPxWfR+85gsfGbEW8ppVxnMANG5iyhZwvpxeXKlC0 zTJVJomZLKGKFrJgSBw4cTRoxwSVJK+jU/GMY= 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=VfCYxQLMAq/EqeOKzJDOjJif0LMyIYIiIdWQCn1RamU=; b=HJilTZa/4xpkClb4vsiPmY1tiEFZjWszkws82dWUXVeafkS//sRM0Qzff0+J0pzDEx v+DBTkRzINh9Vz38PNIxZkJlGBigVvEQqNr1OkSyqEb5QoOfdRacb/7l14DONvZB/wKf osG443kIIJJmQ4RJJAq9GHCVCrQBQ0xKKcIyTcTwz9OPFbq/RMQEoLsYPO1FT0hCeIFi EM47/nnHeJLnCT73XpuEFj9e6XpNo9X2pnzHLaVLo09pD1XpbSNV06WnUdY0eiDl/WNM gP3FNjbpMxiHZq6FM/kMviDjpVHlX8gV84Jh0f6z1HrV3s/5WAr3jtz7JEZjdGLF9qnu ByAA== X-Gm-Message-State: ALQs6tCe5EYIiyR7BfrNbc35YuwqJeZqUmAGMFXDwDEOgtmtoTDC5UHf ep8QIa+up9wDjUZqCdeo/waI1A== X-Received: by 10.28.111.71 with SMTP id k68mr11441236wmc.35.1524573906947; Tue, 24 Apr 2018 05:45:06 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 02/28] venus: hfi: preparation to support venus 4xx Date: Tue, 24 Apr 2018 15:44:10 +0300 Message-Id: <20180424124436.26955-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 | 37 +++++++---- drivers/media/platform/qcom/venus/hfi_helper.h | 84 ++++++++++++++++++++++-- drivers/media/platform/qcom/venus/hfi_venus_io.h | 24 +++++++ drivers/media/platform/qcom/venus/vdec.c | 5 +- drivers/media/platform/qcom/venus/venc.c | 5 +- 6 files changed, 137 insertions(+), 22 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..d9065cc8a7d3 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -166,21 +166,37 @@ 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; + size_t arr_sz; + size_t 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); + else + arr_sz = ARRAY_SIZE(intbuf_types_1xx); + + for (i = 0; i < arr_sz; i++) { + ret = intbufs_set_buffer(inst, + IS_V4(inst->core) ? intbuf_types_4xx[i] : + intbuf_types_1xx[i]); if (ret) goto error; } @@ -257,12 +273,11 @@ 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(clk, freq); + + if (IS_V3(core) || IS_V4(core)) { ret |= clk_set_rate(core->core0_clk, freq); ret |= clk_set_rate(core->core1_clk, freq); - } else { - ret = clk_set_rate(clk, freq); } if (ret) { diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 55d8eb21403a..1bc5aab1ce6b 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,12 +779,56 @@ 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; u32 time_scale; }; +struct hfi_bit_depth { + u32 buffer_type; + u32 bit_depth; +}; + +struct hfi_picture_type { + u32 is_sync_frame; + u32 picture_type; +}; + +struct hfi_pic_struct { + u32 progressive_only; +}; + +struct hfi_colour_space { + u32 colour_space; +}; + +struct hfi_extradata_input_crop { + u32 size; + u32 version; + u32 port_index; + u32 left; + u32 top; + u32 width; + u32 height; +}; + #define HFI_COLOR_FORMAT_MONOCHROME 0x01 #define HFI_COLOR_FORMAT_NV12 0x02 #define HFI_COLOR_FORMAT_NV21 0x03 @@ -961,6 +1017,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 +1033,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..76f47936d0fa 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus_io.h +++ b/drivers/media/platform/qcom/venus/hfi_venus_io.h @@ -110,4 +110,28 @@ #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) + +/* vcodec noc error log registers */ +#define VCODEC_CORE0_VIDEO_NOC_BASE_OFFS 0x4000 +#define VCODEC_CORE1_VIDEO_NOC_BASE_OFFS 0xc000 +#define VCODEC_COREX_VIDEO_NOC_ERR_SWID_LOW_OFFS 0x500 +#define VCODEC_COREX_VIDEO_NOC_ERR_SWID_HIGH_OFFS 0x504 +#define VCODEC_COREX_VIDEO_NOC_ERR_MAINCTL_LOW_OFFS 0x508 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRVLD_LOW_OFFS 0x510 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRCLR_LOW_OFFS 0x518 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_LOW_OFFS 0x520 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG0_HIGH_OFFS 0x524 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_LOW_OFFS 0x528 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG1_HIGH_OFFS 0x52c +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_LOW_OFFS 0x530 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG2_HIGH_OFFS 0x534 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_LOW_OFFS 0x538 +#define VCODEC_COREX_VIDEO_NOC_ERR_ERRLOG3_HIGH_OFFS 0x53c + #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 Tue Apr 24 12:44:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134080 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2190463lji; Tue, 24 Apr 2018 05:45:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+rwEWyhpYYBd2zTp1CxtjEAr5TyTflY+8djQqxDONh5dis5+bO55SqyCC57LUTO8OFeTj0 X-Received: by 10.101.100.75 with SMTP id s11mr20049851pgv.360.1524573932674; Tue, 24 Apr 2018 05:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524573932; cv=none; d=google.com; s=arc-20160816; b=k1CXAnFwFx9+SykZyH+r9qBkZbaCtwa4S4/3hUMxrq+0AM1DYYj0i3J4L27Ow//hIA KOTw4NCbjrcDiDJwsHUcEuyyPHIbojWBSIdMTkHtGpCWeh5iP7rxUh/Pj/MrQIodBwdV j7wbKFWNE7NIQFceNpzlFTzZSLiTkibNBrW5+GfSKKiONW9KtMwQQIE/dQnrrvUzAJmR zPR5clOxG7UfHDdXh490zfiCgXql2bEWFulg7W/SBRcCtC+Rx87ca8PrQgeBnRbeFN4K gsayQQcSJIlalnzvW4JPVy2MrJ9zr4pcgkN0Et+s3wMXRGQw3lQZL7/AVWc4+rjSap5h RkLQ== 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=1Wl88e8hLVwkRwSqVzoF/pW4BWPgDsxkJpBzUcyKn74=; b=buVcvCNexFlO5J50DuLnBoba/Vv5QazqmaIWLUrj56l8ITSOSORFAWHmdCUFYFuXhA 3GOue43tgf1eDPD9JIzZMApZdH7V9gmeOqTCzTu4iCfL9eKi2MeAuTo/WWoB9tt2e4d3 t6wRXfrqy16/a69KH3gY6aEsmp6SC0yw8WAbtjBVpSufrgy8ZgQ2WntkCjOElmKCiAh7 vdUwchGpDB5MkZldPHaCLr+hT8/W8y6jK93bx38rlUMsi1qKU+q3HsVvccfZ9RV7jdBX srcul0lUAfGyqp5DR/lh9vqey0z1pu9ko3DxguJw7bRoc5rNAyEmAn9JNqR0M12mzySY RYtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xcc0Cj9l; 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 c18si13459818pfe.36.2018.04.24.05.45.32; Tue, 24 Apr 2018 05:45: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=Xcc0Cj9l; 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 S933012AbeDXMp0 (ORCPT + 29 others); Tue, 24 Apr 2018 08:45:26 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36557 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757799AbeDXMpN (ORCPT ); Tue, 24 Apr 2018 08:45:13 -0400 Received: by mail-wr0-f193.google.com with SMTP id u18-v6so22544103wrg.3 for ; Tue, 24 Apr 2018 05:45:13 -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=1Wl88e8hLVwkRwSqVzoF/pW4BWPgDsxkJpBzUcyKn74=; b=Xcc0Cj9lcKkzxiIK4ppagDJTRfue5443wec50nCBdw1vXObPadKcuViYYWy65NDd3Y NKUFv6kCwaz1xw6fXpNqNaEgeWeTPiJiGYSr26lJNIPh1hjXIBPg2qfX83QS3pW+CMZf 6dDHmVDLt1gx/QG5TQJubllf5J6CnwWWVJ6Oc= 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=1Wl88e8hLVwkRwSqVzoF/pW4BWPgDsxkJpBzUcyKn74=; b=KUvoQW8V/xrQczwoe+3S2VQ63PP/eRIhwdUfi4F1oiMhnxNLv5ElJa8JjgQFvs0l2K 8KxfAejQueUz7xfxdd0pHIIeO+1YilIMXtz+1swkxC2eVjUvxfyfnk7rEBlLhyJptXok M6CtCj3SHnjbadRiFiNwXhg03UxAggPFCadwdKwuLxgQxmWEx4szDFQFirrleX+qipgN PqO9HOgScmoF9Ad65fhdbFyesf+vdDbtIaRwFMl1qmMYHZ9qwgydrn34I+A9ozYJXD53 1+63hYaNx+Zp6SdCyg11aOtss5nVmrlgXhL2SzgCZgRNaal7KABvRLIZ/611HxVSJNyM sm0w== X-Gm-Message-State: ALQs6tCB5TiAJ1HODzvj3ecDecDieb1YO4wotb7cMOUQ3YuhoLWZDSVT wYLa6cV8qy5fcPmX0MfwBi+o1w== X-Received: by 2002:adf:b8cf:: with SMTP id c15-v6mr21171211wrg.122.1524573912676; Tue, 24 Apr 2018 05:45:12 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:12 -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 , Stanimir Varbanov Subject: [PATCH 05/28] venus: hfi: support session continue for 4xx version Date: Tue, 24 Apr 2018 15:44:13 +0300 Message-Id: <20180424124436.26955-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 --- 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 Tue Apr 24 12:44:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134103 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2199993lji; Tue, 24 Apr 2018 05:54:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+arHzsC/O9VSX9+TNAnWTbHUcOqW+7DKA7hrIaFDOUzX1JlV3Y/wZb24EO/pCJlW1WBueE X-Received: by 10.98.35.11 with SMTP id j11mr14387596pfj.177.1524574493848; Tue, 24 Apr 2018 05:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574493; cv=none; d=google.com; s=arc-20160816; b=BXsbc2yJajNB8CLMUUXCSJNcSXhvPa1cNR7oC6PyhRtfu3mTR9KgkaddDepWBUE3Kr iQMfjj4VbCV/CQ5egzG7egtCZe2+ApwiKm54P5EBQv5R9pojX3mXYrJ7VHiIBKolDE+8 4lVx08SWdBKOBSH7d92CDp0X52fMbYIhACtSS04Opm0aW3CH0qTuF9cXGtGpWHF4scLs BUmww+MaDtMFMX2qaUQpmkLaY15FX9wSyQUAl0JKTbrcVBlWDcdQzWIXqlf2zzk3ety+ ivsnxMtj0PQ4pfs6WzQAWuLR0pd+UPSMjQ9TZ8oo27Gz/jCSOH62ewZtfZe6Iqn9topz tnHw== 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=UJY1ElvCAePNUPkqjsGk3ZluUk9SleoeEVToFWcXc0U=; b=YjSRCTmZihQyCbzzsS57FEIX4uyVeLd3hYk6OnhIJTtUkDewRzvoL/QSZ/8HUbhmcu 8rwRTWtfhc1uoneJ9Rs5ZPCXvxlFjhLL0R9jxB/45+6ZSWv5cCiY4c+nBxkzYYyvbNdH Ku5dt7JncgCkiTqhjE53KkU9Rh8xwgahFhGgIz1oXdmLqfHO+KwBPRKY9OtMZbma94NO HRJW0PtpsyIR7FE764b/MmxvpBISPk4mslwWDgXHw72VmSZVTwOR7wq3WcMb6TcjiZNA fceBmRVBJ5/c7ECws6uWLxk79jwyiyM+UhXSZDZNDCruzaiUMKxfeYq4qyDulXGzwKhh DLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PL1i9Vqw; 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 x124si11859917pgb.651.2018.04.24.05.54.53; Tue, 24 Apr 2018 05:54: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=PL1i9Vqw; 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 S1757801AbeDXMyu (ORCPT + 29 others); Tue, 24 Apr 2018 08:54:50 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37416 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757813AbeDXMpP (ORCPT ); Tue, 24 Apr 2018 08:45:15 -0400 Received: by mail-wr0-f196.google.com with SMTP id c14-v6so9689134wrd.4 for ; Tue, 24 Apr 2018 05:45:14 -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=UJY1ElvCAePNUPkqjsGk3ZluUk9SleoeEVToFWcXc0U=; b=PL1i9Vqww/nxWSnJ7GKIIelU3Sb421JXQHWPaXnETRFKX/Yip4DsUZsDqVLzvGVe5c CZYO+DGbCPIzS4gSsdfKZyc0lZipXceLgPtlsYerPmlfj3UKMnbX+XbE+SWQ7Ib3spHe Jhvvtfk/dYKICDENhdvXVLeDcOcwHKA0gyZFc= 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=UJY1ElvCAePNUPkqjsGk3ZluUk9SleoeEVToFWcXc0U=; b=TZA0e9o4Q8gjKRHgg9ah8+xPhtrPY50hFb5uSG28EfL7UMS2Mmpg+79BDejS0cfmy0 hKM8lK3Xm4l5lVRoHhtv6Nx+1CRnL82x7rjuy96uNuQRH+M6Yp4v3I5Llx0c+FTr1nTk KRfLaeNwNkbL4C3Z+0M17lXBBWwVdIny4mcd3QN2wtHNvXSAty8LAo18UJxKH5ejNnhm C58ZR6D/a0vXOTX6UK8Etz+Ydz04R4Em2W7a1zfkKScI0LgvZR2nKWmRwCwlOFqdYJod kAznhLj1v2NYJJgtl6FJ2K1fxWGqkhuPT+HRCkOk/y82qF7N3njLIr6lxS+Do8f5PyQP HnUA== X-Gm-Message-State: ALQs6tA4oTJJA3fELC1IuMpJE17y477JtsFlmIigG29dkjl7wksspm9w XV72jfnvQsq5ygo5x7vhgRmh+w== X-Received: by 2002:adf:dbc6:: with SMTP id e6-v6mr21542147wrj.212.1524573913665; Tue, 24 Apr 2018 05:45:13 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:13 -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 , Stanimir Varbanov Subject: [PATCH 06/28] venus: hfi: handle buffer output2 type as well Date: Tue, 24 Apr 2018 15:44:14 +0300 Message-Id: <20180424124436.26955-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 handling of buffers of type OUTPUT2 which is needed to support Venus 4xx version. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi.c | 3 ++- drivers/media/platform/qcom/venus/hfi_msgs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index cbc6fad05e47..a570fdad0de0 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -473,7 +473,8 @@ int hfi_session_process_buf(struct venus_inst *inst, struct hfi_frame_data *fd) if (fd->buffer_type == HFI_BUFFER_INPUT) return ops->session_etb(inst, fd); - else if (fd->buffer_type == HFI_BUFFER_OUTPUT) + else if (fd->buffer_type == HFI_BUFFER_OUTPUT || + fd->buffer_type == HFI_BUFFER_OUTPUT2) return ops->session_ftb(inst, fd); return -EINVAL; diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index 5970e9b1716b..023802e62833 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -825,7 +825,8 @@ static void hfi_session_ftb_done(struct venus_core *core, error = HFI_ERR_SESSION_INVALID_PARAMETER; } - if (buffer_type != HFI_BUFFER_OUTPUT) + if (buffer_type != HFI_BUFFER_OUTPUT && + buffer_type != HFI_BUFFER_OUTPUT2) goto done; if (hfi_flags & HFI_BUFFERFLAG_EOS) From patchwork Tue Apr 24 12:44:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134101 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2199851lji; Tue, 24 Apr 2018 05:54:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZopnnnF6g3oUuL5J/n+lE9F/nBaom1JQuXYl37ewh2//t3VkGQlqey/MIHG+wB93UyBDkuq X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr364400pld.104.1524574486323; Tue, 24 Apr 2018 05:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574486; cv=none; d=google.com; s=arc-20160816; b=D1Cd1eRgQC0PZFFbS1mvGlW9CNcC4b4ZwGP1/3Ur/e6FnZBS6XO72Qw3Zhf6K8rN0N RyJHu43nub2xLVCKbcOphZX4AfwTLVbyYprycHvEscW0cCQrGKSVROIlxsIDE42+b216 9wknm9cihVBIGGExasWHQOKKzyVmVZ/Gw+RiKNFQDDMKizTM5dVy9U9mQp8y50bvF2BB z4zLvAUEPHw+jLT9TJao6qq4ci7XIOP7tDiq/iXPluXe9w3leJO7ClVOyQKYlw1i/l6w Y58KkKVFlz0y5a+DTO1+pp8QWJWoXHHDFe0DUZMyzBlCCEIpNYvI5WjdWk5pHUpAbOE2 QwvQ== 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=zuQ1SjEcsKyg6eckkbc65vVKHJNFHgpP18aBxBMCet0=; b=f7yDqBeSHJEzcRxduEO+5lhuJzJI036MDpdH2NPvmrdgwo3qikdKUnF0E/k0iKcsbf pv7zihEYEStVRoqUYS1PNoaHBtAcGKDpFSsHWqQiCrrk0sytVE5Rpvp+e2uKYcGvYv4Y S7TONwCAgCMhyfxkeZX/opovSuTkAx1IaekeHbmYMTrDzD9gZ5EHjIZLrlnHeBVMwH7n qIh3FrGAD/y9iijmah0ixzqi6MThUfxYNNbtZ6jbPV54bA4b0OVdfUcXVoV+g/R3ubqX /Ezo/xXFgKHtE/JRC/Tjb4ODYrtDy8KqGUkFaDI4OJHD4nNWMV64ev7hpIIW8DJ3y33H ZbXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PR96pTEl; 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 b11-v6si13883763pls.145.2018.04.24.05.54.46; Tue, 24 Apr 2018 05:54:46 -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=PR96pTEl; 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 S933323AbeDXMyn (ORCPT + 29 others); Tue, 24 Apr 2018 08:54:43 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55517 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757814AbeDXMpP (ORCPT ); Tue, 24 Apr 2018 08:45:15 -0400 Received: by mail-wm0-f67.google.com with SMTP id a8so693267wmg.5 for ; Tue, 24 Apr 2018 05:45:15 -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=zuQ1SjEcsKyg6eckkbc65vVKHJNFHgpP18aBxBMCet0=; b=PR96pTEltpOFNciZ7IMovpepBv0egzcSmsrT5Lx+yxB9Jhzw23XLv5195utHOLpxAs Mc0QGBXlpvRCPogNmuT5Ga9T5xG4VcjrEjaXWDvhhQelW1b+jl5cGdmUYn1dp/wUPR+K bB5HTcGhD3xEtN3aO5sXx+83I+IufUBLpQ7A0= 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=zuQ1SjEcsKyg6eckkbc65vVKHJNFHgpP18aBxBMCet0=; b=pfx0MWIj+YMlYFPv/xamcywVzhaW9ObKZmK41TCqVifz5M2K1CuHF3E8biteHosZ/6 ru6LQHmCtXIHW+SHCsPd7o+39pDilsS9tPzTj6XI1WyCDMbMNrOpCkTdLbYOfHfXiQDj r2ODq3mkPbSz2nLYBBz/KXlmayNhxHzJnM2sR8OawH6Cbgf8U1EKAhOu6uFbHhSzl1pO zlbyfDMmMAYkZ6biHjaAIs23VBjw8VkWDgmOrasL/YRYR34OhhR4g9AputFnRGvyfzqw lU7BLHutF6+kL+zy3Z8y9+OvF4keAK+7PFmDBtpK3iVVocXLlt1sbCGQ8+NRsrS/VRtU dIzg== X-Gm-Message-State: ALQs6tCnQ3lAqVu1k5/W7I49Af2XuWrNxfBzyJviG6cbxwVo6VVoTr0U 8+BSDbMxA+wJgsnH5uTwbADS5g== X-Received: by 10.28.91.209 with SMTP id p200mr11518923wmb.11.1524573914620; Tue, 24 Apr 2018 05:45:14 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:14 -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 , Stanimir Varbanov Subject: [PATCH 07/28] venus: hfi_venus: add halt AXI support for Venus 4xx Date: Tue, 24 Apr 2018 15:44:15 +0300 Message-Id: <20180424124436.26955-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 AXI halt support for version 4xx by using venus wrapper registers. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 734ce11b0ed0..53546174aab8 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -532,6 +532,23 @@ static int venus_halt_axi(struct venus_hfi_device *hdev) u32 val; int ret; + if (hdev->core->res->hfi_version == HFI_VERSION_4XX) { + val = venus_readl(hdev, WRAPPER_CPU_AXI_HALT); + val |= BIT(16); + venus_writel(hdev, WRAPPER_CPU_AXI_HALT, val); + + ret = readl_poll_timeout(base + WRAPPER_CPU_AXI_HALT_STATUS, + val, val & BIT(24), + POLL_INTERVAL_US, + VBIF_AXI_HALT_ACK_TIMEOUT_US); + if (ret) { + dev_err(dev, "AXI bus port halt timeout\n"); + return ret; + } + + return 0; + } + /* Halt AXI and AXI IMEM VBIF Access */ val = venus_readl(hdev, VBIF_AXI_HALT_CTRL0); val |= VBIF_AXI_HALT_CTRL0_HALT_REQ; From patchwork Tue Apr 24 12:44:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134102 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2199873lji; Tue, 24 Apr 2018 05:54:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/vqiBj/x9kTp5gjeoDEw6NJBWxIVYPK3yJ95ctIy4481HJHsvDvA9/BptAXXopSNEv8/t X-Received: by 2002:a17:902:71cf:: with SMTP id t15-v6mr14624089plm.247.1524574487763; Tue, 24 Apr 2018 05:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574487; cv=none; d=google.com; s=arc-20160816; b=eHw3ZgRtRWRfOyj48sb0rKgWgCBrO26LPrlmdqyrESdhrj2Ozzaotc9+aL3FcSglsW 5hUKcOdn7zU1ZxIhml7BivskUGtBMZf4J8VpO+W4o6y0bqdndSFelY3+VhASxymWZAWZ MwyEwcChFShKrL0tx197Q97oKY0dftNjmQzdUTcWx6qnC8zgmWFj6EBK37k0Ep8WVdna 0NM9AYENmqNuqyMHWOAZlFfOqiuX+OjGy6aT6Hy9LwhVMGmjyboG1vZsXfUcjy+n7V1O zJB8a4eS2MI8vDjLKSIUr3qPNZ9KLV4g6BtT4NyEpTqNpwCz3JdgZHFxuVOhimpxdZpt 3chA== 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=tXBb5tYdSbXkg5a6q0eFfK/urVaFEKtwD4nw6O+n0Dw=; b=V64d9SFMgmKNnL3u+qMTZhqciW4R/vraDMa64hb0YUwWsxIdBaasht4CX1UNs/HD7F bj6iTHS5MkSN5N3kE6SBVBuvOjsjcdfy235g/HAkSql2V+c9vfgDQfVwDv6vrCDgT378 V2wJWU9idPKEkBvX1I6PzJI1lj2weaLUrwMY89DQcdGxAVAnHrzJAmFvhxCWwd4gqUyE Fha+NZlSjmpbE52SvbS6lxCZvlSQy+ejTRKCMDVvWpakfReSPOpY58PxGwl3fCmHDQ9c M0ZAXHESq0aMhN5MYIfRwe8xvgl72nz5KmcpEbtiUK7mn8IYs6WXc74n2WbVr0OEc5jT s3/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4CgnLgm; 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 m72si13441825pfi.236.2018.04.24.05.54.47; Tue, 24 Apr 2018 05:54: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=F4CgnLgm; 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 S933277AbeDXMyj (ORCPT + 29 others); Tue, 24 Apr 2018 08:54:39 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:42929 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757823AbeDXMpR (ORCPT ); Tue, 24 Apr 2018 08:45:17 -0400 Received: by mail-wr0-f195.google.com with SMTP id s18-v6so49791766wrg.9 for ; Tue, 24 Apr 2018 05:45: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=tXBb5tYdSbXkg5a6q0eFfK/urVaFEKtwD4nw6O+n0Dw=; b=F4CgnLgm0e0sJKuvkyC6UCBNumBvHO4YzWHD/JmYD8jFYBP7sT+XIDaNrW/rrac1o8 xkPmf05pSBNUd6plY2/G6+W54i9tcjx4uE5ulVfaC8mb9GnHR1BOiX4whxv4xUwMLZzU ISmPq0lt1cmgHSCxVpsjzGE7jxzJ5dz6UGXoU= 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=tXBb5tYdSbXkg5a6q0eFfK/urVaFEKtwD4nw6O+n0Dw=; b=rAdd833KVgXcM409o4jAcKAkNCvXi4HtLzkjgFElEa1W8kC6pC9s+2x+egTlPkv//x PflD7jDSayVThetyeQFDJngUDuxaWeDSbRFQyYYUAgpTmQph+vQ0di/3fbPiw34nWrkr HbDSW6S2HePhpgh0oC0XhmtCQWMeinJCgDgDCvBn1i55eXClqOSC7fCVi0W3WCbF8i3O k6YcKNtyPIyHKRu+5JkbK0Mijzn2F4CGS/TYWHZs9Nl3xHzfclj/2s0rpo2anDRq1oT4 c/Dtt8AnXlhvnBsx71DBCS8fMdTAwxbEg+BAwlKdld2W/ElLSc16NOmsPwg/XzxJCQjO iuGw== X-Gm-Message-State: ALQs6tCvbAdw+l1T5d95E0dxhfakBnEjaSl4YXU1+7fDvULiorGz1asr vI9tvTFkzTUheiQqRcnv8fnjCQ== X-Received: by 2002:adf:82ce:: with SMTP id 72-v6mr20436848wrc.60.1524573915722; Tue, 24 Apr 2018 05:45:15 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 08/28] venus: hfi_venus: add suspend function for 4xx version Date: Tue, 24 Apr 2018 15:44:16 +0300 Message-Id: <20180424124436.26955-9-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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) function with slightly different order of calls comparing with Venus 3xx. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 53546174aab8..f61d34bf61b4 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1443,6 +1443,55 @@ static int venus_suspend_1xx(struct venus_core *core) return 0; } +static int venus_suspend_4xx(struct venus_core *core) +{ + struct venus_hfi_device *hdev = to_hfi_priv(core); + struct device *dev = core->dev; + u32 val; + int ret; + + if (!hdev->power_enabled || hdev->suspended) + return 0; + + mutex_lock(&hdev->lock); + ret = venus_is_valid_state(hdev); + mutex_unlock(&hdev->lock); + + if (!ret) { + dev_err(dev, "bad state, cannot suspend\n"); + return -EINVAL; + } + + ret = venus_prepare_power_collapse(hdev, false); + if (ret) { + dev_err(dev, "prepare for power collapse fail (%d)\n", ret); + return ret; + } + + ret = readl_poll_timeout(core->base + CPU_CS_SCIACMDARG0, val, + val & CPU_CS_SCIACMDARG0_PC_READY, + POLL_INTERVAL_US, 100000); + if (ret) { + dev_err(dev, "Polling power collapse ready timed out\n"); + return ret; + } + + mutex_lock(&hdev->lock); + + ret = venus_power_off(hdev); + if (ret) { + dev_err(dev, "venus_power_off (%d)\n", ret); + mutex_unlock(&hdev->lock); + return ret; + } + + hdev->suspended = true; + + mutex_unlock(&hdev->lock); + + return 0; +} + static int venus_suspend_3xx(struct venus_core *core) { struct venus_hfi_device *hdev = to_hfi_priv(core); @@ -1507,6 +1556,9 @@ static int venus_suspend(struct venus_core *core) if (core->res->hfi_version == HFI_VERSION_3XX) return venus_suspend_3xx(core); + if (core->res->hfi_version == HFI_VERSION_4XX) + return venus_suspend_4xx(core); + return venus_suspend_1xx(core); } From patchwork Tue Apr 24 12:44:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134098 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2198051lji; Tue, 24 Apr 2018 05:53:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Xauof53rqU9fZL1bUpqMgz2ABvYCAKTKmw+V4jnbfp9yUaUuGag+i0Sg7X+q6vVbr7yMB X-Received: by 2002:a17:902:b105:: with SMTP id q5-v6mr25403041plr.173.1524574384173; Tue, 24 Apr 2018 05:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574384; cv=none; d=google.com; s=arc-20160816; b=FT4K/cuM2TU/Eq/G+KBepKMr8ypIQwZlh1IGutjHEFpo93rt6vYOaxv49jnhd4ZWlE xzNvgD4FtiCHiCKfkBBpXmnDyDTVKzXhmqeH5xt8oL0muAiFFi9gJAdGoDDNnszioUBo pc68aGj0pCPnqnCYXQxJDl3bTdDxl15pehrFQ/tshC2wXKMzXBk4pJJbjW4kTpRFhXsn PB2IJsZRLycOlzncbuxZOBLniq9N9mpG6Ze26lGy/xF0ScxbuUG0CtX6NZ+OCGVlvlf6 nYbyEW6IGEzc9yiHPJCoPMhFV0TarRYEadjc4mIoV+YdGyy0hEF1sMXi54nbs/G72Bde Xk6w== 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=k73mdEHmskQYq1+S2dnT0z8ez9Syn6kxboyLZ0h6Cu4=; b=YJ9KtVsyz8omodBQnQ5vBAhpDdNbru3dlIT7If4HRNitLiZZTnxo4zq+CuD62LGAV8 EfIXoOSugCRHS12rtmCr2hNzseX+hWS4rVJVhvN8FAERy5YA4CYXrcsqqsOIE7kXFPfE UN/y0DnzGoF7eH6qDxAdy2+NxRdZ+g8uz0CaeS/vgnCebszYuPmyBHDsutz5N4T9MyIa Ma5jx6JBq3rOJjhHUZvhX3iJzZkLXzaR0USyZTEyrtKdAzkzLlyeLW8mmBWQNaVhgoTm AqDJqex36BqTma4nxCaA8nUlZLg+iXoz3K4WjdZeV1qMn5DbmFIVvKWZGECZD1Qff3DB EVRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C2VTGmVw; 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 u28si9861361pgo.144.2018.04.24.05.53.03; Tue, 24 Apr 2018 05:53:04 -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=C2VTGmVw; 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 S1757674AbeDXMxB (ORCPT + 29 others); Tue, 24 Apr 2018 08:53:01 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35589 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757847AbeDXMpV (ORCPT ); Tue, 24 Apr 2018 08:45:21 -0400 Received: by mail-wm0-f66.google.com with SMTP id o78so611478wmg.0 for ; Tue, 24 Apr 2018 05:45:20 -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=k73mdEHmskQYq1+S2dnT0z8ez9Syn6kxboyLZ0h6Cu4=; b=C2VTGmVwvw2OAKIvCcw7RDSjSkJo27iLN+9oFyfP50Z15nmgumeKRwW+ECUofAH2yH uiK2lov2MTTrHG7zmkb1BLm7jb+OYp/AHlgR2o/7cYr/1cOZN2c6SMPwoIgtDlvILNMb RNmYMi1+4a6nyE6Jk8Vi9pmfDK/n8Gf5twpps= 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=k73mdEHmskQYq1+S2dnT0z8ez9Syn6kxboyLZ0h6Cu4=; b=rh9gsCf2jiQS5By4oJXfZOVxqquEPUA644HQHZOReIaAjvbwqnWU2cYfFtDCWriWQM eG3hOvlH0PeJhhMAu/fJluVI3ShsHsaEfXHN/SKP/LnvflEhsE+A+CJLItJCcBkdl0GN hh3N9OLCRFbzjYxg9WofMjFMxVlRzRzvrgqRkMaXyfbXgtks+1ZEE4UIWbZ+DHPvT5bK 0CBJxLqx51B5ChuRWxBQGRj0h8a2CtK3fmB7sKyDNiXlcSYA9mdXg9rXSZrQr85K6JIt t7p7q3TAHDvmWBCW2+dSMW7WN3wYIE4hSDc4fBJ62jxfgbGntF4qL272GivnL4QLOa2K 5A4Q== X-Gm-Message-State: ALQs6tDWkUSN+8H5mF+3bz9aAi6F6ILg9Kpey7+XBuv3Y7zEnuEdkqNk 0wMHt6Rsi/EVGgRYYOe56HhFwg== X-Received: by 10.28.111.71 with SMTP id k68mr11441749wmc.35.1524573918866; Tue, 24 Apr 2018 05:45:18 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 11/28] venus: add common capability parser Date: Tue, 24 Apr 2018 15:44:19 +0300 Message-Id: <20180424124436.26955-12-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 formars and codecs and also the capabilities for every codec like max/min width/height, framerate, bitrate and so on. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/Makefile | 3 +- drivers/media/platform/qcom/venus/core.c | 80 ++++++ drivers/media/platform/qcom/venus/core.h | 68 +++-- 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 | 348 ++----------------------- drivers/media/platform/qcom/venus/hfi_parser.c | 294 +++++++++++++++++++++ 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, 524 insertions(+), 437 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..1b72bfbb6297 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -152,6 +152,78 @@ 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; + unsigned int i; + u32 codec, codecs; + int ret; + + if (core->res->hfi_version != HFI_VERSION_1XX) + return 0; + + memset(&inst, 0, sizeof(inst)); + 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) + return ret; + + 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); + mutex_destroy(&inst.lock); + + return ret; +} + static int venus_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -219,6 +291,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 b5b9a84e9155..fe2d2b9e8af8 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -57,6 +57,29 @@ struct venus_format { u32 type; }; +#define MAX_PLANES 4 +#define MAX_FMT_ENTRIES 32 +#define MAX_CAP_ENTRIES 32 +#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; +}; + /** * struct venus_core - holds core parameters valid for all instances * @@ -120,6 +143,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 { @@ -224,22 +249,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; @@ -276,6 +287,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; @@ -287,22 +299,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) @@ -322,4 +320,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 < MAX_CODEC_NUM; 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..64cc2bc946ee 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_format[1]; +}; + struct hfi_uncompressed_format_supported { u32 buffer_type; u32 format_entries; - u32 format_info[1]; + struct hfi_uncompressed_plane_info format_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 023802e62833..8a943f53a12b 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) @@ -219,81 +220,30 @@ 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; + u32 rem_bytes, num_properties, error; error = pkt->error_type; if (error != HFI_ERR_NONE) - goto err_no_prop; + goto done; num_properties = pkt->num_properties; if (!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) { /* 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; - - rem_bytes -= read_bytes; - data += read_bytes; - num_properties--; - } + error = hfi_parser(core, inst, num_properties, &pkt->data[0], + rem_bytes); -err_no_prop: +done: core->error = error; complete(&core->done); } @@ -371,51 +321,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) @@ -505,238 +410,11 @@ 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; + u32 rem_bytes, error; error = pkt->error_type; if (error != HFI_ERR_NONE) @@ -745,8 +423,14 @@ static void hfi_session_init_done(struct venus_core *core, if (core->res->hfi_version != HFI_VERSION_1XX) goto done; - error = init_done_read_prop(core, inst, pkt); + rem_bytes = pkt->shdr.hdr.size - sizeof(*pkt) + sizeof(u32); + if (!rem_bytes) { + error = HFI_ERR_SESSION_INSUFFICIENT_RESOURCES; + goto done; + } + error = hfi_parser(core, inst, pkt->num_properties, &pkt->data[0], + 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..4b155997abbb --- /dev/null +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Linaro Ltd. + * + * Author: Stanimir Varbanov + */ +#include + +#include "core.h" +#include "hfi_helper.h" + +typedef void (*func)(struct venus_caps *cap, void *data, unsigned int size); + +static void init_codecs_vcaps(struct venus_core *core) +{ + struct venus_caps *caps = core->caps; + struct venus_caps *cap; + unsigned int i; + + for (i = 0; i < 8 * sizeof(core->dec_codecs); i++) { + if ((1 << i) & core->dec_codecs) { + cap = &caps[core->codecs_count++]; + cap->codec = (1 << i) & core->dec_codecs; + cap->domain = VIDC_SESSION_TYPE_DEC; + cap->valid = false; + } + } + + for (i = 0; i < 8 * sizeof(core->enc_codecs); i++) { + if ((1 << i) & core->enc_codecs) { + cap = &caps[core->codecs_count++]; + cap->codec = (1 << i) & core->enc_codecs; + 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, void *data, unsigned int num) +{ + 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 > 16) + 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 parse_profile_level(u32 codecs, u32 domain, void *data) +{ + struct hfi_profile_level_supported *pl = data; + struct hfi_profile_level *proflevel = pl->profile_level; + u32 count = pl->profile_count; + + if (count > HFI_MAX_PROFILE_COUNT) + return; + + while (count) { + proflevel = (void *)proflevel + sizeof(*proflevel); + count--; + } +} + +static void fill_caps(struct venus_caps *cap, void *data, unsigned int num) +{ + struct hfi_capability *caps = data; + unsigned int i; + + for (i = 0; i < num; i++) + cap->caps[cap->num_caps++] = caps[i]; +} + +static void parse_caps(struct venus_core *core, struct venus_inst *inst, + 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] = {}; + unsigned int i = 0; + + if (num_caps > MAX_CAP_ENTRIES) + return; + + while (num_caps) { + caps_arr[i++] = *cap; + cap = (void *)cap + sizeof(*cap); + num_caps--; + } + + for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain, + fill_caps, caps_arr, i); +} + +static void fill_raw_fmts(struct venus_caps *cap, void *fmts, + unsigned int num_fmts) +{ + struct raw_formats *formats = fmts; + unsigned int i; + + for (i = 0; i < num_fmts; i++) + cap->fmts[cap->num_fmts++] = formats[i]; +} + +static void parse_raw_formats(struct venus_core *core, struct venus_inst *inst, + u32 codecs, u32 domain, void *data) +{ + struct hfi_uncompressed_format_supported *fmt = data; + struct hfi_uncompressed_plane_info *pinfo = fmt->format_info; + struct hfi_uncompressed_plane_constraints *constr; + u32 entries = fmt->format_entries; + u32 num_planes; + struct raw_formats rfmts[MAX_FMT_ENTRIES] = {}; + unsigned int i = 0; + + while (entries) { + num_planes = pinfo->num_planes; + + rfmts[i].fmt = pinfo->format; + rfmts[i].buftype = fmt->buffer_type; + i++; + + if (pinfo->num_planes > MAX_PLANES) + break; + + constr = pinfo->plane_format; + + while (pinfo->num_planes) { + constr = (void *)constr + sizeof(*constr); + pinfo->num_planes--; + } + + 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, rfmts, 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 (core->res->hfi_version == HFI_VERSION_1XX) { + core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC; + core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK; + } +} + +static void parse_max_sessions(struct venus_core *core, void *data) +{ + 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_core *core, struct venus_inst *inst, + u32 *codecs, u32 *domain) +{ + if (core->res->hfi_version != HFI_VERSION_1XX) + return; + + if (!inst) + return; + + *codecs = inst->hfi_codec; + *domain = inst->session_type; +} + +static void parser_fini(struct venus_core *core, struct venus_inst *inst, + u32 codecs, u32 domain) +{ + struct venus_caps *caps = core->caps; + struct venus_caps *cap; + u32 dom; + unsigned int i; + + if (core->res->hfi_version != HFI_VERSION_1XX) + return; + + if (!inst) + return; + + 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, + u32 num_properties, 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(core, inst, &codecs, &domain); + + while (words_count) { + data = word + 1; + + switch (*word) { + case HFI_PROPERTY_PARAM_CODEC_SUPPORTED: + parse_codecs(core, data); + init_codecs_vcaps(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, inst, codecs, domain, data); + break; + case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED: + parse_caps(core, inst, codecs, domain, data); + break; + case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED: + parse_profile_level(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(core, 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..c484ac91a8e2 --- /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, + u32 num_properties, 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 < MAX_CAP_ENTRIES; 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 91c7384ff9c8..cd278a695899 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; } @@ -910,22 +911,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 bc8c2e7a8d2c..be8ea3326386 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 Tue Apr 24 12:44:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134096 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2194597lji; Tue, 24 Apr 2018 05:49:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Auf+lNkaOUEURPYzA451h36ie4d3hOEZrOmfOwqGsdWr1nRfyy5EJe0tOrp+ni3RostPN X-Received: by 10.98.95.198 with SMTP id t189mr23362209pfb.244.1524574175096; Tue, 24 Apr 2018 05:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574175; cv=none; d=google.com; s=arc-20160816; b=u1/rBXwLBWDIY2nA4x/TM7uctDfj5L6kccodlF8gGZTFkLzZFV2ao+Tdzs2Xeb30jl mVRXJCBk560RqfsIeVJCDRrjJzdlnt4MS7oaZeA4ad4L3O4ElBNNL5s8U7rAy6lczFUq 0cAaCZPZzrXo6HlHKVtcs5o9iJPWOnxvdJpiq0SFMn4lYtJgWNQUeveZHAnqcsjLQOQU r23sNANaYripUWkwIjWEWJPGq2HAFrvv/psLhNjQK4VDN8VNkF6efWyrfJ9DbgNdDdqa pQzDvivTE1ac+JvglqPpRZK3iaJF3NA74p3Sd7aliqTE5Vxauwl8f8amhOeALIK00vxG 1q3A== 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=boZzvw8J9AG3zB/hNfpFR04mGD4vUKszkUB2fak/o04=; b=vnNy4F+CKyqq3LwZZmTpSpcwkgxsjNv24n0zN1s2h0T0bTmo6/VY/2mac6SD0VTELZ TIzyXQgp8Y/MWO/dFvxHwBflI588mYKj/onKQlAb2NZAL4Y7rnVEHANWZto7cQKRO0m2 ckRFbNgw+nyVn2s8zasBlngol0A0O4A6MzhsgP0bbHK76HFgvNdNqTmKjMxiPtOYIyQv DAX00i3UueV2eapNk+7a5SpiIU2naUASS+0VqG6HXKZhrrxG0m6WqaHWXDYQA763gxHl 8IY0GOvJqfJfh5FM/oasK1CNJIX4JsnkoPAygkwMGmraEMy75ukG2pv6xl1NLqg/lVcA V8vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Twek869A; 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 y14si10769740pgr.218.2018.04.24.05.49.32; Tue, 24 Apr 2018 05:49:35 -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=Twek869A; 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 S933298AbeDXMta (ORCPT + 29 others); Tue, 24 Apr 2018 08:49:30 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:38345 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932835AbeDXMpW (ORCPT ); Tue, 24 Apr 2018 08:45:22 -0400 Received: by mail-wm0-f65.google.com with SMTP id i3so614363wmf.3 for ; Tue, 24 Apr 2018 05:45: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=boZzvw8J9AG3zB/hNfpFR04mGD4vUKszkUB2fak/o04=; b=Twek869AjrkmfI4O2C4w2pZfQkZlut3geXF9k776p0hvGVxUs3Ii8WgEcfxwRJX+G1 V2GlcHfzDuLIiV+isxHVw4G0BDX1J1HQ9WIZCuaTrxFZwNjwqDKALfO0AciUcIOQUxJ2 0sWwXbkjvlC+kXwQXx9wNXcDgcOY27EWLgpgE= 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=boZzvw8J9AG3zB/hNfpFR04mGD4vUKszkUB2fak/o04=; b=Ug2U7DwXfJYSA53FSQsg5aPQfFr7uNKMnU9TVMhzu2wAoNhkIQ6G4avnMvEROEV7RM qJjyIDU6iJNoxP/azJL14CfhnwZ2lz7XpjVXRJejCI0hA+xVJiDqVGLvH/sJ6DTxPmdC ID1MNAycye7ykWfHKnypW0I3th/XNic0doGdVbye0nfllFYydr2sbGBjw1qx13aa905M qkdSQNCsvXA5BOwalCPIz/YqI+nA8klaHTKMqyWvq86GxEoNCqBqKoLhg0s6CAmytLXA oqI+CYAnorH8NqpIWjG/cisp+nviTbOvfMd8BRxQ17peG02EUrHXopQ9xHzfE2/zKkyJ KdZg== X-Gm-Message-State: ALQs6tDNul/V06lKFOQhaSpNxg5eFsUTcW8KivZjHKPmFc6uN9mIN4Dy fn6QyoBLMt8utV8Zocp6+TfL0g== X-Received: by 10.28.174.81 with SMTP id x78mr13084808wme.41.1524573920853; Tue, 24 Apr 2018 05:45:20 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:20 -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 , Stanimir Varbanov Subject: [PATCH 13/28] venus: core: delete not used flag for buffer mode Date: Tue, 24 Apr 2018 15:44:21 +0300 Message-Id: <20180424124436.26955-14-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Delete not used flag for capture buffer allocation mode. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 2 -- 1 file changed, 2 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index fe2d2b9e8af8..c46334454cd9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -249,7 +249,6 @@ 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_bufs_mode_static: buffers allocation mode capability * @cap_bufs_mode_dynamic: buffers allocation mode capability */ struct venus_inst { @@ -299,7 +298,6 @@ struct venus_inst { const struct hfi_inst_ops *ops; u32 session_type; union hfi_get_property hprop; - bool cap_bufs_mode_static; bool cap_bufs_mode_dynamic; }; From patchwork Tue Apr 24 12:44:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134095 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2194507lji; Tue, 24 Apr 2018 05:49:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx482q364ss/eDUWE87BqzzJiq8ElFwCYHMgOBeADfC+nHbvdqZj0TVHkiQ9mnyxJdov3roXw X-Received: by 10.98.93.153 with SMTP id n25mr15139569pfj.143.1524574170467; Tue, 24 Apr 2018 05:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574170; cv=none; d=google.com; s=arc-20160816; b=iyAdNKHYnsUiUdaW6oTsgFSxcQs4C2JQVqpFKKwo2+01Wv5aZh2NO1u9zWtmgH1E2k O/7DHffonrGxr3OHSX8IiT+2TatCwn7eJ7j/RMq0cH6Xiz5FKgCY7MCI+sDdSh4dRGs3 NRxHv6hf2vlvMuGRigTA0sQvIJ/bzQQXTBIFsGsIMB/ZIkPvw0ik3ytMHl1GMbZvKZ00 b9BMG1Zv3xjBbraJ/hj2GxmcC4QHFRe9LLVex/dngfHOS+KP/rKMu6SgwhN6TWI7iVut Wpp8CL1KnRjxEyJD+LA7BTu2XoLjJjW4E5StfGTSMVXUZyUqjh6dKrDTtpqzcnrscwhC eAGA== 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=N3frKovU6D+244ryArLGCq4QJaJotXxoCOQlJ6G7Cas=; b=JDBmmlMYYMLGDsJPIHCYP8hRZBeo7325bsWX+lHxZLWLAjkV8ZpANPUBunwI1qphRs 7SBPKR2o/nTxhTDvCaXoYZlgE94l4H+lV8PztSYsEq1EBfMi5yyTxTwuiVToMFzT/hWA Q8AyDLYeBO13VXsl+ma1VUnl1Hr2xzgBdFNPeWzyVpwkonFf4bd1VUOmrf61URJSxXv7 Zw4lS039SNuHG3Lc5ltrN5Z4OVmLjWOhD/HEWZIi7j1slm0ZsjMQKw6P+rmUHc2NhnHY Blh6yd3FphMnTbAgKUAx96XRsLGWFAJoOaGpxn6XA6eJbpqAA+JIde0UnySltS7vN9OL tZZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cwtni/rA; 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 y14si10769740pgr.218.2018.04.24.05.49.29; Tue, 24 Apr 2018 05:49: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=cwtni/rA; 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 S932991AbeDXMtZ (ORCPT + 29 others); Tue, 24 Apr 2018 08:49:25 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40378 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932861AbeDXMpX (ORCPT ); Tue, 24 Apr 2018 08:45:23 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so49796586wrc.7 for ; Tue, 24 Apr 2018 05:45: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=N3frKovU6D+244ryArLGCq4QJaJotXxoCOQlJ6G7Cas=; b=cwtni/rAKivADfZ3eKvS0u8zhAfebgU0BEmfYFpE+vVg7+3m2QIAAorx0mOlM0zzt/ p6wQupxzYhJ3U/ipaUMTwMxa9D2xgpnkBn2rqV3LPVqMFEO2mhUEvpo0OdUxeI9pKSz1 H7UGjR8UfrJ39pD/4OTtAO34dZAPN3pA8mlxk= 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=N3frKovU6D+244ryArLGCq4QJaJotXxoCOQlJ6G7Cas=; b=EcWwkxHUC3kwXu7kwDtnfyGKg8cpXgacUpSlx/zgeaO61Jz0ybm1S/JHJPiHG98Gcb VDmFeUqeElL1alSjfpwkgEiWn4Z4YEYKAcaNayTeO21Oscz2JWnrHaUzN/cfpX5yP/cI e1kMM+/i5Mzp6hBg4oadW7Wri9IkOohhPf2apEDLPrVedLPkyLNLxbRKgTulj7bqkVeQ 6yfXvI/iepw55XFAmrrinTVl3zGqMAzrAnZkd0IULEXENmBGR9UN7bZvbQOfOkvSxeej uaNtYPavJsQKbM9qSldZo5HDM7cf+7JwUKyATKb+W8lUHqwHP/CnDrYQaCdllOB0Lt4p eoug== X-Gm-Message-State: ALQs6tBSHpyCQDSQyJfXUgw5YGoh6D15OsnL8LELpo3XF9tjRbjFdIrE 6zV4rUWhvMcgCP3gtq9YsXos5Q== X-Received: by 2002:adf:b257:: with SMTP id y23-v6mr20147863wra.95.1524573922193; Tue, 24 Apr 2018 05:45:22 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 14/28] venus: helpers: rename a helper function and use buffer mode from caps Date: Tue, 24 Apr 2018 15:44:22 +0300 Message-Id: <20180424124436.26955-15-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename is_reg_unreg_needed() to better name is_dynamic_bufmode() and use buffer mode from enumerated per codec capabilities. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 2b21f6ed7502..1eda19adbf28 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -354,18 +354,19 @@ session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf) return 0; } -static inline int is_reg_unreg_needed(struct venus_inst *inst) +static inline int is_dynamic_bufmode(struct venus_inst *inst) { - if (inst->session_type == VIDC_SESSION_TYPE_DEC && - inst->core->res->hfi_version == HFI_VERSION_3XX) - return 0; + struct venus_core *core = inst->core; + struct venus_caps *caps; - if (inst->session_type == VIDC_SESSION_TYPE_DEC && - inst->cap_bufs_mode_dynamic && - inst->core->res->hfi_version == HFI_VERSION_1XX) + caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type); + if (!caps) return 0; - return 1; + if (caps->cap_bufs_mode_dynamic) + return 1; + + return 0; } static int session_unregister_bufs(struct venus_inst *inst) @@ -374,7 +375,7 @@ static int session_unregister_bufs(struct venus_inst *inst) struct hfi_buffer_desc bd; int ret = 0; - if (!is_reg_unreg_needed(inst)) + if (is_dynamic_bufmode(inst)) return 0; list_for_each_entry_safe(buf, n, &inst->registeredbufs, reg_list) { @@ -394,7 +395,7 @@ static int session_register_bufs(struct venus_inst *inst) struct venus_buffer *buf; int ret = 0; - if (!is_reg_unreg_needed(inst)) + if (is_dynamic_bufmode(inst)) return 0; list_for_each_entry(buf, &inst->registeredbufs, reg_list) { From patchwork Tue Apr 24 12:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134082 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2190740lji; Tue, 24 Apr 2018 05:45:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Eym3IYzCWTQYgBBv/rwvD2leTYdlMpFU/hZ2/hs40LyF8IIwm/nshIb+yT+6T+S5gAxCB X-Received: by 10.99.97.133 with SMTP id v127mr20067922pgb.441.1524573948365; Tue, 24 Apr 2018 05:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524573948; cv=none; d=google.com; s=arc-20160816; b=K4f45cMfCM0Sj+XzUrFfUsyTHAi+MvhzbMhopk3vSVx7q9gRbcASWobMssKHFPncf3 wn3oosjB26Gvd9t+c1AvfVlc+tHpi6l7sQHFRgVDH5F0NrdnzMyjacrQWs7j6Y3X/EkF x47NRrnP+U+Z2zg1Y5IpSnI8Xk1VDtWaDVHim8QXJ7y3OnELNfYkTYjGXtHKDVwuOwXA 1PQszBCZCoKNBGo4cOoXfxhk0X5UlzbqurZauMMF6FYDSPOv36vQKBkYXrGURESGu0jn PZKOA0bRo+s/bI6oiYt3tQSGlNIf9NSzCURloS9KM58MIwoWnRYWeQLiGAXHPNbIFXlK 3/sw== 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=7B6IvLTuye/1rlg6k8AZaH17yDl83HW+r2r6SYhmPsQ=; b=G8f8wUexz+SIT50PEqJYs3c98+fTf82RT/dPZpCteJmQ+EdXRNg2HVI/+mqZ6bpXKY /w9l5mWrp5TTCR39wZWu9J1FT0YeDSYTAjmYd3cBKrkPDo0rM6JSH5Kj9pU7D09IDRms /dwXy60oimaqe77LHaOGPnhvDmHUFY/c8mfD1HU8lZ4cUGhrPX0ujqMs7ozfKVeMxSJz j1ep4E8JXiBd4tLMPlVTrhmLFhWpd0phMRGE8q/j2OlCWkkhAJOMlDHE1dRy2Mr1rB+m HgnUOB5if/S+W+9yp/GzA2ucXro63I8BD3+Hyxyq8HvzeGqfan1yS0eUvujQL549KPys y8xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hYuuBi96; 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 s2si10967882pge.176.2018.04.24.05.45.48; Tue, 24 Apr 2018 05:45:48 -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=hYuuBi96; 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 S933051AbeDXMpn (ORCPT + 29 others); Tue, 24 Apr 2018 08:45:43 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36502 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932864AbeDXMpY (ORCPT ); Tue, 24 Apr 2018 08:45:24 -0400 Received: by mail-wm0-f65.google.com with SMTP id n10so609144wmc.1 for ; Tue, 24 Apr 2018 05:45:23 -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=7B6IvLTuye/1rlg6k8AZaH17yDl83HW+r2r6SYhmPsQ=; b=hYuuBi96zorLIMlfZrTgILdQxI+HBtJRSl1dlt/0ne5TNgkcLH20IxwjcXIgf2VrRi Z4z3ylsptlUTB3TBOICxEC0MKTUHySugho6Q8GEhxwGS7RgxelE7/YhrkWAUHYKuSjWF H6TsjMPEy3kJXNOoD7XHhhPfij0zNhz7SOy0I= 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=7B6IvLTuye/1rlg6k8AZaH17yDl83HW+r2r6SYhmPsQ=; b=G0HvxUbl79uZrBvxjrZxMJlfVN5V0hz3eh540tVTiKIu8yUViEU8MbmUwmXdQo2GQ6 /oad9Awyt3+HabuHEOAqck78sMPwD99GV2KX3qrZ5gFcsDy1MnajbwosD7nkahjDuMeO cBfYXRGlxi5UpoyxWl8u1q0cV4VVky3HdoFeIVGfavyLce8qSLcOVFdpzMGW7Avy3ZYI tfW3eMmazqKDjKbbNV1t7WCYSGP9Dm+eJfg879G4aqfsFEJaA1l0bPmkpC4A+DF8L/Wd 02UkhQAqR65DWtGmRXNTiLuURbFaMADDKvbvxg53ZZOQ5EgffLi1iBhjD3mv8be+GSlY jTlQ== X-Gm-Message-State: ALQs6tDsdhBXvmjn5Sfuc+zVMW1RvNJIq6aUWK/rlLapyIyy/egAtVfV Aoeh5ndKylOwcd/rHPkR4wjk3A== X-Received: by 10.28.230.28 with SMTP id d28mr12586234wmh.92.1524573923238; Tue, 24 Apr 2018 05:45:23 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:22 -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 , Stanimir Varbanov Subject: [PATCH 15/28] venus: add a helper function to set dynamic buffer mode Date: Tue, 24 Apr 2018 15:44:23 +0300 Message-Id: <20180424124436.26955-16-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 dymaic buffer mode if it is supported by current HFI version. 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 1eda19adbf28..824ad4d2d064 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -522,6 +522,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) +{ + 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 0ddc2c4df934..1de9cc64cf2f 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 Tue Apr 24 12:44:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134094 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2194322lji; Tue, 24 Apr 2018 05:49:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx491Ht75hO87+EPujrFs3ZbqUANcnCUpc5Wy0dioUtBftzUQryAccqT35a3vbzAcT/uTF6Si X-Received: by 10.101.102.69 with SMTP id z5mr19765034pgv.178.1524574160362; Tue, 24 Apr 2018 05:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574160; cv=none; d=google.com; s=arc-20160816; b=JIVLoowvKJx736xldfMhAuBtW1WmT3JecKIrJva+7L9LYteDn0j79qjVohIUlpYe9P 24euUMCHZP7e/AHQqb/vXydhAgcocqiumkpkphRpO6iUVCdMeWhcNqcnnaKCpp4Nhu7x VZfDT3Qd0GesLJoVZrV8JYsydCGRUTumSqoNLGmtZeeUzVy7vjiWwfAxzG4lmsICOkvE N0fgB3JkbA9YDUJ6vBTXvVe1NSHPEJxcDGXVzeetnKyJaMZzAv8scY7tQZqA0V92XgrL 7L68njBdUddOVpK0ZlK5ox/NywOe3d23nvgRcbQ17piK1PIF8o86amR0q0L/8tCChqSg Of4Q== 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=0FM8m5fcoFp0v4gBqHZ/k5r16oTTjDSKfkX4wMlrDmQ=; b=e0IHQBWSdZauNsKe0Y/RhVfeIkrQ9nSEyMLgYR1mnGuRAJUdnVolxakVKl7lM1ta09 1dl/d0zwtowrt+AknK2ivHad28m3xtzMziPo3Wju0eoehoG2ww6OzkMwGl+8U3EZw2HC xS2TqcSt2d1qPc3si55XjkoGINlokQTAG29yeiRX+rnzG5BXU4zmxEs+kr1PUUz5tsYV E3+hTAfwbYTtFU0uReQg9HAVdi4kB+JeG9SQlb+gMN1/A5MEu3sCC9blXjh81RfaB0Dx wpXWiVdDNVSCvmIwL1Hh0gtLcRqhSSViuJo4NmA7eQm6chdS7LbnalpdhX8A0pS2mY7I 9GZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jQKr5TKC; 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 bg11-v6si14086182plb.171.2018.04.24.05.49.19; Tue, 24 Apr 2018 05:49: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=jQKr5TKC; 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 S933274AbeDXMtQ (ORCPT + 29 others); Tue, 24 Apr 2018 08:49:16 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39231 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932991AbeDXMp0 (ORCPT ); Tue, 24 Apr 2018 08:45:26 -0400 Received: by mail-wm0-f65.google.com with SMTP id b21so615212wme.4 for ; Tue, 24 Apr 2018 05:45: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=0FM8m5fcoFp0v4gBqHZ/k5r16oTTjDSKfkX4wMlrDmQ=; b=jQKr5TKCDdZ0BlkJI2oseOkUd+ZVAbj8gLOvu0XX9urXHON0xvB1BmAqLEc6Pax7vC Zoe6QEHL/PjaCCXyZZoM7YJHrZ7+SAaBnNC/kSi8wOuKwXx3H2E4e+ZG2o2pxjfbQwAw yu5RFfm95fMhaPZp5y5BEGUIG3iLD1+5eEZrk= 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=0FM8m5fcoFp0v4gBqHZ/k5r16oTTjDSKfkX4wMlrDmQ=; b=EG+yVWDPa1BPhCV1ZLNLJTAVbEA4ufi9PgxtIfunHTptuJCNStB9X7Zsq/4Gl+hMet rAjn3o0wzE+mc2ZnfEZv2tJbZ04l+Z9zecbfP2+//1cBPy/kHjpvL+7RRTMaagTtl/+I wLjZUqfNRuBTmUDSvUFEsA32NIGYb6ByaJRdHfME/Sl4BXVY5BwcL8wQv2uve/UcczZF u0RuLbs09hB59TMNjL+DyPuUVcF5RGjR15pKgyUv/ysfUCrIbiIECeVLz03N7NZ6Hwik CEKLRvBprIUPelUwS5eQg9Bo4yLLi/ZDtsr9AxSgEj6jsSnh6jHfWiI3EQSpuupxMA4y MlkA== X-Gm-Message-State: ALQs6tDlYXT4XY8c1hRT6BbWw2t++21PJoX+KzECCSMcZK1COKKaXIVw NMfEYY5ZYINCpT+xHSL9RPkqKA== X-Received: by 10.28.23.21 with SMTP id 21mr12465723wmx.49.1524573925392; Tue, 24 Apr 2018 05:45:25 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:24 -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 , Stanimir Varbanov Subject: [PATCH 17/28] venus: delete no longer used bufmode flag from instance Date: Tue, 24 Apr 2018 15:44:25 +0300 Message-Id: <20180424124436.26955-18-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Delete no longer used flag cap_bufs_mode_dynamic from instance structure. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 2 -- drivers/media/platform/qcom/venus/hfi_parser.c | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index c46334454cd9..255292899204 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -249,7 +249,6 @@ 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_bufs_mode_dynamic: buffers allocation mode capability */ struct venus_inst { struct list_head list; @@ -298,7 +297,6 @@ struct venus_inst { const struct hfi_inst_ops *ops; u32 session_type; union hfi_get_property hprop; - bool cap_bufs_mode_dynamic; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c index 4b155997abbb..ac92fd347ce1 100644 --- a/drivers/media/platform/qcom/venus/hfi_parser.c +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -74,13 +74,9 @@ static void parse_alloc_mode(struct venus_core *core, struct venus_inst *inst, 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; - + mode->buffer_type == HFI_BUFFER_OUTPUT2) for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain, fill_buf_mode, type, 1); - } type++; } From patchwork Tue Apr 24 12:44:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134093 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2194267lji; Tue, 24 Apr 2018 05:49:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+RcspecDHosOJOC/7Z0HbnW3sFJH8Q5HAbLz6nBZXy7QpEoBJ0ljK5mYJszPaEUinMcYNs X-Received: by 10.101.93.138 with SMTP id f10mr20662687pgt.25.1524574157257; Tue, 24 Apr 2018 05:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574157; cv=none; d=google.com; s=arc-20160816; b=kOgqKpMWAQGRLqAvJT0aJfFEu8Fk+J/DA2xJo2zGATRu82M0dsEjzRY5fGnqxOr7Bz XaDikMRD0/Q4KZgBVBFPb4NOSSj5y5uMHDEdpcFfsIEkdXifLHotSGqTYiKC2TAu+lIV PImw4b28WoFeGLQsvieQUR+Fs2YSjeNvoELZb9fn2/PPoC7Hb/cOkiOAUwf/dV2u2gNn StfVYHMrkVp7cyvLPAXMCfQ3l9t+7cR17I2Awlq7a3UlOpg0qgeNuaP7z2lBL/E/bw50 fedw+nVg21NpJJnoF4/qsvrGl2oTc6SJfiZruYcZEboHQsOw7IrrCDfLla2bq52gyT+j BV2A== 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=1lZp2O9BfjywiJT0LOLaR31PS0wYHF12CIuuGpujLE4=; b=rRlx+T9wLiYw9JlLpS+oTWuod/f2KcHJ4dfInJeTTGwTZ+5pybFqwXdtCyQSGIcahU 0yDzga8zUW3CZ4Tl8RpHCxZdZihXeOPN9Xea79BYIhiZuSOVeuGso1NFPHhmevMq5fjJ hfnOpC2+QQWA0sjpJ9XwZDlkIBXAzK4R5kcvBj2G5V+sgbvEvqmOVVGV5RLfQeSzjW3v KIHfoXuhTAYlKAVBHKrTnw7U3YDrtwZFiEBllY+3UxTLonOXg9nepDub39puA4N7gnyi fxwxsNkQ+4Oowb0tfb38XAdEmDeJ/ZXrvbQb/wyxim13MxyZEUzEYRovGswTc/bEvb7y AKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NI0PQDTt; 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 e3si11339717pgs.449.2018.04.24.05.49.15; Tue, 24 Apr 2018 05:49:17 -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=NI0PQDTt; 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 S933273AbeDXMtM (ORCPT + 29 others); Tue, 24 Apr 2018 08:49:12 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55556 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757799AbeDXMp1 (ORCPT ); Tue, 24 Apr 2018 08:45:27 -0400 Received: by mail-wm0-f66.google.com with SMTP id a8so694411wmg.5 for ; Tue, 24 Apr 2018 05:45:27 -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=1lZp2O9BfjywiJT0LOLaR31PS0wYHF12CIuuGpujLE4=; b=NI0PQDTtlFrrmfDlNfI/fsrqF0HQ9kX3owlLW4MiumvqP5mJER8ol0cGOe1B+Vabhl JO+NotpY3Ue9eJzhKE1MsC2w6TfLksSyypaVtKhrwpvHHLa54XRj3nHRPFqCnnD61HZB +UeRM6UFDJirQyenxXgkwnc/6RTS9DDJjd7CE= 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=1lZp2O9BfjywiJT0LOLaR31PS0wYHF12CIuuGpujLE4=; b=VsYX/mQ24couE2Dbbs3OU6gRFOQvpdTU/Cfc+TQ2dznOhKGQJa9sG5bHORStfaprjz Z6eSZwTCLN5151Gz22MbOqLTzyLU4S/GnMZPxbYPtj4FldVbztscIa9zZLG3uQproXMO XjPa7AL4o6wBB3y6Mfq+gtcKlEYB4Z3F2Z58q8CabmMGeHiDrKc7w/Z1v78kfj8eKuE6 CVGPB1XQjvVg6OZGkSon2RGGwaY+6HXLvSuVpF5FDtmYajDI+CAFwhoVQDc7Drx24M6l eqyUPWj6SOYpm5HOMIcS06soF54mONo1vM8+TdI8GKM2x/9Nn2TxxD02grln3hIZtBSn NImA== X-Gm-Message-State: ALQs6tC59Ub8V1Si3qnNLX/wq787NjOrfPw7Vo2MY/z5aaWQpdSxQoOY yYYEHIbOTf7GFLrjn9gBg9kHOgRN9Nk= X-Received: by 10.28.92.211 with SMTP id q202mr12299297wmb.131.1524573926425; Tue, 24 Apr 2018 05:45:26 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 18/28] venus: helpers: add buffer type argument to a helper Date: Tue, 24 Apr 2018 15:44:26 +0300 Message-Id: <20180424124436.26955-19-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 --- 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 94664a3ce3e2..5512fbfdebb9 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -456,12 +456,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 f87d891325ea..8970f14b3a82 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 Tue Apr 24 12:44:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134089 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2191811lji; Tue, 24 Apr 2018 05:46:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+pvnKFKss3zqLwVGrehshYZ8F/HfM1rR72GpvcXMCu4c7+bcm11ktyJGewzZt6DD+ktysa X-Received: by 2002:a17:902:c81:: with SMTP id 1-v6mr19585963plt.126.1524574011852; Tue, 24 Apr 2018 05:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524574011; cv=none; d=google.com; s=arc-20160816; b=G1giQ1CB1GzKHgjeGvFodBFG05Uuoo4W4jE5lwDz9QUmJRJ3sd4IJGqbkzay0K2PPp Jow0uMJwYNyxvaGHzosYBt+ylT1Ipr3pM/srV7OuiHq80jiXeY8BlBf87DOYnsXQGohR c9OsbVKVlIyhPT9L8ReuqEZPTf5l1KZw6JKL/l0Q2vHK3ExHWDCnZS4LMFmmmBk1B6/t W7y+51yYoPfA95WM4c5FioJPA5gh+lJVj6shHe4lTUy6XNDogWVGzx6WXhpkf3RSnvEA F1e6uY6bsHQhaKfaU67Ddmq+6cX0FGT9r0cO74Gf5F7i6u3e4LgPK9k1ABitLLMNDSho nVMw== 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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=e8Y8o730nOH10vS0qgipK0Tp4FLGFRBV708VVG3Ka+i5c9rmjniNji1PTdnMdluc1y GGcbpNupAkNCPhi6kvsrLRjZBzc7sJvKx0agvDHuRg/z2mi8ZwVOWQQm8dFCvSXETds2 bTIALPO0Dm+RceCtDlMKF3FWuHlAq2GHn+5fc2jpZmKKzosafmcruryIe5RudL4ajPZn 3S6FzAXcafH+/hQU5zjm7zLy8XZwjNWUQ90ugzRu939qZotmJ55HuM1qXMyIyIw9lrFL rNQyjhNeQWS68hWjxnCU50z/BWkuvP/1bi3tjErPnbnEPzljJuAcgncEU3nxNJlnqAct ZvmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FN0DOURu; 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 g7-v6si14329687plk.388.2018.04.24.05.46.51; Tue, 24 Apr 2018 05:46:51 -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=FN0DOURu; 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 S933131AbeDXMqt (ORCPT + 29 others); Tue, 24 Apr 2018 08:46:49 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55579 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757872AbeDXMpd (ORCPT ); Tue, 24 Apr 2018 08:45:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id a8so694951wmg.5 for ; Tue, 24 Apr 2018 05:45:33 -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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=FN0DOURub0h0fNLy/jmYInJXVOK0zdju6mSwya06yvL0GIXo+MZ7i8QWrD+owQf7QL zm2wZBzvO/J+JhzWEefKGokgBtQQcl2qU/zm8sObSHfIjxscRcQPHw7jACRSy5cn3euy BelotzjX1W2lDmL54RfDCjVkOnQtBGbABfTQc= 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=8CZJg6udtDDseCPTSDGO7vUnuY2+DnlG9mgSuAiZvt4=; b=ZKp9BcMKlZdLcH9FL1pKvGnTOOf1N3iO7SVrE7tF/nxNZ1oZFdTpu9hz0g/nafDADv U+E/WzUKuEedd9qk53wJ0xcFjJFjqlV+j62VcYMvTlvGWPRzp0FI3bON6O9XUMaL3chz +HJH8tCDuEyIQg8cERFrpswoURMWFEqB+6EMVVMI2QZPSWarQIuzfa46tI70i7sdm4Xm ZKuDqsHSpqkka3OtvH95je0RgcBFviNl6Rwa4C9tgZFrGW4ZubJi7bfIds60R54wo9Fy +ldGdYQlcN8X2RAzPS7CeO+Fgln3bPAol78AwiK4Kwm72CmIUy7xYXyr5hxpGeUjpAA0 Qe4Q== X-Gm-Message-State: ALQs6tBdvHgncrm4TVmu8RJndnVKvMSLbzOoYz6j8MXiDLpfq+2keyUL ZQdYGhEbNeuEyOXs857wtcL/8w== X-Received: by 10.28.237.11 with SMTP id l11mr13352230wmh.160.1524573931933; Tue, 24 Apr 2018 05:45:31 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:31 -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 , Stanimir Varbanov Subject: [PATCH 23/28] venus: vdec: get required input buffers as well Date: Tue, 24 Apr 2018 15:44:31 +0300 Message-Id: <20180424124436.26955-24-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 --- 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 8d188b11b85a..6ed9b7c4bd6e 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 Tue Apr 24 12:44:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134083 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2190965lji; Tue, 24 Apr 2018 05:46:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48u3onKjIMq153zmsr+/W2Jx6uk+e/U2zYcAwoaPbhunVZ5vwARd5PTnuEBkORPjnJkazgD X-Received: by 2002:a17:902:bf05:: with SMTP id bi5-v6mr24402046plb.235.1524573961332; Tue, 24 Apr 2018 05:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524573961; cv=none; d=google.com; s=arc-20160816; b=yFVWYWyTkKZB3J5JR4q+xmYlNY+XDKiI49zW27VbFgW05C4mVT7POgpfuKTiuxvlCy w/rAbFphBGZuIVLlLz3y95IiZsjcxMIK7D60KAM8UDErjUtm/vQEBhjyx1SKvhhWnEfS hJuG7SQDKeUT7uCa31XNaSeWgca4ctU9Jz3Tf0LYzE5jpowd5kXkDOZ8SeRQ//t4MoVG v3acXSMqKI6MiVUrYtHFkaCbFZc9ANFtyxZIE1AMB2kaiZdElPtG/htGe4/wHjJY0bX4 9IHosGiQ5YxsV5B9/JvLl6GJo+58D7XU8ASXABja/emD7Ue2aMFEbnJZ1U4VF0rhAibZ sbvQ== 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=2Nnb7zQZ27P9tOBFzg8BtR2VmBa0iJvECHuSxxQvMiI=; b=NDvx5BLI+MxBgqcuGROdKh2xMj8GBQtrcSMmMJwAVpFGId106RwrSLH5OFc4ujzgEd XK2/dg6MTgWdpoygs2LDGab3159lMyPAMLZyEaSr5QsrYR1eknI5HqTz1OfdC9JeEJ2N Ll8RTcw/YWP/QUWsLMAzkZOFjpsiULGBXtgFVFDOsSrDFnQ6mskWs2MSFYpz6yzw5h9z LHds9HqR8PPTGglNiG7fp/aSiKEvi3tr4JEKuoAQt1+oG3FrtLIVcGUcpDU49tD2iehO R5d8yVrtAUWNJp4Ac34Z1mMA0swZ+jk+vMvKJf8HY+FFna0ziaycWa+4OCAa7cITyDnk d1iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gxT1iDwi; 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 s2si10967882pge.176.2018.04.24.05.46.01; Tue, 24 Apr 2018 05:46:01 -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=gxT1iDwi; 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 S933072AbeDXMp6 (ORCPT + 29 others); Tue, 24 Apr 2018 08:45:58 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40395 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757879AbeDXMpf (ORCPT ); Tue, 24 Apr 2018 08:45:35 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so49797277wrc.7 for ; Tue, 24 Apr 2018 05:45:34 -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=2Nnb7zQZ27P9tOBFzg8BtR2VmBa0iJvECHuSxxQvMiI=; b=gxT1iDwilM7fvJMYk0xqblLpCPXpPfjxdVMS72sEmQCXkU1qPAh9pCKpVKIENoUhfz WIRg/pJw2ublzlvJ9HDUMRs8n22jF9g7N/ynnRV4TOKet+0yXaqdbmk3kQEXc5Ru2VrG NqGg0ewoQ+44GLTUaI+okwOHLGVFmHYNcOSsk= 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=2Nnb7zQZ27P9tOBFzg8BtR2VmBa0iJvECHuSxxQvMiI=; b=R51tkbnqISaZviHfhiB+hUZgZM9LAXfKsIybNDVS3p7f2AibQtYQSyEAvcWP6by4cR Xkt6dZw+r1IeuQKCbmhUp0jdTLAQT+WpofhIJJAE4YerUeITL8IeLVCPFAWo+PGDMcuD QRbxxP/QK3LO5594WkwsZWrsDwbdb79/z8A835JYT8rJVEr/Z8vVZiyXiF7u+89joZ80 TCtMDfUqruMSJIVtTk9WW4BBHmMumIWwwopXNxnZuTrkF0w05tMeWnNWrtUiGmW2wx/8 8YOeFM2EoFSSmZnKQ6zgVPI5ceiP+bt4NKGJD5RR+2Pcnon9PTd+9YNllJwNPEsmzkaf KECg== X-Gm-Message-State: ALQs6tARH3DdJ1Mz3D9hys+Aj7GyUVqa0+ZT6DAXVVxh8QH/2xtWlYk2 ZbaaTQ8T7UE1xPuIZ3LyUPUxnw== X-Received: by 2002:adf:e290:: with SMTP id v16-v6mr13113299wri.54.1524573934064; Tue, 24 Apr 2018 05:45:34 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45:33 -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 , Stanimir Varbanov Subject: [PATCH 25/28] venus: move frame size calculations in common place Date: Tue, 24 Apr 2018 15:44:33 +0300 Message-Id: <20180424124436.26955-26-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-1-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org move calculations of raw and compressed in a common helper and make it identical for encoder and decoder. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 98 +++++++++++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 2 + drivers/media/platform/qcom/venus/vdec.c | 54 ++++------------ drivers/media/platform/qcom/venus/venc.c | 56 ++++------------- 4 files changed, 126 insertions(+), 84 deletions(-) -- 2.14.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index f0a0fca60c76..ed569705ecac 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -455,6 +455,104 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, } EXPORT_SYMBOL_GPL(venus_helper_get_bufreq); +static u32 get_framesize_raw_nv12(u32 width, u32 height) +{ + u32 y_stride, uv_stride, y_plane; + u32 y_sclines, uv_sclines, uv_plane; + u32 size; + + y_stride = ALIGN(width, 128); + uv_stride = ALIGN(width, 128); + y_sclines = ALIGN(height, 32); + uv_sclines = ALIGN(((height + 1) >> 1), 16); + + y_plane = y_stride * y_sclines; + uv_plane = uv_stride * uv_sclines + SZ_4K; + size = y_plane + uv_plane + SZ_8K; + + return ALIGN(size, SZ_4K); +} + +static u32 get_framesize_raw_nv12_ubwc(u32 width, u32 height) +{ + u32 y_meta_stride, y_meta_plane; + u32 y_stride, y_plane; + u32 uv_meta_stride, uv_meta_plane; + u32 uv_stride, uv_plane; + u32 extradata = SZ_16K; + + y_meta_stride = ALIGN(DIV_ROUND_UP(width, 32), 64); + y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(height, 8), 16); + y_meta_plane = ALIGN(y_meta_plane, SZ_4K); + + y_stride = ALIGN(width, 128); + y_plane = ALIGN(y_stride * ALIGN(height, 32), SZ_4K); + + uv_meta_stride = ALIGN(DIV_ROUND_UP(width / 2, 16), 64); + uv_meta_plane = uv_meta_stride * ALIGN(DIV_ROUND_UP(height / 2, 8), 16); + uv_meta_plane = ALIGN(uv_meta_plane, SZ_4K); + + uv_stride = ALIGN(width, 128); + uv_plane = ALIGN(uv_stride * ALIGN(height / 2, 32), SZ_4K); + + return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane + + max(extradata, y_stride * 48), SZ_4K); +} + +u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height) +{ + switch (hfi_fmt) { + case HFI_COLOR_FORMAT_NV12: + case HFI_COLOR_FORMAT_NV21: + return get_framesize_raw_nv12(width, height); + case HFI_COLOR_FORMAT_NV12_UBWC: + return get_framesize_raw_nv12_ubwc(width, height); + default: + return 0; + } +} +EXPORT_SYMBOL_GPL(venus_helper_get_framesz_raw); + +u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height) +{ + u32 hfi_fmt, sz; + bool compressed; + + switch (v4l2_fmt) { + case V4L2_PIX_FMT_MPEG: + case V4L2_PIX_FMT_H264: + case V4L2_PIX_FMT_H264_NO_SC: + case V4L2_PIX_FMT_H264_MVC: + case V4L2_PIX_FMT_H263: + case V4L2_PIX_FMT_MPEG1: + case V4L2_PIX_FMT_MPEG2: + case V4L2_PIX_FMT_MPEG4: + case V4L2_PIX_FMT_XVID: + case V4L2_PIX_FMT_VC1_ANNEX_G: + case V4L2_PIX_FMT_VC1_ANNEX_L: + case V4L2_PIX_FMT_VP8: + case V4L2_PIX_FMT_VP9: + case V4L2_PIX_FMT_HEVC: + compressed = true; + break; + default: + compressed = false; + break; + } + + if (compressed) { + sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2; + return ALIGN(sz, SZ_4K); + } + + hfi_fmt = to_hfi_raw_fmt(v4l2_fmt); + if (!hfi_fmt) + return 0; + + return venus_helper_get_framesz_raw(hfi_fmt, width, height); +} +EXPORT_SYMBOL_GPL(venus_helper_get_framesz); + int venus_helper_set_input_resolution(struct venus_inst *inst, unsigned int width, unsigned int height) { diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index 92be45894a69..92b167a47166 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -33,6 +33,8 @@ void venus_helper_m2m_device_run(void *priv); void venus_helper_m2m_job_abort(void *priv); int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, struct hfi_buffer_requirements *req); +u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height); +u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height); 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, diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index ced3330c396a..589fc13b84bc 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -29,29 +29,6 @@ #include "helpers.h" #include "vdec.h" -static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 height) -{ - u32 y_stride, uv_stride, y_plane; - u32 y_sclines, uv_sclines, uv_plane; - u32 size; - - y_stride = ALIGN(width, 128); - uv_stride = ALIGN(width, 128); - y_sclines = ALIGN(height, 32); - uv_sclines = ALIGN(((height + 1) >> 1), 16); - - y_plane = y_stride * y_sclines; - uv_plane = uv_stride * uv_sclines + SZ_4K; - size = y_plane + uv_plane + SZ_8K; - - return ALIGN(size, SZ_4K); -} - -static u32 get_framesize_compressed(unsigned int width, unsigned int height) -{ - return ((width * height * 3 / 2) / 2) + 128; -} - /* * Three resons to keep MPLANE formats (despite that the number of planes * currently is one): @@ -160,7 +137,6 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt; const struct venus_format *fmt; - unsigned int p; memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); @@ -191,18 +167,14 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) pixmp->num_planes = fmt->num_planes; pixmp->flags = 0; - if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { - for (p = 0; p < pixmp->num_planes; p++) { - pfmt[p].sizeimage = - get_framesize_uncompressed(p, pixmp->width, - pixmp->height); - pfmt[p].bytesperline = ALIGN(pixmp->width, 128); - } - } else { - pfmt[0].sizeimage = get_framesize_compressed(pixmp->width, - pixmp->height); + pfmt[0].sizeimage = venus_helper_get_framesz(pixmp->pixelformat, + pixmp->width, + pixmp->height); + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + pfmt[0].bytesperline = ALIGN(pixmp->width, 128); + else pfmt[0].bytesperline = 0; - } return fmt; } @@ -648,7 +620,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, in_num, out_num; + unsigned int in_num, out_num; int ret = 0; if (*num_planes) { @@ -678,7 +650,8 @@ static int vdec_queue_setup(struct vb2_queue *q, 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, + sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, + inst->out_width, inst->out_height); inst->input_buf_size = sizes[0]; *num_buffers = max(*num_buffers, in_num); @@ -687,10 +660,9 @@ static int vdec_queue_setup(struct vb2_queue *q, break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: *num_planes = inst->fmt_cap->num_planes; - - for (p = 0; p < *num_planes; p++) - sizes[p] = get_framesize_uncompressed(p, inst->width, - inst->height); + sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt, + inst->width, + inst->height); inst->output_buf_size = sizes[0]; *num_buffers = max(*num_buffers, out_num); inst->num_output_bufs = *num_buffers; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c9c40d1ce7c6..54f253b98b24 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -31,32 +31,6 @@ #define NUM_B_FRAMES_MAX 4 -static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 height) -{ - u32 y_stride, uv_stride, y_plane; - u32 y_sclines, uv_sclines, uv_plane; - u32 size; - - y_stride = ALIGN(width, 128); - uv_stride = ALIGN(width, 128); - y_sclines = ALIGN(height, 32); - uv_sclines = ALIGN(((height + 1) >> 1), 16); - - y_plane = y_stride * y_sclines; - uv_plane = uv_stride * uv_sclines + SZ_4K; - size = y_plane + uv_plane + SZ_8K; - size = ALIGN(size, SZ_4K); - - return size; -} - -static u32 get_framesize_compressed(u32 width, u32 height) -{ - u32 sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2; - - return ALIGN(sz, SZ_4K); -} - /* * Three resons to keep MPLANE formats (despite that the number of planes * currently is one): @@ -284,7 +258,6 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt; const struct venus_format *fmt; - unsigned int p; memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); @@ -318,19 +291,14 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) pixmp->num_planes = fmt->num_planes; pixmp->flags = 0; - if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - for (p = 0; p < pixmp->num_planes; p++) { - pfmt[p].sizeimage = - get_framesize_uncompressed(p, pixmp->width, - pixmp->height); + pfmt[0].sizeimage = venus_helper_get_framesz(pixmp->pixelformat, + pixmp->width, + pixmp->height); - pfmt[p].bytesperline = ALIGN(pixmp->width, 128); - } - } else { - pfmt[0].sizeimage = get_framesize_compressed(pixmp->width, - pixmp->height); + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + pfmt[0].bytesperline = ALIGN(pixmp->width, 128); + else pfmt[0].bytesperline = 0; - } return fmt; } @@ -845,7 +813,7 @@ static int venc_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, min = 4; + unsigned int num, min = 4; int ret = 0; if (*num_planes) { @@ -880,16 +848,18 @@ static int venc_queue_setup(struct vb2_queue *q, *num_buffers = max(*num_buffers, num); inst->num_input_bufs = *num_buffers; - for (p = 0; p < *num_planes; ++p) - sizes[p] = get_framesize_uncompressed(p, inst->width, - inst->height); + sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, + inst->width, + inst->height); inst->input_buf_size = sizes[0]; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: *num_planes = inst->fmt_cap->num_planes; *num_buffers = max(*num_buffers, min); inst->num_output_bufs = *num_buffers; - sizes[0] = get_framesize_compressed(inst->width, inst->height); + sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt, + inst->width, + inst->height); inst->output_buf_size = sizes[0]; break; default: From patchwork Tue Apr 24 12:44:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 134087 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2191571lji; Tue, 24 Apr 2018 05:46:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/WAV7i0DW8zD2VwBNQugeOF1mtUYbLq79Pzc/qS46Sld/C7NV2JJdbCIheAmNA1lmQk6TN X-Received: by 10.99.186.90 with SMTP id l26mr17986269pgu.5.1524573999650; Tue, 24 Apr 2018 05:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524573999; cv=none; d=google.com; s=arc-20160816; b=NZDyQspvl+JFTBIzgZpCGr8q9QVVEPh0xUpz+b2fhRkfm+6jUIdlVLC9q9djIkWxHX S4pvAhfIce8NUTvFA/hxyMIdMzdCK+Lwj70+ljg0qktbJODaYrrKCB89DfyQK/b7lMNY b5JPAdcWDXX24hO+ag/FpBrpD1H+hnSFfDaGyI477xnbOv4UubU1iNdqfRQ9QnQTGbSY zKYwoIXADx8kA8pY2knMvnCa+BixToxV/oesSSnC/FCel7n9Gl/lzx4wHbxqWjO/2PhA CVVTTZf4btFfwGkN8/T1keSTWQVuR0WcEgWQqZZpF7uBdNifECBlxluEILuUDIKa0RYw Mq0g== 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=if1dL2ChaODHiUpefoFiaiW9I4F8W5SvKbkkQBBc5hA=; b=kj/yGmr0zinGS5JnuUup8RBlaqHq9jCne+uXBlv1PXKuTX0k1U5qhW2boVFGAQeYKZ 93iK51Z7fobJbaqtMilzozvwcZ8kqM0xLVZfk72RbWi8t4glmqKLkftT92bNyPrt6i5o PTCpG810kgyTuOxEw0OlOUTRDcZwfsnUkIpBM1U/eFhOv+KKY9zCySVKOA5i9mCUu+QB HHOvgFkMDgUsxD4Y2WwTnYG7wm2dzq4hE2SMUyNL9XTNvXe9iEPcvbcKlYB0+ZFSMH4A 9qgwqKFbJSq4M9bwy57mHl0m0YZvSlyaKEJD8LYHFleSQFWc4A/l+SblJ32b7onNHhTq 2f3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iORr5xE8; 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 c11-v6si13560927pls.97.2018.04.24.05.46.39; Tue, 24 Apr 2018 05:46:39 -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=iORr5xE8; 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 S933080AbeDXMqg (ORCPT + 29 others); Tue, 24 Apr 2018 08:46:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36562 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757887AbeDXMph (ORCPT ); Tue, 24 Apr 2018 08:45:37 -0400 Received: by mail-wm0-f68.google.com with SMTP id n10so610446wmc.1 for ; Tue, 24 Apr 2018 05:45: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=if1dL2ChaODHiUpefoFiaiW9I4F8W5SvKbkkQBBc5hA=; b=iORr5xE8y93b8b06fWJNwxgDekJ0v79s8R/dcHrsZN6tGa2bltHeZlq3TW6HU0bFTK jyACm99W5r4Y4lbhBUKWnNtwK4vKNxfD3Hj/zCw6tnv6sfi2LU8ruWChNtrVi45gxdCk xh7LBThuN4csHYUXc/NzkBuNQIjrr9KncGdWQ= 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=if1dL2ChaODHiUpefoFiaiW9I4F8W5SvKbkkQBBc5hA=; b=OMkW/NYEiJL2OfwVGFXcRlN5zGiHPMxcZOnhC2Lw+hl6/jn7xjWTzx3J/HjN8C1ZeK TaDVoFZRsw7C7EoeMFxJ0kRb8a7DNIuh+coGy5Y6rwU6jLmEOYPQJjnCaHoARrm225Ph sB+3HTUMjK2TAYujBa3HQUa8a9wKO1hkJdU1FY/22DVHIp8vSAV6wVUoxPqmwo5xhfds Zd8kVkkLwq+UBA3WcEoMckuPEfKAX8d7unWETNJ1wXVAacICVKG8M+TwG4goy/eGJGAM crRbjF0dW5dH5jU2iNmEZBaDtKdsitkJh3EtPNqlTKI9NTUCJ2eRGZfVC5ctjDvRYFHP bNBA== X-Gm-Message-State: ALQs6tB2inW8HfUxN4asoPNOV7BQGJHWzM4Lln09Ia+9NyS770TsYD6B cQ0mYF/V9WdmYttbFfGY9liQ7Q== X-Received: by 10.28.143.143 with SMTP id r137mr1252238wmd.103.1524573935342; Tue, 24 Apr 2018 05:45:35 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n49-v6sm22666013wrn.50.2018.04.24.05.45.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 05:45: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 , Stanimir Varbanov Subject: [PATCH 26/28] venus: implementing multi-stream support Date: Tue, 24 Apr 2018 15:44:34 +0300 Message-Id: <20180424124436.26955-27-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180424124436.26955-1-stanimir.varbanov@linaro.org> References: <20180424124436.26955-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 a multi-stream decoder support. The multi stream gives an option to use the secondary decoder output with different raw format (or the same in case of crop). Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/helpers.c | 204 +++++++++++++++++++++++++++- drivers/media/platform/qcom/venus/helpers.h | 6 + drivers/media/platform/qcom/venus/vdec.c | 91 ++++++++++++- drivers/media/platform/qcom/venus/venc.c | 1 + 5 files changed, 299 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 4d6c05f156c4..85e66e2dd672 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -259,6 +259,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; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index ed569705ecac..87dcf9973e6f 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -85,6 +85,112 @@ 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; + + if (list_empty(&inst->dpbbufs)) + return 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; + + if (list_empty(&inst->dpbbufs)) + return 0; + + 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; @@ -342,7 +448,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; } @@ -675,6 +784,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) { u32 ptype = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; @@ -822,9 +952,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) @@ -894,6 +1025,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); } @@ -932,8 +1065,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: @@ -987,6 +1126,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 589fc13b84bc..7deee104ac56 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -532,10 +532,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; @@ -554,6 +560,78 @@ static int vdec_output_conf(struct venus_inst *inst) return ret; } + if (width > 1920 && height > ALIGN(1080, 32)) + ubwc = true; + + 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; @@ -624,6 +702,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; @@ -637,7 +717,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; @@ -746,6 +826,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; @@ -797,9 +881,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++; @@ -945,6 +1031,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 54f253b98b24..a703bce78abc 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);