Lines Matching refs:video
194 static struct frame* frame_new(unsigned int frame_num, struct video_card *video) in frame_new() argument
200 f->video = video; in frame_new()
203 f->header_pool = pci_alloc_consistent(f->video->ohci->dev, PAGE_SIZE, &f->header_pool_dma); in frame_new()
217 f->descriptor_pool = pci_alloc_consistent(f->video->ohci->dev, in frame_new()
221 pci_free_consistent(f->video->ohci->dev, PAGE_SIZE, f->header_pool, f->header_pool_dma); in frame_new()
237 pci_free_consistent(f->video->ohci->dev, PAGE_SIZE, f->header_pool, f->header_pool_dma); in frame_delete()
238 …pci_free_consistent(f->video->ohci->dev, f->descriptor_pool_size, f->descriptor_pool, f->descripto… in frame_delete()
253 static void frame_prepare(struct video_card *video, unsigned int this_frame) in frame_prepare() argument
255 struct frame *f = video->frames[this_frame]; in frame_prepare()
280 if (video->pal_or_ntsc == DV1394_PAL) in frame_prepare()
327 if (video->cip_accum > (video->cip_d - video->cip_n)) { in frame_prepare()
330 video->cip_accum -= (video->cip_d - video->cip_n); in frame_prepare()
333 video->cip_accum += video->cip_n; in frame_prepare()
392 reg_read(video->ohci, OHCI1394_NodeID) & 0x3F, in frame_prepare()
393 video->continuity_counter, in frame_prepare()
394 video->pal_or_ntsc, in frame_prepare()
399 video->continuity_counter++; in frame_prepare()
406 fill_output_more_immediate( &(block->u.out.omi), 1, video->channel, 0, payload_size); in frame_prepare()
457 dma_region_offset_to_bus(&video->dv_buf, in frame_prepare()
458 data_p - (unsigned long) video->dv_buf.kvirt)); in frame_prepare()
472 dma_region_offset_to_bus(&video->dv_buf, in frame_prepare()
473 data_p + PAGE_SIZE - (data_p % PAGE_SIZE) - (unsigned long) video->dv_buf.kvirt)); in frame_prepare()
507 dma_region_offset_to_bus(&video->dv_buf, in frame_prepare()
508 data_p - (unsigned long) video->dv_buf.kvirt)); in frame_prepare()
550 …dma_region_sync_for_device(&video->dv_buf, f->data - (unsigned long) video->dv_buf.kvirt, video->f… in frame_prepare()
553 spin_lock_irqsave(&video->spinlock, irq_flags); in frame_prepare()
557 video->n_clear_frames--; in frame_prepare()
559 last_frame = video->first_clear_frame - 1; in frame_prepare()
561 last_frame = video->n_frames-1; in frame_prepare()
563 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames; in frame_prepare()
566 this_frame, video->active_frame, video->n_clear_frames, video->first_clear_frame, last_frame); in frame_prepare()
574 if (video->active_frame != -1) { in frame_prepare()
578 if (video->frames[last_frame]->frame_end_branch) { in frame_prepare()
582 …*(video->frames[last_frame]->frame_end_branch) = cpu_to_le32(f->descriptor_pool_dma | f->first_n_d… in frame_prepare()
588 temp = le32_to_cpu(*(video->frames[last_frame]->frame_end_branch - 2)); in frame_prepare()
590 *(video->frames[last_frame]->frame_end_branch - 2) = cpu_to_le32(temp); in frame_prepare()
593 flush_pci_write(video->ohci); in frame_prepare()
616 video->active_frame = this_frame; in frame_prepare()
619 reg_write(video->ohci, video->ohci_IsoXmitCommandPtr, in frame_prepare()
620 video->frames[video->active_frame]->descriptor_pool_dma | in frame_prepare()
627 cycleTimer = reg_read(video->ohci, OHCI1394_IsochronousCycleTimer); in frame_prepare()
659 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, 0xFFFFFFFF); in frame_prepare()
675 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, in frame_prepare()
682 video->dma_running = 1; in frame_prepare()
685 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, 0x8000); in frame_prepare()
686 flush_pci_write(video->ohci); in frame_prepare()
691 (reg_read(video->ohci, OHCI1394_IsochronousCycleTimer) >> 12) & 0x1FFF, in frame_prepare()
692 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet), in frame_prepare()
693 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)); in frame_prepare()
705 if (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) { in frame_prepare()
713 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet), in frame_prepare()
714 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr) in frame_prepare()
717 if ( ! (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) { in frame_prepare()
719 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & 0x1F); in frame_prepare()
728 spin_unlock_irqrestore(&video->spinlock, irq_flags); in frame_prepare()
779 static void start_dma_receive(struct video_card *video) in start_dma_receive() argument
781 if (video->first_run == 1) { in start_dma_receive()
782 video->first_run = 0; in start_dma_receive()
785 video->n_clear_frames = 0; in start_dma_receive()
786 video->first_clear_frame = -1; in start_dma_receive()
787 video->current_packet = 0; in start_dma_receive()
788 video->active_frame = 0; in start_dma_receive()
791 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, 0xFFFFFFFF); in start_dma_receive()
795 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, 0x40000000); in start_dma_receive()
798 reg_write(video->ohci, video->ohci_IsoRcvContextMatch, 0xf0000000 | video->channel); in start_dma_receive()
801 reg_write(video->ohci, video->ohci_IsoRcvCommandPtr, in start_dma_receive()
802 video->frames[0]->descriptor_pool_dma | 1); /* Z=1 */ in start_dma_receive()
805 video->dma_running = 1; in start_dma_receive()
808 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, 0x8000); in start_dma_receive()
809 flush_pci_write(video->ohci); in start_dma_receive()
819 if (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) { in start_dma_receive()
824 if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) { in start_dma_receive()
826 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F); in start_dma_receive()
831 } else if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) { in start_dma_receive()
833 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F); in start_dma_receive()
836 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12)); in start_dma_receive()
845 static void receive_packets(struct video_card *video) in receive_packets() argument
857 spin_lock_irqsave(&video->spinlock, irq_flags); in receive_packets()
859 for (j = 0; j < video->n_frames; j++) { in receive_packets()
863 *(f->frame_end_branch) = cpu_to_le32(video->frames[j]->descriptor_pool_dma | 1); /* set Z=1 */ in receive_packets()
865 f = video->frames[j]; in receive_packets()
872 data = ((struct packet*)video->packet_buf.kvirt) + f->frame_num * MAX_PACKETS + i; in receive_packets()
873 data_dma = dma_region_offset_to_bus( &video->packet_buf, in receive_packets()
874 ((unsigned long) data - (unsigned long) video->packet_buf.kvirt) ); in receive_packets()
891 spin_unlock_irqrestore(&video->spinlock, irq_flags); in receive_packets()
899 static int do_dv1394_init(struct video_card *video, struct dv1394_init *init) in do_dv1394_init() argument
906 debug_printk("dv1394: initialising %d\n", video->id); in do_dv1394_init()
936 if (video->dv_buf.kvirt && video->dv_buf_size != new_buf_size) { in do_dv1394_init()
944 do_dv1394_shutdown(video, 0); in do_dv1394_init()
947 spin_lock_irqsave(&video->ohci->IR_channel_lock, flags); in do_dv1394_init()
948 if (video->ohci->ISO_channel_usage & chan_mask) { in do_dv1394_init()
949 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags); in do_dv1394_init()
953 video->ohci->ISO_channel_usage |= chan_mask; in do_dv1394_init()
954 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags); in do_dv1394_init()
956 video->channel = init->channel; in do_dv1394_init()
959 video->n_frames = init->n_frames; in do_dv1394_init()
960 video->pal_or_ntsc = init->format; in do_dv1394_init()
962 video->cip_accum = 0; in do_dv1394_init()
963 video->continuity_counter = 0; in do_dv1394_init()
965 video->active_frame = -1; in do_dv1394_init()
966 video->first_clear_frame = 0; in do_dv1394_init()
967 video->n_clear_frames = video->n_frames; in do_dv1394_init()
968 video->dropped_frames = 0; in do_dv1394_init()
970 video->write_off = 0; in do_dv1394_init()
972 video->first_run = 1; in do_dv1394_init()
973 video->current_packet = -1; in do_dv1394_init()
974 video->first_frame = 0; in do_dv1394_init()
976 if (video->pal_or_ntsc == DV1394_NTSC) { in do_dv1394_init()
977 video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_NTSC; in do_dv1394_init()
978 video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_NTSC; in do_dv1394_init()
979 video->frame_size = DV1394_NTSC_FRAME_SIZE; in do_dv1394_init()
981 video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_PAL; in do_dv1394_init()
982 video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_PAL; in do_dv1394_init()
983 video->frame_size = DV1394_PAL_FRAME_SIZE; in do_dv1394_init()
986 video->syt_offset = init->syt_offset; in do_dv1394_init()
990 if (video->ohci_it_ctx == -1) { in do_dv1394_init()
991 ohci1394_init_iso_tasklet(&video->it_tasklet, OHCI_ISO_TRANSMIT, in do_dv1394_init()
992 it_tasklet_func, (unsigned long) video); in do_dv1394_init()
994 if (ohci1394_register_iso_tasklet(video->ohci, &video->it_tasklet) < 0) { in do_dv1394_init()
1000 video->ohci_it_ctx = video->it_tasklet.context; in do_dv1394_init()
1001 debug_printk("dv1394: claimed IT DMA context %d\n", video->ohci_it_ctx); in do_dv1394_init()
1004 if (video->ohci_ir_ctx == -1) { in do_dv1394_init()
1005 ohci1394_init_iso_tasklet(&video->ir_tasklet, OHCI_ISO_RECEIVE, in do_dv1394_init()
1006 ir_tasklet_func, (unsigned long) video); in do_dv1394_init()
1008 if (ohci1394_register_iso_tasklet(video->ohci, &video->ir_tasklet) < 0) { in do_dv1394_init()
1013 video->ohci_ir_ctx = video->ir_tasklet.context; in do_dv1394_init()
1014 debug_printk("dv1394: claimed IR DMA context %d\n", video->ohci_ir_ctx); in do_dv1394_init()
1019 video->frames[i] = frame_new(i, video); in do_dv1394_init()
1021 if (!video->frames[i]) { in do_dv1394_init()
1028 if (!video->dv_buf.kvirt) { in do_dv1394_init()
1030 retval = dma_region_alloc(&video->dv_buf, new_buf_size, video->ohci->dev, PCI_DMA_TODEVICE); in do_dv1394_init()
1034 video->dv_buf_size = new_buf_size; in do_dv1394_init()
1037 video->n_frames, video->dv_buf.n_pages, in do_dv1394_init()
1038 video->dv_buf.n_dma_pages, video->dv_buf_size); in do_dv1394_init()
1042 for (i = 0; i < video->n_frames; i++) in do_dv1394_init()
1043 video->frames[i]->data = (unsigned long) video->dv_buf.kvirt + i * video->frame_size; in do_dv1394_init()
1045 if (!video->packet_buf.kvirt) { in do_dv1394_init()
1047 video->packet_buf_size = sizeof(struct packet) * video->n_frames * MAX_PACKETS; in do_dv1394_init()
1048 if (video->packet_buf_size % PAGE_SIZE) in do_dv1394_init()
1049 video->packet_buf_size += PAGE_SIZE - (video->packet_buf_size % PAGE_SIZE); in do_dv1394_init()
1051 retval = dma_region_alloc(&video->packet_buf, video->packet_buf_size, in do_dv1394_init()
1052 video->ohci->dev, PCI_DMA_FROMDEVICE); in do_dv1394_init()
1057 video->n_frames*MAX_PACKETS, video->packet_buf.n_pages, in do_dv1394_init()
1058 video->packet_buf.n_dma_pages, video->packet_buf_size); in do_dv1394_init()
1063 video->ohci_IsoXmitContextControlSet = OHCI1394_IsoXmitContextControlSet+16*video->ohci_it_ctx; in do_dv1394_init()
1064 video->ohci_IsoXmitContextControlClear = OHCI1394_IsoXmitContextControlClear+16*video->ohci_it_ctx; in do_dv1394_init()
1065 video->ohci_IsoXmitCommandPtr = OHCI1394_IsoXmitCommandPtr+16*video->ohci_it_ctx; in do_dv1394_init()
1068 reg_write(video->ohci, OHCI1394_IsoXmitIntMaskSet, (1 << video->ohci_it_ctx)); in do_dv1394_init()
1069 debug_printk("dv1394: interrupts enabled for IT context %d\n", video->ohci_it_ctx); in do_dv1394_init()
1073 video->ohci_IsoRcvContextControlSet = OHCI1394_IsoRcvContextControlSet+32*video->ohci_ir_ctx; in do_dv1394_init()
1074 video->ohci_IsoRcvContextControlClear = OHCI1394_IsoRcvContextControlClear+32*video->ohci_ir_ctx; in do_dv1394_init()
1075 video->ohci_IsoRcvCommandPtr = OHCI1394_IsoRcvCommandPtr+32*video->ohci_ir_ctx; in do_dv1394_init()
1076 video->ohci_IsoRcvContextMatch = OHCI1394_IsoRcvContextMatch+32*video->ohci_ir_ctx; in do_dv1394_init()
1079 reg_write(video->ohci, OHCI1394_IsoRecvIntMaskSet, (1 << video->ohci_ir_ctx) ); in do_dv1394_init()
1080 debug_printk("dv1394: interrupts enabled for IR context %d\n", video->ohci_ir_ctx); in do_dv1394_init()
1085 do_dv1394_shutdown(video, 1); in do_dv1394_init()
1092 static int do_dv1394_init_default(struct video_card *video) in do_dv1394_init_default() argument
1098 init.channel = video->channel; in do_dv1394_init_default()
1099 init.format = video->pal_or_ntsc; in do_dv1394_init_default()
1100 init.cip_n = video->cip_n; in do_dv1394_init_default()
1101 init.cip_d = video->cip_d; in do_dv1394_init_default()
1102 init.syt_offset = video->syt_offset; in do_dv1394_init_default()
1104 return do_dv1394_init(video, &init); in do_dv1394_init_default()
1108 static void stop_dma(struct video_card *video) in stop_dma() argument
1114 spin_lock_irqsave(&video->spinlock, flags); in stop_dma()
1116 video->dma_running = 0; in stop_dma()
1118 if ( (video->ohci_it_ctx == -1) && (video->ohci_ir_ctx == -1) ) in stop_dma()
1122 if ( (video->active_frame != -1) || in stop_dma()
1123 (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) || in stop_dma()
1124 (reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) { in stop_dma()
1127 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, (1 << 15)); in stop_dma()
1128 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, (1 << 15)); in stop_dma()
1129 flush_pci_write(video->ohci); in stop_dma()
1131 video->active_frame = -1; in stop_dma()
1132 video->first_run = 1; in stop_dma()
1141 if ( (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) || in stop_dma()
1142 (reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) { in stop_dma()
1162 spin_unlock_irqrestore(&video->spinlock, flags); in stop_dma()
1167 static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf) in do_dv1394_shutdown() argument
1174 stop_dma(video); in do_dv1394_shutdown()
1177 if (video->ohci_it_ctx != -1) { in do_dv1394_shutdown()
1178 video->ohci_IsoXmitContextControlSet = 0; in do_dv1394_shutdown()
1179 video->ohci_IsoXmitContextControlClear = 0; in do_dv1394_shutdown()
1180 video->ohci_IsoXmitCommandPtr = 0; in do_dv1394_shutdown()
1183 reg_write(video->ohci, OHCI1394_IsoXmitIntMaskClear, (1 << video->ohci_it_ctx)); in do_dv1394_shutdown()
1186 ohci1394_unregister_iso_tasklet(video->ohci, &video->it_tasklet); in do_dv1394_shutdown()
1187 debug_printk("dv1394: IT context %d released\n", video->ohci_it_ctx); in do_dv1394_shutdown()
1188 video->ohci_it_ctx = -1; in do_dv1394_shutdown()
1191 if (video->ohci_ir_ctx != -1) { in do_dv1394_shutdown()
1192 video->ohci_IsoRcvContextControlSet = 0; in do_dv1394_shutdown()
1193 video->ohci_IsoRcvContextControlClear = 0; in do_dv1394_shutdown()
1194 video->ohci_IsoRcvCommandPtr = 0; in do_dv1394_shutdown()
1195 video->ohci_IsoRcvContextMatch = 0; in do_dv1394_shutdown()
1198 reg_write(video->ohci, OHCI1394_IsoRecvIntMaskClear, (1 << video->ohci_ir_ctx)); in do_dv1394_shutdown()
1201 ohci1394_unregister_iso_tasklet(video->ohci, &video->ir_tasklet); in do_dv1394_shutdown()
1202 debug_printk("dv1394: IR context %d released\n", video->ohci_ir_ctx); in do_dv1394_shutdown()
1203 video->ohci_ir_ctx = -1; in do_dv1394_shutdown()
1207 if (video->channel != -1) { in do_dv1394_shutdown()
1211 chan_mask = (u64)1 << video->channel; in do_dv1394_shutdown()
1213 spin_lock_irqsave(&video->ohci->IR_channel_lock, flags); in do_dv1394_shutdown()
1214 video->ohci->ISO_channel_usage &= ~(chan_mask); in do_dv1394_shutdown()
1215 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags); in do_dv1394_shutdown()
1217 video->channel = -1; in do_dv1394_shutdown()
1222 if (video->frames[i]) in do_dv1394_shutdown()
1223 frame_delete(video->frames[i]); in do_dv1394_shutdown()
1224 video->frames[i] = NULL; in do_dv1394_shutdown()
1227 video->n_frames = 0; in do_dv1394_shutdown()
1233 dma_region_free(&video->dv_buf); in do_dv1394_shutdown()
1234 video->dv_buf_size = 0; in do_dv1394_shutdown()
1238 dma_region_free(&video->packet_buf); in do_dv1394_shutdown()
1239 video->packet_buf_size = 0; in do_dv1394_shutdown()
1270 struct video_card *video = file_to_video_card(file); in dv1394_mmap() local
1279 if (!mutex_trylock(&video->mtx)) in dv1394_mmap()
1282 if ( ! video_card_initialized(video) ) { in dv1394_mmap()
1283 retval = do_dv1394_init_default(video); in dv1394_mmap()
1288 retval = dma_region_mmap(&video->dv_buf, file, vma); in dv1394_mmap()
1290 mutex_unlock(&video->mtx); in dv1394_mmap()
1299 struct video_card *video = file_to_video_card(file); in dv1394_poll() local
1303 poll_wait(file, &video->waitq, wait); in dv1394_poll()
1305 spin_lock_irqsave(&video->spinlock, flags); in dv1394_poll()
1306 if ( video->n_frames == 0 ) { in dv1394_poll()
1308 } else if ( video->active_frame == -1 ) { in dv1394_poll()
1313 if (video->n_clear_frames >0) in dv1394_poll()
1316 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_poll()
1326 struct video_card *video = file_to_video_card(file); in dv1394_fasync() local
1328 int retval = fasync_helper(fd, file, on, &video->fasync); in dv1394_fasync()
1337 struct video_card *video = file_to_video_card(file); in dv1394_write() local
1346 if (!mutex_trylock(&video->mtx)) in dv1394_write()
1349 if (mutex_lock_interruptible(&video->mtx)) in dv1394_write()
1353 if ( !video_card_initialized(video) ) { in dv1394_write()
1354 ret = do_dv1394_init_default(video); in dv1394_write()
1356 mutex_unlock(&video->mtx); in dv1394_write()
1362 add_wait_queue(&video->waitq, &wait); in dv1394_write()
1372 spin_lock_irqsave(&video->spinlock, flags); in dv1394_write()
1374 target_frame = video->first_clear_frame; in dv1394_write()
1376 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_write()
1378 if (video->frames[target_frame]->state == FRAME_CLEAR) { in dv1394_write()
1381 cnt = video->frame_size - (video->write_off - target_frame * video->frame_size); in dv1394_write()
1409 if (copy_from_user(video->dv_buf.kvirt + video->write_off, buffer, cnt)) { in dv1394_write()
1415 video->write_off = (video->write_off + cnt) % (video->n_frames * video->frame_size); in dv1394_write()
1421 if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames)) in dv1394_write()
1422 frame_prepare(video, target_frame); in dv1394_write()
1425 remove_wait_queue(&video->waitq, &wait); in dv1394_write()
1427 mutex_unlock(&video->mtx); in dv1394_write()
1434 struct video_card *video = file_to_video_card(file); in dv1394_read() local
1443 if (!mutex_trylock(&video->mtx)) in dv1394_read()
1446 if (mutex_lock_interruptible(&video->mtx)) in dv1394_read()
1450 if ( !video_card_initialized(video) ) { in dv1394_read()
1451 ret = do_dv1394_init_default(video); in dv1394_read()
1453 mutex_unlock(&video->mtx); in dv1394_read()
1456 video->continuity_counter = -1; in dv1394_read()
1458 receive_packets(video); in dv1394_read()
1460 start_dma_receive(video); in dv1394_read()
1464 add_wait_queue(&video->waitq, &wait); in dv1394_read()
1474 spin_lock_irqsave(&video->spinlock, flags); in dv1394_read()
1476 target_frame = video->first_clear_frame; in dv1394_read()
1478 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_read()
1481 video->n_clear_frames > 0 && in dv1394_read()
1482 video->frames[target_frame]->state == FRAME_CLEAR) { in dv1394_read()
1485 cnt = video->frame_size - (video->write_off - target_frame * video->frame_size); in dv1394_read()
1513 if (copy_to_user(buffer, video->dv_buf.kvirt + video->write_off, cnt)) { in dv1394_read()
1519 video->write_off = (video->write_off + cnt) % (video->n_frames * video->frame_size); in dv1394_read()
1525 if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames)) { in dv1394_read()
1526 spin_lock_irqsave(&video->spinlock, flags); in dv1394_read()
1527 video->n_clear_frames--; in dv1394_read()
1528 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames; in dv1394_read()
1529 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_read()
1533 remove_wait_queue(&video->waitq, &wait); in dv1394_read()
1535 mutex_unlock(&video->mtx); in dv1394_read()
1544 struct video_card *video = file_to_video_card(file); in dv1394_ioctl() local
1553 if (!mutex_trylock(&video->mtx)) in dv1394_ioctl()
1556 if (mutex_lock_interruptible(&video->mtx)) in dv1394_ioctl()
1565 if ( !video_card_initialized(video) ) { in dv1394_ioctl()
1566 ret = do_dv1394_init_default(video); in dv1394_ioctl()
1573 if (n_submit > video->n_frames) { in dv1394_ioctl()
1580 add_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1583 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1586 while (video->frames[video->first_clear_frame]->state != FRAME_CLEAR) { in dv1394_ioctl()
1588 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1591 remove_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1600 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1602 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1604 remove_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1607 frame_prepare(video, video->first_clear_frame); in dv1394_ioctl()
1619 if ( !video_card_initialized(video) ) { in dv1394_ioctl()
1630 if (n_wait > (video->n_frames-1) ) { in dv1394_ioctl()
1635 add_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1638 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1640 while (video->n_clear_frames < n_wait) { in dv1394_ioctl()
1642 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1645 remove_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1654 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1657 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1659 remove_wait_queue(&video->waitq, &wait); in dv1394_ioctl()
1668 if ( !video_card_initialized(video) ) { in dv1394_ioctl()
1676 if (n_recv > (video->n_frames-1) ) { in dv1394_ioctl()
1681 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1684 video->n_clear_frames -= n_recv; in dv1394_ioctl()
1687 video->first_clear_frame = (video->first_clear_frame + n_recv) % video->n_frames; in dv1394_ioctl()
1690 video->dropped_frames = 0; in dv1394_ioctl()
1692 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1699 if ( !video_card_initialized(video) ) { in dv1394_ioctl()
1700 ret = do_dv1394_init_default(video); in dv1394_ioctl()
1705 video->continuity_counter = -1; in dv1394_ioctl()
1707 receive_packets(video); in dv1394_ioctl()
1709 start_dma_receive(video); in dv1394_ioctl()
1718 ret = do_dv1394_init_default(video); in dv1394_ioctl()
1724 ret = do_dv1394_init(video, &init); in dv1394_ioctl()
1730 do_dv1394_shutdown(video, 0); in dv1394_ioctl()
1738 if ( !video_card_initialized(video) ) { in dv1394_ioctl()
1744 status.init.channel = video->channel; in dv1394_ioctl()
1745 status.init.n_frames = video->n_frames; in dv1394_ioctl()
1746 status.init.format = video->pal_or_ntsc; in dv1394_ioctl()
1747 status.init.cip_n = video->cip_n; in dv1394_ioctl()
1748 status.init.cip_d = video->cip_d; in dv1394_ioctl()
1749 status.init.syt_offset = video->syt_offset; in dv1394_ioctl()
1751 status.first_clear_frame = video->first_clear_frame; in dv1394_ioctl()
1754 spin_lock_irqsave(&video->spinlock, flags); in dv1394_ioctl()
1756 status.active_frame = video->active_frame; in dv1394_ioctl()
1757 status.n_clear_frames = video->n_clear_frames; in dv1394_ioctl()
1759 status.dropped_frames = video->dropped_frames; in dv1394_ioctl()
1762 video->dropped_frames = 0; in dv1394_ioctl()
1764 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_ioctl()
1780 mutex_unlock(&video->mtx); in dv1394_ioctl()
1788 struct video_card *video = NULL; in dv1394_open() local
1791 video = (struct video_card*) file->private_data; in dv1394_open()
1802 video = p; in dv1394_open()
1809 if (!video) { in dv1394_open()
1814 file->private_data = (void*) video; in dv1394_open()
1819 if ( test_and_set_bit(0, &video->open) ) { in dv1394_open()
1836 struct video_card *video = file_to_video_card(file); in dv1394_release() local
1839 do_dv1394_shutdown(video, 1); in dv1394_release()
1842 clear_bit(0, &video->open); in dv1394_release()
1853 struct video_card *video = (struct video_card*) data; in it_tasklet_func() local
1855 spin_lock(&video->spinlock); in it_tasklet_func()
1857 if (!video->dma_running) in it_tasklet_func()
1861 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet), in it_tasklet_func()
1862 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr) in it_tasklet_func()
1866 if ( (video->ohci_it_ctx != -1) && in it_tasklet_func()
1867 (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) { in it_tasklet_func()
1873 if (video->active_frame == -1) in it_tasklet_func()
1876 frame = video->active_frame; in it_tasklet_func()
1879 for (i = 0; i < video->n_frames; i++, frame = (frame+1) % video->n_frames) { in it_tasklet_func()
1882 f = video->frames[frame]; in it_tasklet_func()
1903 prev_frame += video->n_frames; in it_tasklet_func()
1904 prev_f = video->frames[prev_frame]; in it_tasklet_func()
1912 video->n_clear_frames++; in it_tasklet_func()
1914 video->active_frame = frame; in it_tasklet_func()
1939 next_frame = video->frames[ (frame+1) % video->n_frames ]; in it_tasklet_func()
1952 ts_cyc += f->n_packets + video->syt_offset ; in it_tasklet_func()
1978 video->dropped_frames++; in it_tasklet_func()
1985 kill_fasync(&video->fasync, SIGIO, POLL_OUT); in it_tasklet_func()
1988 wake_up_interruptible(&video->waitq); in it_tasklet_func()
1992 spin_unlock(&video->spinlock); in it_tasklet_func()
1998 struct video_card *video = (struct video_card*) data; in ir_tasklet_func() local
2000 spin_lock(&video->spinlock); in ir_tasklet_func()
2002 if (!video->dma_running) in ir_tasklet_func()
2005 if ( (video->ohci_ir_ctx != -1) && in ir_tasklet_func()
2006 (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) ) { in ir_tasklet_func()
2021 for (i = 0; i < video->n_frames*MAX_PACKETS; i++) { in ir_tasklet_func()
2022 struct packet *p = dma_region_i(&video->packet_buf, struct packet, video->current_packet); in ir_tasklet_func()
2025 dma_region_sync_for_cpu(&video->packet_buf, in ir_tasklet_func()
2026 (unsigned long) p - (unsigned long) video->packet_buf.kvirt, in ir_tasklet_func()
2032 …irq_printk("received packet %02d, timestamp=%04x, length=%04x, sof=%02x%02x\n", video->current_pac… in ir_tasklet_func()
2037 f = video->frames[video->current_packet / MAX_PACKETS]; in ir_tasklet_func()
2038 block = &(f->descriptor_pool[video->current_packet % MAX_PACKETS]); in ir_tasklet_func()
2044 f = video->frames[video->active_frame]; in ir_tasklet_func()
2054 if ( video->continuity_counter != -1 && dbc > ((video->continuity_counter + 1) % 256) ) in ir_tasklet_func()
2057 video->dropped_frames += video->n_clear_frames + 1; in ir_tasklet_func()
2058 video->first_frame = 0; in ir_tasklet_func()
2059 video->n_clear_frames = 0; in ir_tasklet_func()
2060 video->first_clear_frame = -1; in ir_tasklet_func()
2062 video->continuity_counter = dbc; in ir_tasklet_func()
2064 if (!video->first_frame) { in ir_tasklet_func()
2066 video->first_frame = 1; in ir_tasklet_func()
2072 video->n_clear_frames++; in ir_tasklet_func()
2073 if (video->n_clear_frames > video->n_frames) { in ir_tasklet_func()
2074 video->dropped_frames++; in ir_tasklet_func()
2076 video->n_clear_frames = video->n_frames-1; in ir_tasklet_func()
2077 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames; in ir_tasklet_func()
2079 if (video->first_clear_frame == -1) in ir_tasklet_func()
2080 video->first_clear_frame = video->active_frame; in ir_tasklet_func()
2083 video->active_frame = (video->active_frame + 1) % video->n_frames; in ir_tasklet_func()
2084 f = video->frames[video->active_frame]; in ir_tasklet_func()
2086 video->active_frame, video->n_clear_frames, video->first_clear_frame); in ir_tasklet_func()
2088 if (video->first_frame) { in ir_tasklet_func()
2095 if (f->n_packets > (video->frame_size / 480)) { in ir_tasklet_func()
2113 next_i = video->current_packet; in ir_tasklet_func()
2114 f = video->frames[next_i / MAX_PACKETS]; in ir_tasklet_func()
2121 prev_i = (next_i == 0) ? (MAX_PACKETS * video->n_frames - 1) : (next_i - 1); in ir_tasklet_func()
2122 f = video->frames[prev_i / MAX_PACKETS]; in ir_tasklet_func()
2133 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12)); in ir_tasklet_func()
2136 video->current_packet = (video->current_packet + 1) % (MAX_PACKETS * video->n_frames); in ir_tasklet_func()
2145 kill_fasync(&video->fasync, SIGIO, POLL_IN); in ir_tasklet_func()
2148 wake_up_interruptible(&video->waitq); in ir_tasklet_func()
2152 spin_unlock(&video->spinlock); in ir_tasklet_func()
2199 struct video_card *video; in dv1394_init() local
2203 video = kzalloc(sizeof(*video), GFP_KERNEL); in dv1394_init()
2204 if (!video) { in dv1394_init()
2209 video->ohci = ohci; in dv1394_init()
2212 video->id = ohci->host->id << 2; in dv1394_init()
2214 video->id |= mode; in dv1394_init()
2216 video->id |= 2 + mode; in dv1394_init()
2218 video->ohci_it_ctx = -1; in dv1394_init()
2219 video->ohci_ir_ctx = -1; in dv1394_init()
2221 video->ohci_IsoXmitContextControlSet = 0; in dv1394_init()
2222 video->ohci_IsoXmitContextControlClear = 0; in dv1394_init()
2223 video->ohci_IsoXmitCommandPtr = 0; in dv1394_init()
2225 video->ohci_IsoRcvContextControlSet = 0; in dv1394_init()
2226 video->ohci_IsoRcvContextControlClear = 0; in dv1394_init()
2227 video->ohci_IsoRcvCommandPtr = 0; in dv1394_init()
2228 video->ohci_IsoRcvContextMatch = 0; in dv1394_init()
2230 video->n_frames = 0; /* flag that video is not initialized */ in dv1394_init()
2231 video->channel = 63; /* default to broadcast channel */ in dv1394_init()
2232 video->active_frame = -1; in dv1394_init()
2235 video->pal_or_ntsc = format; in dv1394_init()
2236 video->cip_n = 0; /* 0 = use builtin default */ in dv1394_init()
2237 video->cip_d = 0; in dv1394_init()
2238 video->syt_offset = 0; in dv1394_init()
2239 video->mode = mode; in dv1394_init()
2242 video->frames[i] = NULL; in dv1394_init()
2244 dma_region_init(&video->dv_buf); in dv1394_init()
2245 video->dv_buf_size = 0; in dv1394_init()
2246 dma_region_init(&video->packet_buf); in dv1394_init()
2247 video->packet_buf_size = 0; in dv1394_init()
2249 clear_bit(0, &video->open); in dv1394_init()
2250 spin_lock_init(&video->spinlock); in dv1394_init()
2251 video->dma_running = 0; in dv1394_init()
2252 mutex_init(&video->mtx); in dv1394_init()
2253 init_waitqueue_head(&video->waitq); in dv1394_init()
2254 video->fasync = NULL; in dv1394_init()
2257 INIT_LIST_HEAD(&video->list); in dv1394_init()
2258 list_add_tail(&video->list, &dv1394_cards); in dv1394_init()
2261 debug_printk("dv1394: dv1394_init() OK on ID %d\n", video->id); in dv1394_init()
2267 struct video_card *video, *tmp_video; in dv1394_remove_host() local
2272 video = NULL; in dv1394_remove_host()
2277 video = tmp_video; in dv1394_remove_host()
2284 if (video) { in dv1394_remove_host()
2285 do_dv1394_shutdown(video, 1); in dv1394_remove_host()
2286 kfree(video); in dv1394_remove_host()
2288 } while (video); in dv1394_remove_host()
2326 struct video_card *video = NULL, *tmp_vid; in dv1394_host_reset() local
2340 video = tmp_vid; in dv1394_host_reset()
2346 if (!video) in dv1394_host_reset()
2350 spin_lock_irqsave(&video->spinlock, flags); in dv1394_host_reset()
2352 if (!video->dma_running) in dv1394_host_reset()
2356 if (video->ohci_it_ctx != -1) { in dv1394_host_reset()
2359 ctx = reg_read(video->ohci, video->ohci_IsoXmitContextControlSet); in dv1394_host_reset()
2369 video->dropped_frames++; in dv1394_host_reset()
2374 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, (1 << 15)); in dv1394_host_reset()
2375 flush_pci_write(video->ohci); in dv1394_host_reset()
2378 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, (1 << 15)); in dv1394_host_reset()
2379 flush_pci_write(video->ohci); in dv1394_host_reset()
2382 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, (1 << 12)); in dv1394_host_reset()
2383 flush_pci_write(video->ohci); in dv1394_host_reset()
2386 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet), in dv1394_host_reset()
2387 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)); in dv1394_host_reset()
2392 if (video->ohci_ir_ctx != -1) { in dv1394_host_reset()
2395 ctx = reg_read(video->ohci, video->ohci_IsoRcvContextControlSet); in dv1394_host_reset()
2405 video->dropped_frames++; in dv1394_host_reset()
2411 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, (1 << 15)); in dv1394_host_reset()
2412 flush_pci_write(video->ohci); in dv1394_host_reset()
2415 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 15)); in dv1394_host_reset()
2416 flush_pci_write(video->ohci); in dv1394_host_reset()
2419 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12)); in dv1394_host_reset()
2420 flush_pci_write(video->ohci); in dv1394_host_reset()
2423 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet), in dv1394_host_reset()
2424 reg_read(video->ohci, video->ohci_IsoRcvCommandPtr)); in dv1394_host_reset()
2429 spin_unlock_irqrestore(&video->spinlock, flags); in dv1394_host_reset()
2432 wake_up_interruptible(&video->waitq); in dv1394_host_reset()