Mercurial > mplayer.hg
annotate stream/tvi_bsdbt848.c @ 26064:e173fde700da
Replace silly check for config.h inclusion, just include it.
author | diego |
---|---|
date | Sun, 24 Feb 2008 23:44:35 +0000 |
parents | 7d5823bd4517 |
children | c43ce7268677 |
rev | line source |
---|---|
5081 | 1 /* |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
2 (C)2002 Charles R. Henrich (henrich@msu.edu) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
3 *BSD (hopefully, requires working driver!) BrookTree capture support. |
5081 | 4 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
5 Still in (active) development! |
5081 | 6 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
7 v1.1 Mar 13 2002 Fully functional, need to move ring buffer to |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
8 the kernel driver. |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
9 v1.0 Feb 19 2002 First Release, need to add support for changing |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
10 audio parameters. |
5081 | 11 */ |
12 | |
13 #include "config.h" | |
14 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
15 #define RINGSIZE 8 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
16 #define FRAGSIZE 4096 /* (2^12 see SETFRAGSIZE below) */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
17 |
5081 | 18 #define TRUE (1==1) |
19 #define FALSE (1==0) | |
20 | |
21 #define PAL_WIDTH 768 | |
22 #define PAL_HEIGHT 576 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
23 #define PAL_FPS 25 |
5081 | 24 |
25 #define NTSC_WIDTH 640 | |
26 #define NTSC_HEIGHT 480 | |
8953
1ebf4c3ab032
NTSC is 29.97 fps, not 30. wrong values here are likely to cause
rfelker
parents:
5886
diff
changeset
|
27 #define NTSC_FPS 29.97 |
5081 | 28 |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <unistd.h> | |
32 #include <fcntl.h> | |
33 #include <sys/types.h> | |
34 #include <sys/mman.h> | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
35 #include <sys/filio.h> |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
36 #include <sys/time.h> |
5081 | 37 #include <signal.h> |
38 #include <string.h> | |
24819
454f3a34d408
add missing include (errno.h). fix compilation on openbsd
ivo
parents:
24411
diff
changeset
|
39 #include <errno.h> |
5081 | 40 |
11723 | 41 #include <sys/param.h> |
22934 | 42 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
43 #include <sys/audioio.h> |
22934 | 44 #endif |
45 | |
46 #ifdef IOCTL_METEOR_H_NAME | |
47 #include IOCTL_METEOR_H_NAME | |
48 #endif | |
49 | |
50 #ifdef IOCTL_BT848_H_NAME | |
51 #include IOCTL_BT848_H_NAME | |
5872 | 52 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
53 |
5142 | 54 #ifdef HAVE_SYS_SOUNDCARD_H |
55 #include <sys/soundcard.h> | |
56 #else | |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
57 #ifdef HAVE_SOUNDCARD_H |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
58 #include <soundcard.h> |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
59 #else |
5081 | 60 #include <machine/soundcard.h> |
5142 | 61 #endif |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
62 #endif |
5081 | 63 |
17012 | 64 #include "libaf/af_format.h" |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19271
diff
changeset
|
65 #include "libmpcodecs/img_format.h" |
5081 | 66 #include "tv.h" |
24411 | 67 #include "help_mp.h" |
24193 | 68 #include "mp_msg.h" |
5081 | 69 |
23883 | 70 static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param); |
5081 | 71 /* information about this file */ |
25689 | 72 const tvi_info_t tvi_info_bsdbt848 = { |
22381
6cabac4d35b5
tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents:
21848
diff
changeset
|
73 tvi_init_bsdbt848, |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
74 "Brooktree848 Support", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
75 "bsdbt848", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
76 "Charles Henrich", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
77 "in development" |
5081 | 78 }; |
79 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
80 typedef struct { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
81 int dirty; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
82 double timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
83 char *buf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
84 } RBFRAME; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
85 |
5081 | 86 /* private data's */ |
87 typedef struct { | |
88 | |
89 /* Audio */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
90 char *dspdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
91 int dspready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
92 int dspfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
93 int dspsamplesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
94 int dspstereo; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
95 int dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
96 int dspfmt; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
97 int dspframesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
98 int dsprate; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
99 long long dspbytesread; |
5081 | 100 |
101 /* Video */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
102 char *btdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
103 int videoready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
104 int btfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
105 int source; |
10019 | 106 float maxfps; |
107 float fps; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
108 int iformat; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
109 int maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
110 int maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
111 struct meteor_geomet geom; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
112 struct meteor_capframe capframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
113 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
114 /* Frame Buffer */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
115 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
116 int framebufsize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
117 float timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
118 int curpaintframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
119 int curbufframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
120 unsigned char *livebuf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
121 RBFRAME framebuf[RINGSIZE]; |
5081 | 122 |
123 /* Inputs */ | |
124 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
125 int input; |
5081 | 126 |
127 /* Tuner */ | |
128 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
129 char *tunerdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
130 int tunerfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
131 int tunerready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
132 u_long tunerfreq; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
133 struct bktr_chnlset cset; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
134 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
135 /* Other */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
136 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
137 int immediatemode; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
138 double starttime; |
5081 | 139 |
23883 | 140 tv_param_t *tv_param; |
5081 | 141 } priv_t; |
142 | |
143 #include "tvi_def.h" | |
144 | |
145 static priv_t *G_private=NULL; | |
146 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
147 static int getinput(int innumber); |
5081 | 148 |
149 static void processframe(int signal) | |
150 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
151 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
152 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
153 if(G_private->immediatemode == TRUE) return; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
154 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
155 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
156 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
157 if(G_private->framebuf[G_private->curpaintframe].dirty == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
158 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
159 memcpy(G_private->framebuf[G_private->curpaintframe].buf, |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
160 G_private->livebuf, G_private->framebufsize); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
161 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
162 G_private->framebuf[G_private->curpaintframe].dirty = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
163 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
164 G_private->framebuf[G_private->curpaintframe].timestamp = |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
165 curtime.tv_sec + curtime.tv_usec*.000001; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
166 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
167 G_private->curpaintframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
168 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
169 if(G_private->curpaintframe >= RINGSIZE) G_private->curpaintframe = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
170 } |
5081 | 171 |
172 return; | |
173 } | |
174 | |
175 /* handler creator - entry point ! */ | |
23883 | 176 static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param) |
5081 | 177 { |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
178 char* sep ; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
179 tvi_handle_t* tvh; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
180 priv_t* priv; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
181 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
182 tvh=new_handle(); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
183 if(!tvh) |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
184 return NULL; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
185 priv=(priv_t*)tvh->priv; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
186 /* |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
187 if user needs to specify both /dev/bktr<n> and /dev/tuner<n> |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
188 it can do this with "-tv device=/dev/bktr1,/dev/tuner1" |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
189 */ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
190 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
191 /* set video device name */ |
23883 | 192 if (!tv_param->device){ |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
193 priv->btdev = strdup("/dev/bktr0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
194 priv->tunerdev = strdup("/dev/tuner0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
195 }else{ |
23883 | 196 sep = strchr(tv_param->device,','); |
197 priv->btdev = strdup(tv_param->device); | |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
198 if(sep){ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
199 // tuner device is also passed |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
200 priv->tunerdev = strdup(sep+1); |
23883 | 201 priv->btdev[sep - tv_param->device] = 0; |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
202 }else{ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
203 priv->tunerdev = strdup("/dev/tuner0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
204 } |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
205 } |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
206 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
207 /* set audio device name */ |
23883 | 208 if (!tv_param->adevice) |
22934 | 209 #ifdef USE_SUN_AUDIO |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
210 priv->dspdev = strdup("/dev/sound"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
211 #else |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
212 priv->dspdev = strdup("/dev/dsp"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
213 #endif |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
214 else |
23883 | 215 priv->dspdev = strdup(tv_param->adevice); |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
216 |
23925
f54903679ad0
10l: wrong pointer was initialized (causes crash during startup).
voroshil
parents:
23884
diff
changeset
|
217 priv->tv_param=tv_param; |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
218 return tvh; |
5081 | 219 } |
220 | |
221 static int control(priv_t *priv, int cmd, void *arg) | |
222 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
223 switch(cmd) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
224 { |
5081 | 225 |
226 /* Tuner Controls */ | |
227 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
228 case TVI_CONTROL_IS_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
229 if(priv->tunerready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
230 return(TVI_CONTROL_TRUE); |
5081 | 231 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
232 case TVI_CONTROL_TUN_GET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
233 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
234 if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
235 { |
24193 | 236 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_GETFREQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
237 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
238 } |
5081 | 239 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
240 *(int *)arg = priv->tunerfreq; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
241 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
242 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
243 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
244 case TVI_CONTROL_TUN_SET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
245 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
246 priv->tunerfreq = *(int *)arg; |
5081 | 247 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
248 if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
249 { |
24193 | 250 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_SETFREQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
251 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
252 } |
5081 | 253 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
254 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
255 } |
24192
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
256 case TVI_CONTROL_TUN_GET_SIGNAL: |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
257 { |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
258 int status; |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
259 if(ioctl(priv->tunerfd, TVTUNER_GETSTATUS, &status) < 0) |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
260 { |
24193 | 261 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "GETSTATUS", strerror(errno)); |
24192
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
262 return(0); |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
263 } |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
264 *(int*)arg=(status & 0x02)? 100 : 0; |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
265 return (TVI_CONTROL_TRUE); |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
266 } |
5081 | 267 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
268 case TVI_CONTROL_TUN_GET_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
269 case TVI_CONTROL_TUN_SET_TUNER: |
5081 | 270 |
271 /* Inputs */ | |
272 | |
273 case TVI_CONTROL_SPC_GET_INPUT: | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
274 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
275 if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
276 { |
24193 | 277 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORGINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
278 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
279 } |
5081 | 280 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
281 *(int *)arg = priv->input; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
282 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
283 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
284 |
5081 | 285 case TVI_CONTROL_SPC_SET_INPUT: |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
286 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
287 priv->input = getinput(*(int *)arg); |
5081 | 288 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
289 if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
290 { |
24193 | 291 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
292 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
293 } |
5081 | 294 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
295 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
296 } |
5081 | 297 |
298 /* Audio Controls */ | |
299 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
300 case TVI_CONTROL_IS_AUDIO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
301 if(priv->dspready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
302 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
303 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
304 case TVI_CONTROL_AUD_GET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
305 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
306 *(int *)arg = AF_FORMAT_S16_LE; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
307 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
308 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
309 case TVI_CONTROL_AUD_GET_CHANNELS: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
310 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
311 *(int *)arg = 2; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
312 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
313 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
314 case TVI_CONTROL_AUD_SET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
315 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
316 int dspspeed = *(int *)arg; |
5081 | 317 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
318 if(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &dspspeed) == -1) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
319 { |
24193 | 320 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848InvalidAudioRate, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
321 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
322 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
323 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
324 priv->dspspeed = dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
325 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
326 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
327 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
328 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8* |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
329 (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
330 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
331 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
332 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
333 case TVI_CONTROL_AUD_GET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
334 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
335 *(int *)arg = priv->dspspeed; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
336 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
337 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
338 case TVI_CONTROL_AUD_GET_SAMPLESIZE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
339 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
340 *(int *)arg = priv->dspsamplesize/8; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
341 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
342 } |
5081 | 343 |
344 /* Video Controls */ | |
345 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
346 case TVI_CONTROL_IS_VIDEO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
347 if(priv->videoready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
348 return(TVI_CONTROL_TRUE); |
5081 | 349 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
350 case TVI_CONTROL_TUN_SET_NORM: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
351 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
352 int req_mode = *(int *)arg; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
353 u_short tmp_fps; |
5081 | 354 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
355 priv->iformat = METEOR_FMT_AUTOMODE; |
5081 | 356 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
357 if(req_mode == TV_NORM_PAL) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
358 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
359 priv->iformat = METEOR_FMT_PAL; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
360 priv->maxheight = PAL_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
361 priv->maxwidth = PAL_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
362 priv->maxfps = PAL_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
363 priv->fps = PAL_FPS; |
5081 | 364 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
365 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 366 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
367 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
368 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
369 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
370 } |
5081 | 371 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
372 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
373 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
374 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
375 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
376 } |
5081 | 377 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
378 if(req_mode == TV_NORM_NTSC) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
379 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
380 priv->iformat = METEOR_FMT_NTSC; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
381 priv->maxheight = NTSC_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
382 priv->maxwidth = NTSC_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
383 priv->maxfps = NTSC_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
384 priv->fps = NTSC_FPS; |
5081 | 385 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
386 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
387 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
388 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8 * |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
389 (priv->dspstereo+1); |
5081 | 390 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
391 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 392 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
393 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
394 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
395 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
396 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
397 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
398 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
399 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
400 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
401 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
402 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
403 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
404 if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM; |
5081 | 405 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
406 if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
407 { |
24193 | 408 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFMT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
409 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
410 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
411 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
412 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
413 { |
24193 | 414 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSETGEO", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
415 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
416 } |
5081 | 417 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
418 tmp_fps = priv->fps; |
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
419 if(ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
420 { |
24193 | 421 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
422 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
423 } |
5081 | 424 |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
425 #ifdef BT848_SAUDIO |
12608
fbd18fae40f1
10l, patch by Michael Nottebrock <michaelnottebrock@gmx.net>
faust3
parents:
12140
diff
changeset
|
426 if(priv->tunerready == TRUE && |
23884 | 427 ioctl(priv->tunerfd, BT848_SAUDIO, &priv->tv_param->audio_id) < 0) |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
428 { |
24193 | 429 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "BT848_SAUDIO", strerror(errno)); |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
430 } |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
431 #endif |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
432 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
433 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
434 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
435 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
436 case TVI_CONTROL_VID_GET_FORMAT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
437 *(int *)arg = IMGFMT_UYVY; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
438 return(TVI_CONTROL_TRUE); |
5081 | 439 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
440 case TVI_CONTROL_VID_SET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
441 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
442 int req_fmt = *(int *)arg; |
5081 | 443 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
444 if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE); |
5081 | 445 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
446 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
447 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
448 case TVI_CONTROL_VID_SET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
449 priv->geom.columns = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
450 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
451 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
452 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
453 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
454 } |
5081 | 455 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
456 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
457 { |
24193 | 458 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
459 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
460 } |
5081 | 461 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
462 return(TVI_CONTROL_TRUE); |
5081 | 463 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
464 case TVI_CONTROL_VID_GET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
465 *(int *)arg = priv->geom.columns; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
466 return(TVI_CONTROL_TRUE); |
5081 | 467 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
468 case TVI_CONTROL_VID_SET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
469 priv->geom.rows = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
470 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
471 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
472 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
473 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
474 } |
5081 | 475 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
476 if(priv->geom.rows <= priv->maxheight / 2) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
477 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
478 priv->geom.oformat |= METEOR_GEO_EVEN_ONLY; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
479 } |
5081 | 480 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
481 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
482 { |
24193 | 483 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
484 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
485 } |
5081 | 486 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
487 return(TVI_CONTROL_TRUE); |
5081 | 488 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
489 case TVI_CONTROL_VID_GET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
490 *(int *)arg = priv->geom.rows; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
491 return(TVI_CONTROL_TRUE); |
5081 | 492 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
493 case TVI_CONTROL_VID_GET_FPS: |
10019 | 494 *(float *)arg = priv->fps; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
495 return(TVI_CONTROL_TRUE); |
5081 | 496 |
497 /* | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
498 case TVI_CONTROL_VID_SET_FPS: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
499 priv->fps = *(int *)arg; |
5081 | 500 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
501 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 502 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
503 if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
504 { |
24193 | 505 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
506 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
507 } |
5081 | 508 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
509 return(TVI_CONTROL_TRUE); |
5081 | 510 */ |
511 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
512 case TVI_CONTROL_VID_CHK_WIDTH: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
513 case TVI_CONTROL_VID_CHK_HEIGHT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
514 return(TVI_CONTROL_TRUE); |
5081 | 515 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
516 case TVI_CONTROL_IMMEDIATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
517 priv->immediatemode = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
518 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
519 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
520 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
521 return(TVI_CONTROL_UNKNOWN); |
5081 | 522 } |
523 | |
524 static int init(priv_t *priv) | |
525 { | |
526 int marg; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
527 int count; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
528 u_short tmp_fps; |
5081 | 529 |
530 G_private = priv; /* Oooh, sick */ | |
531 | |
532 /* Video Configuration */ | |
533 | |
534 priv->videoready = TRUE; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
535 priv->immediatemode = FALSE; |
5081 | 536 priv->iformat = METEOR_FMT_PAL; |
537 priv->maxheight = PAL_HEIGHT; | |
538 priv->maxwidth = PAL_WIDTH; | |
539 priv->maxfps = PAL_FPS; | |
540 priv->source = METEOR_INPUT_DEV0; | |
541 priv->fps = priv->maxfps; | |
542 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
543 priv->starttime=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
544 priv->curpaintframe=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
545 priv->curbufframe=0; |
5081 | 546 |
547 priv->geom.columns = priv->maxwidth; | |
548 priv->geom.rows = priv->maxheight; | |
549 priv->geom.frames = 1; | |
550 priv->geom.oformat = METEOR_GEO_YUV_PACKED; | |
551 | |
552 priv->btfd = open(priv->btdev, O_RDONLY); | |
553 | |
554 if(priv->btfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
555 { |
24193 | 556 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningBktrDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
557 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
558 } |
5081 | 559 |
560 if(priv->videoready == TRUE && | |
561 ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
562 { |
24193 | 563 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SETEORSFMT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
564 } |
5081 | 565 |
566 if(priv->videoready == TRUE && | |
567 ioctl(priv->btfd, METEORSINPUT, &priv->source) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
568 { |
24193 | 569 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
570 } |
5081 | 571 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
572 tmp_fps = priv->fps; |
5081 | 573 if(priv->videoready == TRUE && |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
574 ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
575 { |
24193 | 576 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
577 } |
5081 | 578 |
579 if(priv->videoready == TRUE && | |
580 ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
581 { |
24193 | 582 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSGEQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
583 } |
5081 | 584 |
585 if(priv->videoready == TRUE) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
586 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
587 priv->framebufsize = (priv->geom.columns * priv->geom.rows * 2); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
588 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
589 priv->livebuf = (u_char *)mmap((caddr_t)0, priv->framebufsize, PROT_READ, |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
590 MAP_SHARED, priv->btfd, (off_t)0); |
5081 | 591 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
592 if(priv->livebuf == (u_char *) MAP_FAILED) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
593 { |
24193 | 594 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848MmapFailed, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
595 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
596 } |
5081 | 597 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
598 for(count=0;count<RINGSIZE;count++) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
599 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
600 priv->framebuf[count].buf = malloc(priv->framebufsize); |
5081 | 601 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
602 if(priv->framebuf[count].buf == NULL) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
603 { |
24193 | 604 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848FrameBufAllocFailed, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
605 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
606 break; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
607 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
608 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
609 priv->framebuf[count].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
610 priv->framebuf[count].timestamp = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
611 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
612 } |
5081 | 613 |
614 /* Tuner Configuration */ | |
615 | |
616 priv->tunerready = TRUE; | |
617 | |
618 priv->tunerfd = open(priv->tunerdev, O_RDONLY); | |
619 | |
620 if(priv->tunerfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
621 { |
24193 | 622 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningTunerDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
623 priv->tunerready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
624 } |
5081 | 625 |
626 /* Audio Configuration */ | |
627 | |
628 priv->dspready = TRUE; | |
629 priv->dspsamplesize = 16; | |
630 priv->dspstereo = 1; | |
631 priv->dspspeed = 44100; | |
632 priv->dspfmt = AFMT_S16_LE; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
633 priv->dspbytesread = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
634 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8*(priv->dspstereo+1); |
5081 | 635 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/priv->fps * |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
636 (priv->dspstereo+1); |
5081 | 637 |
12140 | 638 if((priv->dspfd = open (priv->dspdev, O_RDONLY, 0)) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
639 { |
24193 | 640 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningDspDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
641 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
642 } |
5081 | 643 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
644 marg = (256 << 16) | 12; |
5081 | 645 |
646 if (ioctl(priv->dspfd, SNDCTL_DSP_SETFRAGMENT, &marg ) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
647 { |
24193 | 648 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SNDCTL_DSP_SETFRAGMENT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
649 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
650 } |
5081 | 651 |
652 if((priv->dspready == TRUE) && | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
653 ((ioctl(priv->dspfd, SNDCTL_DSP_SAMPLESIZE, &priv->dspsamplesize) == -1) || |
5081 | 654 (ioctl(priv->dspfd, SNDCTL_DSP_STEREO, &priv->dspstereo) == -1) || |
655 (ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &priv->dspspeed) == -1) || | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
656 (ioctl(priv->dspfd, SNDCTL_DSP_SETFMT, &priv->dspfmt) == -1))) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
657 { |
24193 | 658 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorConfiguringDsp, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
659 close(priv->dspfd); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
660 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
661 } |
5081 | 662 |
663 return(1); | |
664 } | |
665 | |
666 /* that's the real start, we'got the format parameters (checked with control) */ | |
667 static int start(priv_t *priv) | |
668 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
669 int tmp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
670 struct timeval curtime; |
5081 | 671 int marg; |
672 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
673 fprintf(stderr,"START\n"); |
5081 | 674 if(priv->videoready == FALSE) return(0); |
675 | |
676 signal(SIGUSR1, processframe); | |
677 signal(SIGALRM, processframe); | |
678 | |
679 marg = SIGUSR1; | |
680 | |
681 if(ioctl(priv->btfd, METEORSSIGNAL, &marg) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
682 { |
24193 | 683 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
684 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
685 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
686 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
687 read(priv->dspfd, &tmp, 2); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
688 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
689 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
690 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
691 priv->starttime = curtime.tv_sec + (curtime.tv_usec *.000001); |
5081 | 692 |
693 marg = METEOR_CAP_CONTINOUS; | |
694 | |
695 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
696 { |
24193 | 697 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORCAPTUR", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
698 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
699 } |
5081 | 700 |
701 return(1); | |
702 } | |
703 | |
704 static int uninit(priv_t *priv) | |
705 { | |
706 int marg; | |
707 | |
708 if(priv->videoready == FALSE) return(0); | |
709 | |
710 marg = METEOR_SIG_MODE_MASK; | |
711 | |
712 if(ioctl( priv->btfd, METEORSSIGNAL, &marg) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
713 { |
24193 | 714 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
715 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
716 } |
5081 | 717 |
718 marg = METEOR_CAP_STOP_CONT; | |
719 | |
720 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
721 { |
24193 | 722 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848UnableToStopCapture, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
723 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
724 } |
5081 | 725 |
726 close(priv->btfd); | |
727 close(priv->dspfd); | |
728 | |
729 priv->dspfd = -1; | |
730 priv->btfd = -1; | |
731 | |
732 priv->dspready = priv->videoready = FALSE; | |
733 | |
734 return(1); | |
735 } | |
736 | |
737 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
738 static double grabimmediate_video_frame(priv_t *priv, char *buffer, int len) |
5081 | 739 { |
740 sigset_t sa_mask; | |
741 | |
742 if(priv->videoready == FALSE) return(0); | |
743 | |
744 alarm(1); | |
745 sigfillset(&sa_mask); | |
746 sigdelset(&sa_mask,SIGINT); | |
747 sigdelset(&sa_mask,SIGUSR1); | |
748 sigdelset(&sa_mask,SIGALRM); | |
749 sigsuspend(&sa_mask); | |
750 alarm(0); | |
751 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
752 memcpy(buffer, priv->livebuf, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
753 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
754 /* PTS = 0, show the frame NOW, this routine is only used in playback mode |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
755 without audio capture .. */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
756 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
757 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
758 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
759 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
760 static double grab_video_frame(priv_t *priv, char *buffer, int len) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
761 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
762 double timestamp=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
763 sigset_t sa_mask; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
764 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
765 if(priv->videoready == FALSE) return(0); |
5081 | 766 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
767 if(priv->immediatemode == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
768 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
769 return grabimmediate_video_frame(priv, buffer, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
770 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
771 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
772 while(priv->framebuf[priv->curbufframe].dirty == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
773 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
774 alarm(1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
775 sigemptyset(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
776 sigsuspend(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
777 alarm(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
778 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
779 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
780 memcpy(buffer, priv->framebuf[priv->curbufframe].buf, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
781 timestamp = priv->framebuf[priv->curbufframe].timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
782 priv->framebuf[priv->curbufframe].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
783 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
784 priv->curbufframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
785 if(priv->curbufframe >= RINGSIZE) priv->curbufframe = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
786 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
787 return(timestamp-priv->starttime); |
5081 | 788 } |
789 | |
790 static int get_video_framesize(priv_t *priv) | |
791 { | |
792 return(priv->geom.columns*priv->geom.rows*16/8); | |
793 } | |
794 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
795 static double grab_audio_frame(priv_t *priv, char *buffer, int len) |
5081 | 796 { |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
797 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
798 double curpts; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
799 double timeskew; |
5081 | 800 int bytesread; |
801 int ret; | |
802 | |
803 if(priv->dspready == FALSE) return 0; | |
804 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
805 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
806 |
5081 | 807 /* Get exactly one frame of audio, which forces video sync to audio.. */ |
808 | |
809 bytesread=read(priv->dspfd, buffer, len); | |
810 | |
811 while(bytesread < len) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
812 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
813 ret=read(priv->dspfd, &buffer[bytesread], len-bytesread); |
5081 | 814 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
815 if(ret == -1) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
816 { |
24193 | 817 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorReadingAudio, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
818 return 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
819 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
820 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
821 bytesread+=ret; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
822 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
823 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
824 priv->dspbytesread += bytesread; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
825 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
826 curpts = curtime.tv_sec + curtime.tv_usec * .000001; |
5081 | 827 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
828 timeskew = priv->dspbytesread * 1.0 / priv->dsprate - (curpts-priv->starttime); |
5081 | 829 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
830 if(timeskew > .125/priv->fps) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
831 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
832 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
833 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
834 else |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
835 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
836 if(timeskew < -.125/priv->fps) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
837 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
838 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
839 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
840 } |
5081 | 841 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
842 return(priv->dspbytesread * 1.0 / priv->dsprate); |
5081 | 843 } |
844 | |
845 static int get_audio_framesize(priv_t *priv) | |
846 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
847 int bytesavail; |
22934 | 848 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
849 struct audio_info auinf; |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
850 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
851 |
5081 | 852 if(priv->dspready == FALSE) return 0; |
853 | |
22934 | 854 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
855 if(ioctl(priv->dspfd, AUDIO_GETINFO, &auinf) < 0) |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
856 { |
24193 | 857 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "AUDIO_GETINFO", strerror(errno)); |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
858 return(TVI_CONTROL_FALSE); |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
859 } |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
860 else |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
861 bytesavail = auinf.record.seek; /* *priv->dspsamplesize; */ |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
862 #else |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
863 if(ioctl(priv->dspfd, FIONREAD, &bytesavail) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
864 { |
24193 | 865 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "FIONREAD", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
866 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
867 } |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
868 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
869 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
870 /* When mencoder wants audio data, it wants data.. |
11000 | 871 it won't go do anything else until it gets it :( */ |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
872 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
873 if(bytesavail == 0) return FRAGSIZE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
874 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
875 return(bytesavail); |
5081 | 876 } |
877 | |
878 static int getinput(int innumber) | |
879 { | |
880 switch(innumber) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
881 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
882 case 0: return METEOR_INPUT_DEV0; /* RCA */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
883 case 1: return METEOR_INPUT_DEV1; /* Tuner */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
884 case 2: return METEOR_INPUT_DEV2; /* In 1 */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
885 case 3: return METEOR_INPUT_DEV3; /* In 2 */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
886 case 4: return METEOR_INPUT_DEV_RGB; /* RGB */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
887 case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
888 } |
5081 | 889 |
890 return 0; | |
891 } |