/* Init Toneport device. */ int toneport_init(struct usb_interface *interface, struct usb_line6_toneport *toneport) { int err, ticks; struct usb_line6 *line6 = &toneport->line6; struct usb_device *usbdev; if ((interface == NULL) || (toneport == NULL)) return -ENODEV; /* initialize audio system: */ err = line6_init_audio(line6); if (err < 0) { toneport_destruct(interface); return err; } /* initialize PCM subsystem: */ err = line6_init_pcm(line6, &toneport_pcm_properties); if (err < 0) { toneport_destruct(interface); return err; } /* register audio system: */ err = line6_register_audio(line6); if (err < 0) { toneport_destruct(interface); return err; } usbdev = line6->usbdev; line6_read_serial_number(line6, &toneport->serial_number); line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); /* sync time on device with host: */ ticks = (int)get_seconds(); line6_write_data(line6, 0x80c6, &ticks, 4); /* seems to work without the first two... */ /* toneport_send_cmd(usbdev, 0x0201, 0x0002); */ /* toneport_send_cmd(usbdev, 0x0801, 0x0000); */ /* only one that works for me; on GP, TP might be different? */ toneport_send_cmd(usbdev, 0x0301, 0x0000); if (usbdev->descriptor.idProduct != LINE6_DEVID_GUITARPORT) { CHECK_RETURN(device_create_file (&interface->dev, &dev_attr_led_red)); CHECK_RETURN(device_create_file (&interface->dev, &dev_attr_led_green)); toneport_update_led(&usbdev->dev); } return 0; }
/* Try to init Toneport device. */ static int toneport_try_init(struct usb_interface *interface, struct usb_line6_toneport *toneport) { int err; struct usb_line6 *line6 = &toneport->line6; struct usb_device *usbdev = line6->usbdev; if ((interface == NULL) || (toneport == NULL)) return -ENODEV; /* initialize audio system: */ err = line6_init_audio(line6); if (err < 0) return err; /* initialize PCM subsystem: */ err = line6_init_pcm(line6, &toneport_pcm_properties); if (err < 0) return err; /* register monitor control: */ err = snd_ctl_add(line6->card, snd_ctl_new1(&toneport_control_monitor, line6->line6pcm)); if (err < 0) return err; /* register source select control: */ switch (usbdev->descriptor.idProduct) { case LINE6_DEVID_TONEPORT_UX1: case LINE6_DEVID_PODSTUDIO_UX1: err = snd_ctl_add(line6->card, snd_ctl_new1(&toneport_control_source, line6->line6pcm)); if (err < 0) return err; } /* register audio system: */ err = line6_register_audio(line6); if (err < 0) return err; line6_read_serial_number(line6, &toneport->serial_number); line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); if (toneport_has_led(usbdev->descriptor.idProduct)) { CHECK_RETURN(device_create_file (&interface->dev, &dev_attr_led_red)); CHECK_RETURN(device_create_file (&interface->dev, &dev_attr_led_green)); } toneport_setup(toneport); init_timer(&toneport->timer); toneport->timer.expires = jiffies + TONEPORT_PCM_DELAY * HZ; toneport->timer.function = toneport_start_pcm; toneport->timer.data = (unsigned long)toneport; add_timer(&toneport->timer); return 0; }