annotate libmpdemux/tvi_bsdbt848.c @ 5081:7473fca49ca0

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