X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvideo%2Fomapdss%2Fconfig.c;h=10a9036bd5b692daaa7db4f35a2283815f882f95;hb=5cc6dcb71c2f2f24e54bf1ab9f09d8e560e8e4d9;hp=e526c363d4a650aacf21ef90562ca01e94a8183d;hpb=b78828bf6c654f3763394f153d31bab3fc5c8a64;p=sdl_omap.git diff --git a/src/video/omapdss/config.c b/src/video/omapdss/config.c index e526c36..10a9036 100644 --- a/src/video/omapdss/config.c +++ b/src/video/omapdss/config.c @@ -1,16 +1,17 @@ /* - * (C) notaz, 2010 + * (C) Gražvydas "notaz" Ignotas, 2010 * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING file in the top-level directory. */ #include +#include #include #include #include -#include "omapsdl.h" +#include "osdl.h" static char *sskip(char *p) { @@ -26,13 +27,29 @@ static char *nsskip(char *p) return p; } -static int check_token(const char *p, const char *token) +static int check_token(char **p_, const char *token) { + char *p = *p_; int tlen = strlen(token); - return strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]); + int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]); + if (ret) + *p_ = sskip(p + tlen + 1); + + return ret; +} + +static int check_token_eq(char **p_, const char *token) +{ + char *p = *p_; + int ret = check_token(&p, token); + ret = ret && *p == '='; + if (ret) + *p_ = sskip(p + 1); + + return ret; } -void omapsdl_config(void) +void omapsdl_config(struct SDL_PrivateVideoData *pdata) { char buff[256]; FILE *f; @@ -46,12 +63,12 @@ void omapsdl_config(void) if (line == NULL) break; p = line = sskip(line); - if (*p == '#') + if (*p == 0 || *p == '#') continue; - if (check_token(p, "bind")) { + if (check_token(&p, "bind")) { char *key, *key_end, *sdlkey, *sdlkey_end; - key = sskip(p + 5); + key = p; key_end = nsskip(key); p = sskip(key_end); if (*p != '=') @@ -66,6 +83,26 @@ void omapsdl_config(void) omapsdl_input_bind(key, sdlkey); continue; } + else if (check_token_eq(&p, "force_vsync")) { + pdata->cfg_force_vsync = !!strtol(p, NULL, 0); + continue; + } + else if (check_token_eq(&p, "force_doublebuf")) { + pdata->cfg_force_doublebuf = !!strtol(p, NULL, 0); + continue; + } + else if (check_token_eq(&p, "force_directbuf")) { + pdata->cfg_force_directbuf = !!strtol(p, NULL, 0); + continue; + } + else if (check_token_eq(&p, "no_ts_translate")) { + pdata->cfg_no_ts_translate = !!strtol(p, NULL, 0); + continue; + } + else if (check_token_eq(&p, "ts_force_tslib")) { + pdata->cfg_ts_force_tslib = !!strtol(p, NULL, 0); + continue; + } bad: err("config: failed to parse: %s", line); @@ -73,4 +110,35 @@ bad: fclose(f); } +void omapsdl_config_from_env(struct SDL_PrivateVideoData *pdata) +{ + const char *tmp; + + tmp = getenv("SDL_OMAP_VSYNC"); + if (tmp != NULL) + pdata->cfg_force_vsync = !!strtol(tmp, NULL, 0); + tmp = getenv("SDL_OMAP_FORCE_DOUBLEBUF"); + if (tmp != NULL) + pdata->cfg_force_doublebuf = !!strtol(tmp, NULL, 0); + tmp = getenv("SDL_OMAP_FORCE_DIRECTBUF"); + if (tmp != NULL) + pdata->cfg_force_directbuf = !!strtol(tmp, NULL, 0); + tmp = getenv("SDL_OMAP_NO_TS_TRANSLATE"); + if (tmp != NULL) + pdata->cfg_no_ts_translate = !!strtol(tmp, NULL, 0); + tmp = getenv("SDL_OMAP_TS_FORCE_TSLIB"); + if (tmp != NULL) + pdata->cfg_ts_force_tslib = !!strtol(tmp, NULL, 0); + tmp = getenv("SDL_OMAP_BORDER_CUT"); + if (tmp != NULL) { + int l, r, t, b; + if (sscanf(tmp, "%d,%d,%d,%d", &l, &r, &t, &b) == 4 + && l >= 0 && r >= 0 && t >= 0 && b >= 0) { + pdata->border_l = l, pdata->border_r = r; + pdata->border_t = t, pdata->border_b = b; + } + else + err("border incorrectly specified, ignored"); + } +}