setting the norm using text ID instead of numeric

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13979 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
henry 2004-11-19 13:04:24 +00:00
parent 26046bd853
commit dabdcbabbc
3 changed files with 41 additions and 12 deletions

View File

@ -123,8 +123,11 @@ int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
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 @@ static int norm_from_string(char* norm)
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 @@ static int open_tv(tvi_handle_t *tvh)
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 @@ static int open_tv(tvi_handle_t *tvh)
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_step_chanlist(tvi_handle_t *tvh)
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) {

View File

@ -156,6 +156,7 @@ char *tv_channel_last_real;
/* 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);

View File

@ -693,6 +693,22 @@ static int control(priv_t *priv, int cmd, void *arg)
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",