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 _BUZ_H_
32#define _BUZ_H_
33
34struct zoran_requestbuffers {
35 unsigned long count;
36 unsigned long size;
37};
38
39struct zoran_sync {
40 unsigned long frame;
41 unsigned long length;
42 unsigned long seq;
43 struct timeval timestamp;
44};
45
46struct zoran_status {
47 int input;
48 int signal;
49 int norm;
50 int color;
51};
52
53struct zoran_params {
54
55
56
57 int major_version;
58 int minor_version;
59
60
61
62 int input;
63 int norm;
64 int decimation;
65
66
67
68
69
70
71
72
73 int HorDcm;
74 int VerDcm;
75 int TmpDcm;
76
77
78 int field_per_buff;
79 int img_x;
80 int img_y;
81 int img_width;
82
83 int img_height;
84
85
86
87
88
89
90 int quality;
91
92
93
94
95 int odd_even;
96
97 int APPn;
98 int APP_len;
99 char APP_data[60];
100
101 int COM_len;
102 char COM_data[60];
103
104 unsigned long jpeg_markers;
105
106
107
108
109
110
111#define JPEG_MARKER_DHT (1<<3)
112#define JPEG_MARKER_DQT (1<<4)
113#define JPEG_MARKER_DRI (1<<5)
114#define JPEG_MARKER_COM (1<<6)
115#define JPEG_MARKER_APP (1<<7)
116
117 int VFIFO_FB;
118
119
120
121
122
123
124
125
126 char reserved[312];
127};
128
129
130
131
132#define BUZIOC_G_PARAMS _IOR ('v', BASE_VIDIOCPRIVATE+0, struct zoran_params)
133#define BUZIOC_S_PARAMS _IOWR('v', BASE_VIDIOCPRIVATE+1, struct zoran_params)
134#define BUZIOC_REQBUFS _IOWR('v', BASE_VIDIOCPRIVATE+2, struct zoran_requestbuffers)
135#define BUZIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOCPRIVATE+3, int)
136#define BUZIOC_QBUF_PLAY _IOW ('v', BASE_VIDIOCPRIVATE+4, int)
137#define BUZIOC_SYNC _IOR ('v', BASE_VIDIOCPRIVATE+5, struct zoran_sync)
138#define BUZIOC_G_STATUS _IOWR('v', BASE_VIDIOCPRIVATE+6, struct zoran_status)
139
140
141#ifdef __KERNEL__
142
143#define MAJOR_VERSION 0
144#define MINOR_VERSION 9
145#define RELEASE_VERSION 5
146
147#define ZORAN_NAME "ZORAN"
148
149#define ZR_DEVNAME(zr) ((zr)->name)
150
151#define BUZ_MAX_WIDTH (zr->timing->Wa)
152#define BUZ_MAX_HEIGHT (zr->timing->Ha)
153#define BUZ_MIN_WIDTH 32
154#define BUZ_MIN_HEIGHT 24
155
156#define BUZ_NUM_STAT_COM 4
157#define BUZ_MASK_STAT_COM 3
158
159#define BUZ_MAX_FRAME 256
160#define BUZ_MASK_FRAME 255
161
162#define BUZ_MAX_INPUT 16
163
164#if VIDEO_MAX_FRAME <= 32
165# define V4L_MAX_FRAME 32
166#elif VIDEO_MAX_FRAME <= 64
167# define V4L_MAX_FRAME 64
168#else
169# error "Too many video frame buffers to handle"
170#endif
171#define V4L_MASK_FRAME (V4L_MAX_FRAME - 1)
172
173#define MAX_KMALLOC_MEM (128*1024)
174
175#include "zr36057.h"
176
177enum card_type {
178 UNKNOWN = -1,
179
180
181 DC10_old,
182 DC10_new,
183 DC10plus,
184 DC30,
185 DC30plus,
186
187
188 LML33,
189 LML33R10,
190
191
192 BUZ,
193
194
195 AVS6EYES,
196
197
198 NUM_CARDS
199};
200
201enum zoran_codec_mode {
202 BUZ_MODE_IDLE,
203 BUZ_MODE_MOTION_COMPRESS,
204 BUZ_MODE_MOTION_DECOMPRESS,
205 BUZ_MODE_STILL_COMPRESS,
206 BUZ_MODE_STILL_DECOMPRESS
207};
208
209enum zoran_buffer_state {
210 BUZ_STATE_USER,
211 BUZ_STATE_PEND,
212 BUZ_STATE_DMA,
213 BUZ_STATE_DONE
214};
215
216enum zoran_map_mode {
217 ZORAN_MAP_MODE_RAW,
218 ZORAN_MAP_MODE_JPG_REC,
219#define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
220 ZORAN_MAP_MODE_JPG_PLAY,
221};
222
223enum gpio_type {
224 GPIO_JPEG_SLEEP = 0,
225 GPIO_JPEG_RESET,
226 GPIO_JPEG_FRAME,
227 GPIO_VID_DIR,
228 GPIO_VID_EN,
229 GPIO_VID_RESET,
230 GPIO_CLK_SEL1,
231 GPIO_CLK_SEL2,
232 GPIO_MAX,
233};
234
235enum gpcs_type {
236 GPCS_JPEG_RESET = 0,
237 GPCS_JPEG_START,
238 GPCS_MAX,
239};
240
241struct zoran_format {
242 char *name;
243#ifdef CONFIG_VIDEO_V4L1_COMPAT
244 int palette;
245#endif
246#ifdef CONFIG_VIDEO_V4L2
247 __u32 fourcc;
248 int colorspace;
249#endif
250 int depth;
251 __u32 flags;
252 __u32 vfespfr;
253};
254
255#define ZORAN_FORMAT_COMPRESSED 1<<0
256#define ZORAN_FORMAT_OVERLAY 1<<1
257#define ZORAN_FORMAT_CAPTURE 1<<2
258#define ZORAN_FORMAT_PLAYBACK 1<<3
259
260
261struct zoran_overlay_settings {
262 int is_set;
263 int x, y, width, height;
264 int clipcount;
265 const struct zoran_format *format;
266};
267
268
269struct zoran_v4l_settings {
270 int width, height, bytesperline;
271 const struct zoran_format *format;
272};
273
274
275#ifndef CONFIG_VIDEO_V4L2
276struct v4l2_jpegcompression {
277 int quality;
278 int APPn;
279 int APP_len;
280 char APP_data[60];
281 int COM_len;
282 char COM_data[60];
283 __u32 jpeg_markers;
284 __u8 reserved[116];
285};
286#endif
287
288
289struct zoran_jpg_settings {
290 int decimation;
291 int HorDcm, VerDcm, TmpDcm;
292 int field_per_buff, odd_even;
293 int img_x, img_y, img_width, img_height;
294 struct v4l2_jpegcompression jpg_comp;
295};
296
297struct zoran_mapping {
298 struct file *file;
299 int count;
300};
301
302struct zoran_jpg_buffer {
303 struct zoran_mapping *map;
304 u32 *frag_tab;
305 u32 frag_tab_bus;
306 enum zoran_buffer_state state;
307 struct zoran_sync bs;
308};
309
310struct zoran_v4l_buffer {
311 struct zoran_mapping *map;
312 char *fbuffer;
313 unsigned long fbuffer_phys;
314 unsigned long fbuffer_bus;
315 enum zoran_buffer_state state;
316 struct zoran_sync bs;
317};
318
319enum zoran_lock_activity {
320 ZORAN_FREE,
321 ZORAN_ACTIVE,
322 ZORAN_LOCKED,
323};
324
325
326struct zoran_jpg_struct {
327 enum zoran_lock_activity active;
328 struct zoran_jpg_buffer buffer[BUZ_MAX_FRAME];
329 int num_buffers, buffer_size;
330 u8 allocated;
331 u8 ready_to_be_freed;
332 u8 need_contiguous;
333};
334
335struct zoran_v4l_struct {
336 enum zoran_lock_activity active;
337 struct zoran_v4l_buffer buffer[VIDEO_MAX_FRAME];
338 int num_buffers, buffer_size;
339 u8 allocated;
340 u8 ready_to_be_freed;
341};
342
343struct zoran;
344
345
346struct zoran_fh {
347 struct zoran *zr;
348
349 enum zoran_map_mode map_mode;
350
351 struct zoran_overlay_settings overlay_settings;
352 u32 *overlay_mask;
353 enum zoran_lock_activity overlay_active;
354
355 struct zoran_v4l_settings v4l_settings;
356 struct zoran_v4l_struct v4l_buffers;
357
358 struct zoran_jpg_settings jpg_settings;
359 struct zoran_jpg_struct jpg_buffers;
360};
361
362struct card_info {
363 enum card_type type;
364 char name[32];
365 u16 i2c_decoder, i2c_encoder;
366 u16 video_vfe, video_codec;
367 u16 audio_chip;
368 u16 vendor_id, device_id;
369
370 int inputs;
371 struct input {
372 int muxsel;
373 char name[32];
374 } input[BUZ_MAX_INPUT];
375
376 int norms;
377 struct tvnorm *tvn[3];
378
379 u32 jpeg_int;
380 u32 vsync_int;
381 s8 gpio[GPIO_MAX];
382 u8 gpcs[GPCS_MAX];
383
384 struct vfe_polarity vfe_pol;
385 u8 gpio_pol[GPIO_MAX];
386
387
388 u8 gws_not_connected;
389
390
391 u8 input_mux;
392
393 void (*init) (struct zoran * zr);
394};
395
396struct zoran {
397 struct video_device *video_dev;
398
399 struct i2c_adapter i2c_adapter;
400 struct i2c_algo_bit_data i2c_algo;
401 u32 i2cbr;
402
403 struct i2c_client *decoder;
404 struct i2c_client *encoder;
405
406 struct videocodec *codec;
407 struct videocodec *vfe;
408
409 struct mutex resource_lock;
410
411 u8 initialized;
412 int user;
413 struct card_info card;
414 struct tvnorm *timing;
415
416 unsigned short id;
417 char name[32];
418 struct pci_dev *pci_dev;
419 unsigned char revision;
420 unsigned int zr36057_adr;
421 unsigned char __iomem *zr36057_mem;
422
423 spinlock_t spinlock;
424
425
426 int input, norm;
427 int hue, saturation, contrast, brightness;
428 struct video_buffer buffer;
429 struct zoran_overlay_settings overlay_settings;
430 u32 *overlay_mask;
431 enum zoran_lock_activity overlay_active;
432
433 wait_queue_head_t v4l_capq;
434
435 int v4l_overlay_active;
436 int v4l_memgrab_active;
437
438 int v4l_grab_frame;
439#define NO_GRAB_ACTIVE (-1)
440 unsigned long v4l_grab_seq;
441 struct zoran_v4l_settings v4l_settings;
442
443
444 unsigned long v4l_pend_head;
445 unsigned long v4l_pend_tail;
446 unsigned long v4l_sync_tail;
447 int v4l_pend[V4L_MAX_FRAME];
448 struct zoran_v4l_struct v4l_buffers;
449
450
451 enum zoran_codec_mode codec_mode;
452 struct zoran_jpg_settings jpg_settings;
453
454 wait_queue_head_t jpg_capq;
455
456
457
458
459 unsigned long jpg_que_head;
460 unsigned long jpg_dma_head;
461 unsigned long jpg_dma_tail;
462 unsigned long jpg_que_tail;
463 unsigned long jpg_seq_num;
464 unsigned long jpg_err_seq;
465 unsigned long jpg_err_shift;
466 unsigned long jpg_queued_num;
467
468
469 u32 *stat_com;
470
471
472 int jpg_pend[BUZ_MAX_FRAME];
473
474
475 struct zoran_jpg_struct jpg_buffers;
476
477
478#ifdef CONFIG_PROC_FS
479 struct proc_dir_entry *zoran_proc;
480#else
481 void *zoran_proc;
482#endif
483 int testing;
484 int jpeg_error;
485 int intr_counter_GIRQ1;
486 int intr_counter_GIRQ0;
487 int intr_counter_CodRepIRQ;
488 int intr_counter_JPEGRepIRQ;
489 int field_counter;
490 int IRQ1_in;
491 int IRQ1_out;
492 int JPEG_in;
493 int JPEG_out;
494 int JPEG_0;
495 int JPEG_1;
496 int END_event_missed;
497 int JPEG_missed;
498 int JPEG_error;
499 int num_errors;
500 int JPEG_max_missed;
501 int JPEG_min_missed;
502
503 u32 last_isr;
504 unsigned long frame_num;
505
506 wait_queue_head_t test_q;
507};
508
509
510
511
512#ifdef _ALPHA_BUZ
513#define btwrite(dat,adr) writel((dat), zr->zr36057_adr+(adr))
514#define btread(adr) readl(zr->zr36057_adr+(adr))
515#else
516#define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr))
517#define btread(adr) readl(zr->zr36057_mem+(adr))
518#endif
519
520#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
521#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
522#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
523
524#endif
525
526#endif
527