diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2008-02-06 04:39:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:15 -0500 |
commit | 162b3a084904a1d6ef1553782b8573885d5f900b (patch) | |
tree | d525a8f16852d80175555d3e28c52fb1f7d98bc0 /drivers/video | |
parent | 529e55b6a57bda6df9e45eb268589efc70f63303 (diff) |
atmel_lcdfb: validate display timings
Setting a display timing parameter too high or too low may cause it to
wrap around and thus become completely wrong. Validate the timings in
atmel_lcdfb_check_var() and saturate to the highest or lowest possible
value if necessary.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/atmel_lcdfb.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index f8e711147501..5d22ea532e42 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -203,6 +203,26 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | |||
203 | var->transp.offset = var->transp.length = 0; | 203 | var->transp.offset = var->transp.length = 0; |
204 | var->xoffset = var->yoffset = 0; | 204 | var->xoffset = var->yoffset = 0; |
205 | 205 | ||
206 | /* Saturate vertical and horizontal timings at maximum values */ | ||
207 | var->vsync_len = min_t(u32, var->vsync_len, | ||
208 | (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1); | ||
209 | var->upper_margin = min_t(u32, var->upper_margin, | ||
210 | ATMEL_LCDC_VBP >> ATMEL_LCDC_VBP_OFFSET); | ||
211 | var->lower_margin = min_t(u32, var->lower_margin, | ||
212 | ATMEL_LCDC_VFP); | ||
213 | var->right_margin = min_t(u32, var->right_margin, | ||
214 | (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 1); | ||
215 | var->hsync_len = min_t(u32, var->hsync_len, | ||
216 | (ATMEL_LCDC_HPW >> ATMEL_LCDC_HPW_OFFSET) + 1); | ||
217 | var->left_margin = min_t(u32, var->left_margin, | ||
218 | ATMEL_LCDC_HBP + 1); | ||
219 | |||
220 | /* Some parameters can't be zero */ | ||
221 | var->vsync_len = max_t(u32, var->vsync_len, 1); | ||
222 | var->right_margin = max_t(u32, var->right_margin, 1); | ||
223 | var->hsync_len = max_t(u32, var->hsync_len, 1); | ||
224 | var->left_margin = max_t(u32, var->left_margin, 1); | ||
225 | |||
206 | switch (var->bits_per_pixel) { | 226 | switch (var->bits_per_pixel) { |
207 | case 1: | 227 | case 1: |
208 | case 2: | 228 | case 2: |