• Home
  • Raw
  • Download

Lines Matching refs:mdc800

216 static struct mdc800_data* mdc800;  variable
273 struct mdc800_data* mdc800=urb->context; in mdc800_usb_irq() local
274 struct device *dev = &mdc800->dev->dev; in mdc800_usb_irq()
280 if (!mdc800->camera_busy) in mdc800_usb_irq()
282 mdc800->camera_busy=1; in mdc800_usb_irq()
288 if (mdc800->camera_busy && mdc800_isReady (b)) in mdc800_usb_irq()
290 mdc800->camera_busy=0; in mdc800_usb_irq()
299 memcpy (mdc800->camera_response,b,8); in mdc800_usb_irq()
303 wake_up= ( mdc800->camera_request_ready > 0 ) in mdc800_usb_irq()
306 ((mdc800->camera_request_ready == 1) && (!mdc800->camera_busy)) in mdc800_usb_irq()
308 ((mdc800->camera_request_ready == 2) && data_received) in mdc800_usb_irq()
310 ((mdc800->camera_request_ready == 3) && (mdc800->camera_busy)) in mdc800_usb_irq()
317 mdc800->camera_request_ready=0; in mdc800_usb_irq()
318 mdc800->irq_woken=1; in mdc800_usb_irq()
319 wake_up (&mdc800->irq_wait); in mdc800_usb_irq()
335 mdc800->camera_request_ready=1+mode; in mdc800_usb_waitForIRQ()
337 wait_event_timeout(mdc800->irq_wait, mdc800->irq_woken, in mdc800_usb_waitForIRQ()
339 mdc800->irq_woken = 0; in mdc800_usb_waitForIRQ()
341 if (mdc800->camera_request_ready>0) in mdc800_usb_waitForIRQ()
343 mdc800->camera_request_ready=0; in mdc800_usb_waitForIRQ()
344 dev_err(&mdc800->dev->dev, "timeout waiting for camera.\n"); in mdc800_usb_waitForIRQ()
348 if (mdc800->state == NOT_CONNECTED) in mdc800_usb_waitForIRQ()
352 mdc800->camera_request_ready=0; in mdc800_usb_waitForIRQ()
365 struct mdc800_data* mdc800=urb->context; in mdc800_usb_write_notify() local
369 dev_err(&mdc800->dev->dev, in mdc800_usb_write_notify()
372 mdc800->state=READY; in mdc800_usb_write_notify()
373 mdc800->written = 1; in mdc800_usb_write_notify()
374 wake_up (&mdc800->write_wait); in mdc800_usb_write_notify()
383 struct mdc800_data* mdc800=urb->context; in mdc800_usb_download_notify() local
388 memcpy (mdc800->out, urb->transfer_buffer, 64); in mdc800_usb_download_notify()
389 mdc800->out_count=64; in mdc800_usb_download_notify()
390 mdc800->out_ptr=0; in mdc800_usb_download_notify()
391 mdc800->download_left-=64; in mdc800_usb_download_notify()
392 if (mdc800->download_left == 0) in mdc800_usb_download_notify()
394 mdc800->state=READY; in mdc800_usb_download_notify()
397 dev_err(&mdc800->dev->dev, in mdc800_usb_download_notify()
400 mdc800->downloaded = 1; in mdc800_usb_download_notify()
401 wake_up (&mdc800->download_wait); in mdc800_usb_download_notify()
433 if (mdc800->dev != NULL) in mdc800_usb_probe()
461 mdc800->endpoint[i]=-1; in mdc800_usb_probe()
466 mdc800->endpoint[i]=intf_desc->endpoint [j].desc.bEndpointAddress ; in mdc800_usb_probe()
473 if (mdc800->endpoint[i] == -1) in mdc800_usb_probe()
483 mutex_lock(&mdc800->io_lock); in mdc800_usb_probe()
488 mutex_unlock(&mdc800->io_lock); in mdc800_usb_probe()
492 mdc800->dev=dev; in mdc800_usb_probe()
493 mdc800->open=0; in mdc800_usb_probe()
497 mdc800->irq_urb, in mdc800_usb_probe()
498 mdc800->dev, in mdc800_usb_probe()
499 usb_rcvintpipe (mdc800->dev,mdc800->endpoint [1]), in mdc800_usb_probe()
500 mdc800->irq_urb_buffer, in mdc800_usb_probe()
503 mdc800, in mdc800_usb_probe()
508 mdc800->write_urb, in mdc800_usb_probe()
509 mdc800->dev, in mdc800_usb_probe()
510 usb_sndbulkpipe (mdc800->dev, mdc800->endpoint[0]), in mdc800_usb_probe()
511 mdc800->write_urb_buffer, in mdc800_usb_probe()
514 mdc800 in mdc800_usb_probe()
518 mdc800->download_urb, in mdc800_usb_probe()
519 mdc800->dev, in mdc800_usb_probe()
520 usb_rcvbulkpipe (mdc800->dev, mdc800->endpoint [3]), in mdc800_usb_probe()
521 mdc800->download_urb_buffer, in mdc800_usb_probe()
524 mdc800 in mdc800_usb_probe()
527 mdc800->state=READY; in mdc800_usb_probe()
529 mutex_unlock(&mdc800->io_lock); in mdc800_usb_probe()
531 usb_set_intfdata(intf, mdc800); in mdc800_usb_probe()
541 struct mdc800_data* mdc800 = usb_get_intfdata(intf); in mdc800_usb_disconnect() local
545 if (mdc800) { in mdc800_usb_disconnect()
546 if (mdc800->state == NOT_CONNECTED) in mdc800_usb_disconnect()
553 mutex_lock(&mdc800->io_lock); in mdc800_usb_disconnect()
554 mdc800->state=NOT_CONNECTED; in mdc800_usb_disconnect()
556 usb_kill_urb(mdc800->irq_urb); in mdc800_usb_disconnect()
557 usb_kill_urb(mdc800->write_urb); in mdc800_usb_disconnect()
558 usb_kill_urb(mdc800->download_urb); in mdc800_usb_disconnect()
559 mutex_unlock(&mdc800->io_lock); in mdc800_usb_disconnect()
561 mdc800->dev = NULL; in mdc800_usb_disconnect()
592 return mdc800->pic_len; in mdc800_getAnswerSize()
611 mutex_lock(&mdc800->io_lock); in mdc800_device_open()
613 if (mdc800->state == NOT_CONNECTED) in mdc800_device_open()
618 if (mdc800->open) in mdc800_device_open()
624 mdc800->in_count=0; in mdc800_device_open()
625 mdc800->out_count=0; in mdc800_device_open()
626 mdc800->out_ptr=0; in mdc800_device_open()
627 mdc800->pic_index=0; in mdc800_device_open()
628 mdc800->pic_len=-1; in mdc800_device_open()
629 mdc800->download_left=0; in mdc800_device_open()
631 mdc800->camera_busy=0; in mdc800_device_open()
632 mdc800->camera_request_ready=0; in mdc800_device_open()
635 mdc800->irq_urb->dev = mdc800->dev; in mdc800_device_open()
636 retval = usb_submit_urb (mdc800->irq_urb, GFP_KERNEL); in mdc800_device_open()
638 dev_err(&mdc800->dev->dev, in mdc800_device_open()
644 mdc800->open=1; in mdc800_device_open()
645 dev_dbg(&mdc800->dev->dev, "Mustek MDC800 device opened.\n"); in mdc800_device_open()
648 mutex_unlock(&mdc800->io_lock); in mdc800_device_open()
660 mutex_lock(&mdc800->io_lock); in mdc800_device_release()
661 if (mdc800->open && (mdc800->state != NOT_CONNECTED)) in mdc800_device_release()
663 usb_kill_urb(mdc800->irq_urb); in mdc800_device_release()
664 usb_kill_urb(mdc800->write_urb); in mdc800_device_release()
665 usb_kill_urb(mdc800->download_urb); in mdc800_device_release()
666 mdc800->open=0; in mdc800_device_release()
673 mutex_unlock(&mdc800->io_lock); in mdc800_device_release()
687 mutex_lock(&mdc800->io_lock); in mdc800_device_read()
688 if (mdc800->state == NOT_CONNECTED) in mdc800_device_read()
690 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
693 if (mdc800->state == WORKING) in mdc800_device_read()
697 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
700 if (!mdc800->open) in mdc800_device_read()
702 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
710 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
714 sts=left > (mdc800->out_count-mdc800->out_ptr)?mdc800->out_count-mdc800->out_ptr:left; in mdc800_device_read()
719 if (mdc800->state == DOWNLOAD) in mdc800_device_read()
721 mdc800->out_count=0; in mdc800_device_read()
722 mdc800->out_ptr=0; in mdc800_device_read()
725 mdc800->download_urb->dev = mdc800->dev; in mdc800_device_read()
726 retval = usb_submit_urb (mdc800->download_urb, GFP_KERNEL); in mdc800_device_read()
728 dev_err(&mdc800->dev->dev, in mdc800_device_read()
731 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
734 wait_event_timeout(mdc800->download_wait, in mdc800_device_read()
735 mdc800->downloaded, in mdc800_device_read()
737 mdc800->downloaded = 0; in mdc800_device_read()
738 if (mdc800->download_urb->status != 0) in mdc800_device_read()
740 dev_err(&mdc800->dev->dev, in mdc800_device_read()
743 mdc800->download_urb->status); in mdc800_device_read()
744 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
751 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
758 if (copy_to_user(ptr, &mdc800->out [mdc800->out_ptr], in mdc800_device_read()
760 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
765 mdc800->out_ptr+=sts; in mdc800_device_read()
769 mutex_unlock(&mdc800->io_lock); in mdc800_device_read()
785 mutex_lock(&mdc800->io_lock); in mdc800_device_write()
786 if (mdc800->state != READY) in mdc800_device_write()
788 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
791 if (!mdc800->open ) in mdc800_device_write()
793 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
802 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
808 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
815 mdc800->in_count=0; in mdc800_device_write()
816 mdc800->out_count=0; in mdc800_device_write()
817 mdc800->out_ptr=0; in mdc800_device_write()
818 mdc800->download_left=0; in mdc800_device_write()
822 if (mdc800->in_count < 8) in mdc800_device_write()
824 mdc800->in[mdc800->in_count] = c; in mdc800_device_write()
825 mdc800->in_count++; in mdc800_device_write()
829 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
834 if (mdc800->in_count == 8) in mdc800_device_write()
840 dev_err(&mdc800->dev->dev, in mdc800_device_write()
842 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
846 answersize=mdc800_getAnswerSize (mdc800->in[1]); in mdc800_device_write()
848 mdc800->state=WORKING; in mdc800_device_write()
849 memcpy (mdc800->write_urb->transfer_buffer, mdc800->in,8); in mdc800_device_write()
850 mdc800->write_urb->dev = mdc800->dev; in mdc800_device_write()
851 retval = usb_submit_urb (mdc800->write_urb, GFP_KERNEL); in mdc800_device_write()
853 dev_err(&mdc800->dev->dev, in mdc800_device_write()
856 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
859 wait_event_timeout(mdc800->write_wait, mdc800->written, in mdc800_device_write()
861 mdc800->written = 0; in mdc800_device_write()
862 if (mdc800->state == WORKING) in mdc800_device_write()
864 usb_kill_urb(mdc800->write_urb); in mdc800_device_write()
865 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
869 switch ((unsigned char) mdc800->in[1]) in mdc800_device_write()
873 if (mdc800->pic_len < 0) in mdc800_device_write()
875 dev_err(&mdc800->dev->dev, in mdc800_device_write()
878 mdc800->state=READY; in mdc800_device_write()
879 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
882 mdc800->pic_len=-1; in mdc800_device_write()
886 mdc800->download_left=answersize+64; in mdc800_device_write()
887 mdc800->state=DOWNLOAD; in mdc800_device_write()
898 dev_err(&mdc800->dev->dev, "requesting answer from irq fails\n"); in mdc800_device_write()
899 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
905 memcpy (mdc800->out, mdc800->camera_response,8); in mdc800_device_write()
908 memcpy (&mdc800->out[8], mdc800->camera_response,8); in mdc800_device_write()
910 mdc800->out_ptr=0; in mdc800_device_write()
911 mdc800->out_count=16; in mdc800_device_write()
914 if (mdc800->in [1] == (char) 0x07) in mdc800_device_write()
916mdc800->pic_len=(int) 65536*(unsigned char) mdc800->camera_response[0]+256*(unsigned char) mdc800-… in mdc800_device_write()
918 dev_dbg(&mdc800->dev->dev, "cached imagesize = %i\n", mdc800->pic_len); in mdc800_device_write()
926 dev_err(&mdc800->dev->dev, "Command Timeout.\n"); in mdc800_device_write()
927 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
931 mdc800->state=READY; in mdc800_device_write()
937 mutex_unlock(&mdc800->io_lock); in mdc800_device_write()
986 mdc800=kzalloc (sizeof (struct mdc800_data), GFP_KERNEL); in usb_mdc800_init()
987 if (!mdc800) in usb_mdc800_init()
990 mdc800->dev = NULL; in usb_mdc800_init()
991 mdc800->state=NOT_CONNECTED; in usb_mdc800_init()
992 mutex_init (&mdc800->io_lock); in usb_mdc800_init()
994 init_waitqueue_head (&mdc800->irq_wait); in usb_mdc800_init()
995 init_waitqueue_head (&mdc800->write_wait); in usb_mdc800_init()
996 init_waitqueue_head (&mdc800->download_wait); in usb_mdc800_init()
998 mdc800->irq_woken = 0; in usb_mdc800_init()
999 mdc800->downloaded = 0; in usb_mdc800_init()
1000 mdc800->written = 0; in usb_mdc800_init()
1002 mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL); in usb_mdc800_init()
1003 if (!mdc800->irq_urb_buffer) in usb_mdc800_init()
1005 mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL); in usb_mdc800_init()
1006 if (!mdc800->write_urb_buffer) in usb_mdc800_init()
1008 mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL); in usb_mdc800_init()
1009 if (!mdc800->download_urb_buffer) in usb_mdc800_init()
1012 mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL); in usb_mdc800_init()
1013 if (!mdc800->irq_urb) in usb_mdc800_init()
1015 mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL); in usb_mdc800_init()
1016 if (!mdc800->download_urb) in usb_mdc800_init()
1018 mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL); in usb_mdc800_init()
1019 if (!mdc800->write_urb) in usb_mdc800_init()
1036 if (mdc800 != NULL) in usb_mdc800_init()
1040 kfree(mdc800->download_urb_buffer); in usb_mdc800_init()
1041 kfree(mdc800->write_urb_buffer); in usb_mdc800_init()
1042 kfree(mdc800->irq_urb_buffer); in usb_mdc800_init()
1044 usb_free_urb(mdc800->write_urb); in usb_mdc800_init()
1045 usb_free_urb(mdc800->download_urb); in usb_mdc800_init()
1046 usb_free_urb(mdc800->irq_urb); in usb_mdc800_init()
1048 kfree (mdc800); in usb_mdc800_init()
1050 mdc800 = NULL; in usb_mdc800_init()
1059 usb_free_urb (mdc800->irq_urb); in usb_mdc800_cleanup()
1060 usb_free_urb (mdc800->download_urb); in usb_mdc800_cleanup()
1061 usb_free_urb (mdc800->write_urb); in usb_mdc800_cleanup()
1063 kfree (mdc800->irq_urb_buffer); in usb_mdc800_cleanup()
1064 kfree (mdc800->write_urb_buffer); in usb_mdc800_cleanup()
1065 kfree (mdc800->download_urb_buffer); in usb_mdc800_cleanup()
1067 kfree (mdc800); in usb_mdc800_cleanup()
1068 mdc800 = NULL; in usb_mdc800_cleanup()