Skip to contentSkip to conversation

drm/atmel-hlcdc: don't reject the commit if the src rect has fractional parts

PATCH Applied Ludovic Desroches 2 participants 3 messages Nov 20, 2025 – Jan 21

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atmel-hlcdc: don't reject the commit if the src rect has fractional parts

Don’t reject the commit when the source rectangle has fractional parts. This can occur due to scaling: drm_atomic_helper_check_plane_state() calls drm_rect_clip_scaled(), which may introduce fractional parts while computing the clipped source rectangle. This does not imply the commit is invalid, so we should accept it instead of discarding it.

---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +4 -15
index 92132be9823f1e705d266f9547702ea9530bd043..bccfe055c087e5632d60503e8e4bcb3d9e18ce50 100644
@@ -79,8 +79,6 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)
 	return container_of(s, struct atmel_hlcdc_plane_state, base);
 }
 
-#define SUBPIXEL_MASK			0xffff
-
 static uint32_t rgb_formats[] = {
 	DRM_FORMAT_C8,
 	DRM_FORMAT_XRGB4444,
@@ -745,24 +743,15 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 	if (ret || !s->visible)
 		return ret;
 
-	hstate->src_x = s->src.x1;
-	hstate->src_y = s->src.y1;
-	hstate->src_w = drm_rect_width(&s->src);
-	hstate->src_h = drm_rect_height(&s->src);
+	hstate->src_x = s->src.x1 >> 16;
+	hstate->src_y = s->src.y1 >> 16;
+	hstate->src_w = drm_rect_width(&s->src) >> 16;
+	hstate->src_h = drm_rect_height(&s->src) >> 16;
 	hstate->crtc_x = s->dst.x1;
 	hstate->crtc_y = s->dst.y1;
 	hstate->crtc_w = drm_rect_width(&s->dst);
 	hstate->crtc_h = drm_rect_height(&s->dst);
 
-	if ((hstate->src_x | hstate->src_y | hstate->src_w | hstate->src_h) &
-	    SUBPIXEL_MASK)
-		return -EINVAL;
-
-	hstate->src_x >>= 16;
-	hstate->src_y >>= 16;
-	hstate->src_w >>= 16;
-	hstate->src_h >>= 16;
-
 	hstate->nplanes = fb->format->num_planes;
 	if (hstate->nplanes > ATMEL_HLCDC_LAYER_MAX_PLANES)
 		return -EINVAL;

---
base-commit: fe4d0dea039f2befb93f27569593ec209843b0f5
change-id: 20251119-lcd_scaling_fix-a4842d86307c

Best regards,

Signature · 1 line
Ludovic Desroches <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Ludovic Desroches

Don’t reject the commit when the source rectangle has fractional parts. This can occur due to scaling: drm_atomic_helper_check_plane_state() calls drm_rect_clip_scaled(), which may introduce fractional parts while computing the clipped source rectangle. This does not imply the commit is invalid, so we should accept it instead of discarding it.

Thanks Ludovic.

Quoted 52 lines
---
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 19 ++++---------------
  1 file changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +4 -16
index 92132be9823f1e705d266f9547702ea9530bd043..bccfe055c087e5632d60503e8e4bcb3d9e18ce50 100644
@@ -79,8 +79,6 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)
  	return container_of(s, struct atmel_hlcdc_plane_state, base);
  }
 
-#define SUBPIXEL_MASK			0xffff
-
  static uint32_t rgb_formats[] = {
  	DRM_FORMAT_C8,
  	DRM_FORMAT_XRGB4444,
@@ -745,24 +743,15 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
  	if (ret || !s->visible)
  		return ret;
 
-	hstate->src_x = s->src.x1;
-	hstate->src_y = s->src.y1;
-	hstate->src_w = drm_rect_width(&s->src);
-	hstate->src_h = drm_rect_height(&s->src);
+	hstate->src_x = s->src.x1 >> 16;
+	hstate->src_y = s->src.y1 >> 16;
+	hstate->src_w = drm_rect_width(&s->src) >> 16;
+	hstate->src_h = drm_rect_height(&s->src) >> 16;
  	hstate->crtc_x = s->dst.x1;
  	hstate->crtc_y = s->dst.y1;
  	hstate->crtc_w = drm_rect_width(&s->dst);
  	hstate->crtc_h = drm_rect_height(&s->dst);
 
-	if ((hstate->src_x | hstate->src_y | hstate->src_w | hstate->src_h) &
-	    SUBPIXEL_MASK)
-		return -EINVAL;
-
-	hstate->src_x >>= 16;
-	hstate->src_y >>= 16;
-	hstate->src_w >>= 16;
-	hstate->src_h >>= 16;
-
  	hstate->nplanes = fb->format->num_planes;
  	if (hstate->nplanes > ATMEL_HLCDC_LAYER_MAX_PLANES)
  		return -EINVAL;
 
---

base-commit: fe4d0dea039f2befb93f27569593ec209843b0f5
change-id: 20251119-lcd_scaling_fix-a4842d86307c

Best regards,

Signature · 2 lines
Thanks and Regards,
Manikandan M.
maintainer Applied
#2 lore raw
In reply to Ludovic Desroches
Quoted 7 lines · Ludovic Desroches

Don’t reject the commit when the source rectangle has fractional parts. This can occur due to scaling: drm_atomic_helper_check_plane_state() calls drm_rect_clip_scaled(), which may introduce fractional parts while computing the clipped source rectangle. This does not imply the commit is invalid, so we should accept it instead of discarding it.

Applied to drm-misc-next.

Thanks!

Quoted 52 lines
---
  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 19 ++++---------------
  1 file changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +4 -16
index 92132be9823f1e705d266f9547702ea9530bd043..bccfe055c087e5632d60503e8e4bcb3d9e18ce50 100644
@@ -79,8 +79,6 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s)
  	return container_of(s, struct atmel_hlcdc_plane_state, base);
  }
 
-#define SUBPIXEL_MASK			0xffff
-
  static uint32_t rgb_formats[] = {
  	DRM_FORMAT_C8,
  	DRM_FORMAT_XRGB4444,
@@ -745,24 +743,15 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
  	if (ret || !s->visible)
  		return ret;
 
-	hstate->src_x = s->src.x1;
-	hstate->src_y = s->src.y1;
-	hstate->src_w = drm_rect_width(&s->src);
-	hstate->src_h = drm_rect_height(&s->src);
+	hstate->src_x = s->src.x1 >> 16;
+	hstate->src_y = s->src.y1 >> 16;
+	hstate->src_w = drm_rect_width(&s->src) >> 16;
+	hstate->src_h = drm_rect_height(&s->src) >> 16;
  	hstate->crtc_x = s->dst.x1;
  	hstate->crtc_y = s->dst.y1;
  	hstate->crtc_w = drm_rect_width(&s->dst);
  	hstate->crtc_h = drm_rect_height(&s->dst);
 
-	if ((hstate->src_x | hstate->src_y | hstate->src_w | hstate->src_h) &
-	    SUBPIXEL_MASK)
-		return -EINVAL;
-
-	hstate->src_x >>= 16;
-	hstate->src_y >>= 16;
-	hstate->src_w >>= 16;
-	hstate->src_h >>= 16;
-
  	hstate->nplanes = fb->format->num_planes;
  	if (hstate->nplanes > ATMEL_HLCDC_LAYER_MAX_PLANES)
  		return -EINVAL;
 
---

base-commit: fe4d0dea039f2befb93f27569593ec209843b0f5
change-id: 20251119-lcd_scaling_fix-a4842d86307c

Best regards,

Signature · 2 lines
Thanks and Regards,
Manikandan M.