30 #define DMA_MAGIC_COOKIE 0x000001fe
34 static const int ivtv_stream_map[] = {
41 static void ivtv_pcm_work_handler(
struct ivtv *itv)
70 static void ivtv_pio_work_handler(
struct ivtv *itv)
78 s->
vdev ==
NULL || !ivtv_use_pio(s)) {
107 ivtv_pio_work_handler(itv);
116 ivtv_pcm_work_handler(itv);
127 u32 bytes_needed = 0;
129 u32 UVoffset = 0, UVsize = 0;
130 int skip_bufs = s->
q_predma.buffers;
161 offset =
data[1] + 12;
170 size = itv->
vbi.enc_size * itv->
vbi.fpi;
210 bytes_needed += UVsize;
214 ivtv_use_pio(s) ?
"PIO" :
"DMA", s->
name, bytes_needed, offset);
219 bytes_needed, s->
name);
223 IVTV_WARN(
"All %s stream buffers are full. Dropping data.\n", s->
name);
224 IVTV_WARN(
"Cause: the application is not reading fast enough.\n");
245 ivtv_buf_sync_for_device(s, buf);
274 ivtv_buf_sync_for_cpu(s, buf);
276 if (x == 0 && ivtv_use_dma(s)) {
280 for (offset = 0; offset < 64; offset++) {
287 IVTV_DEBUG_WARN(
"%s: Couldn't find start of buffer within the first 256 bytes\n", s->
name);
358 u32 y_size = 720 * ((f->
src_h + 31) & ~31);
361 int bytes_written = 0;
362 unsigned long flags = 0;
381 (bytes_written + buf->
bytesused) >= y_size) {
405 ivtv_buf_sync_for_device(s, buf);
411 ivtv_stream_sync_for_device(s);
415 ivtv_dma_dec_start(s);
424 static void ivtv_dma_enc_start_xfer(
struct ivtv_stream *s)
433 ivtv_stream_sync_for_device(s);
440 static void ivtv_dma_dec_start_xfer(
struct ivtv_stream *s)
449 ivtv_stream_sync_for_device(s);
457 static void ivtv_dma_enc_start(
struct ivtv_stream *s)
483 if (ivtv_use_dma(s_vbi))
504 if (ivtv_use_pio(s)) {
512 ivtv_dma_enc_start_xfer(s);
518 static void ivtv_dma_dec_start(
struct ivtv_stream *s)
532 ivtv_dma_dec_start_xfer(s);
537 static void ivtv_irq_dma_read(
struct ivtv *itv)
541 int hw_stream_type = 0;
552 ivtv_stream_sync_for_cpu(s);
573 ivtv_dma_dec_start_xfer(s);
591 ivtv_buf_sync_for_cpu(s, buf);
602 static void ivtv_irq_enc_dma_complete(
struct ivtv *itv)
616 ivtv_stream_sync_for_cpu(s);
618 if (data[0] & 0x18) {
619 IVTV_DEBUG_WARN(
"ENC DMA ERROR %x (offset %08x, xfer %d of %d, retry %d)\n", data[0],
636 ivtv_dma_enc_start_xfer(s);
651 static void ivtv_irq_enc_pio_complete(
struct ivtv *itv)
678 static void ivtv_irq_dma_err(
struct ivtv *itv)
712 ivtv_dma_dec_start(s);
715 if ((status & 0x2) == 0) {
735 ivtv_dma_enc_start_xfer(s);
752 static void ivtv_irq_enc_start_cap(
struct ivtv *itv)
761 if (data[0] > 2 || data[1] == 0 || data[2] == 0) {
763 data[0], data[1], data[2]);
766 s = &itv->
streams[ivtv_stream_map[data[0]]];
767 if (!stream_enc_dma_append(s, data)) {
772 static void ivtv_irq_enc_vbi_cap(
struct ivtv *itv)
780 if (!stream_enc_dma_append(s, data))
784 static void ivtv_irq_dec_vbi_reinsert(
struct ivtv *itv)
791 !stream_enc_dma_append(s, data)) {
796 static void ivtv_irq_dec_data_req(
struct ivtv *itv)
806 1080 * ((itv->
yuv_info.v4l2_src_h + 31) & ~31);
832 static void ivtv_irq_vsync(
struct ivtv *itv)
851 int next_dma_frame = last_dma_frame;
926 #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)
930 struct ivtv *itv = (
struct ivtv *)dev_id;
969 if (combo & ~0xff6d0400)
977 ivtv_irq_dma_read(itv);
981 ivtv_irq_enc_dma_complete(itv);
985 ivtv_irq_enc_pio_complete(itv);
989 ivtv_irq_dma_err(itv);
993 ivtv_irq_enc_start_cap(itv);
997 ivtv_irq_enc_vbi_cap(itv);
1001 ivtv_irq_dec_vbi_reinsert(itv);
1011 ivtv_irq_dec_data_req(itv);
1016 ivtv_irq_vsync(itv);
1031 int idx = (i + itv->
irq_rr_idx) % IVTV_MAX_STREAMS;
1037 ivtv_dma_dec_start(s);
1039 ivtv_dma_enc_start(s);
1043 if (i == IVTV_MAX_STREAMS &&
1051 int idx = (i + itv->
irq_rr_idx) % IVTV_MAX_STREAMS;
1057 ivtv_dma_enc_start(s);
1077 struct ivtv *itv = (
struct ivtv *)arg;