From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA7A6388392; Wed, 23 Sep 2026 02:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131417; cv=none; b=Cr2i/wGEzxm42/aIzoRd7JesNlOm+PRNWussVak+DVSHlakGlzdCicrGpvMfQ6vCR0UQtOmxARJdaB6KYaUyc6+5eAl8C/UyMQiX/WPMykV77AOgPYDVb2dF57e9YBocxMAS7e4tC4jIy+0mfdzj4QBTnpcpLT4QhTdnKmubbys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790131417; c=relaxed/simple; bh=1THgeFw+v0q/DjvjC9PuSSCTOBeW+w4FepZ7IrN9MNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cbWlCTuQM3Et/HITEDGGrOX/4c/by/W7grSL9bfu9USAD4XlFeI9PvUxV8W1xd1wCcvk7y4jAxTW8KKGe1nElR1My8LmL75b4kHv+oAXIYs6krNXdLS5AiQa14PCmreD/68zpSV8AE6EmNvpiwPq2R56O+K87+ncm/EGs1MprW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=D0xQN4aN; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="D0xQN4aN" X-UUID: 8c8749dcb6f811f1b1788b6acf885367-20260923 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=4fyPPjx27HiZYl9sL9EjqcuZ6S+q1wVLjGQYEz0emYc=; b=D0xQN4aNqGaLFDxA9Qby9Qa+A+WSbUU9HEEnJp11oVY3DORTLqi9SYm9HtmvpLwfKzT71wTEN0CXVugy05BMMsjr43lo6E5A942o5/qPraI3fJcuJLtjoKlbyUnR1V2J9FL1EjfbQVF3oePHvZJI+b9BuwAEnwmbrOKFxxgDQ14=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.19,REQID:fad585e6-3359-467a-a704-4e4c850c9d8b,IP:0,U RL:0,TC:0,Content:0,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:7db8b62,CLOUDID:bb6045ba-8825-408e-ae13-13bc2511f41e,B ulkID:nil,BulkQuantity:0,SF:81|82|102|136|836|865|888|898,TC:-5,Content:0| 15|50|99,EDM:2|-100,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL: 0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 8c8749dcb6f811f1b1788b6acf885367-20260923 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 512805936; Wed, 23 Sep 2026 10:43:25 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 23 Sep 2026 10:43:23 +0800 Received: from gcnsap21.gcn.mediatek.inc (10.17.81.22) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 23 Sep 2026 10:43:22 +0800 From: Kyrie Wu To: Tiffany Lin , Andrew-CT Chen , Yunfei Dong , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Kyrie Wu , Nicolas Dufresne , Ricardo Ribalda , Kees Cook , Hans Verkuil , Fei Shao , Haoxiang Li , Chen-Yu Tsai , Laurent Pinchart , Tomasz Figa , Philipp Zabel , Benjamin Gaignard , Qianfeng Rong , Irui Wang , Jacopo Mondi , Fan Wu , , , , , CC: Sakari Ailus Subject: [PATCH v7 14/14] media: mediatek: decoder: support av1 extend vsi Date: Wed, 23 Sep 2026 10:42:57 +0800 Message-ID: <20260923024258.257846-15-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260923024258.257846-1-kyrie.wu@mediatek.com> References: <20260923024258.257846-1-kyrie.wu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N The driver can't access tile buffer address for extend architecture, set tile group information in vcp and share it with kernel. Signed-off-by: Kyrie Wu --- .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c index 14639098f..1ef561dae 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c @@ -25,6 +25,9 @@ #define AV1_INVALID_IDX -1 +#define AV1_NON_EXT_VSI_SIZE 0xD50 +#define AV1_TILE_SIZE 64 + #define AV1_DIV_ROUND_UP_POW2(value, n) \ ({ \ typeof(n) _n = n; \ @@ -641,6 +644,8 @@ struct vdec_av1_slice_fb { * @frame: current frame info * @state: status after decode done * @cur_lst_tile_id: tile id for large scale + * @tile_group: tile group info + * @reserved: reserved */ struct vdec_av1_slice_vsi { /* lat */ @@ -665,6 +670,8 @@ struct vdec_av1_slice_vsi { struct vdec_av1_slice_frame frame; struct vdec_av1_slice_state state; u32 cur_lst_tile_id; + struct vdec_av1_slice_tile_group tile_group; + unsigned int reserved[4]; }; /** @@ -1402,17 +1409,29 @@ static void vdec_av1_slice_setup_uh(struct vdec_av1_slice_instance *instance, vdec_av1_slice_setup_tile(frame, &ctrl_fh->tile_info); } +static +struct vdec_av1_slice_tile_group *vdec_av1_get_tile_group(struct vdec_av1_slice_instance *instance, + struct vdec_av1_slice_vsi *vsi) +{ + if (IS_VDEC_SUPPORT_EXT(instance->ctx->dev->dec_capability)) + return &vsi->tile_group; + else + return &instance->tile_group; +} + static int vdec_av1_slice_setup_tile_group(struct vdec_av1_slice_instance *instance, struct vdec_av1_slice_vsi *vsi) { struct v4l2_ctrl_av1_tile_group_entry *ctrl_tge; - struct vdec_av1_slice_tile_group *tile_group = &instance->tile_group; + struct vdec_av1_slice_tile_group *tile_group; struct vdec_av1_slice_uncompressed_header *uh = &vsi->frame.uh; struct vdec_av1_slice_tile *tile = &uh->tile; struct v4l2_ctrl *ctrl; u32 tge_size; int i; + tile_group = vdec_av1_get_tile_group(instance, vsi); + ctrl = v4l2_ctrl_find(&instance->ctx->ctrl_hdl, V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY); if (!ctrl) return -EINVAL; @@ -1607,6 +1626,15 @@ static int vdec_av1_slice_setup_pfc(struct vdec_av1_slice_instance *instance, return ret; } +static u32 vdec_av1_get_tiles_num(struct vdec_av1_slice_instance *instance, + struct vdec_av1_slice_vsi *vsi) +{ + if (IS_VDEC_SUPPORT_EXT(instance->ctx->dev->dec_capability)) + return vsi->tile_group.num_tiles; + else + return instance->tile_group.num_tiles; +} + static void vdec_av1_slice_setup_lat_buffer(struct vdec_av1_slice_instance *instance, struct vdec_av1_slice_vsi *vsi, struct mtk_vcodec_mem *bs, @@ -1647,12 +1675,18 @@ static void vdec_av1_slice_setup_lat_buffer(struct vdec_av1_slice_instance *inst vsi->tile.buf = instance->tile.dma_addr; vsi->tile.size = instance->tile.size; - memcpy(lat_buf->tile_addr.va, instance->tile.va, 64 * instance->tile_group.num_tiles); vsi->cdf_table.buf = instance->cdf_table.dma_addr; vsi->cdf_table.size = instance->cdf_table.size; vsi->iq_table.buf = instance->iq_table.dma_addr; vsi->iq_table.size = instance->iq_table.size; + + /* lat_buf is used to share hardware decoder syntax between lat and core, + * there isn't only one. But there is only one tile.va for each instance. + * Need to copy tile information to lat_buf every time. + */ + memcpy(lat_buf->tile_addr.va, instance->tile.va, + AV1_TILE_SIZE * vdec_av1_get_tiles_num(instance, vsi)); } static void vdec_av1_slice_setup_seg_buffer(struct vdec_av1_slice_instance *instance, @@ -1675,7 +1709,7 @@ static void vdec_av1_slice_setup_tile_buffer(struct vdec_av1_slice_instance *ins struct vdec_av1_slice_vsi *vsi, struct mtk_vcodec_mem *bs) { - struct vdec_av1_slice_tile_group *tile_group = &instance->tile_group; + struct vdec_av1_slice_tile_group *tile_group; struct vdec_av1_slice_uncompressed_header *uh = &vsi->frame.uh; struct vdec_av1_slice_tile *tile = &uh->tile; u32 tile_num, tile_row, tile_col; @@ -1686,6 +1720,8 @@ static void vdec_av1_slice_setup_tile_buffer(struct vdec_av1_slice_instance *ins u32 *tile_info_buf = instance->tile.va; u64 pa = (u64)bs->dma_addr; + tile_group = vdec_av1_get_tile_group(instance, vsi); + if (uh->disable_cdf_update == 0) allow_update_cdf = 1; @@ -1908,7 +1944,7 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_ctx *ctx) struct vdec_av1_slice_instance *instance; struct vdec_av1_slice_init_vsi *vsi; enum mtk_vcodec_fw_type fw_type = ctx->dev->fw_handler->type; - int ret; + int ret, vsi_size = AV1_NON_EXT_VSI_SIZE; instance = kzalloc_obj(*instance); if (!instance) @@ -1942,9 +1978,18 @@ static int vdec_av1_slice_init(struct mtk_vcodec_dec_ctx *ctx) goto error_vsi; } - if (vsi->vsi_size != sizeof(struct vdec_av1_slice_vsi)) - mtk_vdec_err(ctx, "remote vsi size 0x%x mismatch! expected: 0x%zx\n", - vsi->vsi_size, sizeof(struct vdec_av1_slice_vsi)); + if (IS_VDEC_SUPPORT_EXT(ctx->dev->dec_capability)) { + vsi_size = sizeof(struct vdec_av1_slice_vsi); + vsi->iq_table_size = AV1_IQ_TABLE_SIZE; + vsi->cdf_table_size = AV1_CDF_SIZE; + } + + if (vsi->vsi_size != vsi_size) { + mtk_vdec_err(ctx, "remote vsi size 0x%x mismatch! expected: 0x%x\n", + vsi->vsi_size, vsi_size); + ret = -EINVAL; + goto error_vsi; + } instance->irq_enabled = 1; instance->inneracing_mode = IS_VDEC_INNER_RACING(instance->ctx->dev->dec_capability); -- 2.51.0.windows.2