Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1107122pxj; Fri, 21 May 2021 06:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQntBwQrTVxpbzd4oUm6TiM3BwzeEmTZYAFV9F/eyV0nXIe783DPljnriirMHaPFME6O1z X-Received: by 2002:a17:907:9606:: with SMTP id gb6mr10620288ejc.399.1621604414224; Fri, 21 May 2021 06:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621604414; cv=none; d=google.com; s=arc-20160816; b=ax17lf0msnk5O6tgQJxPy02nbBRpYH7OXM1lIeT2lYpVsi4sQyPx0qqmMGeb4lGopg 5t9iaYVhfPxufj7rf9k5+HyoNkp6JwWRf+yp336VE3KelFqqdrdlnfWwOrcFnXbCLQqW 2rpHuud4wdsH66y1kRcJVx/ZGiLa31D34UTUIQIITkGtN4eg81KhGsSZTGDyPd1UEWjR GKM/5Z8+CsI7g6mYp14xeq4LZsleB3cDD6LMgc4sFoSlpIZLRmE9MKH9Jwg2/MzQxFqp tpRSoft0VSCwiqr3sXxcVOyLO0pBUI35bgxzDbwMyMPzcoNu6g+7hRcKdCtf4BIr0hMD zAdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NttNeLhcm02+oiWbzzzzBiDUNeT7wjZHq2cUEjZv6s0=; b=LZHxOccssJiEWH65wWw2UNCKqocD/swNyJhMNwFTNpk4z0E29vvuKvfNdh+Ztpch02 AyjYXbM6oKb7UuaD8GRzyiO9Vvk9XzcyO0hFpGEYj9M7+2y9gVS4g3HoItxeM8kVy4Yf p59D/t8azHljawndmS+Dvb6+U6rCSrnMXf/gn/RXJ3iihtg6/d0wD4neMW229HE48Ct/ 44vRC06/ICaNcVlpuePo22S1hb7rf9bUXwY5YWA5RQdjelnUqsthoS8aiiSvTOoES8f0 e+RPtklei2zgETAt9uVoosuoI6mcFTvbbIopA6nmlwhCo22Xvj2weAhLj34AtQnotR16 Lb0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="v/KE6bfT"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si5221356edt.158.2021.05.21.06.39.50; Fri, 21 May 2021 06:40:14 -0700 (PDT) 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=@google.com header.s=20161025 header.b="v/KE6bfT"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236087AbhEUNjb (ORCPT + 99 others); Fri, 21 May 2021 09:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236176AbhEUNjN (ORCPT ); Fri, 21 May 2021 09:39:13 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5058DC061574 for ; Fri, 21 May 2021 06:37:50 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id e17so7617629iol.7 for ; Fri, 21 May 2021 06:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NttNeLhcm02+oiWbzzzzBiDUNeT7wjZHq2cUEjZv6s0=; b=v/KE6bfT6VCJYrnenvpz9zBGLCOpXfwLGaZk0v9Et0MttdvDk73dgEJXveraNR9+HX unAm2j2b4tweIPStl854Ty91CNZ4IATbtN30Hdlt/F9+O2Svl3Z3S5y5WCTgpx94AReE i7RJVe2ginenu3xnZAAnJE6i13f7bF9YRyqyVPIKJANH8TlhBrHYcJHjCSkW2pWbMUHN ekoIRlbQcYZbGZKbs+jpMEcUm64QeoI6u+ZCy4uuCGvHtDW4eVhePs2RskuLfrouVAYj UzhtkojWigfj4Np34KD4duWwqLdXu95eTnsWv25YY84Ape7heW8ImGamJvIJVeOouU5m Yhtw== 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=NttNeLhcm02+oiWbzzzzBiDUNeT7wjZHq2cUEjZv6s0=; b=ZsWMrlNbMs4C7X44kOzoGiN/A+zSV4tf86fRWfFqdMqsY54NT7u8xp4dRS0uqaMcse 6LvNXI3UHte/Ha/UcY/aYykgoiGNH7cscfSTrx7Ny5ljqyVjZRJ1pMY44pZAttz5Jwn6 uxVU1R23cVsR1cIouWKpU1umaFT8FbgMuO656N1xhrXj/p6jvbvrotbrygzfMlgJj7pp AilB/Guz0nQxu5wccAfBUEZA/A3IAGHaYTeh9mPTJSYmniIjzGH6N9RS0pS0r9DSn3jf K9zLTFPcvEf+LfDXE9ScrpDzCpXIeLrrycqkZ0DdPmksg8N7zxQTCj/ZLSAxPRUJD4v6 juaA== X-Gm-Message-State: AOAM531jIAyA9VaU0XARuRLDGIxOCqyUwrJazqsEmTPsGg/F69RhP9aQ AAbNyIMAnKAv9nHz9FECrl97ebEvO/5MBMxO04VzcA== X-Received: by 2002:a02:a81a:: with SMTP id f26mr4621472jaj.110.1621604269444; Fri, 21 May 2021 06:37:49 -0700 (PDT) MIME-Version: 1.0 References: <20210519143011.1175546-1-acourbot@chromium.org> <20210519143011.1175546-7-acourbot@chromium.org> In-Reply-To: <20210519143011.1175546-7-acourbot@chromium.org> From: Tzung-Bi Shih Date: Fri, 21 May 2021 21:37:38 +0800 Message-ID: Subject: Re: [PATCH v5 06/14] media: mtk-vcodec: vdec: move stateful ops into their own file To: Alexandre Courbot Cc: Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Dafna Hirschfeld , Yunfei Dong , Mauro Carvalho Chehab , linux-media@vger.kernel.org, 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 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. > +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. > +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. > +static int mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx) > +{ > + bool res_chg; > + int ret = 0; No need to initialize. > +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.