aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-08-23 09:13:15 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:06:48 -0400
commitfd8b281a2809d2bd9119df1fbd717ab2371297cd (patch)
treec5ebdbc3ba9febddded3d4cddd4deb0e75b9c027 /drivers/media
parent33c0fcad2160bc211272295e862c6f708118d006 (diff)
V4L/DVB (6093): ivtv: reorganized and cleanup ivtv struct
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c15
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h243
-rw-r--r--drivers/media/video/ivtv/ivtv-fb.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c10
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c12
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c19
6 files changed, 152 insertions, 149 deletions
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 6a74e509c87d..855697c1c968 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -667,7 +667,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
667 cx2341x_fill_defaults(&itv->params); 667 cx2341x_fill_defaults(&itv->params);
668 itv->params.port = CX2341X_PORT_MEMORY; 668 itv->params.port = CX2341X_PORT_MEMORY;
669 itv->params.capabilities = CX2341X_CAP_HAS_SLICED_VBI; 669 itv->params.capabilities = CX2341X_CAP_HAS_SLICED_VBI;
670 init_waitqueue_head(&itv->cap_w); 670 init_waitqueue_head(&itv->eos_waitq);
671 init_waitqueue_head(&itv->event_waitq); 671 init_waitqueue_head(&itv->event_waitq);
672 init_waitqueue_head(&itv->vsync_waitq); 672 init_waitqueue_head(&itv->vsync_waitq);
673 init_waitqueue_head(&itv->dma_waitq); 673 init_waitqueue_head(&itv->dma_waitq);
@@ -713,14 +713,6 @@ static void __devinit ivtv_init_struct2(struct ivtv *itv)
713 break; 713 break;
714 itv->nof_audio_inputs = i; 714 itv->nof_audio_inputs = i;
715 715
716 /* 0x00EF = saa7114(239) 0x00F0 = saa7115(240) 0x0106 = micro */
717 if (itv->card->hw_all & (IVTV_HW_SAA7115 | IVTV_HW_SAA717X))
718 itv->digitizer = 0xF1;
719 else if (itv->card->hw_all & IVTV_HW_SAA7114)
720 itv->digitizer = 0xEF;
721 else /* cx25840 */
722 itv->digitizer = 0x140;
723
724 if (itv->card->hw_all & IVTV_HW_CX25840) { 716 if (itv->card->hw_all & IVTV_HW_CX25840) {
725 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */ 717 itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */
726 } else { 718 } else {
@@ -749,6 +741,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
749 const struct pci_device_id *pci_id) 741 const struct pci_device_id *pci_id)
750{ 742{
751 u16 cmd; 743 u16 cmd;
744 u8 card_rev;
752 unsigned char pci_latency; 745 unsigned char pci_latency;
753 746
754 IVTV_DEBUG_INFO("Enabling pci device\n"); 747 IVTV_DEBUG_INFO("Enabling pci device\n");
@@ -795,7 +788,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
795 } 788 }
796 IVTV_DEBUG_INFO("Bus Mastering Enabled.\n"); 789 IVTV_DEBUG_INFO("Bus Mastering Enabled.\n");
797 790
798 pci_read_config_byte(dev, PCI_CLASS_REVISION, &itv->card_rev); 791 pci_read_config_byte(dev, PCI_CLASS_REVISION, &card_rev);
799 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); 792 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
800 793
801 if (pci_latency < 64 && ivtv_pci_latency) { 794 if (pci_latency < 64 && ivtv_pci_latency) {
@@ -812,7 +805,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
812 805
813 IVTV_DEBUG_INFO("%d (rev %d) at %02x:%02x.%x, " 806 IVTV_DEBUG_INFO("%d (rev %d) at %02x:%02x.%x, "
814 "irq: %d, latency: %d, memory: 0x%lx\n", 807 "irq: %d, latency: %d, memory: 0x%lx\n",
815 itv->dev->device, itv->card_rev, dev->bus->number, 808 itv->dev->device, card_rev, dev->bus->number,
816 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), 809 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
817 itv->dev->irq, pci_latency, (unsigned long)itv->base_addr); 810 itv->dev->irq, pci_latency, (unsigned long)itv->base_addr);
818 811
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index b9dfdab66362..2c27515d8731 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -550,133 +550,134 @@ struct ivtv_card;
550 550
551/* Struct to hold info about ivtv cards */ 551/* Struct to hold info about ivtv cards */
552struct ivtv { 552struct ivtv {
553 int num; /* board number, -1 during init! */ 553 /* General fixed card data */
554 char name[8]; /* board name for printk and interrupts (e.g. 'ivtv0') */ 554 int num; /* board number, -1 during init! */
555 struct pci_dev *dev; /* PCI device */ 555 char name[8]; /* board name for printk and interrupts (e.g. 'ivtv0') */
556 struct pci_dev *dev; /* PCI device */
556 const struct ivtv_card *card; /* card information */ 557 const struct ivtv_card *card; /* card information */
557 const char *card_name; /* full name of the card */ 558 const char *card_name; /* full name of the card */
558 u8 has_cx23415; /* 1 if it is a cx23415 based card, 0 for cx23416 */ 559 u8 has_cx23415; /* 1 if it is a cx23415 based card, 0 for cx23416 */
559 u8 is_50hz; 560 u8 pvr150_workaround; /* 1 if the cx25840 needs to workaround a PVR150 bug */
560 u8 is_60hz; 561 u8 nof_inputs; /* number of video inputs */
561 u8 is_out_50hz; 562 u8 nof_audio_inputs; /* number of audio inputs */
562 u8 is_out_60hz; 563 u32 v4l2_cap; /* V4L2 capabilities of card */
563 u8 pvr150_workaround; /* 1 if the cx25840 needs to workaround a PVR150 bug */ 564 u32 hw_flags; /* hardware description of the board */
564 u8 nof_inputs; /* number of video inputs */ 565 int tunerid; /* userspace tuner ID for experimental Xceive tuner support */
565 u8 nof_audio_inputs; /* number of audio inputs */ 566 v4l2_std_id tuner_std; /* the norm of the card's tuner (fixed) */
566 u32 v4l2_cap; /* V4L2 capabilities of card */ 567 /* controlling video decoder function */
567 u32 hw_flags; /* Hardware description of the board */
568 int tunerid; /* Userspace tuner ID for experimental Xceive tuner support */
569
570 /* controlling Video decoder function */
571 int (*video_dec_func)(struct ivtv *, unsigned int, void *); 568 int (*video_dec_func)(struct ivtv *, unsigned int, void *);
569 u32 base_addr; /* PCI resource base address */
570 volatile void __iomem *enc_mem; /* pointer to mapped encoder memory */
571 volatile void __iomem *dec_mem; /* pointer to mapped decoder memory */
572 volatile void __iomem *reg_mem; /* pointer to mapped registers */
573 struct ivtv_options options; /* user options */
574
575
576 /* High-level state info */
577 unsigned long i_flags; /* global ivtv flags */
578 u8 is_50hz; /* 1 if the current capture standard is 50 Hz */
579 u8 is_60hz /* 1 if the current capture standard is 60 Hz */;
580 u8 is_out_50hz /* 1 if the current TV output standard is 50 Hz */;
581 u8 is_out_60hz /* 1 if the current TV output standard is 60 Hz */;
582 int output_mode; /* decoder output mode: NONE, MPG, YUV, UDMA YUV, passthrough */
583 u32 audio_input; /* current audio input */
584 u32 active_input; /* current video input */
585 u32 active_output; /* current video output */
586 v4l2_std_id std; /* current capture TV standard */
587 v4l2_std_id std_out; /* current TV output standard */
588 u8 audio_stereo_mode; /* decoder setting how to handle stereo MPEG audio */
589 u8 audio_bilingual_mode; /* decoder setting how to handle bilingual MPEG audio */
590 struct cx2341x_mpeg_params params; /* current encoder parameters */
591
592
593 /* Locking */
594 spinlock_t lock; /* lock access to this struct */
595 /* mutex used to serialize open/close/start/stop/ioctl operations */
596 struct mutex serialize_lock;
597
598
599 /* Streams */
600 int stream_buf_size[IVTV_MAX_STREAMS]; /* stream buffer size */
601 struct ivtv_stream streams[IVTV_MAX_STREAMS]; /* stream data */
602 atomic_t capturing; /* count number of active capture streams */
603 atomic_t decoding; /* count number of active decoding streams */
604
605
606 /* Interrupts & DMA */
607 u32 irqmask; /* active interrupts */
608 u32 irq_rr_idx; /* round-robin stream index */
609 struct workqueue_struct *irq_work_queues; /* workqueue for PIO/YUV/VBI actions */
610 struct work_struct irq_work_queue; /* work entry */
611 spinlock_t dma_reg_lock; /* lock access to DMA engine registers */
612 int cur_dma_stream; /* index of current stream doing DMA (-1 if none) */
613 int cur_pio_stream; /* index of current stream doing PIO (-1 if none) */
614 u32 dma_data_req_offset; /* store offset in decoder memory of current DMA request */
615 u32 dma_data_req_size; /* store size of current DMA request */
616 int dma_retries; /* current DMA retry attempt */
617 struct ivtv_user_dma udma; /* user based DMA for OSD */
618 struct timer_list dma_timer; /* timer used to catch unfinished DMAs */
619 u32 last_vsync_frame; /* last seen vsync field */
620 wait_queue_head_t dma_waitq; /* wake up when the current DMA is finished */
621 wait_queue_head_t eos_waitq; /* wake up when EOS arrives */
622 wait_queue_head_t event_waitq; /* wake up when the next decoder event arrives */
623 wait_queue_head_t vsync_waitq; /* wake up when the next decoder vsync arrives */
624
625
626 /* Mailbox */
627 struct ivtv_mailbox_data enc_mbox; /* encoder mailboxes */
628 struct ivtv_mailbox_data dec_mbox; /* decoder mailboxes */
629 struct ivtv_api_cache api_cache[256]; /* cached API commands */
630
631
632 /* I2C */
633 struct i2c_adapter i2c_adap;
634 struct i2c_algo_bit_data i2c_algo;
635 struct i2c_client i2c_client;
636 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];/* pointers to all I2C clients */
637 int i2c_state; /* i2c bit state */
638 struct mutex i2c_bus_lock; /* lock i2c bus */
639
640
641 /* Program Index information */
642 u32 pgm_info_offset; /* start of pgm info in encoder memory */
643 u32 pgm_info_num; /* number of elements in the pgm cyclic buffer in encoder memory */
644 u32 pgm_info_write_idx; /* last index written by the card that was transferred to pgm_info[] */
645 u32 pgm_info_read_idx; /* last index in pgm_info read by the application */
646 struct v4l2_enc_idx_entry pgm_info[IVTV_MAX_PGM_INDEX]; /* filled from the pgm cyclic buffer on the card */
647
648
649 /* Miscellaneous */
650 u32 open_id; /* incremented each time an open occurs, is >= 1 */
651 struct v4l2_prio_state prio; /* priority state */
652 int search_pack_header; /* 1 if ivtv_copy_buf_to_user() is scanning for a pack header (0xba) */
653 int speed; /* current playback speed setting */
654 u8 speed_mute_audio; /* 1 if audio should be muted when fast forward */
655 u64 mpg_data_received; /* number of bytes received from the MPEG stream */
656 u64 vbi_data_inserted; /* number of VBI bytes inserted into the MPEG stream */
657 u32 last_dec_timing[3]; /* cache last retrieved pts/scr/frame values */
658 unsigned long dualwatch_jiffies;/* jiffies value of the previous dualwatch check */
659 u16 dualwatch_stereo_mode; /* current detected dualwatch stereo mode */
660
661
662 /* VBI state info */
663 struct vbi_info vbi; /* VBI-specific data */
664
665
666 /* YUV playback */
667 struct yuv_playback_info yuv_info; /* YUV playback data */
572 668
573 struct ivtv_options options; /* User options */
574 int stream_buf_size[IVTV_MAX_STREAMS]; /* Stream buffer size */
575 struct ivtv_stream streams[IVTV_MAX_STREAMS]; /* Stream data */
576 int speed;
577 u8 speed_mute_audio;
578 unsigned long i_flags; /* global ivtv flags */
579 atomic_t capturing; /* count number of active capture streams */
580 atomic_t decoding; /* count number of active decoding streams */
581 u32 irq_rr_idx; /* Round-robin stream index */
582 int cur_dma_stream; /* index of stream doing DMA */
583 int cur_pio_stream; /* index of stream doing PIO */
584 u32 dma_data_req_offset;
585 u32 dma_data_req_size;
586 int dma_retries;
587 int output_mode; /* NONE, MPG, YUV, UDMA YUV, passthrough */
588 spinlock_t lock; /* lock access to this struct */
589 int search_pack_header;
590
591 spinlock_t dma_reg_lock; /* lock access to DMA engine registers */
592 struct mutex serialize_lock; /* lock used to serialize starting streams */
593
594 /* User based DMA for OSD */
595 struct ivtv_user_dma udma;
596
597 int open_id; /* incremented each time an open occurs, used as unique ID.
598 starts at 1, so 0 can be used as uninitialized value
599 in the stream->id. */
600
601 u32 base_addr;
602 u32 irqmask;
603
604 struct v4l2_prio_state prio;
605 struct workqueue_struct *irq_work_queues;
606 struct work_struct irq_work_queue;
607 struct timer_list dma_timer; /* Timer used to catch unfinished DMAs */
608
609 struct vbi_info vbi;
610
611 struct ivtv_mailbox_data enc_mbox;
612 struct ivtv_mailbox_data dec_mbox;
613 struct ivtv_api_cache api_cache[256]; /* Cached API Commands */
614
615 u8 card_rev;
616 volatile void __iomem *enc_mem, *dec_mem, *reg_mem;
617
618 u32 pgm_info_offset;
619 u32 pgm_info_num;
620 u32 pgm_info_write_idx;
621 u32 pgm_info_read_idx;
622 struct v4l2_enc_idx_entry pgm_info[IVTV_MAX_PGM_INDEX];
623
624 u64 mpg_data_received;
625 u64 vbi_data_inserted;
626
627 wait_queue_head_t cap_w;
628 /* when the next decoder event arrives this queue is woken up */
629 wait_queue_head_t event_waitq;
630 /* when the next decoder vsync arrives this queue is woken up */
631 wait_queue_head_t vsync_waitq;
632 /* when the current DMA is finished this queue is woken up */
633 wait_queue_head_t dma_waitq;
634 669
635 /* OSD support */ 670 /* OSD support */
636 unsigned long osd_video_pbase; 671 unsigned long osd_video_pbase;
637 int osd_global_alpha_state; /* 0=off : 1=on */ 672 int osd_global_alpha_state; /* 1 = global alpha is on */
638 int osd_local_alpha_state; /* 0=off : 1=on */ 673 int osd_local_alpha_state; /* 1 = local alpha is on */
639 int osd_color_key_state; /* 0=off : 1=on */ 674 int osd_chroma_key_state; /* 1 = chroma-keying is on */
640 u8 osd_global_alpha; /* Current global alpha */ 675 u8 osd_global_alpha; /* current global alpha */
641 u32 osd_color_key; /* Current color key */ 676 u32 osd_chroma_key; /* current chroma key */
642 u32 osd_pixelformat; /* Current pixel format */ 677 u32 osd_pixelformat; /* current pixel format */
643 struct v4l2_rect osd_rect; /* Current OSD position and size */ 678 struct v4l2_rect osd_rect; /* current OSD position and size */
644 struct v4l2_rect main_rect; /* Current Main window position and size */ 679 struct v4l2_rect main_rect; /* current Main window position and size */
645 680 struct osd_info *osd_info; /* ivtv-fb private OSD info */
646 u32 last_dec_timing[3]; /* Store last retrieved pts/scr/frame values */
647
648 /* i2c */
649 struct i2c_adapter i2c_adap;
650 struct i2c_algo_bit_data i2c_algo;
651 struct i2c_client i2c_client;
652 struct mutex i2c_bus_lock;
653 int i2c_state;
654 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
655
656 /* v4l2 and User settings */
657
658 /* codec settings */
659 struct cx2341x_mpeg_params params;
660 u32 audio_input;
661 u32 active_input;
662 u32 active_output;
663 v4l2_std_id std;
664 v4l2_std_id std_out;
665 v4l2_std_id tuner_std; /* The norm of the tuner (fixed) */
666 u8 audio_stereo_mode;
667 u8 audio_bilingual_mode;
668
669 /* dualwatch */
670 unsigned long dualwatch_jiffies;
671 u16 dualwatch_stereo_mode;
672
673 /* Digitizer type */
674 int digitizer; /* 0x00EF = saa7114 0x00FO = saa7115 0x0106 = mic */
675
676 u32 lastVsyncFrame;
677
678 struct yuv_playback_info yuv_info;
679 struct osd_info *osd_info;
680}; 681};
681 682
682/* Globals */ 683/* Globals */
diff --git a/drivers/media/video/ivtv/ivtv-fb.c b/drivers/media/video/ivtv/ivtv-fb.c
index 2c521d1bb057..f5ed2cf1cd87 100644
--- a/drivers/media/video/ivtv/ivtv-fb.c
+++ b/drivers/media/video/ivtv/ivtv-fb.c
@@ -405,7 +405,7 @@ static int ivtvfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long ar
405 if (itv->is_50hz && trace > 312) trace -= 312; 405 if (itv->is_50hz && trace > 312) trace -= 312;
406 else if (itv->is_60hz && trace > 262) trace -= 262; 406 else if (itv->is_60hz && trace > 262) trace -= 262;
407 if (trace == 1) vblank.flags |= FB_VBLANK_VSYNCING; 407 if (trace == 1) vblank.flags |= FB_VBLANK_VSYNCING;
408 vblank.count = itv->lastVsyncFrame; 408 vblank.count = itv->last_vsync_frame;
409 vblank.vcount = trace; 409 vblank.vcount = trace;
410 vblank.hcount = 0; 410 vblank.hcount = 0;
411 if (copy_to_user((void __user *)arg, &vblank, sizeof(vblank))) 411 if (copy_to_user((void __user *)arg, &vblank, sizeof(vblank)))
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index f4f56a6e1f81..01215a1c4b82 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -163,7 +163,7 @@ void ivtv_set_osd_alpha(struct ivtv *itv)
163{ 163{
164 ivtv_vapi(itv, CX2341X_OSD_SET_GLOBAL_ALPHA, 3, 164 ivtv_vapi(itv, CX2341X_OSD_SET_GLOBAL_ALPHA, 3,
165 itv->osd_global_alpha_state, itv->osd_global_alpha, !itv->osd_local_alpha_state); 165 itv->osd_global_alpha_state, itv->osd_global_alpha, !itv->osd_local_alpha_state);
166 ivtv_vapi(itv, CX2341X_OSD_SET_CHROMA_KEY, 2, itv->osd_color_key_state, itv->osd_color_key); 166 ivtv_vapi(itv, CX2341X_OSD_SET_CHROMA_KEY, 2, itv->osd_chroma_key_state, itv->osd_chroma_key);
167} 167}
168 168
169int ivtv_set_speed(struct ivtv *itv, int speed) 169int ivtv_set_speed(struct ivtv *itv, int speed)
@@ -426,7 +426,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
426 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 426 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
427 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 427 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
428 return -EINVAL; 428 return -EINVAL;
429 fmt->fmt.win.chromakey = itv->osd_color_key; 429 fmt->fmt.win.chromakey = itv->osd_chroma_key;
430 fmt->fmt.win.global_alpha = itv->osd_global_alpha; 430 fmt->fmt.win.global_alpha = itv->osd_global_alpha;
431 break; 431 break;
432 432
@@ -546,7 +546,7 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
546 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 546 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
547 return -EINVAL; 547 return -EINVAL;
548 if (set_fmt) { 548 if (set_fmt) {
549 itv->osd_color_key = fmt->fmt.win.chromakey; 549 itv->osd_chroma_key = fmt->fmt.win.chromakey;
550 itv->osd_global_alpha = fmt->fmt.win.global_alpha; 550 itv->osd_global_alpha = fmt->fmt.win.global_alpha;
551 ivtv_set_osd_alpha(itv); 551 ivtv_set_osd_alpha(itv);
552 } 552 }
@@ -1197,7 +1197,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1197 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; 1197 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
1198 if (itv->osd_local_alpha_state) 1198 if (itv->osd_local_alpha_state)
1199 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; 1199 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
1200 if (itv->osd_color_key_state) 1200 if (itv->osd_chroma_key_state)
1201 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; 1201 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY;
1202 break; 1202 break;
1203 } 1203 }
@@ -1209,7 +1209,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1209 return -EINVAL; 1209 return -EINVAL;
1210 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; 1210 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
1211 itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; 1211 itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0;
1212 itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; 1212 itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
1213 ivtv_set_osd_alpha(itv); 1213 ivtv_set_osd_alpha(itv);
1214 break; 1214 break;
1215 } 1215 }
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index b6a94a1ad19b..4ec3df58e247 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -750,8 +750,8 @@ static void ivtv_irq_vsync(struct ivtv *itv)
750 if (0) IVTV_DEBUG_IRQ("DEC VSYNC\n"); 750 if (0) IVTV_DEBUG_IRQ("DEC VSYNC\n");
751 751
752 if (((frame ^ itv->yuv_info.sync_field[last_dma_frame]) == 0 && 752 if (((frame ^ itv->yuv_info.sync_field[last_dma_frame]) == 0 &&
753 ((itv->lastVsyncFrame & 1) ^ itv->yuv_info.sync_field[last_dma_frame])) || 753 ((itv->last_vsync_frame & 1) ^ itv->yuv_info.sync_field[last_dma_frame])) ||
754 (frame != (itv->lastVsyncFrame & 1) && !itv->yuv_info.frame_interlaced)) { 754 (frame != (itv->last_vsync_frame & 1) && !itv->yuv_info.frame_interlaced)) {
755 int next_dma_frame = last_dma_frame; 755 int next_dma_frame = last_dma_frame;
756 756
757 if (!(itv->yuv_info.frame_interlaced && itv->yuv_info.field_delay[next_dma_frame] && itv->yuv_info.fields_lapsed < 1)) { 757 if (!(itv->yuv_info.frame_interlaced && itv->yuv_info.field_delay[next_dma_frame] && itv->yuv_info.fields_lapsed < 1)) {
@@ -766,10 +766,10 @@ static void ivtv_irq_vsync(struct ivtv *itv)
766 } 766 }
767 } 767 }
768 } 768 }
769 if (frame != (itv->lastVsyncFrame & 1)) { 769 if (frame != (itv->last_vsync_frame & 1)) {
770 struct ivtv_stream *s = ivtv_get_output_stream(itv); 770 struct ivtv_stream *s = ivtv_get_output_stream(itv);
771 771
772 itv->lastVsyncFrame += 1; 772 itv->last_vsync_frame += 1;
773 if (frame == 0) { 773 if (frame == 0) {
774 clear_bit(IVTV_F_I_VALID_DEC_TIMINGS, &itv->i_flags); 774 clear_bit(IVTV_F_I_VALID_DEC_TIMINGS, &itv->i_flags);
775 clear_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags); 775 clear_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags);
@@ -834,7 +834,7 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
834 */ 834 */
835 if (~itv->irqmask & IVTV_IRQ_DEC_VSYNC) { 835 if (~itv->irqmask & IVTV_IRQ_DEC_VSYNC) {
836 /* vsync is enabled, see if we're in a new field */ 836 /* vsync is enabled, see if we're in a new field */
837 if ((itv->lastVsyncFrame & 1) != (read_reg(0x28c0) & 1)) { 837 if ((itv->last_vsync_frame & 1) != (read_reg(0x28c0) & 1)) {
838 /* New field, looks like we missed it */ 838 /* New field, looks like we missed it */
839 IVTV_DEBUG_YUV("VSync interrupt missed %d\n",read_reg(0x28c0)>>16); 839 IVTV_DEBUG_YUV("VSync interrupt missed %d\n",read_reg(0x28c0)>>16);
840 vsync_force = 1; 840 vsync_force = 1;
@@ -888,7 +888,7 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
888 if (combo & IVTV_IRQ_ENC_EOS) { 888 if (combo & IVTV_IRQ_ENC_EOS) {
889 IVTV_DEBUG_IRQ("ENC EOS\n"); 889 IVTV_DEBUG_IRQ("ENC EOS\n");
890 set_bit(IVTV_F_I_EOS, &itv->i_flags); 890 set_bit(IVTV_F_I_EOS, &itv->i_flags);
891 wake_up(&itv->cap_w); 891 wake_up(&itv->eos_waitq);
892 } 892 }
893 893
894 if (combo & IVTV_IRQ_DEC_DATA_REQ) { 894 if (combo & IVTV_IRQ_DEC_DATA_REQ) {
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 3939a804f043..e05af62a8cd5 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -404,8 +404,8 @@ static void ivtv_vbi_setup(struct ivtv *itv)
404 if (!itv->vbi.fpi) 404 if (!itv->vbi.fpi)
405 itv->vbi.fpi = 1; 405 itv->vbi.fpi = 1;
406 406
407 IVTV_DEBUG_INFO("Setup VBI start 0x%08x frames %d fpi %d lines 0x%08x\n", 407 IVTV_DEBUG_INFO("Setup VBI start 0x%08x frames %d fpi %d\n",
408 itv->vbi.enc_start, data[1], itv->vbi.fpi, itv->digitizer); 408 itv->vbi.enc_start, data[1], itv->vbi.fpi);
409 409
410 /* select VBI lines. 410 /* select VBI lines.
411 Note that the sliced argument seems to have no effect. */ 411 Note that the sliced argument seems to have no effect. */
@@ -494,6 +494,8 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
494 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); 494 clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags);
495 495
496 if (atomic_read(&itv->capturing) == 0) { 496 if (atomic_read(&itv->capturing) == 0) {
497 int digitizer;
498
497 /* Always use frame based mode. Experiments have demonstrated that byte 499 /* Always use frame based mode. Experiments have demonstrated that byte
498 stream based mode results in dropped frames and corruption. Not often, 500 stream based mode results in dropped frames and corruption. Not often,
499 but occasionally. Many thanks go to Leonard Orb who spent a lot of 501 but occasionally. Many thanks go to Leonard Orb who spent a lot of
@@ -519,7 +521,14 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
519 ivtv_vapi(itv, CX2341X_ENC_SET_PLACEHOLDER, 12, 521 ivtv_vapi(itv, CX2341X_ENC_SET_PLACEHOLDER, 12,
520 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 522 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
521 523
522 ivtv_vapi(itv, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, itv->digitizer, itv->digitizer); 524 if (itv->card->hw_all & (IVTV_HW_SAA7115 | IVTV_HW_SAA717X))
525 digitizer = 0xF1;
526 else if (itv->card->hw_all & IVTV_HW_SAA7114)
527 digitizer = 0xEF;
528 else /* cx25840 */
529 digitizer = 0x140;
530
531 ivtv_vapi(itv, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, digitizer, digitizer);
523 532
524 /* Setup VBI */ 533 /* Setup VBI */
525 if (itv->v4l2_cap & V4L2_CAP_VBI_CAPTURE) { 534 if (itv->v4l2_cap & V4L2_CAP_VBI_CAPTURE) {
@@ -761,7 +770,7 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
761 unsigned long duration; 770 unsigned long duration;
762 771
763 then = jiffies; 772 then = jiffies;
764 add_wait_queue(&itv->cap_w, &wait); 773 add_wait_queue(&itv->eos_waitq, &wait);
765 774
766 set_current_state(TASK_INTERRUPTIBLE); 775 set_current_state(TASK_INTERRUPTIBLE);
767 776
@@ -787,7 +796,7 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
787 IVTV_DEBUG_INFO("%s: EOS took %lu ms to occur.\n", s->name, duration); 796 IVTV_DEBUG_INFO("%s: EOS took %lu ms to occur.\n", s->name, duration);
788 } 797 }
789 set_current_state(TASK_RUNNING); 798 set_current_state(TASK_RUNNING);
790 remove_wait_queue(&itv->cap_w, &wait); 799 remove_wait_queue(&itv->eos_waitq, &wait);
791 } 800 }
792 801
793 then = jiffies; 802 then = jiffies;