Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp293574pxb; Thu, 25 Feb 2021 02:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyQfyR05R2KTvxO/KYX5dgRuK/Lm+F8zWzrn+uiHlJXHx2fcHxUTJ0kEiOd3Jk/K1CZUQq X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr2197874edb.103.1614249860770; Thu, 25 Feb 2021 02:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614249860; cv=none; d=google.com; s=arc-20160816; b=htO4mD8IqP3tnX+AsfgvL9e/PkNiQ69QhKNE5LJV8BpAUh2uRvl4zUxMmhgTs2EICz y5ZIvxQO/aOc8LCh+H7dK9Qm3uFPqGFWYAKMQ4muLVAAgkiUEuZ3kTQhdxdGXHnA7Lgr 6Ob9grZ/wPeUe37QbKz84HKo2laupqZweNI9bLLYrT51Ihzv5KgPHJp/MKsjuusPJ9F9 X7GHS6pmxFAIguDZnE+ODdngMhKHEgD/1Uf6xwwzNfAloNhVGxdFfkN5aaMMalxRATxs +Tt61jPN/r6BvNVXjBrIXbbMqteOXquN8JF6G+vCuRdUGDQbJTPSAeVLBUN6y2yhvPd5 nUsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s7mSN+irdwIhsF2IwhZRcQVeKmeP7JQ9ahNUIts3x4s=; b=Xl/hm6U+BhtapQN4NzXcEClYEdj8qpaZrz2erf/AspMydG4QaqQ1ZjqbKR67XdfRKX 0VVX6TsqHhc/TYVgcAHYew+W1wlONqSlwCnMi9l5kpvgHXRd4GBs/KvU4nwwRzxlLsVc lprhLfhArTzrMEZ7jV6gdARe2YOcgt6QouaxV7JyHMC8z0PZl/0EbALxhcWW2duE9goO mVvVkq3xtQ4bPcQ5UJi51SYl51MDH1mtkugQKh0wdr59r2dYWap+XnBIgHVc3Ub7UzFp otiNWcz/hzOaDgzpLX5j1v+NK/cnDP7ES/P1RKZYNLBbFEvEfg2s1SZ0i2BZaiW6MWHM HbAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VA5P4FPt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si3340115ejq.503.2021.02.25.02.43.58; Thu, 25 Feb 2021 02:44:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VA5P4FPt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbhBYKm7 (ORCPT + 99 others); Thu, 25 Feb 2021 05:42:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232582AbhBYKRM (ORCPT ); Thu, 25 Feb 2021 05:17:12 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 244A7C06178C for ; Thu, 25 Feb 2021 02:16:32 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id t25so3488178pga.2 for ; Thu, 25 Feb 2021 02:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s7mSN+irdwIhsF2IwhZRcQVeKmeP7JQ9ahNUIts3x4s=; b=VA5P4FPtqDNjUTPqvHbPbfMmrqsH/+bthZa1qtHJ5xmR0AU6RudvpkJcVgUAa4EuVs ZFn+G9aSx4gYOB8iqycClcB2AW96HHdAZojWASQNJB+dVurhn5zkaoiqlRcysc83MB/c STAeqH+KNyctpBpOrIYwiRLAeL3Ve0Yl5LOwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s7mSN+irdwIhsF2IwhZRcQVeKmeP7JQ9ahNUIts3x4s=; b=IbkMb1VPpSzksSCUPDeFvdSiUjYcauz7yM0jT3Sq0f9y7F4ec9HQbMDsfOWWRIAms7 7Qr9ZzcSuw6W7Gj+2zRKxtgF9s8rQz2gmcQDRAXBCpzvld17L8QI5lVUs4+OSkUFMorU 20vcMIlPB2EJsppZYZQZr1ke16PlmAYqWNv1ok2BJPnHA9Xwz2jTTVaWdbGyzKTbKFDb zFkUxuq34Aj4uAWHVxQJlwldxVpGmiyE/0Upw9E5DtgGRw0GyWqsNp7baLeffmYGsvF7 rqSsHJTMAlqnSWdyHEwuZC0Xi5HV7eVQVWfv2fo3wNjOcRPbb6GHd8LBpsNsxdUOUk0O xudQ== X-Gm-Message-State: AOAM532nI/Du/pacjRFJmGzMpdvVQVX3p1ZbFBbXJxshKqmJkxKpkiCU F241hBCllq+FikNTvo7Lq6xv2g== X-Received: by 2002:aa7:8e51:0:b029:1ed:2928:18ff with SMTP id d17-20020aa78e510000b02901ed292818ffmr2537841pfr.76.1614248191668; Thu, 25 Feb 2021 02:16:31 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:2550:3154:2c53:b6e7]) by smtp.gmail.com with ESMTPSA id z2sm5848193pfc.8.2021.02.25.02.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 02:16:31 -0800 (PST) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Rob Herring , Yunfei Dong Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Alexandre Courbot Subject: [PATCH v2 2/8] media: mtk-vcodec: support version 2 of decoder firmware ABI Date: Thu, 25 Feb 2021 19:16:06 +0900 Message-Id: <20210225101612.2832444-3-acourbot@chromium.org> X-Mailer: git-send-email 2.30.0.617.g56c4b15f3c-goog In-Reply-To: <20210225101612.2832444-1-acourbot@chromium.org> References: <20210225101612.2832444-1-acourbot@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for decoder firmware version 2, which makes the kernel responsible for managing the VSI context and is used for stateless codecs. Signed-off-by: Alexandre Courbot --- .../media/platform/mtk-vcodec/vdec_ipi_msg.h | 18 +++++++++--- .../media/platform/mtk-vcodec/vdec_vpu_if.c | 28 +++++++++++++++---- .../media/platform/mtk-vcodec/vdec_vpu_if.h | 5 ++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h index eb66729fda63..a0e773ae3ab3 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h +++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h @@ -29,11 +29,15 @@ enum vdec_ipi_msgid { /** * struct vdec_ap_ipi_cmd - generic AP to VPU ipi command format * @msg_id : vdec_ipi_msgid - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. */ struct vdec_ap_ipi_cmd { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; }; /** @@ -63,7 +67,8 @@ struct vdec_ap_ipi_init { /** * struct vdec_ap_ipi_dec_start - for AP_IPIMSG_DEC_START * @msg_id : AP_IPIMSG_DEC_START - * @vpu_inst_addr : VPU decoder instance address + * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2. + * @inst_id : instance ID. Used if the ABI version >= 2. * @data : Header info * H264 decoder [0]:buf_sz [1]:nal_start * VP8 decoder [0]:width/height @@ -72,7 +77,10 @@ struct vdec_ap_ipi_init { */ struct vdec_ap_ipi_dec_start { uint32_t msg_id; - uint32_t vpu_inst_addr; + union { + uint32_t vpu_inst_addr; + uint32_t inst_id; + }; uint32_t data[3]; uint32_t reserved; }; @@ -87,6 +95,7 @@ struct vdec_ap_ipi_dec_start { * ensure that it is compatible with the firmware. * This field is not valid for MT8173 and must not be * accessed for this chip. + * @inst_id : instance ID. Valid only if the ABI version >= 2. */ struct vdec_vpu_ipi_init_ack { uint32_t msg_id; @@ -94,6 +103,7 @@ struct vdec_vpu_ipi_init_ack { uint64_t ap_inst_addr; uint32_t vpu_inst_addr; uint32_t vdec_abi_version; + uint32_t inst_id; }; #endif diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c index 203089213e67..5dffc459a33d 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c @@ -25,18 +25,30 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg) mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr); + /* Set default ABI version if dealing with unversioned firmware. */ + vpu->fw_abi_version = 0; + /* + * Instance ID is only used if ABI version >= 2. Initialize it with + * garbage by default. + */ + vpu->inst_id = 0xdeadbeef; + /* Firmware version field does not exist on MT8173. */ if (vpu->ctx->dev->vdec_pdata->chip == MTK_MT8173) return; /* Check firmware version. */ - mtk_vcodec_debug(vpu, "firmware version 0x%x\n", msg->vdec_abi_version); - switch (msg->vdec_abi_version) { + vpu->fw_abi_version = msg->vdec_abi_version; + mtk_vcodec_debug(vpu, "firmware version 0x%x\n", vpu->fw_abi_version); + switch (vpu->fw_abi_version) { case 1: break; + case 2: + vpu->inst_id = msg->inst_id; + break; default: mtk_vcodec_err(vpu, "unhandled firmware version 0x%x\n", - msg->vdec_abi_version); + vpu->fw_abi_version); vpu->failure = 1; break; } @@ -113,7 +125,10 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id) memset(&msg, 0, sizeof(msg)); msg.msg_id = msg_id; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg)); mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err); @@ -163,7 +178,10 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len) memset(&msg, 0, sizeof(msg)); msg.msg_id = AP_IPIMSG_DEC_START; - msg.vpu_inst_addr = vpu->inst_addr; + if (vpu->fw_abi_version < 2) + msg.vpu_inst_addr = vpu->inst_addr; + else + msg.inst_id = vpu->inst_id; for (i = 0; i < len; i++) msg.data[i] = data[i]; diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h index 85224eb7e34b..c2ed5b6cab8b 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h +++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h @@ -18,6 +18,9 @@ struct mtk_vcodec_ctx; * for control and info share * @failure : VPU execution result status, 0: success, others: fail * @inst_addr : VPU decoder instance address + * @fw_abi_version : ABI version of the firmware. + * @inst_id : if fw_abi_version >= 2, contains the instance ID to be given + * in place of inst_addr in messages. * @signaled : 1 - Host has received ack message from VPU, 0 - not received * @ctx : context for v4l2 layer integration * @dev : platform device of VPU @@ -29,6 +32,8 @@ struct vdec_vpu_inst { void *vsi; int32_t failure; uint32_t inst_addr; + uint32_t fw_abi_version; + uint32_t inst_id; unsigned int signaled; struct mtk_vcodec_ctx *ctx; wait_queue_head_t wq; -- 2.30.0.617.g56c4b15f3c-goog