Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5403118rwd; Wed, 24 May 2023 00:56:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7LlEXnmOgnyJQSL2zFvFFqoVEVscqRKcYyrQhinoGgkDnN7bNqTodgABHwM31yB5+n4Ibb X-Received: by 2002:a17:902:ce81:b0:1ad:ddf0:131f with SMTP id f1-20020a170902ce8100b001adddf0131fmr20417673plg.51.1684914972355; Wed, 24 May 2023 00:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684914972; cv=none; d=google.com; s=arc-20160816; b=tOrWeyeLZsIkWiyXvFn22w+mpbM20vMZRMi5Eqm1WO/NKWwFQ4r+PNY0O/2TwMwIpo 6N3i+sA4sj+Udfm5Tl/MR9swqFzbzhAR7ebSovxs8cnJoHyGFOuudGMxRZt9COzNTSSl E4i8C91QpeEzDtjRhNHX7OQf2vTNlSDZzihq0m+Lo4rWs3wScDVlg9HDIe8jclU9vNbG qMCvWCIW3Q6G+UbP9lImnbyHQDQ8F6N2HFox+Il3a7lQFHtdC7yzYzH4CTLyoymKQWZt ziGmInmwgCjP+cJze9cuY6/y9WsJ9xcqKdYupRvSU3E3Fg4Ma79wcK5ZFrMh8EGX2CbA ziEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=MQ5Ll723gxJOQriEEst7t1/UHqzXhr3nL1YtxUNySoU=; b=nrPlIk7cGFAMiI/ShxQ7skHwfrxKaeGTTihBg/ZDyIszMM5ZpF/X5ly6tVhXwB7h2R rHtoZAyJhnXOOyF3RAzkSSZ0w2ab/9mqpfjp/XRYZzishB9fwiUWnriacKW2K9IYch+j qNOjuQdMcJIYSnz3WcYqbSyRQQdnwi5JvITeyp35AuJFCs7SKVyG23OAE2Y9Q6afOxFk uLAiXZvLYF+OBNIACnWipnYQRcjtNQEm9oweGTJ0mUfa3RePGhrdw9IL8cmyBaE8CZED cdJrjJDFXqKo/dxjCQxLfCKTwCcDPHTLCHbjHHrGmdOW7AQ4JgDZgSkOWBS/0+xVIynj cHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BFGNHizB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik24-20020a170902ab1800b001ab089f7319si2142737plb.52.2023.05.24.00.55.59; Wed, 24 May 2023 00:56:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BFGNHizB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239955AbjEXHgO (ORCPT + 99 others); Wed, 24 May 2023 03:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239580AbjEXHgJ (ORCPT ); Wed, 24 May 2023 03:36:09 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C97131; Wed, 24 May 2023 00:35:59 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab] (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 24E3766032B2; Wed, 24 May 2023 08:35:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684913758; bh=2P4uUVGWSU1yuuIGABANv5MaXiV9HCTbYclu2/IM3PI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BFGNHizBzrDirVgLuoG5p0bLgQGskneur9IIARgRKquZxXDqU5cbeqxLvmAelQpx2 wIQOL1vD2uI6BZk5VzvitQonsIXe53UegCK/lnLH2qGKgOzMcfTFEeRlWvmrEyPkdF a3H2jcrI2lXF1T0ZdY/5IToW7eTbki7UDR2xDHulp3N3pcynSh/2H8g37ZfY8/7zFO ZS8ofYgPXodKinoxhur7XfqRDjxgHWP0WFwe6u+PJg8o6VVyuP2vXfoflUoFJ+BRde sSCzluBsADd0iaAaoVU3hgTDdQmE6fURduxAk9NQFRjKF+RoEYixtpgk/YK3YI/rqZ Np5iExasUbyoA== Message-ID: <2dde9a06-1ed3-f95e-f11e-91b65c039c92@collabora.com> Date: Wed, 24 May 2023 09:35:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v5,2/2] media: mediatek: vcodec: support stateless hevc decoder Content-Language: en-US To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , Benjamin Gaignard , =?UTF-8?Q?N=c3=adcolas_F_=2e_R_=2e_A_=2e_Prado?= , Nathan Hebert Cc: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com References: <20230524021625.13708-1-yunfei.dong@mediatek.com> <20230524021625.13708-3-yunfei.dong@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20230524021625.13708-3-yunfei.dong@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 24/05/23 04:16, Yunfei Dong ha scritto: > Add mediatek hevc decoder linux driver which use the stateless API in MT8195. > > Signed-off-by: Yunfei Dong > Tested-by: Nicolas Dufresne > Tested-by: Nathan Hebert > --- > .../media/platform/mediatek/vcodec/Makefile | 1 + > .../vcodec/mtk_vcodec_dec_stateless.c | 59 +- > .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 1 + > .../vcodec/vdec/vdec_hevc_req_multi_if.c | 1101 +++++++++++++++++ > .../platform/mediatek/vcodec/vdec_drv_if.c | 4 + > .../platform/mediatek/vcodec/vdec_drv_if.h | 1 + > 6 files changed, 1166 insertions(+), 1 deletion(-) > create mode 100644 drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c > ..snip.. > diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c > new file mode 100644 > index 000000000000..9a96547af33c > --- /dev/null > +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c > @@ -0,0 +1,1101 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2023 MediaTek Inc. > + * Author: Yunfei Dong > + */ > + ..snip.. > + > +/** > + * struct vdec_hevc_slice_share_info - shared information used to exchange > + * message between lat and core > + * > + * @sps: sequence header information from user space > + * @dec_params: decoder params from user space > + * @hevc_slice_params: decoder params used for hardware > + * @trans_start: trans start dma address > + * @trans_end: trans end dma address Wrong documentation, there's no trans_start, trans_end, but just `trans`. > + */ > +struct vdec_hevc_slice_share_info { > + struct v4l2_ctrl_hevc_sps sps; > + struct v4l2_ctrl_hevc_decode_params dec_params; > + struct vdec_hevc_slice_lat_dec_param hevc_slice_params; > + struct vdec_hevc_slice_mem trans; > +}; > + > +/** > + * struct vdec_hevc_slice_inst - hevc decoder instance > + * > + * @slice_dec_num: how many picture be decoded > + * @ctx: point to mtk_vcodec_ctx > + * @pred_buf: HW working predication buffer pred_buf is not present in this structure; either add it and make use of it, or remove the documentation for it. > + * @mv_buf: HW working motion vector buffer > + * @vpu: VPU instance > + * @vsi: vsi used for lat > + * @vsi_core: vsi used for core > + * @wrap_addr: wrap address used for hevc > + * > + * @hevc_slice_param: the parameters that hardware use to decode > + * > + * @resolution_changed: resolution changed > + * @realloc_mv_buf: reallocate mv buffer > + * @cap_num_planes: number of capture queue plane > + */ > +struct vdec_hevc_slice_inst { > + unsigned int slice_dec_num; > + struct mtk_vcodec_ctx *ctx; > + struct mtk_vcodec_mem mv_buf[HEVC_MAX_MV_NUM]; > + struct vdec_vpu_inst vpu; > + struct vdec_hevc_slice_vsi *vsi; > + struct vdec_hevc_slice_vsi *vsi_core; > + struct mtk_vcodec_mem wrap_addr; > + > + struct vdec_hevc_slice_lat_dec_param hevc_slice_param; > + > + unsigned int resolution_changed; > + unsigned int realloc_mv_buf; > + unsigned int cap_num_planes; > +}; > + > +static unsigned int vdec_hevc_get_mv_buf_size(unsigned int width, unsigned int height) > +{ > + const int unit_size = (width / 16) * (height / 16) + 8; This is supposed to be `const unsigned int`, otherwise you may overflow here (even if it's unlikely to, but still....!) > + > + return 64 * unit_size; > +} > + ..snip.. > +static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs, > + struct vdec_fb *fb, bool *res_chg) > +{ > + struct vdec_hevc_slice_inst *inst = h_vdec; > + struct vdec_vpu_inst *vpu = &inst->vpu; > + Please remove this extra empty line. > + int err, timeout = 0; > + unsigned int data[2]; > + struct vdec_lat_buf *lat_buf; > + struct vdec_hevc_slice_share_info *share_info; > + ...after which: Reviewed-by: AngeloGioacchino Del Regno