diff options
-rw-r--r-- | cfg-common.h | 4 | ||||
-rwxr-xr-x | configure | 22 | ||||
-rw-r--r-- | libmpdemux/aviwrite.c | 1 | ||||
-rw-r--r-- | libmpdemux/aviwrite.h | 2 | ||||
-rw-r--r-- | libmpdemux/demuxer.c | 4 | ||||
-rw-r--r-- | libmpdemux/tv.c | 104 | ||||
-rw-r--r-- | libmpdemux/tv.h | 13 | ||||
-rw-r--r-- | libmpdemux/tvi_bsdbt848.c | 900 | ||||
-rw-r--r-- | libmpdemux/tvi_def.h | 10 | ||||
-rw-r--r-- | libmpdemux/tvi_dummy.c | 12 | ||||
-rw-r--r-- | libmpdemux/tvi_v4l.c | 11 | ||||
-rw-r--r-- | libmpdemux/video.c | 4 | ||||
-rw-r--r-- | mencoder.c | 64 | ||||
-rw-r--r-- | mplayer.c | 4 |
14 files changed, 703 insertions, 452 deletions
diff --git a/cfg-common.h b/cfg-common.h index bbc08cfb81..d1670bf742 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -107,7 +107,11 @@ #ifdef USE_TV struct config tvopts_conf[]={ {"on", &tv_param_on, CONF_TYPE_FLAG, 0, 0, 1, NULL}, +#ifdef HAVE_TV_BSDBT848 + {"immediatemode", &tv_param_immediate, CONF_TYPE_FLAG, 0, 0, 0, NULL}, +#endif {"noaudio", &tv_param_noaudio, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"audiorate", &tv_param_audiorate, CONF_TYPE_INT, 0, 0, 0, NULL}, {"driver", &tv_param_driver, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"device", &tv_param_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"freq", &tv_param_freq, CONF_TYPE_STRING, 0, 0, 0, NULL}, @@ -3228,6 +3228,21 @@ if test "$_largefiles" = yes || freebsd ; then fi fi +echocheck "ftello()" +# if we dont have ftello map it to ftell +cat > $TMPC << EOF +#include <stdio.h> +int main (void) { ftello(stdin); return 0; } +EOF +_ftello=no +cc_check && _ftello=yes +if test "$_ftello" = yes ; then + _def_ftello='#define HAVE_FTELLO 1' +else + _def_ftello='#undef HAVE_FTELLO' +fi +echores "$_ftello" + # Determine OS dependent libs if cygwin ; then _confcygwin='TARGET_CYGWIN = yes' @@ -3507,6 +3522,13 @@ $_def_rtc /* Define this if your system has the header file for the OSS sound interface */ $_def_sys_soundcard +/* Define this if your system uses ftello() for off_t seeking */ + +$_def_ftello +#ifndef HAVE_FTELLO +# define ftello(a) ftell(a) +#endif + /* Define this if your system has the "malloc.h" header file */ $_def_malloc diff --git a/libmpdemux/aviwrite.c b/libmpdemux/aviwrite.c index be5f5977ae..d0e7f513e3 100644 --- a/libmpdemux/aviwrite.c +++ b/libmpdemux/aviwrite.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include "config.h" diff --git a/libmpdemux/aviwrite.h b/libmpdemux/aviwrite.h index f1a9fb6bb6..7973649747 100644 --- a/libmpdemux/aviwrite.h +++ b/libmpdemux/aviwrite.h @@ -10,7 +10,7 @@ typedef struct { int id; // stream no unsigned int ckid; // chunk id (00dc 01wb etc) double timer; - unsigned int size; + off_t size; // buffering: unsigned char *buffer; unsigned int buffer_size; diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 4585d1f046..18f1739d42 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -214,7 +214,7 @@ int demux_nuv_fill_buffer(demuxer_t *demux); extern tvi_handle_t *tv_handler; extern int tv_param_on; -extern int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh); +extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh); extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh); #endif int demux_y4m_fill_buffer(demuxer_t *demux); @@ -242,7 +242,7 @@ int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){ case DEMUXER_TYPE_REAL: return demux_real_fill_buffer(demux); case DEMUXER_TYPE_NUV: return demux_nuv_fill_buffer(demux); #ifdef USE_TV - case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, tv_handler); + case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, ds, tv_handler); #endif case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux); case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds); diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 13a3a12e78..a7ad398055 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -6,7 +6,7 @@ API idea based on libvo2 Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich@msu.edu) - try to fix audio support, and bktr *BSD support. + to add support for audio, and bktr *BSD support. */ @@ -37,7 +37,11 @@ int tv_param_on = 0; #include "frequencies.h" /* some default values */ +int tv_param_audiorate = 44100; int tv_param_noaudio = 0; +#ifdef HAVE_TV_BSDBT848 +int tv_param_immediate = 0; +#endif char *tv_param_freq = NULL; char *tv_param_channel = NULL; char *tv_param_norm = "pal"; @@ -58,57 +62,39 @@ float tv_param_fps = -1.0; */ /* fill demux->video and demux->audio */ -int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh) +int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds, tvi_handle_t *tvh) { demux_packet_t* dp; sh_video_t *sh_video = demux->video->sh; u_int len; - u_int cframe; int aframeswaiting; - len = cframe = -1; + len = 0; /* ================== ADD AUDIO PACKET =================== */ - if (tv_param_noaudio == 0 && + if (ds==demux->audio && tv_param_noaudio == 0 && tvh->functions->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) { len = tvh->functions->get_audio_framesize(tvh->priv); - do { - dp=new_demux_packet(len); - aframeswaiting=tvh->functions->grab_audio_frame(tvh->priv, - dp->buffer,len); - dp->pts=tvh->seq/sh_video->fps; - dp->pos=tvh->seq*len; - ds_add_packet(demux->audio,dp); - - tvh->seq++; - - } while (aframeswaiting > 0); + dp=new_demux_packet(len); + dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len); + ds_add_packet(demux->audio,dp); } /* ================== ADD VIDEO PACKET =================== */ - if (tvh->functions->control(tvh->priv, + if (ds==demux->video && tvh->functions->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE) { - len = tvh->functions->get_video_framesize(tvh->priv); - - dp=new_demux_packet(len); - - cframe=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, - len); - - if(tv_param_noaudio == 1) tvh->seq = cframe; - - dp->pos=tvh->seq*len; - dp->pts=tvh->seq/sh_video->fps; - - ds_add_packet(demux->video,dp); - } + len = tvh->functions->get_video_framesize(tvh->priv); + dp=new_demux_packet(len); + dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len); + ds_add_packet(demux->video,dp); + } return 1; } @@ -190,7 +176,7 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE) { mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n"); - goto start_device; + goto done; } /* select channel list */ @@ -214,7 +200,7 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) if (tv_param_freq && tv_param_channel) { mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n"); - goto start_device; + goto done; } /* we need to set frequency */ @@ -251,9 +237,9 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) } } -start_device: +done: /* also start device! */ - return(funcs->start(tvh->priv)); + return 1; } int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) @@ -286,6 +272,15 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) printf("fps: %f, frametime: %f\n", sh_video->fps, sh_video->frametime); +#ifdef HAVE_TV_BSDBT848 + /* If playback only mode, go to immediate mode, fail silently */ + if(tv_param_immediate == 1) + { + funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0); + tv_param_noaudio = 1; + } +#endif + /* set width */ funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w); @@ -308,6 +303,10 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) int sh_audio_format; /* yeah, audio is present */ + + funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE, + &tv_param_audiorate); + if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE) goto no_audio; @@ -334,7 +333,6 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) } sh_audio = new_sh_audio(demuxer, 0); - sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX)); funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, &sh_audio->samplerate); @@ -347,33 +345,21 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) sh_audio->sample_format = audio_format; sh_audio->i_bps = sh_audio->o_bps = - sh_audio->samplerate * sh_audio->samplesize/8 * + sh_audio->samplerate * sh_audio->samplesize * sh_audio->channels; + // emulate WF for win32 codecs: + sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX)); sh_audio->wf->wFormatTag = sh_audio->format; sh_audio->wf->nChannels = sh_audio->channels; - switch(audio_format) - { - case AFMT_U8: - case AFMT_S8: - sh_audio->wf->wBitsPerSample = 8; - break; - case AFMT_U16_LE: - case AFMT_U16_BE: - case AFMT_S16_LE: - case AFMT_S16_BE: - sh_audio->wf->wBitsPerSample = 16; - break; - case AFMT_S32_LE: - case AFMT_S32_BE: - sh_audio->wf->wBitsPerSample = 32; - break; - } + sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8; sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; - sh_audio->wf->nBlockAlign = sh_audio->wf->nAvgBytesPerSec; - sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels * - sh_audio->samplesize/8 * - sh_audio->samplerate; + sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels; + sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps; + + mp_msg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n", + sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample, + sh_audio->wf->nSamplesPerSec); demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; @@ -381,7 +367,7 @@ int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) } no_audio: - return(1); + return(funcs->start(tvh->priv)); } /* ================== STREAM_TV ===================== */ diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index ab42ec1e9c..5893c8a46d 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -21,6 +21,8 @@ extern int tv_param_input; extern char *tv_param_outfmt; extern float tv_param_fps; extern int tv_param_noaudio; +extern int tv_param_immediate; +extern int tv_param_audiorate; typedef struct tvi_info_s { @@ -36,9 +38,12 @@ typedef struct tvi_functions_s int (*uninit)(); int (*control)(); int (*start)(); - int (*grab_video_frame)(); + double (*grab_video_frame)(); +#ifdef HAVE_TV_BSDBT848 + double (*grabimmediate_video_frame)(); +#endif int (*get_video_framesize)(); - int (*grab_audio_frame)(); + double (*grab_audio_frame)(); int (*get_audio_framesize)(); } tvi_functions_t; @@ -67,6 +72,9 @@ typedef struct tvi_handle_s { #define TVI_CONTROL_IS_AUDIO 0x1 #define TVI_CONTROL_IS_VIDEO 0x2 #define TVI_CONTROL_IS_TUNER 0x3 +#ifdef HAVE_TV_BSDBT848 +#define TVI_CONTROL_IMMEDIATE 0x4 +#endif /* VIDEO controls */ #define TVI_CONTROL_VID_GET_FPS 0x101 @@ -107,6 +115,7 @@ typedef struct tvi_handle_s { #define TVI_CONTROL_AUD_GET_SAMPLERATE 0x302 #define TVI_CONTROL_AUD_GET_SAMPLESIZE 0x303 #define TVI_CONTROL_AUD_GET_CHANNELS 0x304 +#define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305 /* SPECIFIC controls */ #define TVI_CONTROL_SPC_GET_INPUT 0x401 /* set input channel (tv,s-video,composite..) */ diff --git a/libmpdemux/tvi_bsdbt848.c b/libmpdemux/tvi_bsdbt848.c index 5718bb3b9a..6e7e4967f1 100644 --- a/libmpdemux/tvi_bsdbt848.c +++ b/libmpdemux/tvi_bsdbt848.c @@ -1,27 +1,32 @@ /* - (C)2002 Charles R. Henrich (henrich@msu.edu) - *BSD (hopefully, requires working driver!) BrookTree capture support. + (C)2002 Charles R. Henrich (henrich@msu.edu) + *BSD (hopefully, requires working driver!) BrookTree capture support. - Still in (active) development! + Still in (active) development! - v1.0 Feb 19 2002 First Release, need to add support for changing - audio parameters. + v1.1 Mar 13 2002 Fully functional, need to move ring buffer to + the kernel driver. + v1.0 Feb 19 2002 First Release, need to add support for changing + audio parameters. */ #include "config.h" #if defined(USE_TV) && defined(HAVE_TV_BSDBT848) +#define RINGSIZE 8 +#define FRAGSIZE 4096 /* (2^12 see SETFRAGSIZE below) */ + #define TRUE (1==1) #define FALSE (1==0) #define PAL_WIDTH 768 #define PAL_HEIGHT 576 -#define PAL_FPS 25 +#define PAL_FPS 25 #define NTSC_WIDTH 640 #define NTSC_HEIGHT 480 -#define NTSC_FPS 30 +#define NTSC_FPS 30 #include <stdio.h> #include <stdlib.h> @@ -29,11 +34,14 @@ #include <fcntl.h> #include <sys/types.h> #include <sys/mman.h> +#include <sys/filio.h> +#include <sys/time.h> #include <signal.h> #include <string.h> #include <machine/ioctl_meteor.h> #include <machine/ioctl_bt848.h> + #ifdef HAVE_SYS_SOUNDCARD_H #include <sys/soundcard.h> #else @@ -45,52 +53,71 @@ /* information about this file */ static tvi_info_t info = { - "Brooktree848 Support", - "bt848", - "Charles Henrich", - "in development" + "Brooktree848 Support", + "bsdbt848", + "Charles Henrich", + "in development" }; +typedef struct { + int dirty; + double timestamp; + char *buf; +} RBFRAME; + /* private data's */ typedef struct { /* Audio */ - char *dspdev; - int dspready; - int dspfd; - int dspsamplesize; - int dspstereo; - int dspspeed; - int dspfmt; - int dspframesize; + char *dspdev; + int dspready; + int dspfd; + int dspsamplesize; + int dspstereo; + int dspspeed; + int dspfmt; + int dspframesize; + int dsprate; + long long dspbytesread; /* Video */ - char *btdev; - int videoready; - int btfd; - int source; - int maxfps; - int fps; - int iformat; - int maxheight; - int maxwidth; - struct meteor_geomet geom; - struct meteor_capframe capframe; - int buffersize; - unsigned char *buffer; - int currentframe; + char *btdev; + int videoready; + int btfd; + int source; + int maxfps; + int fps; + int iformat; + int maxheight; + int maxwidth; + struct meteor_geomet geom; + struct meteor_capframe capframe; + +/* Frame Buffer */ + + int framebufsize; + float timestamp; + int curpaintframe; + int curbufframe; + unsigned char *livebuf; + RBFRAME framebuf[RINGSIZE]; /* Inputs */ - int input; + int input; /* Tuner */ - char *tunerdev; - int tunerfd; - int tunerready; - u_long tunerfreq; - struct bktr_chnlset cset; + char *tunerdev; + int tunerfd; + int tunerready; + u_long tunerfreq; + struct bktr_chnlset cset; + +/* Other */ + + int immediatemode; + double starttime; } priv_t; @@ -98,10 +125,30 @@ typedef struct { static priv_t *G_private=NULL; +static int getinput(int innumber); static void processframe(int signal) { -G_private->currentframe++; +struct timeval curtime; + +if(G_private->immediatemode == TRUE) return; + +gettimeofday(&curtime, NULL); + +if(G_private->framebuf[G_private->curpaintframe].dirty == TRUE) + { + memcpy(G_private->framebuf[G_private->curpaintframe].buf, + G_private->livebuf, G_private->framebufsize); + + G_private->framebuf[G_private->curpaintframe].dirty = FALSE; + + G_private->framebuf[G_private->curpaintframe].timestamp = + curtime.tv_sec + curtime.tv_usec*.000001; + + G_private->curpaintframe++; + + if(G_private->curpaintframe >= RINGSIZE) G_private->curpaintframe = 0; + } return; } @@ -109,269 +156,295 @@ return; /* handler creator - entry point ! */ tvi_handle_t *tvi_init_bsdbt848(char *device) { - return(new_handle()); + return(new_handle()); } static int control(priv_t *priv, int cmd, void *arg) { - switch(cmd) - { + switch(cmd) + { /* Tuner Controls */ - case TVI_CONTROL_IS_TUNER: - if(priv->tunerready == FALSE) return TVI_CONTROL_FALSE; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_TUN_GET_FREQ: - { - if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0) - { - perror("GETFREQ:ioctl"); - return(TVI_CONTROL_FALSE); - } - - (int)*(void **)arg = priv->tunerfreq; - return(TVI_CONTROL_TRUE); - } - - case TVI_CONTROL_TUN_SET_FREQ: - { - priv->tunerfreq = (int)*(void **)arg; - - if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0) - { - perror("SETFREQ:ioctl"); - return(0); - } - - return(TVI_CONTROL_TRUE); - } - - case TVI_CONTROL_TUN_GET_TUNER: - case TVI_CONTROL_TUN_SET_TUNER: + case TVI_CONTROL_IS_TUNER: + if(priv->tunerready == FALSE) return TVI_CONTROL_FALSE; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_TUN_GET_FREQ: + { + if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0) + { + perror("GETFREQ:ioctl"); + return(TVI_CONTROL_FALSE); + } + + (int)*(void **)arg = priv->tunerfreq; + return(TVI_CONTROL_TRUE); + } + + case TVI_CONTROL_TUN_SET_FREQ: + { + priv->tunerfreq = (int)*(void **)arg; + + if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0) + { + perror("SETFREQ:ioctl"); + return(0); + } + + return(TVI_CONTROL_TRUE); + } + + case TVI_CONTROL_TUN_GET_TUNER: + case TVI_CONTROL_TUN_SET_TUNER: /* Inputs */ case TVI_CONTROL_SPC_GET_INPUT: - { - if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0) - { - perror("GINPUT:ioctl"); - return(TVI_CONTROL_FALSE); - } - - (int)*(void **)arg = priv->input; - return(TVI_CONTROL_TRUE); - } - + { + if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0) + { + perror("GINPUT:ioctl"); + return(TVI_CONTROL_FALSE); + } + + (int)*(void **)arg = priv->input; + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_SPC_SET_INPUT: - { - priv->input = getinput((int)*(void **)arg); + { + priv->input = getinput((int)*(void **)arg); - if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0) - { - perror("tunerfreq:ioctl"); - return(0); - } + if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0) + { + perror("tunerfreq:ioctl"); + return(0); + } - return(TVI_CONTROL_TRUE); - } + return(TVI_CONTROL_TRUE); + } /* Audio Controls */ - case TVI_CONTROL_IS_AUDIO: - if(priv->dspready == FALSE) return TVI_CONTROL_FALSE; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_AUD_GET_FORMAT: - { - (int)*(void **)arg = AFMT_S16_LE; - return(TVI_CONTROL_TRUE); - } - case TVI_CONTROL_AUD_GET_CHANNELS: - { - (int)*(void **)arg = 2; - return(TVI_CONTROL_TRUE); - } - case TVI_CONTROL_AUD_GET_SAMPLERATE: - { - (int)*(void **)arg = 44100; - return(TVI_CONTROL_TRUE); - } - case TVI_CONTROL_AUD_GET_SAMPLESIZE: - { - (int)*(void **)arg = priv->dspsamplesize; - return(TVI_CONTROL_TRUE); - } + case TVI_CONTROL_IS_AUDIO: + if(priv->dspready == FALSE) return TVI_CONTROL_FALSE; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_AUD_GET_FORMAT: + { + (int)*(void **)arg = AFMT_S16_LE; + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_AUD_GET_CHANNELS: + { + (int)*(void **)arg = 2; + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_AUD_SET_SAMPLERATE: + { + int dspspeed = (int)*(void **)arg; + + if(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &dspspeed) == -1) + { + perror("invalidaudiorate"); + return(TVI_CONTROL_FALSE); + } + + priv->dspspeed = dspspeed; + + priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ + priv->fps * (priv->dspstereo+1); + priv->dsprate = priv->dspspeed * priv->dspsamplesize/8* + (priv->dspstereo+1); + + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_AUD_GET_SAMPLERATE: + { + (int)*(void **)arg = priv->dspspeed; + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_AUD_GET_SAMPLESIZE: + { + (int)*(void **)arg = priv->dspsamplesize/8; + return(TVI_CONTROL_TRUE); + } /* Video Controls */ - case TVI_CONTROL_IS_VIDEO: - if(priv->videoready == FALSE) return TVI_CONTROL_FALSE; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_TUN_SET_NORM: - { - int req_mode = (int)*(void **)arg; - - priv->iformat = METEOR_FMT_AUTOMODE; - - if(req_mode == TV_NORM_PAL) - { - priv->iformat = METEOR_FMT_PAL; - priv->maxheight = PAL_HEIGHT; - priv->maxwidth = PAL_WIDTH; - priv->maxfps = PAL_FPS; - priv->fps = PAL_FPS; - - if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; - - if(priv->geom.rows > priv->maxheight) - { - priv->geom.rows = priv->maxheight; - } - - if(priv->geom.columns > priv->maxwidth) - { - priv->geom.columns = priv->maxwidth; - } - } - - if(req_mode == TV_NORM_NTSC) - { - priv->iformat = METEOR_FMT_NTSC; - priv->maxheight = NTSC_HEIGHT; - priv->maxwidth = NTSC_WIDTH; - priv->maxfps = NTSC_FPS; - priv->fps = NTSC_FPS; - - priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ - priv->fps * (priv->dspstereo+1); - - if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; - - if(priv->geom.rows > priv->maxheight) - { - priv->geom.rows = priv->maxheight; - } - - if(priv->geom.columns > priv->maxwidth) - { - priv->geom.columns = priv->maxwidth; - } - } - - if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM; - - if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) - { - perror("format:ioctl"); - return(TVI_CONTROL_FALSE); - } - - if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) - { - perror("geo:ioctl"); - return(0); - } - - if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0) - { - perror("fps:ioctl"); - return(0); - } - - return(TVI_CONTROL_TRUE); - } - - case TVI_CONTROL_VID_GET_FORMAT: - (int)*(void **)arg = IMGFMT_UYVY; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_VID_SET_FORMAT: - { - int req_fmt = (int)*(void **)arg; - - if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE); - - return(TVI_CONTROL_TRUE); - } - case TVI_CONTROL_VID_SET_WIDTH: - priv->geom.columns = (int)*(void **)arg; - - if(priv->geom.columns > priv->maxwidth) - { - priv->geom.columns = priv->maxwidth; - } - - if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) - { - perror("width:ioctl"); - return(0); - } - - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_VID_GET_WIDTH: - (int)*(void **)arg = priv->geom.columns; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_VID_SET_HEIGHT: - priv->geom.rows = (int)*(void **)arg; - - if(priv->geom.rows > priv->maxheight) - { - priv->geom.rows = priv->maxheight; - } - - if(priv->geom.rows <= priv->maxheight / 2) - { - priv->geom.oformat |= METEOR_GEO_EVEN_ONLY; - } - - if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) - { - perror("height:ioctl"); - return(0); - } - - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_VID_GET_HEIGHT: - (int)*(void **)arg = priv->geom.rows; - return(TVI_CONTROL_TRUE); - - case TVI_CONTROL_VID_GET_FPS: - (int)*(void **)arg = (int)priv->fps; - return(TVI_CONTROL_TRUE); + case TVI_CONTROL_IS_VIDEO: + if(priv->videoready == FALSE) return TVI_CONTROL_FALSE; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_TUN_SET_NORM: + { + int req_mode = (int)*(void **)arg; + + priv->iformat = METEOR_FMT_AUTOMODE; + + if(req_mode == TV_NORM_PAL) + { + priv->iformat = METEOR_FMT_PAL; + priv->maxheight = PAL_HEIGHT; + priv->maxwidth = PAL_WIDTH; + priv->maxfps = PAL_FPS; + priv->fps = PAL_FPS; + + if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; + + if(priv->geom.rows > priv->maxheight) + { + priv->geom.rows = priv->maxheight; + } + + if(priv->geom.columns > priv->maxwidth) + { + priv->geom.columns = priv->maxwidth; + } + } + + if(req_mode == TV_NORM_NTSC) + { + priv->iformat = METEOR_FMT_NTSC; + priv->maxheight = NTSC_HEIGHT; + priv->maxwidth = NTSC_WIDTH; + priv->maxfps = NTSC_FPS; + priv->fps = NTSC_FPS; + + priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ + priv->fps * (priv->dspstereo+1); + priv->dsprate = priv->dspspeed * priv->dspsamplesize/8 * + (priv->dspstereo+1); + + if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; + + if(priv->geom.rows > priv->maxheight) + { + priv->geom.rows = priv->maxheight; + } + + if(priv->geom.columns > priv->maxwidth) + { + priv->geom.columns = priv->maxwidth; + } + } + + if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM; + + if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) + { + perror("format:ioctl"); + return(TVI_CONTROL_FALSE); + } + + if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) + { + perror("geo:ioctl"); + return(0); + } + + if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0) + { + perror("fps:ioctl"); + return(0); + } + + return(TVI_CONTROL_TRUE); + } + + case TVI_CONTROL_VID_GET_FORMAT: + (int)*(void **)arg = IMGFMT_UYVY; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_VID_SET_FORMAT: + { + int req_fmt = (int)*(void **)arg; + + if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE); + + return(TVI_CONTROL_TRUE); + } + case TVI_CONTROL_VID_SET_WIDTH: + priv->geom.columns = (int)*(void **)arg; + + if(priv->geom.columns > priv->maxwidth) + { + priv->geom.columns = priv->maxwidth; + } + + if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) + { + perror("width:ioctl"); + return(0); + } + + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_VID_GET_WIDTH: + (int)*(void **)arg = priv->geom.columns; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_VID_SET_HEIGHT: + priv->geom.rows = (int)*(void **)arg; + + if(priv->geom.rows > priv->maxheight) + { + priv->geom.rows = priv->maxheight; + } + + if(priv->geom.rows <= priv->maxheight / 2) + { + priv->geom.oformat |= METEOR_GEO_EVEN_ONLY; + } + + if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) + { + perror("height:ioctl"); + return(0); + } + + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_VID_GET_HEIGHT: + (int)*(void **)arg = priv->geom.rows; + return(TVI_CONTROL_TRUE); + + case TVI_CONTROL_VID_GET_FPS: + (int)*(void **)arg = (int)priv->fps; + return(TVI_CONTROL_TRUE); /* - case TVI_CONTROL_VID_SET_FPS: - priv->fps = (int)*(void **)arg; + case TVI_CONTROL_VID_SET_FPS: + priv->fps = (int)*(void **)arg; - if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; + if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; - if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0) - { - perror("fps:ioctl"); - retur |