diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2007-10-16 04:29:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:22 -0400 |
commit | d4b766a0bdab8d07b720c8d0a84292949a7d58bd (patch) | |
tree | 995e1dc7b1f0c172c4f53acad3a236138d378ce2 | |
parent | d7dd91ff236b90a8aca2d619554b07bcb82953c7 (diff) |
svgalib: mode selection updates
This patch changes mode selection matching algorithm. It allows to choose
mode with matching depth even when requested color lengths are greater than
color lengths of every mode with requested color depth.
It also fixes bug in s3fb - wrong error value returned when format is not
supported by chip.
Signed-off-by: Ondrej Zajicek <santiago@crfreenet.org>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/video/s3fb.c | 9 | ||||
-rw-r--r-- | drivers/video/svgalib.c | 47 |
2 files changed, 38 insertions, 18 deletions
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c index d11735895a01..a96ac4392173 100644 --- a/drivers/video/s3fb.c +++ b/drivers/video/s3fb.c | |||
@@ -403,8 +403,13 @@ static int s3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
403 | 403 | ||
404 | /* Find appropriate format */ | 404 | /* Find appropriate format */ |
405 | rv = svga_match_format (s3fb_formats, var, NULL); | 405 | rv = svga_match_format (s3fb_formats, var, NULL); |
406 | if ((rv < 0) || ((par->chip == CHIP_988_VIRGE_VX) ? (rv == 7) : (rv == 6))) | 406 | |
407 | { /* 24bpp on VIRGE VX, 32bpp on others */ | 407 | /* 32bpp mode is not supported on VIRGE VX, |
408 | 24bpp is not supported on others */ | ||
409 | if ((par->chip == CHIP_988_VIRGE_VX) ? (rv == 7) : (rv == 6)) | ||
410 | rv = -EINVAL; | ||
411 | |||
412 | if (rv < 0) { | ||
408 | printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node); | 413 | printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node); |
409 | return rv; | 414 | return rv; |
410 | } | 415 | } |
diff --git a/drivers/video/svgalib.c b/drivers/video/svgalib.c index 25df928d37d8..9c7106701572 100644 --- a/drivers/video/svgalib.c +++ b/drivers/video/svgalib.c | |||
@@ -598,9 +598,11 @@ void svga_set_timings(const struct svga_timing_regs *tm, struct fb_var_screeninf | |||
598 | /* ------------------------------------------------------------------------- */ | 598 | /* ------------------------------------------------------------------------- */ |
599 | 599 | ||
600 | 600 | ||
601 | int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix) | 601 | static inline int match_format(const struct svga_fb_format *frm, |
602 | struct fb_var_screeninfo *var) | ||
602 | { | 603 | { |
603 | int i = 0; | 604 | int i = 0; |
605 | int stored = -EINVAL; | ||
604 | 606 | ||
605 | while (frm->bits_per_pixel != SVGA_FORMAT_END_VAL) | 607 | while (frm->bits_per_pixel != SVGA_FORMAT_END_VAL) |
606 | { | 608 | { |
@@ -609,25 +611,38 @@ int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo | |||
609 | (var->green.length <= frm->green.length) && | 611 | (var->green.length <= frm->green.length) && |
610 | (var->blue.length <= frm->blue.length) && | 612 | (var->blue.length <= frm->blue.length) && |
611 | (var->transp.length <= frm->transp.length) && | 613 | (var->transp.length <= frm->transp.length) && |
612 | (var->nonstd == frm->nonstd)) { | 614 | (var->nonstd == frm->nonstd)) |
613 | var->bits_per_pixel = frm->bits_per_pixel; | ||
614 | var->red = frm->red; | ||
615 | var->green = frm->green; | ||
616 | var->blue = frm->blue; | ||
617 | var->transp = frm->transp; | ||
618 | var->nonstd = frm->nonstd; | ||
619 | if (fix != NULL) { | ||
620 | fix->type = frm->type; | ||
621 | fix->type_aux = frm->type_aux; | ||
622 | fix->visual = frm->visual; | ||
623 | fix->xpanstep = frm->xpanstep; | ||
624 | } | ||
625 | return i; | 615 | return i; |
626 | } | 616 | if (var->bits_per_pixel == frm->bits_per_pixel) |
617 | stored = i; | ||
627 | i++; | 618 | i++; |
628 | frm++; | 619 | frm++; |
629 | } | 620 | } |
630 | return -EINVAL; | 621 | return stored; |
622 | } | ||
623 | |||
624 | int svga_match_format(const struct svga_fb_format *frm, | ||
625 | struct fb_var_screeninfo *var, | ||
626 | struct fb_fix_screeninfo *fix) | ||
627 | { | ||
628 | int i = match_format(frm, var); | ||
629 | |||
630 | if (i >= 0) { | ||
631 | var->bits_per_pixel = frm[i].bits_per_pixel; | ||
632 | var->red = frm[i].red; | ||
633 | var->green = frm[i].green; | ||
634 | var->blue = frm[i].blue; | ||
635 | var->transp = frm[i].transp; | ||
636 | var->nonstd = frm[i].nonstd; | ||
637 | if (fix != NULL) { | ||
638 | fix->type = frm[i].type; | ||
639 | fix->type_aux = frm[i].type_aux; | ||
640 | fix->visual = frm[i].visual; | ||
641 | fix->xpanstep = frm[i].xpanstep; | ||
642 | } | ||
643 | } | ||
644 | |||
645 | return i; | ||
631 | } | 646 | } |
632 | 647 | ||
633 | 648 | ||