Commit f92d39e9 authored by Timur Tabi's avatar Timur Tabi Committed by Florian Tobias Schandinat

fbdev: fix indentation in modedb.c

Fix the incorrect indentation in functions fb_try_mode() and fb_find_mode().
Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
parent a67472ad
...@@ -491,55 +491,56 @@ EXPORT_SYMBOL(vesa_modes); ...@@ -491,55 +491,56 @@ EXPORT_SYMBOL(vesa_modes);
static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info, static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info,
const struct fb_videomode *mode, unsigned int bpp) const struct fb_videomode *mode, unsigned int bpp)
{ {
int err = 0; int err = 0;
DPRINTK("Trying mode %s %dx%d-%d@%d\n", mode->name ? mode->name : "noname", DPRINTK("Trying mode %s %dx%d-%d@%d\n",
mode->xres, mode->yres, bpp, mode->refresh); mode->name ? mode->name : "noname",
var->xres = mode->xres; mode->xres, mode->yres, bpp, mode->refresh);
var->yres = mode->yres; var->xres = mode->xres;
var->xres_virtual = mode->xres; var->yres = mode->yres;
var->yres_virtual = mode->yres; var->xres_virtual = mode->xres;
var->xoffset = 0; var->yres_virtual = mode->yres;
var->yoffset = 0; var->xoffset = 0;
var->bits_per_pixel = bpp; var->yoffset = 0;
var->activate |= FB_ACTIVATE_TEST; var->bits_per_pixel = bpp;
var->pixclock = mode->pixclock; var->activate |= FB_ACTIVATE_TEST;
var->left_margin = mode->left_margin; var->pixclock = mode->pixclock;
var->right_margin = mode->right_margin; var->left_margin = mode->left_margin;
var->upper_margin = mode->upper_margin; var->right_margin = mode->right_margin;
var->lower_margin = mode->lower_margin; var->upper_margin = mode->upper_margin;
var->hsync_len = mode->hsync_len; var->lower_margin = mode->lower_margin;
var->vsync_len = mode->vsync_len; var->hsync_len = mode->hsync_len;
var->sync = mode->sync; var->vsync_len = mode->vsync_len;
var->vmode = mode->vmode; var->sync = mode->sync;
if (info->fbops->fb_check_var) var->vmode = mode->vmode;
err = info->fbops->fb_check_var(var, info); if (info->fbops->fb_check_var)
var->activate &= ~FB_ACTIVATE_TEST; err = info->fbops->fb_check_var(var, info);
return err; var->activate &= ~FB_ACTIVATE_TEST;
return err;
} }
/** /**
* fb_find_mode - finds a valid video mode * fb_find_mode - finds a valid video mode
* @var: frame buffer user defined part of display * @var: frame buffer user defined part of display
* @info: frame buffer info structure * @info: frame buffer info structure
* @mode_option: string video mode to find * @mode_option: string video mode to find
* @db: video mode database * @db: video mode database
* @dbsize: size of @db * @dbsize: size of @db
* @default_mode: default video mode to fall back to * @default_mode: default video mode to fall back to
* @default_bpp: default color depth in bits per pixel * @default_bpp: default color depth in bits per pixel
* *
* Finds a suitable video mode, starting with the specified mode * Finds a suitable video mode, starting with the specified mode
* in @mode_option with fallback to @default_mode. If * in @mode_option with fallback to @default_mode. If
* @default_mode fails, all modes in the video mode database will * @default_mode fails, all modes in the video mode database will
* be tried. * be tried.
* *
* Valid mode specifiers for @mode_option: * Valid mode specifiers for @mode_option:
* *
* <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or
* <name>[-<bpp>][@<refresh>] * <name>[-<bpp>][@<refresh>]
* *
* with <xres>, <yres>, <bpp> and <refresh> decimal numbers and * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and
* <name> a string. * <name> a string.
* *
* If 'M' is present after yres (and before refresh/bpp if present), * If 'M' is present after yres (and before refresh/bpp if present),
* the function will compute the timings using VESA(tm) Coordinated * the function will compute the timings using VESA(tm) Coordinated
...@@ -551,12 +552,12 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info, ...@@ -551,12 +552,12 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info,
* *
* 1024x768MR-8@60m - Reduced blank with margins at 60Hz. * 1024x768MR-8@60m - Reduced blank with margins at 60Hz.
* *
* NOTE: The passed struct @var is _not_ cleared! This allows you * NOTE: The passed struct @var is _not_ cleared! This allows you
* to supply values for e.g. the grayscale and accel_flags fields. * to supply values for e.g. the grayscale and accel_flags fields.
* *
* Returns zero for failure, 1 if using specified @mode_option, * Returns zero for failure, 1 if using specified @mode_option,
* 2 if using specified @mode_option with an ignored refresh rate, * 2 if using specified @mode_option with an ignored refresh rate,
* 3 if default mode is used, 4 if fall back to any valid mode. * 3 if default mode is used, 4 if fall back to any valid mode.
* *
*/ */
...@@ -566,198 +567,203 @@ int fb_find_mode(struct fb_var_screeninfo *var, ...@@ -566,198 +567,203 @@ int fb_find_mode(struct fb_var_screeninfo *var,
const struct fb_videomode *default_mode, const struct fb_videomode *default_mode,
unsigned int default_bpp) unsigned int default_bpp)
{ {
int i; int i;
/* Set up defaults */
if (!db) {
db = modedb;
dbsize = ARRAY_SIZE(modedb);
}
if (!default_mode)
default_mode = &db[0];
if (!default_bpp)
default_bpp = 8;
/* Did the user specify a video mode? */
if (!mode_option)
mode_option = fb_mode_option;
if (mode_option) {
const char *name = mode_option;
unsigned int namelen = strlen(name);
int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0;
u32 best, diff, tdiff;
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
case '@':
namelen = i;
if (!refresh_specified && !bpp_specified &&
!yres_specified) {
refresh = simple_strtol(&name[i+1], NULL, 10);
refresh_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case '-':
namelen = i;
if (!bpp_specified && !yres_specified) {
bpp = simple_strtol(&name[i+1], NULL, 10);
bpp_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case 'x':
if (!yres_specified) {
yres = simple_strtol(&name[i+1], NULL, 10);
yres_specified = 1;
} else
goto done;
break;
case '0' ... '9':
break;
case 'M':
if (!yres_specified)
cvt = 1;
break;
case 'R':
if (!cvt)
rb = 1;
break;
case 'm':
if (!cvt)
margins = 1;
break;
case 'i':
if (!cvt)
interlace = 1;
break;
default:
goto done;
}
}
if (i < 0 && yres_specified) {
xres = simple_strtol(name, NULL, 10);
res_specified = 1;
}
done:
if (cvt) {
struct fb_videomode cvt_mode;
int ret;
DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres,
(refresh) ? refresh : 60, (rb) ? " reduced blanking" :
"", (margins) ? " with margins" : "", (interlace) ?
" interlaced" : "");
memset(&cvt_mode, 0, sizeof(cvt_mode));
cvt_mode.xres = xres;
cvt_mode.yres = yres;
cvt_mode.refresh = (refresh) ? refresh : 60;
if (interlace) /* Set up defaults */
cvt_mode.vmode |= FB_VMODE_INTERLACED; if (!db) {
else db = modedb;
cvt_mode.vmode &= ~FB_VMODE_INTERLACED; dbsize = ARRAY_SIZE(modedb);
}
ret = fb_find_mode_cvt(&cvt_mode, margins, rb); if (!default_mode)
default_mode = &db[0];
if (!default_bpp)
default_bpp = 8;
/* Did the user specify a video mode? */
if (!mode_option)
mode_option = fb_mode_option;
if (mode_option) {
const char *name = mode_option;
unsigned int namelen = strlen(name);
int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
int yres_specified = 0, cvt = 0, rb = 0, interlace = 0;
int margins = 0;
u32 best, diff, tdiff;
for (i = namelen-1; i >= 0; i--) {
switch (name[i]) {
case '@':
namelen = i;
if (!refresh_specified && !bpp_specified &&
!yres_specified) {
refresh = simple_strtol(&name[i+1], NULL,
10);
refresh_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case '-':
namelen = i;
if (!bpp_specified && !yres_specified) {
bpp = simple_strtol(&name[i+1], NULL,
10);
bpp_specified = 1;
if (cvt || rb)
cvt = 0;
} else
goto done;
break;
case 'x':
if (!yres_specified) {
yres = simple_strtol(&name[i+1], NULL,
10);
yres_specified = 1;
} else
goto done;
break;
case '0' ... '9':
break;
case 'M':
if (!yres_specified)
cvt = 1;
break;
case 'R':
if (!cvt)
rb = 1;
break;
case 'm':
if (!cvt)
margins = 1;
break;
case 'i':
if (!cvt)
interlace = 1;
break;
default:
goto done;
}
}
if (i < 0 && yres_specified) {
xres = simple_strtol(name, NULL, 10);
res_specified = 1;
}
done:
if (cvt) {
struct fb_videomode cvt_mode;
int ret;
DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres,
(refresh) ? refresh : 60,
(rb) ? " reduced blanking" : "",
(margins) ? " with margins" : "",
(interlace) ? " interlaced" : "");
memset(&cvt_mode, 0, sizeof(cvt_mode));
cvt_mode.xres = xres;
cvt_mode.yres = yres;
cvt_mode.refresh = (refresh) ? refresh : 60;
if (interlace)
cvt_mode.vmode |= FB_VMODE_INTERLACED;
else
cvt_mode.vmode &= ~FB_VMODE_INTERLACED;
ret = fb_find_mode_cvt(&cvt_mode, margins, rb);
if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) {
DPRINTK("modedb CVT: CVT mode ok\n");
return 1;
}
if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) { DPRINTK("CVT mode invalid, getting mode from database\n");
DPRINTK("modedb CVT: CVT mode ok\n"); }
return 1;
}
DPRINTK("CVT mode invalid, getting mode from database\n"); DPRINTK("Trying specified video mode%s %ix%i\n",
} refresh_specified ? "" : " (ignoring refresh rate)",
xres, yres);
DPRINTK("Trying specified video mode%s %ix%i\n", if (!refresh_specified) {
refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); /*
* If the caller has provided a custom mode database and
if (!refresh_specified) { * a valid monspecs structure, we look for the mode with
/* * the highest refresh rate. Otherwise we play it safe
* If the caller has provided a custom mode database and a * it and try to find a mode with a refresh rate closest
* valid monspecs structure, we look for the mode with the * to the standard 60 Hz.
* highest refresh rate. Otherwise we play it safe it and */
* try to find a mode with a refresh rate closest to the if (db != modedb &&
* standard 60 Hz. info->monspecs.vfmin && info->monspecs.vfmax &&
*/ info->monspecs.hfmin && info->monspecs.hfmax &&
if (db != modedb && info->monspecs.dclkmax) {
info->monspecs.vfmin && info->monspecs.vfmax && refresh = 1000;
info->monspecs.hfmin && info->monspecs.hfmax && } else {
info->monspecs.dclkmax) { refresh = 60;
refresh = 1000; }
} else {
refresh = 60;
} }
}
diff = -1; diff = -1;
best = -1; best = -1;
for (i = 0; i < dbsize; i++) { for (i = 0; i < dbsize; i++) {
if ((name_matches(db[i], name, namelen) || if ((name_matches(db[i], name, namelen) ||
(res_specified && res_matches(db[i], xres, yres))) && (res_specified && res_matches(db[i], xres, yres))) &&
!fb_try_mode(var, info, &db[i], bpp)) { !fb_try_mode(var, info, &db[i], bpp)) {
if (refresh_specified && db[i].refresh == refresh) { if (refresh_specified && db[i].refresh == refresh)
return 1; return 1;
} else {
if (abs(db[i].refresh - refresh) < diff) { if (abs(db[i].refresh - refresh) < diff) {
diff = abs(db[i].refresh - refresh); diff = abs(db[i].refresh - refresh);
best = i; best = i;
} }
} }
} }
} if (best != -1) {
if (best != -1) { fb_try_mode(var, info, &db[best], bpp);
fb_try_mode(var, info, &db[best], bpp); return (refresh_specified) ? 2 : 1;
return (refresh_specified) ? 2 : 1; }
}
diff = 2 * (xres + yres);
best = -1;
DPRINTK("Trying best-fit modes\n");
for (i = 0; i < dbsize; i++) {
DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
if (!fb_try_mode(var, info, &db[i], bpp)) {
tdiff = abs(db[i].xres - xres) +
abs(db[i].yres - yres);
/*
* Penalize modes with resolutions smaller
* than requested.
*/
if (xres > db[i].xres || yres > db[i].yres)
tdiff += xres + yres;
if (diff > tdiff) { diff = 2 * (xres + yres);
diff = tdiff; best = -1;
best = i; DPRINTK("Trying best-fit modes\n");
for (i = 0; i < dbsize; i++) {
DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
if (!fb_try_mode(var, info, &db[i], bpp)) {
tdiff = abs(db[i].xres - xres) +
abs(db[i].yres - yres);
/*
* Penalize modes with resolutions smaller
* than requested.
*/
if (xres > db[i].xres || yres > db[i].yres)
tdiff += xres + yres;
if (diff > tdiff) {
diff = tdiff;
best = i;
}
} }
} }
if (best != -1) {
fb_try_mode(var, info, &db[best], bpp);
return 5;
}
} }
if (best != -1) {
fb_try_mode(var, info, &db[best], bpp);
return 5;
}
}
DPRINTK("Trying default video mode\n"); DPRINTK("Trying default video mode\n");
if (!fb_try_mode(var, info, default_mode, default_bpp)) if (!fb_try_mode(var, info, default_mode, default_bpp))
return 3; return 3;
DPRINTK("Trying all modes\n"); DPRINTK("Trying all modes\n");
for (i = 0; i < dbsize; i++) for (i = 0; i < dbsize; i++)
if (!fb_try_mode(var, info, &db[i], default_bpp)) if (!fb_try_mode(var, info, &db[i], default_bpp))
return 4; return 4;
DPRINTK("No valid mode found\n"); DPRINTK("No valid mode found\n");
return 0; return 0;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment