annotate libvo/vo_ivtv.c @ 26160:82bb0624e948

Remove unnecessary #ifdef nesting.
author diego
date Fri, 07 Mar 2008 17:20:04 +0000
parents c9e9ac2008c2
children 2a34d9fa52ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
1 /*
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
2 * Copyright (C) 2006 Benjamin Zores
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
3 * Video output for WinTV PVR-150/250/350 (a.k.a IVTV) cards.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
4 * TV-Out through hardware MPEG decoder.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
5 * Based on some old code from ivtv driver authors.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
6 * See http://ivtvdriver.org/index.php/Main_Page for more details on the
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
7 * cards supported by the ivtv driver.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
8 *
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
12 * (at your option) any later version.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
13 *
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
17 * GNU General Public License for more details.
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
18 *
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
20 * along with this program; if not, write to the Free Software Foundation,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
22 */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
23
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
24 #include "config.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
25
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
26 #include <stdio.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
27 #include <stdlib.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
28 #include <string.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
29 #include <errno.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
30 #include <sys/types.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
31 #include <sys/stat.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
32 #include <sys/ioctl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
33 #include <fcntl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
34 #include <unistd.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
35 #include <stdlib.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
36 #include <inttypes.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
37 #include <linux/types.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
38 #include <linux/videodev2.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
39 #include <linux/ivtv.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
40 #include <linux/ioctl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
41
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
42 #include "mp_msg.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
43 #include "subopt-helper.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
44 #include "video_out.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
45 #include "video_out_internal.h"
19142
4c22e1d84ac9 updated mpeg_packetizer include to new localization
ben
parents: 19137
diff changeset
46 #include "libmpdemux/mpeg_packetizer.h"
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
47
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
48 #define DEFAULT_MPEG_DECODER "/dev/video16"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
49 #define IVTV_VO_HDR "VO: [ivtv]"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
50
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
51 /* ivtv private */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
52 int ivtv_fd = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
53 static vo_mpegpes_t *pes;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
54
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
55 /* suboptions */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
56 static int output = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
57 static char *device = NULL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
58
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
59 static opt_t subopts[] = {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
60 {"output", OPT_ARG_INT, &output, (opt_test_f)int_non_neg},
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
61 {"device", OPT_ARG_MSTRZ, &device, NULL},
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
62 {NULL}
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
63 };
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
64
25216
3aee342be929 Make vo info structs const
reimar
parents: 22335
diff changeset
65 static const vo_info_t info =
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
66 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
67 "IVTV MPEG Video Decoder TV-Out",
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
68 "ivtv",
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
69 "Benjamin Zores",
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
70 ""
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
71 };
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
72 const LIBVO_EXTERN (ivtv)
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
73
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
74 /* ivtv internals */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
75
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
76 static uint32_t
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
77 ivtv_reset (int blank_screen)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
78 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
79 struct ivtv_cfg_stop_decode sd;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
80 struct ivtv_cfg_start_decode sd1;
22335
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
81 int flags = 0;
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
82
22335
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
83 if (blank_screen)
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
84 flags |= IVTV_STOP_FL_HIDE_FRAME;
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
85 sd.flags = flags;
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
86
19978
f04afca36cf4 use a more generic ioctl as the one used was deprecated with Linux 2.6.18 kernel
ben
parents: 19148
diff changeset
87 if (ioctl (ivtv_fd, IVTV_IOC_STOP_DECODE, &sd) < 0)
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
88 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
89 mp_msg (MSGT_VO, MSGL_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
90 "IVTV_IOC_STOP_DECODE: %s\n", strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
91 return 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
92 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
93
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
94 sd1.gop_offset = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
95 sd1.muted_audio_frames = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
96
19978
f04afca36cf4 use a more generic ioctl as the one used was deprecated with Linux 2.6.18 kernel
ben
parents: 19148
diff changeset
97 if (ioctl (ivtv_fd, IVTV_IOC_START_DECODE, &sd1) < 0)
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
98 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
99 mp_msg (MSGT_VO, MSGL_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
100 "IVTV_IOC_START_DECODE: %s\n", strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
101 return 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
102 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
103
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
104 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
105 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
106
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
107 int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
108 ivtv_write (unsigned char *data, int len)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
109 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
110 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
111 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
112
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
113 return write (ivtv_fd, data, len);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
114 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
115
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
116 /* video out functions */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
117
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
118 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
119 config (uint32_t width, uint32_t height,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
120 uint32_t d_width, uint32_t d_height,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
121 uint32_t fullscreen, char *title, uint32_t format)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
122 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
123 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
124 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
125
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
126 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
127 preinit (const char *arg)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
128 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
129 struct v4l2_output vout;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
130 int err;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
131
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
132 if (subopt_parse (arg, subopts) != 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
133 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
134 mp_msg (MSGT_VO, MSGL_FATAL,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
135 "\n-vo ivtv command line help:\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
136 "Example: mplayer -vo ivtv:device=/dev/video16:output=2\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
137 "\nOptions:\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
138 " device=/dev/videoX\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
139 " Name of the MPEG decoder device file.\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
140 " output=<0-...>\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
141 " V4L2 id of the TV output.\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
142 "\n" );
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
143 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
144 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
145
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
146 if (!device)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
147 device = strdup (DEFAULT_MPEG_DECODER);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
148
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
149 ivtv_fd = open (device, O_RDWR);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
150 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
151 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
152 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
153 mp_msg (MSGT_VO, MSGL_FATAL, "%s %s\n", IVTV_VO_HDR, strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
154 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
155 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
156
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
157 /* list available outputs */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
158 vout.index = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
159 err = 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
160 mp_msg (MSGT_VO, MSGL_INFO, "%s Available video outputs: ", IVTV_VO_HDR);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
161 while (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
162 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
163 err = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
164 mp_msg (MSGT_VO, MSGL_INFO, "'#%d, %s' ", vout.index, vout.name);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
165 vout.index++;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
166 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
167 if (err)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
168 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
169 mp_msg (MSGT_VO, MSGL_INFO, "none\n");
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
170 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
171 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
172 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
173 else
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
174 mp_msg (MSGT_VO, MSGL_INFO, "\n");
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
175
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
176 /* set user specified output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
177 if (output != -1)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
178 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
179 if (ioctl (ivtv_fd, VIDIOC_S_OUTPUT, &output) < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
180 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
181 mp_msg (MSGT_VO, MSGL_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
182 "%s can't set output (%s)\n", IVTV_VO_HDR, strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
183 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
184 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
185 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
186 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
187
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
188 /* display device name */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
189 mp_msg (MSGT_VO, MSGL_INFO, "%s using %s\n", IVTV_VO_HDR, device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
190 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
191
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
192 /* display current video output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
193 if (ioctl (ivtv_fd, VIDIOC_G_OUTPUT, &output) == 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
194 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
195 vout.index = output;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
196 if (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
197 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
198 mp_msg (MSGT_VO, MSGL_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
199 "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
200 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
201 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
202 else
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
203 mp_msg (MSGT_VO, MSGL_INFO,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
204 "%s video output: %s\n", IVTV_VO_HDR, vout.name);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
205 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
206 else
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
207 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
208 mp_msg (MSGT_VO, MSGL_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
209 "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
210 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
211 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
212
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
213 /* clear output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
214 ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
215
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
216 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
217 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
218
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
219 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
220 draw_osd (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
221 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
222 /* do nothing */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
223 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
224
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
225 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
226 draw_frame (uint8_t * src[])
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
227 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
228 pes = (vo_mpegpes_t *) src[0];
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
229 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
230 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
231
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
232 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
233 flip_page (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
234 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
235 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
236 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
237
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
238 if (!pes)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
239 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
240
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19142
diff changeset
241 send_mpeg_pes_packet (pes->data, pes->size, pes->id,
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19142
diff changeset
242 pes->timestamp ? pes->timestamp : vo_pts, 2,
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
243 ivtv_write);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
244
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
245 /* ensure flip_page() won't be called twice */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
246 pes = NULL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
247 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
248
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
249 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
250 draw_slice (uint8_t *image[], int stride[], int w, int h, int x, int y)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
251 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
252 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
253 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
254
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
255 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
256 uninit (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
257 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
258 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
259 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
260
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
261 /* clear output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
262 ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
263
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
264 /* close device */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
265 close (ivtv_fd);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
266 ivtv_fd = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
267 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
268
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
269 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
270 check_events (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
271 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
272 /* do nothing */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
273 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
274
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
275 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
276 query_format (uint32_t format)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
277 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
278 if (format != IMGFMT_MPEGPES)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
279 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
280
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
281 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_TIMER;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
282 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
283
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
284 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
285 control (uint32_t request, void *data, ...)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
286 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
287 switch (request)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
288 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
289 case VOCTRL_PAUSE:
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
290 case VOCTRL_RESUME:
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
291 return ivtv_reset (0);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
292
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
293 case VOCTRL_RESET:
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
294 return ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
295
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
296 case VOCTRL_QUERY_FORMAT:
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
297 return query_format (*((uint32_t*) data));
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
298 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
299
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
300 return VO_NOTIMPL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
301 }