variax.c (a019f5e8c522f5b5f8b3419a1e56d142ea4c7621) | variax.c (85a9339becf0af4d547ceb6bb16d1893b05fbce4) |
---|---|
1/* 2 * Line6 Linux USB driver - 0.9.1beta 3 * 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation, version 2. 9 * 10 */ 11 12#include <linux/slab.h> 13#include <linux/spinlock.h> 14#include <linux/usb.h> 15#include <linux/wait.h> 16#include <linux/module.h> 17#include <sound/core.h> 18 | 1/* 2 * Line6 Linux USB driver - 0.9.1beta 3 * 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation, version 2. 9 * 10 */ 11 12#include <linux/slab.h> 13#include <linux/spinlock.h> 14#include <linux/usb.h> 15#include <linux/wait.h> 16#include <linux/module.h> 17#include <sound/core.h> 18 |
19#include "audio.h" | |
20#include "driver.h" 21#include "usbdefs.h" 22 23#define VARIAX_STARTUP_DELAY1 1000 24#define VARIAX_STARTUP_DELAY3 100 25#define VARIAX_STARTUP_DELAY4 100 26 27/* --- 146 unchanged lines hidden (view full) --- 174static void variax_startup6(struct work_struct *work) 175{ 176 struct usb_line6_variax *variax = 177 container_of(work, struct usb_line6_variax, startup_work); 178 179 CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); 180 181 /* ALSA audio interface: */ | 19#include "driver.h" 20#include "usbdefs.h" 21 22#define VARIAX_STARTUP_DELAY1 1000 23#define VARIAX_STARTUP_DELAY3 100 24#define VARIAX_STARTUP_DELAY4 100 25 26/* --- 146 unchanged lines hidden (view full) --- 173static void variax_startup6(struct work_struct *work) 174{ 175 struct usb_line6_variax *variax = 176 container_of(work, struct usb_line6_variax, startup_work); 177 178 CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); 179 180 /* ALSA audio interface: */ |
182 line6_register_audio(&variax->line6); | 181 snd_card_register(variax->line6.card); |
183} 184 185/* 186 Process a completely received message. 187*/ 188static void line6_variax_process_message(struct usb_line6 *line6) 189{ 190 struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; --- 15 unchanged lines hidden (view full) --- 206 } 207 break; 208 } 209} 210 211/* 212 Variax destructor. 213*/ | 182} 183 184/* 185 Process a completely received message. 186*/ 187static void line6_variax_process_message(struct usb_line6 *line6) 188{ 189 struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; --- 15 unchanged lines hidden (view full) --- 205 } 206 break; 207 } 208} 209 210/* 211 Variax destructor. 212*/ |
214static void variax_destruct(struct usb_interface *interface) | 213static void line6_variax_disconnect(struct usb_interface *interface) |
215{ | 214{ |
216 struct usb_line6_variax *variax = usb_get_intfdata(interface); | 215 struct usb_line6_variax *variax; |
217 | 216 |
218 if (variax == NULL) | 217 if (!interface) |
219 return; | 218 return; |
220 line6_cleanup_audio(&variax->line6); | |
221 | 219 |
220 variax = usb_get_intfdata(interface); 221 if (!variax) 222 return; 223 |
|
222 del_timer(&variax->startup_timer1); 223 del_timer(&variax->startup_timer2); 224 cancel_work_sync(&variax->startup_work); 225 226 kfree(variax->buffer_activate); 227} 228 229/* | 224 del_timer(&variax->startup_timer1); 225 del_timer(&variax->startup_timer2); 226 cancel_work_sync(&variax->startup_work); 227 228 kfree(variax->buffer_activate); 229} 230 231/* |
230 Workbench device disconnected. 231*/ 232static void line6_variax_disconnect(struct usb_interface *interface) 233{ 234 if (interface == NULL) 235 return; 236 237 variax_destruct(interface); 238} 239 240/* | |
241 Try to init workbench device. 242*/ | 232 Try to init workbench device. 233*/ |
243static int variax_try_init(struct usb_interface *interface, 244 struct usb_line6 *line6) | 234static int variax_init(struct usb_interface *interface, 235 struct usb_line6 *line6) |
245{ 246 struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; 247 int err; 248 249 line6->process_message = line6_variax_process_message; 250 line6->disconnect = line6_variax_disconnect; 251 252 init_timer(&variax->startup_timer1); --- 5 unchanged lines hidden (view full) --- 258 259 /* initialize USB buffers: */ 260 variax->buffer_activate = kmemdup(variax_activate, 261 sizeof(variax_activate), GFP_KERNEL); 262 263 if (variax->buffer_activate == NULL) 264 return -ENOMEM; 265 | 236{ 237 struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; 238 int err; 239 240 line6->process_message = line6_variax_process_message; 241 line6->disconnect = line6_variax_disconnect; 242 243 init_timer(&variax->startup_timer1); --- 5 unchanged lines hidden (view full) --- 249 250 /* initialize USB buffers: */ 251 variax->buffer_activate = kmemdup(variax_activate, 252 sizeof(variax_activate), GFP_KERNEL); 253 254 if (variax->buffer_activate == NULL) 255 return -ENOMEM; 256 |
266 /* initialize audio system: */ 267 err = line6_init_audio(&variax->line6); 268 if (err < 0) 269 return err; 270 | |
271 /* initialize MIDI subsystem: */ 272 err = line6_init_midi(&variax->line6); 273 if (err < 0) 274 return err; 275 276 /* initiate startup procedure: */ 277 variax_startup1(variax); 278 return 0; 279} 280 | 257 /* initialize MIDI subsystem: */ 258 err = line6_init_midi(&variax->line6); 259 if (err < 0) 260 return err; 261 262 /* initiate startup procedure: */ 263 variax_startup1(variax); 264 return 0; 265} 266 |
281/* 282 Init workbench device (and clean up in case of failure). 283*/ 284static int variax_init(struct usb_interface *interface, 285 struct usb_line6 *line6) 286{ 287 int err = variax_try_init(interface, line6); 288 289 if (err < 0) 290 variax_destruct(interface); 291 292 return err; 293} 294 | |
295#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 296#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 297 298/* table of devices that work with this driver */ 299static const struct usb_device_id variax_id_table[] = { 300 { LINE6_IF_NUM(0x4650, 1), .driver_info = LINE6_PODXTLIVE_VARIAX }, 301 { LINE6_DEVICE(0x534d), .driver_info = LINE6_VARIAX }, 302 {} --- 27 unchanged lines hidden (view full) --- 330 331/* 332 Probe USB device. 333*/ 334static int variax_probe(struct usb_interface *interface, 335 const struct usb_device_id *id) 336{ 337 struct usb_line6_variax *variax; | 267#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 268#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 269 270/* table of devices that work with this driver */ 271static const struct usb_device_id variax_id_table[] = { 272 { LINE6_IF_NUM(0x4650, 1), .driver_info = LINE6_PODXTLIVE_VARIAX }, 273 { LINE6_DEVICE(0x534d), .driver_info = LINE6_VARIAX }, 274 {} --- 27 unchanged lines hidden (view full) --- 302 303/* 304 Probe USB device. 305*/ 306static int variax_probe(struct usb_interface *interface, 307 const struct usb_device_id *id) 308{ 309 struct usb_line6_variax *variax; |
338 int err; | |
339 340 variax = kzalloc(sizeof(*variax), GFP_KERNEL); 341 if (!variax) 342 return -ENODEV; | 310 311 variax = kzalloc(sizeof(*variax), GFP_KERNEL); 312 if (!variax) 313 return -ENODEV; |
343 err = line6_probe(interface, &variax->line6, 344 &variax_properties_table[id->driver_info], 345 variax_init); 346 if (err < 0) 347 kfree(variax); 348 return err; | 314 return line6_probe(interface, &variax->line6, 315 &variax_properties_table[id->driver_info], 316 variax_init); |
349} 350 351static struct usb_driver variax_driver = { 352 .name = KBUILD_MODNAME, 353 .probe = variax_probe, 354 .disconnect = line6_disconnect, 355#ifdef CONFIG_PM 356 .suspend = line6_suspend, 357 .resume = line6_resume, 358 .reset_resume = line6_resume, 359#endif 360 .id_table = variax_id_table, 361}; 362 363module_usb_driver(variax_driver); 364 365MODULE_DESCRIPTION("Vairax Workbench USB driver"); 366MODULE_LICENSE("GPL"); | 317} 318 319static struct usb_driver variax_driver = { 320 .name = KBUILD_MODNAME, 321 .probe = variax_probe, 322 .disconnect = line6_disconnect, 323#ifdef CONFIG_PM 324 .suspend = line6_suspend, 325 .resume = line6_resume, 326 .reset_resume = line6_resume, 327#endif 328 .id_table = variax_id_table, 329}; 330 331module_usb_driver(variax_driver); 332 333MODULE_DESCRIPTION("Vairax Workbench USB driver"); 334MODULE_LICENSE("GPL"); |