annotate stream/stream_pvr.c @ 23139:10425310d2da

cosmetics: Replace manual tab indentation by \n\t as in the rest of the file.
author diego
date Sat, 28 Apr 2007 11:41:11 +0000
parents be7b8a83649c
children 9a4634744b41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18997
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1 /*
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
5 * See http://ivtvdriver.org/index.php/Main_Page for more details on the
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
6 * cards supported by the ivtv driver.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
7 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
11 * (at your option) any later version.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
12 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
16 * GNU General Public License for more details.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
17 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
19 * along with this program; if not, write to the Free Software Foundation,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
21 */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
22
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
23 #include "config.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
24
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
25 #include <stdio.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
26 #include <stdlib.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
27 #include <unistd.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
28 #include <string.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
29 #include <ctype.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
30 #include <sys/time.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
31 #include <errno.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
32 #include <sys/ioctl.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
33 #include <sys/fcntl.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
34 #include <inttypes.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
37 #include <linux/videodev2.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
38
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
39 #include "mp_msg.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
40 #include "help_mp.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
41
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
42 #include "stream.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
43 #include "tv.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
44
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
47
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
48 /* logging mechanisms */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
49 #define LOG_LEVEL_PVR "[pvr]"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
52
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
53 /* audio codec mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
54 #define PVR_AUDIO_MODE_ARG_STEREO "stereo"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
55 #define PVR_AUDIO_MODE_ARG_JOINT_STEREO "joint_stereo"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
56 #define PVR_AUDIO_MODE_ARG_DUAL "dual"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
57 #define PVR_AUDIO_MODE_ARG_MONO "mono"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
58
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
59 /* video codec bitrate mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
60 #define PVR_VIDEO_BITRATE_MODE_ARG_VBR "vbr"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
61 #define PVR_VIDEO_BITRATE_MODE_ARG_CBR "cbr"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
62
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
63 /* video codec stream type */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
64 #define PVR_VIDEO_STREAM_TYPE_PS "ps"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
65 #define PVR_VIDEO_STREAM_TYPE_TS "ts"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
66 #define PVR_VIDEO_STREAM_TYPE_MPEG1 "mpeg1"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
67 #define PVR_VIDEO_STREAM_TYPE_DVD "dvd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
68 #define PVR_VIDEO_STREAM_TYPE_VCD "vcd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
69 #define PVR_VIDEO_STREAM_TYPE_SVCD "svcd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
70
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
71 /* command line arguments */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
72 int pvr_param_aspect_ratio = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
73 int pvr_param_sample_rate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
74 int pvr_param_audio_layer = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
75 int pvr_param_audio_bitrate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
76 char *pvr_param_audio_mode = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
77 int pvr_param_bitrate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
78 char *pvr_param_bitrate_mode = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
79 int pvr_param_bitrate_peak = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
80 char *pvr_param_stream_type = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
81
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
82 struct pvr_t {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
83 int dev_fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
84 char *video_dev;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
85
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
86 /* v4l2 params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
87 int mute;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
88 int input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
89 int normid;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
90 int brightness;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
91 int contrast;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
92 int hue;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
93 int saturation;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
94 int width;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
95 int height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
96 char *freq;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
97
19976
281ac13bf72d cosmetic renames because pvr support will soon be less ivtv driver dependant
ben
parents: 19617
diff changeset
98 /* encoder params */
18997
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
99 int aspect;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
100 int samplerate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
101 int layer;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
102 int audio_rate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
103 int audio_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
104 int bitrate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
105 int bitrate_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
106 int bitrate_peak;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
107 int stream_type;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
108 };
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
109
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
110 static struct pvr_t *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
111 pvr_init (void)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
112 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
113 struct pvr_t *pvr = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
114
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
115 pvr = malloc (sizeof (struct pvr_t));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
116 pvr->dev_fd = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
117 pvr->video_dev = strdup (PVR_DEFAULT_DEVICE);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
118
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
119 /* v4l2 params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
120 pvr->mute = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
121 pvr->input = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
122 pvr->normid = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
123 pvr->brightness = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
124 pvr->contrast = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
125 pvr->hue = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
126 pvr->saturation = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
127 pvr->width = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
128 pvr->height = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
129 pvr->freq = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
145
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
146 return pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
147 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
148
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
149 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
150 pvr_uninit (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
151 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
152 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
153 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
154
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
155 /* close device */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
156 if (pvr->dev_fd)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
157 close (pvr->dev_fd);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
158
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
159 if (pvr->video_dev)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
160 free (pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
161 if (pvr->freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
162 free (pvr->freq);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
163 free (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
164 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
165
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
168 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
169 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
170 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
171
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
174 pvr->aspect = pvr_param_aspect_ratio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
175
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
176 /* -pvr arate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
177 if (pvr_param_sample_rate != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
178 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
179 switch (pvr_param_sample_rate)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
180 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
183 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
186 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
189 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
190 default:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
191 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
192 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
193 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
194
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
195 /* -pvr alayer=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
202
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
203 /* -pvr abitrate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
204 if (pvr_param_audio_bitrate != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
357 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
358 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
359
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
360 /* -pvr amode=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
361 if (pvr_param_audio_mode)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
362 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
371 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
372
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
373 /* -pvr vbitrate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
374 if (pvr_param_bitrate)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
375 pvr->bitrate = pvr_param_bitrate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
376
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
377 /* -pvr vmode=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
378 if (pvr_param_bitrate_mode)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
379 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
384 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
385
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
386 /* -pvr vpeak=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
387 if (pvr_param_bitrate_peak)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
388 pvr->bitrate_peak = pvr_param_bitrate_peak;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
389
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
390 /* -pvr fmt=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
391 if (pvr_param_stream_type)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
392 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
405 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
406 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
423 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
424 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
425
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
426 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
427 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
484 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
485 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
488
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
489 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
490 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
491
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
492 /* V4L2 layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
493
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
494 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
495 parse_v4l2_tv_options (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
496 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
497 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
498 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
499
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
500 if (tv_param_device)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
501 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
502 if (pvr->video_dev)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
503 free (pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
504 pvr->video_dev = strdup (tv_param_device);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
505 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
506
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
507 if (tv_param_noaudio)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
508 pvr->mute = tv_param_noaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
509
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
510 if (tv_param_input)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
511 pvr->input = tv_param_input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
512
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
513 if (tv_param_normid)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
514 pvr->normid = tv_param_normid;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
515
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
516 if (tv_param_brightness)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
517 pvr->brightness = tv_param_brightness;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
518
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
519 if (tv_param_contrast)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
520 pvr->contrast = tv_param_contrast;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
521
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
522 if (tv_param_hue)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
523 pvr->hue = tv_param_hue;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
524
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
525 if (tv_param_saturation)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
526 pvr->saturation = tv_param_saturation;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
527
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
528 if (tv_param_width)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
529 pvr->width = tv_param_width;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
530
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
531 if (tv_param_height)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
532 pvr->height = tv_param_height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
533
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
534 if (tv_param_freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
535 pvr->freq = strdup (tv_param_freq);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
536 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
537
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
538 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
539 set_v4l2_settings (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
540 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
541 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
542 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
543
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
544 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
545 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
546
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
547 /* -tv noaudio */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
548 if (pvr->mute)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
549 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
550 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
551 ctrl.id = V4L2_CID_AUDIO_MUTE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
552 ctrl.value = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
553 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
554 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
555 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
556 "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
557 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
558 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
559 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
560
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
561 /* -tv input=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
562 if (pvr->input != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
563 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
564 if (ioctl (pvr->dev_fd, VIDIOC_S_INPUT, &pvr->input) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
565 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
566 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
567 "%s can't set input (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
568 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
569 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
570 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
571
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
572 /* -tv normid=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
573 if (pvr->normid != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
574 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
575 struct v4l2_standard std;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
576 std.index = pvr->normid;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
577
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
578 if (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &std) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
579 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
580 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
581 "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
582 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
583 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
584
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
585 mp_msg (MSGT_OPEN, MSGL_V,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
586 "%s set norm to %s\n", LOG_LEVEL_V4L2, std.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
587
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
588 if (ioctl (pvr->dev_fd, VIDIOC_S_STD, &std.id) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
589 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
590 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
591 "%s can't set norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
592 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
593 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
594 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
595
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
596 /* -tv brightness=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
597 if (pvr->brightness != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
598 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
599 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
600 ctrl.id = V4L2_CID_BRIGHTNESS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
601 ctrl.value = pvr->brightness;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
602
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
603 if (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
604 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
605 if (ctrl.value > 255)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
606 ctrl.value = 255;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
607
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
608 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
609 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
610 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
611 "%s can't set brightness to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
612 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
613 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
614 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
615 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
616
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
617 /* -tv contrast=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
618 if (pvr->contrast != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
619 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
620 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
621 ctrl.id = V4L2_CID_CONTRAST;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
622 ctrl.value = pvr->contrast;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
623
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
624 if (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
625 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
626 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
627 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
628
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
629 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
630 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
631 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
632 "%s can't set contrast to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
633 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
634 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
635 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
636 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
637
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
638 /* -tv hue=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
639 if (pvr->hue != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
640 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
641 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
642 ctrl.id = V4L2_CID_HUE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
643 ctrl.value = pvr->hue;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
644
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
645 if (ctrl.value < -128)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
646 ctrl.value = -128;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
647 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
648 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
649
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
650 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
651 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
652 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
653 "%s can't set hue to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
654 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
655 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
656 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
657 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
658
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
659 /* -tv saturation=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
660 if (pvr->saturation != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
661 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
662 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
663 ctrl.id = V4L2_CID_SATURATION;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
664 ctrl.value = pvr->saturation;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
665
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
666 if (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
667 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
668 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
669 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
670
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
671 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
672 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
673 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
674 "%s can't set saturation to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
675 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
676 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
677 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
678 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
679
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
680 /* -tv width=x:height=y */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
681 if (pvr->width && pvr->height)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
682 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
683 struct v4l2_format vfmt;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
684 vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
685 vfmt.fmt.pix.width = pvr->width;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
686 vfmt.fmt.pix.height = pvr->height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
687
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
688 if (ioctl (pvr->dev_fd, VIDIOC_S_FMT, &vfmt) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
689 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
690 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
691 "%s can't set resolution to %dx%d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
692 LOG_LEVEL_V4L2, pvr->width, pvr->height, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
693 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
694 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
695 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
696
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
697 /* -tv freq=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
698 if (pvr->freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
699 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
700 struct v4l2_frequency vf;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
701 vf.tuner = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
702 vf.type = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
703 vf.frequency = strtol (pvr->freq, 0L, 0);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
704 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
705 "%s setting frequency to %d\n", LOG_LEVEL_V4L2, vf.frequency);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
706
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
707 if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
708 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
709 mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set frequency (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
710 LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
711 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
712 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
713 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
714
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
715 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
716 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
717
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
718 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
719 v4l2_list_capabilities (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
720 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
721 struct v4l2_audio vaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
722 struct v4l2_standard vs;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
723 struct v4l2_input vin;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
724 int err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
725
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
726 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
727 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
728
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
729 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
730 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
731
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
732 /* list available video inputs */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
733 vin.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
734 err = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
735 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
736 "%s Available video inputs: ", LOG_LEVEL_V4L2);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
737 while (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
738 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
739 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
740 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vin.index, vin.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
741 vin.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
742 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
743 if (err)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
744 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
745 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
746 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
747 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
748 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
749 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
750
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
751 /* list available audio inputs */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
752 vaudio.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
753 err = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
754 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
755 "%s Available audio inputs: ", LOG_LEVEL_V4L2);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
756 while (ioctl (pvr->dev_fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
757 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
758 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
759 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vaudio.index, vaudio.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
760 vaudio.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
761 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
762 if (err)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
763 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
764 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
765 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
766 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
767 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
768 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
769
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
770 /* list available norms */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
771 vs.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
772 mp_msg (MSGT_OPEN, MSGL_INFO, "%s Available norms: ", LOG_LEVEL_V4L2);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
773 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
774 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
775 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
776 mp_msg (MSGT_OPEN, MSGL_INFO, "'#%d, %s' ", vs.index, vs.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
777 vs.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
778 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
779 if (err)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
780 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
781 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
782 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
783 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
784 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
785 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
786
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
787 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
788 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
789
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
790 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
791 v4l2_display_settings (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
792 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
793 struct v4l2_audio vaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
794 struct v4l2_standard vs;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
795 struct v4l2_input vin;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
796 v4l2_std_id std;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
797 int input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
798
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
799 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
800 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
801
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
802 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
803 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
804
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
805 /* get current video input */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
806 if (ioctl (pvr->dev_fd, VIDIOC_G_INPUT, &input) == 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
807 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
808 vin.index = input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
809 if (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
810 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
811 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
812 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
813 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
814 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
815 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
816 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
817 "%s Video input: %s\n", LOG_LEVEL_V4L2, vin.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
818 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
819 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
820 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
821 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
822 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
823 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
824 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
825
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
826 /* get current audio input */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
827 if (ioctl (pvr->dev_fd, VIDIOC_G_AUDIO, &vaudio) == 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
828 {
19294
6e6b33b0b57e correctly report audio input
ben
parents: 19271
diff changeset
829 mp_msg (MSGT_OPEN, MSGL_INFO,
6e6b33b0b57e correctly report audio input
ben
parents: 19271
diff changeset
830 "%s Audio input: %s\n", LOG_LEVEL_V4L2, vaudio.name);
18997
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
831 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
832 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
833 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
834 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
835 "%s can't get input (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
836 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
837 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
838
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
839 /* get current video format */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
840 if (ioctl (pvr->dev_fd, VIDIOC_G_STD, &std) == 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
841 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
842 vs.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
843
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
844 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
845 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
846 if (vs.id == std)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
847 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
848 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
849 "%s Norm: %s.\n", LOG_LEVEL_V4L2, vs.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
850 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
851 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
852 vs.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
853 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
854 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
855 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
856 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
857 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
858 "%s can't get norm (%s)\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
859 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
860 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
861
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
862 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
863 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
864
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
865 /* stream layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
866
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
867 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
868 pvr_stream_close (stream_t *stream)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
869 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
870 struct pvr_t *pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
871
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
872 if (!stream)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
873 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
874
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
875 pvr = (struct pvr_t *) stream->priv;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
876 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
877 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
878
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
879 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
880 pvr_stream_read (stream_t *stream, char *buffer, int size)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
881 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
882 struct pollfd pfds[1];
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
883 struct pvr_t *pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
884 int rk, fd, pos;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
885
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
886 if (!stream || !buffer)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
887 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
888
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
889 pvr = (struct pvr_t *) stream->priv;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
890 fd = pvr->dev_fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
891 pos = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
892
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
893 if (fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
894 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
895
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
896 while (pos < size)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
897 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
898 pfds[0].fd = fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
899 pfds[0].events = POLLIN | POLLPRI;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
900
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
901 rk = size - pos;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
902
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
903 if (poll (pfds, 1, 500) <= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
904 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
905 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
906 "%s failed with errno %d when reading %d bytes\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
907 LOG_LEVEL_PVR, errno, size-pos);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
908 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
909 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
910
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
911 rk = read (fd, &buffer[pos], rk);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
912 if (rk > 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
913 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
914 pos += rk;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
915 mp_msg (MSGT_OPEN, MSGL_DBG3,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
916 "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
917 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
918 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
919
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
920 if (!pos)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
921 mp_msg (MSGT_OPEN, MSGL_ERR, "%s read %d bytes\n", LOG_LEVEL_PVR, pos);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
922
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
923 return pos;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
924 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
925
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
926 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
927 pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
928 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
931 struct pvr_t *pvr = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
932
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
933 if (mode != STREAM_READ)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
934 return STREAM_UNSUPORTED;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
935
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
936 pvr = pvr_init ();
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
937
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
940
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
941 /* open device */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
942 pvr->dev_fd = open (pvr->video_dev, O_RDWR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
943 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
944 "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
945 if (pvr->dev_fd == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
946 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
947 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
948 "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
949 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
950 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
951 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
952
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
953 /* query capabilities (i.e test V4L2 support) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
954 if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
955 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
956 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
957 "%s device is not V4L2 compliant (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
958 LOG_LEVEL_PVR, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
959 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
960 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
961 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
962 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
963 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
964 "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
968 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
972 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
973 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
982 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
985 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
986 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
987
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
988 /* list V4L2 capabilities */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
989 if (v4l2_list_capabilities (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
990 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
991 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
992 "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
993 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
994 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
995 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
996
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
997 /* apply V4L2 settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
998 if (set_v4l2_settings (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
999 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1000 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1001 "%s can't set v4l2 settings\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1002 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1003 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1004 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1008 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1011 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1012 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1013 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1014
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1015 /* display current V4L2 settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1016 if (v4l2_display_settings (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1017 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1018 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1019 "%s can't get v4l2 settings\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1020 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1021 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1022 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1023
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1024 stream->priv = pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1025 stream->type = STREAMTYPE_PVR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1026 stream->fill_buffer = pvr_stream_read;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1027 stream->close = pvr_stream_close;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1028
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1029 return STREAM_OK;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1030 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1031
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1034 "pvr",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1035 "Benjamin Zores",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1036 "",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1037 pvr_stream_open,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1038 { "pvr", NULL },
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1039 NULL,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1040 1
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1041 };