podhd.c (988d350aef30b798198e7915c574f82ba173f40f) | podhd.c (85a9339becf0af4d547ceb6bb16d1893b05fbce4) |
---|---|
1/* 2 * Line6 Pod HD 3 * 4 * Copyright (C) 2011 Stefan Hajnoczi <stefanha@gmail.com> 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/usb.h> 13#include <linux/slab.h> 14#include <linux/module.h> 15#include <sound/core.h> 16#include <sound/pcm.h> 17 | 1/* 2 * Line6 Pod HD 3 * 4 * Copyright (C) 2011 Stefan Hajnoczi <stefanha@gmail.com> 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/usb.h> 13#include <linux/slab.h> 14#include <linux/module.h> 15#include <sound/core.h> 16#include <sound/pcm.h> 17 |
18#include "audio.h" | |
19#include "driver.h" 20#include "pcm.h" 21#include "usbdefs.h" 22 23enum { 24 LINE6_PODHD300, 25 LINE6_PODHD400, 26 LINE6_PODHD500_0, --- 54 unchanged lines hidden (view full) --- 81 .periods_max = 1024}, 82 .snd_line6_rates = { 83 .nrats = 1, 84 .rats = &podhd_ratden}, 85 .bytes_per_frame = PODHD_BYTES_PER_FRAME 86}; 87 88/* | 18#include "driver.h" 19#include "pcm.h" 20#include "usbdefs.h" 21 22enum { 23 LINE6_PODHD300, 24 LINE6_PODHD400, 25 LINE6_PODHD500_0, --- 54 unchanged lines hidden (view full) --- 80 .periods_max = 1024}, 81 .snd_line6_rates = { 82 .nrats = 1, 83 .rats = &podhd_ratden}, 84 .bytes_per_frame = PODHD_BYTES_PER_FRAME 85}; 86 87/* |
89 POD HD destructor. 90*/ 91static void podhd_destruct(struct usb_interface *interface) 92{ 93 struct usb_line6_podhd *podhd = usb_get_intfdata(interface); 94 95 if (podhd == NULL) 96 return; 97 line6_cleanup_audio(&podhd->line6); 98} 99 100/* 101 POD HD device disconnected. 102*/ 103static void line6_podhd_disconnect(struct usb_interface *interface) 104{ 105 struct usb_line6_podhd *podhd; 106 107 if (interface == NULL) 108 return; 109 podhd = usb_get_intfdata(interface); 110 111 if (podhd != NULL) { 112 struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm; 113 114 if (line6pcm != NULL) 115 line6_pcm_disconnect(line6pcm); 116 } 117 118 podhd_destruct(interface); 119} 120 121/* | |
122 Try to init POD HD device. 123*/ | 88 Try to init POD HD device. 89*/ |
124static int podhd_try_init(struct usb_interface *interface, 125 struct usb_line6_podhd *podhd) | 90static int podhd_init(struct usb_interface *interface, 91 struct usb_line6 *line6) |
126{ | 92{ |
93 struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; |
|
127 int err; | 94 int err; |
128 struct usb_line6 *line6 = &podhd->line6; | |
129 130 if ((interface == NULL) || (podhd == NULL)) 131 return -ENODEV; 132 | 95 96 if ((interface == NULL) || (podhd == NULL)) 97 return -ENODEV; 98 |
133 line6->disconnect = line6_podhd_disconnect; 134 135 /* initialize audio system: */ 136 err = line6_init_audio(line6); 137 if (err < 0) 138 return err; 139 | |
140 /* initialize MIDI subsystem: */ 141 err = line6_init_midi(line6); 142 if (err < 0) 143 return err; 144 145 /* initialize PCM subsystem: */ 146 err = line6_init_pcm(line6, &podhd_pcm_properties); 147 if (err < 0) 148 return err; 149 150 /* register USB audio system: */ | 99 /* initialize MIDI subsystem: */ 100 err = line6_init_midi(line6); 101 if (err < 0) 102 return err; 103 104 /* initialize PCM subsystem: */ 105 err = line6_init_pcm(line6, &podhd_pcm_properties); 106 if (err < 0) 107 return err; 108 109 /* register USB audio system: */ |
151 err = line6_register_audio(line6); 152 return err; | 110 return snd_card_register(line6->card); |
153} 154 155#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 156#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 157 158/* table of devices that work with this driver */ 159static const struct usb_device_id podhd_id_table[] = { 160 { LINE6_DEVICE(0x5057), .driver_info = LINE6_PODHD300 }, --- 52 unchanged lines hidden (view full) --- 213 .ep_ctrl_r = 0x81, 214 .ep_ctrl_w = 0x01, 215 .ep_audio_r = 0x86, 216 .ep_audio_w = 0x02, 217 }, 218}; 219 220/* | 111} 112 113#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) 114#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) 115 116/* table of devices that work with this driver */ 117static const struct usb_device_id podhd_id_table[] = { 118 { LINE6_DEVICE(0x5057), .driver_info = LINE6_PODHD300 }, --- 52 unchanged lines hidden (view full) --- 171 .ep_ctrl_r = 0x81, 172 .ep_ctrl_w = 0x01, 173 .ep_audio_r = 0x86, 174 .ep_audio_w = 0x02, 175 }, 176}; 177 178/* |
221 Init POD HD device (and clean up in case of failure). 222*/ 223static int podhd_init(struct usb_interface *interface, 224 struct usb_line6 *line6) 225{ 226 struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; 227 int err = podhd_try_init(interface, podhd); 228 229 if (err < 0) 230 podhd_destruct(interface); 231 232 return err; 233} 234 235/* | |
236 Probe USB device. 237*/ 238static int podhd_probe(struct usb_interface *interface, 239 const struct usb_device_id *id) 240{ 241 struct usb_line6_podhd *podhd; | 179 Probe USB device. 180*/ 181static int podhd_probe(struct usb_interface *interface, 182 const struct usb_device_id *id) 183{ 184 struct usb_line6_podhd *podhd; |
242 int err; | |
243 244 podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); 245 if (!podhd) 246 return -ENODEV; | 185 186 podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); 187 if (!podhd) 188 return -ENODEV; |
247 err = line6_probe(interface, &podhd->line6, 248 &podhd_properties_table[id->driver_info], 249 podhd_init); 250 if (err < 0) 251 kfree(podhd); 252 return err; | 189 return line6_probe(interface, &podhd->line6, 190 &podhd_properties_table[id->driver_info], 191 podhd_init); |
253} 254 255static struct usb_driver podhd_driver = { 256 .name = KBUILD_MODNAME, 257 .probe = podhd_probe, 258 .disconnect = line6_disconnect, 259#ifdef CONFIG_PM 260 .suspend = line6_suspend, 261 .resume = line6_resume, 262 .reset_resume = line6_resume, 263#endif 264 .id_table = podhd_id_table, 265}; 266 267module_usb_driver(podhd_driver); 268 269MODULE_DESCRIPTION("Line6 PODHD USB driver"); 270MODULE_LICENSE("GPL"); | 192} 193 194static struct usb_driver podhd_driver = { 195 .name = KBUILD_MODNAME, 196 .probe = podhd_probe, 197 .disconnect = line6_disconnect, 198#ifdef CONFIG_PM 199 .suspend = line6_suspend, 200 .resume = line6_resume, 201 .reset_resume = line6_resume, 202#endif 203 .id_table = podhd_id_table, 204}; 205 206module_usb_driver(podhd_driver); 207 208MODULE_DESCRIPTION("Line6 PODHD USB driver"); 209MODULE_LICENSE("GPL"); |