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

fbdev: fix indentation in modedb.c

Fix the incorrect indentation in functions fb_try_mode() and fb_find_mode().

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>

authored by

Timur Tabi and committed by
Florian Tobias Schandinat
f92d39e9 a67472ad

+221 -215
+221 -215
drivers/video/modedb.c
··· 491 491 static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info, 492 492 const struct fb_videomode *mode, unsigned int bpp) 493 493 { 494 - int err = 0; 494 + int err = 0; 495 495 496 - DPRINTK("Trying mode %s %dx%d-%d@%d\n", mode->name ? mode->name : "noname", 497 - mode->xres, mode->yres, bpp, mode->refresh); 498 - var->xres = mode->xres; 499 - var->yres = mode->yres; 500 - var->xres_virtual = mode->xres; 501 - var->yres_virtual = mode->yres; 502 - var->xoffset = 0; 503 - var->yoffset = 0; 504 - var->bits_per_pixel = bpp; 505 - var->activate |= FB_ACTIVATE_TEST; 506 - var->pixclock = mode->pixclock; 507 - var->left_margin = mode->left_margin; 508 - var->right_margin = mode->right_margin; 509 - var->upper_margin = mode->upper_margin; 510 - var->lower_margin = mode->lower_margin; 511 - var->hsync_len = mode->hsync_len; 512 - var->vsync_len = mode->vsync_len; 513 - var->sync = mode->sync; 514 - var->vmode = mode->vmode; 515 - if (info->fbops->fb_check_var) 516 - err = info->fbops->fb_check_var(var, info); 517 - var->activate &= ~FB_ACTIVATE_TEST; 518 - return err; 496 + DPRINTK("Trying mode %s %dx%d-%d@%d\n", 497 + mode->name ? mode->name : "noname", 498 + mode->xres, mode->yres, bpp, mode->refresh); 499 + var->xres = mode->xres; 500 + var->yres = mode->yres; 501 + var->xres_virtual = mode->xres; 502 + var->yres_virtual = mode->yres; 503 + var->xoffset = 0; 504 + var->yoffset = 0; 505 + var->bits_per_pixel = bpp; 506 + var->activate |= FB_ACTIVATE_TEST; 507 + var->pixclock = mode->pixclock; 508 + var->left_margin = mode->left_margin; 509 + var->right_margin = mode->right_margin; 510 + var->upper_margin = mode->upper_margin; 511 + var->lower_margin = mode->lower_margin; 512 + var->hsync_len = mode->hsync_len; 513 + var->vsync_len = mode->vsync_len; 514 + var->sync = mode->sync; 515 + var->vmode = mode->vmode; 516 + if (info->fbops->fb_check_var) 517 + err = info->fbops->fb_check_var(var, info); 518 + var->activate &= ~FB_ACTIVATE_TEST; 519 + return err; 519 520 } 520 521 521 522 /** 522 - * fb_find_mode - finds a valid video mode 523 - * @var: frame buffer user defined part of display 524 - * @info: frame buffer info structure 525 - * @mode_option: string video mode to find 526 - * @db: video mode database 527 - * @dbsize: size of @db 528 - * @default_mode: default video mode to fall back to 529 - * @default_bpp: default color depth in bits per pixel 523 + * fb_find_mode - finds a valid video mode 524 + * @var: frame buffer user defined part of display 525 + * @info: frame buffer info structure 526 + * @mode_option: string video mode to find 527 + * @db: video mode database 528 + * @dbsize: size of @db 529 + * @default_mode: default video mode to fall back to 530 + * @default_bpp: default color depth in bits per pixel 530 531 * 531 - * Finds a suitable video mode, starting with the specified mode 532 - * in @mode_option with fallback to @default_mode. If 533 - * @default_mode fails, all modes in the video mode database will 534 - * be tried. 532 + * Finds a suitable video mode, starting with the specified mode 533 + * in @mode_option with fallback to @default_mode. If 534 + * @default_mode fails, all modes in the video mode database will 535 + * be tried. 535 536 * 536 - * Valid mode specifiers for @mode_option: 537 + * Valid mode specifiers for @mode_option: 537 538 * 538 - * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or 539 - * <name>[-<bpp>][@<refresh>] 539 + * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or 540 + * <name>[-<bpp>][@<refresh>] 540 541 * 541 - * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and 542 - * <name> a string. 542 + * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and 543 + * <name> a string. 543 544 * 544 545 * If 'M' is present after yres (and before refresh/bpp if present), 545 546 * the function will compute the timings using VESA(tm) Coordinated ··· 552 551 * 553 552 * 1024x768MR-8@60m - Reduced blank with margins at 60Hz. 554 553 * 555 - * NOTE: The passed struct @var is _not_ cleared! This allows you 556 - * to supply values for e.g. the grayscale and accel_flags fields. 554 + * NOTE: The passed struct @var is _not_ cleared! This allows you 555 + * to supply values for e.g. the grayscale and accel_flags fields. 557 556 * 558 - * Returns zero for failure, 1 if using specified @mode_option, 559 - * 2 if using specified @mode_option with an ignored refresh rate, 560 - * 3 if default mode is used, 4 if fall back to any valid mode. 557 + * Returns zero for failure, 1 if using specified @mode_option, 558 + * 2 if using specified @mode_option with an ignored refresh rate, 559 + * 3 if default mode is used, 4 if fall back to any valid mode. 561 560 * 562 561 */ 563 562 ··· 567 566 const struct fb_videomode *default_mode, 568 567 unsigned int default_bpp) 569 568 { 570 - int i; 569 + int i; 571 570 572 - /* Set up defaults */ 573 - if (!db) { 574 - db = modedb; 575 - dbsize = ARRAY_SIZE(modedb); 576 - } 577 - 578 - if (!default_mode) 579 - default_mode = &db[0]; 580 - 581 - if (!default_bpp) 582 - default_bpp = 8; 583 - 584 - /* Did the user specify a video mode? */ 585 - if (!mode_option) 586 - mode_option = fb_mode_option; 587 - if (mode_option) { 588 - const char *name = mode_option; 589 - unsigned int namelen = strlen(name); 590 - int res_specified = 0, bpp_specified = 0, refresh_specified = 0; 591 - unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; 592 - int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; 593 - u32 best, diff, tdiff; 594 - 595 - for (i = namelen-1; i >= 0; i--) { 596 - switch (name[i]) { 597 - case '@': 598 - namelen = i; 599 - if (!refresh_specified && !bpp_specified && 600 - !yres_specified) { 601 - refresh = simple_strtol(&name[i+1], NULL, 10); 602 - refresh_specified = 1; 603 - if (cvt || rb) 604 - cvt = 0; 605 - } else 606 - goto done; 607 - break; 608 - case '-': 609 - namelen = i; 610 - if (!bpp_specified && !yres_specified) { 611 - bpp = simple_strtol(&name[i+1], NULL, 10); 612 - bpp_specified = 1; 613 - if (cvt || rb) 614 - cvt = 0; 615 - } else 616 - goto done; 617 - break; 618 - case 'x': 619 - if (!yres_specified) { 620 - yres = simple_strtol(&name[i+1], NULL, 10); 621 - yres_specified = 1; 622 - } else 623 - goto done; 624 - break; 625 - case '0' ... '9': 626 - break; 627 - case 'M': 628 - if (!yres_specified) 629 - cvt = 1; 630 - break; 631 - case 'R': 632 - if (!cvt) 633 - rb = 1; 634 - break; 635 - case 'm': 636 - if (!cvt) 637 - margins = 1; 638 - break; 639 - case 'i': 640 - if (!cvt) 641 - interlace = 1; 642 - break; 643 - default: 644 - goto done; 645 - } 646 - } 647 - if (i < 0 && yres_specified) { 648 - xres = simple_strtol(name, NULL, 10); 649 - res_specified = 1; 650 - } 651 - done: 652 - if (cvt) { 653 - struct fb_videomode cvt_mode; 654 - int ret; 655 - 656 - DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres, 657 - (refresh) ? refresh : 60, (rb) ? " reduced blanking" : 658 - "", (margins) ? " with margins" : "", (interlace) ? 659 - " interlaced" : ""); 660 - 661 - memset(&cvt_mode, 0, sizeof(cvt_mode)); 662 - cvt_mode.xres = xres; 663 - cvt_mode.yres = yres; 664 - cvt_mode.refresh = (refresh) ? refresh : 60; 665 - 666 - if (interlace) 667 - cvt_mode.vmode |= FB_VMODE_INTERLACED; 668 - else 669 - cvt_mode.vmode &= ~FB_VMODE_INTERLACED; 670 - 671 - ret = fb_find_mode_cvt(&cvt_mode, margins, rb); 672 - 673 - if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) { 674 - DPRINTK("modedb CVT: CVT mode ok\n"); 675 - return 1; 676 - } 677 - 678 - DPRINTK("CVT mode invalid, getting mode from database\n"); 571 + /* Set up defaults */ 572 + if (!db) { 573 + db = modedb; 574 + dbsize = ARRAY_SIZE(modedb); 679 575 } 680 576 681 - DPRINTK("Trying specified video mode%s %ix%i\n", 682 - refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); 577 + if (!default_mode) 578 + default_mode = &db[0]; 683 579 684 - if (!refresh_specified) { 685 - /* 686 - * If the caller has provided a custom mode database and a 687 - * valid monspecs structure, we look for the mode with the 688 - * highest refresh rate. Otherwise we play it safe it and 689 - * try to find a mode with a refresh rate closest to the 690 - * standard 60 Hz. 691 - */ 692 - if (db != modedb && 693 - info->monspecs.vfmin && info->monspecs.vfmax && 694 - info->monspecs.hfmin && info->monspecs.hfmax && 695 - info->monspecs.dclkmax) { 696 - refresh = 1000; 697 - } else { 698 - refresh = 60; 580 + if (!default_bpp) 581 + default_bpp = 8; 582 + 583 + /* Did the user specify a video mode? */ 584 + if (!mode_option) 585 + mode_option = fb_mode_option; 586 + if (mode_option) { 587 + const char *name = mode_option; 588 + unsigned int namelen = strlen(name); 589 + int res_specified = 0, bpp_specified = 0, refresh_specified = 0; 590 + unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; 591 + int yres_specified = 0, cvt = 0, rb = 0, interlace = 0; 592 + int margins = 0; 593 + u32 best, diff, tdiff; 594 + 595 + for (i = namelen-1; i >= 0; i--) { 596 + switch (name[i]) { 597 + case '@': 598 + namelen = i; 599 + if (!refresh_specified && !bpp_specified && 600 + !yres_specified) { 601 + refresh = simple_strtol(&name[i+1], NULL, 602 + 10); 603 + refresh_specified = 1; 604 + if (cvt || rb) 605 + cvt = 0; 606 + } else 607 + goto done; 608 + break; 609 + case '-': 610 + namelen = i; 611 + if (!bpp_specified && !yres_specified) { 612 + bpp = simple_strtol(&name[i+1], NULL, 613 + 10); 614 + bpp_specified = 1; 615 + if (cvt || rb) 616 + cvt = 0; 617 + } else 618 + goto done; 619 + break; 620 + case 'x': 621 + if (!yres_specified) { 622 + yres = simple_strtol(&name[i+1], NULL, 623 + 10); 624 + yres_specified = 1; 625 + } else 626 + goto done; 627 + break; 628 + case '0' ... '9': 629 + break; 630 + case 'M': 631 + if (!yres_specified) 632 + cvt = 1; 633 + break; 634 + case 'R': 635 + if (!cvt) 636 + rb = 1; 637 + break; 638 + case 'm': 639 + if (!cvt) 640 + margins = 1; 641 + break; 642 + case 'i': 643 + if (!cvt) 644 + interlace = 1; 645 + break; 646 + default: 647 + goto done; 648 + } 699 649 } 700 - } 650 + if (i < 0 && yres_specified) { 651 + xres = simple_strtol(name, NULL, 10); 652 + res_specified = 1; 653 + } 654 + done: 655 + if (cvt) { 656 + struct fb_videomode cvt_mode; 657 + int ret; 701 658 702 - diff = -1; 703 - best = -1; 704 - for (i = 0; i < dbsize; i++) { 705 - if ((name_matches(db[i], name, namelen) || 706 - (res_specified && res_matches(db[i], xres, yres))) && 707 - !fb_try_mode(var, info, &db[i], bpp)) { 708 - if (refresh_specified && db[i].refresh == refresh) { 659 + DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres, 660 + (refresh) ? refresh : 60, 661 + (rb) ? " reduced blanking" : "", 662 + (margins) ? " with margins" : "", 663 + (interlace) ? " interlaced" : ""); 664 + 665 + memset(&cvt_mode, 0, sizeof(cvt_mode)); 666 + cvt_mode.xres = xres; 667 + cvt_mode.yres = yres; 668 + cvt_mode.refresh = (refresh) ? refresh : 60; 669 + 670 + if (interlace) 671 + cvt_mode.vmode |= FB_VMODE_INTERLACED; 672 + else 673 + cvt_mode.vmode &= ~FB_VMODE_INTERLACED; 674 + 675 + ret = fb_find_mode_cvt(&cvt_mode, margins, rb); 676 + 677 + if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) { 678 + DPRINTK("modedb CVT: CVT mode ok\n"); 709 679 return 1; 680 + } 681 + 682 + DPRINTK("CVT mode invalid, getting mode from database\n"); 683 + } 684 + 685 + DPRINTK("Trying specified video mode%s %ix%i\n", 686 + refresh_specified ? "" : " (ignoring refresh rate)", 687 + xres, yres); 688 + 689 + if (!refresh_specified) { 690 + /* 691 + * If the caller has provided a custom mode database and 692 + * a valid monspecs structure, we look for the mode with 693 + * the highest refresh rate. Otherwise we play it safe 694 + * it and try to find a mode with a refresh rate closest 695 + * to the standard 60 Hz. 696 + */ 697 + if (db != modedb && 698 + info->monspecs.vfmin && info->monspecs.vfmax && 699 + info->monspecs.hfmin && info->monspecs.hfmax && 700 + info->monspecs.dclkmax) { 701 + refresh = 1000; 710 702 } else { 703 + refresh = 60; 704 + } 705 + } 706 + 707 + diff = -1; 708 + best = -1; 709 + for (i = 0; i < dbsize; i++) { 710 + if ((name_matches(db[i], name, namelen) || 711 + (res_specified && res_matches(db[i], xres, yres))) && 712 + !fb_try_mode(var, info, &db[i], bpp)) { 713 + if (refresh_specified && db[i].refresh == refresh) 714 + return 1; 715 + 711 716 if (abs(db[i].refresh - refresh) < diff) { 712 717 diff = abs(db[i].refresh - refresh); 713 718 best = i; 714 719 } 715 720 } 716 721 } 717 - } 718 - if (best != -1) { 719 - fb_try_mode(var, info, &db[best], bpp); 720 - return (refresh_specified) ? 2 : 1; 721 - } 722 + if (best != -1) { 723 + fb_try_mode(var, info, &db[best], bpp); 724 + return (refresh_specified) ? 2 : 1; 725 + } 722 726 723 - diff = 2 * (xres + yres); 724 - best = -1; 725 - DPRINTK("Trying best-fit modes\n"); 726 - for (i = 0; i < dbsize; i++) { 727 - DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); 728 - if (!fb_try_mode(var, info, &db[i], bpp)) { 729 - tdiff = abs(db[i].xres - xres) + 730 - abs(db[i].yres - yres); 727 + diff = 2 * (xres + yres); 728 + best = -1; 729 + DPRINTK("Trying best-fit modes\n"); 730 + for (i = 0; i < dbsize; i++) { 731 + DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); 732 + if (!fb_try_mode(var, info, &db[i], bpp)) { 733 + tdiff = abs(db[i].xres - xres) + 734 + abs(db[i].yres - yres); 731 735 732 - /* 733 - * Penalize modes with resolutions smaller 734 - * than requested. 735 - */ 736 - if (xres > db[i].xres || yres > db[i].yres) 737 - tdiff += xres + yres; 736 + /* 737 + * Penalize modes with resolutions smaller 738 + * than requested. 739 + */ 740 + if (xres > db[i].xres || yres > db[i].yres) 741 + tdiff += xres + yres; 738 742 739 - if (diff > tdiff) { 740 - diff = tdiff; 741 - best = i; 743 + if (diff > tdiff) { 744 + diff = tdiff; 745 + best = i; 746 + } 742 747 } 743 748 } 749 + if (best != -1) { 750 + fb_try_mode(var, info, &db[best], bpp); 751 + return 5; 752 + } 744 753 } 745 - if (best != -1) { 746 - fb_try_mode(var, info, &db[best], bpp); 747 - return 5; 748 - } 749 - } 750 754 751 - DPRINTK("Trying default video mode\n"); 752 - if (!fb_try_mode(var, info, default_mode, default_bpp)) 753 - return 3; 755 + DPRINTK("Trying default video mode\n"); 756 + if (!fb_try_mode(var, info, default_mode, default_bpp)) 757 + return 3; 754 758 755 - DPRINTK("Trying all modes\n"); 756 - for (i = 0; i < dbsize; i++) 757 - if (!fb_try_mode(var, info, &db[i], default_bpp)) 758 - return 4; 759 + DPRINTK("Trying all modes\n"); 760 + for (i = 0; i < dbsize; i++) 761 + if (!fb_try_mode(var, info, &db[i], default_bpp)) 762 + return 4; 759 763 760 - DPRINTK("No valid mode found\n"); 761 - return 0; 764 + DPRINTK("No valid mode found\n"); 765 + return 0; 762 766 } 763 767 764 768 /**