annotate libmpdemux/stream_pvr.c @ 19039:b6274641cb17

r19039: Use only one global config.mak file.
author kraymer
date Wed, 12 Jul 2006 19:37:45 +0000
parents 73b8f5ff772d
children
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
3 * Stream layer for WinTV PVR-150/250/350 (a.k.a IVTV) PVR cards.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
4 * 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
5 * cards supported by the ivtv driver.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
6 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
7 * 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
8 * 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
9 * the Free Software Foundation; either version 2 of the License, or
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
10 * (at your option) any later version.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
11 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
12 * 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
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
15 * GNU General Public License for more details.
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
16 *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
17 * 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
18 * 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
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
20 */
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 #include "config.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
23
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
24 #include <stdio.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
25 #include <stdlib.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
26 #include <unistd.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
27 #include <string.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
28 #include <ctype.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
29 #include <sys/time.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
30 #include <errno.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
31 #include <sys/ioctl.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
32 #include <sys/fcntl.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
33 #include <inttypes.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
34 #include <sys/poll.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
35 #include <linux/videodev2.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
36 #include <linux/ivtv.h>
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
37
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
38 #include "mp_msg.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
39 #include "help_mp.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
40
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
41 #include "stream.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
42 #include "tv.h"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
43
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
44 #define PVR_DEFAULT_DEVICE "/dev/video0"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
45
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
46 /* logging mechanisms */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
47 #define LOG_LEVEL_PVR "[pvr]"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
48 #define LOG_LEVEL_V4L2 "[v4l2]"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
49 #define LOG_LEVEL_IVTV "[ivtv]"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
50
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
51 /* IVTV driver settings (see http://ivtvdriver.org/index.php/Ivtvctl ) */
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 /* codec aspect ratio (1:1, 4:3, 16:9, 2.21:1) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
54 #define PVR_ASPECT_RATIO_1_1 1
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
55 #define PVR_ASPECT_RATIO_4_3 2
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
56 #define PVR_ASPECT_RATIO_16_9 3
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
57 #define PVR_ASPECT_RATIO_2_21_1 4
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 /* audio codec sample rate (32KHz, CD 44.1 KHz, AC97 48 KHz) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
60 #define PVR_AUDIO_SAMPLE_RATE_44_1_KHZ 0x0000
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
61 #define PVR_AUDIO_SAMPLE_RATE_48_KHZ 0x0001
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
62 #define PVR_AUDIO_SAMPLE_RATE_32_KHZ 0x0002
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
63
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
64 /* audio codec layer (1 or 2) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
65 #define PVR_AUDIO_LAYER_1 0x0004
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
66 #define PVR_AUDIO_LAYER_2 0x0008
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
67
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
68 /* audio codec bitrate */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
69 #define PVR_AUDIO_BITRATE_32 0x0010
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
70 #define PVR_AUDIO_BITRATE_L1_64 0x0020
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
71 #define PVR_AUDIO_BITRATE_L1_96 0x0030
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
72 #define PVR_AUDIO_BITRATE_L1_128 0x0040
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
73 #define PVR_AUDIO_BITRATE_L1_160 0x0050
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
74 #define PVR_AUDIO_BITRATE_L1_192 0x0060
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
75 #define PVR_AUDIO_BITRATE_L1_224 0x0070
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
76 #define PVR_AUDIO_BITRATE_L1_256 0x0080
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
77 #define PVR_AUDIO_BITRATE_L1_288 0x0090
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
78 #define PVR_AUDIO_BITRATE_L1_320 0x00A0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
79 #define PVR_AUDIO_BITRATE_L1_352 0x00B0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
80 #define PVR_AUDIO_BITRATE_L1_384 0x00C0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
81 #define PVR_AUDIO_BITRATE_L1_416 0x00D0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
82 #define PVR_AUDIO_BITRATE_L1_448 0x00E0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
83 #define PVR_AUDIO_BITRATE_L2_48 0x0020
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
84 #define PVR_AUDIO_BITRATE_L2_56 0x0030
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
85 #define PVR_AUDIO_BITRATE_L2_64 0x0040
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
86 #define PVR_AUDIO_BITRATE_L2_80 0x0050
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
87 #define PVR_AUDIO_BITRATE_L2_96 0x0060
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
88 #define PVR_AUDIO_BITRATE_L2_112 0x0070
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
89 #define PVR_AUDIO_BITRATE_L2_128 0x0080
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
90 #define PVR_AUDIO_BITRATE_L2_160 0x0090
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
91 #define PVR_AUDIO_BITRATE_L2_192 0x00A0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
92 #define PVR_AUDIO_BITRATE_L2_224 0x00B0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
93 #define PVR_AUDIO_BITRATE_L2_256 0x00C0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
94 #define PVR_AUDIO_BITRATE_L2_320 0x00D0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
95 #define PVR_AUDIO_BITRATE_L2_384 0x00E0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
96
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
97 /* audio codec mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
98 #define PVR_AUDIO_MODE_ARG_STEREO "stereo"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
99 #define PVR_AUDIO_MODE_ARG_JOINT_STEREO "joint_stereo"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
100 #define PVR_AUDIO_MODE_ARG_DUAL "dual"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
101 #define PVR_AUDIO_MODE_ARG_MONO "mono"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
102 #define PVR_AUDIO_MODE_STEREO 0x0000
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
103 #define PVR_AUDIO_MODE_JOINT_STEREO 0x0100
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
104 #define PVR_AUDIO_MODE_DUAL 0x0200
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
105 #define PVR_AUDIO_MODE_MONO 0x0300
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
106
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
107 /* video codec bitrate mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
108 #define PVR_VIDEO_BITRATE_MODE_ARG_VBR "vbr"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
109 #define PVR_VIDEO_BITRATE_MODE_ARG_CBR "cbr"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
110 #define PVR_VIDEO_BITRATE_MODE_VBR 0
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
111 #define PVR_VIDEO_BITRATE_MODE_CBR 1
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 /* video codec stream type */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
114 #define PVR_VIDEO_STREAM_TYPE_PS "ps"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
115 #define PVR_VIDEO_STREAM_TYPE_TS "ts"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
116 #define PVR_VIDEO_STREAM_TYPE_MPEG1 "mpeg1"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
117 #define PVR_VIDEO_STREAM_TYPE_DVD "dvd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
118 #define PVR_VIDEO_STREAM_TYPE_VCD "vcd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
119 #define PVR_VIDEO_STREAM_TYPE_SVCD "svcd"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
120 #define PVR_VIDEO_STREAM_TYPE_DVD_S1 "dvds1"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
121 #define PVR_VIDEO_STREAM_TYPE_DVD_S2 "dvds2"
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
122
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
123 /* command line arguments */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
124 int pvr_param_aspect_ratio = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
125 int pvr_param_sample_rate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
126 int pvr_param_audio_layer = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
127 int pvr_param_audio_bitrate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
128 char *pvr_param_audio_mode = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
129 int pvr_param_bitrate = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
130 char *pvr_param_bitrate_mode = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
131 int pvr_param_bitrate_peak = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
132 char *pvr_param_stream_type = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
133
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
134 struct pvr_t {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
135 int dev_fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
136 char *video_dev;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
137
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
138 /* v4l2 params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
139 int mute;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
140 int input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
141 int normid;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
142 int brightness;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
143 int contrast;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
144 int hue;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
145 int saturation;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
146 int width;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
147 int height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
148 char *freq;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
149
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
150 /* ivtv params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
151 int aspect;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
152 int samplerate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
153 int layer;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
154 int audio_rate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
155 int audio_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
156 int bitrate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
157 int bitrate_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
158 int bitrate_peak;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
159 int stream_type;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
160 };
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
161
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
162 static struct pvr_t *
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
163 pvr_init (void)
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 struct pvr_t *pvr = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
166
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
167 pvr = malloc (sizeof (struct pvr_t));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
168 pvr->dev_fd = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
169 pvr->video_dev = strdup (PVR_DEFAULT_DEVICE);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
170
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
171 /* v4l2 params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
172 pvr->mute = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
173 pvr->input = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
174 pvr->normid = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
175 pvr->brightness = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
176 pvr->contrast = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
177 pvr->hue = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
178 pvr->saturation = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
179 pvr->width = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
180 pvr->height = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
181 pvr->freq = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
182
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
183 /* ivtv params */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
184 pvr->aspect = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
185 pvr->samplerate = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
186 pvr->layer = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
187 pvr->audio_rate = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
188 pvr->audio_mode = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
189 pvr->bitrate = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
190 pvr->bitrate_mode = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
191 pvr->bitrate_peak = -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
192 pvr->stream_type = -1;
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 return pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
195 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
196
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
197 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
198 pvr_uninit (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
199 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
200 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
201 return;
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 /* close device */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
204 if (pvr->dev_fd)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
205 close (pvr->dev_fd);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
206
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
207 if (pvr->video_dev)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
208 free (pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
209 if (pvr->freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
210 free (pvr->freq);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
211 free (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
212 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
213
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
214 /* IVTV layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
215
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
216 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
217 parse_ivtv_options (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
218 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
219 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
220 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
221
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
222 /* -pvr aspect=digit */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
223 if (pvr_param_aspect_ratio >= 1 && pvr_param_aspect_ratio <= 4)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
224 pvr->aspect = pvr_param_aspect_ratio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
225
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
226 /* -pvr arate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
227 if (pvr_param_sample_rate != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
228 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
229 switch (pvr_param_sample_rate)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
230 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
231 case 32000:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
232 pvr->samplerate = PVR_AUDIO_SAMPLE_RATE_32_KHZ;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
233 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
234 case 44100:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
235 pvr->samplerate = PVR_AUDIO_SAMPLE_RATE_44_1_KHZ;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
236 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
237 case 48000:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
238 pvr->samplerate = PVR_AUDIO_SAMPLE_RATE_48_KHZ;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
239 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
240 default:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
241 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
242 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
243 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
244
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
245 /* -pvr alayer=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
246 if (pvr_param_audio_layer == 1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
247 pvr->layer = PVR_AUDIO_LAYER_1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
248 else if (pvr_param_audio_layer == 2)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
249 pvr->layer = PVR_AUDIO_LAYER_2;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
250
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
251 /* -pvr abitrate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
252 if (pvr_param_audio_bitrate != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
253 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
254 /* set according to layer or use layer 1 by default if not specified */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
255 switch (pvr_param_audio_bitrate)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
256 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
257 case 32:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
258 pvr->audio_rate = PVR_AUDIO_BITRATE_32;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
259 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
260 case 48:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
261 pvr->audio_rate = PVR_AUDIO_BITRATE_L2_48;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
262 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
263 case 56:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
264 pvr->audio_rate = PVR_AUDIO_BITRATE_L2_56;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
265 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
266 case 64:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
267 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
268 PVR_AUDIO_BITRATE_L2_64 : PVR_AUDIO_BITRATE_L1_64;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
269 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
270 case 80:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
271 pvr->audio_rate = PVR_AUDIO_BITRATE_L2_80;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
272 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
273 case 96:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
274 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
275 PVR_AUDIO_BITRATE_L2_96 : PVR_AUDIO_BITRATE_L1_96;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
276 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
277 case 112:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
278 pvr->audio_rate = PVR_AUDIO_BITRATE_L2_112;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
279 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
280 case 128:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
281 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
282 PVR_AUDIO_BITRATE_L2_128 : PVR_AUDIO_BITRATE_L1_128;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
283 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
284 case 160:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
285 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
286 PVR_AUDIO_BITRATE_L2_160 : PVR_AUDIO_BITRATE_L1_160;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
287 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
288 case 192:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
289 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
290 PVR_AUDIO_BITRATE_L2_192 : PVR_AUDIO_BITRATE_L1_192;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
291 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
292 case 224:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
293 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
294 PVR_AUDIO_BITRATE_L2_224 : PVR_AUDIO_BITRATE_L1_224;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
295 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
296 case 256:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
297 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
298 PVR_AUDIO_BITRATE_L2_256 : PVR_AUDIO_BITRATE_L1_256;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
299 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
300 case 288:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
301 pvr->audio_rate = PVR_AUDIO_BITRATE_L1_288;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
302 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
303 case 320:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
304 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
305 PVR_AUDIO_BITRATE_L2_320 : PVR_AUDIO_BITRATE_L1_320;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
306 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
307 case 352:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
308 pvr->audio_rate = PVR_AUDIO_BITRATE_L1_352;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
309 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
310 case 384:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
311 pvr->audio_rate = (pvr_param_audio_layer == 2) ?
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
312 PVR_AUDIO_BITRATE_L2_384 : PVR_AUDIO_BITRATE_L1_384;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
313 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
314 case 416:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
315 pvr->audio_rate = PVR_AUDIO_BITRATE_L1_416;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
316 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
317 case 448:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
318 pvr->audio_rate = PVR_AUDIO_BITRATE_L1_448;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
319 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
320 default:
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
321 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
322 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
323 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
324
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
325 /* -pvr amode=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
326 if (pvr_param_audio_mode)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
327 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
328 if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_STEREO))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
329 pvr->audio_mode = PVR_AUDIO_MODE_STEREO;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
330 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_JOINT_STEREO))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
331 pvr->audio_mode = PVR_AUDIO_MODE_JOINT_STEREO;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
332 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_DUAL))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
333 pvr->audio_mode = PVR_AUDIO_MODE_DUAL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
334 else if (!strcmp (pvr_param_audio_mode, PVR_AUDIO_MODE_ARG_MONO))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
335 pvr->audio_mode = PVR_AUDIO_MODE_MONO;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
336 else /* for anything else, set to stereo */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
337 pvr->audio_mode = PVR_AUDIO_MODE_STEREO;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
338 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
339
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
340 /* -pvr vbitrate=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
341 if (pvr_param_bitrate)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
342 pvr->bitrate = pvr_param_bitrate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
343
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
344 /* -pvr vmode=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
345 if (pvr_param_bitrate_mode)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
346 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
347 if (!strcmp (pvr_param_bitrate_mode, PVR_VIDEO_BITRATE_MODE_ARG_VBR))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
348 pvr->bitrate_mode = PVR_VIDEO_BITRATE_MODE_VBR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
349 else if (!strcmp (pvr_param_bitrate_mode, PVR_VIDEO_BITRATE_MODE_ARG_CBR))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
350 pvr->bitrate_mode = PVR_VIDEO_BITRATE_MODE_CBR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
351 else /* for anything else, set to VBR */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
352 pvr->bitrate_mode = PVR_VIDEO_BITRATE_MODE_VBR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
353 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
354
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
355 /* -pvr vpeak=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
356 if (pvr_param_bitrate_peak)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
357 pvr->bitrate_peak = pvr_param_bitrate_peak;
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 /* -pvr fmt=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
360 if (pvr_param_stream_type)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
361 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
362 if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_PS))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
363 pvr->stream_type = IVTV_STREAM_PS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
364 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_TS))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
365 pvr->stream_type = IVTV_STREAM_TS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
366 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_MPEG1))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
367 pvr->stream_type = IVTV_STREAM_MPEG1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
368 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_DVD))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
369 pvr->stream_type = IVTV_STREAM_DVD;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
370 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_VCD))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
371 pvr->stream_type = IVTV_STREAM_VCD;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
372 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_SVCD))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
373 pvr->stream_type = IVTV_STREAM_SVCD;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
374 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_DVD_S1))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
375 pvr->stream_type = IVTV_STREAM_DVD_S1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
376 else if (!strcmp (pvr_param_stream_type, PVR_VIDEO_STREAM_TYPE_DVD_S2))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
377 pvr->stream_type = IVTV_STREAM_DVD_S2;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
378 else /* for anything else, set to MPEG PS */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
379 pvr->stream_type = IVTV_STREAM_PS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
380 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
381 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
382
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
383 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
384 set_ivtv_settings (struct pvr_t *pvr)
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 struct ivtv_ioctl_codec codec;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
387
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
388 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
389 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
390
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
391 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
392 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
393
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
394 /* get current settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
395 if (ioctl (pvr->dev_fd, IVTV_IOC_G_CODEC, &codec) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
396 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
397 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
398 "%s can't get codec (%s).\n", LOG_LEVEL_IVTV, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
399 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
400 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
401
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
402 /* set default encoding settings
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
403 * may be overlapped by user parameters
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
404 * Use VBR MPEG_PS encoding at 6 Mbps (peak at 9.6 Mbps)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
405 * with 48 KHz L2 384 kbps audio.
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 codec.aspect = PVR_ASPECT_RATIO_4_3;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
408 codec.bitrate_mode = PVR_VIDEO_BITRATE_MODE_VBR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
409 codec.bitrate = 6000000;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
410 codec.bitrate_peak = 9600000;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
411 codec.stream_type = IVTV_STREAM_PS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
412 codec.audio_bitmask = PVR_AUDIO_LAYER_2
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
413 | PVR_AUDIO_BITRATE_L2_384 | PVR_AUDIO_SAMPLE_RATE_48_KHZ;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
414
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
415 /* set aspect ratio */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
416 if (pvr->aspect != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
417 codec.aspect = pvr->aspect;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
418
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
419 /* if user value is given, we need to reset audio bitmask */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
420 if ((pvr->samplerate != -1) || (pvr->layer != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
421 || (pvr->audio_rate != -1) || (pvr->audio_mode != -1))
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
422 codec.audio_bitmask = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
423
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
424 /* set audio samplerate */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
425 if (pvr->samplerate != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
426 codec.audio_bitmask |= pvr->samplerate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
427
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
428 /* set audio layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
429 if (pvr->layer != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
430 codec.audio_bitmask |= pvr->layer;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
431
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
432 /* set audio bitrate */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
433 if (pvr->audio_rate != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
434 codec.audio_bitmask |= pvr->audio_rate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
435
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
436 /* set audio mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
437 if (pvr->audio_mode != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
438 codec.audio_bitmask |= pvr->audio_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
439
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
440 /* set video bitrate */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
441 if (pvr->bitrate != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
442 codec.bitrate = pvr->bitrate;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
443
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
444 /* set video bitrate mode */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
445 if (pvr->bitrate_mode != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
446 codec.bitrate_mode = pvr->bitrate_mode;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
447
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
448 /* set video bitrate peak */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
449 if (pvr->bitrate != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
450 codec.bitrate_peak = pvr->bitrate_peak;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
451
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
452 /* set video stream type */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
453 if (pvr->stream_type != -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
454 codec.stream_type = pvr->stream_type;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
455
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
456 /* set new encoding settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
457 if (ioctl (pvr->dev_fd, IVTV_IOC_S_CODEC, &codec) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
458 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
459 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
460 "%s can't set codec (%s).\n", LOG_LEVEL_IVTV, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
461 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
462 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
463
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
464 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
465 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
466
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
467 /* V4L2 layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
468
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
469 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
470 parse_v4l2_tv_options (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
471 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
472 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
473 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
474
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
475 if (tv_param_device)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
476 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
477 if (pvr->video_dev)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
478 free (pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
479 pvr->video_dev = strdup (tv_param_device);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
480 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
481
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
482 if (tv_param_noaudio)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
483 pvr->mute = tv_param_noaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
484
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
485 if (tv_param_input)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
486 pvr->input = tv_param_input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
487
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
488 if (tv_param_normid)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
489 pvr->normid = tv_param_normid;
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 if (tv_param_brightness)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
492 pvr->brightness = tv_param_brightness;
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 if (tv_param_contrast)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
495 pvr->contrast = tv_param_contrast;
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 (tv_param_hue)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
498 pvr->hue = tv_param_hue;
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_saturation)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
501 pvr->saturation = tv_param_saturation;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
502
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
503 if (tv_param_width)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
504 pvr->width = tv_param_width;
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 if (tv_param_height)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
507 pvr->height = tv_param_height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
508
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
509 if (tv_param_freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
510 pvr->freq = strdup (tv_param_freq);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
511 }
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 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
514 set_v4l2_settings (struct pvr_t *pvr)
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 (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
517 return -1;
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 (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
520 return -1;
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 /* -tv noaudio */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
523 if (pvr->mute)
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 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
526 ctrl.id = V4L2_CID_AUDIO_MUTE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
527 ctrl.value = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
528 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
529 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
530 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
531 "%s can't mute (%s).\n", LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
532 return -1;
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 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
535
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
536 /* -tv input=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
537 if (pvr->input != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
538 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
539 if (ioctl (pvr->dev_fd, VIDIOC_S_INPUT, &pvr->input) < 0)
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 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
542 "%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
543 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
544 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
545 }
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 normid=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
548 if (pvr->normid != -1)
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_standard std;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
551 std.index = pvr->normid;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
552
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
553 if (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &std) < 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 set norm (%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 mp_msg (MSGT_OPEN, MSGL_V,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
561 "%s set norm to %s\n", LOG_LEVEL_V4L2, std.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
562
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
563 if (ioctl (pvr->dev_fd, VIDIOC_S_STD, &std.id) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
564 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
565 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
566 "%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
567 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
568 }
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 /* -tv brightness=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
572 if (pvr->brightness != 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
573 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
574 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
575 ctrl.id = V4L2_CID_BRIGHTNESS;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
576 ctrl.value = pvr->brightness;
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 (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
579 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
580 if (ctrl.value > 255)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
581 ctrl.value = 255;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
582
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
583 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
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_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
586 "%s can't set brightness to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
587 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
588 return -1;
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 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
591
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
592 /* -tv contrast=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
593 if (pvr->contrast != 0)
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 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
596 ctrl.id = V4L2_CID_CONTRAST;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
597 ctrl.value = pvr->contrast;
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 if (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
600 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
601 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
602 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
603
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
604 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
605 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
606 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
607 "%s can't set contrast to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
608 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
609 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
610 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
611 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
612
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
613 /* -tv hue=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
614 if (pvr->hue != 0)
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 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
617 ctrl.id = V4L2_CID_HUE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
618 ctrl.value = pvr->hue;
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 if (ctrl.value < -128)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
621 ctrl.value = -128;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
622 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
623 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
624
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
625 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
626 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
627 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
628 "%s can't set hue to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
629 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
630 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
631 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
632 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
633
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
634 /* -tv saturation=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
635 if (pvr->saturation != 0)
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 struct v4l2_control ctrl;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
638 ctrl.id = V4L2_CID_SATURATION;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
639 ctrl.value = pvr->saturation;
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 if (ctrl.value < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
642 ctrl.value = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
643 if (ctrl.value > 127)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
644 ctrl.value = 127;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
645
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
646 if (ioctl (pvr->dev_fd, VIDIOC_S_CTRL, &ctrl) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
647 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
648 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
649 "%s can't set saturation to %d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
650 LOG_LEVEL_V4L2, ctrl.value, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
651 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
652 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
653 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
654
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
655 /* -tv width=x:height=y */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
656 if (pvr->width && pvr->height)
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 struct v4l2_format vfmt;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
659 vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
660 vfmt.fmt.pix.width = pvr->width;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
661 vfmt.fmt.pix.height = pvr->height;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
662
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
663 if (ioctl (pvr->dev_fd, VIDIOC_S_FMT, &vfmt) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
664 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
665 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
666 "%s can't set resolution to %dx%d (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
667 LOG_LEVEL_V4L2, pvr->width, pvr->height, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
668 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
669 }
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
672 /* -tv freq=x */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
673 if (pvr->freq)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
674 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
675 struct v4l2_frequency vf;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
676 vf.tuner = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
677 vf.type = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
678 vf.frequency = strtol (pvr->freq, 0L, 0);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
679 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
680 "%s setting frequency to %d\n", LOG_LEVEL_V4L2, vf.frequency);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
681
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
682 if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
683 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
684 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
685 LOG_LEVEL_V4L2, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
686 return -1;
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 }
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 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
691 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
692
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
693 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
694 v4l2_list_capabilities (struct pvr_t *pvr)
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 struct v4l2_audio vaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
697 struct v4l2_standard vs;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
698 struct v4l2_input vin;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
699 int err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
700
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
701 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
702 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
703
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
704 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
705 return -1;
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 /* list available video inputs */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
708 vin.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
709 err = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
710 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
711 "%s Available video inputs: ", LOG_LEVEL_V4L2);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
712 while (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) >= 0)
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 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
715 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
716 vin.index++;
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 if (err)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
719 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
720 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
721 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
722 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
723 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
724 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
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 /* list available audio inputs */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
727 vaudio.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
728 err = 1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
729 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
730 "%s Available audio inputs: ", LOG_LEVEL_V4L2);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
731 while (ioctl (pvr->dev_fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
732 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
733 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
734 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
735 vaudio.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
736 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
737 if (err)
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 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
740 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
741 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
742 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
743 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
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 /* list available norms */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
746 vs.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
747 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
748 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
749 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
750 err = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
751 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
752 vs.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
753 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
754 if (err)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
755 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
756 mp_msg (MSGT_OPEN, MSGL_INFO, "none\n");
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
757 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
758 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
759 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
760 mp_msg (MSGT_OPEN, MSGL_INFO, "\n");
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 return 0;
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
765 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
766 v4l2_display_settings (struct pvr_t *pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
767 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
768 struct v4l2_audio vaudio;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
769 struct v4l2_standard vs;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
770 struct v4l2_input vin;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
771 v4l2_std_id std;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
772 int input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
773
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
774 if (!pvr)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
775 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
776
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
777 if (pvr->dev_fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
778 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
779
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
780 /* get current video input */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
781 if (ioctl (pvr->dev_fd, VIDIOC_G_INPUT, &input) == 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
782 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
783 vin.index = input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
784 if (ioctl (pvr->dev_fd, VIDIOC_ENUMINPUT, &vin) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
785 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
786 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
787 "%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
788 return -1;
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 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
791 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
792 "%s Video input: %s\n", LOG_LEVEL_V4L2, vin.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
793 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
794 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
795 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
796 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
797 "%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
798 return -1;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
799 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
800
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
801 /* get current audio input */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
802 if (ioctl (pvr->dev_fd, VIDIOC_G_AUDIO, &vaudio) == 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
803 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
804 vaudio.index = input;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
805 if (ioctl (pvr->dev_fd, VIDIOC_ENUMAUDIO, &vaudio) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
806 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
807 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
808 "%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
809 return -1;
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 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
812 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
813 "%s Audio input: %s\n", LOG_LEVEL_V4L2, vaudio.name);
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 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
817 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
818 "%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
819 return -1;
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
822 /* get current video format */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
823 if (ioctl (pvr->dev_fd, VIDIOC_G_STD, &std) == 0)
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 vs.index = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
826
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
827 while (ioctl (pvr->dev_fd, VIDIOC_ENUMSTD, &vs) >= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
828 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
829 if (vs.id == std)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
830 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
831 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
832 "%s Norm: %s.\n", LOG_LEVEL_V4L2, vs.name);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
833 break;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
834 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
835 vs.index++;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
836 }
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 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
839 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
840 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
841 "%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
842 return -1;
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
845 return 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
846 }
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 /* stream layer */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
849
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
850 static void
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
851 pvr_stream_close (stream_t *stream)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
852 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
853 struct pvr_t *pvr;
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 if (!stream)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
856 return;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
857
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
858 pvr = (struct pvr_t *) stream->priv;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
859 pvr_uninit (pvr);
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 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
863 pvr_stream_read (stream_t *stream, char *buffer, int size)
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 struct pollfd pfds[1];
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
866 struct pvr_t *pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
867 int rk, fd, pos;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
868
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
869 if (!stream || !buffer)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
870 return 0;
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 pvr = (struct pvr_t *) stream->priv;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
873 fd = pvr->dev_fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
874 pos = 0;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
875
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
876 if (fd < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
877 return 0;
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 while (pos < size)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
880 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
881 pfds[0].fd = fd;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
882 pfds[0].events = POLLIN | POLLPRI;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
883
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
884 rk = size - 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 (poll (pfds, 1, 500) <= 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
887 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
888 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
889 "%s failed with errno %d when reading %d bytes\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
890 LOG_LEVEL_PVR, errno, size-pos);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
891 break;
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
894 rk = read (fd, &buffer[pos], rk);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
895 if (rk > 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
896 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
897 pos += rk;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
898 mp_msg (MSGT_OPEN, MSGL_DBG3,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
899 "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
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 }
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 (!pos)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
904 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
905
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
906 return pos;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
907 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
908
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
909 static int
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
910 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
911 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
912 struct ivtv_ioctl_codec codec;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
913 struct ivtv_driver_info info;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
914 struct v4l2_capability vcap;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
915 struct pvr_t *pvr = NULL;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
916
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
917 if (mode != STREAM_READ)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
918 return STREAM_UNSUPORTED;
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 pvr = pvr_init ();
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
921
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
922 parse_v4l2_tv_options (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
923 parse_ivtv_options (pvr);
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 /* open device */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
926 pvr->dev_fd = open (pvr->video_dev, O_RDWR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
927 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
928 "%s Using device %s\n", LOG_LEVEL_PVR, pvr->video_dev);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
929 if (pvr->dev_fd == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
930 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
931 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
932 "%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
933 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
934 return STREAM_ERROR;
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
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
937 /* query capabilities (i.e test V4L2 support) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
938 if (ioctl (pvr->dev_fd, VIDIOC_QUERYCAP, &vcap) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
939 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
940 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
941 "%s device is not V4L2 compliant (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
942 LOG_LEVEL_PVR, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
943 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
944 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
945 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
946 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
947 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
948 "%s Detected %s\n", LOG_LEVEL_PVR, vcap.card);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
949
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
950 /* get codec and initialize card (i.e test IVTV support) */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
951 if (ioctl (pvr->dev_fd, IVTV_IOC_G_CODEC, &codec) < 0)
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 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
954 "%s device is not IVTV compliant (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
955 LOG_LEVEL_PVR, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
956 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
957 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
958 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
959
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
960 /* get ivtv driver info */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
961 if (ioctl (pvr->dev_fd, IVTV_IOC_G_DRIVER_INFO, &info) < 0)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
962 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
963 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
964 "%s device is not IVTV compliant (%s).\n",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
965 LOG_LEVEL_PVR, strerror (errno));
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
966 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
967 return STREAM_ERROR;
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 else
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
970 mp_msg (MSGT_OPEN, MSGL_INFO,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
971 "%s Detected ivtv driver: %s\n", LOG_LEVEL_PVR, info.comment);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
972
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
973 /* list V4L2 capabilities */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
974 if (v4l2_list_capabilities (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
975 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
976 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
977 "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
978 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
979 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
980 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
981
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
982 /* apply V4L2 settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
983 if (set_v4l2_settings (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
984 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
985 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
986 "%s can't set v4l2 settings\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
987 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
988 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
989 }
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 /* apply IVTV settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
992 if (set_ivtv_settings (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
993 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
994 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
995 "%s can't set ivtv settings\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
996 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
997 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
998 }
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 /* display current V4L2 settings */
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1001 if (v4l2_display_settings (pvr) == -1)
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1002 {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1003 mp_msg (MSGT_OPEN, MSGL_ERR,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1004 "%s can't get v4l2 settings\n", LOG_LEVEL_PVR);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1005 pvr_uninit (pvr);
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1006 return STREAM_ERROR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1007 }
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 stream->priv = pvr;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1010 stream->type = STREAMTYPE_PVR;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1011 stream->fill_buffer = pvr_stream_read;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1012 stream->close = pvr_stream_close;
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 return STREAM_OK;
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1015 }
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1016
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1017 stream_info_t stream_info_pvr = {
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1018 "PVR (V4L2/IVTV) Input",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1019 "pvr",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1020 "Benjamin Zores",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1021 "",
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1022 pvr_stream_open,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1023 { "pvr", NULL },
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1024 NULL,
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1025 1
73b8f5ff772d added new pvr:// input for ivtv based cards
ben
parents:
diff changeset
1026 };