stk11xx-usb.c

Go to the documentation of this file.
00001 
00034 #include <linux/module.h>
00035 #include <linux/init.h>
00036 #include <linux/kernel.h>
00037 #include <linux/errno.h>
00038 #include <linux/slab.h>
00039 #include <linux/kref.h>
00040 
00041 #include <linux/usb.h>
00042 //#include <linux/videodev2.h>
00043 #include <media/v4l2-common.h>
00044 
00045 #include "stk11xx.h"
00046 
00047 
00052 static int default_fps = 25;
00053 
00058 static int default_hflip = 1;
00059 
00064 static int default_vflip = 1;
00065 
00066 
00071 static struct usb_device_id stk11xx_table[] = {
00072     { USB_DEVICE(USB_SYNTEK1_VENDOR_ID, USB_STK_A311_PRODUCT_ID) },
00073     { USB_DEVICE(USB_SYNTEK1_VENDOR_ID, USB_STK_A821_PRODUCT_ID) },
00074     { USB_DEVICE(USB_SYNTEK1_VENDOR_ID, USB_STK_6A31_PRODUCT_ID) },
00075 
00076     { USB_DEVICE(USB_SYNTEK2_VENDOR_ID, USB_STK_0501_PRODUCT_ID) },
00077     { }
00078 };
00079 
00080 
00081 MODULE_DEVICE_TABLE(usb, stk11xx_table);        
00094 int usb_stk11xx_isoc_init(struct usb_stk11xx *dev)
00095 {
00096     int i, j;
00097     int ret = 0;
00098     struct urb *urb;
00099     struct usb_device *udev;
00100 
00101     if (dev == NULL)
00102         return -EFAULT;
00103 
00104     if (dev->isoc_init_ok)
00105         return 0;
00106 
00107     udev = dev->udev;
00108 
00109     STK_DEBUG("usb_stk11xx_isoc_init()\n");
00110 
00111     // Allocate URB structure
00112     for (i=0; i<MAX_ISO_BUFS; i++) {
00113         urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL);
00114 
00115         if (urb == NULL) {
00116             STK_ERROR("Failed to allocate URB %d\n", i);
00117             ret = -ENOMEM;
00118             break;
00119         }
00120 
00121         dev->isobuf[i].urb = urb;
00122     }
00123 
00124     if (ret) {
00125         while (i >= 0) {
00126             if (dev->isobuf[i].urb != NULL)
00127                 usb_free_urb(dev->isobuf[i].urb);
00128 
00129             dev->isobuf[i].urb = NULL;
00130             i--;
00131         }
00132 
00133         return ret;
00134     }
00135 
00136     // Init URB structure
00137     for (i=0; i<MAX_ISO_BUFS; i++) {
00138         urb = dev->isobuf[i].urb;
00139 
00140         urb->interval = 1; 
00141         urb->dev = udev;
00142         urb->pipe = usb_rcvisocpipe(udev, dev->isoc_in_endpointAddr);
00143         urb->transfer_flags = URB_ISO_ASAP;
00144         urb->transfer_buffer = dev->isobuf[i].data;
00145         urb->transfer_buffer_length = ISO_BUFFER_SIZE;
00146         urb->complete = usb_stk11xx_isoc_handler;
00147         urb->context = dev;
00148         urb->start_frame = 0;
00149         urb->number_of_packets = ISO_FRAMES_PER_DESC;
00150 
00151         for (j=0; j<ISO_FRAMES_PER_DESC; j++) {
00152             urb->iso_frame_desc[j].offset = j * ISO_MAX_FRAME_SIZE;
00153             urb->iso_frame_desc[j].length = ISO_MAX_FRAME_SIZE; //dev->isoc_in_size;
00154         }
00155     }
00156 
00157     STK_DEBUG("dev->isoc_in_size = %X\n", dev->isoc_in_size);
00158     STK_DEBUG("dev->isoc_in_endpointAddr = %X\n", dev->isoc_in_endpointAddr);
00159 
00160     // Link
00161     for (i=0; i<MAX_ISO_BUFS; i++) {
00162         ret = usb_submit_urb(dev->isobuf[i].urb, GFP_KERNEL);
00163 
00164         if (ret)
00165             STK_ERROR("isoc_init() submit_urb %d failed with error %d\n", i, ret);
00166         else
00167             STK_DEBUG("URB 0x%p submitted.\n", dev->isobuf[i].urb);
00168 
00169         switch (ret) {
00170             case -ENOMEM:
00171                 STK_ERROR("ENOMEM\n");
00172                 break;
00173             case -ENODEV:
00174                 STK_ERROR("ENODEV\n");
00175                 break;
00176             case -ENXIO:
00177                 STK_ERROR("ENXIO\n");
00178                 break;
00179             case -EINVAL:
00180                 STK_ERROR("EINVAL\n");
00181                 break;
00182             case -EAGAIN:
00183                 STK_ERROR("EAGAIN\n");
00184                 break;
00185             case -EFBIG:
00186                 STK_ERROR("EFBIG\n");
00187                 break;
00188             case -EPIPE:
00189                 STK_ERROR("EPIPE\n");
00190                 break;
00191             case -EMSGSIZE:
00192                 STK_ERROR("EMSGSIZE\n");
00193                 break;
00194         }
00195     }
00196 
00197     // All is done
00198     dev->isoc_init_ok = 1;
00199 
00200     return 0;
00201 }
00202 
00203 
00213 void usb_stk11xx_isoc_handler(struct urb *urb)
00214 {
00215     int i;
00216     int ret;
00217     int skip;
00218 
00219     int awake = 0;
00220     int framestatus;
00221     int framelen;
00222 
00223     unsigned char *fill = NULL;
00224     unsigned char *iso_buf = NULL;
00225 
00226     struct usb_stk11xx *dev;
00227     struct stk11xx_frame_buf *framebuf;
00228 
00229     STK_STREAM("Isoc handler\n");
00230 
00231     dev = (struct usb_stk11xx *) urb->context;
00232 
00233     if (dev == NULL) {
00234         STK_ERROR("isoc_handler called with NULL device !\n");
00235         return;
00236     }
00237 
00238     if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
00239         STK_DEBUG("URB unlinked synchronuously !\n");
00240         return;
00241     }
00242 
00243     if (urb->status != -EINPROGRESS && urb->status != 0) {
00244         const char *errmsg;
00245 
00246         errmsg = "Unknown";
00247 
00248         switch(urb->status) {
00249             case -ENOSR:
00250                 errmsg = "Buffer error (overrun)";
00251                 break;
00252 
00253             case -EPIPE:
00254                 errmsg = "Stalled (device not responding)";
00255                 break;
00256 
00257             case -EOVERFLOW:
00258                 errmsg = "Babble (bad cable?)";
00259                 break;
00260 
00261             case -EPROTO:
00262                 errmsg = "Bit-stuff error (bad cable?)";
00263                 break;
00264 
00265             case -EILSEQ:
00266                 errmsg = "CRC/Timeout (could be anything)";
00267                 break;
00268 
00269             case -ETIMEDOUT:
00270                 errmsg = "NAK (device does not respond)";
00271                 break;
00272         }
00273 
00274         STK_ERROR("isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
00275 
00276         dev->visoc_errors++;
00277 
00278         wake_up_interruptible(&dev->wait_frame);
00279 
00280         urb->dev = dev->udev;
00281         ret = usb_submit_urb(urb, GFP_ATOMIC);
00282 
00283         if (ret != 0) {
00284             STK_ERROR("Error (%d) re-submitting urb in stk11xx_isoc_handler.\n", ret);
00285         }
00286 
00287         return;
00288     }
00289 
00290     framebuf = dev->fill_frame;
00291 
00292     if (framebuf == NULL) {
00293         STK_ERROR("isoc_handler without valid fill frame !\n");
00294         
00295         wake_up_interruptible(&dev->wait_frame);
00296 
00297         urb->dev = dev->udev;
00298         ret = usb_submit_urb(urb, GFP_ATOMIC);
00299 
00300         if (ret != 0) {
00301             STK_ERROR("Error (%d) re-submitting urb in stk11xx_isoc_handler.\n", ret);
00302         }
00303 
00304         return;
00305     }
00306     else {
00307         fill = framebuf->data + framebuf->filled;
00308     }
00309 
00310     // Reset ISOC error counter
00311     dev->visoc_errors = 0;
00312 
00313     // Compact data
00314     for (i=0; i<urb->number_of_packets; i++) {
00315         framestatus = urb->iso_frame_desc[i].status;
00316         framelen = urb->iso_frame_desc[i].actual_length;
00317         iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
00318 
00319         if (framestatus == 0) {
00320             skip = 4;
00321 
00322             if (framelen > 4) {
00323                 // we found something informational from there
00324                 // the isoc frames have to type of headers
00325                 // type1: 00 xx 00 00 or 20 xx 00 00
00326                 // type2: 80 xx 00 00 00 00 00 00 or a0 xx 00 00 00 00 00 00
00327                 // xx is a sequencer which has never been seen over 0x3f
00328                 //
00329                 // imho data written down looks like bayer, i see similarities after
00330                 // every 640 bytes
00331                 if (*iso_buf & 0x80) {
00332                     skip = 8;
00333                 }
00334 
00335                 // Our buffer is full !!!
00336                 if (framelen - skip + framebuf->filled > dev->frame_size) {
00337                     STK_ERROR("Frame buffer overflow !\n");
00338                     framebuf->errors++;
00339                 }
00340                 // All is OK
00341                 else {
00342                     memcpy(fill, iso_buf + skip, framelen - skip);
00343                     fill += framelen - skip;
00344                 }
00345 
00346                 // New size of our buffer
00347                 framebuf->filled += framelen - skip;
00348             }
00349 
00350             STK_STREAM("URB : Length = %d - Skip = %d - Buffer size = %d\n",
00351                 framelen, skip, framebuf->filled);
00352 
00353             // Data is always follow by a frame with a length '4'
00354             if (framelen == 4) {
00355                 if (framebuf->filled > 0) {
00356                     // Our buffer has enough data ?
00357                     if (framebuf->filled < dev->frame_size)
00358                         framebuf->errors++;
00359 
00360                     // If there are errors, we skip a frame...
00361                     if (framebuf->errors == 0) {
00362                         if (stk11xx_next_frame(dev))
00363                             dev->vframes_dumped++;
00364                     }
00365                     else
00366                         dev->vframes_error++;
00367 
00368                     awake = 1;
00369                     framebuf = dev->fill_frame;
00370                     framebuf->filled = 0;
00371                     framebuf->errors = 0;
00372                     fill = framebuf->data;
00373                 }
00374             }
00375         }
00376         else {
00377             STK_ERROR("Iso frame %d of USB has error %d\n", i, framestatus);
00378         }
00379     }
00380 
00381     if (awake == 1)
00382         wake_up_interruptible(&dev->wait_frame);
00383 
00384     urb->dev = dev->udev;
00385 
00386     ret = usb_submit_urb(urb, GFP_ATOMIC);
00387 
00388     if (ret != 0) {
00389         STK_ERROR("Error (%d) re-submitting urb in stk11xx_isoc_handler.\n", ret);
00390     }
00391 }
00392 
00393 
00401 void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *dev)
00402 {
00403     int i;
00404 
00405     STK_DEBUG("Isoc cleanup\n");
00406 
00407     if (dev == NULL)
00408         return;
00409 
00410     if (dev->isoc_init_ok == 0)
00411         return;
00412 
00413     // Unlinking ISOC buffers
00414     for (i=0; i<MAX_ISO_BUFS; i++) {
00415         struct urb *urb;
00416 
00417         urb = dev->isobuf[i].urb;
00418 
00419         if (urb != 0) {
00420             if (dev->isoc_init_ok)
00421                 usb_kill_urb(urb);
00422             
00423             usb_free_urb(urb);
00424             dev->isobuf[i].urb = NULL;
00425         }
00426     }
00427 
00428     // All is done
00429     dev->isoc_init_ok = 0;
00430 }
00431 
00432 
00433 
00444 int usb_stk11xx_set_feature(struct usb_stk11xx *dev, int index)
00445 {
00446     int result;
00447     struct usb_device *udev = dev->udev;
00448 
00449     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
00450             USB_REQ_SET_FEATURE,
00451             USB_TYPE_STANDARD | USB_DIR_OUT | USB_RECIP_DEVICE,
00452             USB_DEVICE_REMOTE_WAKEUP,
00453             index,
00454             NULL,
00455             0,
00456             500);
00457     
00458     if (result < 0)
00459         STK_ERROR("SET FEATURE fail !\n");
00460     else 
00461         STK_DEBUG("SET FEATURE\n");
00462 
00463     return result;
00464 }
00465 
00466 
00476 int usb_stk11xx_set_configuration(struct usb_stk11xx *dev)
00477 {
00478     int result;
00479     struct usb_device *udev = dev->udev;
00480 
00481     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
00482             USB_REQ_SET_CONFIGURATION,
00483             USB_TYPE_STANDARD | USB_DIR_OUT | USB_RECIP_DEVICE,
00484             0,
00485             udev->config[0].desc.bConfigurationValue,
00486             NULL,
00487             0,
00488             500);
00489 
00490     if (result < 0)
00491         STK_ERROR("SET CONFIGURATION fail !\n");
00492     else 
00493         STK_DEBUG("SET CONFIGURATION %d\n", udev->config[0].desc.bConfigurationValue);
00494 
00495     return result;
00496 }
00497 
00498 
00510 int usb_stk11xx_write_registry(struct usb_stk11xx *dev, __u16 index, __u16 value)
00511 {
00512     int result;
00513     struct usb_device *udev = dev->udev;
00514 
00515     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
00516             0x01,
00517             USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
00518             value,
00519             index,
00520             NULL,
00521             0,
00522             500);
00523 
00524     if (result < 0)
00525         STK_ERROR("Write registry fails %02X = %02X", index, value);
00526 
00527     return result;
00528 }
00529 
00530 
00542 int usb_stk11xx_read_registry(struct usb_stk11xx *dev, __u16 index, int *value)
00543 {
00544     int result;
00545 
00546     struct usb_device *udev = dev->udev;
00547 
00548     *value = 0;
00549 
00550     result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
00551             0x00,
00552             USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
00553             0x00,
00554             index,
00555             (__u8 *) value,
00556             sizeof(__u8),
00557             500);
00558 
00559     if (result < 0)
00560         STK_ERROR("Read registry fails %02X", index);
00561 
00562     return result;
00563 }
00564 
00565 
00577 static int usb_stk11xx_probe(struct usb_interface *interface, const struct usb_device_id *id)
00578 {
00579     int i;
00580     int err;
00581     size_t buffer_size;
00582 
00583     int vendor_id;
00584     int product_id;
00585     int bNumInterfaces;
00586     int webcam_model;
00587     int webcam_type;
00588 
00589     struct usb_stk11xx *dev = NULL;
00590     struct usb_device *udev = interface_to_usbdev(interface);
00591     struct usb_host_interface *iface_desc;
00592     struct usb_endpoint_descriptor *endpoint;
00593 
00594 
00595     // Get USB VendorID and ProductID
00596     vendor_id = le16_to_cpu(udev->descriptor.idVendor);
00597     product_id = le16_to_cpu(udev->descriptor.idProduct);
00598 
00599     // Check if we can handle this device
00600     STK_DEBUG("Probe function called with VendorID=%04X, ProductID=%04X and InterfaceNumber=%d\n",
00601             vendor_id, product_id, interface->cur_altsetting->desc.bInterfaceNumber);
00602 
00603     // The interface are probed one by one.
00604     // We are interested in the video interface (always the interface '0')
00605     // The interfaces '1' or '2' (if presents) are the audio control.
00606     if (interface->cur_altsetting->desc.bInterfaceNumber > 0)
00607         return -ENODEV;
00608 
00609     // Detect device
00610     if (vendor_id == USB_SYNTEK1_VENDOR_ID) {
00611         switch (product_id) {
00612             case USB_STK_A311_PRODUCT_ID:
00613                 STK_INFO("Syntek USB2.0 - STK-1135 based webcam found.\n");
00614                 STK_INFO("Syntek AVStream USB2.0 1.3M WebCam - Product ID 0xA311.\n");
00615                 webcam_model = SYNTEK_STK_A311;
00616                 webcam_type = STK11XX_SXGA;
00617                 break;
00618 
00619             case USB_STK_A821_PRODUCT_ID:
00620                 STK_INFO("Syntek USB2.0 - STK-1135 based webcam found.\n");
00621                 STK_INFO("Syntek AVStream USB2.0 VGA WebCam - Product ID 0xA821.\n");
00622                 webcam_model = SYNTEK_STK_A821;
00623                 webcam_type = STK11XX_VGA;
00624                 break;
00625 
00626             case USB_STK_6A31_PRODUCT_ID:
00627                 STK_INFO("Syntek USB2.0 - STK-1135 based webcam found.\n");
00628                 STK_INFO("Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A31.\n");
00629                 webcam_model = SYNTEK_STK_6A31;
00630                 webcam_type = STK11XX_SXGA;
00631                 break;
00632 
00633             default:
00634                 STK_ERROR("usb_stk11xx_probe failed ! Camera product 0x%04X is not supported.\n",
00635                         le16_to_cpu(udev->descriptor.idProduct));
00636                 return -ENODEV;
00637         }
00638     }
00639     else if (vendor_id == USB_SYNTEK2_VENDOR_ID) {
00640         switch (product_id) {
00641             case USB_STK_0501_PRODUCT_ID:
00642                 STK_INFO("Syntek USB2.0 - STK-1135 based webcam found.\n");
00643                 STK_INFO("Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x0501.\n");
00644                 webcam_model = SYNTEK_STK_A311;
00645                 webcam_type = STK11XX_SXGA;
00646                 break;
00647 
00648             default:
00649                 STK_ERROR("usb_stk11xx_probe failed ! Camera product 0x%04X is not supported.\n",
00650                         le16_to_cpu(udev->descriptor.idProduct));
00651                 return -ENODEV;
00652         }
00653     }
00654     else
00655         return -ENODEV;
00656 
00657     // Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device
00658     dev = kzalloc(sizeof(struct usb_stk11xx), GFP_KERNEL);
00659 
00660     if (dev == NULL) {
00661         STK_ERROR("Out of memory !\n");
00662         return -ENOMEM;
00663     }
00664 
00665     // Init mutexes, spinlock, etc.
00666     init_MUTEX(&dev->mutex);
00667     spin_lock_init(&dev->spinlock);
00668     init_waitqueue_head(&dev->wait_frame);
00669 
00670     // Save pointers
00671     dev->webcam_model = webcam_model;
00672     dev->webcam_type = webcam_type;
00673     dev->udev = udev;
00674     dev->interface = interface;
00675 
00676     // Read the product release 
00677     dev->release = le16_to_cpu(udev->descriptor.bcdDevice);
00678     STK_INFO("Release: %04x\n", dev->release);
00679 
00680     // How many interfaces (1 or 3)
00681     bNumInterfaces = udev->config->desc.bNumInterfaces;
00682     STK_INFO("Number of interfaces : %d\n", bNumInterfaces);
00683 
00684 
00685     // Constructor
00686     dev->vsettings.fps = default_fps;
00687     dev->vsettings.vflip = default_vflip;
00688     dev->vsettings.hflip = default_hflip;
00689     dev->nbuffers = 2;
00690     dev->len_per_image = PAGE_ALIGN((1280 * 1024 * 4));
00691 
00692 
00693     // Switch on the camera (to detect size of buffers)
00694     dev_stk11xx_camera_on(dev);
00695 
00696 
00697     // Set up the endpoint information 
00698     // use only the first int-in and isoc-in endpoints
00699     // for the current alternate setting
00700     iface_desc = interface->cur_altsetting;
00701 
00702     for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
00703         endpoint = &iface_desc->endpoint[i].desc;
00704 
00705         if (!dev->int_in_endpointAddr
00706                 && ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
00707                 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
00708             // we found an interrupt in endpoint
00709             buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
00710 
00711             dev->int_in_size = buffer_size;
00712             dev->int_in_endpointAddr = (endpoint->bEndpointAddress & 0xF);
00713         }
00714 
00715         if (!dev->isoc_in_endpointAddr
00716                 && ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
00717                 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_ISOC)) {
00718             // we found an isoc in endpoint
00719             buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
00720 
00721             dev->isoc_in_size = buffer_size;
00722             dev->isoc_in_endpointAddr = (endpoint->bEndpointAddress & 0xF);
00723         }
00724     }
00725 
00726     if (!(dev->int_in_endpointAddr && dev->isoc_in_endpointAddr)) {
00727         STK_ERROR("Could not find both int-in and isoc-in endpoints");
00728 
00729         kfree(dev);
00730 
00731         return -ENODEV;
00732     }
00733 
00734 
00735     // Switch off camera
00736     dev_stk11xx_camera_off(dev);
00737 
00738     // Initialize the video device
00739     dev->vdev = video_device_alloc();
00740 
00741     if (!dev->vdev) {
00742         kfree(dev);
00743         return -ENOMEM;
00744     }
00745 
00746     // Initialize the camera
00747     dev_stk11xx_initialize_device(dev);
00748     
00749     // Register the video device
00750     err = v4l_stk11xx_register_video_device(dev);
00751 
00752     if (err) {
00753         kfree(dev);
00754         return err;
00755     }
00756 
00757     // Create the entries in the sys filesystem
00758     stk11xx_create_sysfs_files(dev->vdev);
00759 
00760     // Save our data pointer in this interface device
00761     usb_set_intfdata(interface, dev);
00762 
00763     return 0;
00764 }
00765 
00766 
00773 static void usb_stk11xx_disconnect(struct usb_interface *interface)
00774 {
00775     struct usb_stk11xx *dev = usb_get_intfdata(interface);
00776 
00777     STK_INFO("Syntek USB2.0 Camera disconnected\n");
00778 
00779     usb_set_intfdata(interface, NULL);
00780 
00781     // We got unplugged; this is signalled by an EPIPE error code
00782     if (dev->vopen) {
00783         STK_INFO("Disconnected while webcam is in use !\n");
00784         dev->error_status = EPIPE;
00785     }
00786 
00787     // Alert waiting processes
00788     wake_up_interruptible(&dev->wait_frame);
00789 
00790     // Wait until device is closed
00791     while (dev->vopen)
00792         schedule();
00793 
00794     // Unregister the video device
00795     v4l_stk11xx_unregister_video_device(dev);
00796 
00797     // Remove the entries in the sys filesystem
00798     stk11xx_remove_sysfs_files(dev->vdev);
00799 }
00800 
00801 
00807 static struct usb_driver usb_stk11xx_driver = {
00808     .name = "usb_stk11xx_driver",
00809     .probe = usb_stk11xx_probe,
00810     .disconnect = usb_stk11xx_disconnect,
00811     .id_table = stk11xx_table,
00812 };
00813 
00814 
00819 static int fps;
00820 
00825 static int hflip = 1;
00826 
00831 static int vflip = 1;
00832 
00833 module_param(fps, int, 0444);           
00834 module_param(hflip, int, 0444);         
00835 module_param(vflip, int, 0444);         
00846 static int __init usb_stk11xx_init(void)
00847 {
00848     int result;
00849 
00850 
00851     STK_INFO("Syntek USB2.0 webcam driver startup\n");
00852 
00853     // Frame per second parameter
00854     if (fps) {
00855         if (fps < 9 || fps > 30) {
00856             STK_ERROR("Framerate out of bounds [10-30] !\n");
00857             return -EINVAL;
00858         }
00859 
00860         default_fps = fps;
00861     }
00862 
00863     // Horizontal flip value
00864     if (hflip != 1) {
00865         if (hflip < 0 || hflip > 1) {
00866             STK_ERROR("Horizontal flip value has to be '0' or '1' !\n");
00867             return -EINVAL;
00868         }
00869 
00870         default_hflip = hflip;
00871     }
00872 
00873     // Vertical flip value
00874     if (vflip != 1) {
00875         if (vflip < 0 || vflip > 1) {
00876             STK_ERROR("Vertical flip value has to be '0' or '1' !\n");
00877             return -EINVAL;
00878         }
00879 
00880         default_vflip = vflip;
00881     }
00882 
00883     // Register the driver with the USB subsystem
00884     result = usb_register(&usb_stk11xx_driver);
00885 
00886     if (result)
00887         STK_ERROR("usb_register failed ! Error number %d\n", result);
00888 
00889     STK_INFO(DRIVER_VERSION " : " DRIVER_DESC "\n");
00890 
00891     return result;
00892 }
00893 
00894 
00900 static void __exit usb_stk11xx_exit(void)
00901 {
00902     STK_INFO("usb_stk11xx_exit: Syntek USB2.0 webcam driver shutdown\n");
00903 
00904     // Deregister this driver with the USB subsystem
00905     usb_deregister(&usb_stk11xx_driver);
00906 }
00907 
00908 
00909 module_init(usb_stk11xx_init);                      
00910 module_exit(usb_stk11xx_exit);                      
00913 MODULE_PARM_DESC(fps, "Frames per second [5-30]");  
00914 MODULE_PARM_DESC(hflip, "Horizontal image flip");   
00915 MODULE_PARM_DESC(vflip, "Vertical image flip");     
00918 MODULE_LICENSE("GPL");                              
00919 MODULE_AUTHOR(DRIVER_AUTHOR);                       
00920 MODULE_DESCRIPTION(DRIVER_DESC);                    
00921 MODULE_SUPPORTED_DEVICE(DRIVER_SUPPORT);            

Generated on Mon Oct 29 15:01:53 2007 for SyntekUSBVideoCamera by  doxygen 1.5.3