Skip to content

Commit

Permalink
V4L/DVB (6116): ivtv: VBI cleanups and fixes
Browse files Browse the repository at this point in the history
Besides some VBI cleanups this patch also fixes a subtle problem with the
VBI re-insertion stream where the PIO work handler wasn't called quickly
enough, resulting in occasional corrupt data.

Furthermore the CC output didn't disable CC correctly and at the right time,
causing duplicates to be sent.

An saa7127 fix for VPS output was also added: the wrong data was sent.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Oct 10, 2007
1 parent 26e9d59 commit 2f3a989
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 187 deletions.
26 changes: 17 additions & 9 deletions drivers/media/video/ivtv/ivtv-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,15 @@ struct yuv_playback_info
#define IVTV_VBI_FRAMES 32

/* VBI data */
struct vbi_cc {
u8 odd[2]; /* two-byte payload of odd field */
u8 even[2]; /* two-byte payload of even field */;
};

struct vbi_vps {
u8 data[5]; /* five-byte VPS payload */
};

struct vbi_info {
/* VBI general fixed card data */
u32 raw_decoder_line_size; /* raw VBI line size from digitizer */
Expand All @@ -502,15 +511,14 @@ struct vbi_info {
u32 enc_start, enc_size;
int fpi;
u32 frame;
u8 cc_data_odd[256];
u8 cc_data_even[256];
int cc_pos;
u8 cc_no_update;
u8 vps[5];
u8 vps_found;
int wss;
u8 wss_found;
u8 wss_no_update;
struct vbi_cc cc_payload[256]; /* Sliced VBI CC payload array. It is an array to
prevent dropping CC data if they couldn't be
processed fast enough. */
int cc_payload_idx; /* Index in cc_payload */
u8 cc_missing_cnt; /* Counts number of frames without CC for passthrough mode */
int wss_payload; /* Sliced VBI WSS payload */
u8 wss_missing_cnt; /* Counts number of frames without WSS for passthrough mode */
struct vbi_vps vps_payload; /* Sliced VBI VPS payload */
struct v4l2_format in;
/* convenience pointer to sliced struct in vbi_in union */
struct v4l2_sliced_vbi_format *sliced_in;
Expand Down
11 changes: 7 additions & 4 deletions drivers/media/video/ivtv/ivtv-fileops.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,11 @@ ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t c

/* This stream does not need to start any decoding */
if (s->type == IVTV_DEC_STREAM_TYPE_VOUT) {
int elems = count / sizeof(struct v4l2_sliced_vbi_data);

set_bit(IVTV_F_S_APPL_IO, &s->s_flags);
return ivtv_write_vbi(itv, user_buf, count);
ivtv_write_vbi(itv, (const struct v4l2_sliced_vbi_data *)user_buf, elems);
return elems * sizeof(struct v4l2_sliced_vbi_data);
}

mode = s->type == IVTV_DEC_STREAM_TYPE_MPG ? OUT_MPG : OUT_YUV;
Expand Down Expand Up @@ -828,10 +831,10 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0);

/* If all output streams are closed, and if the user doesn't have
IVTV_DEC_STREAM_TYPE_VOUT open, then disable VBI on TV-out. */
IVTV_DEC_STREAM_TYPE_VOUT open, then disable CC on TV-out. */
if (itv->output_mode == OUT_NONE && !test_bit(IVTV_F_S_APPL_IO, &s_vout->s_flags)) {
/* disable VBI on TV-out */
ivtv_disable_vbi(itv);
/* disable CC on TV-out */
ivtv_disable_cc(itv);
}
} else {
ivtv_stop_capture(id, 0);
Expand Down
10 changes: 7 additions & 3 deletions drivers/media/video/ivtv/ivtv-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,10 @@ static void ivtv_irq_vsync(struct ivtv *itv)
wake_up(&s->waitq);

/* Send VBI to saa7127 */
if (frame) {
if (frame && (itv->output_mode == OUT_PASSTHROUGH ||
test_bit(IVTV_F_I_UPDATE_WSS, &itv->i_flags) ||
test_bit(IVTV_F_I_UPDATE_VPS, &itv->i_flags) ||
test_bit(IVTV_F_I_UPDATE_CC, &itv->i_flags))) {
set_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags);
set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
}
Expand All @@ -809,7 +812,7 @@ static void ivtv_irq_vsync(struct ivtv *itv)
}
}

#define IVTV_IRQ_DMA (IVTV_IRQ_DMA_READ | IVTV_IRQ_ENC_DMA_COMPLETE | IVTV_IRQ_DMA_ERR | IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_VBI_CAP | IVTV_IRQ_DEC_DATA_REQ)
#define IVTV_IRQ_DMA (IVTV_IRQ_DMA_READ | IVTV_IRQ_ENC_DMA_COMPLETE | IVTV_IRQ_DMA_ERR | IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_VBI_CAP | IVTV_IRQ_DEC_DATA_REQ | IVTV_IRQ_DEC_VBI_RE_INSERT)

irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
{
Expand Down Expand Up @@ -942,8 +945,9 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
}
}

if (test_and_clear_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags))
if (test_and_clear_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags)) {
queue_work(itv->irq_work_queues, &itv->irq_work_queue);
}

spin_unlock(&itv->dma_reg_lock);

Expand Down
Loading

0 comments on commit 2f3a989

Please sign in to comment.