Lines Matching defs:mdc800
33 * Fix: mdc800 used sleep_on and slept with io_lock held.
53 * bugfix : The mdc800->state field gets set to READY after the
63 * The mdc800 driver gets assigned the USB Minor 32-47. The Registration
229 static struct mdc800_data* mdc800;
286 struct mdc800_data* mdc800=urb->context;
295 if (!mdc800->camera_busy)
297 mdc800->camera_busy=1;
303 if (mdc800->camera_busy && mdc800_isReady (b))
305 mdc800->camera_busy=0;
314 memcpy (mdc800->camera_response,b,8);
318 wake_up= ( mdc800->camera_request_ready > 0 )
321 ((mdc800->camera_request_ready == 1) && (!mdc800->camera_busy))
323 ((mdc800->camera_request_ready == 2) && data_received)
325 ((mdc800->camera_request_ready == 3) && (mdc800->camera_busy))
332 mdc800->camera_request_ready=0;
333 mdc800->irq_woken=1;
334 wake_up (&mdc800->irq_wait);
350 mdc800->camera_request_ready=1+mode;
352 wait_event_timeout(mdc800->irq_wait, mdc800->irq_woken, msec*HZ/1000);
353 mdc800->irq_woken = 0;
355 if (mdc800->camera_request_ready>0)
357 mdc800->camera_request_ready=0;
358 dev_err(&mdc800->dev->dev, "timeout waiting for camera.\n");
362 if (mdc800->state == NOT_CONNECTED)
364 printk(KERN_WARNING "mdc800: Camera gets disconnected "
366 mdc800->camera_request_ready=0;
379 struct mdc800_data* mdc800=urb->context;
383 dev_err(&mdc800->dev->dev,
386 mdc800->state=READY;
387 mdc800->written = 1;
388 wake_up (&mdc800->write_wait);
397 struct mdc800_data* mdc800=urb->context;
402 memcpy (mdc800->out, urb->transfer_buffer, 64);
403 mdc800->out_count=64;
404 mdc800->out_ptr=0;
405 mdc800->download_left-=64;
406 if (mdc800->download_left == 0)
408 mdc800->state=READY;
411 dev_err(&mdc800->dev->dev,
414 mdc800->downloaded = 1;
415 wake_up (&mdc800->download_wait);
426 .name = "mdc800%d",
447 if (mdc800->dev != NULL)
475 mdc800->endpoint[i]=-1;
480 mdc800->endpoint[i]=intf_desc->endpoint [j].desc.bEndpointAddress ;
487 if (mdc800->endpoint[i] == -1)
497 mutex_lock(&mdc800->io_lock);
502 mutex_unlock(&mdc800->io_lock);
506 mdc800->dev=dev;
507 mdc800->open=0;
511 mdc800->irq_urb,
512 mdc800->dev,
513 usb_rcvintpipe (mdc800->dev,mdc800->endpoint [1]),
514 mdc800->irq_urb_buffer,
517 mdc800,
522 mdc800->write_urb,
523 mdc800->dev,
524 usb_sndbulkpipe (mdc800->dev, mdc800->endpoint[0]),
525 mdc800->write_urb_buffer,
528 mdc800
532 mdc800->download_urb,
533 mdc800->dev,
534 usb_rcvbulkpipe (mdc800->dev, mdc800->endpoint [3]),
535 mdc800->download_urb_buffer,
538 mdc800
541 mdc800->state=READY;
543 mutex_unlock(&mdc800->io_lock);
545 usb_set_intfdata(intf, mdc800);
555 struct mdc800_data* mdc800 = usb_get_intfdata(intf);
559 if (mdc800) {
560 if (mdc800->state == NOT_CONNECTED)
567 mutex_lock(&mdc800->io_lock);
568 mdc800->state=NOT_CONNECTED;
570 usb_kill_urb(mdc800->irq_urb);
571 usb_kill_urb(mdc800->write_urb);
572 usb_kill_urb(mdc800->download_urb);
573 mutex_unlock(&mdc800->io_lock);
575 mdc800->dev = NULL;
606 return mdc800->pic_len;
625 mutex_lock(&mdc800->io_lock);
627 if (mdc800->state == NOT_CONNECTED)
632 if (mdc800->open)
638 mdc800->in_count=0;
639 mdc800->out_count=0;
640 mdc800->out_ptr=0;
641 mdc800->pic_index=0;
642 mdc800->pic_len=-1;
643 mdc800->download_left=0;
645 mdc800->camera_busy=0;
646 mdc800->camera_request_ready=0;
649 mdc800->irq_urb->dev = mdc800->dev;
650 retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL);
652 dev_err(&mdc800->dev->dev,
658 mdc800->open=1;
662 mutex_unlock(&mdc800->io_lock);
675 mutex_lock(&mdc800->io_lock);
676 if (mdc800->open && (mdc800->state != NOT_CONNECTED))
678 usb_kill_urb(mdc800->irq_urb);
679 usb_kill_urb(mdc800->write_urb);
680 usb_kill_urb(mdc800->download_urb);
681 mdc800->open=0;
688 mutex_unlock(&mdc800->io_lock);
702 mutex_lock(&mdc800->io_lock);
703 if (mdc800->state == NOT_CONNECTED)
705 mutex_unlock(&mdc800->io_lock);
708 if (mdc800->state == WORKING)
710 printk(KERN_WARNING "mdc800: Illegal State \"working\""
712 mutex_unlock(&mdc800->io_lock);
715 if (!mdc800->open)
717 mutex_unlock(&mdc800->io_lock);
725 mutex_unlock(&mdc800->io_lock);
729 sts=left > (mdc800->out_count-mdc800->out_ptr)?mdc800->out_count-mdc800->out_ptr:left;
734 if (mdc800->state == DOWNLOAD)
736 mdc800->out_count=0;
737 mdc800->out_ptr=0;
740 mdc800->download_urb->dev = mdc800->dev;
741 retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL);
743 dev_err(&mdc800->dev->dev,
746 mutex_unlock(&mdc800->io_lock);
749 wait_event_timeout(mdc800->download_wait, mdc800->downloaded,
751 mdc800->downloaded = 0;
752 if (mdc800->download_urb->status != 0)
754 dev_err(&mdc800->dev->dev,
757 mdc800->download_urb->status);
758 mutex_unlock(&mdc800->io_lock);
765 mutex_unlock(&mdc800->io_lock);
772 if (copy_to_user(ptr, &mdc800->out [mdc800->out_ptr],
774 mutex_unlock(&mdc800->io_lock);
779 mdc800->out_ptr+=sts;
783 mutex_unlock(&mdc800->io_lock);
799 mutex_lock(&mdc800->io_lock);
800 if (mdc800->state != READY)
802 mutex_unlock(&mdc800->io_lock);
805 if (!mdc800->open )
807 mutex_unlock(&mdc800->io_lock);
816 mutex_unlock(&mdc800->io_lock);
822 mutex_unlock(&mdc800->io_lock);
829 mdc800->in_count=0;
830 mdc800->out_count=0;
831 mdc800->out_ptr=0;
832 mdc800->download_left=0;
836 if (mdc800->in_count < 8)
838 mdc800->in[mdc800->in_count] = c;
839 mdc800->in_count++;
843 mutex_unlock(&mdc800->io_lock);
848 if (mdc800->in_count == 8)
854 dev_err(&mdc800->dev->dev,
856 mutex_unlock(&mdc800->io_lock);
860 answersize=mdc800_getAnswerSize (mdc800->in[1]);
862 mdc800->state=WORKING;
863 memcpy (mdc800->write_urb->transfer_buffer, mdc800->in,8);
864 mdc800->write_urb->dev = mdc800->dev;
865 retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL);
867 dev_err(&mdc800->dev->dev,
870 mutex_unlock(&mdc800->io_lock);
873 wait_event_timeout(mdc800->write_wait, mdc800->written, TO_WRITE_GET_READY*HZ/1000);
874 mdc800->written = 0;
875 if (mdc800->state == WORKING)
877 usb_kill_urb(mdc800->write_urb);
878 mutex_unlock(&mdc800->io_lock);
882 switch ((unsigned char) mdc800->in[1])
886 if (mdc800->pic_len < 0)
888 dev_err(&mdc800->dev->dev,
891 mdc800->state=READY;
892 mutex_unlock(&mdc800->io_lock);
895 mdc800->pic_len=-1;
898 mdc800->download_left=answersize+64;
899 mdc800->state=DOWNLOAD;
910 dev_err(&mdc800->dev->dev, "requesting answer from irq fails\n");
911 mutex_unlock(&mdc800->io_lock);
917 memcpy (mdc800->out, mdc800->camera_response,8);
920 memcpy (&mdc800->out[8], mdc800->camera_response,8);
922 mdc800->out_ptr=0;
923 mdc800->out_count=16;
926 if (mdc800->in [1] == (char) 0x07)
928 mdc800->pic_len=(int) 65536*(unsigned char) mdc800->camera_response[0]+256*(unsigned char) mdc800->camera_response[1]+(unsigned char) mdc800->camera_response[2];
930 dbg ("cached imagesize = %i",mdc800->pic_len);
938 dev_err(&mdc800->dev->dev, "Command Timeout.\n");
939 mutex_unlock(&mdc800->io_lock);
943 mdc800->state=READY;
949 mutex_unlock(&mdc800->io_lock);
981 .name = "mdc800",
997 mdc800=kzalloc (sizeof (struct mdc800_data), GFP_KERNEL);
998 if (!mdc800)
1001 mdc800->dev = NULL;
1002 mdc800->state=NOT_CONNECTED;
1003 mutex_init (&mdc800->io_lock);
1005 init_waitqueue_head (&mdc800->irq_wait);
1006 init_waitqueue_head (&mdc800->write_wait);
1007 init_waitqueue_head (&mdc800->download_wait);
1009 mdc800->irq_woken = 0;
1010 mdc800->downloaded = 0;
1011 mdc800->written = 0;
1013 mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL);
1014 if (!mdc800->irq_urb_buffer)
1016 mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL);
1017 if (!mdc800->write_urb_buffer)
1019 mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL);
1020 if (!mdc800->download_urb_buffer)
1023 mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL);
1024 if (!mdc800->irq_urb)
1026 mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL);
1027 if (!mdc800->download_urb)
1029 mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL);
1030 if (!mdc800->write_urb)
1047 if (mdc800 != NULL)
1049 printk(KERN_ERR "mdc800: can't alloc memory!\n");
1051 kfree(mdc800->download_urb_buffer);
1052 kfree(mdc800->write_urb_buffer);
1053 kfree(mdc800->irq_urb_buffer);
1055 usb_free_urb(mdc800->write_urb);
1056 usb_free_urb(mdc800->download_urb);
1057 usb_free_urb(mdc800->irq_urb);
1059 kfree (mdc800);
1061 mdc800 = NULL;
1070 usb_free_urb (mdc800->irq_urb);
1071 usb_free_urb (mdc800->download_urb);
1072 usb_free_urb (mdc800->write_urb);
1074 kfree (mdc800->irq_urb_buffer);
1075 kfree (mdc800->write_urb_buffer);
1076 kfree (mdc800->download_urb_buffer);
1078 kfree (mdc800);
1079 mdc800 = NULL;