Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ARM] pxafb: cleanup of the timing checking code

Signed-off-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Eric Miao <ycmiao@ycmiao-hp520.(none)>

authored by

Eric Miao and committed by
Eric Miao
3f16ff60 878f5783

+50 -64
+44 -64
drivers/video/pxafb.c
··· 391 391 pxafb_set_pixfmt(var, mode->depth); 392 392 } 393 393 394 + static int pxafb_adjust_timing(struct pxafb_info *fbi, 395 + struct fb_var_screeninfo *var) 396 + { 397 + int line_length; 398 + 399 + var->xres = max_t(int, var->xres, MIN_XRES); 400 + var->yres = max_t(int, var->yres, MIN_YRES); 401 + 402 + if (!(fbi->lccr0 & LCCR0_LCDT)) { 403 + clamp_val(var->hsync_len, 1, 64); 404 + clamp_val(var->vsync_len, 1, 64); 405 + clamp_val(var->left_margin, 1, 255); 406 + clamp_val(var->right_margin, 1, 255); 407 + clamp_val(var->upper_margin, 1, 255); 408 + clamp_val(var->lower_margin, 1, 255); 409 + } 410 + 411 + /* make sure each line is aligned on word boundary */ 412 + line_length = var->xres * var->bits_per_pixel / 8; 413 + line_length = ALIGN(line_length, 4); 414 + var->xres = line_length * 8 / var->bits_per_pixel; 415 + 416 + /* we don't support xpan, force xres_virtual to be equal to xres */ 417 + var->xres_virtual = var->xres; 418 + 419 + if (var->accel_flags & FB_ACCELF_TEXT) 420 + var->yres_virtual = fbi->fb.fix.smem_len / line_length; 421 + else 422 + var->yres_virtual = max(var->yres_virtual, var->yres); 423 + 424 + /* check for limits */ 425 + if (var->xres > MAX_XRES || var->yres > MAX_YRES) 426 + return -EINVAL; 427 + 428 + if (var->yres > var->yres_virtual) 429 + return -EINVAL; 430 + 431 + return 0; 432 + } 433 + 394 434 /* 395 435 * pxafb_check_var(): 396 436 * Get the video params out of 'var'. If a value doesn't fit, round it up, ··· 446 406 struct pxafb_mach_info *inf = fbi->dev->platform_data; 447 407 int err; 448 408 449 - if (var->xres < MIN_XRES) 450 - var->xres = MIN_XRES; 451 - if (var->yres < MIN_YRES) 452 - var->yres = MIN_YRES; 453 - 454 409 if (inf->fixed_modes) { 455 410 struct pxafb_mode_info *mode; 456 411 ··· 453 418 if (!mode) 454 419 return -EINVAL; 455 420 pxafb_setmode(var, mode); 456 - } else { 457 - if (var->xres > inf->modes->xres) 458 - return -EINVAL; 459 - if (var->yres > inf->modes->yres) 460 - return -EINVAL; 461 - if (var->bits_per_pixel > inf->modes->bpp) 462 - return -EINVAL; 463 421 } 464 - 465 - /* we don't support xpan, force xres_virtual to be equal to xres */ 466 - var->xres_virtual = var->xres; 467 - 468 - if (var->accel_flags & FB_ACCELF_TEXT) 469 - var->yres_virtual = fbi->fb.fix.smem_len / 470 - (var->xres_virtual * var->bits_per_pixel / 8); 471 - else 472 - var->yres_virtual = max(var->yres_virtual, var->yres); 473 422 474 423 /* do a test conversion to BPP fields to check the color formats */ 475 424 err = pxafb_var_to_bpp(var); ··· 461 442 return err; 462 443 463 444 pxafb_set_pixfmt(var, var_to_depth(var)); 445 + 446 + err = pxafb_adjust_timing(fbi, var); 447 + if (err) 448 + return err; 464 449 465 450 #ifdef CONFIG_CPU_FREQ 466 451 pr_debug("pxafb: dma period = %d ps\n", ··· 971 948 { 972 949 u_long flags; 973 950 974 - #if DEBUG_VAR 975 - if (!(fbi->lccr0 & LCCR0_LCDT)) { 976 - if (var->xres < 16 || var->xres > 1024) 977 - printk(KERN_ERR "%s: invalid xres %d\n", 978 - fbi->fb.fix.id, var->xres); 979 - switch (var->bits_per_pixel) { 980 - case 1: 981 - case 2: 982 - case 4: 983 - case 8: 984 - case 16: 985 - case 24: 986 - case 32: 987 - break; 988 - default: 989 - printk(KERN_ERR "%s: invalid bit depth %d\n", 990 - fbi->fb.fix.id, var->bits_per_pixel); 991 - break; 992 - } 993 - 994 - if (var->hsync_len < 1 || var->hsync_len > 64) 995 - printk(KERN_ERR "%s: invalid hsync_len %d\n", 996 - fbi->fb.fix.id, var->hsync_len); 997 - if (var->left_margin < 1 || var->left_margin > 255) 998 - printk(KERN_ERR "%s: invalid left_margin %d\n", 999 - fbi->fb.fix.id, var->left_margin); 1000 - if (var->right_margin < 1 || var->right_margin > 255) 1001 - printk(KERN_ERR "%s: invalid right_margin %d\n", 1002 - fbi->fb.fix.id, var->right_margin); 1003 - if (var->yres < 1 || var->yres > 1024) 1004 - printk(KERN_ERR "%s: invalid yres %d\n", 1005 - fbi->fb.fix.id, var->yres); 1006 - if (var->vsync_len < 1 || var->vsync_len > 64) 1007 - printk(KERN_ERR "%s: invalid vsync_len %d\n", 1008 - fbi->fb.fix.id, var->vsync_len); 1009 - if (var->upper_margin < 0 || var->upper_margin > 255) 1010 - printk(KERN_ERR "%s: invalid upper_margin %d\n", 1011 - fbi->fb.fix.id, var->upper_margin); 1012 - if (var->lower_margin < 0 || var->lower_margin > 255) 1013 - printk(KERN_ERR "%s: invalid lower_margin %d\n", 1014 - fbi->fb.fix.id, var->lower_margin); 1015 - } 1016 - #endif 1017 951 /* Update shadow copy atomically */ 1018 952 local_irq_save(flags); 1019 953
+6
drivers/video/pxafb.h
··· 145 145 #define MIN_XRES 64 146 146 #define MIN_YRES 64 147 147 148 + /* maximum X and Y resolutions - note these are limits from the register 149 + * bits length instead of the real ones 150 + */ 151 + #define MAX_XRES 1024 152 + #define MAX_YRES 1024 153 + 148 154 #endif /* __PXAFB_H__ */