* [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block
@ 2026-11-29 17:42 Lin Huiyi
2026-12-01 12:42 ` Hans Verkuil
0 siblings, 1 reply; 4+ messages in thread
From: Lin Huiyi @ 2026-11-29 17:42 UTC (permalink / raw)
To: hugues.fruchet, alain.volmat
Cc: mchehab, mcoquelin.stm32, alexandre.torgue, linux-media,
linux-stm32, linux-arm-kernel, Lin Huiyi
The pixelproc subdev advertises a maximum width of
DCMIPP_FRAME_MAX_WIDTH (4096), but the downsize block target size
register DCMIPP_PxDSSZR stores the width in a 12-bit field
(GENMASK(11,0)) which can hold at most 4095. Composing a full
4096-pixel wide stream therefore writes 4096 into the register,
setting bit 12 outside of the HSIZE field and leaving the field
itself at 0.
Clamp the pixelproc width to the largest value the field can
represent (4095).
Fixes: 239cf9e5fda1 ("media: stm32: dcmipp: pixelproc: addition of dcmipp-pixelproc subdev")
Signed-off-by: Lin Huiyi <xinghui79@qq.com>
---
.../platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
index 7d8e5f0863..779c898793 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
@@ -455,8 +455,14 @@ dcmipp_pixelproc_adjust_fmt(struct dcmipp_pixelproc_device *pixelproc,
if (!vpix)
fmt->code = PIXELPROC_MEDIA_BUS_FMT_DEFAULT;
+ /*
+ * The downsize target size register DCMIPP_PxDSSZR stores the
+ * output width in a 12-bit field which can not hold
+ * DCMIPP_FRAME_MAX_WIDTH, clamp the width to the largest value
+ * the field can represent.
+ */
fmt->width = clamp_t(u32, fmt->width, DCMIPP_FRAME_MIN_WIDTH,
- DCMIPP_FRAME_MAX_WIDTH);
+ DCMIPP_PxDSSZR_HSIZE_MASK);
fmt->height = clamp_t(u32, fmt->height, DCMIPP_FRAME_MIN_HEIGHT,
DCMIPP_FRAME_MAX_HEIGHT);
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block
2026-11-29 17:42 [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block Lin Huiyi
@ 2026-12-01 12:42 ` Hans Verkuil
2026-12-02 8:40 ` Alain Volmat
0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2026-12-01 12:42 UTC (permalink / raw)
To: Lin Huiyi, hugues.fruchet, alain.volmat
Cc: mchehab, mcoquelin.stm32, alexandre.torgue, linux-media,
linux-stm32, linux-arm-kernel
Alain,
Can you review this? It sounds plausible, but someone with the datasheet should
verify this.
Regards,
Hans
On 29/11/2026 18:42, Lin Huiyi wrote:
> The pixelproc subdev advertises a maximum width of
> DCMIPP_FRAME_MAX_WIDTH (4096), but the downsize block target size
> register DCMIPP_PxDSSZR stores the width in a 12-bit field
> (GENMASK(11,0)) which can hold at most 4095. Composing a full
> 4096-pixel wide stream therefore writes 4096 into the register,
> setting bit 12 outside of the HSIZE field and leaving the field
> itself at 0.
>
> Clamp the pixelproc width to the largest value the field can
> represent (4095).
>
> Fixes: 239cf9e5fda1 ("media: stm32: dcmipp: pixelproc: addition of dcmipp-pixelproc subdev")
> Signed-off-by: Lin Huiyi <xinghui79@qq.com>
> ---
> .../platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> index 7d8e5f0863..779c898793 100644
> --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> @@ -455,8 +455,14 @@ dcmipp_pixelproc_adjust_fmt(struct dcmipp_pixelproc_device *pixelproc,
> if (!vpix)
> fmt->code = PIXELPROC_MEDIA_BUS_FMT_DEFAULT;
>
> + /*
> + * The downsize target size register DCMIPP_PxDSSZR stores the
> + * output width in a 12-bit field which can not hold
> + * DCMIPP_FRAME_MAX_WIDTH, clamp the width to the largest value
> + * the field can represent.
> + */
> fmt->width = clamp_t(u32, fmt->width, DCMIPP_FRAME_MIN_WIDTH,
> - DCMIPP_FRAME_MAX_WIDTH);
> + DCMIPP_PxDSSZR_HSIZE_MASK);
> fmt->height = clamp_t(u32, fmt->height, DCMIPP_FRAME_MIN_HEIGHT,
> DCMIPP_FRAME_MAX_HEIGHT);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block
2026-12-01 12:42 ` Hans Verkuil
@ 2026-12-02 8:40 ` Alain Volmat
2026-12-03 11:26 ` Hans Verkuil
0 siblings, 1 reply; 4+ messages in thread
From: Alain Volmat @ 2026-12-02 8:40 UTC (permalink / raw)
To: Hans Verkuil
Cc: Lin Huiyi, hugues.fruchet, mchehab, mcoquelin.stm32,
alexandre.torgue, linux-media, linux-stm32, linux-arm-kernel
Hi Hans,
On Tue, Dec 01, 2026 at 01:42:42PM +0100, Hans Verkuil wrote:
> Alain,
>
> Can you review this? It sounds plausible, but someone with the datasheet should
> verify this.
Indeed, 4096 is too big for this field. However 4095 is also too big
since the maximum value is 4094. As a matter of fact I have a downstream
kernel commit fixing that and have in my todo to push it but just haven't
done it yet since I am currently focusing on preparation of the ISP
statistics and control block upstreaming.
Regards,
Alain
>
> Regards,
>
> Hans
>
> On 29/11/2026 18:42, Lin Huiyi wrote:
> > The pixelproc subdev advertises a maximum width of
> > DCMIPP_FRAME_MAX_WIDTH (4096), but the downsize block target size
> > register DCMIPP_PxDSSZR stores the width in a 12-bit field
> > (GENMASK(11,0)) which can hold at most 4095. Composing a full
> > 4096-pixel wide stream therefore writes 4096 into the register,
> > setting bit 12 outside of the HSIZE field and leaving the field
> > itself at 0.
> >
> > Clamp the pixelproc width to the largest value the field can
> > represent (4095).
> >
> > Fixes: 239cf9e5fda1 ("media: stm32: dcmipp: pixelproc: addition of dcmipp-pixelproc subdev")
> > Signed-off-by: Lin Huiyi <xinghui79@qq.com>
> > ---
> > .../platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> > index 7d8e5f0863..779c898793 100644
> > --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> > +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
> > @@ -455,8 +455,14 @@ dcmipp_pixelproc_adjust_fmt(struct dcmipp_pixelproc_device *pixelproc,
> > if (!vpix)
> > fmt->code = PIXELPROC_MEDIA_BUS_FMT_DEFAULT;
> >
> > + /*
> > + * The downsize target size register DCMIPP_PxDSSZR stores the
> > + * output width in a 12-bit field which can not hold
> > + * DCMIPP_FRAME_MAX_WIDTH, clamp the width to the largest value
> > + * the field can represent.
> > + */
> > fmt->width = clamp_t(u32, fmt->width, DCMIPP_FRAME_MIN_WIDTH,
> > - DCMIPP_FRAME_MAX_WIDTH);
> > + DCMIPP_PxDSSZR_HSIZE_MASK);
> > fmt->height = clamp_t(u32, fmt->height, DCMIPP_FRAME_MIN_HEIGHT,
> > DCMIPP_FRAME_MAX_HEIGHT);
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block
2026-12-02 8:40 ` Alain Volmat
@ 2026-12-03 11:26 ` Hans Verkuil
0 siblings, 0 replies; 4+ messages in thread
From: Hans Verkuil @ 2026-12-03 11:26 UTC (permalink / raw)
To: Alain Volmat
Cc: Lin Huiyi, hugues.fruchet, mchehab, mcoquelin.stm32,
alexandre.torgue, linux-media, linux-stm32, linux-arm-kernel
On 02/12/2026 09:40, Alain Volmat wrote:
> Hi Hans,
>
> On Tue, Dec 01, 2026 at 01:42:42PM +0100, Hans Verkuil wrote:
>> Alain,
>>
>> Can you review this? It sounds plausible, but someone with the datasheet should
>> verify this.
>
> Indeed, 4096 is too big for this field. However 4095 is also too big
> since the maximum value is 4094. As a matter of fact I have a downstream
> kernel commit fixing that and have in my todo to push it but just haven't
> done it yet since I am currently focusing on preparation of the ISP
> statistics and control block upstreaming.
OK, in that case I'll drop this patch and wait for your patch.
Regards,
Hans
>
> Regards,
> Alain
>
>>
>> Regards,
>>
>> Hans
>>
>> On 29/11/2026 18:42, Lin Huiyi wrote:
>>> The pixelproc subdev advertises a maximum width of
>>> DCMIPP_FRAME_MAX_WIDTH (4096), but the downsize block target size
>>> register DCMIPP_PxDSSZR stores the width in a 12-bit field
>>> (GENMASK(11,0)) which can hold at most 4095. Composing a full
>>> 4096-pixel wide stream therefore writes 4096 into the register,
>>> setting bit 12 outside of the HSIZE field and leaving the field
>>> itself at 0.
>>>
>>> Clamp the pixelproc width to the largest value the field can
>>> represent (4095).
>>>
>>> Fixes: 239cf9e5fda1 ("media: stm32: dcmipp: pixelproc: addition of dcmipp-pixelproc subdev")
>>> Signed-off-by: Lin Huiyi <xinghui79@qq.com>
>>> ---
>>> .../platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c | 8 +++++++-
>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
>>> index 7d8e5f0863..779c898793 100644
>>> --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
>>> +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
>>> @@ -455,8 +455,14 @@ dcmipp_pixelproc_adjust_fmt(struct dcmipp_pixelproc_device *pixelproc,
>>> if (!vpix)
>>> fmt->code = PIXELPROC_MEDIA_BUS_FMT_DEFAULT;
>>>
>>> + /*
>>> + * The downsize target size register DCMIPP_PxDSSZR stores the
>>> + * output width in a 12-bit field which can not hold
>>> + * DCMIPP_FRAME_MAX_WIDTH, clamp the width to the largest value
>>> + * the field can represent.
>>> + */
>>> fmt->width = clamp_t(u32, fmt->width, DCMIPP_FRAME_MIN_WIDTH,
>>> - DCMIPP_FRAME_MAX_WIDTH);
>>> + DCMIPP_PxDSSZR_HSIZE_MASK);
>>> fmt->height = clamp_t(u32, fmt->height, DCMIPP_FRAME_MIN_HEIGHT,
>>> DCMIPP_FRAME_MAX_HEIGHT);
>>>
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 17:42 [PATCH] media: stm32: dcmipp: pixelproc: Fix width limit for downsize block Lin Huiyi
2026-12-01 12:42 ` Hans Verkuil
2026-12-02 8:40 ` Alain Volmat
2026-12-03 11:26 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox