Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp47014lqs; Thu, 13 Jun 2024 03:29:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWPkekbc82q2DhiNYjSndRgoc2aVFrCqBOkg/hKdJfHMPhiwkOZrF+a2SDC0ukyGjv1RRt3KPl57asfWGIcviYsxo5Kq6uFLfLZNxnCQ== X-Google-Smtp-Source: AGHT+IGs+O8Wo92n/QaGanZmCQX1H95LYh/ySzG0Txp3a9OpZkJe9ZLKUCKdpoFBqEBKYNpgm62Y X-Received: by 2002:a17:906:3b47:b0:a6f:1cf9:9b56 with SMTP id a640c23a62f3a-a6f47f56d44mr265485966b.9.1718274564543; Thu, 13 Jun 2024 03:29:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718274564; cv=pass; d=google.com; s=arc-20160816; b=WacMCRMdGP70QWz7TzJ3cTkoUse+bOJNylMlRFOKyiBHILHv7wqsxWca+H6gVTRCQW 6765b9eUUA/4etO8A9FLJuAs75+61I/7ePxvEb60CxwTzXPs/k1zQ5Ivk7weTg85fNtR d2ryZGtPCxGSkU6DSffD0sVSuZYGFoepuAi6iMuShvi9hGH3gOFssyGWBEk+hJG33csk KNAHlnGWIOwz9NdtoBFEUmCMlKW5RLkjGISBWuDhptjKnurZnPzg1EM3t3ZE6U0wIXJ0 ToDN8Vjf1YcXAyvY1cof1SJtNwxQhlSopDmbC98SE9LR4wlxgWbaxe3m2AB/96qqdYZS kn6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=pB5DBvrJWvV7ghr2X+7pnRO+X27U0y9m62BqTgYiTDQ=; fh=sD39IK6Bh27lk+EOYQOm145fLxXugdIc5QYLL9pgvwU=; b=lslM2P1lxSVTLIeJ1pg9zzS73RjW5+IIgE9now9jx0CR/XKMd2aXu5ZAn+j/cOPiuL n5H+Gcaz5VcSy7GqpKbL1WCu+yt8w/JUM6CX3nAXwfhnu46G/PAouKCaPdv8qAIizZXw vVodcpETe0bcdJ8bpeS79Au32+kqtUyN6OhR/ns1iHDJubVRw4DcroKoWVyvNgo3N9x/ MNYQVLUIWrytDnpu5Vt7lWXtfIwDpKz+31StNcogTE2u2MPhBVF7D8jKDJe8cIqLaRzb vIoCaKF5+bzoPYqoN89lmCpWygRaXldlZgTI/cwOfC1sdmkUqMjeISwPU3onyqev+xDU BOZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-213025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd6064si53132766b.368.2024.06.13.03.29.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 03:29:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-213025-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EA4091F25B21 for ; Thu, 13 Jun 2024 10:28:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F923142651; Thu, 13 Jun 2024 10:28:41 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8287B84A56; Thu, 13 Jun 2024 10:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718274520; cv=none; b=hdlIiKGOUIdY6DhURa5smM7biZNVdD0FKnVNScLKD+On9e5jB3C0s2Vlc/mT3gHPVqMMZhVxRiuO8pVfenQBaLINWYZWiCwwNlEwlyXBIhT2m97CPmTWRGpsdT02CglrVh6eep7yjoBh7TsclQUBWn0LsgB7NJ+jhn6K41hCfJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718274520; c=relaxed/simple; bh=gXIDd7kaBV1qUrIkyMMv+2dtaqYzdSwdJdsuebziqnY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ge4v0gFzYHQf6vd8sqDsDabTCXVMtiqbQ96mWs7dkJIjOFBHtvFJJcx4sQ3HHmzlTEA0H0LfgY5PX8O/jg0KLgw9ljCvN3gt6iB+K80++gMhcmDXVT7G+qWeKFyjuIIREzzzSlb0yfdf++DI7ALcPCDS3JkBy4yc3WEQUSucU1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC8AC2BBFC; Thu, 13 Jun 2024 10:28:37 +0000 (UTC) Message-ID: <52b3f0be-6427-40b3-862b-640f378e6b02@xs4all.nl> Date: Thu, 13 Jun 2024 12:28:35 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/4] media: chips-media: wave5: Use helpers to calculate bytesperline and sizeimage. To: Jackson Lee , mchehab@kernel.org, nicolas@ndufresne.ca, sebastian.fricke@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, Nicolas Dufresne References: <20240611071501.80-1-jackson.lee@chipsnmedia.com> <20240611071501.80-4-jackson.lee@chipsnmedia.com> Content-Language: en-US, nl From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicjzj5+yffv1lB5A1btG+AmoZrgf0X2O1B96fqgHx8w9PIpVERN YsmkfxvhfP3MO3oHh8UY1OLKdlKamMneCLk2up1Zlli347KMjHAVjBAiy8qOguKF9k7HOjif JCLYTkggrRiEiE1xg4tblBNj8WGyKH+u/hwwwBqCd/Px2HvhAsJQ7DwuuB3vBAp845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dB7rB3wCzfYkAuCBqaF7Zgfw8xkad KEiQTexRbM1sc/I8ACpla3N26SfQwrfg6V7TIoweP0RwDrcf5PVvwSWsRQp2LxFCkwnCXOra gYmkrmv0duG1FStpY+IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: <20240611071501.80-4-jackson.lee@chipsnmedia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/06/2024 09:15, Jackson Lee wrote: > From: "jackson.lee" > > Use v4l2-common helper functions to calculate bytesperline and sizeimage, > instead of calculating in a wave5 driver directly. > > In case of raw(YUV) v4l2_pix_format, the wave5 driver updates > v4l2_pix_format_mplane struct through v4l2_fill_pixfmt_mp() function. > > Encoder and Decoder need same bytesperline and sizeimage values > for same v4l2_pix_format. > So, a wave5_update_pix_fmt is refactored to support both together. > > Signed-off-by: Jackson.lee > Signed-off-by: Nas Chung > Reviewed-by: Nicolas Dufresne > --- > .../platform/chips-media/wave5/wave5-helper.c | 24 ++ > .../platform/chips-media/wave5/wave5-helper.h | 5 + > .../chips-media/wave5/wave5-vpu-dec.c | 296 ++++++------------ > .../chips-media/wave5/wave5-vpu-enc.c | 197 +++++------- > .../platform/chips-media/wave5/wave5-vpu.h | 5 +- > .../chips-media/wave5/wave5-vpuconfig.h | 27 +- > 6 files changed, 235 insertions(+), 319 deletions(-) > > diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.c > index 7e0f34bfa5be..b20ab69cd341 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-helper.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c > @@ -7,6 +7,8 @@ > > #include "wave5-helper.h" > > +#define DEFAULT_BS_SIZE(width, height) ((width) * (height) / 8 * 3) > + > const char *state_to_str(enum vpu_instance_state state) > { > switch (state) { > @@ -224,3 +226,25 @@ void wave5_return_bufs(struct vb2_queue *q, u32 state) > v4l2_m2m_buf_done(vbuf, state); > } > } > + > +void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, > + int pix_fmt_type, > + unsigned int width, > + unsigned int height, > + const struct v4l2_frmsize_stepwise *frmsize) > +{ > + v4l2_apply_frmsize_constraints(&width, &height, frmsize); > + > + if (pix_fmt_type == VPU_FMT_TYPE_CODEC) { > + pix_mp->width = width; > + pix_mp->height = height; > + pix_mp->num_planes = 1; > + pix_mp->plane_fmt[0].bytesperline = 0; > + pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_BS_SIZE(width, height), > + pix_mp->plane_fmt[0].sizeimage); > + } else { > + v4l2_fill_pixfmt_mp(pix_mp, pix_mp->pixelformat, width, height); > + } > + pix_mp->flags = 0; > + pix_mp->field = V4L2_FIELD_NONE; > +} > diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.h b/drivers/media/platform/chips-media/wave5/wave5-helper.h > index 6cee1c14d3ce..9937fce553fc 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-helper.h > +++ b/drivers/media/platform/chips-media/wave5/wave5-helper.h > @@ -28,4 +28,9 @@ const struct vpu_format *wave5_find_vpu_fmt_by_idx(unsigned int idx, > const struct vpu_format fmt_list[MAX_FMTS]); > enum wave_std wave5_to_vpu_std(unsigned int v4l2_pix_fmt, enum vpu_instance_type type); > void wave5_return_bufs(struct vb2_queue *q, u32 state); > +void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, > + int pix_fmt_type, > + unsigned int width, > + unsigned int height, > + const struct v4l2_frmsize_stepwise *frmsize); > #endif > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > index 861a0664047c..f246c290ad6a 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > @@ -11,111 +11,92 @@ > #define VPU_DEC_DEV_NAME "C&M Wave5 VPU decoder" > #define VPU_DEC_DRV_NAME "wave5-dec" > > -#define DEFAULT_SRC_SIZE(width, height) ({ \ > - (width) * (height) / 8 * 3; \ > -}) > +static const struct v4l2_frmsize_stepwise dec_hevc_frmsize = { > + .min_width = W5_MIN_DEC_PIC_8_WIDTH, > + .max_width = W5_MAX_DEC_PIC_WIDTH, > + .step_width = W5_DEC_CODEC_STEP_WIDTH, > + .min_height = W5_MIN_DEC_PIC_8_HEIGHT, > + .max_height = W5_MAX_DEC_PIC_HEIGHT, > + .step_height = W5_DEC_CODEC_STEP_HEIGHT, > +}; > + > +static const struct v4l2_frmsize_stepwise dec_h264_frmsize = { > + .min_width = W5_MIN_DEC_PIC_32_WIDTH, > + .max_width = W5_MAX_DEC_PIC_WIDTH, > + .step_width = W5_DEC_CODEC_STEP_WIDTH, > + .min_height = W5_MIN_DEC_PIC_32_HEIGHT, > + .max_height = W5_MAX_DEC_PIC_HEIGHT, > + .step_height = W5_DEC_CODEC_STEP_HEIGHT, > +}; > + > +static const struct v4l2_frmsize_stepwise dec_raw_frmsize = { > + .min_width = W5_MIN_DEC_PIC_8_WIDTH, > + .max_width = W5_MAX_DEC_PIC_WIDTH, > + .step_width = W5_DEC_RAW_STEP_WIDTH, > + .min_height = W5_MIN_DEC_PIC_8_HEIGHT, > + .max_height = W5_MAX_DEC_PIC_HEIGHT, > + .step_height = W5_DEC_RAW_STEP_HEIGHT, > +}; > > static const struct vpu_format dec_fmt_list[FMT_TYPES][MAX_FMTS] = { > [VPU_FMT_TYPE_CODEC] = { > { > .v4l2_pix_fmt = V4L2_PIX_FMT_HEVC, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_hevc_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_H264, > - .max_width = 8192, > - .min_width = 32, > - .max_height = 4320, > - .min_height = 32, > + .v4l2_frmsize = &dec_h264_frmsize, > }, > }, > [VPU_FMT_TYPE_RAW] = { > { > .v4l2_pix_fmt = V4L2_PIX_FMT_YUV420, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV12, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV21, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_YUV420M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV12M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV21M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, > - .max_width = 8192, > - .min_width = 8, > - .max_height = 4320, > - .min_height = 8, > + .v4l2_frmsize = &dec_raw_frmsize, > }, > } > }; > @@ -234,74 +215,6 @@ static void wave5_handle_src_buffer(struct vpu_instance *inst, dma_addr_t rd_ptr > inst->remaining_consumed_bytes = consumed_bytes; > } > > -static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned int width, > - unsigned int height) > -{ > - switch (pix_mp->pixelformat) { > - case V4L2_PIX_FMT_YUV420: > - case V4L2_PIX_FMT_NV12: > - case V4L2_PIX_FMT_NV21: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height * 3 / 2; > - break; > - case V4L2_PIX_FMT_YUV422P: > - case V4L2_PIX_FMT_NV16: > - case V4L2_PIX_FMT_NV61: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height * 2; > - break; > - case V4L2_PIX_FMT_YUV420M: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height; > - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32) / 2; > - pix_mp->plane_fmt[1].sizeimage = width * height / 4; > - pix_mp->plane_fmt[2].bytesperline = round_up(width, 32) / 2; > - pix_mp->plane_fmt[2].sizeimage = width * height / 4; > - break; > - case V4L2_PIX_FMT_NV12M: > - case V4L2_PIX_FMT_NV21M: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height; > - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[1].sizeimage = width * height / 2; > - break; > - case V4L2_PIX_FMT_YUV422M: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height; > - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32) / 2; > - pix_mp->plane_fmt[1].sizeimage = width * height / 2; > - pix_mp->plane_fmt[2].bytesperline = round_up(width, 32) / 2; > - pix_mp->plane_fmt[2].sizeimage = width * height / 2; > - break; > - case V4L2_PIX_FMT_NV16M: > - case V4L2_PIX_FMT_NV61M: > - pix_mp->width = round_up(width, 32); > - pix_mp->height = round_up(height, 16); > - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[0].sizeimage = width * height; > - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); > - pix_mp->plane_fmt[1].sizeimage = width * height; > - break; > - default: > - pix_mp->width = width; > - pix_mp->height = height; > - pix_mp->plane_fmt[0].bytesperline = 0; > - pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_SRC_SIZE(width, height), > - pix_mp->plane_fmt[0].sizeimage); > - break; > - } > -} > - > static int start_decode(struct vpu_instance *inst, u32 *fail_res) > { > struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx; > @@ -389,6 +302,8 @@ static int handle_dynamic_resolution_change(struct vpu_instance *inst) > } > > if (p_dec_info->initial_info_obtained) { > + const struct vpu_format *vpu_fmt; > + > inst->conf_win.left = initial_info->pic_crop_rect.left; > inst->conf_win.top = initial_info->pic_crop_rect.top; > inst->conf_win.width = initial_info->pic_width - > @@ -396,10 +311,27 @@ static int handle_dynamic_resolution_change(struct vpu_instance *inst) > inst->conf_win.height = initial_info->pic_height - > initial_info->pic_crop_rect.top - initial_info->pic_crop_rect.bottom; > > - wave5_update_pix_fmt(&inst->src_fmt, initial_info->pic_width, > - initial_info->pic_height); > - wave5_update_pix_fmt(&inst->dst_fmt, initial_info->pic_width, > - initial_info->pic_height); > + vpu_fmt = wave5_find_vpu_fmt(inst->src_fmt.pixelformat, > + dec_fmt_list[VPU_FMT_TYPE_CODEC]); > + if (!vpu_fmt) > + return -EINVAL; > + > + wave5_update_pix_fmt(&inst->src_fmt, > + VPU_FMT_TYPE_CODEC, > + initial_info->pic_width, > + initial_info->pic_height, > + vpu_fmt->v4l2_frmsize); > + > + vpu_fmt = wave5_find_vpu_fmt(inst->dst_fmt.pixelformat, > + dec_fmt_list[VPU_FMT_TYPE_RAW]); > + if (!vpu_fmt) > + return -EINVAL; > + > + wave5_update_pix_fmt(&inst->dst_fmt, > + VPU_FMT_TYPE_RAW, > + initial_info->pic_width, > + initial_info->pic_height, > + vpu_fmt->v4l2_frmsize); > } > > v4l2_event_queue_fh(fh, &vpu_event_src_ch); > @@ -545,15 +477,11 @@ static int wave5_vpu_dec_enum_framesizes(struct file *f, void *fh, struct v4l2_f > vpu_fmt = wave5_find_vpu_fmt(fsize->pixel_format, dec_fmt_list[VPU_FMT_TYPE_RAW]); > if (!vpu_fmt) > return -EINVAL; > + return -ENOTTY; Huh? Where does this come from? It wasn't part of v4, and it doesn't make sense either. It looks like a spurious test line that you forgot to remove. Regards, Hans > } > > fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; > - fsize->stepwise.min_width = vpu_fmt->min_width; > - fsize->stepwise.max_width = vpu_fmt->max_width; > - fsize->stepwise.step_width = 1; > - fsize->stepwise.min_height = vpu_fmt->min_height; > - fsize->stepwise.max_height = vpu_fmt->max_height; > - fsize->stepwise.step_height = 1; > + fsize->stepwise = *vpu_fmt->v4l2_frmsize; > > return 0; > } Regards, Hans