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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 7AB47C4708A for ; Thu, 27 May 2021 10:10:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A5D4613B4 for ; Thu, 27 May 2021 10:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236120AbhE0KMW (ORCPT ); Thu, 27 May 2021 06:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236096AbhE0KMR (ORCPT ); Thu, 27 May 2021 06:12:17 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10950C061574 for ; Thu, 27 May 2021 03:10:44 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id q1so7169433lfo.3 for ; Thu, 27 May 2021 03:10:43 -0700 (PDT) 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=Jm/6jFCe3/7FOinz4SHy1Ee5ISvSki/EZvOhN9srBpY=; b=LGZVhXqBUDdX1KmMdSxzLcJeA+4qUVmlfy8wrXeVpW8TABCjHmnkD9dGcbbP71xWLg 7Vxy1H6Br35G36rwv5dOVypvJYzC0jSVtg/wZomZQDxm2xB/vkWoMCzI/Tjgg9wl6R7j do9h37JCcYmF5NUhoh1KeG2QlKpOrIcgL4R+s= 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=Jm/6jFCe3/7FOinz4SHy1Ee5ISvSki/EZvOhN9srBpY=; b=PHRNyq37GQvCGHSr6ZdEE1/lfvynEc1ObEKRnF7GiOR+ksb1oT2GNgonuqJFKN01cp Wd+l4bNROixEjDyywTw4eOlLvgmc+KHZAp4X/pFD2jAt4IkITwSMMCOshvxTZE54dwA8 AM9Zcfycf5tcPjEMnw7W8rLH0oGJ9Ni1Tt6NXOb1SKLkhkDjn9VaYH3drWw9uPGRR0eo d3vOVcNrvB3cvVpYi4Fv5C9zC+cAG52atCg8gblvnIPXy+KYVpOLFAOxXawO2ChXVUqM XsnyzWUaAPbYgyFOXM9kv7jl32VaKJeHfFva02Lb6U8GQGJKHnLKlyzG4LZUfm+OLA0D zm1Q== X-Gm-Message-State: AOAM532TcTUXqbmngMo7Sl2YrNmiKkn8HIKcHnlUJBlNSYjuSgcmQN86 7RnMoO8gpreZWr89tWVI8lHZPxKpUmzb/Q== X-Google-Smtp-Source: ABdhPJzlNO3ZNP+bIy2Kmsoe4NVvuXpjCGl/7GQdHHdsCDNKOayRxii/3Dlq1UUaGoJeXIs5yz9gRA== X-Received: by 2002:ac2:4919:: with SMTP id n25mr1835367lfi.646.1622110242205; Thu, 27 May 2021 03:10:42 -0700 (PDT) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com. [209.85.208.178]) by smtp.gmail.com with ESMTPSA id s20sm183874ljs.116.2021.05.27.03.10.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 May 2021 03:10:41 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id f12so77771ljp.2 for ; Thu, 27 May 2021 03:10:41 -0700 (PDT) X-Received: by 2002:a2e:988b:: with SMTP id b11mr2014124ljj.87.1622110241115; Thu, 27 May 2021 03:10:41 -0700 (PDT) MIME-Version: 1.0 References: <20210519143011.1175546-1-acourbot@chromium.org> <20210519143011.1175546-7-acourbot@chromium.org> In-Reply-To: From: Alexandre Courbot Date: Thu, 27 May 2021 19:10:28 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 06/14] media: mtk-vcodec: vdec: move stateful ops into their own file To: Tzung-Bi Shih Cc: Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Dafna Hirschfeld , Yunfei Dong , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 10:37 PM Tzung-Bi Shih wrote: > > On Wed, May 19, 2021 at 10:31 PM Alexandre Courbot > wrote: > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c > > new file mode 100644 > > index 000000000000..ed4b1308a0e4 > > --- /dev/null > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c > > @@ -0,0 +1,667 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include > > +#include > > +#include > > + > > +#include "mtk_vcodec_drv.h" > > +#include "mtk_vcodec_dec.h" > > +#include "mtk_vcodec_intr.h" > > +#include "mtk_vcodec_util.h" > > +#include "vdec_drv_if.h" > > +#include "mtk_vcodec_dec_pm.h" > > Would be good practice to sort them. Did what I could, but the order seems to somehow matter. :/ > > > +static struct vb2_buffer *get_display_buffer(struct mtk_vcodec_ctx *ctx) > > +{ > > + struct vdec_fb *disp_frame_buffer = NULL; > > + struct mtk_video_dec_buf *dstbuf; > > + struct vb2_v4l2_buffer *vb; > > + > > + mtk_v4l2_debug(3, "[%d]", ctx->id); > > + if (vdec_if_get_param(ctx, > > + GET_PARAM_DISP_FRAME_BUFFER, > > + &disp_frame_buffer)) { > > + mtk_v4l2_err("[%d]Cannot get param : GET_PARAM_DISP_FRAME_BUFFER", > > + ctx->id); > > + return NULL; > > + } > > + > > + if (disp_frame_buffer == NULL) { > > Although this is a move refactor, to be neat, !disp_frame_buffer. These were also raised by checkpatch.pl --strict, they are now all fixed. > > > +static struct vb2_buffer *get_free_buffer(struct mtk_vcodec_ctx *ctx) > > +{ > > + struct mtk_video_dec_buf *dstbuf; > > + struct vdec_fb *free_frame_buffer = NULL; > > + struct vb2_v4l2_buffer *vb; > > + > > + if (vdec_if_get_param(ctx, > > + GET_PARAM_FREE_FRAME_BUFFER, > > + &free_frame_buffer)) { > > + mtk_v4l2_err("[%d] Error!! Cannot get param", ctx->id); > > + return NULL; > > + } > > + if (free_frame_buffer == NULL) { > > The same concern as above. > > > +static void clean_display_buffer(struct mtk_vcodec_ctx *ctx) > > +{ > > + struct vb2_buffer *framptr; > > + > > + do { > > + framptr = get_display_buffer(ctx); > > + } while (framptr); > > +} > > + > > +static void clean_free_buffer(struct mtk_vcodec_ctx *ctx) > > +{ > > + struct vb2_buffer *framptr; > > + > > + do { > > + framptr = get_free_buffer(ctx); > > + } while (framptr); > > +} > > while (get_display_buffer(ctx)) ; > and > while (get_free_buffer(ctx)) ; > looks better. Done. > > > +static int mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx) > > +{ > > + bool res_chg; > > + int ret = 0; > > No need to initialize. Done. > > > +static void mtk_vdec_worker(struct work_struct *work) > > +{ > > + struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx, > > + decode_work); > > + struct mtk_vcodec_dev *dev = ctx->dev; > > + struct vb2_v4l2_buffer *src_buf, *dst_buf; > > + struct mtk_vcodec_mem buf; > > + struct vdec_fb *pfb; > > + bool res_chg = false; > > + int ret; > > + struct mtk_video_dec_buf *dst_buf_info, *src_buf_info; > > + > > + src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx); > > + if (src_buf == NULL) { > > To neat, !src_buf. > > > + dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); > > + if (dst_buf == NULL) { > > To neat, !dst_buf. > > > +static void vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb) > > +{ > > + struct vb2_v4l2_buffer *src_buf; > > + struct mtk_vcodec_mem src_mem; > > + bool res_chg = false; > > + int ret = 0; > > + unsigned int dpbsize = 1, i = 0; > > + struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); > > + struct vb2_v4l2_buffer *vb2_v4l2 = NULL; > > ret, i, and vb2_v4l2 are obviously no need to initialize. Done, thanks!