• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/ieee1394/

Lines Matching refs:video

7  *  video1394.c - video driver for OHCI 1394 boards
155 static struct frame* frame_new(unsigned int frame_num, struct video_card *video)
161 f->video = video;
164 f->header_pool = pci_alloc_consistent(f->video->ohci->dev, PAGE_SIZE, &f->header_pool_dma);
178 f->descriptor_pool = pci_alloc_consistent(f->video->ohci->dev,
182 pci_free_consistent(f->video->ohci->dev, PAGE_SIZE, f->header_pool, f->header_pool_dma);
198 pci_free_consistent(f->video->ohci->dev, PAGE_SIZE, f->header_pool, f->header_pool_dma);
199 pci_free_consistent(f->video->ohci->dev, f->descriptor_pool_size, f->descriptor_pool, f->descriptor_pool_dma);
209 Frame_prepare() must be called OUTSIDE the video->spinlock.
211 it should be called WITH the video->mtx taken.
214 static void frame_prepare(struct video_card *video, unsigned int this_frame)
216 struct frame *f = video->frames[this_frame];
241 if (video->pal_or_ntsc == DV1394_PAL)
288 if (video->cip_accum > (video->cip_d - video->cip_n)) {
291 video->cip_accum -= (video->cip_d - video->cip_n);
294 video->cip_accum += video->cip_n;
353 reg_read(video->ohci, OHCI1394_NodeID) & 0x3F,
354 video->continuity_counter,
355 video->pal_or_ntsc,
360 video->continuity_counter++;
367 fill_output_more_immediate( &(block->u.out.omi), 1, video->channel, 0, payload_size);
418 dma_region_offset_to_bus(&video->dv_buf,
419 data_p - (unsigned long) video->dv_buf.kvirt));
433 dma_region_offset_to_bus(&video->dv_buf,
434 data_p + PAGE_SIZE - (data_p % PAGE_SIZE) - (unsigned long) video->dv_buf.kvirt));
468 dma_region_offset_to_bus(&video->dv_buf,
469 data_p - (unsigned long) video->dv_buf.kvirt));
511 dma_region_sync_for_device(&video->dv_buf, f->data - (unsigned long) video->dv_buf.kvirt, video->frame_size);
514 spin_lock_irqsave(&video->spinlock, irq_flags);
518 video->n_clear_frames--;
520 last_frame = video->first_clear_frame - 1;
522 last_frame = video->n_frames-1;
524 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames;
527 this_frame, video->active_frame, video->n_clear_frames, video->first_clear_frame, last_frame);
535 if (video->active_frame != -1) {
539 if (video->frames[last_frame]->frame_end_branch) {
543 *(video->frames[last_frame]->frame_end_branch) = cpu_to_le32(f->descriptor_pool_dma | f->first_n_descriptors);
549 temp = le32_to_cpu(*(video->frames[last_frame]->frame_end_branch - 2));
551 *(video->frames[last_frame]->frame_end_branch - 2) = cpu_to_le32(temp);
554 flush_pci_write(video->ohci);
577 video->active_frame = this_frame;
580 reg_write(video->ohci, video->ohci_IsoXmitCommandPtr,
581 video->frames[video->active_frame]->descriptor_pool_dma |
588 cycleTimer = reg_read(video->ohci, OHCI1394_IsochronousCycleTimer);
619 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, 0xFFFFFFFF);
635 video->dma_running = 1;
638 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, 0x8000);
639 flush_pci_write(video->ohci);
644 (reg_read(video->ohci, OHCI1394_IsochronousCycleTimer) >> 12) & 0x1FFF,
645 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet),
646 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr));
658 if (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) {
666 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet),
667 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)
670 if ( ! (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) {
672 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & 0x1F);
681 spin_unlock_irqrestore(&video->spinlock, irq_flags);
718 case 3: /* 9 Audio blocks interleaved with video */
732 static void start_dma_receive(struct video_card *video)
734 if (video->first_run == 1) {
735 video->first_run = 0;
738 video->n_clear_frames = 0;
739 video->first_clear_frame = -1;
740 video->current_packet = 0;
741 video->active_frame = 0;
744 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, 0xFFFFFFFF);
748 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, 0x40000000);
751 reg_write(video->ohci, video->ohci_IsoRcvContextMatch, 0xf0000000 | video->channel);
754 reg_write(video->ohci, video->ohci_IsoRcvCommandPtr,
755 video->frames[0]->descriptor_pool_dma | 1); /* Z=1 */
758 video->dma_running = 1;
761 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, 0x8000);
762 flush_pci_write(video->ohci);
772 if (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) {
777 if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
779 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F);
784 } else if ( reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 11) ) {
786 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & 0x1F);
789 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12));
798 static void receive_packets(struct video_card *video)
810 spin_lock_irqsave(&video->spinlock, irq_flags);
812 for (j = 0; j < video->n_frames; j++) {
816 *(f->frame_end_branch) = cpu_to_le32(video->frames[j]->descriptor_pool_dma | 1); /* set Z=1 */
818 f = video->frames[j];
825 data = ((struct packet*)video->packet_buf.kvirt) + f->frame_num * MAX_PACKETS + i;
826 data_dma = dma_region_offset_to_bus( &video->packet_buf,
827 ((unsigned long) data - (unsigned long) video->packet_buf.kvirt) );
844 spin_unlock_irqrestore(&video->spinlock, irq_flags);
852 static int do_dv1394_init(struct video_card *video, struct dv1394_init *init)
859 debug_printk("dv1394: initialising %d\n", video->id);
889 if (video->dv_buf.kvirt && video->dv_buf_size != new_buf_size) {
897 do_dv1394_shutdown(video, 0);
900 spin_lock_irqsave(&video->ohci->IR_channel_lock, flags);
901 if (video->ohci->ISO_channel_usage & chan_mask) {
902 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags);
906 video->ohci->ISO_channel_usage |= chan_mask;
907 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags);
909 video->channel = init->channel;
911 /* initialize misc. fields of video */
912 video->n_frames = init->n_frames;
913 video->pal_or_ntsc = init->format;
915 video->cip_accum = 0;
916 video->continuity_counter = 0;
918 video->active_frame = -1;
919 video->first_clear_frame = 0;
920 video->n_clear_frames = video->n_frames;
921 video->dropped_frames = 0;
923 video->write_off = 0;
925 video->first_run = 1;
926 video->current_packet = -1;
927 video->first_frame = 0;
929 if (video->pal_or_ntsc == DV1394_NTSC) {
930 video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_NTSC;
931 video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_NTSC;
932 video->frame_size = DV1394_NTSC_FRAME_SIZE;
934 video->cip_n = init->cip_n != 0 ? init->cip_n : CIP_N_PAL;
935 video->cip_d = init->cip_d != 0 ? init->cip_d : CIP_D_PAL;
936 video->frame_size = DV1394_PAL_FRAME_SIZE;
939 video->syt_offset = init->syt_offset;
943 if (video->ohci_it_ctx == -1) {
944 ohci1394_init_iso_tasklet(&video->it_tasklet, OHCI_ISO_TRANSMIT,
945 it_tasklet_func, (unsigned long) video);
947 if (ohci1394_register_iso_tasklet(video->ohci, &video->it_tasklet) < 0) {
953 video->ohci_it_ctx = video->it_tasklet.context;
954 debug_printk("dv1394: claimed IT DMA context %d\n", video->ohci_it_ctx);
957 if (video->ohci_ir_ctx == -1) {
958 ohci1394_init_iso_tasklet(&video->ir_tasklet, OHCI_ISO_RECEIVE,
959 ir_tasklet_func, (unsigned long) video);
961 if (ohci1394_register_iso_tasklet(video->ohci, &video->ir_tasklet) < 0) {
966 video->ohci_ir_ctx = video->ir_tasklet.context;
967 debug_printk("dv1394: claimed IR DMA context %d\n", video->ohci_ir_ctx);
972 video->frames[i] = frame_new(i, video);
974 if (!video->frames[i]) {
981 if (!video->dv_buf.kvirt) {
983 retval = dma_region_alloc(&video->dv_buf, new_buf_size, video->ohci->dev, PCI_DMA_TODEVICE);
987 video->dv_buf_size = new_buf_size;
990 video->n_frames, video->dv_buf.n_pages,
991 video->dv_buf.n_dma_pages, video->dv_buf_size);
995 for (i = 0; i < video->n_frames; i++)
996 video->frames[i]->data = (unsigned long) video->dv_buf.kvirt + i * video->frame_size;
998 if (!video->packet_buf.kvirt) {
1000 video->packet_buf_size = sizeof(struct packet) * video->n_frames * MAX_PACKETS;
1001 if (video->packet_buf_size % PAGE_SIZE)
1002 video->packet_buf_size += PAGE_SIZE - (video->packet_buf_size % PAGE_SIZE);
1004 retval = dma_region_alloc(&video->packet_buf, video->packet_buf_size,
1005 video->ohci->dev, PCI_DMA_FROMDEVICE);
1010 video->n_frames*MAX_PACKETS, video->packet_buf.n_pages,
1011 video->packet_buf.n_dma_pages, video->packet_buf_size);
1016 video->ohci_IsoXmitContextControlSet = OHCI1394_IsoXmitContextControlSet+16*video->ohci_it_ctx;
1017 video->ohci_IsoXmitContextControlClear = OHCI1394_IsoXmitContextControlClear+16*video->ohci_it_ctx;
1018 video->ohci_IsoXmitCommandPtr = OHCI1394_IsoXmitCommandPtr+16*video->ohci_it_ctx;
1021 reg_write(video->ohci, OHCI1394_IsoXmitIntMaskSet, (1 << video->ohci_it_ctx));
1022 debug_printk("dv1394: interrupts enabled for IT context %d\n", video->ohci_it_ctx);
1026 video->ohci_IsoRcvContextControlSet = OHCI1394_IsoRcvContextControlSet+32*video->ohci_ir_ctx;
1027 video->ohci_IsoRcvContextControlClear = OHCI1394_IsoRcvContextControlClear+32*video->ohci_ir_ctx;
1028 video->ohci_IsoRcvCommandPtr = OHCI1394_IsoRcvCommandPtr+32*video->ohci_ir_ctx;
1029 video->ohci_IsoRcvContextMatch = OHCI1394_IsoRcvContextMatch+32*video->ohci_ir_ctx;
1032 reg_write(video->ohci, OHCI1394_IsoRecvIntMaskSet, (1 << video->ohci_ir_ctx) );
1033 debug_printk("dv1394: interrupts enabled for IR context %d\n", video->ohci_ir_ctx);
1038 do_dv1394_shutdown(video, 1);
1045 static int do_dv1394_init_default(struct video_card *video)
1051 init.channel = video->channel;
1052 init.format = video->pal_or_ntsc;
1053 init.cip_n = video->cip_n;
1054 init.cip_d = video->cip_d;
1055 init.syt_offset = video->syt_offset;
1057 return do_dv1394_init(video, &init);
1061 static void stop_dma(struct video_card *video)
1067 spin_lock_irqsave(&video->spinlock, flags);
1069 video->dma_running = 0;
1071 if ( (video->ohci_it_ctx == -1) && (video->ohci_ir_ctx == -1) )
1075 if ( (video->active_frame != -1) ||
1076 (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
1077 (reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) {
1080 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, (1 << 15));
1081 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, (1 << 15));
1082 flush_pci_write(video->ohci);
1084 video->active_frame = -1;
1085 video->first_run = 1;
1094 if ( (reg_read(video->ohci, video->ohci_IsoXmitContextControlClear) & (1 << 10)) ||
1095 (reg_read(video->ohci, video->ohci_IsoRcvContextControlClear) & (1 << 10)) ) {
1115 spin_unlock_irqrestore(&video->spinlock, flags);
1120 static void do_dv1394_shutdown(struct video_card *video, int free_dv_buf)
1127 stop_dma(video);
1130 if (video->ohci_it_ctx != -1) {
1131 video->ohci_IsoXmitContextControlSet = 0;
1132 video->ohci_IsoXmitContextControlClear = 0;
1133 video->ohci_IsoXmitCommandPtr = 0;
1136 reg_write(video->ohci, OHCI1394_IsoXmitIntMaskClear, (1 << video->ohci_it_ctx));
1139 ohci1394_unregister_iso_tasklet(video->ohci, &video->it_tasklet);
1140 debug_printk("dv1394: IT context %d released\n", video->ohci_it_ctx);
1141 video->ohci_it_ctx = -1;
1144 if (video->ohci_ir_ctx != -1) {
1145 video->ohci_IsoRcvContextControlSet = 0;
1146 video->ohci_IsoRcvContextControlClear = 0;
1147 video->ohci_IsoRcvCommandPtr = 0;
1148 video->ohci_IsoRcvContextMatch = 0;
1151 reg_write(video->ohci, OHCI1394_IsoRecvIntMaskClear, (1 << video->ohci_ir_ctx));
1154 ohci1394_unregister_iso_tasklet(video->ohci, &video->ir_tasklet);
1155 debug_printk("dv1394: IR context %d released\n", video->ohci_ir_ctx);
1156 video->ohci_ir_ctx = -1;
1160 if (video->channel != -1) {
1164 chan_mask = (u64)1 << video->channel;
1166 spin_lock_irqsave(&video->ohci->IR_channel_lock, flags);
1167 video->ohci->ISO_channel_usage &= ~(chan_mask);
1168 spin_unlock_irqrestore(&video->ohci->IR_channel_lock, flags);
1170 video->channel = -1;
1175 if (video->frames[i])
1176 frame_delete(video->frames[i]);
1177 video->frames[i] = NULL;
1180 video->n_frames = 0;
1186 dma_region_free(&video->dv_buf);
1187 video->dv_buf_size = 0;
1191 dma_region_free(&video->packet_buf);
1192 video->packet_buf_size = 0;
1223 struct video_card *video = file_to_video_card(file);
1229 * video->mtx and subsequently call copy_to/from_user which will
1232 if (!mutex_trylock(&video->mtx))
1235 if ( ! video_card_initialized(video) ) {
1236 retval = do_dv1394_init_default(video);
1241 retval = dma_region_mmap(&video->dv_buf, file, vma);
1243 mutex_unlock(&video->mtx);
1252 struct video_card *video = file_to_video_card(file);
1256 poll_wait(file, &video->waitq, wait);
1258 spin_lock_irqsave(&video->spinlock, flags);
1259 if ( video->n_frames == 0 ) {
1261 } else if ( video->active_frame == -1 ) {
1266 if (video->n_clear_frames >0)
1269 spin_unlock_irqrestore(&video->spinlock, flags);
1279 struct video_card *video = file_to_video_card(file);
1281 return fasync_helper(fd, file, on, &video->fasync);
1286 struct video_card *video = file_to_video_card(file);
1295 if (!mutex_trylock(&video->mtx))
1298 if (mutex_lock_interruptible(&video->mtx))
1302 if ( !video_card_initialized(video) ) {
1303 ret = do_dv1394_init_default(video);
1305 mutex_unlock(&video->mtx);
1311 add_wait_queue(&video->waitq, &wait);
1321 spin_lock_irqsave(&video->spinlock, flags);
1323 target_frame = video->first_clear_frame;
1325 spin_unlock_irqrestore(&video->spinlock, flags);
1327 if (video->frames[target_frame]->state == FRAME_CLEAR) {
1330 cnt = video->frame_size - (video->write_off - target_frame * video->frame_size);
1358 if (copy_from_user(video->dv_buf.kvirt + video->write_off, buffer, cnt)) {
1364 video->write_off = (video->write_off + cnt) % (video->n_frames * video->frame_size);
1370 if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames))
1371 frame_prepare(video, target_frame);
1374 remove_wait_queue(&video->waitq, &wait);
1376 mutex_unlock(&video->mtx);
1383 struct video_card *video = file_to_video_card(file);
1392 if (!mutex_trylock(&video->mtx))
1395 if (mutex_lock_interruptible(&video->mtx))
1399 if ( !video_card_initialized(video) ) {
1400 ret = do_dv1394_init_default(video);
1402 mutex_unlock(&video->mtx);
1405 video->continuity_counter = -1;
1407 receive_packets(video);
1409 start_dma_receive(video);
1413 add_wait_queue(&video->waitq, &wait);
1423 spin_lock_irqsave(&video->spinlock, flags);
1425 target_frame = video->first_clear_frame;
1427 spin_unlock_irqrestore(&video->spinlock, flags);
1430 video->n_clear_frames > 0 &&
1431 video->frames[target_frame]->state == FRAME_CLEAR) {
1434 cnt = video->frame_size - (video->write_off - target_frame * video->frame_size);
1462 if (copy_to_user(buffer, video->dv_buf.kvirt + video->write_off, cnt)) {
1468 video->write_off = (video->write_off + cnt) % (video->n_frames * video->frame_size);
1474 if (video->write_off == video->frame_size * ((target_frame + 1) % video->n_frames)) {
1475 spin_lock_irqsave(&video->spinlock, flags);
1476 video->n_clear_frames--;
1477 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames;
1478 spin_unlock_irqrestore(&video->spinlock, flags);
1482 remove_wait_queue(&video->waitq, &wait);
1484 mutex_unlock(&video->mtx);
1493 struct video_card *video = file_to_video_card(file);
1502 if (!mutex_trylock(&video->mtx))
1505 if (mutex_lock_interruptible(&video->mtx))
1514 if ( !video_card_initialized(video) ) {
1515 ret = do_dv1394_init_default(video);
1522 if (n_submit > video->n_frames) {
1529 add_wait_queue(&video->waitq, &wait);
1532 spin_lock_irqsave(&video->spinlock, flags);
1534 /* wait until video->first_clear_frame is really CLEAR */
1535 while (video->frames[video->first_clear_frame]->state != FRAME_CLEAR) {
1537 spin_unlock_irqrestore(&video->spinlock, flags);
1540 remove_wait_queue(&video->waitq, &wait);
1549 spin_lock_irqsave(&video->spinlock, flags);
1551 spin_unlock_irqrestore(&video->spinlock, flags);
1553 remove_wait_queue(&video->waitq, &wait);
1556 frame_prepare(video, video->first_clear_frame);
1568 if ( !video_card_initialized(video) ) {
1579 if (n_wait > (video->n_frames-1) ) {
1584 add_wait_queue(&video->waitq, &wait);
1587 spin_lock_irqsave(&video->spinlock, flags);
1589 while (video->n_clear_frames < n_wait) {
1591 spin_unlock_irqrestore(&video->spinlock, flags);
1594 remove_wait_queue(&video->waitq, &wait);
1603 spin_lock_irqsave(&video->spinlock, flags);
1606 spin_unlock_irqrestore(&video->spinlock, flags);
1608 remove_wait_queue(&video->waitq, &wait);
1617 if ( !video_card_initialized(video) ) {
1625 if (n_recv > (video->n_frames-1) ) {
1630 spin_lock_irqsave(&video->spinlock, flags);
1633 video->n_clear_frames -= n_recv;
1636 video->first_clear_frame = (video->first_clear_frame + n_recv) % video->n_frames;
1639 video->dropped_frames = 0;
1641 spin_unlock_irqrestore(&video->spinlock, flags);
1648 if ( !video_card_initialized(video) ) {
1649 ret = do_dv1394_init_default(video);
1654 video->continuity_counter = -1;
1656 receive_packets(video);
1658 start_dma_receive(video);
1667 ret = do_dv1394_init_default(video);
1673 ret = do_dv1394_init(video, &init);
1679 do_dv1394_shutdown(video, 0);
1687 if ( !video_card_initialized(video) ) {
1693 status.init.channel = video->channel;
1694 status.init.n_frames = video->n_frames;
1695 status.init.format = video->pal_or_ntsc;
1696 status.init.cip_n = video->cip_n;
1697 status.init.cip_d = video->cip_d;
1698 status.init.syt_offset = video->syt_offset;
1700 status.first_clear_frame = video->first_clear_frame;
1703 spin_lock_irqsave(&video->spinlock, flags);
1705 status.active_frame = video->active_frame;
1706 status.n_clear_frames = video->n_clear_frames;
1708 status.dropped_frames = video->dropped_frames;
1711 video->dropped_frames = 0;
1713 spin_unlock_irqrestore(&video->spinlock, flags);
1729 mutex_unlock(&video->mtx);
1737 struct video_card *video = NULL;
1740 video = file->private_data;
1752 video = p;
1759 if (!video) {
1764 file->private_data = (void*) video;
1769 if ( test_and_set_bit(0, &video->open) ) {
1770 /* video is already open by someone else */
1786 struct video_card *video = file_to_video_card(file);
1789 do_dv1394_shutdown(video, 1);
1792 clear_bit(0, &video->open);
1803 struct video_card *video = (struct video_card*) data;
1805 spin_lock(&video->spinlock);
1807 if (!video->dma_running)
1811 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet),
1812 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr)
1816 if ( (video->ohci_it_ctx != -1) &&
1817 (reg_read(video->ohci, video->ohci_IsoXmitContextControlSet) & (1 << 10)) ) {
1823 if (video->active_frame == -1)
1826 frame = video->active_frame;
1829 for (i = 0; i < video->n_frames; i++, frame = (frame+1) % video->n_frames) {
1832 f = video->frames[frame];
1853 prev_frame += video->n_frames;
1854 prev_f = video->frames[prev_frame];
1862 video->n_clear_frames++;
1864 video->active_frame = frame;
1889 next_frame = video->frames[ (frame+1) % video->n_frames ];
1902 ts_cyc += f->n_packets + video->syt_offset ;
1928 video->dropped_frames++;
1935 kill_fasync(&video->fasync, SIGIO, POLL_OUT);
1938 wake_up_interruptible(&video->waitq);
1942 spin_unlock(&video->spinlock);
1948 struct video_card *video = (struct video_card*) data;
1950 spin_lock(&video->spinlock);
1952 if (!video->dma_running)
1955 if ( (video->ohci_ir_ctx != -1) &&
1956 (reg_read(video->ohci, video->ohci_IsoRcvContextControlSet) & (1 << 10)) ) {
1971 for (i = 0; i < video->n_frames*MAX_PACKETS; i++) {
1972 struct packet *p = dma_region_i(&video->packet_buf, struct packet, video->current_packet);
1975 dma_region_sync_for_cpu(&video->packet_buf,
1976 (unsigned long) p - (unsigned long) video->packet_buf.kvirt,
1982 f = video->frames[video->current_packet / MAX_PACKETS];
1983 block = &(f->descriptor_pool[video->current_packet % MAX_PACKETS]);
1989 f = video->frames[video->active_frame];
1999 if ( video->continuity_counter != -1 && dbc > ((video->continuity_counter + 1) % 256) )
2002 video->dropped_frames += video->n_clear_frames + 1;
2003 video->first_frame = 0;
2004 video->n_clear_frames = 0;
2005 video->first_clear_frame = -1;
2007 video->continuity_counter = dbc;
2009 if (!video->first_frame) {
2011 video->first_frame = 1;
2017 video->n_clear_frames++;
2018 if (video->n_clear_frames > video->n_frames) {
2019 video->dropped_frames++;
2021 video->n_clear_frames = video->n_frames-1;
2022 video->first_clear_frame = (video->first_clear_frame + 1) % video->n_frames;
2024 if (video->first_clear_frame == -1)
2025 video->first_clear_frame = video->active_frame;
2028 video->active_frame = (video->active_frame + 1) % video->n_frames;
2029 f = video->frames[video->active_frame];
2031 video->active_frame, video->n_clear_frames, video->first_clear_frame);
2033 if (video->first_frame) {
2040 if (f->n_packets > (video->frame_size / 480)) {
2058 next_i = video->current_packet;
2059 f = video->frames[next_i / MAX_PACKETS];
2066 prev_i = (next_i == 0) ? (MAX_PACKETS * video->n_frames - 1) : (next_i - 1);
2067 f = video->frames[prev_i / MAX_PACKETS];
2078 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12));
2081 video->current_packet = (video->current_packet + 1) % (MAX_PACKETS * video->n_frames);
2090 kill_fasync(&video->fasync, SIGIO, POLL_IN);
2093 wake_up_interruptible(&video->waitq);
2097 spin_unlock(&video->spinlock);
2145 struct video_card *video;
2149 video = kzalloc(sizeof(*video), GFP_KERNEL);
2150 if (!video) {
2155 video->ohci = ohci;
2158 video->id = ohci->host->id << 2;
2160 video->id |= mode;
2162 video->id |= 2 + mode;
2164 video->ohci_it_ctx = -1;
2165 video->ohci_ir_ctx = -1;
2167 video->ohci_IsoXmitContextControlSet = 0;
2168 video->ohci_IsoXmitContextControlClear = 0;
2169 video->ohci_IsoXmitCommandPtr = 0;
2171 video->ohci_IsoRcvContextControlSet = 0;
2172 video->ohci_IsoRcvContextControlClear = 0;
2173 video->ohci_IsoRcvCommandPtr = 0;
2174 video->ohci_IsoRcvContextMatch = 0;
2176 video->n_frames = 0; /* flag that video is not initialized */
2177 video->channel = 63; /* default to broadcast channel */
2178 video->active_frame = -1;
2181 video->pal_or_ntsc = format;
2182 video->cip_n = 0; /* 0 = use builtin default */
2183 video->cip_d = 0;
2184 video->syt_offset = 0;
2185 video->mode = mode;
2188 video->frames[i] = NULL;
2190 dma_region_init(&video->dv_buf);
2191 video->dv_buf_size = 0;
2192 dma_region_init(&video->packet_buf);
2193 video->packet_buf_size = 0;
2195 clear_bit(0, &video->open);
2196 spin_lock_init(&video->spinlock);
2197 video->dma_running = 0;
2198 mutex_init(&video->mtx);
2199 init_waitqueue_head(&video->waitq);
2200 video->fasync = NULL;
2203 INIT_LIST_HEAD(&video->list);
2204 list_add_tail(&video->list, &dv1394_cards);
2207 debug_printk("dv1394: dv1394_init() OK on ID %d\n", video->id);
2213 struct video_card *video, *tmp_video;
2218 video = NULL;
2223 video = tmp_video;
2230 if (video) {
2231 do_dv1394_shutdown(video, 1);
2232 kfree(video);
2234 } while (video);
2271 struct video_card *video = NULL, *tmp_vid;
2282 video = tmp_vid;
2288 if (!video)
2292 spin_lock_irqsave(&video->spinlock, flags);
2294 if (!video->dma_running)
2298 if (video->ohci_it_ctx != -1) {
2301 ctx = reg_read(video->ohci, video->ohci_IsoXmitContextControlSet);
2311 video->dropped_frames++;
2316 reg_write(video->ohci, video->ohci_IsoXmitContextControlClear, (1 << 15));
2317 flush_pci_write(video->ohci);
2320 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, (1 << 15));
2321 flush_pci_write(video->ohci);
2324 reg_write(video->ohci, video->ohci_IsoXmitContextControlSet, (1 << 12));
2325 flush_pci_write(video->ohci);
2328 reg_read(video->ohci, video->ohci_IsoXmitContextControlSet),
2329 reg_read(video->ohci, video->ohci_IsoXmitCommandPtr));
2334 if (video->ohci_ir_ctx != -1) {
2337 ctx = reg_read(video->ohci, video->ohci_IsoRcvContextControlSet);
2347 video->dropped_frames++;
2352 reg_write(video->ohci, video->ohci_IsoRcvContextControlClear, (1 << 15));
2353 flush_pci_write(video->ohci);
2356 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 15));
2357 flush_pci_write(video->ohci);
2360 reg_write(video->ohci, video->ohci_IsoRcvContextControlSet, (1 << 12));
2361 flush_pci_write(video->ohci);
2364 reg_read(video->ohci, video->ohci_IsoRcvContextControlSet),
2365 reg_read(video->ohci, video->ohci_IsoRcvCommandPtr));
2370 spin_unlock_irqrestore(&video->spinlock, flags);
2373 wake_up_interruptible(&video->waitq);