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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23562C28D13 for ; Mon, 22 Aug 2022 12:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V6I7E24kfLpbJn53Y/BNUWbItAKG8EI8/949CEGIC+o=; b=M0oBI8ffMWyApQ +zmn0F0Vv57uySs5hRnWvoem+TbtrPQED1fyl0jKaEzrLVwuGaq3QrZ/WtcpJT8usE4aiZCruiQoN Epn+Yl58tAF3TPCgJzyfW3Fa+JTQKH9hROfzkk9Ue76V9zcvMW416SRv9CHOMZ3zmGgw/wRT5kxLg rNIgroqS//TkJWVUSvbFYQaPXea+OaATZ0SRWwih8CQmjZD4x4nEkLjhjn1BGbJRsu9K/KVcd+Occ cMcuifOj4JWqhfQ1gPT6klov2zB3JT2Pubq6EtImYm1F5p3b1x69Oj7vFQM3m+HcEJYULpfQ8dh39 aZBBngJZTruPFzD2XI7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ69c-008idX-3B; Mon, 22 Aug 2022 12:03:41 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ69P-008iWv-3h for linux-arm-kernel@lists.infradead.org; Mon, 22 Aug 2022 12:03:36 +0000 Received: by mail-ed1-x52d.google.com with SMTP id a22so13554038edj.5 for ; Mon, 22 Aug 2022 05:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=5bsRy8NmbqAJ5Fg8qdrRQ5r91QFBlNcy6cH/Qzqv7m8=; b=asgePyz0CxZM9KLikVoyogbZcYggCpzQYNR4oxwrlvgcOmJZqmREcmlXxTyJjbceBg N8h65kpi9teX2/SJ7pI63oq1itQUgwoAbGyeLADZBAGsE0Ge/IL3ikb6ps615xJT+JXd jztDQOyUsDiBv7628AnPBPS3kZuwvsJ4HnkGs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=5bsRy8NmbqAJ5Fg8qdrRQ5r91QFBlNcy6cH/Qzqv7m8=; b=xgNND6grKWdYCmM/CHzeQeySRPrms2jfmwsLouV1LpX+MD8ZHhotfQ/1TR4f3iu9xe Cf8j6q8PQVcQr3bVs878LZBci7rNnGHSYFy2ui/tJRmmB2EAW6DXqonNlEs8g4xQl//t ttIEOACtxRiEAdUch0rk5j0ub700xH4F8/MZrmJbFgnz6BN3y/uNLEjsEj3Ptq4bnSUa r4Ah46u4JFomUQDqeDsVzYyile9pjiE41NG707+3JGeQZO+e+Ph3V/+NtltdiLg1Ilta bqDaeDZWZQBFfWaiMJT8XIga2PhWCyn4A5yLCu47Ge53YyDkK1SVFGeQuL/ZJ0XM5FBS 2Egw== X-Gm-Message-State: ACgBeo2haTv53nVVAuVhHGM8V1s3rNpLvuFXPxRgcHcpPNjwl7ICyJuL 9Yi9csHk4J2sPYJRlYQ4K6lvRA== X-Google-Smtp-Source: AA6agR7DzGqJD0yEZSf2uStXMrGk/irCyGL6RLzZ4ikIqfI80SKc0OuyH4itNpIQs0qxTPg93rcXKg== X-Received: by 2002:a05:6402:3227:b0:446:e48c:1251 with SMTP id g39-20020a056402322700b00446e48c1251mr1872833eda.186.1661169804974; Mon, 22 Aug 2022 05:03:24 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i (net-188-217-57-252.cust.vodafonedsl.it. [188.217.57.252]) by smtp.gmail.com with ESMTPSA id bd11-20020a056402206b00b00445f3ba4674sm8084493edb.63.2022.08.22.05.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 05:03:24 -0700 (PDT) Date: Mon, 22 Aug 2022 14:03:22 +0200 From: Tommaso Merciai To: Ming Qian Cc: "mchehab@kernel.org" , "hverkuil-cisco@xs4all.nl" , "shawnguo@kernel.org" , "robh+dt@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "X.H. Bao" , "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [EXT] Re: [PATCH v4 2/4] media: amphion: tell and handle contiguous and non contiguous format Message-ID: <20220822120322.GD17530@tom-ThinkPad-T14s-Gen-2i> References: <4af9766eb664a02d1c5884cb48fadef24dec142f.1660027440.git.ming.qian@nxp.com> <20220822111655.GA17530@tom-ThinkPad-T14s-Gen-2i> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220822_050333_487017_51A4B8C6 X-CRM114-Status: GOOD ( 34.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Ming, On Mon, Aug 22, 2022 at 11:56:11AM +0000, Ming Qian wrote: > >Hi Ming, > >Sorry for delay. I'm on vacation last week :) > > > >On Tue, Aug 09, 2022 at 02:50:39PM +0800, Ming Qian wrote: > >> Driver should tell the number of memory planes and component planes. > >> the amphion vpu support non contiguous planes, but for compatibility > >> with other device that only support contiguous planes. > >> driver can add support for contiguous planes in the same time. > >> Then the mem_planes can be different from the comp_planes. > >> driver need to handle buffer according mem_planes and comp_planes. > >> > >> So driver can support NV12 and NV12M. > >> > >> Signed-off-by: Ming Qian > >> --- > >> drivers/media/platform/amphion/vdec.c | 187 ++++++++++--------- > >> drivers/media/platform/amphion/venc.c | 33 ++-- > >> drivers/media/platform/amphion/vpu.h | 4 +- > >> drivers/media/platform/amphion/vpu_dbg.c | 8 +- > >> drivers/media/platform/amphion/vpu_helpers.c | 48 ++++- > >> drivers/media/platform/amphion/vpu_helpers.h | 2 + > >> drivers/media/platform/amphion/vpu_malone.c | 3 +- > >> drivers/media/platform/amphion/vpu_v4l2.c | 168 ++++++++++++----- > >> drivers/media/platform/amphion/vpu_v4l2.h | 3 +- > >> drivers/media/platform/amphion/vpu_windsor.c | 8 +- > >> 10 files changed, 299 insertions(+), 165 deletions(-) > >> > > [snip] > > >> +const struct vpu_format *vpu_helper_find_sibling(struct vpu_inst > >> +*inst, u32 type, u32 pixelfmt) { > >> + const struct vpu_format *fmt; > >> + const struct vpu_format *sibling; > >> + > >> + fmt = vpu_helper_find_format(inst, type, pixelfmt); > >> + if (!fmt) > >> + return NULL; > >> + if (!fmt->sibling) > >> + return NULL; > >> + sibling = vpu_helper_find_format(inst, type, fmt->sibling); > >> + if (!sibling) > >> + return NULL; > >> + if (sibling->sibling != fmt->pixfmt) > >> + return NULL; > >> + if (sibling->comp_planes != fmt->comp_planes) > >> + return NULL; > >> + return sibling; > >> +} > > > >I think we can limit the use of "if" statement here. What about this? > > > >const struct vpu_format *vpu_helper_find_sibling(struct vpu_inst *inst, u32 > >type, u32 pixelfmt) { > > const struct vpu_format *fmt; > > const struct vpu_format *sibling; > > > > fmt = vpu_helper_find_format(inst, type, pixelfmt); > > if (!fmt || !fmt->sibling) > > return NULL; > > > > sibling = vpu_helper_find_format(inst, type, fmt->sibling); > > if (!sibling || (sibling->sibling != fmt->pixfmt) || > > (sibling->comp_planes != fmt->comp_planes)) > > return NULL; > > > > return sibling; > >} > > > > OK, I'll apply this change in v5 > > >> + > >> +bool vpu_helper_match_format(struct vpu_inst *inst, u32 type, u32 > >> +fmta, u32 fmtb) { > >> + const struct vpu_format *sibling; > >> + > >> + if (fmta == fmtb) > >> + return true; > >> + > >> + sibling = vpu_helper_find_sibling(inst, type, fmta); > >> + if (sibling && sibling->pixfmt == fmtb) > >> + return true; > >> + return false; > >> +} > >> + > > [snip] > > >> --- a/drivers/media/platform/amphion/vpu_malone.c > >> +++ b/drivers/media/platform/amphion/vpu_malone.c > >> @@ -583,7 +583,8 @@ bool vpu_malone_check_fmt(enum vpu_core_type > >type, u32 pixelfmt) > >> if (!vpu_imx8q_check_fmt(type, pixelfmt)) > >> return false; > >> > >> - if (pixelfmt == V4L2_PIX_FMT_NV12M_8L128 || pixelfmt == > >V4L2_PIX_FMT_NV12M_10BE_8L128) > >> + if (pixelfmt == V4L2_PIX_FMT_NV12_8L128 || pixelfmt == > >V4L2_PIX_FMT_NV12_10BE_8L128 || > >> + pixelfmt == V4L2_PIX_FMT_NV12M_8L128 || pixelfmt == > >> + V4L2_PIX_FMT_NV12M_10BE_8L128) > > > >^Here are we using spaces instead of tab or I'm wrong? > > > > It's following the rule of checkpatch.pl > > >> return true; > >> if (vpu_malone_format_remap(pixelfmt) == MALONE_FMT_NULL) > >> return false; > > [snip] > > >> +static int vpu_calc_fmt_sizeimage(struct vpu_inst *inst, struct > >> +vpu_format *fmt) { > >> u32 stride = 1; > >> - u32 bytesperline; > >> - u32 sizeimage; > >> - const struct vpu_format *fmt; > >> - const struct vpu_core_resources *res; > >> int i; > >> > >> - fmt = vpu_helper_find_format(inst, type, pixmp->pixelformat); > >> - if (!fmt) { > >> - fmt = vpu_helper_enum_format(inst, type, 0); > >> - if (!fmt) > >> - return NULL; > >> - pixmp->pixelformat = fmt->pixfmt; > >> + if (!(fmt->flags & V4L2_FMT_FLAG_COMPRESSED)) { > >> + const struct vpu_core_resources *res = > >> + vpu_get_resource(inst); > >> + > >> + if (res) > >> + stride = res->stride; > > > >If res=NULL stride=1 it is ok? Or we need to return some error? > > > > If res is NULL, it means there is no additional alignment constraints > So it's ok to set stride to 1 in this case. > > >> } > >> > >> - res = vpu_get_resource(inst); > >> - if (res) > >> - stride = res->stride; > >> - if (pixmp->width) > >> - pixmp->width = vpu_helper_valid_frame_width(inst, > >pixmp->width); > >> - if (pixmp->height) > >> - pixmp->height = vpu_helper_valid_frame_height(inst, > >pixmp->height); > >> + for (i = 0; i < fmt->comp_planes; i++) { > >> + fmt->sizeimage[i] = vpu_helper_get_plane_size(fmt->pixfmt, > >> + > >fmt->width, > >> + > >fmt->height, > >> + i, > >> + stride, > >> + > >fmt->field != V4L2_FIELD_NONE ? 1 : 0, > >> + > >&fmt->bytesperline[i]); > >> + fmt->sizeimage[i] = max_t(u32, fmt->sizeimage[i], PAGE_SIZE); > >> + if (fmt->flags & V4L2_FMT_FLAG_COMPRESSED) { > >> + fmt->sizeimage[i] = clamp_val(fmt->sizeimage[i], > >SZ_128K, SZ_8M); > >> + fmt->bytesperline[i] = 0; > >> + } > >> + } > >> + > >> + return 0; > >> +} > >> + > >> +u32 vpu_get_fmt_plane_size(struct vpu_format *fmt, u32 plane_no) { > >> + u32 size; > >> + int i; > >> + > >> + if (plane_no >= fmt->mem_planes) > >> + return 0; > >> + > >> + if (fmt->comp_planes == fmt->mem_planes) > >> + return fmt->sizeimage[plane_no]; > >> + if (plane_no < fmt->mem_planes - 1) > >> + return fmt->sizeimage[plane_no]; > > > >I like a space here but is my personal opinion :) > > > > OK, I'll add a space line here in v5 > > [snip] Thanks for clarifications. Regards, Tommaso -- Tommaso Merciai Embedded Linux Engineer tommaso.merciai@amarulasolutions.com __________________________________ Amarula Solutions SRL Via Le Canevare 30, 31100 Treviso, Veneto, IT T. +39 042 243 5310 info@amarulasolutions.com www.amarulasolutions.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel