annotate vidix/ivtv_vid.c @ 30946:82a429bcf680

Indentation fix.
author reimar
date Sat, 03 Apr 2010 07:12:32 +0000
parents 912e642ffb95
children 8fa2f43cb760
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 "fourcc.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
43 #include "dha.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
44 #include "pci_ids.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
45 #include "pci_names.h"
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
46
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
47 #define VIDIX_STATIC ivtv_
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
48
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
49 #define IVTV_MSG "[ivtv-vid] "
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
50 #define MAXLINE 128
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
51 #define IVTVMAXWIDTH 720
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
52 #define IVTVMAXHEIGHT 576
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
53
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
54 static int fbdev = -1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
55 static int yuvdev = -1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
56 static void *memBase = NULL;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
57 static int frameSize = 0;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
58 static int probed = 0;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
59 static int ivtv_verbose;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
60 static vidix_rect_t destVideo;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
61 static vidix_rect_t srcVideo;
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
62 static unsigned char *outbuf = NULL;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
63 double fb_width;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
64 double fb_height;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
65 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
66 static struct ivtvfb_ioctl_state_info fb_state_old;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
67 static struct ivtvfb_ioctl_state_info fb_state_hide;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
68 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
69 struct v4l2_format format_old, format_hide;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
70 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
71 int alpha_disable = 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
72
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
73 /* VIDIX exports */
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
74
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
75 static vidix_capability_t ivtv_cap =
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
76 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
77 "Hauppauge PVR 350 YUV Video",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
78 "Lutz Koschorreck",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
79 TYPE_OUTPUT,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
80 { 0, 0, 0, 0 },
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
81 IVTVMAXWIDTH,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
82 IVTVMAXHEIGHT,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
83 4,
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 -1,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
86 FLAG_UPSCALER|FLAG_DOWNSCALER,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
87 -1,
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 { 0, 0, 0, 0 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
90 };
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
91
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
92 static void de_macro_y(unsigned char *src, unsigned char *dst,
27624
905e9c7ac862 Remove pointless and gcc-specific __attribute__ ((unused)).
diego
parents: 27079
diff changeset
93 unsigned int w, unsigned int h, int src_x, int src_y, int height, int width)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
94 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
95 unsigned int x, y, i;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
96 unsigned char *dst_2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
97 unsigned int h_tail, w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
98 unsigned int h_size, w_size;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
99
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
100 // 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
101 if (src_x & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
102 w += src_x & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
103 src_x &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
104 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
105
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
106 if (src_y & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
107 h += src_y & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
108 src_y &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
109 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
110
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
111 // 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
112 h_tail = h & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
113 w_tail = w & 15;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
114
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
115 // One block is 16 pixels high
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
116 h_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
117
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
118 // descramble Y plane
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
119 for (y = 0; y < h; y += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
120
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
121 // 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
122 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
123
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
124 for (x = 0; x < w; x += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
125 if (x + 16 > w)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
126 w_size = w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
127 else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
128 w_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
129
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
130 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
131
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
132 for (i = 0; i < h_size; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
133 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
134 dst_2 += 16;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
135 }
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 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
138 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
139
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
140 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
141 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
142 int height, int width)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
143 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
144 unsigned int x, y, i, f;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
145 unsigned char *dst_2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
146 unsigned int h_tail, w_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
147 unsigned int h_size;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
148
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
149 // 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
150 w /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
151 h /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
152 src_x /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
153 src_y /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
154 height /= 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
155 width /= 2;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
156
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
157 // 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
158 if (src_x & 7) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
159 w += src_x & 7;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
160 src_x &= ~7;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
161 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
162
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
163 if (src_y & 15) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
164 h += src_y & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
165 src_y &= ~15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
166 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
167
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
168 // 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
169 h_tail = h & 15;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
170 w_tail = w & 7;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
171
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
172 h_size = 16;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
173
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
174 // descramble U/V plane
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
175 for (y = 0; y < h; y += 16) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
176 if ( y + 16 > h ) h_size = h_tail;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
177 for (x = 0; x < w; x += 8) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
178 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
179 if (x + 8 <= w) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
180 for (i = 0; i < h_size; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
181 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
182 dst_2[0] = srcu[idx + 0];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
183 dst_2[1] = srcv[idx + 0];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
184 dst_2[2] = srcu[idx + 1];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
185 dst_2[3] = srcv[idx + 1];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
186 dst_2[4] = srcu[idx + 2];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
187 dst_2[5] = srcv[idx + 2];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
188 dst_2[6] = srcu[idx + 3];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
189 dst_2[7] = srcv[idx + 3];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
190 dst_2[8] = srcu[idx + 4];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
191 dst_2[9] = srcv[idx + 4];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
192 dst_2[10] = srcu[idx + 5];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
193 dst_2[11] = srcv[idx + 5];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
194 dst_2[12] = srcu[idx + 6];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
195 dst_2[13] = srcv[idx + 6];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
196 dst_2[14] = srcu[idx + 7];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
197 dst_2[15] = srcv[idx + 7];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
198 dst_2 += 16;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
199 }
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 else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
202 for (i = 0; i < h_size; i ++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
203 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
204 for (f = 0; f < w_tail; f++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
205 dst_2[0] = srcu[idx + f];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
206 dst_2[1] = srcv[idx + f];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
207 dst_2 += 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
208 }
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 // Used for testing edge cutoff. Sets colour to Green
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
211 for (f = w_tail;f < 8;f ++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
212 dst_2[0] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
213 dst_2[1] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
214 dst_2 += 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
215 }
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 dst_2 += 16 - (w_tail << 1);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
218 }
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 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
222 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
223
27625
79f8fefa53df Restore function parameters mistakenly removed in previous commit.
diego
parents: 27624
diff changeset
224 int ivtv_probe(int verbose, int force)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
225 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
226 unsigned char fb_number = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
227 char *device_name = NULL;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
228 char *alpha = NULL;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
229 struct fb_var_screeninfo vinfo;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
230 char fb_dev_name[] = "/dev/fb0\0";
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
231 pciinfo_t lst[MAX_PCI_DEVICES];
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
232 int err = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
233 unsigned int i, num_pci = 0;
29389
912e642ffb95 Move some variable declarations up to avoid the warnings:
diego
parents: 29263
diff changeset
234 unsigned char yuv_device_number = 48, yuv_device = 48 + fb_number;
912e642ffb95 Move some variable declarations up to avoid the warnings:
diego
parents: 29263
diff changeset
235 char yuv_device_name[] = "/dev/videoXXX\0";
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
236
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
237 if(verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
238 printf(IVTV_MSG"probe\n");
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
239
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
240 ivtv_verbose = verbose;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
241
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
242 err = pci_scan(lst, &num_pci);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
243 if(err) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
244 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
245 return err;
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
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
248 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
249 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
250
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
251 for(i = 0; i < num_pci; i++) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
252 if(2 == ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
253 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
254 ,lst[i].vendor
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
255 ,lst[i].device
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
256 ,pci_vendor_name(lst[i].vendor)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
257 ,pci_device_name(lst[i].vendor,lst[i].device));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
258 if(VENDOR_INTERNEXT == lst[i].vendor) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
259 switch(lst[i].device)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
260 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
261 case DEVICE_INTERNEXT_ITVC15_MPEG_2_ENCODER:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
262 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
263 printf(IVTV_MSG"Found PVR 350\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
264 goto card_found;
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 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
267 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
268
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
269 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
270 printf(IVTV_MSG"Can't find chip\n");
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
271 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
272
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
273 card_found:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
274
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
275 device_name = getenv("FRAMEBUFFER");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
276 if(NULL == device_name) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
277 device_name = fb_dev_name;
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
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
280 fb_number = atoi(device_name+strlen("/dev/fb"));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
281
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
282 fbdev = open(device_name, O_RDWR);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
283 if(-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
284 if(ioctl(fbdev, FBIOGET_VSCREENINFO, &vinfo) < 0) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
285 printf(IVTV_MSG"Unable to read screen info\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
286 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
287 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
288 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
289 fb_width = vinfo.xres;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
290 fb_height = vinfo.yres;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
291 if(2 == ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
292 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
293 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
294 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
295 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
296 if(NULL != (alpha = getenv("VIDIXIVTVALPHA"))) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
297 if(0 == strcmp(alpha, "disable")) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
298 alpha_disable = 1;
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 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
301 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
302 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
303 return ENXIO;
25276
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
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
306 /* Try to find YUV device */
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
307 do {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
308 sprintf(yuv_device_name, "/dev/video%u", yuv_device);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
309 yuvdev = open(yuv_device_name, O_RDWR);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
310 if(-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
311 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
312 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
313 goto yuv_found;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
314 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
315 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
316 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
317 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
318 } while(yuv_device-- > yuv_device_number);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
319 return ENXIO;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
320
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
321 yuv_found:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
322 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
323 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
324 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
325 printf(IVTV_MSG"Unable to read fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
326 close(yuvdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
327 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
328 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
329 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
330 if(ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
331 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
332 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
333 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
334 fb_state_hide.alpha = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
335 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
336 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
337 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
338 memset(&format_old, 0, sizeof(format_old));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
339 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
340 if(ioctl(yuvdev, VIDIOC_G_FMT , &format_old) < 0) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
341 printf(IVTV_MSG"Unable to read fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
342 close(yuvdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
343 close(fbdev);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
344 return ENXIO;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
345 } else {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
346 if(ivtv_verbose) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
347 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
348 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
349 memcpy(&format_hide, &format_old, sizeof(format_old));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
350 format_hide.fmt.win.global_alpha = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
351 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
352 #endif
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 probed = 1;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
355 return 0;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
356 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
357
27625
79f8fefa53df Restore function parameters mistakenly removed in previous commit.
diego
parents: 27624
diff changeset
358 int ivtv_init(const char *args)
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
359 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
360 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
361 printf(IVTV_MSG"init\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
362
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
363 if (!probed) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
364 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
365 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
366 return EINTR;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
367 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
368 outbuf = malloc((IVTVMAXHEIGHT * IVTVMAXWIDTH) + (IVTVMAXHEIGHT * IVTVMAXWIDTH / 2));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
369 if(NULL == outbuf) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
370 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
371 printf(IVTV_MSG"Not enough memory availabe!\n");
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
372 return EINTR;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
373 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
374 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
375 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
376
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
377 void ivtv_destroy(void)
23275
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 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
380 printf(IVTV_MSG"destroy\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
381 if(-1 != yuvdev)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
382 close(yuvdev);
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
383 if(-1 != fbdev)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
384 close(fbdev);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
385 if(NULL != outbuf)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
386 free(outbuf);
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
387 if(NULL != memBase)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
388 free(memBase);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
389 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
390
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
391 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
392 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
393 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
394 printf(IVTV_MSG"GetCap\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
395 memcpy(to, &ivtv_cap, sizeof(vidix_capability_t));
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
396 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
397 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
398
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
399 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
400 {
29389
912e642ffb95 Move some variable declarations up to avoid the warnings:
diego
parents: 29263
diff changeset
401 int supports = 0;
912e642ffb95 Move some variable declarations up to avoid the warnings:
diego
parents: 29263
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);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
405
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
406 switch(to->fourcc)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
407 {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
408 case IMGFMT_YV12:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
409 supports = 1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
410 break;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
411 default:
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
412 supports = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
413 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
414
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
415 if(!supports) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
416 to->depth = to->flags = 0;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
417 return ENOTSUP;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
418 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
419 to->depth = VID_DEPTH_12BPP |
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
420 VID_DEPTH_15BPP | VID_DEPTH_16BPP |
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
421 VID_DEPTH_24BPP | VID_DEPTH_32BPP;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
422 to->flags = 0;
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
423 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
424 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
425
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
426 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
427 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
428 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
429 printf(IVTV_MSG"config playback\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
430
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
431 if(2 == ivtv_verbose){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
432 printf(IVTV_MSG"src : x:%d y:%d w:%d h:%d\n",
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
433 info->src.x, info->src.y, info->src.w, info->src.h);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
434 printf(IVTV_MSG"dest: x:%d y:%d w:%d h:%d\n",
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
435 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
436 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
437
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
438 memcpy(&destVideo, &info->dest, sizeof(vidix_rect_t));
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
439 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
440
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
441 info->num_frames = 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
442 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
443 info->dest.pitch.y = 1;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
444 info->dest.pitch.u = info->dest.pitch.v = 2;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
445 info->offsets[0] = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
446 info->offsets[1] = info->frame_size;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
447 info->offset.y = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
448 info->offset.u = info->src.w * info->src.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
449 info->offset.v = info->offset.u + ((info->src.w * info->src.h)/4);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
450 info->dga_addr = memBase = malloc(info->num_frames*info->frame_size);
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
451 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
452 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
453 info->frame_size, info->dga_addr);
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
454 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
455 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
456
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
457 int ivtv_playback_on(void)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
458 {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
459 if(ivtv_verbose)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
460 printf(IVTV_MSG"playback on\n");
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
461
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
462 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
463 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
464 if (-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
465 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
466 printf (IVTV_MSG"Failed to set fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
467 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
468 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
469 if (-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
470 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_hide) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
471 printf (IVTV_MSG"Failed to set fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
472 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
473 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
474 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
475 return 0;
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
476 }
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
477
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
478 int ivtv_playback_off(void)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
479 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
480 if(ivtv_verbose)
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
481 printf(IVTV_MSG"playback off\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27625
diff changeset
482
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
483 if(0 == alpha_disable) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
484 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
485 if (-1 != fbdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
486 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
487 printf (IVTV_MSG"Failed to restore fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
488 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
489 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
490 if (-1 != yuvdev) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
491 if (ioctl(yuvdev, VIDIOC_S_FMT, &format_old) < 0)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
492 printf (IVTV_MSG"Failed to restore fb state\n");
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
493 }
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
494 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
495 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
496 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
497 }
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
498
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
499 int ivtv_frame_sel(unsigned int frame)
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
500 {
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
501
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
502 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
503 struct ivtvyuv_ioctl_dma_host_to_ivtv_args args;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
504 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
505 struct ivtv_dma_frame args;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
506 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
507 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
508
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
509 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
510 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
511 curMemBase + (srcVideo.w * srcVideo.h), outbuf + (IVTVMAXHEIGHT * IVTVMAXWIDTH),
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
512 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
513
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
514 args.y_source = outbuf;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
515 args.uv_source = outbuf + (IVTVMAXHEIGHT * IVTVMAXWIDTH);
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
516
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
517 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
518 args.src_x = srcVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
519 args.src_y = srcVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
520 args.dst_x = destVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
521 args.dst_y = destVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
522 args.src_w = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
523 args.dst_w = destVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
524 args.srcBuf_width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
525 args.src_h = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
526 args.dst_h = destVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
527 args.srcBuf_height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
528 args.yuv_type = 0;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
529 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
530 args.src.left = srcVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
531 args.src.top = srcVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
532 args.dst.left = destVideo.x;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
533 args.dst.top = destVideo.y;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
534 args.src.width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
535 args.dst.width = destVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
536 args.src_width = srcVideo.w;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
537 args.src.height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
538 args.dst.height = destVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
539 args.src_height = srcVideo.h;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
540 args.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
541 #endif
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
542
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
543 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
544 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
545 #else
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
546 if(ioctl(yuvdev, IVTV_IOC_DMA_FRAME, &args) == -1) {
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
547 #endif
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
548 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
549 }
26753
502f04b67653 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26719
diff changeset
550 return 0;
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
551 }
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 VDXDriver ivtv_drv = {
25276
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
554 "ivtv",
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
555 NULL,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
556 .probe = ivtv_probe,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
557 .get_caps = ivtv_get_caps,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
558 .query_fourcc = ivtv_query_fourcc,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
559 .init = ivtv_init,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
560 .destroy = ivtv_destroy,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
561 .config_playback = ivtv_config_playback,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
562 .playback_on = ivtv_playback_on,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
563 .playback_off = ivtv_playback_off,
334d55a31174 sync ivtv driver with vidix.sf.net (multiple revisions)
ben
parents: 23275
diff changeset
564 .frame_sel = ivtv_frame_sel,
23275
17fcd644f32e new VIDIX driver for IVTV cards, original patch by Lutz Koschorreck
ben
parents:
diff changeset
565 };