1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef IVTV_DRIVER_H
23#define IVTV_DRIVER_H
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39#include <linux/module.h>
40#include <linux/init.h>
41#include <linux/delay.h>
42#include <linux/sched.h>
43#include <linux/fs.h>
44#include <linux/pci.h>
45#include <linux/interrupt.h>
46#include <linux/spinlock.h>
47#include <linux/i2c.h>
48#include <linux/i2c-algo-bit.h>
49#include <linux/list.h>
50#include <linux/unistd.h>
51#include <linux/pagemap.h>
52#include <linux/scatterlist.h>
53#include <linux/kthread.h>
54#include <linux/mutex.h>
55#include <linux/slab.h>
56#include <asm/uaccess.h>
57#include <asm/byteorder.h>
58
59#include <linux/dvb/video.h>
60#include <linux/dvb/audio.h>
61#include <media/v4l2-common.h>
62#include <media/v4l2-ioctl.h>
63#include <media/v4l2-ctrls.h>
64#include <media/v4l2-device.h>
65#include <media/v4l2-fh.h>
66#include <media/tuner.h>
67#include <media/drv-intf/cx2341x.h>
68#include <media/i2c/ir-kbd-i2c.h>
69
70#include <linux/ivtv.h>
71
72
73#define IVTV_ENCODER_OFFSET 0x00000000
74#define IVTV_ENCODER_SIZE 0x00800000
75#define IVTV_DECODER_OFFSET 0x01000000
76#define IVTV_DECODER_SIZE 0x00800000
77#define IVTV_REG_OFFSET 0x02000000
78#define IVTV_REG_SIZE 0x00010000
79
80
81
82#define IVTV_MAX_CARDS 32
83
84#define IVTV_ENC_STREAM_TYPE_MPG 0
85#define IVTV_ENC_STREAM_TYPE_YUV 1
86#define IVTV_ENC_STREAM_TYPE_VBI 2
87#define IVTV_ENC_STREAM_TYPE_PCM 3
88#define IVTV_ENC_STREAM_TYPE_RAD 4
89#define IVTV_DEC_STREAM_TYPE_MPG 5
90#define IVTV_DEC_STREAM_TYPE_VBI 6
91#define IVTV_DEC_STREAM_TYPE_VOUT 7
92#define IVTV_DEC_STREAM_TYPE_YUV 8
93#define IVTV_MAX_STREAMS 9
94
95#define IVTV_DMA_SG_OSD_ENT (2883584/PAGE_SIZE)
96
97
98#define IVTV_REG_DMAXFER (0x0000)
99#define IVTV_REG_DMASTATUS (0x0004)
100#define IVTV_REG_DECDMAADDR (0x0008)
101#define IVTV_REG_ENCDMAADDR (0x000c)
102#define IVTV_REG_DMACONTROL (0x0010)
103#define IVTV_REG_IRQSTATUS (0x0040)
104#define IVTV_REG_IRQMASK (0x0048)
105
106
107#define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8)
108#define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC)
109#define IVTV_REG_DEC_SDRAM_REFRESH (0x08F8)
110#define IVTV_REG_DEC_SDRAM_PRECHARGE (0x08FC)
111#define IVTV_REG_VDM (0x2800)
112#define IVTV_REG_AO (0x2D00)
113#define IVTV_REG_BYTEFLUSH (0x2D24)
114#define IVTV_REG_SPU (0x9050)
115#define IVTV_REG_HW_BLOCKS (0x9054)
116#define IVTV_REG_VPU (0x9058)
117#define IVTV_REG_APU (0xA064)
118
119
120#define IVTV_REG_DEC_LINE_FIELD (0x28C0)
121
122
123extern int ivtv_debug;
124#ifdef CONFIG_VIDEO_ADV_DEBUG
125extern int ivtv_fw_debug;
126#endif
127
128#define IVTV_DBGFLG_WARN (1 << 0)
129#define IVTV_DBGFLG_INFO (1 << 1)
130#define IVTV_DBGFLG_MB (1 << 2)
131#define IVTV_DBGFLG_IOCTL (1 << 3)
132#define IVTV_DBGFLG_FILE (1 << 4)
133#define IVTV_DBGFLG_DMA (1 << 5)
134#define IVTV_DBGFLG_IRQ (1 << 6)
135#define IVTV_DBGFLG_DEC (1 << 7)
136#define IVTV_DBGFLG_YUV (1 << 8)
137#define IVTV_DBGFLG_I2C (1 << 9)
138
139#define IVTV_DBGFLG_HIGHVOL (1 << 10)
140
141#define IVTV_DEBUG(x, type, fmt, args...) \
142 do { \
143 if ((x) & ivtv_debug) \
144 v4l2_info(&itv->v4l2_dev, " " type ": " fmt , ##args); \
145 } while (0)
146#define IVTV_DEBUG_WARN(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_WARN, "warn", fmt , ## args)
147#define IVTV_DEBUG_INFO(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_INFO, "info", fmt , ## args)
148#define IVTV_DEBUG_MB(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_MB, "mb", fmt , ## args)
149#define IVTV_DEBUG_DMA(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_DMA, "dma", fmt , ## args)
150#define IVTV_DEBUG_IOCTL(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_IOCTL, "ioctl", fmt , ## args)
151#define IVTV_DEBUG_FILE(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_FILE, "file", fmt , ## args)
152#define IVTV_DEBUG_I2C(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_I2C, "i2c", fmt , ## args)
153#define IVTV_DEBUG_IRQ(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_IRQ, "irq", fmt , ## args)
154#define IVTV_DEBUG_DEC(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_DEC, "dec", fmt , ## args)
155#define IVTV_DEBUG_YUV(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_YUV, "yuv", fmt , ## args)
156
157#define IVTV_DEBUG_HIGH_VOL(x, type, fmt, args...) \
158 do { \
159 if (((x) & ivtv_debug) && (ivtv_debug & IVTV_DBGFLG_HIGHVOL)) \
160 v4l2_info(&itv->v4l2_dev, " " type ": " fmt , ##args); \
161 } while (0)
162#define IVTV_DEBUG_HI_WARN(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_WARN, "warn", fmt , ## args)
163#define IVTV_DEBUG_HI_INFO(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_INFO, "info", fmt , ## args)
164#define IVTV_DEBUG_HI_MB(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_MB, "mb", fmt , ## args)
165#define IVTV_DEBUG_HI_DMA(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_DMA, "dma", fmt , ## args)
166#define IVTV_DEBUG_HI_IOCTL(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_IOCTL, "ioctl", fmt , ## args)
167#define IVTV_DEBUG_HI_FILE(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_FILE, "file", fmt , ## args)
168#define IVTV_DEBUG_HI_I2C(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_I2C, "i2c", fmt , ## args)
169#define IVTV_DEBUG_HI_IRQ(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_IRQ, "irq", fmt , ## args)
170#define IVTV_DEBUG_HI_DEC(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_DEC, "dec", fmt , ## args)
171#define IVTV_DEBUG_HI_YUV(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_YUV, "yuv", fmt , ## args)
172
173
174#define IVTV_ERR(fmt, args...) v4l2_err(&itv->v4l2_dev, fmt , ## args)
175#define IVTV_WARN(fmt, args...) v4l2_warn(&itv->v4l2_dev, fmt , ## args)
176#define IVTV_INFO(fmt, args...) v4l2_info(&itv->v4l2_dev, fmt , ## args)
177
178
179#define OUT_NONE 0
180#define OUT_MPG 1
181#define OUT_YUV 2
182#define OUT_UDMA_YUV 3
183#define OUT_PASSTHROUGH 4
184
185#define IVTV_MAX_PGM_INDEX (400)
186
187
188#define IVTV_DEFAULT_I2C_CLOCK_PERIOD 20
189
190struct ivtv_options {
191 int kilobytes[IVTV_MAX_STREAMS];
192 int cardtype;
193 int tuner;
194 int radio;
195 int newi2c;
196 int i2c_clock_period;
197};
198
199
200struct ivtv_mailbox {
201 u32 flags;
202 u32 cmd;
203 u32 retval;
204 u32 timeout;
205 u32 data[CX2341X_MBOX_MAX_DATA];
206};
207
208struct ivtv_api_cache {
209 unsigned long last_jiffies;
210 u32 data[CX2341X_MBOX_MAX_DATA];
211};
212
213struct ivtv_mailbox_data {
214 volatile struct ivtv_mailbox __iomem *mbox;
215
216
217 unsigned long busy;
218 u8 max_mbox;
219};
220
221
222#define IVTV_F_B_NEED_BUF_SWAP (1 << 0)
223
224
225#define IVTV_F_S_DMA_PENDING 0
226#define IVTV_F_S_DMA_HAS_VBI 1
227#define IVTV_F_S_NEEDS_DATA 2
228
229#define IVTV_F_S_CLAIMED 3
230#define IVTV_F_S_STREAMING 4
231#define IVTV_F_S_INTERNAL_USE 5
232#define IVTV_F_S_PASSTHROUGH 6
233#define IVTV_F_S_STREAMOFF 7
234#define IVTV_F_S_APPL_IO 8
235
236#define IVTV_F_S_PIO_PENDING 9
237#define IVTV_F_S_PIO_HAS_VBI 1
238
239
240#define IVTV_F_I_DMA 0
241#define IVTV_F_I_UDMA 1
242#define IVTV_F_I_UDMA_PENDING 2
243#define IVTV_F_I_SPEED_CHANGE 3
244#define IVTV_F_I_EOS 4
245#define IVTV_F_I_RADIO_USER 5
246#define IVTV_F_I_DIG_RST 6
247#define IVTV_F_I_DEC_YUV 7
248#define IVTV_F_I_UPDATE_CC 9
249#define IVTV_F_I_UPDATE_WSS 10
250#define IVTV_F_I_UPDATE_VPS 11
251#define IVTV_F_I_DECODING_YUV 12
252#define IVTV_F_I_ENC_PAUSED 13
253#define IVTV_F_I_VALID_DEC_TIMINGS 14
254#define IVTV_F_I_HAVE_WORK 15
255#define IVTV_F_I_WORK_HANDLER_VBI 16
256#define IVTV_F_I_WORK_HANDLER_YUV 17
257#define IVTV_F_I_WORK_HANDLER_PIO 18
258#define IVTV_F_I_PIO 19
259#define IVTV_F_I_DEC_PAUSED 20
260#define IVTV_F_I_INITED 21
261#define IVTV_F_I_FAILED 22
262#define IVTV_F_I_WORK_HANDLER_PCM 23
263
264
265#define IVTV_F_I_EV_DEC_STOPPED 28
266#define IVTV_F_I_EV_VSYNC 29
267#define IVTV_F_I_EV_VSYNC_FIELD 30
268#define IVTV_F_I_EV_VSYNC_ENABLED 31
269
270
271struct ivtv_sg_element {
272 __le32 src;
273 __le32 dst;
274 __le32 size;
275};
276
277struct ivtv_sg_host_element {
278 u32 src;
279 u32 dst;
280 u32 size;
281};
282
283struct ivtv_user_dma {
284 struct mutex lock;
285 int page_count;
286 struct page *map[IVTV_DMA_SG_OSD_ENT];
287
288 struct page *bouncemap[IVTV_DMA_SG_OSD_ENT];
289
290
291 struct ivtv_sg_element SGarray[IVTV_DMA_SG_OSD_ENT];
292 dma_addr_t SG_handle;
293 int SG_length;
294
295
296 struct scatterlist SGlist[IVTV_DMA_SG_OSD_ENT];
297};
298
299struct ivtv_dma_page_info {
300 unsigned long uaddr;
301 unsigned long first;
302 unsigned long last;
303 unsigned int offset;
304 unsigned int tail;
305 int page_count;
306};
307
308struct ivtv_buffer {
309 struct list_head list;
310 dma_addr_t dma_handle;
311 unsigned short b_flags;
312 unsigned short dma_xfer_cnt;
313 char *buf;
314 u32 bytesused;
315 u32 readpos;
316};
317
318struct ivtv_queue {
319 struct list_head list;
320 u32 buffers;
321 u32 length;
322 u32 bytesused;
323};
324
325struct ivtv;
326
327struct ivtv_stream {
328
329
330 struct video_device vdev;
331 struct ivtv *itv;
332 const char *name;
333 int type;
334 u32 caps;
335
336 struct v4l2_fh *fh;
337 spinlock_t qlock;
338 unsigned long s_flags;
339 int dma;
340 u32 pending_offset;
341 u32 pending_backup;
342 u64 pending_pts;
343
344 u32 dma_offset;
345 u32 dma_backup;
346 u64 dma_pts;
347
348 int subtype;
349 wait_queue_head_t waitq;
350 u32 dma_last_offset;
351
352
353 u32 buffers;
354 u32 buf_size;
355 u32 buffers_stolen;
356
357
358 struct ivtv_queue q_free;
359 struct ivtv_queue q_full;
360 struct ivtv_queue q_io;
361 struct ivtv_queue q_dma;
362 struct ivtv_queue q_predma;
363
364
365
366 u16 dma_xfer_cnt;
367
368
369 struct ivtv_sg_host_element *sg_pending;
370 struct ivtv_sg_host_element *sg_processing;
371 struct ivtv_sg_element *sg_dma;
372 dma_addr_t sg_handle;
373 int sg_pending_size;
374 int sg_processing_size;
375 int sg_processed;
376
377
378 struct scatterlist *SGlist;
379};
380
381struct ivtv_open_id {
382 struct v4l2_fh fh;
383 int type;
384 int yuv_frames;
385 struct ivtv *itv;
386};
387
388static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
389{
390 return container_of(fh, struct ivtv_open_id, fh);
391}
392
393struct yuv_frame_info
394{
395 u32 update;
396 s32 src_x;
397 s32 src_y;
398 u32 src_w;
399 u32 src_h;
400 s32 dst_x;
401 s32 dst_y;
402 u32 dst_w;
403 u32 dst_h;
404 s32 pan_x;
405 s32 pan_y;
406 u32 vis_w;
407 u32 vis_h;
408 u32 interlaced_y;
409 u32 interlaced_uv;
410 s32 tru_x;
411 u32 tru_w;
412 u32 tru_h;
413 u32 offset_y;
414 s32 lace_mode;
415 u32 sync_field;
416 u32 delay;
417 u32 interlaced;
418};
419
420#define IVTV_YUV_MODE_INTERLACED 0x00
421#define IVTV_YUV_MODE_PROGRESSIVE 0x01
422#define IVTV_YUV_MODE_AUTO 0x02
423#define IVTV_YUV_MODE_MASK 0x03
424
425#define IVTV_YUV_SYNC_EVEN 0x00
426#define IVTV_YUV_SYNC_ODD 0x04
427#define IVTV_YUV_SYNC_MASK 0x04
428
429#define IVTV_YUV_BUFFERS 8
430
431struct yuv_playback_info
432{
433 u32 reg_2834;
434 u32 reg_2838;
435 u32 reg_283c;
436 u32 reg_2840;
437 u32 reg_2844;
438 u32 reg_2848;
439 u32 reg_2854;
440 u32 reg_285c;
441 u32 reg_2864;
442
443 u32 reg_2870;
444 u32 reg_2874;
445 u32 reg_2890;
446 u32 reg_2898;
447 u32 reg_289c;
448
449 u32 reg_2918;
450 u32 reg_291c;
451 u32 reg_2920;
452 u32 reg_2924;
453 u32 reg_2928;
454 u32 reg_292c;
455 u32 reg_2930;
456
457 u32 reg_2934;
458
459 u32 reg_2938;
460 u32 reg_293c;
461 u32 reg_2940;
462 u32 reg_2944;
463 u32 reg_2948;
464 u32 reg_294c;
465 u32 reg_2950;
466 u32 reg_2954;
467 u32 reg_2958;
468 u32 reg_295c;
469 u32 reg_2960;
470 u32 reg_2964;
471 u32 reg_2968;
472 u32 reg_296c;
473
474 u32 reg_2970;
475
476 int v_filter_1;
477 int v_filter_2;
478 int h_filter;
479
480 u8 track_osd;
481
482 u32 osd_x_offset;
483 u32 osd_y_offset;
484
485 u32 osd_x_pan;
486 u32 osd_y_pan;
487
488 u32 osd_vis_w;
489 u32 osd_vis_h;
490
491 u32 osd_full_w;
492 u32 osd_full_h;
493
494 int decode_height;
495
496 int lace_mode;
497 int lace_threshold;
498 int lace_sync_field;
499
500 atomic_t next_dma_frame;
501 atomic_t next_fill_frame;
502
503 u32 yuv_forced_update;
504 int update_frame;
505
506 u8 fields_lapsed;
507
508 struct yuv_frame_info new_frame_info[IVTV_YUV_BUFFERS];
509 struct yuv_frame_info old_frame_info;
510 struct yuv_frame_info old_frame_info_args;
511
512 void *blanking_ptr;
513 dma_addr_t blanking_dmaptr;
514
515 int stream_size;
516
517 u8 draw_frame;
518 u8 max_frames_buffered;
519
520 struct v4l2_rect main_rect;
521 u32 v4l2_src_w;
522 u32 v4l2_src_h;
523
524 u8 running;
525};
526
527#define IVTV_VBI_FRAMES 32
528
529
530struct vbi_cc {
531 u8 odd[2];
532 u8 even[2]; ;
533};
534
535struct vbi_vps {
536 u8 data[5];
537};
538
539struct vbi_info {
540
541
542 u32 raw_decoder_line_size;
543 u8 raw_decoder_sav_odd_field;
544 u8 raw_decoder_sav_even_field;
545 u32 sliced_decoder_line_size;
546 u8 sliced_decoder_sav_odd_field;
547 u8 sliced_decoder_sav_even_field;
548
549 u32 start[2];
550 u32 count;
551 u32 raw_size;
552 u32 sliced_size;
553
554 u32 dec_start;
555 u32 enc_start;
556 u32 enc_size;
557 int fpi;
558
559 struct v4l2_format in;
560 struct v4l2_sliced_vbi_format *sliced_in;
561 int insert_mpeg;
562
563
564
565 u32 frame;
566
567
568
569
570 struct vbi_cc cc_payload[256];
571
572
573 int cc_payload_idx;
574 u8 cc_missing_cnt;
575 int wss_payload;
576 u8 wss_missing_cnt;
577 struct vbi_vps vps_payload;
578
579
580
581 struct v4l2_sliced_vbi_data sliced_data[36];
582 struct v4l2_sliced_vbi_data sliced_dec_data[36];
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599 u8 *sliced_mpeg_data[IVTV_VBI_FRAMES];
600 u32 sliced_mpeg_size[IVTV_VBI_FRAMES];
601 struct ivtv_buffer sliced_mpeg_buf;
602 u32 inserted_frame;
603
604};
605
606
607struct ivtv_card;
608
609
610struct ivtv {
611
612 struct pci_dev *pdev;
613 const struct ivtv_card *card;
614 const char *card_name;
615 const struct ivtv_card_tuner_i2c *card_i2c;
616 u8 has_cx23415;
617 u8 pvr150_workaround;
618 u8 nof_inputs;
619 u8 nof_audio_inputs;
620 u32 v4l2_cap;
621 u32 hw_flags;
622 v4l2_std_id tuner_std;
623 struct v4l2_subdev *sd_video;
624 struct v4l2_subdev *sd_audio;
625 struct v4l2_subdev *sd_muxer;
626 resource_size_t base_addr;
627 volatile void __iomem *enc_mem;
628 volatile void __iomem *dec_mem;
629 volatile void __iomem *reg_mem;
630 struct ivtv_options options;
631
632 struct v4l2_device v4l2_dev;
633 struct cx2341x_handler cxhdl;
634 struct {
635
636 struct v4l2_ctrl *ctrl_pts;
637 struct v4l2_ctrl *ctrl_frame;
638 };
639 struct {
640
641 struct v4l2_ctrl *ctrl_audio_playback;
642 struct v4l2_ctrl *ctrl_audio_multilingual_playback;
643 };
644 struct v4l2_ctrl_handler hdl_gpio;
645 struct v4l2_subdev sd_gpio;
646 u16 instance;
647
648
649 unsigned long i_flags;
650 u8 is_50hz;
651 u8 is_60hz ;
652 u8 is_out_50hz ;
653 u8 is_out_60hz ;
654 int output_mode;
655 u32 audio_input;
656 u32 active_input;
657 u32 active_output;
658 v4l2_std_id std;
659 v4l2_std_id std_out;
660 u8 audio_stereo_mode;
661 u8 audio_bilingual_mode;
662
663
664 spinlock_t lock;
665 struct mutex serialize_lock;
666
667
668 int stream_buf_size[IVTV_MAX_STREAMS];
669 struct ivtv_stream streams[IVTV_MAX_STREAMS];
670 atomic_t capturing;
671 atomic_t decoding;
672
673
674 struct snd_ivtv_card *alsa;
675 void (*pcm_announce_callback)(struct snd_ivtv_card *card, u8 *pcm_data,
676 size_t num_bytes);
677
678
679 struct work_struct request_module_wk;
680
681
682 u32 irqmask;
683 u32 irq_rr_idx;
684 struct kthread_worker irq_worker;
685 struct task_struct *irq_worker_task;
686 struct kthread_work irq_work;
687 spinlock_t dma_reg_lock;
688 int cur_dma_stream;
689 int cur_pio_stream;
690 u32 dma_data_req_offset;
691 u32 dma_data_req_size;
692 int dma_retries;
693 struct ivtv_user_dma udma;
694 struct timer_list dma_timer;
695 u32 last_vsync_field;
696 wait_queue_head_t dma_waitq;
697 wait_queue_head_t eos_waitq;
698 wait_queue_head_t event_waitq;
699 wait_queue_head_t vsync_waitq;
700
701
702
703 struct ivtv_mailbox_data enc_mbox;
704 struct ivtv_mailbox_data dec_mbox;
705 struct ivtv_api_cache api_cache[256];
706
707
708
709 struct i2c_adapter i2c_adap;
710 struct i2c_algo_bit_data i2c_algo;
711 struct i2c_client i2c_client;
712 int i2c_state;
713 struct mutex i2c_bus_lock;
714
715 struct IR_i2c_init_data ir_i2c_init_data;
716
717
718 u32 pgm_info_offset;
719 u32 pgm_info_num;
720 u32 pgm_info_write_idx;
721 u32 pgm_info_read_idx;
722 struct v4l2_enc_idx_entry pgm_info[IVTV_MAX_PGM_INDEX];
723
724
725
726 u32 open_id;
727 int search_pack_header;
728 int speed;
729 u8 speed_mute_audio;
730 u64 mpg_data_received;
731 u64 vbi_data_inserted;
732 u32 last_dec_timing[3];
733 unsigned long dualwatch_jiffies;
734 u32 dualwatch_stereo_mode;
735
736
737
738 struct vbi_info vbi;
739
740
741
742 struct yuv_playback_info yuv_info;
743
744
745
746 unsigned long osd_video_pbase;
747 int osd_global_alpha_state;
748 int osd_local_alpha_state;
749 int osd_chroma_key_state;
750 u8 osd_global_alpha;
751 u32 osd_chroma_key;
752 struct v4l2_rect osd_rect;
753 struct v4l2_rect main_rect;
754 struct osd_info *osd_info;
755 void (*ivtvfb_restore)(struct ivtv *itv);
756};
757
758static inline struct ivtv *to_ivtv(struct v4l2_device *v4l2_dev)
759{
760 return container_of(v4l2_dev, struct ivtv, v4l2_dev);
761}
762
763
764extern int (*ivtv_ext_init)(struct ivtv *);
765
766
767extern int ivtv_first_minor;
768
769
770
771
772void ivtv_set_irq_mask(struct ivtv *itv, u32 mask);
773void ivtv_clear_irq_mask(struct ivtv *itv, u32 mask);
774
775
776int ivtv_set_output_mode(struct ivtv *itv, int mode);
777
778
779struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv);
780
781
782int ivtv_msleep_timeout(unsigned int msecs, int intr);
783
784
785int ivtv_waitq(wait_queue_head_t *waitq);
786
787
788struct tveeprom;
789void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv);
790
791
792int ivtv_init_on_first_open(struct ivtv *itv);
793
794
795static inline int ivtv_raw_vbi(const struct ivtv *itv)
796{
797 return itv->vbi.in.type == V4L2_BUF_TYPE_VBI_CAPTURE;
798}
799
800
801
802
803
804
805
806
807
808
809#define write_sync(val, reg) \
810 do { writel(val, reg); readl(reg); } while (0)
811
812#define read_reg(reg) readl(itv->reg_mem + (reg))
813#define write_reg(val, reg) writel(val, itv->reg_mem + (reg))
814#define write_reg_sync(val, reg) \
815 do { write_reg(val, reg); read_reg(reg); } while (0)
816
817#define read_enc(addr) readl(itv->enc_mem + (u32)(addr))
818#define write_enc(val, addr) writel(val, itv->enc_mem + (u32)(addr))
819#define write_enc_sync(val, addr) \
820 do { write_enc(val, addr); read_enc(addr); } while (0)
821
822#define read_dec(addr) readl(itv->dec_mem + (u32)(addr))
823#define write_dec(val, addr) writel(val, itv->dec_mem + (u32)(addr))
824#define write_dec_sync(val, addr) \
825 do { write_dec(val, addr); read_dec(addr); } while (0)
826
827
828
829#define ivtv_call_hw(itv, hw, o, f, args...) \
830 do { \
831 struct v4l2_subdev *__sd; \
832 __v4l2_device_call_subdevs_p(&(itv)->v4l2_dev, __sd, \
833 !(hw) ? true : (__sd->grp_id & (hw)), \
834 o, f, ##args); \
835 } while (0)
836
837#define ivtv_call_all(itv, o, f, args...) ivtv_call_hw(itv, 0, o, f , ##args)
838
839
840
841
842#define ivtv_call_hw_err(itv, hw, o, f, args...) \
843({ \
844 struct v4l2_subdev *__sd; \
845 __v4l2_device_call_subdevs_until_err_p(&(itv)->v4l2_dev, __sd, \
846 !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \
847})
848
849#define ivtv_call_all_err(itv, o, f, args...) ivtv_call_hw_err(itv, 0, o, f , ##args)
850
851#endif
852