annotate vidix/ivtv_vid.c @ 26790:abfadf6ba341

Do not install DATADIR always, the GUI installation target takes care of this.
author diego
date Sun, 18 May 2008 17:12:49 +0000
parents 502f04b67653
children df448e1248b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26719
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
1 /*
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
2 * VIDIX driver for Hauppauge PVR 350
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
3 *
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
4 * Copyright 2007 Lutz Koschorreck
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
5 * Based on genfb_vid.c and ivtv_xv.c
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
6 *
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
7 * This file is part of MPlayer.
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
8 *
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
10 * it under the terms of the GNU General Public License as published by
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
12 * (at your option) any later version.
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
13 *
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
17 * GNU General Public License for more details.
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
18 *
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
19 * You should have received a copy of the GNU General Public License along
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3abd1629658b Use standard license headers.
diego
parents: 26715
diff changeset
22 */
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
23
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
24 #include <errno.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
25 #include <stdio.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
26 #include <stdlib.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
27 #include <string.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
28 #include <unistd.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
29 #include <math.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
30 #include <inttypes.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
31 #include <fcntl.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
32 #include <sys/ioctl.h>
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
33 #include <linux/types.h>
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
34 #include <linux/version.h>
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
36 #include <linux/videodev2.h>
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
37 #endif
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
38 #include <linux/ivtv.h>
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
39 #include <linux/fb.h>
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
40
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
41 #include "vidix.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
42 #include "vidixlib.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
43 #include "fourcc.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
44 #include "dha.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
45 #include "pci_ids.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
46 #include "pci_names.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
47
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
48 #define VIDIX_STATIC ivtv_
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
49
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
50 #define IVTV_MSG "[ivtv-vid] "
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
51 #define MAXLINE 128
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
52 #define IVTVMAXWIDTH 720
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
53 #define IVTVMAXHEIGHT 576
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
54
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
55 static int fbdev = -1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
56 static int yuvdev = -1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
57 static void *memBase = NULL;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
58 static int frameSize = 0;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
59 static int probed = 0;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
60 static int ivtv_verbose;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
61 static vidix_rect_t destVideo;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
62 static vidix_rect_t srcVideo;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
63 static unsigned char *outbuf = NULL;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
64 double fb_width;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
65 double fb_height;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
66 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
67 static struct ivtvfb_ioctl_state_info fb_state_old;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
68 static struct ivtvfb_ioctl_state_info fb_state_hide;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
69 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
70 struct v4l2_format format_old, format_hide;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
71 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
72 int alpha_disable = 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
73
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
74 /* VIDIX exports */
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
75
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
76 static vidix_capability_t ivtv_cap =
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
77 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
78 "Hauppauge PVR 350 YUV Video",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
79 "Lutz Koschorreck",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
80 TYPE_OUTPUT,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
81 { 0, 0, 0, 0 },
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
82 IVTVMAXWIDTH,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
83 IVTVMAXHEIGHT,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
84 4,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
85 4,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
86 -1,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
87 FLAG_UPSCALER|FLAG_DOWNSCALER,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
88 -1,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
89 -1,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
90 { 0, 0, 0, 0 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
91 };
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
92
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
93 static void de_macro_y(unsigned char *src, unsigned char *dst,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
94 unsigned int w, unsigned int h, int src_x, int src_y, int height __attribute__ ((unused)), int width)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
95 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
96 unsigned int x, y, i;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
97 unsigned char *dst_2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
98 unsigned int h_tail, w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
99 unsigned int h_size, w_size;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
100
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
101 // Always round the origin, but compensate by increasing the size
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
102 if (src_x & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
103 w += src_x & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
104 src_x &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
105 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
106
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
107 if (src_y & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
108 h += src_y & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
109 src_y &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
110 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
111
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
112 // The right / bottom edge might not be a multiple of 16
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
113 h_tail = h & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
114 w_tail = w & 15;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
115
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
116 // One block is 16 pixels high
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
117 h_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
118
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
119 // descramble Y plane
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
120 for (y = 0; y < h; y += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
121
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
122 // Clip if we've reached the bottom & the size isn't a multiple of 16
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
123 if (y + 16 > h) h_size = h_tail;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
124
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
125 for (x = 0; x < w; x += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
126 if (x + 16 > w)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
127 w_size = w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
128 else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
129 w_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
130
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
131 dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>4)) + (x * 16);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
132
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
133 for (i = 0; i < h_size; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
134 memcpy(dst_2, src + src_x + x + (y + i) * width + (src_y * width), w_size);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
135 dst_2 += 16;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
136 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
137 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
138 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
139 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
140
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
141 static void de_macro_uv(unsigned char *srcu, unsigned char *srcv,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
142 unsigned char *dst, unsigned int w, unsigned int h, int src_x, int src_y,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
143 int height, int width)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
144 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
145 unsigned int x, y, i, f;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
146 unsigned char *dst_2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
147 unsigned int h_tail, w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
148 unsigned int h_size;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
149
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
150 // The uv plane is half the size of the y plane, so 'correct' all dimensions.
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
151 w /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
152 h /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
153 src_x /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
154 src_y /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
155 height /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
156 width /= 2;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
157
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
158 // Always round the origin, but compensate by increasing the size
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
159 if (src_x & 7) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
160 w += src_x & 7;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
161 src_x &= ~7;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
162 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
163
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
164 if (src_y & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
165 h += src_y & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
166 src_y &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
167 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
168
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
169 // The right / bottom edge may not be a multiple of 16
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
170 h_tail = h & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
171 w_tail = w & 7;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
172
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
173 h_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
174
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
175 // descramble U/V plane
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
176 for (y = 0; y < h; y += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
177 if ( y + 16 > h ) h_size = h_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
178 for (x = 0; x < w; x += 8) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
179 dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>3)) + (x * 32);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
180 if (x + 8 <= w) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
181 for (i = 0; i < h_size; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
182 int idx = src_x + x + ((y + i) * width) + (src_y * width);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
183 dst_2[0] = srcu[idx + 0];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
184 dst_2[1] = srcv[idx + 0];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
185 dst_2[2] = srcu[idx + 1];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
186 dst_2[3] = srcv[idx + 1];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
187 dst_2[4] = srcu[idx + 2];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
188 dst_2[5] = srcv[idx + 2];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
189 dst_2[6] = srcu[idx + 3];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
190 dst_2[7] = srcv[idx + 3];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
191 dst_2[8] = srcu[idx + 4];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
192 dst_2[9] = srcv[idx + 4];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
193 dst_2[10] = srcu[idx + 5];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
194 dst_2[11] = srcv[idx + 5];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
195 dst_2[12] = srcu[idx + 6];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
196 dst_2[13] = srcv[idx + 6];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
197 dst_2[14] = srcu[idx + 7];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
198 dst_2[15] = srcv[idx + 7];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
199 dst_2 += 16;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
200 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
201 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
202 else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
203 for (i = 0; i < h_size; i ++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
204 int idx = src_x + x + ((y + i) * width) + (src_y * width);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
205 for (f = 0; f < w_tail; f++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
206 dst_2[0] = srcu[idx + f];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
207 dst_2[1] = srcv[idx + f];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
208 dst_2 += 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
209 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
210 /*
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
211 // Used for testing edge cutoff. Sets colour to Green
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
212 for (f = w_tail;f < 8;f ++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
213 dst_2[0] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
214 dst_2[1] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
215 dst_2 += 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
216 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
217 */
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
218 dst_2 += 16 - (w_tail << 1);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
219 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
220 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
221 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
222 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
223 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
224
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
225 int ivtv_probe(int verbose,int force __attribute__ ((unused)))
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
226 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
227 unsigned char fb_number = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
228 char *device_name = NULL;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
229 char *alpha = NULL;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
230 struct fb_var_screeninfo vinfo;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
231 char fb_dev_name[] = "/dev/fb0\0";
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
232 pciinfo_t lst[MAX_PCI_DEVICES];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
233 int err = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
234 unsigned int i, num_pci = 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
235
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
236 if(verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
237 printf(IVTV_MSG"probe\n");
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
238
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
239 ivtv_verbose = verbose;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
240
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
241 err = pci_scan(lst, &num_pci);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
242 if(err) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
243 printf(IVTV_MSG"Error occured during pci scan: %s\n", strerror(err));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
244 return err;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
245 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
246
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
247 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
248 printf(IVTV_MSG"Found %d pci devices\n", num_pci);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
249
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
250 for(i = 0; i < num_pci; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
251 if(2 == ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
252 printf(IVTV_MSG"Found chip [%04X:%04X] '%s' '%s'\n"
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
253 ,lst[i].vendor
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
254 ,lst[i].device
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
255 ,pci_vendor_name(lst[i].vendor)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
256 ,pci_device_name(lst[i].vendor,lst[i].device));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
257 if(VENDOR_INTERNEXT == lst[i].vendor) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
258 switch(lst[i].device)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
259 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
260 case DEVICE_INTERNEXT_ITVC15_MPEG_2_ENCODER:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
261 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
262 printf(IVTV_MSG"Found PVR 350\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
263 goto card_found;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
264 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
265 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
266 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
267
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
268 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
269 printf(IVTV_MSG"Can't find chip\n");
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
270 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
271
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
272 card_found:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
273
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
274 device_name = getenv("FRAMEBUFFER");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
275 if(NULL == device_name) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
276 device_name = fb_dev_name;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
277 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
278
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
279 fb_number = atoi(device_name+strlen("/dev/fb"));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
280
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
281 fbdev = open(device_name, O_RDWR);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
282 if(-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
283 if(ioctl(fbdev, FBIOGET_VSCREENINFO, &vinfo) < 0) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
284 printf(IVTV_MSG"Unable to read screen info\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
285 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
286 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
287 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
288 fb_width = vinfo.xres;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
289 fb_height = vinfo.yres;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
290 if(2 == ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
291 printf(IVTV_MSG"framebuffer width : %3.0f\n",fb_width);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
292 printf(IVTV_MSG"framebuffer height: %3.0f\n",fb_height);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
293 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
294 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
295 if(NULL != (alpha = getenv("VIDIXIVTVALPHA"))) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
296 if(0 == strcmp(alpha, "disable")) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
297 alpha_disable = 1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
298 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
299 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
300 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
301 printf(IVTV_MSG"Failed to open /dev/fb%u\n", fb_number);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
302 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
303 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
304
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
305 /* Try to find YUV device */
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
306 unsigned char yuv_device_number = 48, yuv_device = 48 + fb_number;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
307 char yuv_device_name[] = "/dev/videoXXX\0";
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
308
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
309 do {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
310 sprintf(yuv_device_name, "/dev/video%u", yuv_device);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
311 yuvdev = open(yuv_device_name, O_RDWR);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
312 if(-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
313 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
314 printf(IVTV_MSG"YUV device found /dev/video%u\n", yuv_device);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
315 goto yuv_found;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
316 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
317 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
318 printf(IVTV_MSG"YUV device not found: /dev/video%u\n", yuv_device);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
319 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
320 } while(yuv_device-- > yuv_device_number);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
321 return ENXIO;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
322
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
323 yuv_found:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
324 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
325 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
326 if(ioctl(fbdev, IVTVFB_IOCTL_GET_STATE, &fb_state_old) < 0) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
327 printf(IVTV_MSG"Unable to read fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
328 close(yuvdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
329 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
330 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
331 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
332 if(ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
333 printf(IVTV_MSG"old alpha : %ld\n",fb_state_old.alpha);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
334 printf(IVTV_MSG"old status: 0x%lx\n",fb_state_old.status);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
335 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
336 fb_state_hide.alpha = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
337 fb_state_hide.status = fb_state_old.status | IVTVFB_STATUS_GLOBAL_ALPHA;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
338 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
339 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
340 memset(&format_old, 0, sizeof(format_old));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
341 format_old.type = format_hide.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
342 if(ioctl(yuvdev, VIDIOC_G_FMT , &format_old) < 0) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
343 printf(IVTV_MSG"Unable to read fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
344 close(yuvdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
345 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
346 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
347 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
348 if(ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
349 printf(IVTV_MSG"old alpha : %d\n",format_old.fmt.win.global_alpha);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
350 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
351 memcpy(&format_hide, &format_old, sizeof(format_old));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
352 format_hide.fmt.win.global_alpha = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
353 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
354 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
355 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
356 probed = 1;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
357 return 0;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
358 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
359
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
360 int ivtv_init(const char *args __attribute__ ((unused)))
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
361 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
362 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
363 printf(IVTV_MSG"init\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
364
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
365 if (!probed) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
366 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
367 printf(IVTV_MSG"Driver was not probed but is being initialized\n");
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
368 return EINTR;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
369 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
370 outbuf = malloc((IVTVMAXHEIGHT * IVTVMAXWIDTH) + (IVTVMAXHEIGHT * IVTVMAXWIDTH / 2));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
371 if(NULL == outbuf) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
372 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
373 printf(IVTV_MSG"Not enough memory availabe!\n");
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
374 return EINTR;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
375 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
376 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
377 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
378
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
379 void ivtv_destroy(void)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
380 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
381 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
382 printf(IVTV_MSG"destroy\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
383 if(-1 != yuvdev)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
384 close(yuvdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
385 if(-1 != fbdev)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
386 close(fbdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
387 if(NULL != outbuf)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
388 free(outbuf);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
389 if(NULL != memBase)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
390 free(memBase);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
391 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
392
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
393 int ivtv_get_caps(vidix_capability_t *to)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
394 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
395 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
396 printf(IVTV_MSG"GetCap\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
397 memcpy(to, &ivtv_cap, sizeof(vidix_capability_t));
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
398 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
399 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
400
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
401 int ivtv_query_fourcc(vidix_fourcc_t *to)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
402 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
403 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
404 printf(IVTV_MSG"query fourcc (%x)\n", to->fourcc);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
405
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
406 int supports = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
407 switch(to->fourcc)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
408 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
409 case IMGFMT_YV12:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
410 supports = 1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
411 break;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
412 default:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
413 supports = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
414 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
415
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
416 if(!supports) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
417 to->depth = to->flags = 0;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
418 return ENOTSUP;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
419 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
420 to->depth = VID_DEPTH_12BPP |
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
421 VID_DEPTH_15BPP | VID_DEPTH_16BPP |
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
422 VID_DEPTH_24BPP | VID_DEPTH_32BPP;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
423 to->flags = 0;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
424 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
425 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
426
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
427 int ivtv_config_playback(vidix_playback_t *info)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
428 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
429 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
430 printf(IVTV_MSG"config playback\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
431
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
432 if(2 == ivtv_verbose){
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
433 printf(IVTV_MSG"src : x:%d y:%d w:%d h:%d\n",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
434 info->src.x, info->src.y, info->src.w, info->src.h);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
435 printf(IVTV_MSG"dest: x:%d y:%d w:%d h:%d\n",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
436 info->dest.x, info->dest.y, info->dest.w, info->dest.h);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
437 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
438
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
439 memcpy(&destVideo, &info->dest, sizeof(vidix_rect_t));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
440 memcpy(&srcVideo, &info->src, sizeof(vidix_rect_t));
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
441
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
442 info->num_frames = 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
443 info->frame_size = frameSize = info->src.w*info->src.h+(info->src.w*info->src.h)/2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
444 info->dest.pitch.y = 1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
445 info->dest.pitch.u = info->dest.pitch.v = 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
446 info->offsets[0] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
447 info->offsets[1] = info->frame_size;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
448 info->offset.y = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
449 info->offset.u = info->src.w * info->src.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
450 info->offset.v = info->offset.u + ((info->src.w * info->src.h)/4);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
451 info->dga_addr = memBase = malloc(info->num_frames*info->frame_size);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
452 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
453 printf(IVTV_MSG"frame_size: %d, dga_addr: %p\n",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
454 info->frame_size, info->dga_addr);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
455 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
456 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
457
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
458 int ivtv_playback_on(void)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
459 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
460 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
461 printf(IVTV_MSG"playback on\n");
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
462
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
463 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
464 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
465 if (-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
466 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_hide) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
467 printf (IVTV_MSG"Failed to set fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
468 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
469 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
470 if (-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
471 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_hide) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
472 printf (IVTV_MSG"Failed to set fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
473 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
474 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
475 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
476 return 0;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
477 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
478
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
479 int ivtv_playback_off(void)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
480 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
481 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
482 printf(IVTV_MSG"playback off\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
483
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
484 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
485 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
486 if (-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
487 if (ioctl(fbdev, IVTVFB_IOCTL_SET_STATE, &fb_state_old) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
488 printf (IVTV_MSG"Failed to restore fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
489 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
490 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
491 if (-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
492 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_old) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
493 printf (IVTV_MSG"Failed to restore fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
494 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
495 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
496 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
497 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
498 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
499
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
500 int ivtv_frame_sel(unsigned int frame)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
501 {
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
502
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
503 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
504 struct ivtvyuv_ioctl_dma_host_to_ivtv_args args;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
505 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
506 struct ivtv_dma_frame args;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
507 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
508 unsigned char *curMemBase = (unsigned char *)memBase + (frame * frameSize);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
509
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
510 de_macro_y(curMemBase, outbuf, srcVideo.w, srcVideo.h, srcVideo.x, srcVideo.y, srcVideo.h, srcVideo.w);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
511 de_macro_uv(curMemBase + (srcVideo.w * srcVideo.h) + srcVideo.w * srcVideo.h / 4,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
512 curMemBase + (srcVideo.w * srcVideo.h), outbuf + (IVTVMAXHEIGHT * IVTVMAXWIDTH),
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
513 srcVideo.w, srcVideo.h, srcVideo.x, srcVideo.y, srcVideo.h, srcVideo.w);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
514
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
515 args.y_source = outbuf;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
516 args.uv_source = outbuf + (IVTVMAXHEIGHT * IVTVMAXWIDTH);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
517
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
518 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
519 args.src_x = srcVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
520 args.src_y = srcVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
521 args.dst_x = destVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
522 args.dst_y = destVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
523 args.src_w = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
524 args.dst_w = destVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
525 args.srcBuf_width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
526 args.src_h = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
527 args.dst_h = destVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
528 args.srcBuf_height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
529 args.yuv_type = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
530 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
531 args.src.left = srcVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
532 args.src.top = srcVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
533 args.dst.left = destVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
534 args.dst.top = destVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
535 args.src.width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
536 args.dst.width = destVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
537 args.src_width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
538 args.src.height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
539 args.dst.height = destVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
540 args.src_height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
541 args.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
542 #endif
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
543
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
544 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
545 if(ioctl(yuvdev, IVTV_IOC_PREP_FRAME_YUV, &args) == -1) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
546 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
547 if(ioctl(yuvdev, IVTV_IOC_DMA_FRAME, &args) == -1) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
548 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
549 printf("Ioctl IVTV_IOC_DMA_FRAME returned failed Error\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
550 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
551 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
552 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
553
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
554 VDXDriver ivtv_drv = {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
555 "ivtv",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
556 NULL,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
557 .probe = ivtv_probe,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
558 .get_caps = ivtv_get_caps,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
559 .query_fourcc = ivtv_query_fourcc,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
560 .init = ivtv_init,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
561 .destroy = ivtv_destroy,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
562 .config_playback = ivtv_config_playback,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
563 .playback_on = ivtv_playback_on,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
564 .playback_off = ivtv_playback_off,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
565 .frame_sel = ivtv_frame_sel,
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
566 };