annotate libvo/vo_ivtv.c @ 36617:7d4fa6681d2b

vd: Make sure we test the preferred format first. Otherwise vd_ffmpeg will always convert 422 to 420 for e.g. ffh246 since it only needs a stride adjustment.
author reimar
date Thu, 23 Jan 2014 19:36:52 +0000
parents 5d3f93051de9
children
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 /*
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
2 * video output for WinTV PVR-150/250/350 (a.k.a IVTV) cards
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
3 * TV-Out through hardware MPEG decoder
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
4 * Based on some old code from ivtv driver authors.
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
5 * See http://ivtvdriver.org/index.php/Main_Page for more details on the
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
6 * cards supported by the ivtv driver.
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
7 *
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
8 * Copyright (C) 2006 Benjamin Zores
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
9 *
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
10 * This file is part of MPlayer.
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
11 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
12 * MPlayer is free software; you can redistribute it and/or modify
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
13 * it under the terms of the GNU General Public License as published by
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
15 * (at your option) any later version.
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
16 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
17 * MPlayer is distributed in the hope that it will be useful,
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
20 * GNU General Public License for more details.
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
21 *
26739
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
22 * You should have received a copy of the GNU General Public License along
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
23 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
2a34d9fa52ab Use standard license headers with standard formatting.
diego
parents: 25220
diff changeset
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19137
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
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
27 #include "config.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
28
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
29 #include <stdio.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
30 #include <stdlib.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
31 #include <string.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
32 #include <errno.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
33 #include <sys/types.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
34 #include <sys/stat.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
35 #include <sys/ioctl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
36 #include <fcntl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
37 #include <unistd.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
38 #include <stdlib.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
39 #include <inttypes.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
40 #include <linux/types.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
41 #include <linux/videodev2.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
42 #include <linux/ivtv.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
43 #include <linux/ioctl.h>
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
44
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
45 #include "mp_msg.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
46 #include "subopt-helper.h"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
47 #include "video_out.h"
36517
5d3f93051de9 Remove empty draw_slice and draw_frame stubs.
reimar
parents: 33305
diff changeset
48 #define NO_DRAW_SLICE
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
49 #include "video_out_internal.h"
31353
a465b54b0897 Add header for ivtv_write() instead of forward declaring it.
diego
parents: 31352
diff changeset
50 #include "vo_ivtv.h"
19142
4c22e1d84ac9 updated mpeg_packetizer include to new localization
ben
parents: 19137
diff changeset
51 #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
52
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
53 #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
54 #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
55
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
56 /* ivtv private */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
57 int ivtv_fd = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
58 static vo_mpegpes_t *pes;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
59
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
60 /* suboptions */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
61 static int output = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
62 static char *device = NULL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
63
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 26739
diff changeset
64 static const opt_t subopts[] = {
30122
1772a5171ac7 Fix function declarations to avoid casting function pointers.
reimar
parents: 29263
diff changeset
65 {"output", OPT_ARG_INT, &output, int_non_neg},
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
66 {"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
67 {NULL}
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
68 };
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
69
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
70 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
71 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
72 "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
73 "ivtv",
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
74 "Benjamin Zores",
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 };
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
77 const LIBVO_EXTERN (ivtv)
19137
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 /* ivtv internals */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
80
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
81 static uint32_t
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
82 ivtv_reset (int blank_screen)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
83 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
84 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
85 struct ivtv_cfg_start_decode sd1;
22335
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
86 int flags = 0;
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
87
22335
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
88 if (blank_screen)
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
89 flags |= IVTV_STOP_FL_HIDE_FRAME;
2f43fee89f0e support for new ivtv api
ben
parents: 19978
diff changeset
90 sd.flags = flags;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
91
19978
f04afca36cf4 use a more generic ioctl as the one used was deprecated with Linux 2.6.18 kernel
ben
parents: 19148
diff changeset
92 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
93 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
94 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
95 "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
96 return 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
97 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
98
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
99 sd1.gop_offset = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
100 sd1.muted_audio_frames = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
101
19978
f04afca36cf4 use a more generic ioctl as the one used was deprecated with Linux 2.6.18 kernel
ben
parents: 19148
diff changeset
102 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
103 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
104 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
105 "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
106 return 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
107 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
108
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
109 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
110 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
111
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
112 int
31352
f924b5c78117 Mark first parameter of ivtv_write as const; it is never changed.
diego
parents: 30122
diff changeset
113 ivtv_write (const unsigned char *data, int len)
19137
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 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
116 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
117
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
118 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
119 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
120
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
121 /* video out functions */
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 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
124 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
125 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
126 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
127 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
128 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
129 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
130
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
131 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
132 preinit (const char *arg)
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 struct v4l2_output vout;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
135 int err;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
136
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
137 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
138 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
139 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
140 "\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
141 "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
142 "\nOptions:\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
143 " device=/dev/videoX\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
144 " 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
145 " output=<0-...>\n"
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
146 " 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
147 "\n" );
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
148 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
149 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
150
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
151 if (!device)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
152 device = strdup (DEFAULT_MPEG_DECODER);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
153
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
154 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
155 if (ivtv_fd < 0)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
156 {
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
157 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
158 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
159 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
160 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
161
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
162 /* list available outputs */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
163 vout.index = 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
164 err = 1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
165 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
166 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
167 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
168 err = 0;
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, "'#%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
170 vout.index++;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
171 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
172 if (err)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
173 {
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, "none\n");
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
175 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
176 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
177 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
178 else
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
179 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
180
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
181 /* set user specified output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
182 if (output != -1)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
183 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
184 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
185 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
186 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
187 "%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
188 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
189 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
190 }
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
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
193 /* display device name */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
194 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
195 free (device);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
196
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
197 /* display current video output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
198 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
199 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
200 vout.index = output;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
201 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
202 {
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_ERR,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
204 "%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
205 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
206 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
207 else
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_INFO,
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
209 "%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
210 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
211 else
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 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
214 "%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
215 return -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
216 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
217
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
218 /* clear output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
219 ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
220
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
221 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
222 }
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 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
225 draw_osd (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
226 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
227 /* do nothing */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
228 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
229
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
230 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
231 draw_frame (uint8_t * src[])
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
232 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
233 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
234 return 0;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
235 }
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
236
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
237 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
238 flip_page (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
239 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
240 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
241 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
242
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
243 if (!pes)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
244 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
245
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19142
diff changeset
246 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
247 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
248 ivtv_write);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
249
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
250 /* 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
251 pes = NULL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
252 }
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 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
255 uninit (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
256 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
257 if (ivtv_fd < 0)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
258 return;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
259
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
260 /* clear output */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
261 ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
262
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
263 /* close device */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
264 close (ivtv_fd);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
265 ivtv_fd = -1;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
266 }
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 static void
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
269 check_events (void)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
270 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
271 /* do nothing */
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
272 }
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 static int
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
275 query_format (uint32_t format)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
276 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
277 if (format != IMGFMT_MPEGPES)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
278 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
279
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
280 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
281 }
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 static int
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 31353
diff changeset
284 control (uint32_t request, void *data)
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
285 {
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
286 switch (request)
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
287 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
288 case VOCTRL_PAUSE:
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
289 case VOCTRL_RESUME:
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
290 return ivtv_reset (0);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
291
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
292 case VOCTRL_RESET:
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
293 return ivtv_reset (1);
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
294
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
295 case VOCTRL_QUERY_FORMAT:
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
296 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
297 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28828
diff changeset
298
19137
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
299 return VO_NOTIMPL;
d9656bb2ae0e new vo driver for ivtv cards tv-out through internal h/w mpeg decoder
ben
parents:
diff changeset
300 }