diff options
Diffstat (limited to 'sound/usb/usx2y')
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.c | 65 | ||||
-rw-r--r-- | sound/usb/usx2y/usX2Yhwdep.h | 2 | ||||
-rw-r--r-- | sound/usb/usx2y/usbus428ctldefs.h | 36 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.c | 49 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2y.h | 45 | ||||
-rw-r--r-- | sound/usb/usx2y/usbusx2yaudio.c | 383 | ||||
-rw-r--r-- | sound/usb/usx2y/usx2yhwdeppcm.c | 206 | ||||
-rw-r--r-- | sound/usb/usx2y/usx2yhwdeppcm.h | 1 |
8 files changed, 396 insertions, 391 deletions
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 8abe08611df6..4b52d18dcd53 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "usbusx2y.h" | 31 | #include "usbusx2y.h" |
32 | #include "usX2Yhwdep.h" | 32 | #include "usX2Yhwdep.h" |
33 | 33 | ||
34 | int usX2Y_hwdep_pcm_new(snd_card_t* card); | 34 | int usX2Y_hwdep_pcm_new(struct snd_card *card); |
35 | 35 | ||
36 | 36 | ||
37 | static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) | 37 | static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) |
@@ -49,7 +49,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign | |||
49 | offset = area->vm_pgoff << PAGE_SHIFT; | 49 | offset = area->vm_pgoff << PAGE_SHIFT; |
50 | offset += address - area->vm_start; | 50 | offset += address - area->vm_start; |
51 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); | 51 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); |
52 | vaddr = (char*)((usX2Ydev_t*)area->vm_private_data)->us428ctls_sharedmem + offset; | 52 | vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset; |
53 | page = virt_to_page(vaddr); | 53 | page = virt_to_page(vaddr); |
54 | get_page(page); | 54 | get_page(page); |
55 | snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset); | 55 | snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset); |
@@ -64,27 +64,27 @@ static struct vm_operations_struct us428ctls_vm_ops = { | |||
64 | .nopage = snd_us428ctls_vm_nopage, | 64 | .nopage = snd_us428ctls_vm_nopage, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) | 67 | static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
68 | { | 68 | { |
69 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); | 69 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); |
70 | usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; | 70 | struct usX2Ydev *us428 = hw->private_data; |
71 | 71 | ||
72 | // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? | 72 | // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? |
73 | // so as long as the device isn't fully initialised yet we return -EBUSY here. | 73 | // so as long as the device isn't fully initialised yet we return -EBUSY here. |
74 | if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) | 74 | if (!(us428->chip_status & USX2Y_STAT_CHIP_INIT)) |
75 | return -EBUSY; | 75 | return -EBUSY; |
76 | 76 | ||
77 | /* if userspace tries to mmap beyond end of our buffer, fail */ | 77 | /* if userspace tries to mmap beyond end of our buffer, fail */ |
78 | if (size > ((PAGE_SIZE - 1 + sizeof(us428ctls_sharedmem_t)) / PAGE_SIZE) * PAGE_SIZE) { | 78 | if (size > PAGE_ALIGN(sizeof(struct us428ctls_sharedmem))) { |
79 | snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(us428ctls_sharedmem_t)); | 79 | snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(struct us428ctls_sharedmem)); |
80 | return -EINVAL; | 80 | return -EINVAL; |
81 | } | 81 | } |
82 | 82 | ||
83 | if (!us428->us428ctls_sharedmem) { | 83 | if (!us428->us428ctls_sharedmem) { |
84 | init_waitqueue_head(&us428->us428ctls_wait_queue_head); | 84 | init_waitqueue_head(&us428->us428ctls_wait_queue_head); |
85 | if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(us428ctls_sharedmem_t), GFP_KERNEL))) | 85 | if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(struct us428ctls_sharedmem), GFP_KERNEL))) |
86 | return -ENOMEM; | 86 | return -ENOMEM; |
87 | memset(us428->us428ctls_sharedmem, -1, sizeof(us428ctls_sharedmem_t)); | 87 | memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem)); |
88 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; | 88 | us428->us428ctls_sharedmem->CtlSnapShotLast = -2; |
89 | } | 89 | } |
90 | area->vm_ops = &us428ctls_vm_ops; | 90 | area->vm_ops = &us428ctls_vm_ops; |
@@ -93,11 +93,11 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are | |||
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_table *wait) | 96 | static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) |
97 | { | 97 | { |
98 | unsigned int mask = 0; | 98 | unsigned int mask = 0; |
99 | usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; | 99 | struct usX2Ydev *us428 = hw->private_data; |
100 | us428ctls_sharedmem_t *shm = us428->us428ctls_sharedmem; | 100 | struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem; |
101 | if (us428->chip_status & USX2Y_STAT_CHIP_HUP) | 101 | if (us428->chip_status & USX2Y_STAT_CHIP_HUP) |
102 | return POLLHUP; | 102 | return POLLHUP; |
103 | 103 | ||
@@ -110,26 +110,28 @@ static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_ | |||
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | static int snd_usX2Y_hwdep_open(snd_hwdep_t *hw, struct file *file) | 113 | static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file) |
114 | { | 114 | { |
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int snd_usX2Y_hwdep_release(snd_hwdep_t *hw, struct file *file) | 118 | static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file) |
119 | { | 119 | { |
120 | return 0; | 120 | return 0; |
121 | } | 121 | } |
122 | 122 | ||
123 | static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) | 123 | static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, |
124 | struct snd_hwdep_dsp_status *info) | ||
124 | { | 125 | { |
125 | static char *type_ids[USX2Y_TYPE_NUMS] = { | 126 | static char *type_ids[USX2Y_TYPE_NUMS] = { |
126 | [USX2Y_TYPE_122] = "us122", | 127 | [USX2Y_TYPE_122] = "us122", |
127 | [USX2Y_TYPE_224] = "us224", | 128 | [USX2Y_TYPE_224] = "us224", |
128 | [USX2Y_TYPE_428] = "us428", | 129 | [USX2Y_TYPE_428] = "us428", |
129 | }; | 130 | }; |
131 | struct usX2Ydev *us428 = hw->private_data; | ||
130 | int id = -1; | 132 | int id = -1; |
131 | 133 | ||
132 | switch (le16_to_cpu(((usX2Ydev_t*)hw->private_data)->chip.dev->descriptor.idProduct)) { | 134 | switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { |
133 | case USB_ID_US122: | 135 | case USB_ID_US122: |
134 | id = USX2Y_TYPE_122; | 136 | id = USX2Y_TYPE_122; |
135 | break; | 137 | break; |
@@ -144,35 +146,35 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i | |||
144 | return -ENODEV; | 146 | return -ENODEV; |
145 | strcpy(info->id, type_ids[id]); | 147 | strcpy(info->id, type_ids[id]); |
146 | info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code | 148 | info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code |
147 | if (((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT) | 149 | if (us428->chip_status & USX2Y_STAT_CHIP_INIT) |
148 | info->chip_ready = 1; | 150 | info->chip_ready = 1; |
149 | info->version = USX2Y_DRIVER_VERSION; | 151 | info->version = USX2Y_DRIVER_VERSION; |
150 | return 0; | 152 | return 0; |
151 | } | 153 | } |
152 | 154 | ||
153 | 155 | ||
154 | static int usX2Y_create_usbmidi(snd_card_t* card ) | 156 | static int usX2Y_create_usbmidi(struct snd_card *card) |
155 | { | 157 | { |
156 | static snd_usb_midi_endpoint_info_t quirk_data_1 = { | 158 | static struct snd_usb_midi_endpoint_info quirk_data_1 = { |
157 | .out_ep =0x06, | 159 | .out_ep = 0x06, |
158 | .in_ep = 0x06, | 160 | .in_ep = 0x06, |
159 | .out_cables = 0x001, | 161 | .out_cables = 0x001, |
160 | .in_cables = 0x001 | 162 | .in_cables = 0x001 |
161 | }; | 163 | }; |
162 | static snd_usb_audio_quirk_t quirk_1 = { | 164 | static struct snd_usb_audio_quirk quirk_1 = { |
163 | .vendor_name = "TASCAM", | 165 | .vendor_name = "TASCAM", |
164 | .product_name = NAME_ALLCAPS, | 166 | .product_name = NAME_ALLCAPS, |
165 | .ifnum = 0, | 167 | .ifnum = 0, |
166 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 168 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
167 | .data = &quirk_data_1 | 169 | .data = &quirk_data_1 |
168 | }; | 170 | }; |
169 | static snd_usb_midi_endpoint_info_t quirk_data_2 = { | 171 | static struct snd_usb_midi_endpoint_info quirk_data_2 = { |
170 | .out_ep =0x06, | 172 | .out_ep = 0x06, |
171 | .in_ep = 0x06, | 173 | .in_ep = 0x06, |
172 | .out_cables = 0x003, | 174 | .out_cables = 0x003, |
173 | .in_cables = 0x003 | 175 | .in_cables = 0x003 |
174 | }; | 176 | }; |
175 | static snd_usb_audio_quirk_t quirk_2 = { | 177 | static struct snd_usb_audio_quirk quirk_2 = { |
176 | .vendor_name = "TASCAM", | 178 | .vendor_name = "TASCAM", |
177 | .product_name = "US428", | 179 | .product_name = "US428", |
178 | .ifnum = 0, | 180 | .ifnum = 0, |
@@ -181,13 +183,15 @@ static int usX2Y_create_usbmidi(snd_card_t* card ) | |||
181 | }; | 183 | }; |
182 | struct usb_device *dev = usX2Y(card)->chip.dev; | 184 | struct usb_device *dev = usX2Y(card)->chip.dev; |
183 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); | 185 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); |
184 | snd_usb_audio_quirk_t *quirk = le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? &quirk_2 : &quirk_1; | 186 | struct snd_usb_audio_quirk *quirk = |
187 | le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? | ||
188 | &quirk_2 : &quirk_1; | ||
185 | 189 | ||
186 | snd_printdd("usX2Y_create_usbmidi \n"); | 190 | snd_printdd("usX2Y_create_usbmidi \n"); |
187 | return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); | 191 | return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); |
188 | } | 192 | } |
189 | 193 | ||
190 | static int usX2Y_create_alsa_devices(snd_card_t* card) | 194 | static int usX2Y_create_alsa_devices(struct snd_card *card) |
191 | { | 195 | { |
192 | int err; | 196 | int err; |
193 | 197 | ||
@@ -207,9 +211,10 @@ static int usX2Y_create_alsa_devices(snd_card_t* card) | |||
207 | return err; | 211 | return err; |
208 | } | 212 | } |
209 | 213 | ||
210 | static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) | 214 | static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, |
215 | struct snd_hwdep_dsp_image *dsp) | ||
211 | { | 216 | { |
212 | usX2Ydev_t *priv = hw->private_data; | 217 | struct usX2Ydev *priv = hw->private_data; |
213 | int lret, err = -EINVAL; | 218 | int lret, err = -EINVAL; |
214 | snd_printdd( "dsp_load %s\n", dsp->name); | 219 | snd_printdd( "dsp_load %s\n", dsp->name); |
215 | 220 | ||
@@ -256,10 +261,10 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) | |||
256 | } | 261 | } |
257 | 262 | ||
258 | 263 | ||
259 | int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device) | 264 | int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) |
260 | { | 265 | { |
261 | int err; | 266 | int err; |
262 | snd_hwdep_t *hw; | 267 | struct snd_hwdep *hw; |
263 | 268 | ||
264 | if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0) | 269 | if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0) |
265 | return err; | 270 | return err; |
diff --git a/sound/usb/usx2y/usX2Yhwdep.h b/sound/usb/usx2y/usX2Yhwdep.h index d612a26eb77c..c095d5bf1220 100644 --- a/sound/usb/usx2y/usX2Yhwdep.h +++ b/sound/usb/usx2y/usX2Yhwdep.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef USX2YHWDEP_H | 1 | #ifndef USX2YHWDEP_H |
2 | #define USX2YHWDEP_H | 2 | #define USX2YHWDEP_H |
3 | 3 | ||
4 | int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device); | 4 | int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device); |
5 | 5 | ||
6 | #endif | 6 | #endif |
diff --git a/sound/usb/usx2y/usbus428ctldefs.h b/sound/usb/usx2y/usbus428ctldefs.h index 6af16438d2c7..b864e7e262e5 100644 --- a/sound/usb/usx2y/usbus428ctldefs.h +++ b/sound/usb/usx2y/usbus428ctldefs.h | |||
@@ -51,7 +51,7 @@ enum E_In84{ | |||
51 | #define T_NULL 0x80 | 51 | #define T_NULL 0x80 |
52 | 52 | ||
53 | 53 | ||
54 | struct us428_ctls{ | 54 | struct us428_ctls { |
55 | unsigned char Fader[9]; | 55 | unsigned char Fader[9]; |
56 | unsigned char Transport; | 56 | unsigned char Transport; |
57 | unsigned char Modifier; | 57 | unsigned char Modifier; |
@@ -63,46 +63,42 @@ struct us428_ctls{ | |||
63 | unsigned char Wheel[5]; | 63 | unsigned char Wheel[5]; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | typedef struct us428_ctls us428_ctls_t; | 66 | struct us428_setByte { |
67 | |||
68 | typedef struct us428_setByte{ | ||
69 | unsigned char Offset, | 67 | unsigned char Offset, |
70 | Value; | 68 | Value; |
71 | }us428_setByte_t; | 69 | }; |
72 | 70 | ||
73 | enum { | 71 | enum { |
74 | eLT_Volume = 0, | 72 | eLT_Volume = 0, |
75 | eLT_Light | 73 | eLT_Light |
76 | }; | 74 | }; |
77 | 75 | ||
78 | typedef struct usX2Y_volume { | 76 | struct usX2Y_volume { |
79 | unsigned char Channel, | 77 | unsigned char Channel, |
80 | LH, | 78 | LH, |
81 | LL, | 79 | LL, |
82 | RH, | 80 | RH, |
83 | RL; | 81 | RL; |
84 | } usX2Y_volume_t; | 82 | }; |
85 | 83 | ||
86 | struct us428_lights{ | 84 | struct us428_lights { |
87 | us428_setByte_t Light[7]; | 85 | struct us428_setByte Light[7]; |
88 | }; | 86 | }; |
89 | typedef struct us428_lights us428_lights_t; | ||
90 | 87 | ||
91 | typedef struct { | 88 | struct us428_p4out { |
92 | char type; | 89 | char type; |
93 | union { | 90 | union { |
94 | usX2Y_volume_t vol; | 91 | struct usX2Y_volume vol; |
95 | us428_lights_t lights; | 92 | struct us428_lights lights; |
96 | } val; | 93 | } val; |
97 | } us428_p4out_t; | 94 | }; |
98 | 95 | ||
99 | #define N_us428_ctl_BUFS 16 | 96 | #define N_us428_ctl_BUFS 16 |
100 | #define N_us428_p4out_BUFS 16 | 97 | #define N_us428_p4out_BUFS 16 |
101 | struct us428ctls_sharedmem{ | 98 | struct us428ctls_sharedmem{ |
102 | us428_ctls_t CtlSnapShot[N_us428_ctl_BUFS]; | 99 | struct us428_ctls CtlSnapShot[N_us428_ctl_BUFS]; |
103 | int CtlSnapShotDiffersAt[N_us428_ctl_BUFS]; | 100 | int CtlSnapShotDiffersAt[N_us428_ctl_BUFS]; |
104 | int CtlSnapShotLast, CtlSnapShotRed; | 101 | int CtlSnapShotLast, CtlSnapShotRed; |
105 | us428_p4out_t p4out[N_us428_p4out_BUFS]; | 102 | struct us428_p4out p4out[N_us428_p4out_BUFS]; |
106 | int p4outLast, p4outSent; | 103 | int p4outLast, p4outSent; |
107 | }; | 104 | }; |
108 | typedef struct us428ctls_sharedmem us428ctls_sharedmem_t; | ||
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index a3967f72ab4e..e0abb56bbe49 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -167,28 +167,28 @@ MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS"."); | |||
167 | static int snd_usX2Y_card_used[SNDRV_CARDS]; | 167 | static int snd_usX2Y_card_used[SNDRV_CARDS]; |
168 | 168 | ||
169 | static void usX2Y_usb_disconnect(struct usb_device* usb_device, void* ptr); | 169 | static void usX2Y_usb_disconnect(struct usb_device* usb_device, void* ptr); |
170 | static void snd_usX2Y_card_private_free(snd_card_t *card); | 170 | static void snd_usX2Y_card_private_free(struct snd_card *card); |
171 | 171 | ||
172 | /* | 172 | /* |
173 | * pipe 4 is used for switching the lamps, setting samplerate, volumes .... | 173 | * pipe 4 is used for switching the lamps, setting samplerate, volumes .... |
174 | */ | 174 | */ |
175 | static void i_usX2Y_Out04Int(struct urb* urb, struct pt_regs *regs) | 175 | static void i_usX2Y_Out04Int(struct urb *urb, struct pt_regs *regs) |
176 | { | 176 | { |
177 | #ifdef CONFIG_SND_DEBUG | 177 | #ifdef CONFIG_SND_DEBUG |
178 | if (urb->status) { | 178 | if (urb->status) { |
179 | int i; | 179 | int i; |
180 | usX2Ydev_t* usX2Y = urb->context; | 180 | struct usX2Ydev *usX2Y = urb->context; |
181 | for (i = 0; i < 10 && usX2Y->AS04.urb[i] != urb; i++); | 181 | for (i = 0; i < 10 && usX2Y->AS04.urb[i] != urb; i++); |
182 | snd_printdd("i_usX2Y_Out04Int() urb %i status=%i\n", i, urb->status); | 182 | snd_printdd("i_usX2Y_Out04Int() urb %i status=%i\n", i, urb->status); |
183 | } | 183 | } |
184 | #endif | 184 | #endif |
185 | } | 185 | } |
186 | 186 | ||
187 | static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) | 187 | static void i_usX2Y_In04Int(struct urb *urb, struct pt_regs *regs) |
188 | { | 188 | { |
189 | int err = 0; | 189 | int err = 0; |
190 | usX2Ydev_t *usX2Y = urb->context; | 190 | struct usX2Ydev *usX2Y = urb->context; |
191 | us428ctls_sharedmem_t *us428ctls = usX2Y->us428ctls_sharedmem; | 191 | struct us428ctls_sharedmem *us428ctls = usX2Y->us428ctls_sharedmem; |
192 | 192 | ||
193 | usX2Y->In04IntCalls++; | 193 | usX2Y->In04IntCalls++; |
194 | 194 | ||
@@ -239,10 +239,10 @@ static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) | |||
239 | send = 0; | 239 | send = 0; |
240 | for (j = 0; j < URBS_AsyncSeq && !err; ++j) | 240 | for (j = 0; j < URBS_AsyncSeq && !err; ++j) |
241 | if (0 == usX2Y->AS04.urb[j]->status) { | 241 | if (0 == usX2Y->AS04.urb[j]->status) { |
242 | us428_p4out_t *p4out = us428ctls->p4out + send; // FIXME if more then 1 p4out is new, 1 gets lost. | 242 | struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more then 1 p4out is new, 1 gets lost. |
243 | usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->chip.dev, | 243 | usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->chip.dev, |
244 | usb_sndbulkpipe(usX2Y->chip.dev, 0x04), &p4out->val.vol, | 244 | usb_sndbulkpipe(usX2Y->chip.dev, 0x04), &p4out->val.vol, |
245 | p4out->type == eLT_Light ? sizeof(us428_lights_t) : 5, | 245 | p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5, |
246 | i_usX2Y_Out04Int, usX2Y); | 246 | i_usX2Y_Out04Int, usX2Y); |
247 | err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); | 247 | err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); |
248 | us428ctls->p4outSent = send; | 248 | us428ctls->p4outSent = send; |
@@ -261,7 +261,7 @@ static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) | |||
261 | /* | 261 | /* |
262 | * Prepare some urbs | 262 | * Prepare some urbs |
263 | */ | 263 | */ |
264 | int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) | 264 | int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y) |
265 | { | 265 | { |
266 | int err = 0, | 266 | int err = 0, |
267 | i; | 267 | i; |
@@ -283,9 +283,8 @@ int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) | |||
283 | return err; | 283 | return err; |
284 | } | 284 | } |
285 | 285 | ||
286 | int usX2Y_In04_init(usX2Ydev_t* usX2Y) | 286 | int usX2Y_In04_init(struct usX2Ydev *usX2Y) |
287 | { | 287 | { |
288 | int err = 0; | ||
289 | if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL))) | 288 | if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL))) |
290 | return -ENOMEM; | 289 | return -ENOMEM; |
291 | 290 | ||
@@ -299,11 +298,10 @@ int usX2Y_In04_init(usX2Ydev_t* usX2Y) | |||
299 | usX2Y->In04Buf, 21, | 298 | usX2Y->In04Buf, 21, |
300 | i_usX2Y_In04Int, usX2Y, | 299 | i_usX2Y_In04Int, usX2Y, |
301 | 10); | 300 | 10); |
302 | err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); | 301 | return usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); |
303 | return err; | ||
304 | } | 302 | } |
305 | 303 | ||
306 | static void usX2Y_unlinkSeq(snd_usX2Y_AsyncSeq_t* S) | 304 | static void usX2Y_unlinkSeq(struct snd_usX2Y_AsyncSeq *S) |
307 | { | 305 | { |
308 | int i; | 306 | int i; |
309 | for (i = 0; i < URBS_AsyncSeq; ++i) { | 307 | for (i = 0; i < URBS_AsyncSeq; ++i) { |
@@ -336,16 +334,16 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = { | |||
336 | { /* terminator */ } | 334 | { /* terminator */ } |
337 | }; | 335 | }; |
338 | 336 | ||
339 | static snd_card_t* usX2Y_create_card(struct usb_device* device) | 337 | static struct snd_card *usX2Y_create_card(struct usb_device *device) |
340 | { | 338 | { |
341 | int dev; | 339 | int dev; |
342 | snd_card_t* card; | 340 | struct snd_card * card; |
343 | for (dev = 0; dev < SNDRV_CARDS; ++dev) | 341 | for (dev = 0; dev < SNDRV_CARDS; ++dev) |
344 | if (enable[dev] && !snd_usX2Y_card_used[dev]) | 342 | if (enable[dev] && !snd_usX2Y_card_used[dev]) |
345 | break; | 343 | break; |
346 | if (dev >= SNDRV_CARDS) | 344 | if (dev >= SNDRV_CARDS) |
347 | return NULL; | 345 | return NULL; |
348 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(usX2Ydev_t)); | 346 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev)); |
349 | if (!card) | 347 | if (!card) |
350 | return NULL; | 348 | return NULL; |
351 | snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; | 349 | snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; |
@@ -369,10 +367,10 @@ static snd_card_t* usX2Y_create_card(struct usb_device* device) | |||
369 | } | 367 | } |
370 | 368 | ||
371 | 369 | ||
372 | static void* usX2Y_usb_probe(struct usb_device* device, struct usb_interface *intf, const struct usb_device_id* device_id) | 370 | static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) |
373 | { | 371 | { |
374 | int err; | 372 | int err; |
375 | snd_card_t* card; | 373 | struct snd_card * card; |
376 | if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || | 374 | if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || |
377 | (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && | 375 | (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && |
378 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && | 376 | le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && |
@@ -415,7 +413,7 @@ static struct usb_driver snd_usX2Y_usb_driver = { | |||
415 | .id_table = snd_usX2Y_usb_id_table, | 413 | .id_table = snd_usX2Y_usb_id_table, |
416 | }; | 414 | }; |
417 | 415 | ||
418 | static void snd_usX2Y_card_private_free(snd_card_t *card) | 416 | static void snd_usX2Y_card_private_free(struct snd_card *card) |
419 | { | 417 | { |
420 | kfree(usX2Y(card)->In04Buf); | 418 | kfree(usX2Y(card)->In04Buf); |
421 | usb_free_urb(usX2Y(card)->In04urb); | 419 | usb_free_urb(usX2Y(card)->In04urb); |
@@ -428,23 +426,24 @@ static void snd_usX2Y_card_private_free(snd_card_t *card) | |||
428 | /* | 426 | /* |
429 | * Frees the device. | 427 | * Frees the device. |
430 | */ | 428 | */ |
431 | static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) | 429 | static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr) |
432 | { | 430 | { |
433 | if (ptr) { | 431 | if (ptr) { |
434 | usX2Ydev_t* usX2Y = usX2Y((snd_card_t*)ptr); | 432 | struct snd_card *card = ptr; |
435 | struct list_head* p; | 433 | struct usX2Ydev *usX2Y = usX2Y(card); |
434 | struct list_head *p; | ||
436 | usX2Y->chip.shutdown = 1; | 435 | usX2Y->chip.shutdown = 1; |
437 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; | 436 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; |
438 | usX2Y_unlinkSeq(&usX2Y->AS04); | 437 | usX2Y_unlinkSeq(&usX2Y->AS04); |
439 | usb_kill_urb(usX2Y->In04urb); | 438 | usb_kill_urb(usX2Y->In04urb); |
440 | snd_card_disconnect((snd_card_t*)ptr); | 439 | snd_card_disconnect(card); |
441 | /* release the midi resources */ | 440 | /* release the midi resources */ |
442 | list_for_each(p, &usX2Y->chip.midi_list) { | 441 | list_for_each(p, &usX2Y->chip.midi_list) { |
443 | snd_usbmidi_disconnect(p); | 442 | snd_usbmidi_disconnect(p); |
444 | } | 443 | } |
445 | if (usX2Y->us428ctls_sharedmem) | 444 | if (usX2Y->us428ctls_sharedmem) |
446 | wake_up(&usX2Y->us428ctls_wait_queue_head); | 445 | wake_up(&usX2Y->us428ctls_wait_queue_head); |
447 | snd_card_free((snd_card_t*)ptr); | 446 | snd_card_free(card); |
448 | } | 447 | } |
449 | } | 448 | } |
450 | 449 | ||
diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h index f65f3a7194ca..435c1feda9df 100644 --- a/sound/usb/usx2y/usbusx2y.h +++ b/sound/usb/usx2y/usbusx2y.h | |||
@@ -8,47 +8,46 @@ | |||
8 | 8 | ||
9 | #define URBS_AsyncSeq 10 | 9 | #define URBS_AsyncSeq 10 |
10 | #define URB_DataLen_AsyncSeq 32 | 10 | #define URB_DataLen_AsyncSeq 32 |
11 | typedef struct { | 11 | struct snd_usX2Y_AsyncSeq { |
12 | struct urb* urb[URBS_AsyncSeq]; | 12 | struct urb *urb[URBS_AsyncSeq]; |
13 | char* buffer; | 13 | char *buffer; |
14 | } snd_usX2Y_AsyncSeq_t; | 14 | }; |
15 | 15 | ||
16 | typedef struct { | 16 | struct snd_usX2Y_urbSeq { |
17 | int submitted; | 17 | int submitted; |
18 | int len; | 18 | int len; |
19 | struct urb* urb[0]; | 19 | struct urb *urb[0]; |
20 | } snd_usX2Y_urbSeq_t; | 20 | }; |
21 | 21 | ||
22 | typedef struct snd_usX2Y_substream snd_usX2Y_substream_t; | ||
23 | #include "usx2yhwdeppcm.h" | 22 | #include "usx2yhwdeppcm.h" |
24 | 23 | ||
25 | typedef struct { | 24 | struct usX2Ydev { |
26 | snd_usb_audio_t chip; | 25 | struct snd_usb_audio chip; |
27 | int stride; | 26 | int stride; |
28 | struct urb *In04urb; | 27 | struct urb *In04urb; |
29 | void *In04Buf; | 28 | void *In04Buf; |
30 | char In04Last[24]; | 29 | char In04Last[24]; |
31 | unsigned In04IntCalls; | 30 | unsigned In04IntCalls; |
32 | snd_usX2Y_urbSeq_t *US04; | 31 | struct snd_usX2Y_urbSeq *US04; |
33 | wait_queue_head_t In04WaitQueue; | 32 | wait_queue_head_t In04WaitQueue; |
34 | snd_usX2Y_AsyncSeq_t AS04; | 33 | struct snd_usX2Y_AsyncSeq AS04; |
35 | unsigned int rate, | 34 | unsigned int rate, |
36 | format; | 35 | format; |
37 | int chip_status; | 36 | int chip_status; |
38 | struct semaphore prepare_mutex; | 37 | struct semaphore prepare_mutex; |
39 | us428ctls_sharedmem_t *us428ctls_sharedmem; | 38 | struct us428ctls_sharedmem *us428ctls_sharedmem; |
40 | int wait_iso_frame; | 39 | int wait_iso_frame; |
41 | wait_queue_head_t us428ctls_wait_queue_head; | 40 | wait_queue_head_t us428ctls_wait_queue_head; |
42 | snd_usX2Y_hwdep_pcm_shm_t *hwdep_pcm_shm; | 41 | struct snd_usX2Y_hwdep_pcm_shm *hwdep_pcm_shm; |
43 | snd_usX2Y_substream_t *subs[4]; | 42 | struct snd_usX2Y_substream *subs[4]; |
44 | snd_usX2Y_substream_t * volatile prepare_subs; | 43 | struct snd_usX2Y_substream * volatile prepare_subs; |
45 | wait_queue_head_t prepare_wait_queue; | 44 | wait_queue_head_t prepare_wait_queue; |
46 | } usX2Ydev_t; | 45 | }; |
47 | 46 | ||
48 | 47 | ||
49 | struct snd_usX2Y_substream { | 48 | struct snd_usX2Y_substream { |
50 | usX2Ydev_t *usX2Y; | 49 | struct usX2Ydev *usX2Y; |
51 | snd_pcm_substream_t *pcm_substream; | 50 | struct snd_pcm_substream *pcm_substream; |
52 | 51 | ||
53 | int endpoint; | 52 | int endpoint; |
54 | unsigned int maxpacksize; /* max packet size in bytes */ | 53 | unsigned int maxpacksize; /* max packet size in bytes */ |
@@ -72,12 +71,12 @@ struct snd_usX2Y_substream { | |||
72 | }; | 71 | }; |
73 | 72 | ||
74 | 73 | ||
75 | #define usX2Y(c) ((usX2Ydev_t*)(c)->private_data) | 74 | #define usX2Y(c) ((struct usX2Ydev *)(c)->private_data) |
76 | 75 | ||
77 | int usX2Y_audio_create(snd_card_t* card); | 76 | int usX2Y_audio_create(struct snd_card *card); |
78 | 77 | ||
79 | int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y); | 78 | int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y); |
80 | int usX2Y_In04_init(usX2Ydev_t* usX2Y); | 79 | int usX2Y_In04_init(struct usX2Ydev *usX2Y); |
81 | 80 | ||
82 | #define NAME_ALLCAPS "US-X2Y" | 81 | #define NAME_ALLCAPS "US-X2Y" |
83 | 82 | ||
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index affda973cece..a6bbc7a6348f 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -67,18 +67,20 @@ | |||
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | 69 | ||
70 | static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | 70 | static int usX2Y_urb_capt_retire(struct snd_usX2Y_substream *subs) |
71 | { | 71 | { |
72 | struct urb *urb = subs->completed_urb; | 72 | struct urb *urb = subs->completed_urb; |
73 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 73 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
74 | unsigned char *cp; | 74 | unsigned char *cp; |
75 | int i, len, lens = 0, hwptr_done = subs->hwptr_done; | 75 | int i, len, lens = 0, hwptr_done = subs->hwptr_done; |
76 | usX2Ydev_t *usX2Y = subs->usX2Y; | 76 | struct usX2Ydev *usX2Y = subs->usX2Y; |
77 | 77 | ||
78 | for (i = 0; i < nr_of_packs(); i++) { | 78 | for (i = 0; i < nr_of_packs(); i++) { |
79 | cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 79 | cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset; |
80 | if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */ | 80 | if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */ |
81 | snd_printk(KERN_ERR "activ frame status %i. Most propably some hardware problem.\n", urb->iso_frame_desc[i].status); | 81 | snd_printk(KERN_ERR "active frame status %i. " |
82 | "Most propably some hardware problem.\n", | ||
83 | urb->iso_frame_desc[i].status); | ||
82 | return urb->iso_frame_desc[i].status; | 84 | return urb->iso_frame_desc[i].status; |
83 | } | 85 | } |
84 | len = urb->iso_frame_desc[i].actual_length / usX2Y->stride; | 86 | len = urb->iso_frame_desc[i].actual_length / usX2Y->stride; |
@@ -94,7 +96,8 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | |||
94 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen); | 96 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen); |
95 | memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen); | 97 | memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen); |
96 | } else { | 98 | } else { |
97 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, len * usX2Y->stride); | 99 | memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, |
100 | len * usX2Y->stride); | ||
98 | } | 101 | } |
99 | lens += len; | 102 | lens += len; |
100 | if ((hwptr_done += len) >= runtime->buffer_size) | 103 | if ((hwptr_done += len) >= runtime->buffer_size) |
@@ -120,13 +123,13 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) | |||
120 | * it directly from the buffer. thus the data is once copied to | 123 | * it directly from the buffer. thus the data is once copied to |
121 | * a temporary buffer and urb points to that. | 124 | * a temporary buffer and urb points to that. |
122 | */ | 125 | */ |
123 | static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | 126 | static int usX2Y_urb_play_prepare(struct snd_usX2Y_substream *subs, |
124 | struct urb *cap_urb, | 127 | struct urb *cap_urb, |
125 | struct urb *urb) | 128 | struct urb *urb) |
126 | { | 129 | { |
127 | int count, counts, pack; | 130 | int count, counts, pack; |
128 | usX2Ydev_t* usX2Y = subs->usX2Y; | 131 | struct usX2Ydev *usX2Y = subs->usX2Y; |
129 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 132 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
130 | 133 | ||
131 | count = 0; | 134 | count = 0; |
132 | for (pack = 0; pack < nr_of_packs(); pack++) { | 135 | for (pack = 0; pack < nr_of_packs(); pack++) { |
@@ -139,7 +142,8 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
139 | } | 142 | } |
140 | /* set up descriptor */ | 143 | /* set up descriptor */ |
141 | urb->iso_frame_desc[pack].offset = pack ? | 144 | urb->iso_frame_desc[pack].offset = pack ? |
142 | urb->iso_frame_desc[pack - 1].offset + urb->iso_frame_desc[pack - 1].length : | 145 | urb->iso_frame_desc[pack - 1].offset + |
146 | urb->iso_frame_desc[pack - 1].length : | ||
143 | 0; | 147 | 0; |
144 | urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length; | 148 | urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length; |
145 | } | 149 | } |
@@ -151,8 +155,10 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
151 | int len; | 155 | int len; |
152 | len = runtime->buffer_size - subs->hwptr; | 156 | len = runtime->buffer_size - subs->hwptr; |
153 | urb->transfer_buffer = subs->tmpbuf; | 157 | urb->transfer_buffer = subs->tmpbuf; |
154 | memcpy(subs->tmpbuf, runtime->dma_area + subs->hwptr * usX2Y->stride, len * usX2Y->stride); | 158 | memcpy(subs->tmpbuf, runtime->dma_area + |
155 | memcpy(subs->tmpbuf + len * usX2Y->stride, runtime->dma_area, (count - len) * usX2Y->stride); | 159 | subs->hwptr * usX2Y->stride, len * usX2Y->stride); |
160 | memcpy(subs->tmpbuf + len * usX2Y->stride, | ||
161 | runtime->dma_area, (count - len) * usX2Y->stride); | ||
156 | subs->hwptr += count; | 162 | subs->hwptr += count; |
157 | subs->hwptr -= runtime->buffer_size; | 163 | subs->hwptr -= runtime->buffer_size; |
158 | } else { | 164 | } else { |
@@ -172,9 +178,9 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
172 | * | 178 | * |
173 | * update the current position and call callback if a period is processed. | 179 | * update the current position and call callback if a period is processed. |
174 | */ | 180 | */ |
175 | static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) | 181 | static void usX2Y_urb_play_retire(struct snd_usX2Y_substream *subs, struct urb *urb) |
176 | { | 182 | { |
177 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 183 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
178 | int len = urb->actual_length / subs->usX2Y->stride; | 184 | int len = urb->actual_length / subs->usX2Y->stride; |
179 | 185 | ||
180 | subs->transfer_done += len; | 186 | subs->transfer_done += len; |
@@ -187,7 +193,7 @@ static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) | |||
187 | } | 193 | } |
188 | } | 194 | } |
189 | 195 | ||
190 | static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int frame) | 196 | static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, int frame) |
191 | { | 197 | { |
192 | int err; | 198 | int err; |
193 | if (!urb) | 199 | if (!urb) |
@@ -202,50 +208,47 @@ static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int fr | |||
202 | return 0; | 208 | return 0; |
203 | } | 209 | } |
204 | 210 | ||
205 | static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_usX2Y_substream_t *playbacksubs, int frame) | 211 | static inline int usX2Y_usbframe_complete(struct snd_usX2Y_substream *capsubs, |
212 | struct snd_usX2Y_substream *playbacksubs, | ||
213 | int frame) | ||
206 | { | 214 | { |
207 | int err, state; | 215 | int err, state; |
208 | { | 216 | struct urb *urb = playbacksubs->completed_urb; |
209 | struct urb *urb = playbacksubs->completed_urb; | 217 | |
210 | 218 | state = atomic_read(&playbacksubs->state); | |
211 | state = atomic_read(&playbacksubs->state); | 219 | if (NULL != urb) { |
212 | if (NULL != urb) { | 220 | if (state == state_RUNNING) |
213 | if (state == state_RUNNING) | 221 | usX2Y_urb_play_retire(playbacksubs, urb); |
214 | usX2Y_urb_play_retire(playbacksubs, urb); | 222 | else if (state >= state_PRERUNNING) |
215 | else | 223 | atomic_inc(&playbacksubs->state); |
216 | if (state >= state_PRERUNNING) { | 224 | } else { |
217 | atomic_inc(&playbacksubs->state); | 225 | switch (state) { |
218 | } | 226 | case state_STARTING1: |
219 | } else { | 227 | urb = playbacksubs->urb[0]; |
220 | switch (state) { | 228 | atomic_inc(&playbacksubs->state); |
221 | case state_STARTING1: | 229 | break; |
222 | urb = playbacksubs->urb[0]; | 230 | case state_STARTING2: |
223 | atomic_inc(&playbacksubs->state); | 231 | urb = playbacksubs->urb[1]; |
224 | break; | 232 | atomic_inc(&playbacksubs->state); |
225 | case state_STARTING2: | 233 | break; |
226 | urb = playbacksubs->urb[1]; | ||
227 | atomic_inc(&playbacksubs->state); | ||
228 | break; | ||
229 | } | ||
230 | } | 234 | } |
231 | if (urb) { | 235 | } |
232 | if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || | 236 | if (urb) { |
233 | (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { | 237 | if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || |
234 | return err; | 238 | (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { |
235 | } | 239 | return err; |
236 | } | 240 | } |
237 | |||
238 | playbacksubs->completed_urb = NULL; | ||
239 | } | 241 | } |
242 | |||
243 | playbacksubs->completed_urb = NULL; | ||
244 | |||
240 | state = atomic_read(&capsubs->state); | 245 | state = atomic_read(&capsubs->state); |
241 | if (state >= state_PREPARED) { | 246 | if (state >= state_PREPARED) { |
242 | if (state == state_RUNNING) { | 247 | if (state == state_RUNNING) { |
243 | if ((err = usX2Y_urb_capt_retire(capsubs))) | 248 | if ((err = usX2Y_urb_capt_retire(capsubs))) |
244 | return err; | 249 | return err; |
245 | } else | 250 | } else if (state >= state_PRERUNNING) |
246 | if (state >= state_PRERUNNING) { | 251 | atomic_inc(&capsubs->state); |
247 | atomic_inc(&capsubs->state); | ||
248 | } | ||
249 | if ((err = usX2Y_urb_submit(capsubs, capsubs->completed_urb, frame))) | 252 | if ((err = usX2Y_urb_submit(capsubs, capsubs->completed_urb, frame))) |
250 | return err; | 253 | return err; |
251 | } | 254 | } |
@@ -254,18 +257,19 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us | |||
254 | } | 257 | } |
255 | 258 | ||
256 | 259 | ||
257 | static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | 260 | static void usX2Y_clients_stop(struct usX2Ydev *usX2Y) |
258 | { | 261 | { |
259 | int s, u; | 262 | int s, u; |
263 | |||
260 | for (s = 0; s < 4; s++) { | 264 | for (s = 0; s < 4; s++) { |
261 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 265 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
262 | if (subs) { | 266 | if (subs) { |
263 | snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); | 267 | snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); |
264 | atomic_set(&subs->state, state_STOPPED); | 268 | atomic_set(&subs->state, state_STOPPED); |
265 | } | 269 | } |
266 | } | 270 | } |
267 | for (s = 0; s < 4; s++) { | 271 | for (s = 0; s < 4; s++) { |
268 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 272 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
269 | if (subs) { | 273 | if (subs) { |
270 | if (atomic_read(&subs->state) >= state_PRERUNNING) { | 274 | if (atomic_read(&subs->state) >= state_PRERUNNING) { |
271 | snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); | 275 | snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); |
@@ -273,7 +277,8 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | |||
273 | for (u = 0; u < NRURBS; u++) { | 277 | for (u = 0; u < NRURBS; u++) { |
274 | struct urb *urb = subs->urb[u]; | 278 | struct urb *urb = subs->urb[u]; |
275 | if (NULL != urb) | 279 | if (NULL != urb) |
276 | snd_printdd("%i status=%i start_frame=%i\n", u, urb->status, urb->start_frame); | 280 | snd_printdd("%i status=%i start_frame=%i\n", |
281 | u, urb->status, urb->start_frame); | ||
277 | } | 282 | } |
278 | } | 283 | } |
279 | } | 284 | } |
@@ -281,30 +286,36 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) | |||
281 | wake_up(&usX2Y->prepare_wait_queue); | 286 | wake_up(&usX2Y->prepare_wait_queue); |
282 | } | 287 | } |
283 | 288 | ||
284 | static void usX2Y_error_urb_status(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) | 289 | static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y, |
290 | struct snd_usX2Y_substream *subs, struct urb *urb) | ||
285 | { | 291 | { |
286 | snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); | 292 | snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); |
287 | urb->status = 0; | 293 | urb->status = 0; |
288 | usX2Y_clients_stop(usX2Y); | 294 | usX2Y_clients_stop(usX2Y); |
289 | } | 295 | } |
290 | 296 | ||
291 | static void usX2Y_error_sequence(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) | 297 | static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, |
298 | struct snd_usX2Y_substream *subs, struct urb *urb) | ||
292 | { | 299 | { |
293 | snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" | 300 | snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" |
294 | KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" | 301 | KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" |
295 | KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", | 302 | KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", |
296 | usb_get_current_frame_number(usX2Y->chip.dev), | 303 | usb_get_current_frame_number(usX2Y->chip.dev), |
297 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | 304 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
305 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | ||
298 | usX2Y_clients_stop(usX2Y); | 306 | usX2Y_clients_stop(usX2Y); |
299 | } | 307 | } |
300 | 308 | ||
301 | static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | 309 | static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) |
302 | { | 310 | { |
303 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 311 | struct snd_usX2Y_substream *subs = urb->context; |
304 | usX2Ydev_t *usX2Y = subs->usX2Y; | 312 | struct usX2Ydev *usX2Y = subs->usX2Y; |
305 | 313 | ||
306 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { | 314 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
307 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", usb_get_current_frame_number(usX2Y->chip.dev), subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", urb->status, urb->start_frame); | 315 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
316 | usb_get_current_frame_number(usX2Y->chip.dev), | ||
317 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | ||
318 | urb->status, urb->start_frame); | ||
308 | return; | 319 | return; |
309 | } | 320 | } |
310 | if (unlikely(urb->status)) { | 321 | if (unlikely(urb->status)) { |
@@ -318,10 +329,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | |||
318 | return; | 329 | return; |
319 | } | 330 | } |
320 | { | 331 | { |
321 | snd_usX2Y_substream_t *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], | 332 | struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], |
322 | *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 333 | *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
323 | if (capsubs->completed_urb && atomic_read(&capsubs->state) >= state_PREPARED && | 334 | if (capsubs->completed_urb && |
324 | (playbacksubs->completed_urb || atomic_read(&playbacksubs->state) < state_PREPARED)) { | 335 | atomic_read(&capsubs->state) >= state_PREPARED && |
336 | (playbacksubs->completed_urb || | ||
337 | atomic_read(&playbacksubs->state) < state_PREPARED)) { | ||
325 | if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { | 338 | if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { |
326 | if (nr_of_packs() <= urb->start_frame && | 339 | if (nr_of_packs() <= urb->start_frame && |
327 | urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci | 340 | urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci |
@@ -336,11 +349,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) | |||
336 | } | 349 | } |
337 | } | 350 | } |
338 | 351 | ||
339 | static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct urb *, struct pt_regs *)) | 352 | static void usX2Y_urbs_set_complete(struct usX2Ydev * usX2Y, |
353 | void (*complete)(struct urb *, struct pt_regs *)) | ||
340 | { | 354 | { |
341 | int s, u; | 355 | int s, u; |
342 | for (s = 0; s < 4; s++) { | 356 | for (s = 0; s < 4; s++) { |
343 | snd_usX2Y_substream_t *subs = usX2Y->subs[s]; | 357 | struct snd_usX2Y_substream *subs = usX2Y->subs[s]; |
344 | if (NULL != subs) | 358 | if (NULL != subs) |
345 | for (u = 0; u < NRURBS; u++) { | 359 | for (u = 0; u < NRURBS; u++) { |
346 | struct urb * urb = subs->urb[u]; | 360 | struct urb * urb = subs->urb[u]; |
@@ -350,7 +364,7 @@ static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct | |||
350 | } | 364 | } |
351 | } | 365 | } |
352 | 366 | ||
353 | static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) | 367 | static void usX2Y_subs_startup_finish(struct usX2Ydev * usX2Y) |
354 | { | 368 | { |
355 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); | 369 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); |
356 | usX2Y->prepare_subs = NULL; | 370 | usX2Y->prepare_subs = NULL; |
@@ -358,9 +372,9 @@ static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) | |||
358 | 372 | ||
359 | static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) | 373 | static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) |
360 | { | 374 | { |
361 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 375 | struct snd_usX2Y_substream *subs = urb->context; |
362 | usX2Ydev_t *usX2Y = subs->usX2Y; | 376 | struct usX2Ydev *usX2Y = subs->usX2Y; |
363 | snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; | 377 | struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; |
364 | if (NULL != prepare_subs) | 378 | if (NULL != prepare_subs) |
365 | if (urb->start_frame == prepare_subs->urb[0]->start_frame) { | 379 | if (urb->start_frame == prepare_subs->urb[0]->start_frame) { |
366 | usX2Y_subs_startup_finish(usX2Y); | 380 | usX2Y_subs_startup_finish(usX2Y); |
@@ -371,9 +385,10 @@ static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) | |||
371 | i_usX2Y_urb_complete(urb, regs); | 385 | i_usX2Y_urb_complete(urb, regs); |
372 | } | 386 | } |
373 | 387 | ||
374 | static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) | 388 | static void usX2Y_subs_prepare(struct snd_usX2Y_substream *subs) |
375 | { | 389 | { |
376 | snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", subs, subs->endpoint, subs->urb[0], subs->urb[1]); | 390 | snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", |
391 | subs, subs->endpoint, subs->urb[0], subs->urb[1]); | ||
377 | /* reset the pointer */ | 392 | /* reset the pointer */ |
378 | subs->hwptr = 0; | 393 | subs->hwptr = 0; |
379 | subs->hwptr_done = 0; | 394 | subs->hwptr_done = 0; |
@@ -381,7 +396,7 @@ static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) | |||
381 | } | 396 | } |
382 | 397 | ||
383 | 398 | ||
384 | static void usX2Y_urb_release(struct urb** urb, int free_tb) | 399 | static void usX2Y_urb_release(struct urb **urb, int free_tb) |
385 | { | 400 | { |
386 | if (*urb) { | 401 | if (*urb) { |
387 | usb_kill_urb(*urb); | 402 | usb_kill_urb(*urb); |
@@ -394,12 +409,13 @@ static void usX2Y_urb_release(struct urb** urb, int free_tb) | |||
394 | /* | 409 | /* |
395 | * release a substreams urbs | 410 | * release a substreams urbs |
396 | */ | 411 | */ |
397 | static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) | 412 | static void usX2Y_urbs_release(struct snd_usX2Y_substream *subs) |
398 | { | 413 | { |
399 | int i; | 414 | int i; |
400 | snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); | 415 | snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); |
401 | for (i = 0; i < NRURBS; i++) | 416 | for (i = 0; i < NRURBS; i++) |
402 | usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); | 417 | usX2Y_urb_release(subs->urb + i, |
418 | subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); | ||
403 | 419 | ||
404 | kfree(subs->tmpbuf); | 420 | kfree(subs->tmpbuf); |
405 | subs->tmpbuf = NULL; | 421 | subs->tmpbuf = NULL; |
@@ -407,7 +423,7 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) | |||
407 | /* | 423 | /* |
408 | * initialize a substream's urbs | 424 | * initialize a substream's urbs |
409 | */ | 425 | */ |
410 | static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) | 426 | static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) |
411 | { | 427 | { |
412 | int i; | 428 | int i; |
413 | unsigned int pipe; | 429 | unsigned int pipe; |
@@ -429,7 +445,7 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) | |||
429 | } | 445 | } |
430 | /* allocate and initialize data urbs */ | 446 | /* allocate and initialize data urbs */ |
431 | for (i = 0; i < NRURBS; i++) { | 447 | for (i = 0; i < NRURBS; i++) { |
432 | struct urb** purb = subs->urb + i; | 448 | struct urb **purb = subs->urb + i; |
433 | if (*purb) { | 449 | if (*purb) { |
434 | usb_kill_urb(*purb); | 450 | usb_kill_urb(*purb); |
435 | continue; | 451 | continue; |
@@ -457,70 +473,68 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) | |||
457 | return 0; | 473 | return 0; |
458 | } | 474 | } |
459 | 475 | ||
460 | static void usX2Y_subs_startup(snd_usX2Y_substream_t *subs) | 476 | static void usX2Y_subs_startup(struct snd_usX2Y_substream *subs) |
461 | { | 477 | { |
462 | usX2Ydev_t *usX2Y = subs->usX2Y; | 478 | struct usX2Ydev *usX2Y = subs->usX2Y; |
463 | usX2Y->prepare_subs = subs; | 479 | usX2Y->prepare_subs = subs; |
464 | subs->urb[0]->start_frame = -1; | 480 | subs->urb[0]->start_frame = -1; |
465 | wmb(); | 481 | wmb(); |
466 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); | 482 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); |
467 | } | 483 | } |
468 | 484 | ||
469 | static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) | 485 | static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs) |
470 | { | 486 | { |
471 | int i, err; | 487 | int i, err; |
472 | usX2Ydev_t *usX2Y = subs->usX2Y; | 488 | struct usX2Ydev *usX2Y = subs->usX2Y; |
473 | 489 | ||
474 | if ((err = usX2Y_urbs_allocate(subs)) < 0) | 490 | if ((err = usX2Y_urbs_allocate(subs)) < 0) |
475 | return err; | 491 | return err; |
476 | subs->completed_urb = NULL; | 492 | subs->completed_urb = NULL; |
477 | for (i = 0; i < 4; i++) { | 493 | for (i = 0; i < 4; i++) { |
478 | snd_usX2Y_substream_t *subs = usX2Y->subs[i]; | 494 | struct snd_usX2Y_substream *subs = usX2Y->subs[i]; |
479 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) | 495 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) |
480 | goto start; | 496 | goto start; |
481 | } | 497 | } |
482 | usX2Y->wait_iso_frame = -1; | 498 | usX2Y->wait_iso_frame = -1; |
499 | |||
483 | start: | 500 | start: |
484 | { | 501 | usX2Y_subs_startup(subs); |
485 | usX2Y_subs_startup(subs); | 502 | for (i = 0; i < NRURBS; i++) { |
486 | for (i = 0; i < NRURBS; i++) { | 503 | struct urb *urb = subs->urb[i]; |
487 | struct urb *urb = subs->urb[i]; | 504 | if (usb_pipein(urb->pipe)) { |
488 | if (usb_pipein(urb->pipe)) { | 505 | unsigned long pack; |
489 | unsigned long pack; | 506 | if (0 == i) |
490 | if (0 == i) | 507 | atomic_set(&subs->state, state_STARTING3); |
491 | atomic_set(&subs->state, state_STARTING3); | 508 | urb->dev = usX2Y->chip.dev; |
492 | urb->dev = usX2Y->chip.dev; | 509 | urb->transfer_flags = URB_ISO_ASAP; |
493 | urb->transfer_flags = URB_ISO_ASAP; | 510 | for (pack = 0; pack < nr_of_packs(); pack++) { |
494 | for (pack = 0; pack < nr_of_packs(); pack++) { | 511 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; |
495 | urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; | 512 | urb->iso_frame_desc[pack].length = subs->maxpacksize; |
496 | urb->iso_frame_desc[pack].length = subs->maxpacksize; | 513 | } |
497 | } | 514 | urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); |
498 | urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); | 515 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { |
499 | if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { | 516 | snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); |
500 | snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); | 517 | err = -EPIPE; |
501 | err = -EPIPE; | 518 | goto cleanup; |
502 | goto cleanup; | ||
503 | } else { | ||
504 | if (0 > usX2Y->wait_iso_frame) | ||
505 | usX2Y->wait_iso_frame = urb->start_frame; | ||
506 | } | ||
507 | urb->transfer_flags = 0; | ||
508 | } else { | 519 | } else { |
509 | atomic_set(&subs->state, state_STARTING1); | 520 | if (0 > usX2Y->wait_iso_frame) |
510 | break; | 521 | usX2Y->wait_iso_frame = urb->start_frame; |
511 | } | 522 | } |
523 | urb->transfer_flags = 0; | ||
524 | } else { | ||
525 | atomic_set(&subs->state, state_STARTING1); | ||
526 | break; | ||
512 | } | 527 | } |
513 | err = 0; | 528 | } |
514 | wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs); | 529 | err = 0; |
515 | if (atomic_read(&subs->state) != state_PREPARED) { | 530 | wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs); |
516 | err = -EPIPE; | 531 | if (atomic_read(&subs->state) != state_PREPARED) |
517 | } | 532 | err = -EPIPE; |
518 | 533 | ||
519 | cleanup: | 534 | cleanup: |
520 | if (err) { | 535 | if (err) { |
521 | usX2Y_subs_startup_finish(usX2Y); | 536 | usX2Y_subs_startup_finish(usX2Y); |
522 | usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything | 537 | usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything |
523 | } | ||
524 | } | 538 | } |
525 | return err; | 539 | return err; |
526 | } | 540 | } |
@@ -528,17 +542,17 @@ static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) | |||
528 | /* | 542 | /* |
529 | * return the current pcm pointer. just return the hwptr_done value. | 543 | * return the current pcm pointer. just return the hwptr_done value. |
530 | */ | 544 | */ |
531 | static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(snd_pcm_substream_t *substream) | 545 | static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(struct snd_pcm_substream *substream) |
532 | { | 546 | { |
533 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; | 547 | struct snd_usX2Y_substream *subs = substream->runtime->private_data; |
534 | return subs->hwptr_done; | 548 | return subs->hwptr_done; |
535 | } | 549 | } |
536 | /* | 550 | /* |
537 | * start/stop substream | 551 | * start/stop substream |
538 | */ | 552 | */ |
539 | static int snd_usX2Y_pcm_trigger(snd_pcm_substream_t *substream, int cmd) | 553 | static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
540 | { | 554 | { |
541 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; | 555 | struct snd_usX2Y_substream *subs = substream->runtime->private_data; |
542 | 556 | ||
543 | switch (cmd) { | 557 | switch (cmd) { |
544 | case SNDRV_PCM_TRIGGER_START: | 558 | case SNDRV_PCM_TRIGGER_START: |
@@ -649,9 +663,9 @@ static struct s_c2 SetRate48000[] = | |||
649 | }; | 663 | }; |
650 | #define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) | 664 | #define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) |
651 | 665 | ||
652 | static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) | 666 | static void i_usX2Y_04Int(struct urb *urb, struct pt_regs *regs) |
653 | { | 667 | { |
654 | usX2Ydev_t* usX2Y = urb->context; | 668 | struct usX2Ydev *usX2Y = urb->context; |
655 | 669 | ||
656 | if (urb->status) | 670 | if (urb->status) |
657 | snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status); | 671 | snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status); |
@@ -659,21 +673,20 @@ static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) | |||
659 | wake_up(&usX2Y->In04WaitQueue); | 673 | wake_up(&usX2Y->In04WaitQueue); |
660 | } | 674 | } |
661 | 675 | ||
662 | static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) | 676 | static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) |
663 | { | 677 | { |
664 | int err = 0, i; | 678 | int err = 0, i; |
665 | snd_usX2Y_urbSeq_t *us = NULL; | 679 | struct snd_usX2Y_urbSeq *us = NULL; |
666 | int *usbdata = NULL; | 680 | int *usbdata = NULL; |
667 | struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; | 681 | struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; |
668 | 682 | ||
669 | if (usX2Y->rate != rate) { | 683 | if (usX2Y->rate != rate) { |
670 | us = kmalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); | 684 | us = kzalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); |
671 | if (NULL == us) { | 685 | if (NULL == us) { |
672 | err = -ENOMEM; | 686 | err = -ENOMEM; |
673 | goto cleanup; | 687 | goto cleanup; |
674 | } | 688 | } |
675 | memset(us, 0, sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS); | 689 | usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL); |
676 | usbdata = kmalloc(sizeof(int)*NOOF_SETRATE_URBS, GFP_KERNEL); | ||
677 | if (NULL == usbdata) { | 690 | if (NULL == usbdata) { |
678 | err = -ENOMEM; | 691 | err = -ENOMEM; |
679 | goto cleanup; | 692 | goto cleanup; |
@@ -713,9 +726,8 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) | |||
713 | usX2Y->US04 = NULL; | 726 | usX2Y->US04 = NULL; |
714 | kfree(usbdata); | 727 | kfree(usbdata); |
715 | kfree(us); | 728 | kfree(us); |
716 | if (!err) { | 729 | if (!err) |
717 | usX2Y->rate = rate; | 730 | usX2Y->rate = rate; |
718 | } | ||
719 | } | 731 | } |
720 | } | 732 | } |
721 | 733 | ||
@@ -723,7 +735,7 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) | |||
723 | } | 735 | } |
724 | 736 | ||
725 | 737 | ||
726 | static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) | 738 | static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) |
727 | { | 739 | { |
728 | int alternate, err; | 740 | int alternate, err; |
729 | struct list_head* p; | 741 | struct list_head* p; |
@@ -753,40 +765,40 @@ static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) | |||
753 | } | 765 | } |
754 | 766 | ||
755 | 767 | ||
756 | static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, | 768 | static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream, |
757 | snd_pcm_hw_params_t *hw_params) | 769 | struct snd_pcm_hw_params *hw_params) |
758 | { | 770 | { |
759 | int err = 0; | 771 | int err = 0; |
760 | unsigned int rate = params_rate(hw_params); | 772 | unsigned int rate = params_rate(hw_params); |
761 | snd_pcm_format_t format = params_format(hw_params); | 773 | snd_pcm_format_t format = params_format(hw_params); |
762 | snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); | 774 | struct snd_card *card = substream->pstr->pcm->card; |
775 | struct list_head *list; | ||
763 | 776 | ||
764 | { // all pcm substreams off one usX2Y have to operate at the same rate & format | 777 | snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); |
765 | snd_card_t *card = substream->pstr->pcm->card; | 778 | // all pcm substreams off one usX2Y have to operate at the same rate & format |
766 | struct list_head *list; | 779 | list_for_each(list, &card->devices) { |
767 | list_for_each(list, &card->devices) { | 780 | struct snd_device *dev; |
768 | snd_device_t *dev; | 781 | struct snd_pcm *pcm; |
769 | snd_pcm_t *pcm; | 782 | int s; |
770 | int s; | 783 | dev = snd_device(list); |
771 | dev = snd_device(list); | 784 | if (dev->type != SNDRV_DEV_PCM) |
772 | if (dev->type != SNDRV_DEV_PCM) | 785 | continue; |
773 | continue; | 786 | pcm = dev->device_data; |
774 | pcm = dev->device_data; | 787 | for (s = 0; s < 2; ++s) { |
775 | for (s = 0; s < 2; ++s) { | 788 | struct snd_pcm_substream *test_substream; |
776 | snd_pcm_substream_t *test_substream; | 789 | test_substream = pcm->streams[s].substream; |
777 | test_substream = pcm->streams[s].substream; | 790 | if (test_substream && test_substream != substream && |
778 | if (test_substream && test_substream != substream && | 791 | test_substream->runtime && |
779 | test_substream->runtime && | 792 | ((test_substream->runtime->format && |
780 | ((test_substream->runtime->format && | 793 | test_substream->runtime->format != format) || |
781 | test_substream->runtime->format != format) || | 794 | (test_substream->runtime->rate && |
782 | (test_substream->runtime->rate && | 795 | test_substream->runtime->rate != rate))) |
783 | test_substream->runtime->rate != rate))) | 796 | return -EINVAL; |
784 | return -EINVAL; | ||
785 | } | ||
786 | } | 797 | } |
787 | } | 798 | } |
788 | if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { | 799 | if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { |
789 | snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", substream, params_buffer_bytes(hw_params), err); | 800 | snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", |
801 | substream, params_buffer_bytes(hw_params), err); | ||
790 | return err; | 802 | return err; |
791 | } | 803 | } |
792 | return 0; | 804 | return 0; |
@@ -795,15 +807,15 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, | |||
795 | /* | 807 | /* |
796 | * free the buffer | 808 | * free the buffer |
797 | */ | 809 | */ |
798 | static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | 810 | static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream) |
799 | { | 811 | { |
800 | snd_pcm_runtime_t *runtime = substream->runtime; | 812 | struct snd_pcm_runtime *runtime = substream->runtime; |
801 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 813 | struct snd_usX2Y_substream *subs = runtime->private_data; |
802 | down(&subs->usX2Y->prepare_mutex); | 814 | down(&subs->usX2Y->prepare_mutex); |
803 | snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); | 815 | snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); |
804 | 816 | ||
805 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { | 817 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { |
806 | snd_usX2Y_substream_t *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 818 | struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
807 | atomic_set(&subs->state, state_STOPPED); | 819 | atomic_set(&subs->state, state_STOPPED); |
808 | usX2Y_urbs_release(subs); | 820 | usX2Y_urbs_release(subs); |
809 | if (!cap_subs->pcm_substream || | 821 | if (!cap_subs->pcm_substream || |
@@ -814,7 +826,7 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | |||
814 | usX2Y_urbs_release(cap_subs); | 826 | usX2Y_urbs_release(cap_subs); |
815 | } | 827 | } |
816 | } else { | 828 | } else { |
817 | snd_usX2Y_substream_t *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 829 | struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
818 | if (atomic_read(&playback_subs->state) < state_PREPARED) { | 830 | if (atomic_read(&playback_subs->state) < state_PREPARED) { |
819 | atomic_set(&subs->state, state_STOPPED); | 831 | atomic_set(&subs->state, state_STOPPED); |
820 | usX2Y_urbs_release(subs); | 832 | usX2Y_urbs_release(subs); |
@@ -828,12 +840,12 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) | |||
828 | * | 840 | * |
829 | * set format and initialize urbs | 841 | * set format and initialize urbs |
830 | */ | 842 | */ |
831 | static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) | 843 | static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream) |
832 | { | 844 | { |
833 | snd_pcm_runtime_t *runtime = substream->runtime; | 845 | struct snd_pcm_runtime *runtime = substream->runtime; |
834 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 846 | struct snd_usX2Y_substream *subs = runtime->private_data; |
835 | usX2Ydev_t *usX2Y = subs->usX2Y; | 847 | struct usX2Ydev *usX2Y = subs->usX2Y; |
836 | snd_usX2Y_substream_t *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 848 | struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
837 | int err = 0; | 849 | int err = 0; |
838 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); | 850 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); |
839 | 851 | ||
@@ -861,7 +873,7 @@ static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) | |||
861 | return err; | 873 | return err; |
862 | } | 874 | } |
863 | 875 | ||
864 | static snd_pcm_hardware_t snd_usX2Y_2c = | 876 | static struct snd_pcm_hardware snd_usX2Y_2c = |
865 | { | 877 | { |
866 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 878 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
867 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 879 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
@@ -882,11 +894,11 @@ static snd_pcm_hardware_t snd_usX2Y_2c = | |||
882 | 894 | ||
883 | 895 | ||
884 | 896 | ||
885 | static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) | 897 | static int snd_usX2Y_pcm_open(struct snd_pcm_substream *substream) |
886 | { | 898 | { |
887 | snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) | 899 | struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) |
888 | snd_pcm_substream_chip(substream))[substream->stream]; | 900 | snd_pcm_substream_chip(substream))[substream->stream]; |
889 | snd_pcm_runtime_t *runtime = substream->runtime; | 901 | struct snd_pcm_runtime *runtime = substream->runtime; |
890 | 902 | ||
891 | if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) | 903 | if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) |
892 | return -EBUSY; | 904 | return -EBUSY; |
@@ -900,19 +912,18 @@ static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) | |||
900 | 912 | ||
901 | 913 | ||
902 | 914 | ||
903 | static int snd_usX2Y_pcm_close(snd_pcm_substream_t *substream) | 915 | static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream) |
904 | { | 916 | { |
905 | snd_pcm_runtime_t *runtime = substream->runtime; | 917 | struct snd_pcm_runtime *runtime = substream->runtime; |
906 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 918 | struct snd_usX2Y_substream *subs = runtime->private_data; |
907 | int err = 0; | ||
908 | 919 | ||
909 | subs->pcm_substream = NULL; | 920 | subs->pcm_substream = NULL; |
910 | 921 | ||
911 | return err; | 922 | return 0; |
912 | } | 923 | } |
913 | 924 | ||
914 | 925 | ||
915 | static snd_pcm_ops_t snd_usX2Y_pcm_ops = | 926 | static struct snd_pcm_ops snd_usX2Y_pcm_ops = |
916 | { | 927 | { |
917 | .open = snd_usX2Y_pcm_open, | 928 | .open = snd_usX2Y_pcm_open, |
918 | .close = snd_usX2Y_pcm_close, | 929 | .close = snd_usX2Y_pcm_close, |
@@ -928,7 +939,7 @@ static snd_pcm_ops_t snd_usX2Y_pcm_ops = | |||
928 | /* | 939 | /* |
929 | * free a usb stream instance | 940 | * free a usb stream instance |
930 | */ | 941 | */ |
931 | static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) | 942 | static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream) |
932 | { | 943 | { |
933 | if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { | 944 | if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { |
934 | kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); | 945 | kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); |
@@ -938,25 +949,23 @@ static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) | |||
938 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; | 949 | usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; |
939 | } | 950 | } |
940 | 951 | ||
941 | static void snd_usX2Y_pcm_private_free(snd_pcm_t *pcm) | 952 | static void snd_usX2Y_pcm_private_free(struct snd_pcm *pcm) |
942 | { | 953 | { |
943 | snd_usX2Y_substream_t **usX2Y_stream = pcm->private_data; | 954 | struct snd_usX2Y_substream **usX2Y_stream = pcm->private_data; |
944 | if (usX2Y_stream) { | 955 | if (usX2Y_stream) |
945 | snd_pcm_lib_preallocate_free_for_all(pcm); | ||
946 | usX2Y_audio_stream_free(usX2Y_stream); | 956 | usX2Y_audio_stream_free(usX2Y_stream); |
947 | } | ||
948 | } | 957 | } |
949 | 958 | ||
950 | static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int capture_endpoint) | 959 | static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint) |
951 | { | 960 | { |
952 | snd_pcm_t *pcm; | 961 | struct snd_pcm *pcm; |
953 | int err, i; | 962 | int err, i; |
954 | snd_usX2Y_substream_t **usX2Y_substream = | 963 | struct snd_usX2Y_substream **usX2Y_substream = |
955 | usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; | 964 | usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; |
956 | 965 | ||
957 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; | 966 | for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; |
958 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { | 967 | i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { |
959 | usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL); | 968 | usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL); |
960 | if (NULL == usX2Y_substream[i]) { | 969 | if (NULL == usX2Y_substream[i]) { |
961 | snd_printk(KERN_ERR "cannot malloc\n"); | 970 | snd_printk(KERN_ERR "cannot malloc\n"); |
962 | return -ENOMEM; | 971 | return -ENOMEM; |
@@ -1006,7 +1015,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c | |||
1006 | /* | 1015 | /* |
1007 | * create a chip instance and set its names. | 1016 | * create a chip instance and set its names. |
1008 | */ | 1017 | */ |
1009 | int usX2Y_audio_create(snd_card_t* card) | 1018 | int usX2Y_audio_create(struct snd_card *card) |
1010 | { | 1019 | { |
1011 | int err = 0; | 1020 | int err = 0; |
1012 | 1021 | ||
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index c9136a98755f..796a7dcef09d 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c | |||
@@ -58,12 +58,12 @@ | |||
58 | #include <sound/hwdep.h> | 58 | #include <sound/hwdep.h> |
59 | 59 | ||
60 | 60 | ||
61 | static int usX2Y_usbpcm_urb_capt_retire(snd_usX2Y_substream_t *subs) | 61 | static int usX2Y_usbpcm_urb_capt_retire(struct snd_usX2Y_substream *subs) |
62 | { | 62 | { |
63 | struct urb *urb = subs->completed_urb; | 63 | struct urb *urb = subs->completed_urb; |
64 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 64 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
65 | int i, lens = 0, hwptr_done = subs->hwptr_done; | 65 | int i, lens = 0, hwptr_done = subs->hwptr_done; |
66 | usX2Ydev_t *usX2Y = subs->usX2Y; | 66 | struct usX2Ydev *usX2Y = subs->usX2Y; |
67 | if (0 > usX2Y->hwdep_pcm_shm->capture_iso_start) { //FIXME | 67 | if (0 > usX2Y->hwdep_pcm_shm->capture_iso_start) { //FIXME |
68 | int head = usX2Y->hwdep_pcm_shm->captured_iso_head + 1; | 68 | int head = usX2Y->hwdep_pcm_shm->captured_iso_head + 1; |
69 | if (head >= ARRAY_SIZE(usX2Y->hwdep_pcm_shm->captured_iso)) | 69 | if (head >= ARRAY_SIZE(usX2Y->hwdep_pcm_shm->captured_iso)) |
@@ -90,7 +90,8 @@ static int usX2Y_usbpcm_urb_capt_retire(snd_usX2Y_substream_t *subs) | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static inline int usX2Y_iso_frames_per_buffer(snd_pcm_runtime_t *runtime, usX2Ydev_t * usX2Y) | 93 | static inline int usX2Y_iso_frames_per_buffer(struct snd_pcm_runtime *runtime, |
94 | struct usX2Ydev * usX2Y) | ||
94 | { | 95 | { |
95 | return (runtime->buffer_size * 1000) / usX2Y->rate + 1; //FIXME: so far only correct period_size == 2^x ? | 96 | return (runtime->buffer_size * 1000) / usX2Y->rate + 1; //FIXME: so far only correct period_size == 2^x ? |
96 | } | 97 | } |
@@ -105,13 +106,13 @@ static inline int usX2Y_iso_frames_per_buffer(snd_pcm_runtime_t *runtime, usX2Yd | |||
105 | * it directly from the buffer. thus the data is once copied to | 106 | * it directly from the buffer. thus the data is once copied to |
106 | * a temporary buffer and urb points to that. | 107 | * a temporary buffer and urb points to that. |
107 | */ | 108 | */ |
108 | static int usX2Y_hwdep_urb_play_prepare(snd_usX2Y_substream_t *subs, | 109 | static int usX2Y_hwdep_urb_play_prepare(struct snd_usX2Y_substream *subs, |
109 | struct urb *urb) | 110 | struct urb *urb) |
110 | { | 111 | { |
111 | int count, counts, pack; | 112 | int count, counts, pack; |
112 | usX2Ydev_t *usX2Y = subs->usX2Y; | 113 | struct usX2Ydev *usX2Y = subs->usX2Y; |
113 | struct snd_usX2Y_hwdep_pcm_shm *shm = usX2Y->hwdep_pcm_shm; | 114 | struct snd_usX2Y_hwdep_pcm_shm *shm = usX2Y->hwdep_pcm_shm; |
114 | snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; | 115 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
115 | 116 | ||
116 | if (0 > shm->playback_iso_start) { | 117 | if (0 > shm->playback_iso_start) { |
117 | shm->playback_iso_start = shm->captured_iso_head - | 118 | shm->playback_iso_start = shm->captured_iso_head - |
@@ -144,13 +145,14 @@ static int usX2Y_hwdep_urb_play_prepare(snd_usX2Y_substream_t *subs, | |||
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | static inline void usX2Y_usbpcm_urb_capt_iso_advance(snd_usX2Y_substream_t *subs, struct urb *urb) | 148 | static inline void usX2Y_usbpcm_urb_capt_iso_advance(struct snd_usX2Y_substream *subs, |
149 | struct urb *urb) | ||
148 | { | 150 | { |
149 | int pack; | 151 | int pack; |
150 | for (pack = 0; pack < nr_of_packs(); ++pack) { | 152 | for (pack = 0; pack < nr_of_packs(); ++pack) { |
151 | struct usb_iso_packet_descriptor *desc = urb->iso_frame_desc + pack; | 153 | struct usb_iso_packet_descriptor *desc = urb->iso_frame_desc + pack; |
152 | if (NULL != subs) { | 154 | if (NULL != subs) { |
153 | snd_usX2Y_hwdep_pcm_shm_t *shm = subs->usX2Y->hwdep_pcm_shm; | 155 | struct snd_usX2Y_hwdep_pcm_shm *shm = subs->usX2Y->hwdep_pcm_shm; |
154 | int head = shm->captured_iso_head + 1; | 156 | int head = shm->captured_iso_head + 1; |
155 | if (head >= ARRAY_SIZE(shm->captured_iso)) | 157 | if (head >= ARRAY_SIZE(shm->captured_iso)) |
156 | head = 0; | 158 | head = 0; |
@@ -166,9 +168,10 @@ static inline void usX2Y_usbpcm_urb_capt_iso_advance(snd_usX2Y_substream_t *subs | |||
166 | } | 168 | } |
167 | } | 169 | } |
168 | 170 | ||
169 | static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, | 171 | static inline int usX2Y_usbpcm_usbframe_complete(struct snd_usX2Y_substream *capsubs, |
170 | snd_usX2Y_substream_t *capsubs2, | 172 | struct snd_usX2Y_substream *capsubs2, |
171 | snd_usX2Y_substream_t *playbacksubs, int frame) | 173 | struct snd_usX2Y_substream *playbacksubs, |
174 | int frame) | ||
172 | { | 175 | { |
173 | int err, state; | 176 | int err, state; |
174 | struct urb *urb = playbacksubs->completed_urb; | 177 | struct urb *urb = playbacksubs->completed_urb; |
@@ -177,10 +180,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, | |||
177 | if (NULL != urb) { | 180 | if (NULL != urb) { |
178 | if (state == state_RUNNING) | 181 | if (state == state_RUNNING) |
179 | usX2Y_urb_play_retire(playbacksubs, urb); | 182 | usX2Y_urb_play_retire(playbacksubs, urb); |
180 | else | 183 | else if (state >= state_PRERUNNING) |
181 | if (state >= state_PRERUNNING) { | 184 | atomic_inc(&playbacksubs->state); |
182 | atomic_inc(&playbacksubs->state); | ||
183 | } | ||
184 | } else { | 185 | } else { |
185 | switch (state) { | 186 | switch (state) { |
186 | case state_STARTING1: | 187 | case state_STARTING1: |
@@ -207,10 +208,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, | |||
207 | if (state == state_RUNNING) { | 208 | if (state == state_RUNNING) { |
208 | if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs))) | 209 | if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs))) |
209 | return err; | 210 | return err; |
210 | } else { | 211 | } else if (state >= state_PRERUNNING) |
211 | if (state >= state_PRERUNNING) | 212 | atomic_inc(&capsubs->state); |
212 | atomic_inc(&capsubs->state); | ||
213 | } | ||
214 | usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); | 213 | usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); |
215 | if (NULL != capsubs2) | 214 | if (NULL != capsubs2) |
216 | usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); | 215 | usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); |
@@ -229,12 +228,15 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, | |||
229 | 228 | ||
230 | static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) | 229 | static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) |
231 | { | 230 | { |
232 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 231 | struct snd_usX2Y_substream *subs = urb->context; |
233 | usX2Ydev_t *usX2Y = subs->usX2Y; | 232 | struct usX2Ydev *usX2Y = subs->usX2Y; |
234 | snd_usX2Y_substream_t *capsubs, *capsubs2, *playbacksubs; | 233 | struct snd_usX2Y_substream *capsubs, *capsubs2, *playbacksubs; |
235 | 234 | ||
236 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { | 235 | if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { |
237 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", usb_get_current_frame_number(usX2Y->chip.dev), subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", urb->status, urb->start_frame); | 236 | snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", |
237 | usb_get_current_frame_number(usX2Y->chip.dev), | ||
238 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | ||
239 | urb->status, urb->start_frame); | ||
238 | return; | 240 | return; |
239 | } | 241 | } |
240 | if (unlikely(urb->status)) { | 242 | if (unlikely(urb->status)) { |
@@ -268,7 +270,7 @@ static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) | |||
268 | } | 270 | } |
269 | 271 | ||
270 | 272 | ||
271 | static void usX2Y_hwdep_urb_release(struct urb** urb) | 273 | static void usX2Y_hwdep_urb_release(struct urb **urb) |
272 | { | 274 | { |
273 | usb_kill_urb(*urb); | 275 | usb_kill_urb(*urb); |
274 | usb_free_urb(*urb); | 276 | usb_free_urb(*urb); |
@@ -278,7 +280,7 @@ static void usX2Y_hwdep_urb_release(struct urb** urb) | |||
278 | /* | 280 | /* |
279 | * release a substream | 281 | * release a substream |
280 | */ | 282 | */ |
281 | static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs) | 283 | static void usX2Y_usbpcm_urbs_release(struct snd_usX2Y_substream *subs) |
282 | { | 284 | { |
283 | int i; | 285 | int i; |
284 | snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint); | 286 | snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint); |
@@ -286,7 +288,7 @@ static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs) | |||
286 | usX2Y_hwdep_urb_release(subs->urb + i); | 288 | usX2Y_hwdep_urb_release(subs->urb + i); |
287 | } | 289 | } |
288 | 290 | ||
289 | static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y) | 291 | static void usX2Y_usbpcm_subs_startup_finish(struct usX2Ydev * usX2Y) |
290 | { | 292 | { |
291 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete); | 293 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete); |
292 | usX2Y->prepare_subs = NULL; | 294 | usX2Y->prepare_subs = NULL; |
@@ -294,14 +296,14 @@ static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y) | |||
294 | 296 | ||
295 | static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) | 297 | static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) |
296 | { | 298 | { |
297 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; | 299 | struct snd_usX2Y_substream *subs = urb->context; |
298 | usX2Ydev_t *usX2Y = subs->usX2Y; | 300 | struct usX2Ydev *usX2Y = subs->usX2Y; |
299 | snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; | 301 | struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; |
300 | if (NULL != prepare_subs && | 302 | if (NULL != prepare_subs && |
301 | urb->start_frame == prepare_subs->urb[0]->start_frame) { | 303 | urb->start_frame == prepare_subs->urb[0]->start_frame) { |
302 | atomic_inc(&prepare_subs->state); | 304 | atomic_inc(&prepare_subs->state); |
303 | if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) { | 305 | if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) { |
304 | snd_usX2Y_substream_t *cap_subs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; | 306 | struct snd_usX2Y_substream *cap_subs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
305 | if (cap_subs2 != NULL) | 307 | if (cap_subs2 != NULL) |
306 | atomic_inc(&cap_subs2->state); | 308 | atomic_inc(&cap_subs2->state); |
307 | } | 309 | } |
@@ -315,7 +317,7 @@ static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) | |||
315 | /* | 317 | /* |
316 | * initialize a substream's urbs | 318 | * initialize a substream's urbs |
317 | */ | 319 | */ |
318 | static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) | 320 | static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs) |
319 | { | 321 | { |
320 | int i; | 322 | int i; |
321 | unsigned int pipe; | 323 | unsigned int pipe; |
@@ -330,7 +332,7 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) | |||
330 | 332 | ||
331 | /* allocate and initialize data urbs */ | 333 | /* allocate and initialize data urbs */ |
332 | for (i = 0; i < NRURBS; i++) { | 334 | for (i = 0; i < NRURBS; i++) { |
333 | struct urb** purb = subs->urb + i; | 335 | struct urb **purb = subs->urb + i; |
334 | if (*purb) { | 336 | if (*purb) { |
335 | usb_kill_urb(*purb); | 337 | usb_kill_urb(*purb); |
336 | continue; | 338 | continue; |
@@ -359,16 +361,16 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) | |||
359 | /* | 361 | /* |
360 | * free the buffer | 362 | * free the buffer |
361 | */ | 363 | */ |
362 | static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) | 364 | static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream) |
363 | { | 365 | { |
364 | snd_pcm_runtime_t *runtime = substream->runtime; | 366 | struct snd_pcm_runtime *runtime = substream->runtime; |
365 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data, | 367 | struct snd_usX2Y_substream *subs = runtime->private_data, |
366 | *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; | 368 | *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; |
367 | down(&subs->usX2Y->prepare_mutex); | 369 | down(&subs->usX2Y->prepare_mutex); |
368 | snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream); | 370 | snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream); |
369 | 371 | ||
370 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { | 372 | if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { |
371 | snd_usX2Y_substream_t *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 373 | struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
372 | atomic_set(&subs->state, state_STOPPED); | 374 | atomic_set(&subs->state, state_STOPPED); |
373 | usX2Y_usbpcm_urbs_release(subs); | 375 | usX2Y_usbpcm_urbs_release(subs); |
374 | if (!cap_subs->pcm_substream || | 376 | if (!cap_subs->pcm_substream || |
@@ -383,7 +385,7 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) | |||
383 | usX2Y_usbpcm_urbs_release(cap_subs2); | 385 | usX2Y_usbpcm_urbs_release(cap_subs2); |
384 | } | 386 | } |
385 | } else { | 387 | } else { |
386 | snd_usX2Y_substream_t *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; | 388 | struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; |
387 | if (atomic_read(&playback_subs->state) < state_PREPARED) { | 389 | if (atomic_read(&playback_subs->state) < state_PREPARED) { |
388 | atomic_set(&subs->state, state_STOPPED); | 390 | atomic_set(&subs->state, state_STOPPED); |
389 | if (NULL != cap_subs2) | 391 | if (NULL != cap_subs2) |
@@ -397,20 +399,20 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) | |||
397 | return snd_pcm_lib_free_pages(substream); | 399 | return snd_pcm_lib_free_pages(substream); |
398 | } | 400 | } |
399 | 401 | ||
400 | static void usX2Y_usbpcm_subs_startup(snd_usX2Y_substream_t *subs) | 402 | static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs) |
401 | { | 403 | { |
402 | usX2Ydev_t * usX2Y = subs->usX2Y; | 404 | struct usX2Ydev * usX2Y = subs->usX2Y; |
403 | usX2Y->prepare_subs = subs; | 405 | usX2Y->prepare_subs = subs; |
404 | subs->urb[0]->start_frame = -1; | 406 | subs->urb[0]->start_frame = -1; |
405 | smp_wmb(); // Make shure above modifications are seen by i_usX2Y_subs_startup() | 407 | smp_wmb(); // Make shure above modifications are seen by i_usX2Y_subs_startup() |
406 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup); | 408 | usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup); |
407 | } | 409 | } |
408 | 410 | ||
409 | static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) | 411 | static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs) |
410 | { | 412 | { |
411 | int p, u, err, | 413 | int p, u, err, |
412 | stream = subs->pcm_substream->stream; | 414 | stream = subs->pcm_substream->stream; |
413 | usX2Ydev_t *usX2Y = subs->usX2Y; | 415 | struct usX2Ydev *usX2Y = subs->usX2Y; |
414 | 416 | ||
415 | if (SNDRV_PCM_STREAM_CAPTURE == stream) { | 417 | if (SNDRV_PCM_STREAM_CAPTURE == stream) { |
416 | usX2Y->hwdep_pcm_shm->captured_iso_head = -1; | 418 | usX2Y->hwdep_pcm_shm->captured_iso_head = -1; |
@@ -418,7 +420,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) | |||
418 | } | 420 | } |
419 | 421 | ||
420 | for (p = 0; 3 >= (stream + p); p += 2) { | 422 | for (p = 0; 3 >= (stream + p); p += 2) { |
421 | snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; | 423 | struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; |
422 | if (subs != NULL) { | 424 | if (subs != NULL) { |
423 | if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0) | 425 | if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0) |
424 | return err; | 426 | return err; |
@@ -427,7 +429,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) | |||
427 | } | 429 | } |
428 | 430 | ||
429 | for (p = 0; p < 4; p++) { | 431 | for (p = 0; p < 4; p++) { |
430 | snd_usX2Y_substream_t *subs = usX2Y->subs[p]; | 432 | struct snd_usX2Y_substream *subs = usX2Y->subs[p]; |
431 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) | 433 | if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) |
432 | goto start; | 434 | goto start; |
433 | } | 435 | } |
@@ -437,7 +439,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) | |||
437 | usX2Y_usbpcm_subs_startup(subs); | 439 | usX2Y_usbpcm_subs_startup(subs); |
438 | for (u = 0; u < NRURBS; u++) { | 440 | for (u = 0; u < NRURBS; u++) { |
439 | for (p = 0; 3 >= (stream + p); p += 2) { | 441 | for (p = 0; 3 >= (stream + p); p += 2) { |
440 | snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; | 442 | struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; |
441 | if (subs != NULL) { | 443 | if (subs != NULL) { |
442 | struct urb *urb = subs->urb[u]; | 444 | struct urb *urb = subs->urb[u]; |
443 | if (usb_pipein(urb->pipe)) { | 445 | if (usb_pipein(urb->pipe)) { |
@@ -486,19 +488,19 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) | |||
486 | * | 488 | * |
487 | * set format and initialize urbs | 489 | * set format and initialize urbs |
488 | */ | 490 | */ |
489 | static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) | 491 | static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream) |
490 | { | 492 | { |
491 | snd_pcm_runtime_t *runtime = substream->runtime; | 493 | struct snd_pcm_runtime *runtime = substream->runtime; |
492 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 494 | struct snd_usX2Y_substream *subs = runtime->private_data; |
493 | usX2Ydev_t *usX2Y = subs->usX2Y; | 495 | struct usX2Ydev *usX2Y = subs->usX2Y; |
494 | snd_usX2Y_substream_t *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; | 496 | struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; |
495 | int err = 0; | 497 | int err = 0; |
496 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); | 498 | snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); |
497 | 499 | ||
498 | if (NULL == usX2Y->hwdep_pcm_shm) { | 500 | if (NULL == usX2Y->hwdep_pcm_shm) { |
499 | if (NULL == (usX2Y->hwdep_pcm_shm = snd_malloc_pages(sizeof(snd_usX2Y_hwdep_pcm_shm_t), GFP_KERNEL))) | 501 | if (NULL == (usX2Y->hwdep_pcm_shm = snd_malloc_pages(sizeof(struct snd_usX2Y_hwdep_pcm_shm), GFP_KERNEL))) |
500 | return -ENOMEM; | 502 | return -ENOMEM; |
501 | memset(usX2Y->hwdep_pcm_shm, 0, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); | 503 | memset(usX2Y->hwdep_pcm_shm, 0, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
502 | } | 504 | } |
503 | 505 | ||
504 | down(&usX2Y->prepare_mutex); | 506 | down(&usX2Y->prepare_mutex); |
@@ -512,7 +514,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) | |||
512 | if (usX2Y->rate != runtime->rate) | 514 | if (usX2Y->rate != runtime->rate) |
513 | if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0) | 515 | if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0) |
514 | goto up_prepare_mutex; | 516 | goto up_prepare_mutex; |
515 | snd_printdd("starting capture pipe for %s\n", subs == capsubs ? "self" : "playpipe"); | 517 | snd_printdd("starting capture pipe for %s\n", subs == capsubs ? |
518 | "self" : "playpipe"); | ||
516 | if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs))) | 519 | if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs))) |
517 | goto up_prepare_mutex; | 520 | goto up_prepare_mutex; |
518 | } | 521 | } |
@@ -520,8 +523,12 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) | |||
520 | if (subs != capsubs) { | 523 | if (subs != capsubs) { |
521 | usX2Y->hwdep_pcm_shm->playback_iso_start = -1; | 524 | usX2Y->hwdep_pcm_shm->playback_iso_start = -1; |
522 | if (atomic_read(&subs->state) < state_PREPARED) { | 525 | if (atomic_read(&subs->state) < state_PREPARED) { |
523 | while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) { | 526 | while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > |
524 | snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); | 527 | usX2Y->hwdep_pcm_shm->captured_iso_frames) { |
528 | snd_printdd("Wait: iso_frames_per_buffer=%i," | ||
529 | "captured_iso_frames=%i\n", | ||
530 | usX2Y_iso_frames_per_buffer(runtime, usX2Y), | ||
531 | usX2Y->hwdep_pcm_shm->captured_iso_frames); | ||
525 | if (msleep_interruptible(10)) { | 532 | if (msleep_interruptible(10)) { |
526 | err = -ERESTARTSYS; | 533 | err = -ERESTARTSYS; |
527 | goto up_prepare_mutex; | 534 | goto up_prepare_mutex; |
@@ -530,7 +537,9 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) | |||
530 | if (0 > (err = usX2Y_usbpcm_urbs_start(subs))) | 537 | if (0 > (err = usX2Y_usbpcm_urbs_start(subs))) |
531 | goto up_prepare_mutex; | 538 | goto up_prepare_mutex; |
532 | } | 539 | } |
533 | snd_printd("Ready: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); | 540 | snd_printdd("Ready: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", |
541 | usX2Y_iso_frames_per_buffer(runtime, usX2Y), | ||
542 | usX2Y->hwdep_pcm_shm->captured_iso_frames); | ||
534 | } else | 543 | } else |
535 | usX2Y->hwdep_pcm_shm->capture_iso_start = -1; | 544 | usX2Y->hwdep_pcm_shm->capture_iso_start = -1; |
536 | 545 | ||
@@ -539,7 +548,7 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) | |||
539 | return err; | 548 | return err; |
540 | } | 549 | } |
541 | 550 | ||
542 | static snd_pcm_hardware_t snd_usX2Y_4c = | 551 | static struct snd_pcm_hardware snd_usX2Y_4c = |
543 | { | 552 | { |
544 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 553 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
545 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 554 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
@@ -560,11 +569,11 @@ static snd_pcm_hardware_t snd_usX2Y_4c = | |||
560 | 569 | ||
561 | 570 | ||
562 | 571 | ||
563 | static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream) | 572 | static int snd_usX2Y_usbpcm_open(struct snd_pcm_substream *substream) |
564 | { | 573 | { |
565 | snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) | 574 | struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) |
566 | snd_pcm_substream_chip(substream))[substream->stream]; | 575 | snd_pcm_substream_chip(substream))[substream->stream]; |
567 | snd_pcm_runtime_t *runtime = substream->runtime; | 576 | struct snd_pcm_runtime *runtime = substream->runtime; |
568 | 577 | ||
569 | if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) | 578 | if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) |
570 | return -EBUSY; | 579 | return -EBUSY; |
@@ -578,18 +587,17 @@ static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream) | |||
578 | } | 587 | } |
579 | 588 | ||
580 | 589 | ||
581 | static int snd_usX2Y_usbpcm_close(snd_pcm_substream_t *substream) | 590 | static int snd_usX2Y_usbpcm_close(struct snd_pcm_substream *substream) |
582 | { | 591 | { |
583 | snd_pcm_runtime_t *runtime = substream->runtime; | 592 | struct snd_pcm_runtime *runtime = substream->runtime; |
584 | snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; | 593 | struct snd_usX2Y_substream *subs = runtime->private_data; |
585 | int err = 0; | 594 | |
586 | snd_printd("\n"); | ||
587 | subs->pcm_substream = NULL; | 595 | subs->pcm_substream = NULL; |
588 | return err; | 596 | return 0; |
589 | } | 597 | } |
590 | 598 | ||
591 | 599 | ||
592 | static snd_pcm_ops_t snd_usX2Y_usbpcm_ops = | 600 | static struct snd_pcm_ops snd_usX2Y_usbpcm_ops = |
593 | { | 601 | { |
594 | .open = snd_usX2Y_usbpcm_open, | 602 | .open = snd_usX2Y_usbpcm_open, |
595 | .close = snd_usX2Y_usbpcm_close, | 603 | .close = snd_usX2Y_usbpcm_close, |
@@ -602,11 +610,11 @@ static snd_pcm_ops_t snd_usX2Y_usbpcm_ops = | |||
602 | }; | 610 | }; |
603 | 611 | ||
604 | 612 | ||
605 | static int usX2Y_pcms_lock_check(snd_card_t *card) | 613 | static int usX2Y_pcms_lock_check(struct snd_card *card) |
606 | { | 614 | { |
607 | struct list_head *list; | 615 | struct list_head *list; |
608 | snd_device_t *dev; | 616 | struct snd_device *dev; |
609 | snd_pcm_t *pcm; | 617 | struct snd_pcm *pcm; |
610 | int err = 0; | 618 | int err = 0; |
611 | list_for_each(list, &card->devices) { | 619 | list_for_each(list, &card->devices) { |
612 | dev = snd_device(list); | 620 | dev = snd_device(list); |
@@ -622,7 +630,7 @@ static int usX2Y_pcms_lock_check(snd_card_t *card) | |||
622 | continue; | 630 | continue; |
623 | pcm = dev->device_data; | 631 | pcm = dev->device_data; |
624 | for (s = 0; s < 2; ++s) { | 632 | for (s = 0; s < 2; ++s) { |
625 | snd_pcm_substream_t *substream; | 633 | struct snd_pcm_substream *substream; |
626 | substream = pcm->streams[s].substream; | 634 | substream = pcm->streams[s].substream; |
627 | if (substream && substream->ffile != NULL) | 635 | if (substream && substream->ffile != NULL) |
628 | err = -EBUSY; | 636 | err = -EBUSY; |
@@ -632,11 +640,11 @@ static int usX2Y_pcms_lock_check(snd_card_t *card) | |||
632 | } | 640 | } |
633 | 641 | ||
634 | 642 | ||
635 | static void usX2Y_pcms_unlock(snd_card_t *card) | 643 | static void usX2Y_pcms_unlock(struct snd_card *card) |
636 | { | 644 | { |
637 | struct list_head *list; | 645 | struct list_head *list; |
638 | snd_device_t *dev; | 646 | struct snd_device *dev; |
639 | snd_pcm_t *pcm; | 647 | struct snd_pcm *pcm; |
640 | list_for_each(list, &card->devices) { | 648 | list_for_each(list, &card->devices) { |
641 | dev = snd_device(list); | 649 | dev = snd_device(list); |
642 | if (dev->type != SNDRV_DEV_PCM) | 650 | if (dev->type != SNDRV_DEV_PCM) |
@@ -647,10 +655,10 @@ static void usX2Y_pcms_unlock(snd_card_t *card) | |||
647 | } | 655 | } |
648 | 656 | ||
649 | 657 | ||
650 | static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file) | 658 | static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file) |
651 | { | 659 | { |
652 | // we need to be the first | 660 | // we need to be the first |
653 | snd_card_t *card = hw->card; | 661 | struct snd_card *card = hw->card; |
654 | int err = usX2Y_pcms_lock_check(card); | 662 | int err = usX2Y_pcms_lock_check(card); |
655 | if (0 == err) | 663 | if (0 == err) |
656 | usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; | 664 | usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
@@ -659,9 +667,9 @@ static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file) | |||
659 | } | 667 | } |
660 | 668 | ||
661 | 669 | ||
662 | static int snd_usX2Y_hwdep_pcm_release(snd_hwdep_t *hw, struct file *file) | 670 | static int snd_usX2Y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file) |
663 | { | 671 | { |
664 | snd_card_t *card = hw->card; | 672 | struct snd_card *card = hw->card; |
665 | int err = usX2Y_pcms_lock_check(card); | 673 | int err = usX2Y_pcms_lock_check(card); |
666 | if (0 == err) | 674 | if (0 == err) |
667 | usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; | 675 | usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; |
@@ -689,7 +697,7 @@ static struct page * snd_usX2Y_hwdep_pcm_vm_nopage(struct vm_area_struct *area, | |||
689 | offset = area->vm_pgoff << PAGE_SHIFT; | 697 | offset = area->vm_pgoff << PAGE_SHIFT; |
690 | offset += address - area->vm_start; | 698 | offset += address - area->vm_start; |
691 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); | 699 | snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); |
692 | vaddr = (char*)((usX2Ydev_t*)area->vm_private_data)->hwdep_pcm_shm + offset; | 700 | vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->hwdep_pcm_shm + offset; |
693 | page = virt_to_page(vaddr); | 701 | page = virt_to_page(vaddr); |
694 | get_page(page); | 702 | get_page(page); |
695 | 703 | ||
@@ -707,17 +715,17 @@ static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = { | |||
707 | }; | 715 | }; |
708 | 716 | ||
709 | 717 | ||
710 | static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) | 718 | static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) |
711 | { | 719 | { |
712 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); | 720 | unsigned long size = (unsigned long)(area->vm_end - area->vm_start); |
713 | usX2Ydev_t *usX2Y = (usX2Ydev_t*)hw->private_data; | 721 | struct usX2Ydev *usX2Y = hw->private_data; |
714 | 722 | ||
715 | if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) | 723 | if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT)) |
716 | return -EBUSY; | 724 | return -EBUSY; |
717 | 725 | ||
718 | /* if userspace tries to mmap beyond end of our buffer, fail */ | 726 | /* if userspace tries to mmap beyond end of our buffer, fail */ |
719 | if (size > PAGE_ALIGN(sizeof(snd_usX2Y_hwdep_pcm_shm_t))) { | 727 | if (size > PAGE_ALIGN(sizeof(struct snd_usX2Y_hwdep_pcm_shm))) { |
720 | snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(snd_usX2Y_hwdep_pcm_shm_t)); | 728 | snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
721 | return -EINVAL; | 729 | return -EINVAL; |
722 | } | 730 | } |
723 | 731 | ||
@@ -726,39 +734,31 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct | |||
726 | } | 734 | } |
727 | area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; | 735 | area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; |
728 | area->vm_flags |= VM_RESERVED; | 736 | area->vm_flags |= VM_RESERVED; |
729 | snd_printd("vm_flags=0x%lX\n", area->vm_flags); | ||
730 | area->vm_private_data = hw->private_data; | 737 | area->vm_private_data = hw->private_data; |
731 | return 0; | 738 | return 0; |
732 | } | 739 | } |
733 | 740 | ||
734 | 741 | ||
735 | static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) | 742 | static void snd_usX2Y_hwdep_pcm_private_free(struct snd_hwdep *hwdep) |
736 | { | 743 | { |
737 | usX2Ydev_t *usX2Y = (usX2Ydev_t *)hwdep->private_data; | 744 | struct usX2Ydev *usX2Y = hwdep->private_data; |
738 | if (NULL != usX2Y->hwdep_pcm_shm) | 745 | if (NULL != usX2Y->hwdep_pcm_shm) |
739 | snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); | 746 | snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); |
740 | } | 747 | } |
741 | 748 | ||
742 | 749 | ||
743 | static void snd_usX2Y_usbpcm_private_free(snd_pcm_t *pcm) | 750 | int usX2Y_hwdep_pcm_new(struct snd_card *card) |
744 | { | ||
745 | snd_pcm_lib_preallocate_free_for_all(pcm); | ||
746 | } | ||
747 | |||
748 | |||
749 | int usX2Y_hwdep_pcm_new(snd_card_t* card) | ||
750 | { | 751 | { |
751 | int err; | 752 | int err; |
752 | snd_hwdep_t *hw; | 753 | struct snd_hwdep *hw; |
753 | snd_pcm_t *pcm; | 754 | struct snd_pcm *pcm; |
754 | struct usb_device *dev = usX2Y(card)->chip.dev; | 755 | struct usb_device *dev = usX2Y(card)->chip.dev; |
755 | if (1 != nr_of_packs()) | 756 | if (1 != nr_of_packs()) |
756 | return 0; | 757 | return 0; |
757 | 758 | ||
758 | if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0) { | 759 | if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0) |
759 | snd_printd("\n"); | ||
760 | return err; | 760 | return err; |
761 | } | 761 | |
762 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM; | 762 | hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM; |
763 | hw->private_data = usX2Y(card); | 763 | hw->private_data = usX2Y(card); |
764 | hw->private_free = snd_usX2Y_hwdep_pcm_private_free; | 764 | hw->private_free = snd_usX2Y_hwdep_pcm_private_free; |
@@ -776,7 +776,6 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) | |||
776 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usX2Y_usbpcm_ops); | 776 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usX2Y_usbpcm_ops); |
777 | 777 | ||
778 | pcm->private_data = usX2Y(card)->subs; | 778 | pcm->private_data = usX2Y(card)->subs; |
779 | pcm->private_free = snd_usX2Y_usbpcm_private_free; | ||
780 | pcm->info_flags = 0; | 779 | pcm->info_flags = 0; |
781 | 780 | ||
782 | sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); | 781 | sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); |
@@ -788,7 +787,6 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) | |||
788 | SNDRV_DMA_TYPE_CONTINUOUS, | 787 | SNDRV_DMA_TYPE_CONTINUOUS, |
789 | snd_dma_continuous_data(GFP_KERNEL), | 788 | snd_dma_continuous_data(GFP_KERNEL), |
790 | 64*1024, 128*1024))) { | 789 | 64*1024, 128*1024))) { |
791 | snd_usX2Y_usbpcm_private_free(pcm); | ||
792 | return err; | 790 | return err; |
793 | } | 791 | } |
794 | 792 | ||
@@ -798,7 +796,7 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) | |||
798 | 796 | ||
799 | #else | 797 | #else |
800 | 798 | ||
801 | int usX2Y_hwdep_pcm_new(snd_card_t* card) | 799 | int usX2Y_hwdep_pcm_new(struct snd_card *card) |
802 | { | 800 | { |
803 | return 0; | 801 | return 0; |
804 | } | 802 | } |
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.h b/sound/usb/usx2y/usx2yhwdeppcm.h index d68f0cbdbbe2..c3382fdc386b 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.h +++ b/sound/usb/usx2y/usx2yhwdeppcm.h | |||
@@ -18,4 +18,3 @@ struct snd_usX2Y_hwdep_pcm_shm { | |||
18 | volatile unsigned captured_iso_frames; | 18 | volatile unsigned captured_iso_frames; |
19 | int capture_iso_start; | 19 | int capture_iso_start; |
20 | }; | 20 | }; |
21 | typedef struct snd_usX2Y_hwdep_pcm_shm snd_usX2Y_hwdep_pcm_shm_t; | ||