1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#ifndef _PLANB_H_
32#define _PLANB_H_
33
34#ifdef __KERNEL__
35#include <asm/dbdma.h>
36#include "saa7196.h"
37#endif
38
39#define PLANB_DEVICE_NAME "Apple PlanB Video-In"
40#define PLANB_REV "1.0"
41
42#ifdef __KERNEL__
43
44
45
46#define PLANB_MAXPIXELS 768
47#define PLANB_MAXLINES 576
48#define PLANB_NTSC_MAXLINES 480
49
50
51#define PLANB_DEF_NORM VIDEO_MODE_PAL
52
53
54
55
56#define PLANB_GRAY 0x1
57#define PLANB_COLOUR15 0x2
58#define PLANB_COLOUR32 0x4
59#define PLANB_CLIPMASK 0x8
60
61
62#define CH_SYNC 0x1
63
64#define FIELD_SYNC 0x2
65
66#define EVEN_FIELD 0x0
67#define DMA_ABORT 0x2
68#define ODD_FIELD 0x4
69
70
71#define MAX_GBUFFERS 2
72
73#ifdef PLANB_GSCANLINE
74#define PLANB_MAX_FBUF 0x240000
75#define TAB_FACTOR (1)
76#else
77#define PLANB_MAX_FBUF 0x1b0000
78#define TAB_FACTOR (2)
79#endif
80#endif
81
82struct planb_saa_regs {
83 unsigned char addr;
84 unsigned char val;
85};
86
87struct planb_stat_regs {
88 unsigned int ch1_stat;
89 unsigned int ch2_stat;
90 unsigned char saa_stat0;
91 unsigned char saa_stat1;
92};
93
94struct planb_any_regs {
95 unsigned int offset;
96 unsigned int bytes;
97 unsigned char data[128];
98};
99
100
101#define PLANBIOCGSAAREGS _IOWR('v', BASE_VIDIOCPRIVATE, struct planb_saa_regs)
102#define PLANBIOCSSAAREGS _IOW('v', BASE_VIDIOCPRIVATE + 1, struct planb_saa_regs)
103#define PLANBIOCGSTAT _IOR('v', BASE_VIDIOCPRIVATE + 2, struct planb_stat_regs)
104#define PLANB_TV_MODE 1
105#define PLANB_VTR_MODE 2
106#define PLANBIOCGMODE _IOR('v', BASE_VIDIOCPRIVATE + 3, int)
107#define PLANBIOCSMODE _IOW('v', BASE_VIDIOCPRIVATE + 4, int)
108
109#ifdef PLANB_GSCANLINE
110#define PLANBG_GRAB_BPL _IOR('v', BASE_VIDIOCPRIVATE + 5, int)
111#endif
112
113
114#define PLANB_INTR_DEBUG _IOW('v', BASE_VIDIOCPRIVATE + 20, int)
115
116#define PLANB_INV_REGS _IOWR('v', BASE_VIDIOCPRIVATE + 21, struct planb_any_regs)
117
118#ifdef __KERNEL__
119
120
121#define PLANB_SET(x) ((x) << 16 | (x))
122#define PLANB_CLR(x) ((x) << 16)
123
124
125struct planb_registers {
126 volatile struct dbdma_regs ch1;
127 volatile unsigned int even;
128 volatile unsigned int odd;
129 unsigned int pad1[14];
130 volatile struct dbdma_regs ch2;
131 unsigned int pad2[16];
132 volatile unsigned int reg3;
133 volatile unsigned int intr_stat;
134#define PLANB_CLR_IRQ 0x00
135#define PLANB_GEN_IRQ 0x01
136#define PLANB_FRM_IRQ 0x0100
137 unsigned int pad3[1];
138 volatile unsigned int reg5;
139 unsigned int pad4[60];
140 volatile unsigned char saa_addr;
141 char pad5[3];
142 volatile unsigned char saa_regval;
143 char pad6[3];
144 volatile unsigned char saa_status;
145
146};
147
148struct planb_window {
149 int x, y;
150 ushort width, height;
151 ushort bpp, bpl, depth, pad;
152 ushort swidth, sheight;
153 int norm;
154 int interlace;
155 u32 color_fmt;
156 int chromakey;
157 int mode;
158};
159
160struct planb_suspend {
161 int overlay;
162 int frame;
163 struct dbdma_cmd cmd;
164};
165
166struct planb {
167 struct video_device video_dev;
168 struct video_picture picture;
169 struct video_audio audio_dev;
170
171 volatile struct planb_registers *planb_base;
172 struct planb_registers *planb_base_phys;
173 void *priv_space;
174 int user;
175 unsigned int tab_size;
176 int maxlines;
177 struct mutex lock;
178 unsigned int irq;
179 volatile unsigned int intr_mask;
180 struct pci_dev *dev;
181
182 int overlay;
183 struct planb_window win;
184 unsigned long frame_buffer_phys;
185 int offset;
186 volatile struct dbdma_cmd *ch1_cmd;
187 volatile struct dbdma_cmd *ch2_cmd;
188 volatile struct dbdma_cmd *overlay_last1;
189 volatile struct dbdma_cmd *overlay_last2;
190 unsigned long ch1_cmd_phys;
191 volatile unsigned char *mask;
192 int suspend;
193 wait_queue_head_t suspendq;
194 struct planb_suspend suspended;
195 int cmd_buff_inited;
196
197 int grabbing;
198 unsigned int gcount;
199 wait_queue_head_t capq;
200 int last_fr;
201 int prev_last_fr;
202 unsigned char **rawbuf;
203 int rawbuf_size;
204 int gbuf_idx[MAX_GBUFFERS];
205 volatile struct dbdma_cmd *cap_cmd[MAX_GBUFFERS];
206 volatile struct dbdma_cmd *last_cmd[MAX_GBUFFERS];
207 volatile struct dbdma_cmd *pre_cmd[MAX_GBUFFERS];
208 int need_pre_capture[MAX_GBUFFERS];
209#define PLANB_DUMMY 40
210 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
211 unsigned int gfmt[MAX_GBUFFERS];
212 int gnorm_switch[MAX_GBUFFERS];
213 volatile unsigned int *frame_stat;
214#define GBUFFER_UNUSED 0x00U
215#define GBUFFER_GRABBING 0x01U
216#define GBUFFER_DONE 0x02U
217#ifdef PLANB_GSCANLINE
218 int gbytes_per_line;
219#else
220#define MAX_LNUM 431
221
222 int l_fr_addr_idx[MAX_GBUFFERS];
223 unsigned char *l_to_addr[MAX_GBUFFERS][MAX_LNUM];
224 int l_to_next_idx[MAX_GBUFFERS][MAX_LNUM];
225 int l_to_next_size[MAX_GBUFFERS][MAX_LNUM];
226 int lsize[MAX_GBUFFERS], lnum[MAX_GBUFFERS];
227#endif
228};
229
230#endif
231
232#endif
233