diff -Nur dmx/CREDITS dmx/CREDITS --- dmx/CREDITS 1970-01-01 01:00:00.000000000 +0100 +++ dmx/CREDITS 2006-02-28 23:10:02.000000000 +0100 @@ -0,0 +1,3 @@ + +Thanks to Markus Tavenrath (speedygoo AT speedygooi DOT de) for fixing and testing the Sunlite USB-DMX driver. + diff -Nur dmx/drivers/devices/usb/sunlite_base.c dmx/drivers/devices/usb/sunlite_base.c --- dmx/drivers/devices/usb/sunlite_base.c 2005-11-26 17:32:24.000000000 +0100 +++ dmx/drivers/devices/usb/sunlite_base.c 2006-02-28 22:03:30.000000000 +0100 @@ -32,6 +32,8 @@ *---------------------------------------------------------*/ char *usberror2string (int e) { + // fixme +#if 0 switch (e) { case USB_ST_NOERROR: return "USB_ST_NOERROR"; @@ -57,6 +59,7 @@ case USB_ST_URB_REQUEST_ERROR: return "USB_ST_URB_REQUEST_ERROR: invalid endpoint"; case USB_ST_STALL: return "USB_ST_STALL: pipe stalled, also in urb->status"; } +#endif return "unknown error"; } diff -Nur dmx/drivers/devices/usb/sunlite.c dmx/drivers/devices/usb/sunlite.c --- dmx/drivers/devices/usb/sunlite.c 2005-11-26 17:32:24.000000000 +0100 +++ dmx/drivers/devices/usb/sunlite.c 2006-02-28 22:35:43.000000000 +0100 @@ -31,6 +31,7 @@ MODULE_PARM(inputrate,"i"); MODULE_PARM_DESC(inputrate,"input universe is read times per second (default 30)"); +//DECLARE_COMPLETION( on_u2daemon_exit ); DMXFamily *usbdmx2_family = NULL; @@ -227,53 +228,56 @@ } - -/*----------------------------------------------------------- - *-- usbdmx2_delete_interface - *-- - *-- - *---------------------------------------------------------*/ -static int usbdmx2_delete_interface (DMXInterface *dif) +void +usbdmx2_thread_cleanup(struct dmxusb_interface *u2d_if) { - printk ("usbdmx2_delete_interface (DMXInterface *dif=%p)" _FUNCFRAME_ "\n", dif, FUNCFRAME_(usbdmx2_delete_interface)); - - if (dif && dif->user_data) - { - int waitpid_result = 0; - int ret = 0; - struct dmxusb_interface *u2d_if = (struct dmxusb_interface *)dif->user_data; - - /* lock the interface */ + int ret = 0; if (u2d_if->thread_pid > 0) /* we don't want to kill init */ { - printk ("attempting to kill usbdmx2-thread pid=%d\n", u2d_if->thread_pid); + info("attempting to kill ftdi2dmxd thread pid=%d", u2d_if->thread_pid); ret = kill_proc(u2d_if->thread_pid, SIGTERM, 1); if (ret) { - printk(KERN_ERR "usbdmx2: unable to signal thread\n"); - return -1; + err("ftdi2dmx_thread_cleanup() unable to signal thread"); + return; } THREAD_SEM_WAIT_COMPLETE(&u2d_if->thr_exited); - /* down(&u2d_if->thr_exited); */ - waitpid_result = waitpid (u2d_if->thread_pid, NULL, __WCLONE|WNOHANG); - printk("usbdmx2 thread has been stopped\n"); + info("sunlite thread has been stopped"); + } else { + dbg("sunlite_thread_cleanup: wasn't running."); } - /* be paranoyd and wait for a while */ schedule_timeout(HZ/5); +} + + +/*----------------------------------------------------------- + *-- usbdmx2_delete_interface + *-- + *-- + *---------------------------------------------------------*/ +static int usbdmx2_delete_interface (DMXInterface *dif) +{ + printk ("usbdmx2_delete_interface (DMXInterface *dif=%p)" _FUNCFRAME_ "\n", dif, FUNCFRAME_(usbdmx2_delete_interface)); + if (dif && dif->user_data) + { + struct dmxusb_interface *u2d_if = (struct dmxusb_interface *)dif->user_data; - if (u2d_if->universe) - u2d_if->universe->dmx_if = NULL; - u2d_if->universe = NULL; - u2d_if->interface = NULL; - - printk ("freeing interface->user_data = 0x%p\n", dif->user_data); - FREE(dif->user_data); - dif->user_data = NULL; - printk ("freeing interface->user_data done\n"); + /* lock the interface */ + if (u2d_if) { + if (u2d_if->universe) + u2d_if->universe->dmx_if = NULL; + u2d_if->universe = NULL; + u2d_if->interface = NULL; + + printk ("freeing interface->user_data = 0x%p\n", dif->user_data); + FREE(dif->user_data); + dif->user_data = NULL; + printk ("freeing interface->user_data done\n"); + } } return 0; } @@ -352,11 +356,14 @@ lock_kernel(); - daemonize (); - spin_lock_irq(¤t->sigmask_lock); + daemonize ("USBDMX"); + // FIXME + //spin_lock_irq(¤t->sigmask_lock); sigemptyset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + recalc_sigpending(); + // FIXME + //spin_unlock_irq(¤t->sigmask_lock); + unlock_kernel(); strncpy (current->comm, "usbdmx2d", sizeof(current->comm) - 1); current->comm[sizeof(current->comm) - 1] = '\0'; @@ -365,18 +372,17 @@ printk ("starting usbdmx2d...\n"); - /* set_current_state(TASK_INTERRUPTIBLE); */ + set_current_state(TASK_INTERRUPTIBLE); /* schedule_timeout(HZ*2); */ /* USBDMX-IN */ if (u2d_if->dmx_dev->descriptor.idProduct == USB_PRODUCT_EZ_USB3a) { - atomic_set(&u2d_if->urb_submit_pending, 1); - purb = usb_alloc_urb(0); + purb = usb_alloc_urb(0, GFP_KERNEL); if (purb) { usb_fill_bulk_urb (purb, u2d_if->dmx_dev, usb_rcvbulkpipe(u2d_if->dmx_dev, 2), inbuffer, sizeof(inbuffer), bulk_urb_complete, u2d_if); - status=usb_submit_urb(purb); + status=usb_submit_urb(purb, GFP_KERNEL); if (status) info("urb submit error: %d", status); } @@ -388,14 +394,25 @@ if (purb && !atomic_read(&u2d_if->urb_submit_pending)) { usb_fill_bulk_urb (purb, u2d_if->dmx_dev, usb_rcvbulkpipe(u2d_if->dmx_dev, 2), inbuffer, sizeof(inbuffer), bulk_urb_complete, u2d_if); - status=usb_submit_urb(purb); - if (status) + status=usb_submit_urb(purb, GFP_KERNEL); + if (status) { info("urb submit error: %d", status); - + // continue -> probably a signal is pending + continue; + } atomic_set(&u2d_if->urb_submit_pending, 1); - } + struct dmxusb_universe *u2d_u = u2d_if->universe; + if (u2d_u && u2d_u->universe && u2d_u->universe->signal_changed) { + memcpy(u2d_u->buffer, inbuffer + 3, 512); + u2d_u->data_avail=1; + u2d_u->universe->signal_changed (u2d_u->universe, 0, 512); + } + //atomic_set(&u2d_if-> + } + } while (!signal_pending(current)); + printk("Signal pending: %d\n", signal_pending(current)); if (atomic_read(&u2d_if->urb_submit_pending)) info("waiting for urb submit completion"); @@ -436,9 +453,11 @@ printk ("usbdmx2 thread is exiting\n"); u2d_if->running = 0; + + //complete_and_exit( &on_u2daemon_exit, 0); THREAD_SEM_EXIT (&u2d_if->thr_exited, 0); - return 0; + //return 0; } @@ -471,11 +490,13 @@ return -1; } - if (usbdev->actconfig && usbdev->actconfig->iConfiguration) + if (usbdev->actconfig && usbdev->actconfig->string) { char str[128]; - if(usb_string(usbdev, usbdev->actconfig->iConfiguration, str, sizeof(str)) >= 0 ) + /* FIXME + if(usb_string(usbdev, usbdev->actconfig->string, str, sizeof(str)) >= 0 ) info ("current configuration is \"%s\"", str); + */ } u2d_if = DMX_ALLOC(struct dmxusb_interface); @@ -534,8 +555,8 @@ /*----------------------------------------------------------- *-- Some declaration for USBDMX2. *---------------------------------------------------------*/ -static void *usbdmx2_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id /* since 2.4.2 */); -static void usbdmx2_disconnect(struct usb_device *dev, void *ptr); +static int usbdmx2_probe (struct usb_interface *iface, const struct usb_device_id *id); +static void usbdmx2_disconnect(struct usb_interface *iface); typedef struct { @@ -587,25 +608,14 @@ *---------------------------------------------------------*/ static struct usb_driver dmx_driver = { - name: "USBDMX", - probe: usbdmx2_probe, - disconnect: usbdmx2_disconnect, - driver_list: LIST_HEAD_INIT(dmx_driver.driver_list), - id_table: usbdmx2_id_table, -/* - struct semaphore serialize; - void (*suspend)(struct usb_device *dev); - void (*resume)(struct usb_device *dev); -*/ + .owner = THIS_MODULE, + .name = "SUNLITE USB2DMX", + .probe = usbdmx2_probe, + .disconnect = usbdmx2_disconnect, + .id_table = usbdmx2_id_table, }; - - - - - - /*----------------------------------------------------------- *-- usbdmx2_probe *-- @@ -614,10 +624,11 @@ *-- If so, it initializes it and creates as much *-- DMX universes as the interface provides. *---------------------------------------------------------*/ -static void *usbdmx2_probe (struct usb_device *dev, unsigned int ifnum, - const struct usb_device_id *id /* since 2.4.2 */ +static int usbdmx2_probe (struct usb_interface *interface, const struct usb_device_id *id /* since 2.4.2 */ ) { + struct usb_device *dev = interface_to_usbdev(interface); + printk("\nusbdmx2_probe, dev: %p, id: %p\n", dev, id); const int sunlite_info_size = sizeof(sunlite_device_info) / sizeof(sunlite_device_info[0]); int device_info_idx = id->driver_info; dmxsunlite_device_info * device_info = (device_info_idx>=0 && device_info_idx < sunlite_info_size) ? &sunlite_device_info[device_info_idx] : NULL; @@ -626,7 +637,7 @@ char str[128]; int res; - printk ("usbdmx2_probe (struct usb_device *dev=0x%p, unsigned int ifnum=%u, const struct usb_device_id *id=0x%p" _FUNCFRAME_ "\n", dev, ifnum, id, FUNCFRAME_(usbdmx2_probe)); + printk ("usbdmx2_probe (struct usb_device *dev=0x%p, const struct usb_device_id *id=0x%p" _FUNCFRAME_ "\n", dev, id, FUNCFRAME_(usbdmx2_probe)); if (dev == NULL) { @@ -687,7 +698,7 @@ info (DRIVERNAME "...failed"); else info (DRIVERNAME "...succeded"); - return (void *)0xFA57FEED; + return 0; } else if (dev->descriptor.idVendor == 0xb334 && dev->descriptor.idProduct == 0x01) { @@ -698,7 +709,7 @@ info (DRIVERNAME "...failed"); else info (DRIVERNAME "...succeded"); - return (void *)0xFA57FEED; + return 0; } @@ -708,12 +719,14 @@ if (dev->actconfig) { - if (dev->actconfig->iConfiguration) + if (dev->actconfig->string) { - if((res = usb_string(dev, dev->actconfig->iConfiguration, str, sizeof(str))) < 0 ) + /* FIXME + if((res = usb_string(dev, dev->actconfig->string, str, sizeof(str))) < 0 ) err ("reading string for current config failed (error=%i)", res); else info ("configuration changed to \"%s\"", str); + */ } else warn ("dev->actconfig->iConfiguration = NULL"); @@ -739,12 +752,14 @@ if (uout) { + usb_set_intfdata(interface, dmx_if->user_data); printk("input/output-universes created, usb.private=%08lX\n", (unsigned long)dmx_if); - return dmx_if; + + return 0; } dmx_if->delete(dmx_if); } - return dmx_if; + return 0; } else printk (KERN_INFO "unable to find driver for dmx-family usbdmx2.usbdmx2\n"); @@ -753,7 +768,7 @@ /* * Something failed. */ - return NULL; + return -ENODEV; } @@ -766,28 +781,27 @@ *-- It is called after a USBDMX2 device has been *-- removed from the USB bus. *---------------------------------------------------------*/ -static void usbdmx2_disconnect (struct usb_device *dev, void *ptr) +static void usbdmx2_disconnect (struct usb_interface *interface) { - if (ptr == (void *)0xFA57FEED) - printk ("disconnecting fake firmware loader\n"); - else if (ptr == (void *)0xDEADBEEF) - printk("disconnecting from 0xDEADBEEF\n"); - else - { - DMXInterface *dmx = (DMXInterface *)ptr; - printk ("usbdmx2_disconnect(struct usb_device *dev=0x%p, void *ptr=0x%p" _FUNCFRAME_ "\n", dev, ptr, FUNCFRAME_(usbdmx2_disconnect)); - if (dmx) - { -#if 0 - wait(dmx->sem); /* wait for the interface to be unused and block it (forever :-) */ -#endif - printk (KERN_INFO "delete usbdmx2 interface\n"); - if (dmx && dmx->delete) - dmx->delete (dmx); - /* does a cascaded delete on the universes of that interface */ - } + printk("SUNLITE USB2DMX disconnect\n"); + lock_kernel(); + struct dmxusb_interface *dev = usb_get_intfdata(interface); + printk("Dev: %p\n", dev); + if (dev && dev->interface) { + struct dmxusb_interface *u2d_if = (struct dmxusb_interface *)dev->interface->user_data; + if (u2d_if) + { + printk("Thread cleanup\n"); + usbdmx2_thread_cleanup(u2d_if); + } + + printk (KERN_INFO "delete usbdmx2 interface\n"); + if (dev->interface) + dev->interface->delete (dev->interface); + /* does a cascaded delete on the universes of that interface */ } - printk ("after usbdmx2_disconnect\n"); + unlock_kernel(); + printk ("SUNLITE USB2DMX disconnected\n"); } @@ -850,4 +864,3 @@ module_init(usbdmx2_init); module_exit(usbdmx2_cleanup); -EXPORT_NO_SYMBOLS; diff -Nur dmx/include/dmx/dmxconfig.h dmx/include/dmx/dmxconfig.h --- dmx/include/dmx/dmxconfig.h 2004-11-17 00:03:06.000000000 +0100 +++ dmx/include/dmx/dmxconfig.h 2006-02-28 22:02:49.000000000 +0100 @@ -47,7 +47,7 @@ # if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) # define KILL_FASYNC(a,b,c) kill_fasync((a),(c)) # else -# define KILL_FASYNC(a,b,c) kill_fasync(&(a),(b),(c)) +# define KILL_FASYNC(a,b,c) kill_fasync((a),(b),(c)) # endif #endif