Mercurial > mplayer.hg
annotate stream/stream_pvr.c @ 22457:ec65ae350bb6
A function always returning 0 could as well return void.
author | eugeni |
---|---|
date | Tue, 06 Mar 2007 10:00:53 +0000 |
parents | be7b8a83649c |
children | 9a4634744b41 |
rev | line source |
---|---|
18997 | 1 /* |
2 * Copyright (C) 2006 Benjamin Zores | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
3 * Stream layer for hardware MPEG 1/2/4 encoders a.k.a PVR |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
4 * (such as WinTV PVR-150/250/350/500 (a.k.a IVTV), pvrusb2 and cx88). |
18997 | 5 * See http://ivtvdriver.org/index.php/Main_Page for more details on the |
6 * cards supported by the ivtv driver. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software Foundation, | |
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
21 */ | |
22 | |
23 #include "config.h" | |
24 | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <unistd.h> | |
28 #include <string.h> | |
29 #include <ctype.h> | |
30 #include <sys/time.h> | |
31 #include <errno.h> | |
32 #include <sys/ioctl.h> | |
33 #include <sys/fcntl.h> | |
34 #include <inttypes.h> | |
35 #include <sys/poll.h> | |
19617
75063178d39f
fix build on some old 2.6 kernels, patch by Gernot Hillier
ben
parents:
19294
diff
changeset
|
36 #include <linux/types.h> |
18997 | 37 #include <linux/videodev2.h> |
38 | |
39 #include "mp_msg.h" | |
40 #include "help_mp.h" | |
41 | |
42 #include "stream.h" | |
43 #include "tv.h" | |
44 | |
45 #define PVR_DEFAULT_DEVICE "/dev/video0" | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
46 #define PVR_MAX_CONTROLS 10 |
18997 | 47 |
48 /* logging mechanisms */ | |
49 #define LOG_LEVEL_PVR "[pvr]" | |
50 #define LOG_LEVEL_V4L2 "[v4l2]" | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
51 #define LOG_LEVEL_ENCODER "[encoder]" |
18997 | 52 |
53 /* audio codec mode */ | |
54 #define PVR_AUDIO_MODE_ARG_STEREO "stereo" | |
55 #define PVR_AUDIO_MODE_ARG_JOINT_STEREO "joint_stereo" | |
56 #define PVR_AUDIO_MODE_ARG_DUAL "dual" | |
57 #define PVR_AUDIO_MODE_ARG_MONO "mono" | |
58 | |
59 /* video codec bitrate mode */ | |
60 #define PVR_VIDEO_BITRATE_MODE_ARG_VBR "vbr" | |
61 #define PVR_VIDEO_BITRATE_MODE_ARG_CBR "cbr" | |
62 | |
63 /* video codec stream type */ | |
64 #define PVR_VIDEO_STREAM_TYPE_PS "ps" | |
65 #define PVR_VIDEO_STREAM_TYPE_TS "ts" | |
66 #define PVR_VIDEO_STREAM_TYPE_MPEG1 "mpeg1" | |
67 #define PVR_VIDEO_STREAM_TYPE_DVD "dvd" | |
68 #define PVR_VIDEO_STREAM_TYPE_VCD "vcd" | |
69 #define PVR_VIDEO_STREAM_TYPE_SVCD "svcd" | |
70 | |
71 /* command line arguments */ | |
72 int pvr_param_aspect_ratio = 0; | |
73 int pvr_param_sample_rate = 0; | |
74 int pvr_param_audio_layer = 0; | |
75 int pvr_param_audio_bitrate = 0; | |
76 char *pvr_param_audio_mode = NULL; | |
77 int pvr_param_bitrate = 0; | |
78 char *pvr_param_bitrate_mode = NULL; | |
79 int pvr_param_bitrate_peak = 0; | |
80 char *pvr_param_stream_type = NULL; | |
81 | |
82 struct pvr_t { | |
83 int dev_fd; | |
84 char *video_dev; | |
85 | |
86 /* v4l2 params */ | |
87 int mute; | |
88 int input; | |
89 int normid; | |
90 int brightness; | |
91 int contrast; | |
92 int hue; | |
93 int saturation; | |
94 int width; | |
95 int height; | |
96 char *freq; | |
97 | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
98 /* encoder params */ |
18997 | 99 int aspect; |
100 int samplerate; | |
101 int layer; | |
102 int audio_rate; | |
103 int audio_mode; | |
104 int bitrate; | |
105 int bitrate_mode; | |
106 int bitrate_peak; | |
107 int stream_type; | |
108 }; | |
109 | |
110 static struct pvr_t * | |
111 pvr_init (void) | |
112 { | |
113 struct pvr_t *pvr = NULL; | |
114 | |
115 pvr = malloc (sizeof (struct pvr_t)); | |
116 pvr->dev_fd = -1; | |
117 pvr->video_dev = strdup (PVR_DEFAULT_DEVICE); | |
118 | |
119 /* v4l2 params */ | |
120 pvr->mute = 0; | |
121 pvr->input = 0; | |
122 pvr->normid = -1; | |
123 pvr->brightness = 0; | |
124 pvr->contrast = 0; | |
125 pvr->hue = 0; | |
126 pvr->saturation = 0; | |
127 pvr->width = -1; | |
128 pvr->height = -1; | |
129 pvr->freq = NULL; | |
130 | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
131 /* set default encoding settings |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
132 * may be overlapped by user parameters |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
133 * Use VBR MPEG_PS encoding at 6 Mbps (peak at 9.6 Mbps) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
134 * with 48 KHz L2 384 kbps audio. |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
135 */ |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
136 pvr->aspect = V4L2_MPEG_VIDEO_ASPECT_4x3; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
137 pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
138 pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_2; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
139 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_384K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
140 pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
141 pvr->bitrate = 6000000; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
142 pvr->bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
143 pvr->bitrate_peak = 9600000; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
144 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS; |
18997 | 145 |
146 return pvr; | |
147 } | |
148 | |
149 static void | |
150 pvr_uninit (struct pvr_t *pvr) | |
151 { | |
152 if (!pvr) | |
153 return; | |
154 | |
155 /* close device */ | |
156 if (pvr->dev_fd) | |
157 close (pvr->dev_fd); | |
158 | |
159 if (pvr->video_dev) | |
160 free (pvr->video_dev); | |
161 if (pvr->freq) | |
162 free (pvr->freq); | |
163 free (pvr); | |
164 } | |
165 | |
166 static void | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
167 parse_encoder_options (struct pvr_t *pvr) |
18997 | 168 { |
169 if (!pvr) | |
170 return; | |
171 | |
172 /* -pvr aspect=digit */ | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
173 if (pvr_param_aspect_ratio >= 0 && pvr_param_aspect_ratio <= 3) |
18997 | 174 pvr->aspect = pvr_param_aspect_ratio; |
175 | |
176 /* -pvr arate=x */ | |
177 if (pvr_param_sample_rate != 0) | |
178 { | |
179 switch (pvr_param_sample_rate) | |
180 { | |
181 case 32000: | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
182 pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000; |
18997 | 183 break; |
184 case 44100: | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
185 pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100; |
18997 | 186 break; |
187 case 48000: | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
188 pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000; |
18997 | 189 break; |
190 default: | |
191 break; | |
192 } | |
193 } | |
194 | |
195 /* -pvr alayer=x */ | |
196 if (pvr_param_audio_layer == 1) | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
197 pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_1; |
18997 | 198 else if (pvr_param_audio_layer == 2) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
199 pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_2; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
200 else if (pvr_param_audio_layer == 3) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
201 pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_3; |
18997 | 202 |
203 /* -pvr abitrate=x */ | |
204 if (pvr_param_audio_bitrate != 0) | |
205 { | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
206 if (pvr->layer == V4L2_MPEG_AUDIO_ENCODING_LAYER_1) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
207 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
208 switch (pvr_param_audio_bitrate) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
209 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
210 case 32: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
211 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_32K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
212 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
213 case 64: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
214 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_64K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
215 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
216 case 96: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
217 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_96K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
218 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
219 case 128: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
220 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_128K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
221 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
222 case 160: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
223 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_160K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
224 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
225 case 192: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
226 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_192K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
227 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
228 case 224: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
229 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_224K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
230 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
231 case 256: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
232 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_256K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
233 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
234 case 288: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
235 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_288K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
236 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
237 case 320: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
238 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_320K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
239 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
240 case 352: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
241 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_352K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
242 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
243 case 384: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
244 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_384K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
245 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
246 case 416: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
247 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_416K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
248 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
249 case 448: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
250 pvr->audio_rate = V4L2_MPEG_AUDIO_L1_BITRATE_448K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
251 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
252 default: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
253 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
254 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
255 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
256 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
257 else if (pvr->layer == V4L2_MPEG_AUDIO_ENCODING_LAYER_2) |
18997 | 258 { |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
259 switch (pvr_param_audio_bitrate) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
260 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
261 case 32: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
262 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_32K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
263 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
264 case 48: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
265 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_48K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
266 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
267 case 56: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
268 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_56K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
269 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
270 case 64: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
271 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_64K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
272 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
273 case 80: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
274 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_80K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
275 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
276 case 96: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
277 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_96K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
278 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
279 case 112: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
280 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_112K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
281 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
282 case 128: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
283 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_128K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
284 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
285 case 160: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
286 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_160K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
287 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
288 case 192: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
289 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_192K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
290 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
291 case 224: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
292 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_224K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
293 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
294 case 256: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
295 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_256K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
296 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
297 case 320: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
298 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_320K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
299 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
300 case 384: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
301 pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_384K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
302 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
303 default: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
304 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
305 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
306 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
307 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
308 else if (pvr->layer == V4L2_MPEG_AUDIO_ENCODING_LAYER_3) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
309 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
310 switch (pvr_param_audio_bitrate) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
311 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
312 case 32: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
313 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_32K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
314 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
315 case 40: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
316 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_40K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
317 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
318 case 48: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
319 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_48K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
320 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
321 case 56: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
322 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_56K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
323 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
324 case 64: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
325 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_64K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
326 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
327 case 80: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
328 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_80K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
329 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
330 case 96: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
331 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_96K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
332 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
333 case 112: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
334 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_112K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
335 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
336 case 128: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
337 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_128K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
338 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
339 case 160: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
340 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_160K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
341 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
342 case 192: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
343 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_192K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
344 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
345 case 224: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
346 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_224K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
347 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
348 case 256: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
349 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_256K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
350 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
351 case 320: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
352 pvr->audio_rate = V4L2_MPEG_AUDIO_L3_BITRATE_320K; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
353 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
354 default: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
355 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
356 } |
18997 | 357 } |
358 } | |
359 | |
360 /* -pvr amode=x */ | |
361 if (pvr_param_audio_mode) | |
362 { | |
363 if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_STEREO)) | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
364 pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO; |
18997 | 365 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_JOINT_STEREO)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
366 pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_JOINT_STEREO; |
18997 | 367 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_DUAL)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
368 pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_DUAL; |
18997 | 369 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_MONO)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
370 pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_MONO; |
18997 | 371 } |
372 | |
373 /* -pvr vbitrate=x */ | |
374 if (pvr_param_bitrate) | |
375 pvr->bitrate = pvr_param_bitrate; | |
376 | |
377 /* -pvr vmode=x */ | |
378 if (pvr_param_bitrate_mode) | |
379 { | |
380 if (!strcmp (pvr_param_bitrate_mode, PVR_VIDEO_BITRATE_MODE_ARG_VBR)) | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
381 pvr->bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR; |
18997 | 382 else if (!strcmp (pvr_param_bitrate_mode, PVR_VIDEO_BITRATE_MODE_ARG_CBR)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
383 pvr->bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR; |
18997 | 384 } |
385 | |
386 /* -pvr vpeak=x */ | |
387 if (pvr_param_bitrate_peak) | |
388 pvr->bitrate_peak = pvr_param_bitrate_peak; | |
389 | |
390 /* -pvr fmt=x */ | |
391 if (pvr_param_stream_type) | |
392 { | |
393 if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_PS)) | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
394 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS; |
18997 | 395 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_TS)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
396 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_TS; |
18997 | 397 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_MPEG1)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
398 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG1_SS; |
18997 | 399 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_DVD)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
400 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; |
18997 | 401 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_VCD)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
402 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG1_VCD; |
18997 | 403 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_SVCD)) |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
404 pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD; |
18997 | 405 } |
406 } | |
407 | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
408 static void |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
409 add_v4l2_ext_control (struct v4l2_ext_control *ctrl, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
410 uint32_t id, int32_t value) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
411 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
412 ctrl->id = id; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
413 ctrl->value = value; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
414 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
415 |
18997 | 416 static int |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
417 set_encoder_settings (struct pvr_t *pvr) |
18997 | 418 { |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
419 struct v4l2_ext_control *ext_ctrl = NULL; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
420 struct v4l2_ext_controls ctrls; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
421 uint32_t count = 0; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
422 |
18997 | 423 if (!pvr) |
424 return -1; | |
425 | |
426 if (pvr->dev_fd < 0) | |
427 return -1; | |
428 | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
429 ext_ctrl = (struct v4l2_ext_control *) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
430 malloc (PVR_MAX_CONTROLS * sizeof (struct v4l2_ext_control)); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
431 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
432 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_VIDEO_ASPECT, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
433 pvr->aspect); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
434 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
435 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
436 pvr->samplerate); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
437 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
438 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_ENCODING, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
439 pvr->layer); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
440 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
441 switch (pvr->layer) |
18997 | 442 { |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
443 case V4L2_MPEG_AUDIO_ENCODING_LAYER_1: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
444 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_L1_BITRATE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
445 pvr->audio_rate); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
446 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
447 case V4L2_MPEG_AUDIO_ENCODING_LAYER_2: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
448 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_L2_BITRATE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
449 pvr->audio_rate); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
450 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
451 case V4L2_MPEG_AUDIO_ENCODING_LAYER_3: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
452 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_L3_BITRATE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
453 pvr->audio_rate); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
454 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
455 default: |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
456 break; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
457 } |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
458 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
459 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_AUDIO_MODE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
460 pvr->audio_mode); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
461 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
462 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_VIDEO_BITRATE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
463 pvr->bitrate); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
464 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
465 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
466 pvr->bitrate_peak); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
467 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
468 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_VIDEO_BITRATE_MODE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
469 pvr->bitrate_mode); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
470 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
471 add_v4l2_ext_control (&ext_ctrl[count++], V4L2_CID_MPEG_STREAM_TYPE, |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
472 pvr->stream_type); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
473 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
474 /* set new encoding settings */ |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
475 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
476 ctrls.count = count; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
477 ctrls.controls = ext_ctrl; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
478 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
479 if (ioctl (pvr->dev_fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0) |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
480 { |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
481 mp_msg (MSGT_OPEN, MSGL_ERR, "%s Error setting MPEG controls (%s).\n", |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
482 LOG_LEVEL_ENCODER, strerror (errno)); |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
483 free (ext_ctrl); |
18997 | 484 return -1; |
485 } | |
486 | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
487 free (ext_ctrl); |
18997 | 488 |
489 return 0; | |
490 } | |
491 | |
492 /* V4L2 layer */ | |
493 | |
494 static void | |
495 parse_v4l2_tv_options (struct pvr_t *pvr) | |
496 { | |
497 if (!pvr) | |
498 return; | |
499 | |
500 if (tv_param_device) | |
501 { | |
502 if (pvr->video_dev) | |
503 free (pvr->video_dev); | |
504 pvr->video_dev = strdup (tv_param_device); | |
505 } | |
506 | |
507 if (tv_param_noaudio) | |
508 pvr->mute = tv_param_noaudio; | |
509 | |
510 if (tv_param_input) | |
511 pvr->input = tv_param_input; | |
512 | |
513 if (tv_param_normid) | |
514 pvr->normid = tv_param_normid; | |
515 | |
516 if (tv_param_brightness) | |
517 pvr->brightness = tv_param_brightness; | |
518 | |
519 if (tv_param_contrast) | |
520 pvr->contrast = tv_param_contrast; | |
521 | |
522 if (tv_param_hue) | |
523 pvr->hue = tv_param_hue; | |
524 | |
525 if (tv_param_saturation) | |
526 pvr->saturation = tv_param_saturation; | |
527 | |
528 if (tv_param_width) | |
529 pvr->width = tv_param_width; | |
530 | |
531 if (tv_param_height) | |
532 pvr->height = tv_param_height; | |
533 | |
534 if (tv_param_freq) | |
535 pvr->freq = strdup (tv_param_freq); | |
536 } | |
537 | |
538 static int | |
539 set_v4l2_settings (struct pvr_t *pvr) | |
540 { | |
541 if (!pvr) | |
542 return -1; | |
543 | |
544 if (pvr->dev_fd < 0) | |
545 return -1; | |
546 | |
547 /* -tv noaudio */ | |
548 if (pvr->mute) | |
549 { | |
550 struct v4l2_control ctrl; | |
551 ctrl.id = V4L2_CID_AUDIO_MUTE; | |
552 ctrl.value = 1; | |
553 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0) | |
554 { | |
555 mp_msg (MSGT_OPEN, MSGL_ERR, | |
556 "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno)); | |
557 return -1; | |
558 } | |
559 } | |
560 | |
561 /* -tv input=x */ | |
562 if (pvr->input != 0) | |
563 { | |
564 if (ioctl (pvr->dev_fd, VIDIOC_S_INPUT, &pvr->input) < 0) | |
565 { | |
566 mp_msg (MSGT_OPEN, MSGL_ERR, | |
567 "%s can't set input (%s)\n", LOG_LEVEL_V4L2, strerror (errno)); | |
568 return -1; | |
569 } | |
570 } | |
571 | |
572 /* -tv normid=x */ | |
573 if (pvr->normid != -1) | |
574 { | |
575 struct v4l2_standard std; | |
576 std.index = pvr->normid; | |
577 | |
578 if (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &std) < 0) | |
579 { | |
580 mp_msg (MSGT_OPEN, MSGL_ERR, | |
581 "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno)); | |
582 return -1; | |
583 } | |
584 | |
585 mp_msg (MSGT_OPEN, MSGL_V, | |
586 "%s set norm to %s\n", LOG_LEVEL_V4L2, std.name); | |
587 | |
588 if (ioctl (pvr->dev_fd, VIDIOC_S_STD, &std.id) < 0) | |
589 { | |
590 mp_msg (MSGT_OPEN, MSGL_ERR, | |
591 "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno)); | |
592 return -1; | |
593 } | |
594 } | |
595 | |
596 /* -tv brightness=x */ | |
597 if (pvr->brightness != 0) | |
598 { | |
599 struct v4l2_control ctrl; | |
600 ctrl.id = V4L2_CID_BRIGHTNESS; | |
601 ctrl.value = pvr->brightness; | |
602 | |
603 if (ctrl.value < 0) | |
604 ctrl.value = 0; | |
605 if (ctrl.value > 255) | |
606 ctrl.value = 255; | |
607 | |
608 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0) | |
609 { | |
610 mp_msg (MSGT_OPEN, MSGL_ERR, | |
611 "%s can't set brightness to %d (%s).\n", | |
612 LOG_LEVEL_V4L2, ctrl.value, strerror (errno)); | |
613 return -1; | |
614 } | |
615 } | |
616 | |
617 /* -tv contrast=x */ | |
618 if (pvr->contrast != 0) | |
619 { | |
620 struct v4l2_control ctrl; | |
621 ctrl.id = V4L2_CID_CONTRAST; | |
622 ctrl.value = pvr->contrast; | |
623 | |
624 if (ctrl.value < 0) | |
625 ctrl.value = 0; | |
626 if (ctrl.value > 127) | |
627 ctrl.value = 127; | |
628 | |
629 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0) | |
630 { | |
631 mp_msg (MSGT_OPEN, MSGL_ERR, | |
632 "%s can't set contrast to %d (%s).\n", | |
633 LOG_LEVEL_V4L2, ctrl.value, strerror (errno)); | |
634 return -1; | |
635 } | |
636 } | |
637 | |
638 /* -tv hue=x */ | |
639 if (pvr->hue != 0) | |
640 { | |
641 struct v4l2_control ctrl; | |
642 ctrl.id = V4L2_CID_HUE; | |
643 ctrl.value = pvr->hue; | |
644 | |
645 if (ctrl.value < -128) | |
646 ctrl.value = -128; | |
647 if (ctrl.value > 127) | |
648 ctrl.value = 127; | |
649 | |
650 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0) | |
651 { | |
652 mp_msg (MSGT_OPEN, MSGL_ERR, | |
653 "%s can't set hue to %d (%s).\n", | |
654 LOG_LEVEL_V4L2, ctrl.value, strerror (errno)); | |
655 return -1; | |
656 } | |
657 } | |
658 | |
659 /* -tv saturation=x */ | |
660 if (pvr->saturation != 0) | |
661 { | |
662 struct v4l2_control ctrl; | |
663 ctrl.id = V4L2_CID_SATURATION; | |
664 ctrl.value = pvr->saturation; | |
665 | |
666 if (ctrl.value < 0) | |
667 ctrl.value = 0; | |
668 if (ctrl.value > 127) | |
669 ctrl.value = 127; | |
670 | |
671 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0) | |
672 { | |
673 mp_msg (MSGT_OPEN, MSGL_ERR, | |
674 "%s can't set saturation to %d (%s).\n", | |
675 LOG_LEVEL_V4L2, ctrl.value, strerror (errno)); | |
676 return -1; | |
677 } | |
678 } | |
679 | |
680 /* -tv width=x:height=y */ | |
681 if (pvr->width && pvr->height) | |
682 { | |
683 struct v4l2_format vfmt; | |
684 vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |
685 vfmt.fmt.pix.width = pvr->width; | |
686 vfmt.fmt.pix.height = pvr->height; | |
687 | |
688 if (ioctl (pvr->dev_fd, VIDIOC_S_FMT, &vfmt) < 0) | |
689 { | |
690 mp_msg (MSGT_OPEN, MSGL_ERR, | |
691 "%s can't set resolution to %dx%d (%s).\n", | |
692 LOG_LEVEL_V4L2, pvr->width, pvr->height, strerror (errno)); | |
693 return -1; | |
694 } | |
695 } | |
696 | |
697 /* -tv freq=x */ | |
698 if (pvr->freq) | |
699 { | |
700 struct v4l2_frequency vf; | |
701 vf.tuner = 0; | |
702 vf.type = 0; | |
703 vf.frequency = strtol (pvr->freq, 0L, 0); | |
704 mp_msg (MSGT_OPEN, MSGL_INFO, | |
705 "%s setting frequency to %d\n", LOG_LEVEL_V4L2, vf.frequency); | |
706 | |
707 if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0) | |
708 { | |
709 mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set frequency (%s).\n", | |
710 LOG_LEVEL_V4L2, strerror (errno)); | |
711 return -1; | |
712 } | |
713 } | |
714 | |
715 return 0; | |
716 } | |
717 | |
718 static int | |
719 v4l2_list_capabilities (struct pvr_t *pvr) | |
720 { | |
721 struct v4l2_audio vaudio; | |
722 struct v4l2_standard vs; | |
723 struct v4l2_input vin; | |
724 int err = 0; | |
725 | |
726 if (!pvr) | |
727 return -1; | |
728 | |
729 if (pvr->dev_fd < 0) | |
730 return -1; | |
731 | |
732 /* list available video inputs */ | |
733 vin.index = 0; | |
734 err = 1; | |
735 mp_msg (MSGT_OPEN, MSGL_INFO, | |
736 "%s Available video inputs: ", LOG_LEVEL_V4L2); | |
737 while (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) >= 0) | |
738 { | |
739 err = 0; | |
740 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vin.index, vin.name); | |
741 vin.index++; | |
742 } | |
743 if (err) | |
744 { | |
745 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n"); | |
746 return -1; | |
747 } | |
748 else | |
749 mp_msg (MSGT_OPEN, MSGL_INFO, "\n"); | |
750 | |
751 /* list available audio inputs */ | |
752 vaudio.index = 0; | |
753 err = 1; | |
754 mp_msg (MSGT_OPEN, MSGL_INFO, | |
755 "%s Available audio inputs: ", LOG_LEVEL_V4L2); | |
756 while (ioctl (pvr->dev_fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0) | |
757 { | |
758 err = 0; | |
759 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vaudio.index, vaudio.name); | |
760 vaudio.index++; | |
761 } | |
762 if (err) | |
763 { | |
764 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n"); | |
765 return -1; | |
766 } | |
767 else | |
768 mp_msg (MSGT_OPEN, MSGL_INFO, "\n"); | |
769 | |
770 /* list available norms */ | |
771 vs.index = 0; | |
772 mp_msg (MSGT_OPEN, MSGL_INFO, "%s Available norms: ", LOG_LEVEL_V4L2); | |
773 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0) | |
774 { | |
775 err = 0; | |
776 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vs.index, vs.name); | |
777 vs.index++; | |
778 } | |
779 if (err) | |
780 { | |
781 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n"); | |
782 return -1; | |
783 } | |
784 else | |
785 mp_msg (MSGT_OPEN, MSGL_INFO, "\n"); | |
786 | |
787 return 0; | |
788 } | |
789 | |
790 static int | |
791 v4l2_display_settings (struct pvr_t *pvr) | |
792 { | |
793 struct v4l2_audio vaudio; | |
794 struct v4l2_standard vs; | |
795 struct v4l2_input vin; | |
796 v4l2_std_id std; | |
797 int input; | |
798 | |
799 if (!pvr) | |
800 return -1; | |
801 | |
802 if (pvr->dev_fd < 0) | |
803 return -1; | |
804 | |
805 /* get current video input */ | |
806 if (ioctl (pvr->dev_fd, VIDIOC_G_INPUT, &input) == 0) | |
807 { | |
808 vin.index = input; | |
809 if (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) < 0) | |
810 { | |
811 mp_msg (MSGT_OPEN, MSGL_ERR, | |
812 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno)); | |
813 return -1; | |
814 } | |
815 else | |
816 mp_msg (MSGT_OPEN, MSGL_INFO, | |
817 "%s Video input: %s\n", LOG_LEVEL_V4L2, vin.name); | |
818 } | |
819 else | |
820 { | |
821 mp_msg (MSGT_OPEN, MSGL_ERR, | |
822 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno)); | |
823 return -1; | |
824 } | |
825 | |
826 /* get current audio input */ | |
827 if (ioctl (pvr->dev_fd, VIDIOC_G_AUDIO, &vaudio) == 0) | |
828 { | |
19294 | 829 mp_msg (MSGT_OPEN, MSGL_INFO, |
830 "%s Audio input: %s\n", LOG_LEVEL_V4L2, vaudio.name); | |
18997 | 831 } |
832 else | |
833 { | |
834 mp_msg (MSGT_OPEN, MSGL_ERR, | |
835 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno)); | |
836 return -1; | |
837 } | |
838 | |
839 /* get current video format */ | |
840 if (ioctl (pvr->dev_fd, VIDIOC_G_STD, &std) == 0) | |
841 { | |
842 vs.index = 0; | |
843 | |
844 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0) | |
845 { | |
846 if (vs.id == std) | |
847 { | |
848 mp_msg (MSGT_OPEN, MSGL_INFO, | |
849 "%s Norm: %s.\n", LOG_LEVEL_V4L2, vs.name); | |
850 break; | |
851 } | |
852 vs.index++; | |
853 } | |
854 } | |
855 else | |
856 { | |
857 mp_msg (MSGT_OPEN, MSGL_ERR, | |
858 "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno)); | |
859 return -1; | |
860 } | |
861 | |
862 return 0; | |
863 } | |
864 | |
865 /* stream layer */ | |
866 | |
867 static void | |
868 pvr_stream_close (stream_t *stream) | |
869 { | |
870 struct pvr_t *pvr; | |
871 | |
872 if (!stream) | |
873 return; | |
874 | |
875 pvr = (struct pvr_t *) stream->priv; | |
876 pvr_uninit (pvr); | |
877 } | |
878 | |
879 static int | |
880 pvr_stream_read (stream_t *stream, char *buffer, int size) | |
881 { | |
882 struct pollfd pfds[1]; | |
883 struct pvr_t *pvr; | |
884 int rk, fd, pos; | |
885 | |
886 if (!stream || !buffer) | |
887 return 0; | |
888 | |
889 pvr = (struct pvr_t *) stream->priv; | |
890 fd = pvr->dev_fd; | |
891 pos = 0; | |
892 | |
893 if (fd < 0) | |
894 return 0; | |
895 | |
896 while (pos < size) | |
897 { | |
898 pfds[0].fd = fd; | |
899 pfds[0].events = POLLIN | POLLPRI; | |
900 | |
901 rk = size - pos; | |
902 | |
903 if (poll (pfds, 1, 500) <= 0) | |
904 { | |
905 mp_msg (MSGT_OPEN, MSGL_ERR, | |
906 "%s failed with errno %d when reading %d bytes\n", | |
907 LOG_LEVEL_PVR, errno, size-pos); | |
908 break; | |
909 } | |
910 | |
911 rk = read (fd, &buffer[pos], rk); | |
912 if (rk > 0) | |
913 { | |
914 pos += rk; | |
915 mp_msg (MSGT_OPEN, MSGL_DBG3, | |
916 "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos); | |
917 } | |
918 } | |
919 | |
920 if (!pos) | |
921 mp_msg (MSGT_OPEN, MSGL_ERR, "%s read %d bytes\n", LOG_LEVEL_PVR, pos); | |
922 | |
923 return pos; | |
924 } | |
925 | |
926 static int | |
927 pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format) | |
928 { | |
929 struct v4l2_capability vcap; | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
930 struct v4l2_ext_controls ctrls; |
18997 | 931 struct pvr_t *pvr = NULL; |
932 | |
933 if (mode != STREAM_READ) | |
934 return STREAM_UNSUPORTED; | |
935 | |
936 pvr = pvr_init (); | |
937 | |
938 parse_v4l2_tv_options (pvr); | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
939 parse_encoder_options (pvr); |
18997 | 940 |
941 /* open device */ | |
942 pvr->dev_fd = open (pvr->video_dev, O_RDWR); | |
943 mp_msg (MSGT_OPEN, MSGL_INFO, | |
944 "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev); | |
945 if (pvr->dev_fd == -1) | |
946 { | |
947 mp_msg (MSGT_OPEN, MSGL_ERR, | |
948 "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev); | |
949 pvr_uninit (pvr); | |
950 return STREAM_ERROR; | |
951 } | |
952 | |
953 /* query capabilities (i.e test V4L2 support) */ | |
954 if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0) | |
955 { | |
956 mp_msg (MSGT_OPEN, MSGL_ERR, | |
957 "%s device is not V4L2 compliant (%s).\n", | |
958 LOG_LEVEL_PVR, strerror (errno)); | |
959 pvr_uninit (pvr); | |
960 return STREAM_ERROR; | |
961 } | |
962 else | |
963 mp_msg (MSGT_OPEN, MSGL_INFO, | |
964 "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card); | |
965 | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
966 /* check for a valid V4L2 capture device */ |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
967 if (!(vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) |
18997 | 968 { |
969 mp_msg (MSGT_OPEN, MSGL_ERR, | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
970 "%s device is not a valid V4L2 capture device.\n", |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
971 LOG_LEVEL_PVR); |
18997 | 972 pvr_uninit (pvr); |
973 return STREAM_ERROR; | |
974 } | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
975 |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
976 /* check for device hardware MPEG encoding capability */ |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
977 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
978 ctrls.count = 0; |
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
979 ctrls.controls = NULL; |
18997 | 980 |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
981 if (ioctl (pvr->dev_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0) |
18997 | 982 { |
983 mp_msg (MSGT_OPEN, MSGL_ERR, | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
984 "%s device do not support MPEG input.\n", LOG_LEVEL_ENCODER); |
18997 | 985 return STREAM_ERROR; |
986 } | |
987 | |
988 /* list V4L2 capabilities */ | |
989 if (v4l2_list_capabilities (pvr) == -1) | |
990 { | |
991 mp_msg (MSGT_OPEN, MSGL_ERR, | |
992 "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR); | |
993 pvr_uninit (pvr); | |
994 return STREAM_ERROR; | |
995 } | |
996 | |
997 /* apply V4L2 settings */ | |
998 if (set_v4l2_settings (pvr) == -1) | |
999 { | |
1000 mp_msg (MSGT_OPEN, MSGL_ERR, | |
1001 "%s can't set v4l2 settings\n", LOG_LEVEL_PVR); | |
1002 pvr_uninit (pvr); | |
1003 return STREAM_ERROR; | |
1004 } | |
1005 | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
1006 /* apply encoder settings */ |
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
1007 if (set_encoder_settings (pvr) == -1) |
18997 | 1008 { |
1009 mp_msg (MSGT_OPEN, MSGL_ERR, | |
19976
281ac13bf72d
cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents:
19617
diff
changeset
|
1010 "%s can't set encoder settings\n", LOG_LEVEL_PVR); |
18997 | 1011 pvr_uninit (pvr); |
1012 return STREAM_ERROR; | |
1013 } | |
1014 | |
1015 /* display current V4L2 settings */ | |
1016 if (v4l2_display_settings (pvr) == -1) | |
1017 { | |
1018 mp_msg (MSGT_OPEN, MSGL_ERR, | |
1019 "%s can't get v4l2 settings\n", LOG_LEVEL_PVR); | |
1020 pvr_uninit (pvr); | |
1021 return STREAM_ERROR; | |
1022 } | |
1023 | |
1024 stream->priv = pvr; | |
1025 stream->type = STREAMTYPE_PVR; | |
1026 stream->fill_buffer = pvr_stream_read; | |
1027 stream->close = pvr_stream_close; | |
1028 | |
1029 return STREAM_OK; | |
1030 } | |
1031 | |
1032 stream_info_t stream_info_pvr = { | |
19992
be7b8a83649c
removed ivtv driver dependancy in favor of native V4L2 MPEG API (requires Linux 2.6.18 and above)
ben
parents:
19976
diff
changeset
|
1033 "V4L2 MPEG Input (a.k.a PVR)", |
18997 | 1034 "pvr", |
1035 "Benjamin Zores", | |
1036 "", | |
1037 pvr_stream_open, | |
1038 { "pvr", NULL }, | |
1039 NULL, | |
1040 1 | |
1041 }; |