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 A8202C433EF for ; Tue, 5 Apr 2022 18:42:30 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wZj9KJCx2yZ7mw8SewtXT4CWJSwEEZpBR1hKKRSCAbU=; b=uNDrgEa9Um8F4C TWRkl4uUhhRF7iRKlYBkE/PHd5VVgkxiYFhWEPCYKB2PwGGDpi2wvDIXrG71KsVsd+ZfNdWHfCVNI TsCcYqjOpPyEJuRXgBALEAnysKD0Qse2YI+GqKE4L/jbhyy5EdpyiNzQNHIkkjwIULgGIjCgtFSWQ 0lxezilwbEvG+nE1gOtc/mKAvNSDJdUO2EFDosHL6cUIO4JiAlrM7WN8EFYvUkqwlI8bEu08CaSdq 723Av15GiZX6Fs8I+rGixUbKDMvGOfLc97lSncwTcJIpcrLziMhBGLFoEaePjxLc9mKma8eNGAbkg q9SjG4UGWdUwtQ0puQVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbo7Q-002EuQ-2S; Tue, 05 Apr 2022 18:41:32 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbo7L-002Esl-Ni; Tue, 05 Apr 2022 18:41:29 +0000 Received: by mail-ed1-x52a.google.com with SMTP id b24so15936712edu.10; Tue, 05 Apr 2022 11:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m8+gZUwdiEE5qvl2VnmW6rVS2LU3YP93jBijbUtmgIU=; b=XYbsuW/9J3w3AJ5TIXJONDZppci86m75YL2FDgn0BaMCRRL3EXnp4ebuaOd1zQIy0u XLnuET7H+rFD/Ge1BZsJmxmLwTUc/fEkgd9s71790cxoRZRMM9rqpIbga772wTCLoc2W QlfVKF9CjwpkoJ7CvrAUQdS1nyxawahdgwr1MOw4b6QC7D83s62JBwP+7IdTAjZ1KyD9 I4zOGbI8xhi7aHYcAeKU3T7PRfBICAw0yN2UUOMNk5Cvdd17gHRT/NAa82rOWg+AUVh9 GxoGY0GayTi7hetZuDPDQcxFwi45JPJUAMgSiHDW2ERr9LYChHTYTzbDFGEwF2u9iZBF s0PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m8+gZUwdiEE5qvl2VnmW6rVS2LU3YP93jBijbUtmgIU=; b=vOKlTmUeVA13X8ToKsu+/73olWWD0sxiOfJck+GPY1djgKRlehEgXDkxLzIj/SvFo7 DPYV8lS/cXwbtSIokivoUJcpGEYeV665mtHmYAU3D/Y4PrBlD0RxNIUnGdYajw3H8JCY Dl5OG6XuyUe+gG1qJmVYcRB77omT9wWgn3QKd4kzhkOHyfphcXY8qhD6cBCYD7Iuggut n0HQyLDYdjYUbWAJcVNGtBo0g7+4yLchtElQiOWh11wOEyCHai86gQ8yOyDSmLPTfwak esbirbkptbX09nbzlyjqm9y5kS/iybGhpKxMYbKTYaVw7tthyPtYLSO6fXT6v347kzkK 5lqQ== X-Gm-Message-State: AOAM533iRWlXAL6ByxolzKMZ48c4Zy83d6ls3qTXPCYSmzICOUWt26Bv 0XTsHgnl78gdjapDx7c0mjI= X-Google-Smtp-Source: ABdhPJz/BDSth3cyv5w1yUkWvK/7raS2HQuG5NyF9YhgGRBDVIEl5pHryGirWcHzIO89O4eDdGT19g== X-Received: by 2002:a05:6402:b3a:b0:41c:dcf9:ca65 with SMTP id bo26-20020a0564020b3a00b0041cdcf9ca65mr4980860edb.208.1649184084319; Tue, 05 Apr 2022 11:41:24 -0700 (PDT) Received: from jernej-laptop.localnet (cpe-86-58-32-107.static.triera.net. [86.58.32.107]) by smtp.gmail.com with ESMTPSA id o21-20020a170906289500b006d144662b24sm5730375ejd.152.2022.04.05.11.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 11:41:24 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, Benjamin Gaignard Cc: mchehab@kernel.org, nicolas@ndufresne.ca, hverkuil-cisco@xs4all.nl, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [RFC PATCH 3/8] media: hantro: Support format filtering by depth Date: Tue, 05 Apr 2022 20:41:22 +0200 Message-ID: <4699374.GXAFRqVoOG@jernej-laptop> In-Reply-To: <7972feba-221c-9960-68d0-ee15ad2a4f1a@collabora.com> References: <20220227144926.3006585-1-jernej.skrabec@gmail.com> <20220227144926.3006585-4-jernej.skrabec@gmail.com> <7972feba-221c-9960-68d0-ee15ad2a4f1a@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220405_114127_834052_63D9E6C5 X-CRM114-Status: GOOD ( 26.52 ) 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dne torek, 05. april 2022 ob 18:09:03 CEST je Benjamin Gaignard napisal(a): > Le 27/02/2022 =E0 15:49, Jernej Skrabec a =E9crit : > > In preparation for supporting 10-bit formats, add mechanism which will > > filter formats based on pixel depth. > > = > > Hantro G2 supports only one decoding format natively and that is based > > on bit depth of current video frame. Additionally, it makes no sense to > > upconvert bitness, so filter those out too. > > = > > Signed-off-by: Jernej Skrabec > > --- > > = > > drivers/staging/media/hantro/hantro.h | 4 ++ > > drivers/staging/media/hantro/hantro_v4l2.c | 48 ++++++++++++++++++++-- > > drivers/staging/media/hantro/hantro_v4l2.h | 1 + > > 3 files changed, 50 insertions(+), 3 deletions(-) > > = > > diff --git a/drivers/staging/media/hantro/hantro.h > > b/drivers/staging/media/hantro/hantro.h index 06d0f3597694..c6525ee8d89a > > 100644 > > --- a/drivers/staging/media/hantro/hantro.h > > +++ b/drivers/staging/media/hantro/hantro.h > > @@ -227,6 +227,7 @@ struct hantro_dev { > > = > > * > > * @ctrl_handler: Control handler used to register controls. > > * @jpeg_quality: User-specified JPEG compression quality. > > = > > + * @bit_depth: Bit depth of current frame > > = > > * > > * @codec_ops: Set of operations related to codec mode. > > * @postproc: Post-processing context. > > = > > @@ -252,6 +253,7 @@ struct hantro_ctx { > > = > > struct v4l2_ctrl_handler ctrl_handler; > > int jpeg_quality; > > = > > + int bit_depth; > > = > > const struct hantro_codec_ops *codec_ops; > > struct hantro_postproc_ctx postproc; > > = > > @@ -278,6 +280,7 @@ struct hantro_ctx { > > = > > * @enc_fmt: Format identifier for encoder registers. > > * @frmsize: Supported range of frame sizes (only for bitstream > > formats). > > * @postprocessed: Indicates if this format needs the post-processor. > > = > > + * @match_depth: Indicates if format bit depth must match video bit de= pth > > = > > */ > > = > > struct hantro_fmt { > > = > > char *name; > > = > > @@ -288,6 +291,7 @@ struct hantro_fmt { > > = > > enum hantro_enc_fmt enc_fmt; > > struct v4l2_frmsize_stepwise frmsize; > > bool postprocessed; > > = > > + bool match_depth; > > = > > }; > > = > > struct hantro_reg { > > = > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c > > b/drivers/staging/media/hantro/hantro_v4l2.c index > > e595905b3bd7..1214fa2f64ae 100644 > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > @@ -64,6 +64,42 @@ hantro_get_postproc_formats(const struct hantro_ctx > > *ctx,> = > > return ctx->dev->variant->postproc_fmts; > > = > > } > > = > > +int hantro_get_formath_depth(u32 fourcc) > = > Just a typo here: > = > s/hantro_get_formath_depth -> hantro_get_format_depth Good catch! I'll fix it in new series. Best regards, Jernej > = > regards > Benjamin > = > > +{ > > + switch (fourcc) { > > + case V4L2_PIX_FMT_P010: > > + case V4L2_PIX_FMT_P010_4L4: > > + return 10; > > + default: > > + return 8; > > + } > > +} > > + > > +static bool > > +hantro_check_depth_match(const struct hantro_ctx *ctx, > > + const struct hantro_fmt *fmt) > > +{ > > + int fmt_depth, ctx_depth =3D 8; > > + > > + if (!fmt->match_depth && !fmt->postprocessed) > > + return true; > > + > > + /* 0 means default depth, which is 8 */ > > + if (ctx->bit_depth) > > + ctx_depth =3D ctx->bit_depth; > > + > > + fmt_depth =3D hantro_get_formath_depth(fmt->fourcc); > > + > > + /* > > + * Allow only downconversion for postproc formats for now. > > + * It may be possible to relax that on some HW. > > + */ > > + if (!fmt->match_depth) > > + return fmt_depth <=3D ctx_depth; > > + > > + return fmt_depth =3D=3D ctx_depth; > > +} > > + > > = > > static const struct hantro_fmt * > > hantro_find_format(const struct hantro_ctx *ctx, u32 fourcc) > > { > > = > > @@ -91,7 +127,8 @@ hantro_get_default_fmt(const struct hantro_ctx *ctx, > > bool bitstream)> = > > formats =3D hantro_get_formats(ctx, &num_fmts); > > for (i =3D 0; i < num_fmts; i++) { > > = > > if (bitstream =3D=3D (formats[i].codec_mode !=3D > > = > > - HANTRO_MODE_NONE)) > > + HANTRO_MODE_NONE) && > > + hantro_check_depth_match(ctx, &formats[i])) > > = > > return &formats[i]; > > = > > } > > return NULL; > > = > > @@ -163,11 +200,13 @@ static int vidioc_enum_fmt(struct file *file, void > > *priv,> = > > formats =3D hantro_get_formats(ctx, &num_fmts); > > for (i =3D 0; i < num_fmts; i++) { > > = > > bool mode_none =3D formats[i].codec_mode =3D=3D = HANTRO_MODE_NONE; > > = > > + fmt =3D &formats[i]; > > = > > if (skip_mode_none =3D=3D mode_none) > > = > > continue; > > = > > + if (!hantro_check_depth_match(ctx, fmt)) > > + continue; > > = > > if (j =3D=3D f->index) { > > = > > - fmt =3D &formats[i]; > > = > > f->pixelformat =3D fmt->fourcc; > > return 0; > > = > > } > > = > > @@ -183,8 +222,11 @@ static int vidioc_enum_fmt(struct file *file, void > > *priv,> = > > return -EINVAL; > > = > > formats =3D hantro_get_postproc_formats(ctx, &num_fmts); > > for (i =3D 0; i < num_fmts; i++) { > > = > > + fmt =3D &formats[i]; > > + > > + if (!hantro_check_depth_match(ctx, fmt)) > > + continue; > > = > > if (j =3D=3D f->index) { > > = > > - fmt =3D &formats[i]; > > = > > f->pixelformat =3D fmt->fourcc; > > return 0; > > = > > } > > = > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.h > > b/drivers/staging/media/hantro/hantro_v4l2.h index > > 18bc682c8556..f4a5905ed518 100644 > > --- a/drivers/staging/media/hantro/hantro_v4l2.h > > +++ b/drivers/staging/media/hantro/hantro_v4l2.h > > @@ -22,5 +22,6 @@ extern const struct v4l2_ioctl_ops hantro_ioctl_ops; > > = > > extern const struct vb2_ops hantro_queue_ops; > > = > > void hantro_reset_fmts(struct hantro_ctx *ctx); > > = > > +int hantro_get_formath_depth(u32 fourcc); > > = > > #endif /* HANTRO_V4L2_H_ */ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel