annotate libmpdemux/tvi_bsdbt848.c @ 5408:f9cd6381e327

reworked ADPCM decoders; changes include: * fixed MS IMA ADPCM * dissolved adpcm.c/.h into appropriate ad_* decoders * DK4 audio is handled directly by IMA ADPCM decoder (this obsoletes ad_dk4adpcm.c)
author melanson
date Sat, 30 Mar 2002 22:27:45 +0000
parents 7fc559dbc607
children 8cd761968f35
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5081
7473fca49ca0 initial
alex
parents:
diff changeset
1 /*
7473fca49ca0 initial
alex
parents:
diff changeset
2 (C)2002 Charles R. Henrich (henrich@msu.edu)
7473fca49ca0 initial
alex
parents:
diff changeset
3 *BSD (hopefully, requires working driver!) BrookTree capture support.
7473fca49ca0 initial
alex
parents:
diff changeset
4
7473fca49ca0 initial
alex
parents:
diff changeset
5 Still in (active) development!
7473fca49ca0 initial
alex
parents:
diff changeset
6
7473fca49ca0 initial
alex
parents:
diff changeset
7 v1.0 Feb 19 2002 First Release, need to add support for changing
7473fca49ca0 initial
alex
parents:
diff changeset
8 audio parameters.
7473fca49ca0 initial
alex
parents:
diff changeset
9 */
7473fca49ca0 initial
alex
parents:
diff changeset
10
7473fca49ca0 initial
alex
parents:
diff changeset
11 #include "config.h"
7473fca49ca0 initial
alex
parents:
diff changeset
12
7473fca49ca0 initial
alex
parents:
diff changeset
13 #if defined(USE_TV) && defined(HAVE_TV_BSDBT848)
7473fca49ca0 initial
alex
parents:
diff changeset
14
7473fca49ca0 initial
alex
parents:
diff changeset
15 #define TRUE (1==1)
7473fca49ca0 initial
alex
parents:
diff changeset
16 #define FALSE (1==0)
7473fca49ca0 initial
alex
parents:
diff changeset
17
7473fca49ca0 initial
alex
parents:
diff changeset
18 #define PAL_WIDTH 768
7473fca49ca0 initial
alex
parents:
diff changeset
19 #define PAL_HEIGHT 576
7473fca49ca0 initial
alex
parents:
diff changeset
20 #define PAL_FPS 25
7473fca49ca0 initial
alex
parents:
diff changeset
21
7473fca49ca0 initial
alex
parents:
diff changeset
22 #define NTSC_WIDTH 640
7473fca49ca0 initial
alex
parents:
diff changeset
23 #define NTSC_HEIGHT 480
7473fca49ca0 initial
alex
parents:
diff changeset
24 #define NTSC_FPS 30
7473fca49ca0 initial
alex
parents:
diff changeset
25
7473fca49ca0 initial
alex
parents:
diff changeset
26 #include <stdio.h>
7473fca49ca0 initial
alex
parents:
diff changeset
27 #include <stdlib.h>
7473fca49ca0 initial
alex
parents:
diff changeset
28 #include <unistd.h>
7473fca49ca0 initial
alex
parents:
diff changeset
29 #include <fcntl.h>
7473fca49ca0 initial
alex
parents:
diff changeset
30 #include <sys/types.h>
7473fca49ca0 initial
alex
parents:
diff changeset
31 #include <sys/mman.h>
7473fca49ca0 initial
alex
parents:
diff changeset
32 #include <signal.h>
7473fca49ca0 initial
alex
parents:
diff changeset
33 #include <string.h>
7473fca49ca0 initial
alex
parents:
diff changeset
34
7473fca49ca0 initial
alex
parents:
diff changeset
35 #include <machine/ioctl_meteor.h>
7473fca49ca0 initial
alex
parents:
diff changeset
36 #include <machine/ioctl_bt848.h>
5142
7fc559dbc607 BSD compatibility fix by Steven M. Schultz
alex
parents: 5081
diff changeset
37 #ifdef HAVE_SYS_SOUNDCARD_H
7fc559dbc607 BSD compatibility fix by Steven M. Schultz
alex
parents: 5081
diff changeset
38 #include <sys/soundcard.h>
7fc559dbc607 BSD compatibility fix by Steven M. Schultz
alex
parents: 5081
diff changeset
39 #else
5081
7473fca49ca0 initial
alex
parents:
diff changeset
40 #include <machine/soundcard.h>
5142
7fc559dbc607 BSD compatibility fix by Steven M. Schultz
alex
parents: 5081
diff changeset
41 #endif
5081
7473fca49ca0 initial
alex
parents:
diff changeset
42
7473fca49ca0 initial
alex
parents:
diff changeset
43 #include "../libvo/img_format.h"
7473fca49ca0 initial
alex
parents:
diff changeset
44 #include "tv.h"
7473fca49ca0 initial
alex
parents:
diff changeset
45
7473fca49ca0 initial
alex
parents:
diff changeset
46 /* information about this file */
7473fca49ca0 initial
alex
parents:
diff changeset
47 static tvi_info_t info = {
7473fca49ca0 initial
alex
parents:
diff changeset
48 "Brooktree848 Support",
7473fca49ca0 initial
alex
parents:
diff changeset
49 "bt848",
7473fca49ca0 initial
alex
parents:
diff changeset
50 "Charles Henrich",
7473fca49ca0 initial
alex
parents:
diff changeset
51 "in development"
7473fca49ca0 initial
alex
parents:
diff changeset
52 };
7473fca49ca0 initial
alex
parents:
diff changeset
53
7473fca49ca0 initial
alex
parents:
diff changeset
54 /* private data's */
7473fca49ca0 initial
alex
parents:
diff changeset
55 typedef struct {
7473fca49ca0 initial
alex
parents:
diff changeset
56
7473fca49ca0 initial
alex
parents:
diff changeset
57 /* Audio */
7473fca49ca0 initial
alex
parents:
diff changeset
58 char *dspdev;
7473fca49ca0 initial
alex
parents:
diff changeset
59 int dspready;
7473fca49ca0 initial
alex
parents:
diff changeset
60 int dspfd;
7473fca49ca0 initial
alex
parents:
diff changeset
61 int dspsamplesize;
7473fca49ca0 initial
alex
parents:
diff changeset
62 int dspstereo;
7473fca49ca0 initial
alex
parents:
diff changeset
63 int dspspeed;
7473fca49ca0 initial
alex
parents:
diff changeset
64 int dspfmt;
7473fca49ca0 initial
alex
parents:
diff changeset
65 int dspframesize;
7473fca49ca0 initial
alex
parents:
diff changeset
66
7473fca49ca0 initial
alex
parents:
diff changeset
67 /* Video */
7473fca49ca0 initial
alex
parents:
diff changeset
68 char *btdev;
7473fca49ca0 initial
alex
parents:
diff changeset
69 int videoready;
7473fca49ca0 initial
alex
parents:
diff changeset
70 int btfd;
7473fca49ca0 initial
alex
parents:
diff changeset
71 int source;
7473fca49ca0 initial
alex
parents:
diff changeset
72 int maxfps;
7473fca49ca0 initial
alex
parents:
diff changeset
73 int fps;
7473fca49ca0 initial
alex
parents:
diff changeset
74 int iformat;
7473fca49ca0 initial
alex
parents:
diff changeset
75 int maxheight;
7473fca49ca0 initial
alex
parents:
diff changeset
76 int maxwidth;
7473fca49ca0 initial
alex
parents:
diff changeset
77 struct meteor_geomet geom;
7473fca49ca0 initial
alex
parents:
diff changeset
78 struct meteor_capframe capframe;
7473fca49ca0 initial
alex
parents:
diff changeset
79 int buffersize;
7473fca49ca0 initial
alex
parents:
diff changeset
80 unsigned char *buffer;
7473fca49ca0 initial
alex
parents:
diff changeset
81 int currentframe;
7473fca49ca0 initial
alex
parents:
diff changeset
82
7473fca49ca0 initial
alex
parents:
diff changeset
83 /* Inputs */
7473fca49ca0 initial
alex
parents:
diff changeset
84
7473fca49ca0 initial
alex
parents:
diff changeset
85 int input;
7473fca49ca0 initial
alex
parents:
diff changeset
86
7473fca49ca0 initial
alex
parents:
diff changeset
87 /* Tuner */
7473fca49ca0 initial
alex
parents:
diff changeset
88
7473fca49ca0 initial
alex
parents:
diff changeset
89 char *tunerdev;
7473fca49ca0 initial
alex
parents:
diff changeset
90 int tunerfd;
7473fca49ca0 initial
alex
parents:
diff changeset
91 int tunerready;
7473fca49ca0 initial
alex
parents:
diff changeset
92 u_long tunerfreq;
7473fca49ca0 initial
alex
parents:
diff changeset
93 struct bktr_chnlset cset;
7473fca49ca0 initial
alex
parents:
diff changeset
94
7473fca49ca0 initial
alex
parents:
diff changeset
95 } priv_t;
7473fca49ca0 initial
alex
parents:
diff changeset
96
7473fca49ca0 initial
alex
parents:
diff changeset
97 #include "tvi_def.h"
7473fca49ca0 initial
alex
parents:
diff changeset
98
7473fca49ca0 initial
alex
parents:
diff changeset
99 static priv_t *G_private=NULL;
7473fca49ca0 initial
alex
parents:
diff changeset
100
7473fca49ca0 initial
alex
parents:
diff changeset
101
7473fca49ca0 initial
alex
parents:
diff changeset
102 static void processframe(int signal)
7473fca49ca0 initial
alex
parents:
diff changeset
103 {
7473fca49ca0 initial
alex
parents:
diff changeset
104 G_private->currentframe++;
7473fca49ca0 initial
alex
parents:
diff changeset
105
7473fca49ca0 initial
alex
parents:
diff changeset
106 return;
7473fca49ca0 initial
alex
parents:
diff changeset
107 }
7473fca49ca0 initial
alex
parents:
diff changeset
108
7473fca49ca0 initial
alex
parents:
diff changeset
109 /* handler creator - entry point ! */
7473fca49ca0 initial
alex
parents:
diff changeset
110 tvi_handle_t *tvi_init_bsdbt848(char *device)
7473fca49ca0 initial
alex
parents:
diff changeset
111 {
7473fca49ca0 initial
alex
parents:
diff changeset
112 return(new_handle());
7473fca49ca0 initial
alex
parents:
diff changeset
113 }
7473fca49ca0 initial
alex
parents:
diff changeset
114
7473fca49ca0 initial
alex
parents:
diff changeset
115 static int control(priv_t *priv, int cmd, void *arg)
7473fca49ca0 initial
alex
parents:
diff changeset
116 {
7473fca49ca0 initial
alex
parents:
diff changeset
117 switch(cmd)
7473fca49ca0 initial
alex
parents:
diff changeset
118 {
7473fca49ca0 initial
alex
parents:
diff changeset
119
7473fca49ca0 initial
alex
parents:
diff changeset
120 /* Tuner Controls */
7473fca49ca0 initial
alex
parents:
diff changeset
121
7473fca49ca0 initial
alex
parents:
diff changeset
122 case TVI_CONTROL_IS_TUNER:
7473fca49ca0 initial
alex
parents:
diff changeset
123 if(priv->tunerready == FALSE) return TVI_CONTROL_FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
124 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
125
7473fca49ca0 initial
alex
parents:
diff changeset
126 case TVI_CONTROL_TUN_GET_FREQ:
7473fca49ca0 initial
alex
parents:
diff changeset
127 {
7473fca49ca0 initial
alex
parents:
diff changeset
128 if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
129 {
7473fca49ca0 initial
alex
parents:
diff changeset
130 perror("GETFREQ:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
131 return(TVI_CONTROL_FALSE);
7473fca49ca0 initial
alex
parents:
diff changeset
132 }
7473fca49ca0 initial
alex
parents:
diff changeset
133
7473fca49ca0 initial
alex
parents:
diff changeset
134 (int)*(void **)arg = priv->tunerfreq;
7473fca49ca0 initial
alex
parents:
diff changeset
135 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
136 }
7473fca49ca0 initial
alex
parents:
diff changeset
137
7473fca49ca0 initial
alex
parents:
diff changeset
138 case TVI_CONTROL_TUN_SET_FREQ:
7473fca49ca0 initial
alex
parents:
diff changeset
139 {
7473fca49ca0 initial
alex
parents:
diff changeset
140 priv->tunerfreq = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
141
7473fca49ca0 initial
alex
parents:
diff changeset
142 if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
143 {
7473fca49ca0 initial
alex
parents:
diff changeset
144 perror("SETFREQ:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
145 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
146 }
7473fca49ca0 initial
alex
parents:
diff changeset
147
7473fca49ca0 initial
alex
parents:
diff changeset
148 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
149 }
7473fca49ca0 initial
alex
parents:
diff changeset
150
7473fca49ca0 initial
alex
parents:
diff changeset
151 case TVI_CONTROL_TUN_GET_TUNER:
7473fca49ca0 initial
alex
parents:
diff changeset
152 case TVI_CONTROL_TUN_SET_TUNER:
7473fca49ca0 initial
alex
parents:
diff changeset
153
7473fca49ca0 initial
alex
parents:
diff changeset
154 /* Inputs */
7473fca49ca0 initial
alex
parents:
diff changeset
155
7473fca49ca0 initial
alex
parents:
diff changeset
156 case TVI_CONTROL_SPC_GET_INPUT:
7473fca49ca0 initial
alex
parents:
diff changeset
157 {
7473fca49ca0 initial
alex
parents:
diff changeset
158 if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
159 {
7473fca49ca0 initial
alex
parents:
diff changeset
160 perror("GINPUT:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
161 return(TVI_CONTROL_FALSE);
7473fca49ca0 initial
alex
parents:
diff changeset
162 }
7473fca49ca0 initial
alex
parents:
diff changeset
163
7473fca49ca0 initial
alex
parents:
diff changeset
164 (int)*(void **)arg = priv->input;
7473fca49ca0 initial
alex
parents:
diff changeset
165 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
166 }
7473fca49ca0 initial
alex
parents:
diff changeset
167
7473fca49ca0 initial
alex
parents:
diff changeset
168 case TVI_CONTROL_SPC_SET_INPUT:
7473fca49ca0 initial
alex
parents:
diff changeset
169 {
7473fca49ca0 initial
alex
parents:
diff changeset
170 priv->input = getinput((int)*(void **)arg);
7473fca49ca0 initial
alex
parents:
diff changeset
171
7473fca49ca0 initial
alex
parents:
diff changeset
172 if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
173 {
7473fca49ca0 initial
alex
parents:
diff changeset
174 perror("tunerfreq:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
175 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
176 }
7473fca49ca0 initial
alex
parents:
diff changeset
177
7473fca49ca0 initial
alex
parents:
diff changeset
178 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
179 }
7473fca49ca0 initial
alex
parents:
diff changeset
180
7473fca49ca0 initial
alex
parents:
diff changeset
181 /* Audio Controls */
7473fca49ca0 initial
alex
parents:
diff changeset
182
7473fca49ca0 initial
alex
parents:
diff changeset
183 case TVI_CONTROL_IS_AUDIO:
7473fca49ca0 initial
alex
parents:
diff changeset
184 if(priv->dspready == FALSE) return TVI_CONTROL_FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
185 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
186
7473fca49ca0 initial
alex
parents:
diff changeset
187 case TVI_CONTROL_AUD_GET_FORMAT:
7473fca49ca0 initial
alex
parents:
diff changeset
188 {
7473fca49ca0 initial
alex
parents:
diff changeset
189 (int)*(void **)arg = AFMT_S16_LE;
7473fca49ca0 initial
alex
parents:
diff changeset
190 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
191 }
7473fca49ca0 initial
alex
parents:
diff changeset
192 case TVI_CONTROL_AUD_GET_CHANNELS:
7473fca49ca0 initial
alex
parents:
diff changeset
193 {
7473fca49ca0 initial
alex
parents:
diff changeset
194 (int)*(void **)arg = 2;
7473fca49ca0 initial
alex
parents:
diff changeset
195 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
196 }
7473fca49ca0 initial
alex
parents:
diff changeset
197 case TVI_CONTROL_AUD_GET_SAMPLERATE:
7473fca49ca0 initial
alex
parents:
diff changeset
198 {
7473fca49ca0 initial
alex
parents:
diff changeset
199 (int)*(void **)arg = 44100;
7473fca49ca0 initial
alex
parents:
diff changeset
200 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
201 }
7473fca49ca0 initial
alex
parents:
diff changeset
202 case TVI_CONTROL_AUD_GET_SAMPLESIZE:
7473fca49ca0 initial
alex
parents:
diff changeset
203 {
7473fca49ca0 initial
alex
parents:
diff changeset
204 (int)*(void **)arg = priv->dspsamplesize;
7473fca49ca0 initial
alex
parents:
diff changeset
205 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
206 }
7473fca49ca0 initial
alex
parents:
diff changeset
207
7473fca49ca0 initial
alex
parents:
diff changeset
208 /* Video Controls */
7473fca49ca0 initial
alex
parents:
diff changeset
209
7473fca49ca0 initial
alex
parents:
diff changeset
210 case TVI_CONTROL_IS_VIDEO:
7473fca49ca0 initial
alex
parents:
diff changeset
211 if(priv->videoready == FALSE) return TVI_CONTROL_FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
212 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
213
7473fca49ca0 initial
alex
parents:
diff changeset
214 case TVI_CONTROL_TUN_SET_NORM:
7473fca49ca0 initial
alex
parents:
diff changeset
215 {
7473fca49ca0 initial
alex
parents:
diff changeset
216 int req_mode = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
217
7473fca49ca0 initial
alex
parents:
diff changeset
218 priv->iformat = METEOR_FMT_AUTOMODE;
7473fca49ca0 initial
alex
parents:
diff changeset
219
7473fca49ca0 initial
alex
parents:
diff changeset
220 if(req_mode == TV_NORM_PAL)
7473fca49ca0 initial
alex
parents:
diff changeset
221 {
7473fca49ca0 initial
alex
parents:
diff changeset
222 priv->iformat = METEOR_FMT_PAL;
7473fca49ca0 initial
alex
parents:
diff changeset
223 priv->maxheight = PAL_HEIGHT;
7473fca49ca0 initial
alex
parents:
diff changeset
224 priv->maxwidth = PAL_WIDTH;
7473fca49ca0 initial
alex
parents:
diff changeset
225 priv->maxfps = PAL_FPS;
7473fca49ca0 initial
alex
parents:
diff changeset
226 priv->fps = PAL_FPS;
7473fca49ca0 initial
alex
parents:
diff changeset
227
7473fca49ca0 initial
alex
parents:
diff changeset
228 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps;
7473fca49ca0 initial
alex
parents:
diff changeset
229
7473fca49ca0 initial
alex
parents:
diff changeset
230 if(priv->geom.rows > priv->maxheight)
7473fca49ca0 initial
alex
parents:
diff changeset
231 {
7473fca49ca0 initial
alex
parents:
diff changeset
232 priv->geom.rows = priv->maxheight;
7473fca49ca0 initial
alex
parents:
diff changeset
233 }
7473fca49ca0 initial
alex
parents:
diff changeset
234
7473fca49ca0 initial
alex
parents:
diff changeset
235 if(priv->geom.columns > priv->maxwidth)
7473fca49ca0 initial
alex
parents:
diff changeset
236 {
7473fca49ca0 initial
alex
parents:
diff changeset
237 priv->geom.columns = priv->maxwidth;
7473fca49ca0 initial
alex
parents:
diff changeset
238 }
7473fca49ca0 initial
alex
parents:
diff changeset
239 }
7473fca49ca0 initial
alex
parents:
diff changeset
240
7473fca49ca0 initial
alex
parents:
diff changeset
241 if(req_mode == TV_NORM_NTSC)
7473fca49ca0 initial
alex
parents:
diff changeset
242 {
7473fca49ca0 initial
alex
parents:
diff changeset
243 priv->iformat = METEOR_FMT_NTSC;
7473fca49ca0 initial
alex
parents:
diff changeset
244 priv->maxheight = NTSC_HEIGHT;
7473fca49ca0 initial
alex
parents:
diff changeset
245 priv->maxwidth = NTSC_WIDTH;
7473fca49ca0 initial
alex
parents:
diff changeset
246 priv->maxfps = NTSC_FPS;
7473fca49ca0 initial
alex
parents:
diff changeset
247 priv->fps = NTSC_FPS;
7473fca49ca0 initial
alex
parents:
diff changeset
248
7473fca49ca0 initial
alex
parents:
diff changeset
249 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/
7473fca49ca0 initial
alex
parents:
diff changeset
250 priv->fps * (priv->dspstereo+1);
7473fca49ca0 initial
alex
parents:
diff changeset
251
7473fca49ca0 initial
alex
parents:
diff changeset
252 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps;
7473fca49ca0 initial
alex
parents:
diff changeset
253
7473fca49ca0 initial
alex
parents:
diff changeset
254 if(priv->geom.rows > priv->maxheight)
7473fca49ca0 initial
alex
parents:
diff changeset
255 {
7473fca49ca0 initial
alex
parents:
diff changeset
256 priv->geom.rows = priv->maxheight;
7473fca49ca0 initial
alex
parents:
diff changeset
257 }
7473fca49ca0 initial
alex
parents:
diff changeset
258
7473fca49ca0 initial
alex
parents:
diff changeset
259 if(priv->geom.columns > priv->maxwidth)
7473fca49ca0 initial
alex
parents:
diff changeset
260 {
7473fca49ca0 initial
alex
parents:
diff changeset
261 priv->geom.columns = priv->maxwidth;
7473fca49ca0 initial
alex
parents:
diff changeset
262 }
7473fca49ca0 initial
alex
parents:
diff changeset
263 }
7473fca49ca0 initial
alex
parents:
diff changeset
264
7473fca49ca0 initial
alex
parents:
diff changeset
265 if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM;
7473fca49ca0 initial
alex
parents:
diff changeset
266
7473fca49ca0 initial
alex
parents:
diff changeset
267 if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
268 {
7473fca49ca0 initial
alex
parents:
diff changeset
269 perror("format:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
270 return(TVI_CONTROL_FALSE);
7473fca49ca0 initial
alex
parents:
diff changeset
271 }
7473fca49ca0 initial
alex
parents:
diff changeset
272
7473fca49ca0 initial
alex
parents:
diff changeset
273 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
274 {
7473fca49ca0 initial
alex
parents:
diff changeset
275 perror("geo:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
276 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
277 }
7473fca49ca0 initial
alex
parents:
diff changeset
278
7473fca49ca0 initial
alex
parents:
diff changeset
279 if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
280 {
7473fca49ca0 initial
alex
parents:
diff changeset
281 perror("fps:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
282 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
283 }
7473fca49ca0 initial
alex
parents:
diff changeset
284
7473fca49ca0 initial
alex
parents:
diff changeset
285 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
286 }
7473fca49ca0 initial
alex
parents:
diff changeset
287
7473fca49ca0 initial
alex
parents:
diff changeset
288 case TVI_CONTROL_VID_GET_FORMAT:
7473fca49ca0 initial
alex
parents:
diff changeset
289 (int)*(void **)arg = IMGFMT_UYVY;
7473fca49ca0 initial
alex
parents:
diff changeset
290 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
291
7473fca49ca0 initial
alex
parents:
diff changeset
292 case TVI_CONTROL_VID_SET_FORMAT:
7473fca49ca0 initial
alex
parents:
diff changeset
293 {
7473fca49ca0 initial
alex
parents:
diff changeset
294 int req_fmt = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
295
7473fca49ca0 initial
alex
parents:
diff changeset
296 if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE);
7473fca49ca0 initial
alex
parents:
diff changeset
297
7473fca49ca0 initial
alex
parents:
diff changeset
298 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
299 }
7473fca49ca0 initial
alex
parents:
diff changeset
300 case TVI_CONTROL_VID_SET_WIDTH:
7473fca49ca0 initial
alex
parents:
diff changeset
301 priv->geom.columns = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
302
7473fca49ca0 initial
alex
parents:
diff changeset
303 if(priv->geom.columns > priv->maxwidth)
7473fca49ca0 initial
alex
parents:
diff changeset
304 {
7473fca49ca0 initial
alex
parents:
diff changeset
305 priv->geom.columns = priv->maxwidth;
7473fca49ca0 initial
alex
parents:
diff changeset
306 }
7473fca49ca0 initial
alex
parents:
diff changeset
307
7473fca49ca0 initial
alex
parents:
diff changeset
308 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
309 {
7473fca49ca0 initial
alex
parents:
diff changeset
310 perror("width:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
311 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
312 }
7473fca49ca0 initial
alex
parents:
diff changeset
313
7473fca49ca0 initial
alex
parents:
diff changeset
314 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
315
7473fca49ca0 initial
alex
parents:
diff changeset
316 case TVI_CONTROL_VID_GET_WIDTH:
7473fca49ca0 initial
alex
parents:
diff changeset
317 (int)*(void **)arg = priv->geom.columns;
7473fca49ca0 initial
alex
parents:
diff changeset
318 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
319
7473fca49ca0 initial
alex
parents:
diff changeset
320 case TVI_CONTROL_VID_SET_HEIGHT:
7473fca49ca0 initial
alex
parents:
diff changeset
321 priv->geom.rows = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
322
7473fca49ca0 initial
alex
parents:
diff changeset
323 if(priv->geom.rows > priv->maxheight)
7473fca49ca0 initial
alex
parents:
diff changeset
324 {
7473fca49ca0 initial
alex
parents:
diff changeset
325 priv->geom.rows = priv->maxheight;
7473fca49ca0 initial
alex
parents:
diff changeset
326 }
7473fca49ca0 initial
alex
parents:
diff changeset
327
7473fca49ca0 initial
alex
parents:
diff changeset
328 if(priv->geom.rows <= priv->maxheight / 2)
7473fca49ca0 initial
alex
parents:
diff changeset
329 {
7473fca49ca0 initial
alex
parents:
diff changeset
330 priv->geom.oformat |= METEOR_GEO_EVEN_ONLY;
7473fca49ca0 initial
alex
parents:
diff changeset
331 }
7473fca49ca0 initial
alex
parents:
diff changeset
332
7473fca49ca0 initial
alex
parents:
diff changeset
333 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
334 {
7473fca49ca0 initial
alex
parents:
diff changeset
335 perror("height:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
336 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
337 }
7473fca49ca0 initial
alex
parents:
diff changeset
338
7473fca49ca0 initial
alex
parents:
diff changeset
339 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
340
7473fca49ca0 initial
alex
parents:
diff changeset
341 case TVI_CONTROL_VID_GET_HEIGHT:
7473fca49ca0 initial
alex
parents:
diff changeset
342 (int)*(void **)arg = priv->geom.rows;
7473fca49ca0 initial
alex
parents:
diff changeset
343 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
344
7473fca49ca0 initial
alex
parents:
diff changeset
345 case TVI_CONTROL_VID_GET_FPS:
7473fca49ca0 initial
alex
parents:
diff changeset
346 (int)*(void **)arg = (int)priv->fps;
7473fca49ca0 initial
alex
parents:
diff changeset
347 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
348
7473fca49ca0 initial
alex
parents:
diff changeset
349 /*
7473fca49ca0 initial
alex
parents:
diff changeset
350 case TVI_CONTROL_VID_SET_FPS:
7473fca49ca0 initial
alex
parents:
diff changeset
351 priv->fps = (int)*(void **)arg;
7473fca49ca0 initial
alex
parents:
diff changeset
352
7473fca49ca0 initial
alex
parents:
diff changeset
353 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps;
7473fca49ca0 initial
alex
parents:
diff changeset
354
7473fca49ca0 initial
alex
parents:
diff changeset
355 if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
356 {
7473fca49ca0 initial
alex
parents:
diff changeset
357 perror("fps:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
358 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
359 }
7473fca49ca0 initial
alex
parents:
diff changeset
360
7473fca49ca0 initial
alex
parents:
diff changeset
361 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
362 */
7473fca49ca0 initial
alex
parents:
diff changeset
363
7473fca49ca0 initial
alex
parents:
diff changeset
364 case TVI_CONTROL_VID_CHK_WIDTH:
7473fca49ca0 initial
alex
parents:
diff changeset
365 case TVI_CONTROL_VID_CHK_HEIGHT:
7473fca49ca0 initial
alex
parents:
diff changeset
366 return(TVI_CONTROL_TRUE);
7473fca49ca0 initial
alex
parents:
diff changeset
367
7473fca49ca0 initial
alex
parents:
diff changeset
368 }
7473fca49ca0 initial
alex
parents:
diff changeset
369 return(TVI_CONTROL_UNKNOWN);
7473fca49ca0 initial
alex
parents:
diff changeset
370 }
7473fca49ca0 initial
alex
parents:
diff changeset
371
7473fca49ca0 initial
alex
parents:
diff changeset
372 static int init(priv_t *priv)
7473fca49ca0 initial
alex
parents:
diff changeset
373 {
7473fca49ca0 initial
alex
parents:
diff changeset
374 int marg;
7473fca49ca0 initial
alex
parents:
diff changeset
375
7473fca49ca0 initial
alex
parents:
diff changeset
376 G_private = priv; /* Oooh, sick */
7473fca49ca0 initial
alex
parents:
diff changeset
377
7473fca49ca0 initial
alex
parents:
diff changeset
378 /* Video Configuration */
7473fca49ca0 initial
alex
parents:
diff changeset
379
7473fca49ca0 initial
alex
parents:
diff changeset
380 priv->videoready = TRUE;
7473fca49ca0 initial
alex
parents:
diff changeset
381 priv->btdev = strdup("/dev/bktr0");
7473fca49ca0 initial
alex
parents:
diff changeset
382 priv->iformat = METEOR_FMT_PAL;
7473fca49ca0 initial
alex
parents:
diff changeset
383 priv->maxheight = PAL_HEIGHT;
7473fca49ca0 initial
alex
parents:
diff changeset
384 priv->maxwidth = PAL_WIDTH;
7473fca49ca0 initial
alex
parents:
diff changeset
385 priv->maxfps = PAL_FPS;
7473fca49ca0 initial
alex
parents:
diff changeset
386 priv->source = METEOR_INPUT_DEV0;
7473fca49ca0 initial
alex
parents:
diff changeset
387 priv->fps = priv->maxfps;
7473fca49ca0 initial
alex
parents:
diff changeset
388
7473fca49ca0 initial
alex
parents:
diff changeset
389 priv->currentframe=0;
7473fca49ca0 initial
alex
parents:
diff changeset
390
7473fca49ca0 initial
alex
parents:
diff changeset
391 priv->geom.columns = priv->maxwidth;
7473fca49ca0 initial
alex
parents:
diff changeset
392 priv->geom.rows = priv->maxheight;
7473fca49ca0 initial
alex
parents:
diff changeset
393 priv->geom.frames = 1;
7473fca49ca0 initial
alex
parents:
diff changeset
394 priv->geom.oformat = METEOR_GEO_YUV_PACKED;
7473fca49ca0 initial
alex
parents:
diff changeset
395
7473fca49ca0 initial
alex
parents:
diff changeset
396 priv->btfd = open(priv->btdev, O_RDONLY);
7473fca49ca0 initial
alex
parents:
diff changeset
397
7473fca49ca0 initial
alex
parents:
diff changeset
398 if(priv->btfd < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
399 {
7473fca49ca0 initial
alex
parents:
diff changeset
400 perror("bktr open");
7473fca49ca0 initial
alex
parents:
diff changeset
401 priv->videoready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
402 }
7473fca49ca0 initial
alex
parents:
diff changeset
403
7473fca49ca0 initial
alex
parents:
diff changeset
404 if(priv->videoready == TRUE &&
7473fca49ca0 initial
alex
parents:
diff changeset
405 ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
406 {
7473fca49ca0 initial
alex
parents:
diff changeset
407 perror("FMT:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
408 }
7473fca49ca0 initial
alex
parents:
diff changeset
409
7473fca49ca0 initial
alex
parents:
diff changeset
410 if(priv->videoready == TRUE &&
7473fca49ca0 initial
alex
parents:
diff changeset
411 ioctl(priv->btfd, METEORSINPUT, &priv->source) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
412 {
7473fca49ca0 initial
alex
parents:
diff changeset
413 perror("SINPUT:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
414 }
7473fca49ca0 initial
alex
parents:
diff changeset
415
7473fca49ca0 initial
alex
parents:
diff changeset
416 if(priv->videoready == TRUE &&
7473fca49ca0 initial
alex
parents:
diff changeset
417 ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
418 {
7473fca49ca0 initial
alex
parents:
diff changeset
419 perror("SFPS:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
420 }
7473fca49ca0 initial
alex
parents:
diff changeset
421
7473fca49ca0 initial
alex
parents:
diff changeset
422 if(priv->videoready == TRUE &&
7473fca49ca0 initial
alex
parents:
diff changeset
423 ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
424 {
7473fca49ca0 initial
alex
parents:
diff changeset
425 perror("SGEO:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
426 }
7473fca49ca0 initial
alex
parents:
diff changeset
427
7473fca49ca0 initial
alex
parents:
diff changeset
428 if(priv->videoready == TRUE)
7473fca49ca0 initial
alex
parents:
diff changeset
429 {
7473fca49ca0 initial
alex
parents:
diff changeset
430 priv->buffersize = (priv->geom.columns * priv->geom.rows * 2);
7473fca49ca0 initial
alex
parents:
diff changeset
431
7473fca49ca0 initial
alex
parents:
diff changeset
432 priv->buffer = (u_char *)mmap((caddr_t)0, priv->buffersize, PROT_READ,
7473fca49ca0 initial
alex
parents:
diff changeset
433 MAP_SHARED, priv->btfd, (off_t)0);
7473fca49ca0 initial
alex
parents:
diff changeset
434
7473fca49ca0 initial
alex
parents:
diff changeset
435 if(priv->buffer == (u_char *) MAP_FAILED)
7473fca49ca0 initial
alex
parents:
diff changeset
436 {
7473fca49ca0 initial
alex
parents:
diff changeset
437 perror("mmap");
7473fca49ca0 initial
alex
parents:
diff changeset
438 priv->videoready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
439 }
7473fca49ca0 initial
alex
parents:
diff changeset
440
7473fca49ca0 initial
alex
parents:
diff changeset
441 }
7473fca49ca0 initial
alex
parents:
diff changeset
442
7473fca49ca0 initial
alex
parents:
diff changeset
443 /* Tuner Configuration */
7473fca49ca0 initial
alex
parents:
diff changeset
444
7473fca49ca0 initial
alex
parents:
diff changeset
445 priv->tunerdev = strdup("/dev/tuner0");
7473fca49ca0 initial
alex
parents:
diff changeset
446 priv->tunerready = TRUE;
7473fca49ca0 initial
alex
parents:
diff changeset
447
7473fca49ca0 initial
alex
parents:
diff changeset
448 priv->tunerfd = open(priv->tunerdev, O_RDONLY);
7473fca49ca0 initial
alex
parents:
diff changeset
449
7473fca49ca0 initial
alex
parents:
diff changeset
450 if(priv->tunerfd < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
451 {
7473fca49ca0 initial
alex
parents:
diff changeset
452 perror("tune open");
7473fca49ca0 initial
alex
parents:
diff changeset
453 priv->tunerready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
454 }
7473fca49ca0 initial
alex
parents:
diff changeset
455
7473fca49ca0 initial
alex
parents:
diff changeset
456 /* Audio Configuration */
7473fca49ca0 initial
alex
parents:
diff changeset
457
7473fca49ca0 initial
alex
parents:
diff changeset
458 priv->dspready = TRUE;
7473fca49ca0 initial
alex
parents:
diff changeset
459 priv->dspdev = strdup("/dev/dsp");
7473fca49ca0 initial
alex
parents:
diff changeset
460 priv->dspsamplesize = 16;
7473fca49ca0 initial
alex
parents:
diff changeset
461 priv->dspstereo = 1;
7473fca49ca0 initial
alex
parents:
diff changeset
462 priv->dspspeed = 44100;
7473fca49ca0 initial
alex
parents:
diff changeset
463 priv->dspfmt = AFMT_S16_LE;
7473fca49ca0 initial
alex
parents:
diff changeset
464 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/priv->fps *
7473fca49ca0 initial
alex
parents:
diff changeset
465 (priv->dspstereo+1);
7473fca49ca0 initial
alex
parents:
diff changeset
466
7473fca49ca0 initial
alex
parents:
diff changeset
467 if((priv->dspfd = open ("/dev/dsp", O_RDWR, 0)) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
468 {
7473fca49ca0 initial
alex
parents:
diff changeset
469 perror("/dev/dsp open");
7473fca49ca0 initial
alex
parents:
diff changeset
470 priv->dspready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
471 }
7473fca49ca0 initial
alex
parents:
diff changeset
472
7473fca49ca0 initial
alex
parents:
diff changeset
473 marg = (256 << 16) | 13;
7473fca49ca0 initial
alex
parents:
diff changeset
474
7473fca49ca0 initial
alex
parents:
diff changeset
475 if (ioctl(priv->dspfd, SNDCTL_DSP_SETFRAGMENT, &marg ) < 0 )
7473fca49ca0 initial
alex
parents:
diff changeset
476 {
7473fca49ca0 initial
alex
parents:
diff changeset
477 perror("setfrag");
7473fca49ca0 initial
alex
parents:
diff changeset
478 priv->dspready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
479 }
7473fca49ca0 initial
alex
parents:
diff changeset
480
7473fca49ca0 initial
alex
parents:
diff changeset
481 if((priv->dspready == TRUE) &&
7473fca49ca0 initial
alex
parents:
diff changeset
482 (ioctl(priv->dspfd, SNDCTL_DSP_SAMPLESIZE, &priv->dspsamplesize) == -1) ||
7473fca49ca0 initial
alex
parents:
diff changeset
483 (ioctl(priv->dspfd, SNDCTL_DSP_STEREO, &priv->dspstereo) == -1) ||
7473fca49ca0 initial
alex
parents:
diff changeset
484 (ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &priv->dspspeed) == -1) ||
7473fca49ca0 initial
alex
parents:
diff changeset
485 (ioctl(priv->dspfd, SNDCTL_DSP_SETFMT, &priv->dspfmt) == -1))
7473fca49ca0 initial
alex
parents:
diff changeset
486 {
7473fca49ca0 initial
alex
parents:
diff changeset
487 perror ("configuration of /dev/dsp failed");
7473fca49ca0 initial
alex
parents:
diff changeset
488 close(priv->dspfd);
7473fca49ca0 initial
alex
parents:
diff changeset
489 priv->dspready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
490 }
7473fca49ca0 initial
alex
parents:
diff changeset
491
7473fca49ca0 initial
alex
parents:
diff changeset
492 return(1);
7473fca49ca0 initial
alex
parents:
diff changeset
493 }
7473fca49ca0 initial
alex
parents:
diff changeset
494
7473fca49ca0 initial
alex
parents:
diff changeset
495 /* that's the real start, we'got the format parameters (checked with control) */
7473fca49ca0 initial
alex
parents:
diff changeset
496 static int start(priv_t *priv)
7473fca49ca0 initial
alex
parents:
diff changeset
497 {
7473fca49ca0 initial
alex
parents:
diff changeset
498 int marg;
7473fca49ca0 initial
alex
parents:
diff changeset
499
7473fca49ca0 initial
alex
parents:
diff changeset
500 if(priv->videoready == FALSE) return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
501
7473fca49ca0 initial
alex
parents:
diff changeset
502 signal(SIGUSR1, processframe);
7473fca49ca0 initial
alex
parents:
diff changeset
503 signal(SIGALRM, processframe);
7473fca49ca0 initial
alex
parents:
diff changeset
504
7473fca49ca0 initial
alex
parents:
diff changeset
505 marg = SIGUSR1;
7473fca49ca0 initial
alex
parents:
diff changeset
506
7473fca49ca0 initial
alex
parents:
diff changeset
507 if(ioctl(priv->btfd, METEORSSIGNAL, &marg) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
508 {
7473fca49ca0 initial
alex
parents:
diff changeset
509 perror("METEORSSIGNAL failed");
7473fca49ca0 initial
alex
parents:
diff changeset
510 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
511 }
7473fca49ca0 initial
alex
parents:
diff changeset
512
7473fca49ca0 initial
alex
parents:
diff changeset
513 marg = METEOR_CAP_CONTINOUS;
7473fca49ca0 initial
alex
parents:
diff changeset
514
7473fca49ca0 initial
alex
parents:
diff changeset
515 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
516 {
7473fca49ca0 initial
alex
parents:
diff changeset
517 perror("METEORCAPTUR failed");
7473fca49ca0 initial
alex
parents:
diff changeset
518 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
519 }
7473fca49ca0 initial
alex
parents:
diff changeset
520
7473fca49ca0 initial
alex
parents:
diff changeset
521 return(1);
7473fca49ca0 initial
alex
parents:
diff changeset
522 }
7473fca49ca0 initial
alex
parents:
diff changeset
523
7473fca49ca0 initial
alex
parents:
diff changeset
524 static int uninit(priv_t *priv)
7473fca49ca0 initial
alex
parents:
diff changeset
525 {
7473fca49ca0 initial
alex
parents:
diff changeset
526 int marg;
7473fca49ca0 initial
alex
parents:
diff changeset
527
7473fca49ca0 initial
alex
parents:
diff changeset
528 if(priv->videoready == FALSE) return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
529
7473fca49ca0 initial
alex
parents:
diff changeset
530 marg = METEOR_SIG_MODE_MASK;
7473fca49ca0 initial
alex
parents:
diff changeset
531
7473fca49ca0 initial
alex
parents:
diff changeset
532 if(ioctl( priv->btfd, METEORSSIGNAL, &marg) < 0 )
7473fca49ca0 initial
alex
parents:
diff changeset
533 {
7473fca49ca0 initial
alex
parents:
diff changeset
534 perror("METEORSSIGNAL");
7473fca49ca0 initial
alex
parents:
diff changeset
535 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
536 }
7473fca49ca0 initial
alex
parents:
diff changeset
537
7473fca49ca0 initial
alex
parents:
diff changeset
538 marg = METEOR_CAP_STOP_CONT;
7473fca49ca0 initial
alex
parents:
diff changeset
539
7473fca49ca0 initial
alex
parents:
diff changeset
540 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0 )
7473fca49ca0 initial
alex
parents:
diff changeset
541 {
7473fca49ca0 initial
alex
parents:
diff changeset
542 perror("METEORCAPTUR STOP");
7473fca49ca0 initial
alex
parents:
diff changeset
543 return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
544 }
7473fca49ca0 initial
alex
parents:
diff changeset
545
7473fca49ca0 initial
alex
parents:
diff changeset
546 close(priv->btfd);
7473fca49ca0 initial
alex
parents:
diff changeset
547 close(priv->dspfd);
7473fca49ca0 initial
alex
parents:
diff changeset
548
7473fca49ca0 initial
alex
parents:
diff changeset
549 priv->dspfd = -1;
7473fca49ca0 initial
alex
parents:
diff changeset
550 priv->btfd = -1;
7473fca49ca0 initial
alex
parents:
diff changeset
551
7473fca49ca0 initial
alex
parents:
diff changeset
552 priv->dspready = priv->videoready = FALSE;
7473fca49ca0 initial
alex
parents:
diff changeset
553
7473fca49ca0 initial
alex
parents:
diff changeset
554 return(1);
7473fca49ca0 initial
alex
parents:
diff changeset
555 }
7473fca49ca0 initial
alex
parents:
diff changeset
556
7473fca49ca0 initial
alex
parents:
diff changeset
557
7473fca49ca0 initial
alex
parents:
diff changeset
558 static int grab_video_frame(priv_t *priv, char *buffer, int len)
7473fca49ca0 initial
alex
parents:
diff changeset
559 {
7473fca49ca0 initial
alex
parents:
diff changeset
560 sigset_t sa_mask;
7473fca49ca0 initial
alex
parents:
diff changeset
561
7473fca49ca0 initial
alex
parents:
diff changeset
562 if(priv->videoready == FALSE) return(0);
7473fca49ca0 initial
alex
parents:
diff changeset
563
7473fca49ca0 initial
alex
parents:
diff changeset
564 alarm(1);
7473fca49ca0 initial
alex
parents:
diff changeset
565 sigfillset(&sa_mask);
7473fca49ca0 initial
alex
parents:
diff changeset
566 sigdelset(&sa_mask,SIGINT);
7473fca49ca0 initial
alex
parents:
diff changeset
567 sigdelset(&sa_mask,SIGUSR1);
7473fca49ca0 initial
alex
parents:
diff changeset
568 sigdelset(&sa_mask,SIGALRM);
7473fca49ca0 initial
alex
parents:
diff changeset
569 sigsuspend(&sa_mask);
7473fca49ca0 initial
alex
parents:
diff changeset
570 alarm(0);
7473fca49ca0 initial
alex
parents:
diff changeset
571
7473fca49ca0 initial
alex
parents:
diff changeset
572 memcpy(buffer, priv->buffer, len);
7473fca49ca0 initial
alex
parents:
diff changeset
573
7473fca49ca0 initial
alex
parents:
diff changeset
574 return(priv->currentframe);
7473fca49ca0 initial
alex
parents:
diff changeset
575 }
7473fca49ca0 initial
alex
parents:
diff changeset
576
7473fca49ca0 initial
alex
parents:
diff changeset
577 static int get_video_framesize(priv_t *priv)
7473fca49ca0 initial
alex
parents:
diff changeset
578 {
7473fca49ca0 initial
alex
parents:
diff changeset
579 return(priv->geom.columns*priv->geom.rows*16/8);
7473fca49ca0 initial
alex
parents:
diff changeset
580 }
7473fca49ca0 initial
alex
parents:
diff changeset
581
7473fca49ca0 initial
alex
parents:
diff changeset
582 static int grab_audio_frame(priv_t *priv, char *buffer, int len)
7473fca49ca0 initial
alex
parents:
diff changeset
583 {
7473fca49ca0 initial
alex
parents:
diff changeset
584 struct audio_buf_info abi;
7473fca49ca0 initial
alex
parents:
diff changeset
585 int bytesread;
7473fca49ca0 initial
alex
parents:
diff changeset
586 int ret;
7473fca49ca0 initial
alex
parents:
diff changeset
587
7473fca49ca0 initial
alex
parents:
diff changeset
588 if(priv->dspready == FALSE) return 0;
7473fca49ca0 initial
alex
parents:
diff changeset
589
7473fca49ca0 initial
alex
parents:
diff changeset
590 /* Get exactly one frame of audio, which forces video sync to audio.. */
7473fca49ca0 initial
alex
parents:
diff changeset
591
7473fca49ca0 initial
alex
parents:
diff changeset
592 bytesread=read(priv->dspfd, buffer, len);
7473fca49ca0 initial
alex
parents:
diff changeset
593
7473fca49ca0 initial
alex
parents:
diff changeset
594 while(bytesread < len)
7473fca49ca0 initial
alex
parents:
diff changeset
595 {
7473fca49ca0 initial
alex
parents:
diff changeset
596 ret=read(priv->dspfd, &buffer[bytesread], len-bytesread);
7473fca49ca0 initial
alex
parents:
diff changeset
597
7473fca49ca0 initial
alex
parents:
diff changeset
598 if(ret == -1)
7473fca49ca0 initial
alex
parents:
diff changeset
599 {
7473fca49ca0 initial
alex
parents:
diff changeset
600 perror("Audio read failed!");
7473fca49ca0 initial
alex
parents:
diff changeset
601 return 0;
7473fca49ca0 initial
alex
parents:
diff changeset
602 }
7473fca49ca0 initial
alex
parents:
diff changeset
603
7473fca49ca0 initial
alex
parents:
diff changeset
604 bytesread+=ret;
7473fca49ca0 initial
alex
parents:
diff changeset
605 }
7473fca49ca0 initial
alex
parents:
diff changeset
606
7473fca49ca0 initial
alex
parents:
diff changeset
607 if(ioctl(priv->dspfd, SNDCTL_DSP_GETISPACE, &abi) < 0)
7473fca49ca0 initial
alex
parents:
diff changeset
608 {
7473fca49ca0 initial
alex
parents:
diff changeset
609 perror("abi:ioctl");
7473fca49ca0 initial
alex
parents:
diff changeset
610 return(TVI_CONTROL_FALSE);
7473fca49ca0 initial
alex
parents:
diff changeset
611 }
7473fca49ca0 initial
alex
parents:
diff changeset
612
7473fca49ca0 initial
alex
parents:
diff changeset
613 return(abi.bytes/len);
7473fca49ca0 initial
alex
parents:
diff changeset
614 }
7473fca49ca0 initial
alex
parents:
diff changeset
615
7473fca49ca0 initial
alex
parents:
diff changeset
616 static int get_audio_framesize(priv_t *priv)
7473fca49ca0 initial
alex
parents:
diff changeset
617 {
7473fca49ca0 initial
alex
parents:
diff changeset
618 if(priv->dspready == FALSE) return 0;
7473fca49ca0 initial
alex
parents:
diff changeset
619
7473fca49ca0 initial
alex
parents:
diff changeset
620 return(priv->dspframesize);
7473fca49ca0 initial
alex
parents:
diff changeset
621 }
7473fca49ca0 initial
alex
parents:
diff changeset
622
7473fca49ca0 initial
alex
parents:
diff changeset
623 static int getinput(int innumber)
7473fca49ca0 initial
alex
parents:
diff changeset
624 {
7473fca49ca0 initial
alex
parents:
diff changeset
625 switch(innumber)
7473fca49ca0 initial
alex
parents:
diff changeset
626 {
7473fca49ca0 initial
alex
parents:
diff changeset
627 case 0: return METEOR_INPUT_DEV0; /* RCA */
7473fca49ca0 initial
alex
parents:
diff changeset
628 case 1: return METEOR_INPUT_DEV1; /* Tuner */
7473fca49ca0 initial
alex
parents:
diff changeset
629 case 2: return METEOR_INPUT_DEV2; /* In 1 */
7473fca49ca0 initial
alex
parents:
diff changeset
630 case 3: return METEOR_INPUT_DEV3; /* In 2 */
7473fca49ca0 initial
alex
parents:
diff changeset
631 case 4: return METEOR_INPUT_DEV_RGB; /* RGB */
7473fca49ca0 initial
alex
parents:
diff changeset
632 case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid */
7473fca49ca0 initial
alex
parents:
diff changeset
633 }
7473fca49ca0 initial
alex
parents:
diff changeset
634
7473fca49ca0 initial
alex
parents:
diff changeset
635 return 0;
7473fca49ca0 initial
alex
parents:
diff changeset
636 }
7473fca49ca0 initial
alex
parents:
diff changeset
637
7473fca49ca0 initial
alex
parents:
diff changeset
638 #endif /* USE_TV */