Mercurial > mplayer.hg
annotate stream/tvi_bsdbt848.c @ 22071:c2e9b5d0ccba
x264's crf takes a float argument
author | lorenm |
---|---|
date | Wed, 31 Jan 2007 08:23:37 +0000 |
parents | 3ff1eade91f9 |
children | 6cabac4d35b5 |
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> | |
39 | |
11723 | 40 #include <sys/param.h> |
5872 | 41 #ifdef __NetBSD__ |
42 #include <dev/ic/bt8xx.h> | |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
43 #include <sys/audioio.h> |
15566 | 44 #elif defined(__DragonFly__) |
45 #include <dev/video/meteor/ioctl_meteor.h> | |
46 #include <dev/video/bktr/ioctl_bt848.h> | |
21848 | 47 #elif (__FreeBSD_version >= 502100) || defined(__FreeBSD_kernel__) |
11723 | 48 #include <dev/bktr/ioctl_meteor.h> |
49 #include <dev/bktr/ioctl_bt848.h> | |
5872 | 50 #else |
5081 | 51 #include <machine/ioctl_meteor.h> |
52 #include <machine/ioctl_bt848.h> | |
5872 | 53 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
54 |
5142 | 55 #ifdef HAVE_SYS_SOUNDCARD_H |
56 #include <sys/soundcard.h> | |
57 #else | |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
58 #ifdef HAVE_SOUNDCARD_H |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
59 #include <soundcard.h> |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
60 #else |
5081 | 61 #include <machine/soundcard.h> |
5142 | 62 #endif |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
63 #endif |
5081 | 64 |
17012 | 65 #include "libaf/af_format.h" |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19271
diff
changeset
|
66 #include "libmpcodecs/img_format.h" |
5081 | 67 #include "tv.h" |
68 | |
69 /* information about this file */ | |
70 static tvi_info_t info = { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
71 "Brooktree848 Support", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
72 "bsdbt848", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
73 "Charles Henrich", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
74 "in development" |
5081 | 75 }; |
76 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
77 typedef struct { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
78 int dirty; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
79 double timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
80 char *buf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
81 } RBFRAME; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
82 |
5081 | 83 /* private data's */ |
84 typedef struct { | |
85 | |
86 /* Audio */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
87 char *dspdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
88 int dspready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
89 int dspfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
90 int dspsamplesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
91 int dspstereo; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
92 int dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
93 int dspfmt; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
94 int dspframesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
95 int dsprate; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
96 long long dspbytesread; |
5081 | 97 |
98 /* Video */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
99 char *btdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
100 int videoready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
101 int btfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
102 int source; |
10019 | 103 float maxfps; |
104 float fps; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
105 int iformat; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
106 int maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
107 int maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
108 struct meteor_geomet geom; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
109 struct meteor_capframe capframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
110 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
111 /* Frame Buffer */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
112 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
113 int framebufsize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
114 float timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
115 int curpaintframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
116 int curbufframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
117 unsigned char *livebuf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
118 RBFRAME framebuf[RINGSIZE]; |
5081 | 119 |
120 /* Inputs */ | |
121 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
122 int input; |
5081 | 123 |
124 /* Tuner */ | |
125 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
126 char *tunerdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
127 int tunerfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
128 int tunerready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
129 u_long tunerfreq; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
130 struct bktr_chnlset cset; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
131 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
132 /* Other */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
133 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
134 int immediatemode; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
135 double starttime; |
5081 | 136 |
137 } priv_t; | |
138 | |
139 #include "tvi_def.h" | |
140 | |
141 static priv_t *G_private=NULL; | |
142 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
143 static int getinput(int innumber); |
5081 | 144 |
145 static void processframe(int signal) | |
146 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
147 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
148 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
149 if(G_private->immediatemode == TRUE) return; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
150 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
151 gettimeofday(&curtime, NULL); |
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->framebuf[G_private->curpaintframe].dirty == TRUE) |
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 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
|
156 G_private->livebuf, G_private->framebufsize); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
157 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
158 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
|
159 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
160 G_private->framebuf[G_private->curpaintframe].timestamp = |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
161 curtime.tv_sec + curtime.tv_usec*.000001; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
162 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
163 G_private->curpaintframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
164 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
165 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
|
166 } |
5081 | 167 |
168 return; | |
169 } | |
170 | |
171 /* handler creator - entry point ! */ | |
172 tvi_handle_t *tvi_init_bsdbt848(char *device) | |
173 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
174 return(new_handle()); |
5081 | 175 } |
176 | |
177 static int control(priv_t *priv, int cmd, void *arg) | |
178 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
179 switch(cmd) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
180 { |
5081 | 181 |
182 /* Tuner Controls */ | |
183 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
184 case TVI_CONTROL_IS_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
185 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
|
186 return(TVI_CONTROL_TRUE); |
5081 | 187 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
188 case TVI_CONTROL_TUN_GET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
189 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
190 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
|
191 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
192 perror("GETFREQ:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
193 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
194 } |
5081 | 195 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
196 *(int *)arg = priv->tunerfreq; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
197 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
198 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
199 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
200 case TVI_CONTROL_TUN_SET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
201 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
202 priv->tunerfreq = *(int *)arg; |
5081 | 203 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
204 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
|
205 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
206 perror("SETFREQ:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
207 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
208 } |
5081 | 209 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
210 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
211 } |
5081 | 212 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
213 case TVI_CONTROL_TUN_GET_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
214 case TVI_CONTROL_TUN_SET_TUNER: |
5081 | 215 |
216 /* Inputs */ | |
217 | |
218 case TVI_CONTROL_SPC_GET_INPUT: | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
219 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
220 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
|
221 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
222 perror("GINPUT:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
223 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
224 } |
5081 | 225 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
226 *(int *)arg = priv->input; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
227 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
228 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
229 |
5081 | 230 case TVI_CONTROL_SPC_SET_INPUT: |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
231 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
232 priv->input = getinput(*(int *)arg); |
5081 | 233 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
234 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
|
235 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
236 perror("tunerfreq:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
237 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
238 } |
5081 | 239 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
240 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
241 } |
5081 | 242 |
243 /* Audio Controls */ | |
244 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
245 case TVI_CONTROL_IS_AUDIO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
246 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
|
247 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
248 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
249 case TVI_CONTROL_AUD_GET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
250 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
251 *(int *)arg = AF_FORMAT_S16_LE; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
252 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
253 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
254 case TVI_CONTROL_AUD_GET_CHANNELS: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
255 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
256 *(int *)arg = 2; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
257 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
258 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
259 case TVI_CONTROL_AUD_SET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
260 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
261 int dspspeed = *(int *)arg; |
5081 | 262 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
263 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
|
264 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
265 perror("invalidaudiorate"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
266 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
267 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
268 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
269 priv->dspspeed = dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
270 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
271 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
272 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
273 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8* |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
274 (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
275 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
276 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
277 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
278 case TVI_CONTROL_AUD_GET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
279 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
280 *(int *)arg = priv->dspspeed; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
281 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
282 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
283 case TVI_CONTROL_AUD_GET_SAMPLESIZE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
284 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
285 *(int *)arg = priv->dspsamplesize/8; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
286 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
287 } |
5081 | 288 |
289 /* Video Controls */ | |
290 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
291 case TVI_CONTROL_IS_VIDEO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
292 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
|
293 return(TVI_CONTROL_TRUE); |
5081 | 294 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
295 case TVI_CONTROL_TUN_SET_NORM: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
296 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
297 int req_mode = *(int *)arg; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
298 u_short tmp_fps; |
5081 | 299 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
300 priv->iformat = METEOR_FMT_AUTOMODE; |
5081 | 301 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
302 if(req_mode == TV_NORM_PAL) |
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 priv->iformat = METEOR_FMT_PAL; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
305 priv->maxheight = PAL_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
306 priv->maxwidth = PAL_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
307 priv->maxfps = PAL_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
308 priv->fps = PAL_FPS; |
5081 | 309 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
310 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 311 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
312 if(priv->geom.rows > priv->maxheight) |
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 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
315 } |
5081 | 316 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
317 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
318 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
319 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
320 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
321 } |
5081 | 322 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
323 if(req_mode == TV_NORM_NTSC) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
324 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
325 priv->iformat = METEOR_FMT_NTSC; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
326 priv->maxheight = NTSC_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
327 priv->maxwidth = NTSC_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
328 priv->maxfps = NTSC_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
329 priv->fps = NTSC_FPS; |
5081 | 330 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
331 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
332 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
333 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8 * |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
334 (priv->dspstereo+1); |
5081 | 335 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
336 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 337 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
338 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
339 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
340 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
341 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
342 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
343 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
344 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
345 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
346 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
347 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
348 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
349 if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM; |
5081 | 350 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
351 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
|
352 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
353 perror("format:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
354 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
355 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
356 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
357 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
|
358 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
359 perror("geo:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
360 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
361 } |
5081 | 362 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
363 tmp_fps = priv->fps; |
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
364 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
|
365 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
366 perror("fps:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
367 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
368 } |
5081 | 369 |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
370 #ifdef BT848_SAUDIO |
12608
fbd18fae40f1
10l, patch by Michael Nottebrock <michaelnottebrock@gmx.net>
faust3
parents:
12140
diff
changeset
|
371 if(priv->tunerready == TRUE && |
fbd18fae40f1
10l, patch by Michael Nottebrock <michaelnottebrock@gmx.net>
faust3
parents:
12140
diff
changeset
|
372 ioctl(priv->tunerfd, BT848_SAUDIO, &tv_param_audio_id) < 0) |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
373 { |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
374 perror("audioid:ioctl"); |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
375 } |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
376 #endif |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
377 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
378 return(TVI_CONTROL_TRUE); |
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 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
381 case TVI_CONTROL_VID_GET_FORMAT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
382 *(int *)arg = IMGFMT_UYVY; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
383 return(TVI_CONTROL_TRUE); |
5081 | 384 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
385 case TVI_CONTROL_VID_SET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
386 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
387 int req_fmt = *(int *)arg; |
5081 | 388 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
389 if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE); |
5081 | 390 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
391 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
392 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
393 case TVI_CONTROL_VID_SET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
394 priv->geom.columns = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
395 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
396 if(priv->geom.columns > priv->maxwidth) |
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 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
399 } |
5081 | 400 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
401 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
|
402 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
403 perror("width:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
404 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
405 } |
5081 | 406 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
407 return(TVI_CONTROL_TRUE); |
5081 | 408 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
409 case TVI_CONTROL_VID_GET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
410 *(int *)arg = priv->geom.columns; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
411 return(TVI_CONTROL_TRUE); |
5081 | 412 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
413 case TVI_CONTROL_VID_SET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
414 priv->geom.rows = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
415 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
416 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
417 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
418 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
419 } |
5081 | 420 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
421 if(priv->geom.rows <= priv->maxheight / 2) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
422 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
423 priv->geom.oformat |= METEOR_GEO_EVEN_ONLY; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
424 } |
5081 | 425 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
426 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
|
427 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
428 perror("height:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
429 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
430 } |
5081 | 431 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
432 return(TVI_CONTROL_TRUE); |
5081 | 433 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
434 case TVI_CONTROL_VID_GET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
435 *(int *)arg = priv->geom.rows; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
436 return(TVI_CONTROL_TRUE); |
5081 | 437 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
438 case TVI_CONTROL_VID_GET_FPS: |
10019 | 439 *(float *)arg = priv->fps; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
440 return(TVI_CONTROL_TRUE); |
5081 | 441 |
442 /* | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
443 case TVI_CONTROL_VID_SET_FPS: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
444 priv->fps = *(int *)arg; |
5081 | 445 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
446 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 447 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
448 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
|
449 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
450 perror("fps:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
451 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
452 } |
5081 | 453 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
454 return(TVI_CONTROL_TRUE); |
5081 | 455 */ |
456 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
457 case TVI_CONTROL_VID_CHK_WIDTH: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
458 case TVI_CONTROL_VID_CHK_HEIGHT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
459 return(TVI_CONTROL_TRUE); |
5081 | 460 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
461 case TVI_CONTROL_IMMEDIATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
462 priv->immediatemode = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
463 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
464 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
465 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
466 return(TVI_CONTROL_UNKNOWN); |
5081 | 467 } |
468 | |
469 static int init(priv_t *priv) | |
470 { | |
471 int marg; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
472 int count; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
473 u_short tmp_fps; |
5081 | 474 |
475 G_private = priv; /* Oooh, sick */ | |
476 | |
477 /* Video Configuration */ | |
478 | |
479 priv->videoready = TRUE; | |
480 priv->btdev = strdup("/dev/bktr0"); | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
481 priv->immediatemode = FALSE; |
5081 | 482 priv->iformat = METEOR_FMT_PAL; |
483 priv->maxheight = PAL_HEIGHT; | |
484 priv->maxwidth = PAL_WIDTH; | |
485 priv->maxfps = PAL_FPS; | |
486 priv->source = METEOR_INPUT_DEV0; | |
487 priv->fps = priv->maxfps; | |
488 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
489 priv->starttime=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
490 priv->curpaintframe=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
491 priv->curbufframe=0; |
5081 | 492 |
493 priv->geom.columns = priv->maxwidth; | |
494 priv->geom.rows = priv->maxheight; | |
495 priv->geom.frames = 1; | |
496 priv->geom.oformat = METEOR_GEO_YUV_PACKED; | |
497 | |
498 priv->btfd = open(priv->btdev, O_RDONLY); | |
499 | |
500 if(priv->btfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
501 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
502 perror("bktr open"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
503 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
504 } |
5081 | 505 |
506 if(priv->videoready == TRUE && | |
507 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
|
508 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
509 perror("FMT:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
510 } |
5081 | 511 |
512 if(priv->videoready == TRUE && | |
513 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
|
514 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
515 perror("SINPUT:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
516 } |
5081 | 517 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
518 tmp_fps = priv->fps; |
5081 | 519 if(priv->videoready == TRUE && |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
520 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
|
521 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
522 perror("SFPS:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
523 } |
5081 | 524 |
525 if(priv->videoready == TRUE && | |
526 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
|
527 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
528 perror("SGEO:ioctl"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
529 } |
5081 | 530 |
531 if(priv->videoready == TRUE) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
532 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
533 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
|
534 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
535 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
|
536 MAP_SHARED, priv->btfd, (off_t)0); |
5081 | 537 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
538 if(priv->livebuf == (u_char *) MAP_FAILED) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
539 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
540 perror("mmap"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
541 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
542 } |
5081 | 543 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
544 for(count=0;count<RINGSIZE;count++) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
545 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
546 priv->framebuf[count].buf = malloc(priv->framebufsize); |
5081 | 547 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
548 if(priv->framebuf[count].buf == NULL) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
549 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
550 perror("framebufmalloc"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
551 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
552 break; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
553 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
554 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
555 priv->framebuf[count].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
556 priv->framebuf[count].timestamp = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
557 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
558 } |
5081 | 559 |
560 /* Tuner Configuration */ | |
561 | |
562 priv->tunerdev = strdup("/dev/tuner0"); | |
563 priv->tunerready = TRUE; | |
564 | |
565 priv->tunerfd = open(priv->tunerdev, O_RDONLY); | |
566 | |
567 if(priv->tunerfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
568 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
569 perror("tune open"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
570 priv->tunerready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
571 } |
5081 | 572 |
573 /* Audio Configuration */ | |
574 | |
575 priv->dspready = TRUE; | |
12140 | 576 #ifdef __NetBSD__ |
577 priv->dspdev = strdup("/dev/sound"); | |
578 #else | |
5081 | 579 priv->dspdev = strdup("/dev/dsp"); |
12140 | 580 #endif |
5081 | 581 priv->dspsamplesize = 16; |
582 priv->dspstereo = 1; | |
583 priv->dspspeed = 44100; | |
584 priv->dspfmt = AFMT_S16_LE; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
585 priv->dspbytesread = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
586 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8*(priv->dspstereo+1); |
5081 | 587 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
|
588 (priv->dspstereo+1); |
5081 | 589 |
12140 | 590 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
|
591 { |
12140 | 592 perror("dsp open"); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
593 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
594 } |
5081 | 595 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
596 marg = (256 << 16) | 12; |
5081 | 597 |
598 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
|
599 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
600 perror("setfrag"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
601 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
602 } |
5081 | 603 |
604 if((priv->dspready == TRUE) && | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
605 ((ioctl(priv->dspfd, SNDCTL_DSP_SAMPLESIZE, &priv->dspsamplesize) == -1) || |
5081 | 606 (ioctl(priv->dspfd, SNDCTL_DSP_STEREO, &priv->dspstereo) == -1) || |
607 (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
|
608 (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
|
609 { |
12140 | 610 perror ("configuration of dsp failed"); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
611 close(priv->dspfd); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
612 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
613 } |
5081 | 614 |
615 return(1); | |
616 } | |
617 | |
618 /* that's the real start, we'got the format parameters (checked with control) */ | |
619 static int start(priv_t *priv) | |
620 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
621 int tmp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
622 struct timeval curtime; |
5081 | 623 int marg; |
624 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
625 fprintf(stderr,"START\n"); |
5081 | 626 if(priv->videoready == FALSE) return(0); |
627 | |
628 signal(SIGUSR1, processframe); | |
629 signal(SIGALRM, processframe); | |
630 | |
631 marg = SIGUSR1; | |
632 | |
633 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
|
634 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
635 perror("METEORSSIGNAL failed"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
636 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
637 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
638 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
639 read(priv->dspfd, &tmp, 2); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
640 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
641 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
642 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
643 priv->starttime = curtime.tv_sec + (curtime.tv_usec *.000001); |
5081 | 644 |
645 marg = METEOR_CAP_CONTINOUS; | |
646 | |
647 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
|
648 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
649 perror("METEORCAPTUR failed"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
650 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
651 } |
5081 | 652 |
653 return(1); | |
654 } | |
655 | |
656 static int uninit(priv_t *priv) | |
657 { | |
658 int marg; | |
659 | |
660 if(priv->videoready == FALSE) return(0); | |
661 | |
662 marg = METEOR_SIG_MODE_MASK; | |
663 | |
664 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
|
665 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
666 perror("METEORSSIGNAL"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
667 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
668 } |
5081 | 669 |
670 marg = METEOR_CAP_STOP_CONT; | |
671 | |
672 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
|
673 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
674 perror("METEORCAPTUR STOP"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
675 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
676 } |
5081 | 677 |
678 close(priv->btfd); | |
679 close(priv->dspfd); | |
680 | |
681 priv->dspfd = -1; | |
682 priv->btfd = -1; | |
683 | |
684 priv->dspready = priv->videoready = FALSE; | |
685 | |
686 return(1); | |
687 } | |
688 | |
689 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
690 static double grabimmediate_video_frame(priv_t *priv, char *buffer, int len) |
5081 | 691 { |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
692 struct timeval curtime; |
5081 | 693 sigset_t sa_mask; |
694 | |
695 if(priv->videoready == FALSE) return(0); | |
696 | |
697 alarm(1); | |
698 sigfillset(&sa_mask); | |
699 sigdelset(&sa_mask,SIGINT); | |
700 sigdelset(&sa_mask,SIGUSR1); | |
701 sigdelset(&sa_mask,SIGALRM); | |
702 sigsuspend(&sa_mask); | |
703 alarm(0); | |
704 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
705 memcpy(buffer, priv->livebuf, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
706 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
707 /* 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
|
708 without audio capture .. */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
709 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
710 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
711 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
712 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
713 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
|
714 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
715 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
716 double timestamp=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
717 sigset_t sa_mask; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
718 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
719 if(priv->videoready == FALSE) return(0); |
5081 | 720 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
721 if(priv->immediatemode == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
722 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
723 return grabimmediate_video_frame(priv, buffer, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
724 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
725 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
726 while(priv->framebuf[priv->curbufframe].dirty == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
727 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
728 alarm(1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
729 sigemptyset(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
730 sigsuspend(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
731 alarm(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
732 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
733 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
734 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
|
735 timestamp = priv->framebuf[priv->curbufframe].timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
736 priv->framebuf[priv->curbufframe].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
737 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
738 priv->curbufframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
739 if(priv->curbufframe >= RINGSIZE) priv->curbufframe = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
740 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
741 return(timestamp-priv->starttime); |
5081 | 742 } |
743 | |
744 static int get_video_framesize(priv_t *priv) | |
745 { | |
746 return(priv->geom.columns*priv->geom.rows*16/8); | |
747 } | |
748 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
749 static double grab_audio_frame(priv_t *priv, char *buffer, int len) |
5081 | 750 { |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
751 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
752 double curpts; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
753 double timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
754 int bytesavail; |
5081 | 755 int bytesread; |
756 int ret; | |
757 | |
758 if(priv->dspready == FALSE) return 0; | |
759 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
760 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
761 |
5081 | 762 /* Get exactly one frame of audio, which forces video sync to audio.. */ |
763 | |
764 bytesread=read(priv->dspfd, buffer, len); | |
765 | |
766 while(bytesread < len) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
767 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
768 ret=read(priv->dspfd, &buffer[bytesread], len-bytesread); |
5081 | 769 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
770 if(ret == -1) |
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 perror("Audio read failed!"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
773 return 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
774 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
775 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
776 bytesread+=ret; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
777 } |
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 priv->dspbytesread += bytesread; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
780 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
781 curpts = curtime.tv_sec + curtime.tv_usec * .000001; |
5081 | 782 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
783 timeskew = priv->dspbytesread * 1.0 / priv->dsprate - (curpts-priv->starttime); |
5081 | 784 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
785 if(timeskew > .125/priv->fps) |
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 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
788 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
789 else |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
790 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
791 if(timeskew < -.125/priv->fps) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
792 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
793 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
794 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
795 } |
5081 | 796 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
797 return(priv->dspbytesread * 1.0 / priv->dsprate); |
5081 | 798 } |
799 | |
800 static int get_audio_framesize(priv_t *priv) | |
801 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
802 int bytesavail; |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
803 #ifdef __NetBSD__ |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
804 struct audio_info auinf; |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
805 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
806 |
5081 | 807 if(priv->dspready == FALSE) return 0; |
808 | |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
809 #ifdef __NetBSD__ |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
810 if(ioctl(priv->dspfd, AUDIO_GETINFO, &auinf) < 0) |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
811 { |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
812 perror("AUDIO_GETINFO"); |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
813 return(TVI_CONTROL_FALSE); |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
814 } |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
815 else |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
816 bytesavail = auinf.record.seek; /* *priv->dspsamplesize; */ |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
817 #else |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
818 if(ioctl(priv->dspfd, FIONREAD, &bytesavail) < 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 perror("FIONREAD"); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
821 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
822 } |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
823 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
824 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
825 /* When mencoder wants audio data, it wants data.. |
11000 | 826 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
|
827 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
828 if(bytesavail == 0) return FRAGSIZE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
829 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
830 return(bytesavail); |
5081 | 831 } |
832 | |
833 static int getinput(int innumber) | |
834 { | |
835 switch(innumber) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
836 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
837 case 0: return METEOR_INPUT_DEV0; /* RCA */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
838 case 1: return METEOR_INPUT_DEV1; /* Tuner */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 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
|
843 } |
5081 | 844 |
845 return 0; | |
846 } |