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