public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: "Yunfei Dong (董云飞)" <Yunfei.Dong@mediatek.com>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"Tiffany Lin (林慧珊)" <tiffany.lin@mediatek.com>,
	"nicolas@ndufresne.ca" <nicolas@ndufresne.ca>,
	"benjamin.gaignard@collabora.com"
	<benjamin.gaignard@collabora.com>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>
Cc: "Xiaoyong Lu (卢小勇)" <Xiaoyong.Lu@mediatek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"George Sun (孙林)" <George.Sun@mediatek.com>,
	"frkoenig@chromium.org" <frkoenig@chromium.org>,
	"stevecho@chromium.org" <stevecho@chromium.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"hsinyi@chromium.org" <hsinyi@chromium.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Subject: Re: [PATCH v2] media: mediatek: vcodec: fix h264 cavlc bitstream fail
Date: Tue, 15 Nov 2022 09:48:38 +0100	[thread overview]
Message-ID: <75d967f0-f200-da86-868d-7f85a56371aa@collabora.com> (raw)
In-Reply-To: <2d7212e96ca2b80934cc5b53300f46e0454085a3.camel@mediatek.com>

Il 15/11/22 03:00, Yunfei Dong (董云飞) ha scritto:
> Hi AngeloGioacchino,
> 
> Thanks for your detail suggestion.
> On Mon, 2022-11-14 at 12:08 +0100, AngeloGioacchino Del Regno wrote:
>> Il 18/10/22 13:41, Yunfei Dong ha scritto:
>>> Some cavlc bistream will decode fail when the frame size is small
>>> than
>>
>> s/small/smaller/g
> 
> Will fix in next patch.
>>
>>> 20 bytes. Need to add pending data at the end of the bitstream.
>>>
>>> For the minimum size of mapped memory is 256 bytes(16x16), adding
>>> four bytes data
>>> won't lead to access unknown virtual memory.
>>>
>>> Fixes: 59fba9eed5a7 ("media: mediatek: vcodec: support stateless
>>> H.264 decoding for mt8192")
>>> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
>>> ---
>>> compared with v1:
>>> - add detail comments for function: vdec_h264_insert_startcode.
>>> - re-write commit message.
>>> ---
>>>    .../vcodec/vdec/vdec_h264_req_multi_if.c      | 32
>>> +++++++++++++++++--
>>>    1 file changed, 29 insertions(+), 3 deletions(-)
>>>
>>> diff --git
>>> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
>>> f.c
>>> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
>>> f.c
>>> index 4cc92700692b..18e048755d11 100644
>>> ---
>>> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
>>> f.c
>>> +++
>>> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_i
>>> f.c
>>> @@ -539,6 +539,29 @@ static int vdec_h264_slice_core_decode(struct
>>> vdec_lat_buf *lat_buf)
>>>    	return 0;
>>>    }
>>>    
>>> +static void vdec_h264_insert_startcode(struct mtk_vcodec_dev
>>> *vcodec_dev, unsigned char *buf,
>>> +				       size_t *bs_size, struct
>>> mtk_h264_pps_param *pps)
>>> +{
>>> +	struct device *dev = &vcodec_dev->plat_dev->dev;
>>> +
>>> +	/* Need to add pending data at the end of bitstream when bs_sz
>>> is small than
>>> +	 * 20 bytes for cavlc bitstream, or lat will decode fail. This
>>> pending data is
>>> +	 * useful for mt8192 and mt8195 platform.
>>
>> What is the reason why other SoCs don't need this?
>>
> For the hardware not add this feature, and will add in the future Soc.
>>> +	 *
>>> +	 * cavlc bitstream when entropy_coding_mode_flag is false.
>>> +	 */
>>> +	if (pps->entropy_coding_mode_flag || *bs_size > 20 ||
>>> +	    !(of_device_is_compatible(dev->of_node, "mediatek,mt8192-
>>> vcodec-dec") ||
>>> +	    of_device_is_compatible(dev->of_node, "mediatek,mt8195-
>>> vcodec-dec")))
>>
>> I'm not comfortable seeing of_device_is_compatible... this list will
>> grow whenever
>> a new SoC needing this appears.
>> Please think about a good name for a flag/quirk, or a bool, in the
>> platform data
>> for these two SoCs and use it.
>>
> For this feature only need to add in these two Socs, and won't grow
> anymore. So just want to use compatible to separate, not add one flags.
> 
> So you think that using one flag to separate much better?
> 

A flag is better: please remember that calls to of_device_is_compatible()
will perform a string comparison which, as you know, as much optimized as
it can be, it's always going to be slower than a simple integer/bool/flag
check.

This means that even for functional (not just cosmetic) reasons we should
not use of_device_is_compatible() here :-)

Cheers,
Angelo




  reply	other threads:[~2022-11-15  8:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 11:41 [PATCH v2] media: mediatek: vcodec: fix h264 cavlc bitstream fail Yunfei Dong
2022-11-14  6:12 ` Chen-Yu Tsai
2022-11-14 11:08 ` AngeloGioacchino Del Regno
2022-11-15  2:00   ` Yunfei Dong (董云飞)
2022-11-15  8:48     ` AngeloGioacchino Del Regno [this message]
2022-11-16  5:54   ` Yunfei Dong (董云飞)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75d967f0-f200-da86-868d-7f85a56371aa@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=George.Sun@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Xiaoyong.Lu@mediatek.com \
    --cc=Yunfei.Dong@mediatek.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=frkoenig@chromium.org \
    --cc=hsinyi@chromium.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=stevecho@chromium.org \
    --cc=tiffany.lin@mediatek.com \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox