# HG changeset patch # User gabucino # Date 1059988390 0 # Node ID 141141fdd250ade3e95076a6c60692d5965eccb9 # Parent 880e5d24c4c3c4f10f991f6aed09b0a6c5f814ec I'd like to change tv tuner frequency in the slave mode. So this patch helps me. Patch by Kir Kostuchenko diff -r 880e5d24c4c3 -r 141141fdd250 DOCS/tech/slave.txt --- a/DOCS/tech/slave.txt Mon Aug 04 07:46:22 2003 +0000 +++ b/DOCS/tech/slave.txt Mon Aug 04 09:13:10 2003 +0000 @@ -76,5 +76,9 @@ Set the current TV channel. tv_last_channel Set the current TV channel to the last one. +tv_set_freq + Set the tv tuner frequency. +tv_set_norm + Set the tv tuner norm. PAL, SECAM, NTSC and so on.. gui_[loadsubtitle|about|play|stop] GUI actions diff -r 880e5d24c4c3 -r 141141fdd250 input/input.c --- a/input/input.c Mon Aug 04 07:46:22 2003 +0000 +++ b/input/input.c Mon Aug 04 09:13:10 2003 +0000 @@ -85,6 +85,8 @@ { MP_CMD_TV_STEP_CHANNEL_LIST, "tv_step_chanlist", 0, { {-1,{0}} } }, { MP_CMD_TV_SET_CHANNEL, "tv_set_channel", 1, { { MP_CMD_ARG_STRING, {0}}, {-1,{0}} }}, { MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", 0, { {-1,{0}} } }, + { MP_CMD_TV_SET_FREQ, "tv_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, + { MP_CMD_TV_SET_NORM, "tv_set_norm", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, #endif { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {-1,{0}} } }, { MP_CMD_SCREENSHOT, "screenshot", 0, { {-1,{0}} } }, diff -r 880e5d24c4c3 -r 141141fdd250 input/input.h --- a/input/input.h Mon Aug 04 07:46:22 2003 +0000 +++ b/input/input.h Mon Aug 04 09:13:10 2003 +0000 @@ -43,6 +43,8 @@ #define MP_CMD_SUB_ALIGNMENT 39 #define MP_CMD_TV_LAST_CHANNEL 40 #define MP_CMD_OSD_SHOW_TEXT 41 +#define MP_CMD_TV_SET_FREQ 42 +#define MP_CMD_TV_SET_NORM 43 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 diff -r 880e5d24c4c3 -r 141141fdd250 libmpdemux/tv.c --- a/libmpdemux/tv.c Mon Aug 04 07:46:22 2003 +0000 +++ b/libmpdemux/tv.c Mon Aug 04 09:13:10 2003 +0000 @@ -118,9 +118,27 @@ return 1; } - /* forward declarations */ -int tv_set_freq(tvi_handle_t *tvh, unsigned long freq); -int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq); +static int norm_from_string(char* norm) +{ + if (!strcasecmp(norm, "pal")) + return TV_NORM_PAL; + else if (!strcasecmp(norm, "ntsc")) + return TV_NORM_NTSC; + else if (!strcasecmp(norm, "secam")) + return TV_NORM_SECAM; + else if (!strcasecmp(norm, "palnc")) + return TV_NORM_PALNC; + else if (!strcasecmp(norm, "palm")) + return TV_NORM_PALM; + else if (!strcasecmp(norm, "paln")) + return TV_NORM_PALN; + else if (!strcasecmp(norm, "ntscjp")) + return TV_NORM_NTSCJP; + else { + mp_msg(MSGT_TV, MSGL_V, "tv.c : norm_from_string(%s): Bogus norm parameter, setting PAL.\n", norm); + return TV_NORM_PAL; + } +} static int open_tv(tvi_handle_t *tvh) { @@ -162,24 +180,7 @@ funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); /* select video norm */ - if (!strcasecmp(tv_param_norm, "pal")) - tvh->norm = TV_NORM_PAL; - else if (!strcasecmp(tv_param_norm, "ntsc")) - tvh->norm = TV_NORM_NTSC; - else if (!strcasecmp(tv_param_norm, "secam")) - tvh->norm = TV_NORM_SECAM; - else if (!strcasecmp(tv_param_norm, "palnc")) - tvh->norm = TV_NORM_PALNC; - else if (!strcasecmp(tv_param_norm, "palm")) - tvh->norm = TV_NORM_PALM; - else if (!strcasecmp(tv_param_norm, "paln")) - tvh->norm = TV_NORM_PALN; - else if (!strcasecmp(tv_param_norm, "ntscjp")) - tvh->norm = TV_NORM_NTSCJP; - else { - mp_msg(MSGT_TV, MSGL_V, "Bogus norm parameter, setting PAL.\n"); - tvh->norm = TV_NORM_PAL; - } + tvh->norm = norm_from_string(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) { @@ -804,4 +805,17 @@ { return(1); } + +int tv_set_norm(tvi_handle_t *tvh, char* norm) +{ + tvh->norm = norm_from_string(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) { + mp_msg(MSGT_TV, MSGL_ERR, "Error: cannot set norm!\n"); + return 0; + } + return(1); +} + #endif /* USE_TV */ diff -r 880e5d24c4c3 -r 141141fdd250 libmpdemux/tv.h --- a/libmpdemux/tv.h Mon Aug 04 07:46:22 2003 +0000 +++ b/libmpdemux/tv.h Mon Aug 04 09:13:10 2003 +0000 @@ -177,6 +177,11 @@ int tv_step_norm(tvi_handle_t *tvh); int tv_step_chanlist(tvi_handle_t *tvh); +int tv_set_freq(tvi_handle_t *tvh, unsigned long freq); +int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq); + +int tv_set_norm(tvi_handle_t *tvh, char* norm); + #define TV_NORM_PAL 1 #define TV_NORM_NTSC 2 #define TV_NORM_SECAM 3 diff -r 880e5d24c4c3 -r 141141fdd250 mplayer.c --- a/mplayer.c Mon Aug 04 07:46:22 2003 +0000 +++ b/mplayer.c Mon Aug 04 09:13:10 2003 +0000 @@ -2777,6 +2777,14 @@ frame_dropping = v > 2 ? 2 : v; } break; #ifdef USE_TV + case MP_CMD_TV_SET_FREQ : { + if (file_format == DEMUXER_TYPE_TV) + tv_set_freq((tvi_handle_t*)(demuxer->priv), cmd->args[0].v.f * 16.0); + } break; + case MP_CMD_TV_SET_NORM : { + if (file_format == DEMUXER_TYPE_TV) + tv_set_norm((tvi_handle_t*)(demuxer->priv), cmd->args[0].v.s); + } break; case MP_CMD_TV_STEP_CHANNEL : { if (file_format == DEMUXER_TYPE_TV) { int v = cmd->args[0].v.i;