Skip to contentSkip to conversation

atmel-lcdc: Fix pixclock upper bound detection

PATCH In review Ben Nizette 2 participants 2 messages May 10, 2009 – May 12, 2009

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

PATCH 1/1 atmel-lcdc: Fix pixclock upper bound detection

AFAICT the code which checks that the requested pixclock value is within bounds is incorrect. It ensures that the lcdc core clock is at least (bytes per pixel) times higher than the pixel clock rather than just greater than or equal to.

There are tighter restrictions on the pixclock value as a function of bus width for STN panels but even then it isn't a simple relationship as currently checked for. IMO either something like the below patch should be applied or else more detailed checking logic should be implemented which takes in to account the panel type as well.

CMIIW :-)

---

drivers/video/atmel_lcdfb.c +1 -1
index 9a577a8..5779641 100644
@@ -351,7 +351,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
 	dev_dbg(dev, "  bpp:        %u\n", var->bits_per_pixel);
 	dev_dbg(dev, "  clk:        %lu KHz\n", clk_value_khz);
 
-	if ((PICOS2KHZ(var->pixclock) * var->bits_per_pixel / 8) > clk_value_khz) {
+	if (PICOS2KHZ(var->pixclock) > clk_value_khz) {
 		dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock));
 		return -EINVAL;
 	}
Acked-by on v1 1/1
#1 lore raw

Ben Nizette :

Quoted 11 lines

AFAICT the code which checks that the requested pixclock value is within bounds is incorrect. It ensures that the lcdc core clock is at least (bytes per pixel) times higher than the pixel clock rather than just greater than or equal to.

There are tighter restrictions on the pixclock value as a function of bus width for STN panels but even then it isn't a simple relationship as currently checked for. IMO either something like the below patch should be applied or else more detailed checking logic should be implemented which takes in to account the panel type as well.

Quoted 3 lines

CMIIW :-)

Quoted 17 lines

---

drivers/video/atmel_lcdfb.c +1 -1
index 9a577a8..5779641 100644
@@ -351,7 +351,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
 	dev_dbg(dev, "  bpp:        %u\n", var->bits_per_pixel);
 	dev_dbg(dev, "  clk:        %lu KHz\n", clk_value_khz);
 
-	if ((PICOS2KHZ(var->pixclock) * var->bits_per_pixel / 8) > clk_value_khz) {
+	if (PICOS2KHZ(var->pixclock) > clk_value_khz) {
 		dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock));
 		return -EINVAL;
 	}
Signature · 1 line
Nicolas Ferre