From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B451C33CB1 for ; Wed, 15 Jan 2020 05:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10C032072B for ; Wed, 15 Jan 2020 05:14:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Toqv6jeG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbgAOFO1 (ORCPT ); Wed, 15 Jan 2020 00:14:27 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:35053 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgAOFO0 (ORCPT ); Wed, 15 Jan 2020 00:14:26 -0500 Received: by mail-oi1-f196.google.com with SMTP id k4so14283100oik.2 for ; Tue, 14 Jan 2020 21:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1V7MW/ylG5HH52qKYnJfjENVm5zMbyLo/1xAyipVPNU=; b=Toqv6jeGfvvxWRkr5nvZFkzGlWyXW0qh9bEcuwG/GucvkAKkjZSDtLzEWNyuJz0kAn 3LFtDjFZjvJ7Cjg7QuoSNUcSCrCzCprhHwc/fgBE3nhH6SR9YUsAAdK89gezNLJwSh+u U2JRzqaD9IF3wcMHh/XVE6mg6as3ybZqHT9UQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1V7MW/ylG5HH52qKYnJfjENVm5zMbyLo/1xAyipVPNU=; b=RDjnvjYNKrwet8Bkwxdcs82u+C5untbFb6n6bu/LfFoNEVwkBzye96yLJPhIPiR2SW vYL1W2Ku2wZGH4FLmRXY7DWbtQ2So8ITmdy+qYlOialJ4Y/MRa3wYWG/3haXXrNhZcBp HA2aG7xs//cLhQt1o0/VGEOgMea88o6DlQUXggmgi5DRxlodSpE+TD1RZGEYSWErpusX b/1KmXAey4VcnMj91nYtpKMjuy4T4qjLgCqk8NB4CtSFMDVFO84LyInow+cU84RLVdJA 5bn2XdX1qxpq44XUEgfrIXA/MfpWqRRgGIzHX85zK3y9GR7KMmi/2bLoB5I+k3iqSy+J o26g== X-Gm-Message-State: APjAAAXdjviXFFLNl1Gtf2clOjyhxSYa5ey5Y4ghNMnQ8mL+Nvuh61DY j+NdQal1fxMXax3IFWZhvvkorRHzy4g4Ww== X-Google-Smtp-Source: APXvYqx6n8vR72Y3mR4jSjGgejOzofKvuTdN3bKxqiis0/X51PRVsceOS/LP5oESybg48JHMtBhokg== X-Received: by 2002:aca:1309:: with SMTP id e9mr19752381oii.7.1579065264730; Tue, 14 Jan 2020 21:14:24 -0800 (PST) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com. [209.85.167.180]) by smtp.gmail.com with ESMTPSA id q13sm6194232otc.5.2020.01.14.21.14.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2020 21:14:23 -0800 (PST) Received: by mail-oi1-f180.google.com with SMTP id d62so14215348oia.11 for ; Tue, 14 Jan 2020 21:14:23 -0800 (PST) X-Received: by 2002:aca:d0b:: with SMTP id 11mr19753910oin.71.1579065262776; Tue, 14 Jan 2020 21:14:22 -0800 (PST) MIME-Version: 1.0 References: <20200114033226.16786-1-gtk_ruiwang@mediatek.com> In-Reply-To: From: Alexandre Courbot Date: Wed, 15 Jan 2020 14:14:11 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: media: mtk-vcodec: reset segment data then trig decoder To: gtk_ruiwang Cc: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , Thomas Gleixner , Tomasz Figa , Tiffany Lin , Longfei Wang , Yunfei Dong , Maoguang Meng , Linux Media Mailing List , LKML , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , srv_heupstream@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 12:47 PM Alexandre Courbot wrote: > > On Tue, Jan 14, 2020 at 12:32 PM wrote: > > > > From: gtk_ruiwang > > > > VP9 bitstream specification indicate segment data should reset to > > default when meet key frames, intra only frames or enable error > > resilience mode. So memset segmentation map buffer before every > > decode process is not appropriate. > > > > Reset segment data only when needed, then trig decoder hardware > > > > Signed-off-by: Rui Wang > > --- > > .../platform/mtk-vcodec/vdec/vdec_vp9_if.c | 19 +++++++++++++++---- > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c > > index 24c1f0bf2147..42c9c3c98076 100644 > > --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c > > +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c > > @@ -110,7 +110,9 @@ struct vp9_sf_ref_fb { > > * @buf_len_sz_c : size used to store cbcr plane ufo info (AP-R, VPU-W) > > > > * @profile : profile sparsed from vpu (AP-R, VPU-W) > > - * @show_frame : display this frame or not (AP-R, VPU-W) > > + * @show_frame : [BIT(0)] display this frame or not (AP-R, VPU-W) > > + * [BIT(14)] reset segment data or not (AP-R, VPU-W) > > + * [BIT(15)] trig decoder hardware or not (AP-R, VPU-W) > > * @show_existing_frame : inform this frame is show existing frame > > * (AP-R, VPU-W) > > * @frm_to_show_idx : index to show frame (AP-R, VPU-W) > > @@ -494,12 +496,12 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst) > > frm_to_show->fb->base_y.size); > > } > > if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { > > - if (vsi->show_frame) > > + if (vsi->show_frame & BIT(0)) > > vp9_add_to_fb_disp_list(inst, inst->cur_fb); > > } > > } else { > > if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) { > > - if (vsi->show_frame) > > + if (vsi->show_frame & BIT(0)) > > vp9_add_to_fb_disp_list(inst, frm_to_show->fb); > > } > > } > > @@ -870,13 +872,22 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs, > > vsi->sf_frm_sz[idx]); > > } > > } > > - memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size); > > ret = vpu_dec_start(&inst->vpu, data, 3); > > if (ret) { > > mtk_vcodec_err(inst, "vpu_dec_start failed"); > > goto DECODE_ERROR; > > } > > > > + if ((vsi->show_frame & BIT(15)) && > > + (vsi->show_frame & BIT(14))) { > > Using the new bits in this manner means this patch is not compatible > with the older firmware. > > On an older firmware, these bits will be 0, which means the decoder > will never be started. To preserve compatibility, the behavior should > be reversed: *do not* reset and/or start the decoder if the bits are > set. > > Also both bits are only used together - we should either separate the > data segment reset and decoder start, or rely on only one bit for > this. Ah, looks like I missed the fact that the decoder is still started even when these bits are not set. So this indeed looks backward-compatible. Please ignore my comment.