diff options
author | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-11-23 13:06:37 +0000 |
---|---|---|
committer | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-11-23 13:06:37 +0000 |
commit | 92ea709db2a5ab3d79a94593cbc94c9a19c52c01 (patch) | |
tree | fd39ccca0cd8071d875c593bdfa78ba82e41226c /libvo | |
parent | 21a6361d95a23d77fd32666ecf8c6842dda51174 (diff) | |
download | mpv-92ea709db2a5ab3d79a94593cbc94c9a19c52c01.tar.bz2 mpv-92ea709db2a5ab3d79a94593cbc94c9a19c52c01.tar.xz |
cosmetics: complete reformatting, tabs to spaces, etc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27990 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_fbdev.c | 1908 |
1 files changed, 952 insertions, 956 deletions
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 431ce1257a..08f70c262c 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -2,7 +2,7 @@ * Video driver for Framebuffer device * by Szabolcs Berecz <szabi@inf.elte.hu> * (C) 2001 - * + * * Some idea and code borrowed from Chris Lawrence's ppmtofb-0.27 * Some fixes and small improvements by Joey Parrish <joey@nicewarrior.org> */ @@ -33,10 +33,10 @@ #include "mp_msg.h" static const vo_info_t info = { - "Framebuffer Device", - "fbdev", - "Szabolcs Berecz <szabi@inf.elte.hu>", - "" + "Framebuffer Device", + "fbdev", + "Szabolcs Berecz <szabi@inf.elte.hu>", + "" }; LIBVO_EXTERN(fbdev) @@ -48,39 +48,39 @@ static vidix_grkey_t gr_key; #endif static signed int pre_init_err = -2; /****************************** -* fb.modes support * -******************************/ + * fb.modes support * + ******************************/ static range_t *monitor_hfreq = NULL; static range_t *monitor_vfreq = NULL; static range_t *monitor_dotclock = NULL; typedef struct { - char *name; - uint32_t xres, yres, vxres, vyres, depth; - uint32_t pixclock, left, right, upper, lower, hslen, vslen; - uint32_t sync; - uint32_t vmode; + char *name; + uint32_t xres, yres, vxres, vyres, depth; + uint32_t pixclock, left, right, upper, lower, hslen, vslen; + uint32_t sync; + uint32_t vmode; } fb_mode_t; -#define MAX_NR_TOKEN 16 +#define MAX_NR_TOKEN 16 -#define MAX_LINE_LEN 1000 +#define MAX_LINE_LEN 1000 -#define RET_EOF -1 -#define RET_EOL -2 +#define RET_EOF -1 +#define RET_EOL -2 static int validate_mode(fb_mode_t *m) { - if (!m->xres) { - mp_msg(MSGT_VO, MSGL_V, "needs geometry "); - return 0; - } - if (!m->pixclock) { - mp_msg(MSGT_VO, MSGL_V, "needs timings "); - return 0; - } - return 1; + if (!m->xres) { + mp_msg(MSGT_VO, MSGL_V, "needs geometry "); + return 0; + } + if (!m->pixclock) { + mp_msg(MSGT_VO, MSGL_V, "needs timings "); + return 0; + } + return 1; } static FILE *fp; @@ -90,58 +90,58 @@ static char *token[MAX_NR_TOKEN]; static int get_token(int num) { - static int read_nextline = 1; - static int line_pos; - int i; - char c; - - if (num >= MAX_NR_TOKEN) { - mp_msg(MSGT_VO, MSGL_V, "get_token(): max >= MAX_NR_TOKEN!\n"); - goto out_eof; - } - - if (read_nextline) { - if (!fgets(line, MAX_LINE_LEN, fp)) - goto out_eof; - line_pos = 0; - ++line_num; - read_nextline = 0; - } - for (i = 0; i < num; i++) { - while (isspace(line[line_pos])) - ++line_pos; - if (line[line_pos] == '\0' || line[line_pos] == '#') { - read_nextline = 1; - goto out_eol; - } - token[i] = line + line_pos; - c = line[line_pos]; - if (c == '"' || c == '\'') { - token[i]++; - while (line[++line_pos] != c && line[line_pos]) - /* NOTHING */; - if (!line[line_pos]) - goto out_eol; - line[line_pos] = ' '; - } else { - for (/* NOTHING */; !isspace(line[line_pos]) && - line[line_pos]; line_pos++) - /* NOTHING */; - } - if (!line[line_pos]) { - read_nextline = 1; - if (i == num - 1) - goto out_ok; - goto out_eol; - } - line[line_pos++] = '\0'; - } + static int read_nextline = 1; + static int line_pos; + int i; + char c; + + if (num >= MAX_NR_TOKEN) { + mp_msg(MSGT_VO, MSGL_V, "get_token(): max >= MAX_NR_TOKEN!\n"); + goto out_eof; + } + + if (read_nextline) { + if (!fgets(line, MAX_LINE_LEN, fp)) + goto out_eof; + line_pos = 0; + ++line_num; + read_nextline = 0; + } + for (i = 0; i < num; i++) { + while (isspace(line[line_pos])) + ++line_pos; + if (line[line_pos] == '\0' || line[line_pos] == '#') { + read_nextline = 1; + goto out_eol; + } + token[i] = line + line_pos; + c = line[line_pos]; + if (c == '"' || c == '\'') { + token[i]++; + while (line[++line_pos] != c && line[line_pos]) + /* NOTHING */; + if (!line[line_pos]) + goto out_eol; + line[line_pos] = ' '; + } else { + for (/* NOTHING */; !isspace(line[line_pos]) && + line[line_pos]; line_pos++) + /* NOTHING */; + } + if (!line[line_pos]) { + read_nextline = 1; + if (i == num - 1) + goto out_ok; + goto out_eol; + } + line[line_pos++] = '\0'; + } out_ok: - return i; + return i; out_eof: - return RET_EOF; + return RET_EOF; out_eol: - return RET_EOL; + return RET_EOL; } static fb_mode_t *fb_modes = NULL; @@ -150,385 +150,385 @@ static int nr_modes = 0; static int parse_fbmode_cfg(char *cfgfile) { #define CHECK_IN_MODE_DEF\ - if (!in_mode_def) {\ - mp_msg(MSGT_VO, MSGL_V, "'needs 'mode' first");\ - goto err_out_print_linenum;\ - } - fb_mode_t *mode = NULL; - char *endptr; // strtoul()... - int in_mode_def = 0; - int tmp, i; - - /* If called more than once, reuse parsed data */ - if (nr_modes) - return nr_modes; - - mp_msg(MSGT_VO, MSGL_V, "Reading %s: ", cfgfile); - - if ((fp = fopen(cfgfile, "r")) == NULL) { - mp_msg(MSGT_VO, MSGL_V, "can't open '%s': %s\n", cfgfile, strerror(errno)); - return -1; - } - - if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { - mp_msg(MSGT_VO, MSGL_V, "can't get memory for 'line': %s\n", strerror(errno)); - return -2; - } - - /* - * check if the cfgfile starts with 'mode' - */ - while ((tmp = get_token(1)) == RET_EOL) - /* NOTHING */; - if (tmp == RET_EOF) - goto out; - if (!strcmp(token[0], "mode")) - goto loop_enter; - goto err_out_parse_error; - - while ((tmp = get_token(1)) != RET_EOF) { - if (tmp == RET_EOL) - continue; - if (!strcmp(token[0], "mode")) { - if (in_mode_def) { - mp_msg(MSGT_VO, MSGL_V, "'endmode' required"); - goto err_out_print_linenum; - } - if (!validate_mode(mode)) - goto err_out_not_valid; - loop_enter: - if (!(fb_modes = (fb_mode_t *) realloc(fb_modes, - sizeof(fb_mode_t) * (nr_modes + 1)))) { - mp_msg(MSGT_VO, MSGL_V, "can't realloc 'fb_modes' (nr_modes = %d):" - " %s\n", nr_modes, strerror(errno)); - goto err_out; - } - mode=fb_modes + nr_modes; - ++nr_modes; - memset(mode,0,sizeof(fb_mode_t)); - - if (get_token(1) < 0) - goto err_out_parse_error; - for (i = 0; i < nr_modes - 1; i++) { - if (!strcmp(token[0], fb_modes[i].name)) { - mp_msg(MSGT_VO, MSGL_V, "mode name '%s' isn't unique", token[0]); - goto err_out_print_linenum; - } - } - if (!(mode->name = strdup(token[0]))) { - mp_msg(MSGT_VO, MSGL_V, "can't strdup -> 'name': %s\n", strerror(errno)); - goto err_out; - } - in_mode_def = 1; - } else if (!strcmp(token[0], "geometry")) { - CHECK_IN_MODE_DEF; - if (get_token(5) < 0) - goto err_out_parse_error; - mode->xres = strtoul(token[0], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->yres = strtoul(token[1], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->vxres = strtoul(token[2], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->vyres = strtoul(token[3], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->depth = strtoul(token[4], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - } else if (!strcmp(token[0], "timings")) { - CHECK_IN_MODE_DEF; - if (get_token(7) < 0) - goto err_out_parse_error; - mode->pixclock = strtoul(token[0], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->left = strtoul(token[1], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->right = strtoul(token[2], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->upper = strtoul(token[3], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->lower = strtoul(token[4], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->hslen = strtoul(token[5], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - mode->vslen = strtoul(token[6], &endptr, 0); - if (*endptr) - goto err_out_parse_error; - } else if (!strcmp(token[0], "endmode")) { - CHECK_IN_MODE_DEF; - in_mode_def = 0; - } else if (!strcmp(token[0], "accel")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - /* - * it's only used for text acceleration - * so we just ignore it. - */ - } else if (!strcmp(token[0], "hsync")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "low")) - mode->sync &= ~FB_SYNC_HOR_HIGH_ACT; - else if(!strcmp(token[0], "high")) - mode->sync |= FB_SYNC_HOR_HIGH_ACT; - else - goto err_out_parse_error; - } else if (!strcmp(token[0], "vsync")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "low")) - mode->sync &= ~FB_SYNC_VERT_HIGH_ACT; - else if(!strcmp(token[0], "high")) - mode->sync |= FB_SYNC_VERT_HIGH_ACT; - else - goto err_out_parse_error; - } else if (!strcmp(token[0], "csync")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "low")) - mode->sync &= ~FB_SYNC_COMP_HIGH_ACT; - else if(!strcmp(token[0], "high")) - mode->sync |= FB_SYNC_COMP_HIGH_ACT; - else - goto err_out_parse_error; - } else if (!strcmp(token[0], "extsync")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "false")) - mode->sync &= ~FB_SYNC_EXT; - else if(!strcmp(token[0], "true")) - mode->sync |= FB_SYNC_EXT; - else - goto err_out_parse_error; - } else if (!strcmp(token[0], "laced")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "false")) - mode->vmode = FB_VMODE_NONINTERLACED; - else if (!strcmp(token[0], "true")) - mode->vmode = FB_VMODE_INTERLACED; - else - goto err_out_parse_error; - } else if (!strcmp(token[0], "double")) { - CHECK_IN_MODE_DEF; - if (get_token(1) < 0) - goto err_out_parse_error; - if (!strcmp(token[0], "false")) - ; - else if (!strcmp(token[0], "true")) - mode->vmode = FB_VMODE_DOUBLE; - else - goto err_out_parse_error; - } else - goto err_out_parse_error; - } - if (!validate_mode(mode)) - goto err_out_not_valid; + if (!in_mode_def) {\ + mp_msg(MSGT_VO, MSGL_V, "'needs 'mode' first");\ + goto err_out_print_linenum;\ + } + fb_mode_t *mode = NULL; + char *endptr; // strtoul()... + int in_mode_def = 0; + int tmp, i; + + /* If called more than once, reuse parsed data */ + if (nr_modes) + return nr_modes; + + mp_msg(MSGT_VO, MSGL_V, "Reading %s: ", cfgfile); + + if ((fp = fopen(cfgfile, "r")) == NULL) { + mp_msg(MSGT_VO, MSGL_V, "can't open '%s': %s\n", cfgfile, strerror(errno)); + return -1; + } + + if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { + mp_msg(MSGT_VO, MSGL_V, "can't get memory for 'line': %s\n", strerror(errno)); + return -2; + } + + /* + * check if the cfgfile starts with 'mode' + */ + while ((tmp = get_token(1)) == RET_EOL) + /* NOTHING */; + if (tmp == RET_EOF) + goto out; + if (!strcmp(token[0], "mode")) + goto loop_enter; + goto err_out_parse_error; + + while ((tmp = get_token(1)) != RET_EOF) { + if (tmp == RET_EOL) + continue; + if (!strcmp(token[0], "mode")) { + if (in_mode_def) { + mp_msg(MSGT_VO, MSGL_V, "'endmode' required"); + goto err_out_print_linenum; + } + if (!validate_mode(mode)) + goto err_out_not_valid; + loop_enter: + if (!(fb_modes = (fb_mode_t *) + realloc(fb_modes, sizeof(fb_mode_t) * (nr_modes + 1)))) { + mp_msg(MSGT_VO, MSGL_V, "can't realloc 'fb_modes' (nr_modes = %d):" + " %s\n", nr_modes, strerror(errno)); + goto err_out; + } + mode = fb_modes + nr_modes; + ++nr_modes; + memset(mode, 0, sizeof(fb_mode_t)); + + if (get_token(1) < 0) + goto err_out_parse_error; + for (i = 0; i < nr_modes - 1; i++) { + if (!strcmp(token[0], fb_modes[i].name)) { + mp_msg(MSGT_VO, MSGL_V, "mode name '%s' isn't unique", token[0]); + goto err_out_print_linenum; + } + } + if (!(mode->name = strdup(token[0]))) { + mp_msg(MSGT_VO, MSGL_V, "can't strdup -> 'name': %s\n", strerror(errno)); + goto err_out; + } + in_mode_def = 1; + } else if (!strcmp(token[0], "geometry")) { + CHECK_IN_MODE_DEF; + if (get_token(5) < 0) + goto err_out_parse_error; + mode->xres = strtoul(token[0], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->yres = strtoul(token[1], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->vxres = strtoul(token[2], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->vyres = strtoul(token[3], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->depth = strtoul(token[4], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + } else if (!strcmp(token[0], "timings")) { + CHECK_IN_MODE_DEF; + if (get_token(7) < 0) + goto err_out_parse_error; + mode->pixclock = strtoul(token[0], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->left = strtoul(token[1], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->right = strtoul(token[2], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->upper = strtoul(token[3], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->lower = strtoul(token[4], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->hslen = strtoul(token[5], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + mode->vslen = strtoul(token[6], &endptr, 0); + if (*endptr) + goto err_out_parse_error; + } else if (!strcmp(token[0], "endmode")) { + CHECK_IN_MODE_DEF; + in_mode_def = 0; + } else if (!strcmp(token[0], "accel")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + /* + * it's only used for text acceleration + * so we just ignore it. + */ + } else if (!strcmp(token[0], "hsync")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "low")) + mode->sync &= ~FB_SYNC_HOR_HIGH_ACT; + else if (!strcmp(token[0], "high")) + mode->sync |= FB_SYNC_HOR_HIGH_ACT; + else + goto err_out_parse_error; + } else if (!strcmp(token[0], "vsync")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "low")) + mode->sync &= ~FB_SYNC_VERT_HIGH_ACT; + else if (!strcmp(token[0], "high")) + mode->sync |= FB_SYNC_VERT_HIGH_ACT; + else + goto err_out_parse_error; + } else if (!strcmp(token[0], "csync")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "low")) + mode->sync &= ~FB_SYNC_COMP_HIGH_ACT; + else if (!strcmp(token[0], "high")) + mode->sync |= FB_SYNC_COMP_HIGH_ACT; + else + goto err_out_parse_error; + } else if (!strcmp(token[0], "extsync")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "false")) + mode->sync &= ~FB_SYNC_EXT; + else if (!strcmp(token[0], "true")) + mode->sync |= FB_SYNC_EXT; + else + goto err_out_parse_error; + } else if (!strcmp(token[0], "laced")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "false")) + mode->vmode = FB_VMODE_NONINTERLACED; + else if (!strcmp(token[0], "true")) + mode->vmode = FB_VMODE_INTERLACED; + else + goto err_out_parse_error; + } else if (!strcmp(token[0], "double")) { + CHECK_IN_MODE_DEF; + if (get_token(1) < 0) + goto err_out_parse_error; + if (!strcmp(token[0], "false")) + ; + else if (!strcmp(token[0], "true")) + mode->vmode = FB_VMODE_DOUBLE; + else + goto err_out_parse_error; + } else + goto err_out_parse_error; + } + if (!validate_mode(mode)) + goto err_out_not_valid; out: - mp_msg(MSGT_VO, MSGL_V, "%d modes\n", nr_modes); - free(line); - fclose(fp); - return nr_modes; + mp_msg(MSGT_VO, MSGL_V, "%d modes\n", nr_modes); + free(line); + fclose(fp); + return nr_modes; err_out_parse_error: - mp_msg(MSGT_VO, MSGL_V, "parse error"); + mp_msg(MSGT_VO, MSGL_V, "parse error"); err_out_print_linenum: - mp_msg(MSGT_VO, MSGL_V, " at line %d\n", line_num); + mp_msg(MSGT_VO, MSGL_V, " at line %d\n", line_num); err_out: - if (fb_modes) { - free(fb_modes); - fb_modes = NULL; - } - nr_modes = 0; - free(line); - free(fp); - return -2; + if (fb_modes) { + free(fb_modes); + fb_modes = NULL; + } + nr_modes = 0; + free(line); + free(fp); + return -2; err_out_not_valid: - mp_msg(MSGT_VO, MSGL_V, "previous mode is not correct"); - goto err_out_print_linenum; + mp_msg(MSGT_VO, MSGL_V, "previous mode is not correct"); + goto err_out_print_linenum; } static fb_mode_t *find_mode_by_name(char *name) { - int i; + int i; - for (i = 0; i < nr_modes; i++) - if (!strcmp(name, fb_modes[i].name)) - return fb_modes + i; - return NULL; + for (i = 0; i < nr_modes; i++) + if (!strcmp(name, fb_modes[i].name)) + return fb_modes + i; + return NULL; } -static float dcf(fb_mode_t *m) //driving clock frequency +static float dcf(fb_mode_t *m) //driving clock frequency { - return 1e12f / m->pixclock; + return 1e12f / m->pixclock; } -static float hsf(fb_mode_t *m) //horizontal scan frequency +static float hsf(fb_mode_t *m) //horizontal scan frequency { - int htotal = m->left + m->xres + m->right + m->hslen; - return dcf(m) / htotal; + int htotal = m->left + m->xres + m->right + m->hslen; + return dcf(m) / htotal; } -static float vsf(fb_mode_t *m) //vertical scan frequency +static float vsf(fb_mode_t *m) //vertical scan frequency { - int vtotal = m->upper + m->yres + m->lower + m->vslen; - return hsf(m) / vtotal; + int vtotal = m->upper + m->yres + m->lower + m->vslen; + return hsf(m) / vtotal; } static int mode_works(fb_mode_t *m, range_t *hfreq, range_t *vfreq, - range_t *dotclock) + range_t *dotclock) { - float h = hsf(m); - float v = vsf(m); - float d = dcf(m); - int ret = 1; - - mp_msg(MSGT_VO, MSGL_DBG2, "mode %dx%d:", m->xres, m->yres); - if (!in_range(hfreq, h)) { - ret = 0; - mp_msg(MSGT_VO, MSGL_DBG2, " hsync out of range."); - } - if (!in_range(vfreq, v)) { - ret = 0; - mp_msg(MSGT_VO, MSGL_DBG2, " vsync out of range."); - } - if (!in_range(dotclock, d)) { - ret = 0; - mp_msg(MSGT_VO, MSGL_DBG2, " dotclock out of range."); - } - if (ret) - mp_msg(MSGT_VO, MSGL_DBG2, " hsync, vsync, dotclock ok.\n"); - else - mp_msg(MSGT_VO, MSGL_DBG2, "\n"); - - return ret; + float h = hsf(m); + float v = vsf(m); + float d = dcf(m); + int ret = 1; + + mp_msg(MSGT_VO, MSGL_DBG2, "mode %dx%d:", m->xres, m->yres); + if (!in_range(hfreq, h)) { + ret = 0; + mp_msg(MSGT_VO, MSGL_DBG2, " hsync out of range."); + } + if (!in_range(vfreq, v)) { + ret = 0; + mp_msg(MSGT_VO, MSGL_DBG2, " vsync out of range."); + } + if (!in_range(dotclock, d)) { + ret = 0; + mp_msg(MSGT_VO, MSGL_DBG2, " dotclock out of range."); + } + if (ret) + mp_msg(MSGT_VO, MSGL_DBG2, " hsync, vsync, dotclock ok.\n"); + else + mp_msg(MSGT_VO, MSGL_DBG2, "\n"); + + return ret; } static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq, - range_t *vfreq, range_t *dotclock) + range_t *vfreq, range_t *dotclock) { - int i; - fb_mode_t *best = fb_modes; - fb_mode_t *curr; - - mp_msg(MSGT_VO, MSGL_DBG2, "Searching for first working mode\n"); - - for (i = 0; i < nr_modes; i++, best++) - if (mode_works(best, hfreq, vfreq, dotclock)) - break; - - if (i == nr_modes) - return NULL; - if (i == nr_modes - 1) - return best; - - mp_msg(MSGT_VO, MSGL_DBG2, "First working mode: %dx%d\n", best->xres, best->yres); - mp_msg(MSGT_VO, MSGL_DBG2, "Searching for better modes\n"); - - for (curr = best + 1; i < nr_modes - 1; i++, curr++) { - if (!mode_works(curr, hfreq, vfreq, dotclock)) - continue; - - if (best->xres < xres || best->yres < yres) { - if (curr->xres > best->xres || curr->yres > best->yres) { - mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too small.\n", - best->xres, best->yres); - best = curr; - } else - mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); - } else if (curr->xres == best->xres && curr->yres == best->yres && - vsf(curr) > vsf(best)) { - mp_msg(MSGT_VO, MSGL_DBG2, "faster screen refresh.\n"); - best = curr; - } else if ((curr->xres <= best->xres && curr->yres <= best->yres) && - (curr->xres >= xres && curr->yres >= yres)) { - mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too large.\n", - best->xres, best->yres); - best = curr; - } else { - if (curr->xres < xres || curr->yres < yres) - mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); - else if (curr->xres > best->xres || curr->yres > best->yres) - mp_msg(MSGT_VO, MSGL_DBG2, "too large.\n"); - else - mp_msg(MSGT_VO, MSGL_DBG2, "it's worse, don't know why.\n"); - } - } - - return best; + int i; + fb_mode_t *best = fb_modes; + fb_mode_t *curr; + + mp_msg(MSGT_VO, MSGL_DBG2, "Searching for first working mode\n"); + + for (i = 0; i < nr_modes; i++, best++) + if (mode_works(best, hfreq, vfreq, dotclock)) + break; + + if (i == nr_modes) + return NULL; + if (i == nr_modes - 1) + return best; + + mp_msg(MSGT_VO, MSGL_DBG2, "First working mode: %dx%d\n", best->xres, best->yres); + mp_msg(MSGT_VO, MSGL_DBG2, "Searching for better modes\n"); + + for (curr = best + 1; i < nr_modes - 1; i++, curr++) { + if (!mode_works(curr, hfreq, vfreq, dotclock)) + continue; + + if (best->xres < xres || best->yres < yres) { + if (curr->xres > best->xres || curr->yres > best->yres) { + mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too small.\n", + best->xres, best->yres); + best = curr; + } else + mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); + } else if (curr->xres == best->xres && curr->yres == best->yres && + vsf(curr) > vsf(best)) { + mp_msg(MSGT_VO, MSGL_DBG2, "faster screen refresh.\n"); + best = curr; + } else if ((curr->xres <= best->xres && curr->yres <= best->yres) && + (curr->xres >= xres && curr->yres >= yres)) { + mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too large.\n", + best->xres, best->yres); + best = curr; + } else { + if (curr->xres < xres || curr->yres < yres) + mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); + else if (curr->xres > best->xres || curr->yres > best->yres) + mp_msg(MSGT_VO, MSGL_DBG2, "too large.\n"); + else + mp_msg(MSGT_VO, MSGL_DBG2, "it's worse, don't know why.\n"); + } + } + + return best; } static void set_bpp(struct fb_var_screeninfo *p, int bpp) { - p->bits_per_pixel = (bpp + 1) & ~1; - p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; - p->transp.offset = p->transp.length = 0; - p->blue.offset = 0; - switch (bpp) { - case 32: - p->transp.offset = 24; - p->transp.length = 8; - case 24: - p->red.offset = 16; - p->red.length = 8; - p->green.offset = 8; - p->green.length = 8; - p->blue.length = 8; - break; - case 16: - p->red.offset = 11; - p->green.length = 6; - p->red.length = 5; - p->green.offset = 5; - p->blue.length = 5; - break; - case 15: - p->red.offset = 10; - p->green.length = 5; - p->red.length = 5; - p->green.offset = 5; - p->blue.length = 5; - break; - } + p->bits_per_pixel = (bpp + 1) & ~1; + p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; + p->transp.offset = p->transp.length = 0; + p->blue.offset = 0; + switch (bpp) { + case 32: + p->transp.offset = 24; + p->transp.length = 8; + case 24: + p->red.offset = 16; + p->red.length = 8; + p->green.offset = 8; + p->green.length = 8; + p->blue.length = 8; + break; + case 16: + p->red.offset = 11; + p->green.length = 6; + p->red.length = 5; + p->green.offset = 5; + p->blue.length = 5; + break; + case 15: + p->red.offset = 10; + p->green.length = 5; + p->red.length = 5; + p->green.offset = 5; + p->blue.length = 5; + break; + } } static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v) { - v->xres = m->xres; - v->yres = m->yres; - v->xres_virtual = m->vxres; - v->yres_virtual = m->vyres; - set_bpp(v, m->depth); - v->pixclock = m->pixclock; - v->left_margin = m->left; - v->right_margin = m->right; - v->upper_margin = m->upper; - v->lower_margin = m->lower; - v->hsync_len = m->hslen; - v->vsync_len = m->vslen; - v->sync = m->sync; - v->vmode = m->vmode; + v->xres = m->xres; + v->yres = m->yres; + v->xres_virtual = m->vxres; + v->yres_virtual = m->vyres; + set_bpp(v, m->depth); + v->pixclock = m->pixclock; + v->left_margin = m->left; + v->right_margin = m->right; + v->upper_margin = m->upper; + v->lower_margin = m->lower; + v->hsync_len = m->hslen; + v->vsync_len = m->vslen; + v->sync = m->sync; + v->vmode = m->vmode; } /****************************** -* vo_fbdev * +* vo_fbdev * ******************************/ /* command line/config file options */ @@ -554,15 +554,15 @@ static struct fb_var_screeninfo fb_vinfo; static unsigned short fb_ored[256], fb_ogreen[256], fb_oblue[256]; static struct fb_cmap fb_oldcmap = { 0, 256, fb_ored, fb_ogreen, fb_oblue }; static int fb_cmap_changed = 0; -static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 -static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 -static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15 +static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 +static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 +static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15 static int fb_line_len; static int fb_xres; static int fb_yres; static void (*draw_alpha_p)(int w, int h, unsigned char *src, - unsigned char *srca, int stride, unsigned char *dst, - int dstride); + unsigned char *srca, int stride, + unsigned char *dst, int dstride); static int in_width; static int in_height; @@ -580,513 +580,509 @@ static int fs; */ static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) { - /* Hopefully any DIRECTCOLOR device will have a big enough palette - * to handle mapping the full color depth. - * e.g. 8 bpp -> 256 entry palette - * - * We could handle some sort of gamma here - */ - int i, cols, rcols, gcols, bcols; - uint16_t *red, *green, *blue; - struct fb_cmap *cmap; - - rcols = 1 << var->red.length; - gcols = 1 << var->green.length; - bcols = 1 << var->blue.length; - - /* Make our palette the length of the deepest color */ - cols = (rcols > gcols ? rcols : gcols); - cols = (cols > bcols ? cols : bcols); - - red = malloc(cols * sizeof(red[0])); - if(!red) { - mp_msg(MSGT_VO, MSGL_V, "Can't allocate red palette with %d entries.\n", cols); - return NULL; - } - for(i=0; i< rcols; i++) - red[i] = (65535/(rcols-1)) * i; - - green = malloc(cols * sizeof(green[0])); - if(!green) { - mp_msg(MSGT_VO, MSGL_V, "Can't allocate green palette with %d entries.\n", cols); - free(red); - return NULL; - } - for(i=0; i< gcols; i++) - green[i] = (65535/(gcols-1)) * i; - - blue = malloc(cols * sizeof(blue[0])); - if(!blue) { - mp_msg(MSGT_VO, MSGL_V, "Can't allocate blue palette with %d entries.\n", cols); - free(red); - free(green); - return NULL; - } - for(i=0; i< bcols; i++) - blue[i] = (65535/(bcols-1)) * i; - - cmap = malloc(sizeof(struct fb_cmap)); - if(!cmap) { - mp_msg(MSGT_VO, MSGL_V, "Can't allocate color map\n"); - free(red); - free(green); - free(blue); - return NULL; - } - cmap->start = 0; - cmap->transp = 0; - cmap->len = cols; - cmap->red = red; - cmap->blue = blue; - cmap->green = green; - cmap->transp = NULL; - - return cmap; + /* Hopefully any DIRECTCOLOR device will have a big enough palette + * to handle mapping the full color depth. + * e.g. 8 bpp -> 256 entry palette + * + * We could handle some sort of gamma here + */ + int i, cols, rcols, gcols, bcols; + uint16_t *red, *green, *blue; + struct fb_cmap *cmap; + + rcols = 1 << var->red.length; + gcols = 1 << var->green.length; + bcols = 1 << var->blue.length; + + /* Make our palette the length of the deepest color */ + cols = (rcols > gcols ? rcols : gcols); + cols = (cols > bcols ? cols : bcols); + + red = malloc(cols * sizeof(red[0])); + if (!red) { + mp_msg(MSGT_VO, MSGL_V, "Can't allocate red palette with %d entries.\n", cols); + return NULL; + } + for (i = 0; i < rcols; i++) + red[i] = (65535 / (rcols - 1)) * i; + + green = malloc(cols * sizeof(green[0])); + if (!green) { + mp_msg(MSGT_VO, MSGL_V, "Can't allocate green palette with %d entries.\n", cols); + free(red); + return NULL; + } + for (i = 0; i < gcols; i++) + green[i] = (65535 / (gcols - 1)) * i; + + blue = malloc(cols * sizeof(blue[0])); + if (!blue) { + mp_msg(MSGT_VO, MSGL_V, "Can't allocate blue palette with %d entries.\n", cols); + free(red); + free(green); + return NULL; + } + for (i = 0; i < bcols; i++) + blue[i] = (65535 / (bcols - 1)) * i; + + cmap = malloc(sizeof(struct fb_cmap)); + if (!cmap) { + mp_msg(MSGT_VO, MSGL_V, "Can't allocate color map\n"); + free(red); + free(gree |