Mercurial > mplayer.hg
changeset 13978:2a9afbfc79d7
setting the norm using text ID instead of numeric
author | henry |
---|---|
date | Fri, 19 Nov 2004 13:04:24 +0000 |
parents | 7895a1b73828 |
children | d5dff36405c3 |
files | libmpdemux/tv.c libmpdemux/tv.h libmpdemux/tvi_v4l2.c |
diffstat | 3 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/tv.c Fri Nov 19 12:03:41 2004 +0000 +++ b/libmpdemux/tv.c Fri Nov 19 13:04:24 2004 +0000 @@ -123,8 +123,11 @@ return 1; } -static int norm_from_string(char* norm) +static int norm_from_string(tvi_handle_t *tvh, char* norm) { +#ifdef HAVE_TV_V4L2 + if (strcmp(tv_param_driver, "v4l2") != 0) { +#endif if (!strcasecmp(norm, "pal")) return TV_NORM_PAL; else if (!strcasecmp(norm, "ntsc")) @@ -143,6 +146,17 @@ mp_msg(MSGT_TV, MSGL_V, "tv.c: norm_from_string(%s): Bogus norm parameter, setting PAL.\n", norm); return TV_NORM_PAL; } +#ifdef HAVE_TV_V4L2 + } else { + tvi_functions_t *funcs = tvh->functions; + char str[8]; + strncpy(str, norm, sizeof(str)-1); + str[sizeof(str)-1] = '\0'; + if (funcs->control(tvh->priv, TVI_CONTROL_SPC_GET_NORMID, str) != TVI_CONTROL_TRUE) + return 0; + return *(int *)str; + } +#endif } static int open_tv(tvi_handle_t *tvh) @@ -181,10 +195,16 @@ funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); #ifdef HAVE_TV_V4L2 - if (strcmp(tv_param_driver, "v4l2") != 0) { + if (!strcmp(tv_param_driver, "v4l2") && tv_param_normid >= 0) { + mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", tv_param_normid); + if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tv_param_normid) != TVI_CONTROL_TRUE) { + mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n"); + return 0; + } + } else { #endif /* select video norm */ - tvh->norm = norm_from_string(tv_param_norm); + tvh->norm = norm_from_string(tvh, tv_param_norm); mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm); if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) { @@ -192,14 +212,6 @@ return 0; } #ifdef HAVE_TV_V4L2 - } else { - if (tv_param_normid >= 0) { - mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", tv_param_normid); - if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tv_param_normid) != TVI_CONTROL_TRUE) { - mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n"); - return 0; - } - } } #endif @@ -826,7 +838,7 @@ int tv_set_norm(tvi_handle_t *tvh, char* norm) { - tvh->norm = norm_from_string(norm); + tvh->norm = norm_from_string(tvh, norm); mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm); if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
--- a/libmpdemux/tv.h Fri Nov 19 12:03:41 2004 +0000 +++ b/libmpdemux/tv.h Fri Nov 19 13:04:24 2004 +0000 @@ -156,6 +156,7 @@ /* SPECIFIC controls */ #define TVI_CONTROL_SPC_GET_INPUT 0x401 /* set input channel (tv,s-video,composite..) */ #define TVI_CONTROL_SPC_SET_INPUT 0x402 /* set input channel (tv,s-video,composite..) */ +#define TVI_CONTROL_SPC_GET_NORMID 0x403 /* get normid from norm name */ extern tvi_handle_t *tv_begin(void); extern int tv_init(tvi_handle_t *tvh);
--- a/libmpdemux/tvi_v4l2.c Fri Nov 19 12:03:41 2004 +0000 +++ b/libmpdemux/tvi_v4l2.c Fri Nov 19 13:04:24 2004 +0000 @@ -693,6 +693,22 @@ return TVI_CONTROL_FALSE; } return TVI_CONTROL_TRUE; + case TVI_CONTROL_SPC_GET_NORMID: + { + int i; + for (i = 0;; i++) { + struct v4l2_standard standard; + memset(&standard, 0, sizeof(standard)); + standard.index = i; + if (-1 == ioctl(priv->video_fd, VIDIOC_ENUMSTD, &standard)) + return TVI_CONTROL_FALSE; + if (!strcasecmp(standard.name, (char *)arg)) { + *(int *)arg = i; + return TVI_CONTROL_TRUE; + } + } + return TVI_CONTROL_FALSE; + } case TVI_CONTROL_SPC_GET_INPUT: if (ioctl(priv->video_fd, VIDIOC_G_INPUT, (int *)arg) < 0) { mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get input failed: %s\n",