Commit d4b766a0bdab8d07b720c8d0a84292949a7d58bd

Authored by Ondrej Zajicek
Committed by Linus Torvalds
1 parent d7dd91ff23

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>

Showing 2 changed files with 38 additions and 18 deletions Side-by-side Diff

drivers/video/s3fb.c
... ... @@ -403,8 +403,13 @@
403 403  
404 404 /* Find appropriate format */
405 405 rv = svga_match_format (s3fb_formats, var, NULL);
406   - if ((rv < 0) || ((par->chip == CHIP_988_VIRGE_VX) ? (rv == 7) : (rv == 6)))
407   - { /* 24bpp on VIRGE VX, 32bpp on others */
  406 +
  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 413 printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node);
409 414 return rv;
410 415 }
drivers/video/svgalib.c
... ... @@ -598,9 +598,11 @@
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 604 int i = 0;
  605 + int stored = -EINVAL;
604 606  
605 607 while (frm->bits_per_pixel != SVGA_FORMAT_END_VAL)
606 608 {
607 609  
608 610  
... ... @@ -609,25 +611,38 @@
609 611 (var->green.length <= frm->green.length) &&
610 612 (var->blue.length <= frm->blue.length) &&
611 613 (var->transp.length <= frm->transp.length) &&
612   - (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   - }
  614 + (var->nonstd == frm->nonstd))
625 615 return i;
626   - }
  616 + if (var->bits_per_pixel == frm->bits_per_pixel)
  617 + stored = i;
627 618 i++;
628 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