aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c62
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.h2
-rw-r--r--sound/usb/usx2y/usbus428ctldefs.h36
-rw-r--r--sound/usb/usx2y/usbusx2y.c40
-rw-r--r--sound/usb/usx2y/usbusx2y.h45
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c209
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.c171
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.h1
8 files changed, 299 insertions, 267 deletions
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index fc0d534ec7fc..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
34int usX2Y_hwdep_pcm_new(snd_card_t* card); 34int usX2Y_hwdep_pcm_new(struct snd_card *card);
35 35
36 36
37static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) 37static 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,10 +64,10 @@ static struct vm_operations_struct us428ctls_vm_ops = {
64 .nopage = snd_us428ctls_vm_nopage, 64 .nopage = snd_us428ctls_vm_nopage,
65}; 65};
66 66
67static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) 67static 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 = 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.
@@ -75,16 +75,16 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are
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_ALIGN(sizeof(us428ctls_sharedmem_t))) { 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
96static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_table *wait) 96static 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 = 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,24 +110,25 @@ static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_
110} 110}
111 111
112 112
113static int snd_usX2Y_hwdep_open(snd_hwdep_t *hw, struct file *file) 113static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file)
114{ 114{
115 return 0; 115 return 0;
116} 116}
117 117
118static int snd_usX2Y_hwdep_release(snd_hwdep_t *hw, struct file *file) 118static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file)
119{ 119{
120 return 0; 120 return 0;
121} 121}
122 122
123static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) 123static 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 };
130 usX2Ydev_t *us428 = hw->private_data; 131 struct usX2Ydev *us428 = hw->private_data;
131 int id = -1; 132 int id = -1;
132 133
133 switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { 134 switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) {
@@ -145,35 +146,35 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i
145 return -ENODEV; 146 return -ENODEV;
146 strcpy(info->id, type_ids[id]); 147 strcpy(info->id, type_ids[id]);
147 info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code 148 info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code
148 if (us428->chip_status & USX2Y_STAT_CHIP_INIT) 149 if (us428->chip_status & USX2Y_STAT_CHIP_INIT)
149 info->chip_ready = 1; 150 info->chip_ready = 1;
150 info->version = USX2Y_DRIVER_VERSION; 151 info->version = USX2Y_DRIVER_VERSION;
151 return 0; 152 return 0;
152} 153}
153 154
154 155
155static int usX2Y_create_usbmidi(snd_card_t* card ) 156static int usX2Y_create_usbmidi(struct snd_card *card)
156{ 157{
157 static snd_usb_midi_endpoint_info_t quirk_data_1 = { 158 static struct snd_usb_midi_endpoint_info quirk_data_1 = {
158 .out_ep =0x06, 159 .out_ep = 0x06,
159 .in_ep = 0x06, 160 .in_ep = 0x06,
160 .out_cables = 0x001, 161 .out_cables = 0x001,
161 .in_cables = 0x001 162 .in_cables = 0x001
162 }; 163 };
163 static snd_usb_audio_quirk_t quirk_1 = { 164 static struct snd_usb_audio_quirk quirk_1 = {
164 .vendor_name = "TASCAM", 165 .vendor_name = "TASCAM",
165 .product_name = NAME_ALLCAPS, 166 .product_name = NAME_ALLCAPS,
166 .ifnum = 0, 167 .ifnum = 0,
167 .type = QUIRK_MIDI_FIXED_ENDPOINT, 168 .type = QUIRK_MIDI_FIXED_ENDPOINT,
168 .data = &quirk_data_1 169 .data = &quirk_data_1
169 }; 170 };
170 static snd_usb_midi_endpoint_info_t quirk_data_2 = { 171 static struct snd_usb_midi_endpoint_info quirk_data_2 = {
171 .out_ep =0x06, 172 .out_ep = 0x06,
172 .in_ep = 0x06, 173 .in_ep = 0x06,
173 .out_cables = 0x003, 174 .out_cables = 0x003,
174 .in_cables = 0x003 175 .in_cables = 0x003
175 }; 176 };
176 static snd_usb_audio_quirk_t quirk_2 = { 177 static struct snd_usb_audio_quirk quirk_2 = {
177 .vendor_name = "TASCAM", 178 .vendor_name = "TASCAM",
178 .product_name = "US428", 179 .product_name = "US428",
179 .ifnum = 0, 180 .ifnum = 0,
@@ -182,13 +183,15 @@ static int usX2Y_create_usbmidi(snd_card_t* card )
182 }; 183 };
183 struct usb_device *dev = usX2Y(card)->chip.dev; 184 struct usb_device *dev = usX2Y(card)->chip.dev;
184 struct usb_interface *iface = usb_ifnum_to_if(dev, 0); 185 struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
185 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;
186 189
187 snd_printdd("usX2Y_create_usbmidi \n"); 190 snd_printdd("usX2Y_create_usbmidi \n");
188 return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); 191 return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk);
189} 192}
190 193
191static int usX2Y_create_alsa_devices(snd_card_t* card) 194static int usX2Y_create_alsa_devices(struct snd_card *card)
192{ 195{
193 int err; 196 int err;
194 197
@@ -208,9 +211,10 @@ static int usX2Y_create_alsa_devices(snd_card_t* card)
208 return err; 211 return err;
209} 212}
210 213
211static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) 214static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
215 struct snd_hwdep_dsp_image *dsp)
212{ 216{
213 usX2Ydev_t *priv = hw->private_data; 217 struct usX2Ydev *priv = hw->private_data;
214 int lret, err = -EINVAL; 218 int lret, err = -EINVAL;
215 snd_printdd( "dsp_load %s\n", dsp->name); 219 snd_printdd( "dsp_load %s\n", dsp->name);
216 220
@@ -257,10 +261,10 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp)
257} 261}
258 262
259 263
260int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device) 264int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device)
261{ 265{
262 int err; 266 int err;
263 snd_hwdep_t *hw; 267 struct snd_hwdep *hw;
264 268
265 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)
266 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
4int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device); 4int 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
54struct us428_ctls{ 54struct 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
66typedef struct us428_ctls us428_ctls_t; 66struct us428_setByte {
67
68typedef struct us428_setByte{
69 unsigned char Offset, 67 unsigned char Offset,
70 Value; 68 Value;
71}us428_setByte_t; 69};
72 70
73enum { 71enum {
74 eLT_Volume = 0, 72 eLT_Volume = 0,
75 eLT_Light 73 eLT_Light
76}; 74};
77 75
78typedef struct usX2Y_volume { 76struct 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
86struct us428_lights{ 84struct us428_lights {
87 us428_setByte_t Light[7]; 85 struct us428_setByte Light[7];
88}; 86};
89typedef struct us428_lights us428_lights_t;
90 87
91typedef struct { 88struct 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
101struct us428ctls_sharedmem{ 98struct 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};
108typedef struct us428ctls_sharedmem us428ctls_sharedmem_t;
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 412c2e52d867..9807c3d7b1a4 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -167,28 +167,28 @@ MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS".");
167static int snd_usX2Y_card_used[SNDRV_CARDS]; 167static int snd_usX2Y_card_used[SNDRV_CARDS];
168 168
169static void usX2Y_usb_disconnect(struct usb_device* usb_device, void* ptr); 169static void usX2Y_usb_disconnect(struct usb_device* usb_device, void* ptr);
170static void snd_usX2Y_card_private_free(snd_card_t *card); 170static 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 */
175static void i_usX2Y_Out04Int(struct urb* urb, struct pt_regs *regs) 175static 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
187static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) 187static 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 */
264int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) 264int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y)
265{ 265{
266 int err = 0, 266 int err = 0,
267 i; 267 i;
@@ -283,7 +283,7 @@ int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y)
283 return err; 283 return err;
284} 284}
285 285
286int usX2Y_In04_init(usX2Ydev_t* usX2Y) 286int usX2Y_In04_init(struct usX2Ydev *usX2Y)
287{ 287{
288 if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL))) 288 if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL)))
289 return -ENOMEM; 289 return -ENOMEM;
@@ -301,7 +301,7 @@ int usX2Y_In04_init(usX2Ydev_t* usX2Y)
301 return usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); 301 return usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
302} 302}
303 303
304static void usX2Y_unlinkSeq(snd_usX2Y_AsyncSeq_t* S) 304static void usX2Y_unlinkSeq(struct snd_usX2Y_AsyncSeq *S)
305{ 305{
306 int i; 306 int i;
307 for (i = 0; i < URBS_AsyncSeq; ++i) { 307 for (i = 0; i < URBS_AsyncSeq; ++i) {
@@ -334,16 +334,16 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = {
334 { /* terminator */ } 334 { /* terminator */ }
335}; 335};
336 336
337static snd_card_t* usX2Y_create_card(struct usb_device* device) 337static struct snd_card *usX2Y_create_card(struct usb_device *device)
338{ 338{
339 int dev; 339 int dev;
340 snd_card_t* card; 340 struct snd_card * card;
341 for (dev = 0; dev < SNDRV_CARDS; ++dev) 341 for (dev = 0; dev < SNDRV_CARDS; ++dev)
342 if (enable[dev] && !snd_usX2Y_card_used[dev]) 342 if (enable[dev] && !snd_usX2Y_card_used[dev])
343 break; 343 break;
344 if (dev >= SNDRV_CARDS) 344 if (dev >= SNDRV_CARDS)
345 return NULL; 345 return NULL;
346 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));
347 if (!card) 347 if (!card)
348 return NULL; 348 return NULL;
349 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; 349 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1;
@@ -367,10 +367,10 @@ static snd_card_t* usX2Y_create_card(struct usb_device* device)
367} 367}
368 368
369 369
370static void* usX2Y_usb_probe(struct usb_device* device, struct usb_interface *intf, const struct usb_device_id* device_id) 370static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id)
371{ 371{
372 int err; 372 int err;
373 snd_card_t* card; 373 struct snd_card * card;
374 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || 374 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 ||
375 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && 375 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 &&
376 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && 376 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 &&
@@ -414,7 +414,7 @@ static struct usb_driver snd_usX2Y_usb_driver = {
414 .id_table = snd_usX2Y_usb_id_table, 414 .id_table = snd_usX2Y_usb_id_table,
415}; 415};
416 416
417static void snd_usX2Y_card_private_free(snd_card_t *card) 417static void snd_usX2Y_card_private_free(struct snd_card *card)
418{ 418{
419 kfree(usX2Y(card)->In04Buf); 419 kfree(usX2Y(card)->In04Buf);
420 usb_free_urb(usX2Y(card)->In04urb); 420 usb_free_urb(usX2Y(card)->In04urb);
@@ -427,11 +427,11 @@ static void snd_usX2Y_card_private_free(snd_card_t *card)
427/* 427/*
428 * Frees the device. 428 * Frees the device.
429 */ 429 */
430static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) 430static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr)
431{ 431{
432 if (ptr) { 432 if (ptr) {
433 snd_card_t *card = ptr; 433 struct snd_card *card = ptr;
434 usX2Ydev_t* usX2Y = usX2Y(card); 434 struct usX2Ydev *usX2Y = usX2Y(card);
435 struct list_head *p; 435 struct list_head *p;
436 usX2Y->chip.shutdown = 1; 436 usX2Y->chip.shutdown = 1;
437 usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; 437 usX2Y->chip_status = USX2Y_STAT_CHIP_HUP;
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
11typedef struct { 11struct 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
16typedef struct { 16struct 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
22typedef struct snd_usX2Y_substream snd_usX2Y_substream_t;
23#include "usx2yhwdeppcm.h" 22#include "usx2yhwdeppcm.h"
24 23
25typedef struct { 24struct 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
49struct snd_usX2Y_substream { 48struct 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
77int usX2Y_audio_create(snd_card_t* card); 76int usX2Y_audio_create(struct snd_card *card);
78 77
79int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y); 78int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y);
80int usX2Y_In04_init(usX2Ydev_t* usX2Y); 79int 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 e1dbfbba8fa9..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
70static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) 70static 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 */
123static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, 126static 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 */
175static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) 181static 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
190static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int frame) 196static 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,7 +208,9 @@ 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
205static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_usX2Y_substream_t *playbacksubs, int frame) 211static 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 struct urb *urb = playbacksubs->completed_urb; 216 struct urb *urb = playbacksubs->completed_urb;
@@ -211,9 +219,8 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us
211 if (NULL != urb) { 219 if (NULL != urb) {
212 if (state == state_RUNNING) 220 if (state == state_RUNNING)
213 usX2Y_urb_play_retire(playbacksubs, urb); 221 usX2Y_urb_play_retire(playbacksubs, urb);
214 else 222 else if (state >= state_PRERUNNING)
215 if (state >= state_PRERUNNING) 223 atomic_inc(&playbacksubs->state);
216 atomic_inc(&playbacksubs->state);
217 } else { 224 } else {
218 switch (state) { 225 switch (state) {
219 case state_STARTING1: 226 case state_STARTING1:
@@ -228,8 +235,9 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us
228 } 235 }
229 if (urb) { 236 if (urb) {
230 if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || 237 if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) ||
231 (err = usX2Y_urb_submit(playbacksubs, urb, frame))) 238 (err = usX2Y_urb_submit(playbacksubs, urb, frame))) {
232 return err; 239 return err;
240 }
233 } 241 }
234 242
235 playbacksubs->completed_urb = NULL; 243 playbacksubs->completed_urb = NULL;
@@ -249,18 +257,19 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us
249} 257}
250 258
251 259
252static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) 260static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
253{ 261{
254 int s, u; 262 int s, u;
263
255 for (s = 0; s < 4; s++) { 264 for (s = 0; s < 4; s++) {
256 snd_usX2Y_substream_t *subs = usX2Y->subs[s]; 265 struct snd_usX2Y_substream *subs = usX2Y->subs[s];
257 if (subs) { 266 if (subs) {
258 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));
259 atomic_set(&subs->state, state_STOPPED); 268 atomic_set(&subs->state, state_STOPPED);
260 } 269 }
261 } 270 }
262 for (s = 0; s < 4; s++) { 271 for (s = 0; s < 4; s++) {
263 snd_usX2Y_substream_t *subs = usX2Y->subs[s]; 272 struct snd_usX2Y_substream *subs = usX2Y->subs[s];
264 if (subs) { 273 if (subs) {
265 if (atomic_read(&subs->state) >= state_PRERUNNING) { 274 if (atomic_read(&subs->state) >= state_PRERUNNING) {
266 snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); 275 snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
@@ -268,7 +277,8 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y)
268 for (u = 0; u < NRURBS; u++) { 277 for (u = 0; u < NRURBS; u++) {
269 struct urb *urb = subs->urb[u]; 278 struct urb *urb = subs->urb[u];
270 if (NULL != urb) 279 if (NULL != urb)
271 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);
272 } 282 }
273 } 283 }
274 } 284 }
@@ -276,30 +286,36 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y)
276 wake_up(&usX2Y->prepare_wait_queue); 286 wake_up(&usX2Y->prepare_wait_queue);
277} 287}
278 288
279static void usX2Y_error_urb_status(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) 289static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y,
290 struct snd_usX2Y_substream *subs, struct urb *urb)
280{ 291{
281 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);
282 urb->status = 0; 293 urb->status = 0;
283 usX2Y_clients_stop(usX2Y); 294 usX2Y_clients_stop(usX2Y);
284} 295}
285 296
286static void usX2Y_error_sequence(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) 297static void usX2Y_error_sequence(struct usX2Ydev *usX2Y,
298 struct snd_usX2Y_substream *subs, struct urb *urb)
287{ 299{
288 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"
289 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"
290 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",
291 usb_get_current_frame_number(usX2Y->chip.dev), 303 usb_get_current_frame_number(usX2Y->chip.dev),
292 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);
293 usX2Y_clients_stop(usX2Y); 306 usX2Y_clients_stop(usX2Y);
294} 307}
295 308
296static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) 309static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs)
297{ 310{
298 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; 311 struct snd_usX2Y_substream *subs = urb->context;
299 usX2Ydev_t *usX2Y = subs->usX2Y; 312 struct usX2Ydev *usX2Y = subs->usX2Y;
300 313
301 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { 314 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) {
302 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);
303 return; 319 return;
304 } 320 }
305 if (unlikely(urb->status)) { 321 if (unlikely(urb->status)) {
@@ -313,10 +329,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs)
313 return; 329 return;
314 } 330 }
315 { 331 {
316 snd_usX2Y_substream_t *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], 332 struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE],
317 *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; 333 *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
318 if (capsubs->completed_urb && atomic_read(&capsubs->state) >= state_PREPARED && 334 if (capsubs->completed_urb &&
319 (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)) {
320 if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { 338 if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) {
321 if (nr_of_packs() <= urb->start_frame && 339 if (nr_of_packs() <= urb->start_frame &&
322 urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci 340 urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci
@@ -331,11 +349,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs)
331 } 349 }
332} 350}
333 351
334static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct urb *, struct pt_regs *)) 352static void usX2Y_urbs_set_complete(struct usX2Ydev * usX2Y,
353 void (*complete)(struct urb *, struct pt_regs *))
335{ 354{
336 int s, u; 355 int s, u;
337 for (s = 0; s < 4; s++) { 356 for (s = 0; s < 4; s++) {
338 snd_usX2Y_substream_t *subs = usX2Y->subs[s]; 357 struct snd_usX2Y_substream *subs = usX2Y->subs[s];
339 if (NULL != subs) 358 if (NULL != subs)
340 for (u = 0; u < NRURBS; u++) { 359 for (u = 0; u < NRURBS; u++) {
341 struct urb * urb = subs->urb[u]; 360 struct urb * urb = subs->urb[u];
@@ -345,7 +364,7 @@ static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct
345 } 364 }
346} 365}
347 366
348static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) 367static void usX2Y_subs_startup_finish(struct usX2Ydev * usX2Y)
349{ 368{
350 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); 369 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete);
351 usX2Y->prepare_subs = NULL; 370 usX2Y->prepare_subs = NULL;
@@ -353,9 +372,9 @@ static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y)
353 372
354static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) 373static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs)
355{ 374{
356 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; 375 struct snd_usX2Y_substream *subs = urb->context;
357 usX2Ydev_t *usX2Y = subs->usX2Y; 376 struct usX2Ydev *usX2Y = subs->usX2Y;
358 snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; 377 struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs;
359 if (NULL != prepare_subs) 378 if (NULL != prepare_subs)
360 if (urb->start_frame == prepare_subs->urb[0]->start_frame) { 379 if (urb->start_frame == prepare_subs->urb[0]->start_frame) {
361 usX2Y_subs_startup_finish(usX2Y); 380 usX2Y_subs_startup_finish(usX2Y);
@@ -366,9 +385,10 @@ static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs)
366 i_usX2Y_urb_complete(urb, regs); 385 i_usX2Y_urb_complete(urb, regs);
367} 386}
368 387
369static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) 388static void usX2Y_subs_prepare(struct snd_usX2Y_substream *subs)
370{ 389{
371 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]);
372 /* reset the pointer */ 392 /* reset the pointer */
373 subs->hwptr = 0; 393 subs->hwptr = 0;
374 subs->hwptr_done = 0; 394 subs->hwptr_done = 0;
@@ -376,7 +396,7 @@ static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs)
376} 396}
377 397
378 398
379static void usX2Y_urb_release(struct urb** urb, int free_tb) 399static void usX2Y_urb_release(struct urb **urb, int free_tb)
380{ 400{
381 if (*urb) { 401 if (*urb) {
382 usb_kill_urb(*urb); 402 usb_kill_urb(*urb);
@@ -389,12 +409,13 @@ static void usX2Y_urb_release(struct urb** urb, int free_tb)
389/* 409/*
390 * release a substreams urbs 410 * release a substreams urbs
391 */ 411 */
392static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) 412static void usX2Y_urbs_release(struct snd_usX2Y_substream *subs)
393{ 413{
394 int i; 414 int i;
395 snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); 415 snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint);
396 for (i = 0; i < NRURBS; i++) 416 for (i = 0; i < NRURBS; i++)
397 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]);
398 419
399 kfree(subs->tmpbuf); 420 kfree(subs->tmpbuf);
400 subs->tmpbuf = NULL; 421 subs->tmpbuf = NULL;
@@ -402,7 +423,7 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs)
402/* 423/*
403 * initialize a substream's urbs 424 * initialize a substream's urbs
404 */ 425 */
405static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) 426static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs)
406{ 427{
407 int i; 428 int i;
408 unsigned int pipe; 429 unsigned int pipe;
@@ -452,25 +473,25 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs)
452 return 0; 473 return 0;
453} 474}
454 475
455static void usX2Y_subs_startup(snd_usX2Y_substream_t *subs) 476static void usX2Y_subs_startup(struct snd_usX2Y_substream *subs)
456{ 477{
457 usX2Ydev_t *usX2Y = subs->usX2Y; 478 struct usX2Ydev *usX2Y = subs->usX2Y;
458 usX2Y->prepare_subs = subs; 479 usX2Y->prepare_subs = subs;
459 subs->urb[0]->start_frame = -1; 480 subs->urb[0]->start_frame = -1;
460 wmb(); 481 wmb();
461 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); 482 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup);
462} 483}
463 484
464static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) 485static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs)
465{ 486{
466 int i, err; 487 int i, err;
467 usX2Ydev_t *usX2Y = subs->usX2Y; 488 struct usX2Ydev *usX2Y = subs->usX2Y;
468 489
469 if ((err = usX2Y_urbs_allocate(subs)) < 0) 490 if ((err = usX2Y_urbs_allocate(subs)) < 0)
470 return err; 491 return err;
471 subs->completed_urb = NULL; 492 subs->completed_urb = NULL;
472 for (i = 0; i < 4; i++) { 493 for (i = 0; i < 4; i++) {
473 snd_usX2Y_substream_t *subs = usX2Y->subs[i]; 494 struct snd_usX2Y_substream *subs = usX2Y->subs[i];
474 if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) 495 if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED)
475 goto start; 496 goto start;
476 } 497 }
@@ -521,17 +542,17 @@ static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs)
521/* 542/*
522 * return the current pcm pointer. just return the hwptr_done value. 543 * return the current pcm pointer. just return the hwptr_done value.
523 */ 544 */
524static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(snd_pcm_substream_t *substream) 545static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(struct snd_pcm_substream *substream)
525{ 546{
526 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; 547 struct snd_usX2Y_substream *subs = substream->runtime->private_data;
527 return subs->hwptr_done; 548 return subs->hwptr_done;
528} 549}
529/* 550/*
530 * start/stop substream 551 * start/stop substream
531 */ 552 */
532static int snd_usX2Y_pcm_trigger(snd_pcm_substream_t *substream, int cmd) 553static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
533{ 554{
534 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; 555 struct snd_usX2Y_substream *subs = substream->runtime->private_data;
535 556
536 switch (cmd) { 557 switch (cmd) {
537 case SNDRV_PCM_TRIGGER_START: 558 case SNDRV_PCM_TRIGGER_START:
@@ -642,9 +663,9 @@ static struct s_c2 SetRate48000[] =
642}; 663};
643#define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) 664#define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000)
644 665
645static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) 666static void i_usX2Y_04Int(struct urb *urb, struct pt_regs *regs)
646{ 667{
647 usX2Ydev_t* usX2Y = urb->context; 668 struct usX2Ydev *usX2Y = urb->context;
648 669
649 if (urb->status) 670 if (urb->status)
650 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);
@@ -652,10 +673,10 @@ static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs)
652 wake_up(&usX2Y->In04WaitQueue); 673 wake_up(&usX2Y->In04WaitQueue);
653} 674}
654 675
655static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) 676static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
656{ 677{
657 int err = 0, i; 678 int err = 0, i;
658 snd_usX2Y_urbSeq_t *us = NULL; 679 struct snd_usX2Y_urbSeq *us = NULL;
659 int *usbdata = NULL; 680 int *usbdata = NULL;
660 struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; 681 struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100;
661 682
@@ -714,7 +735,7 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate)
714} 735}
715 736
716 737
717static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) 738static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format)
718{ 739{
719 int alternate, err; 740 int alternate, err;
720 struct list_head* p; 741 struct list_head* p;
@@ -744,27 +765,27 @@ static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format)
744} 765}
745 766
746 767
747static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, 768static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream,
748 snd_pcm_hw_params_t *hw_params) 769 struct snd_pcm_hw_params *hw_params)
749{ 770{
750 int err = 0; 771 int err = 0;
751 unsigned int rate = params_rate(hw_params); 772 unsigned int rate = params_rate(hw_params);
752 snd_pcm_format_t format = params_format(hw_params); 773 snd_pcm_format_t format = params_format(hw_params);
753 snd_card_t *card = substream->pstr->pcm->card; 774 struct snd_card *card = substream->pstr->pcm->card;
754 struct list_head *list; 775 struct list_head *list;
755 776
756 snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); 777 snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params);
757 // all pcm substreams off one usX2Y have to operate at the same rate & format 778 // all pcm substreams off one usX2Y have to operate at the same rate & format
758 list_for_each(list, &card->devices) { 779 list_for_each(list, &card->devices) {
759 snd_device_t *dev; 780 struct snd_device *dev;
760 snd_pcm_t *pcm; 781 struct snd_pcm *pcm;
761 int s; 782 int s;
762 dev = snd_device(list); 783 dev = snd_device(list);
763 if (dev->type != SNDRV_DEV_PCM) 784 if (dev->type != SNDRV_DEV_PCM)
764 continue; 785 continue;
765 pcm = dev->device_data; 786 pcm = dev->device_data;
766 for (s = 0; s < 2; ++s) { 787 for (s = 0; s < 2; ++s) {
767 snd_pcm_substream_t *test_substream; 788 struct snd_pcm_substream *test_substream;
768 test_substream = pcm->streams[s].substream; 789 test_substream = pcm->streams[s].substream;
769 if (test_substream && test_substream != substream && 790 if (test_substream && test_substream != substream &&
770 test_substream->runtime && 791 test_substream->runtime &&
@@ -776,7 +797,8 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream,
776 } 797 }
777 } 798 }
778 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)))) {
779 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);
780 return err; 802 return err;
781 } 803 }
782 return 0; 804 return 0;
@@ -785,15 +807,15 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream,
785/* 807/*
786 * free the buffer 808 * free the buffer
787 */ 809 */
788static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) 810static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream)
789{ 811{
790 snd_pcm_runtime_t *runtime = substream->runtime; 812 struct snd_pcm_runtime *runtime = substream->runtime;
791 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 813 struct snd_usX2Y_substream *subs = runtime->private_data;
792 down(&subs->usX2Y->prepare_mutex); 814 down(&subs->usX2Y->prepare_mutex);
793 snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); 815 snd_printdd("snd_usX2Y_hw_free(%p)\n", substream);
794 816
795 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { 817 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
796 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];
797 atomic_set(&subs->state, state_STOPPED); 819 atomic_set(&subs->state, state_STOPPED);
798 usX2Y_urbs_release(subs); 820 usX2Y_urbs_release(subs);
799 if (!cap_subs->pcm_substream || 821 if (!cap_subs->pcm_substream ||
@@ -804,7 +826,7 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream)
804 usX2Y_urbs_release(cap_subs); 826 usX2Y_urbs_release(cap_subs);
805 } 827 }
806 } else { 828 } else {
807 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];
808 if (atomic_read(&playback_subs->state) < state_PREPARED) { 830 if (atomic_read(&playback_subs->state) < state_PREPARED) {
809 atomic_set(&subs->state, state_STOPPED); 831 atomic_set(&subs->state, state_STOPPED);
810 usX2Y_urbs_release(subs); 832 usX2Y_urbs_release(subs);
@@ -818,12 +840,12 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream)
818 * 840 *
819 * set format and initialize urbs 841 * set format and initialize urbs
820 */ 842 */
821static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) 843static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream)
822{ 844{
823 snd_pcm_runtime_t *runtime = substream->runtime; 845 struct snd_pcm_runtime *runtime = substream->runtime;
824 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 846 struct snd_usX2Y_substream *subs = runtime->private_data;
825 usX2Ydev_t *usX2Y = subs->usX2Y; 847 struct usX2Ydev *usX2Y = subs->usX2Y;
826 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];
827 int err = 0; 849 int err = 0;
828 snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); 850 snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream);
829 851
@@ -851,7 +873,7 @@ static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream)
851 return err; 873 return err;
852} 874}
853 875
854static snd_pcm_hardware_t snd_usX2Y_2c = 876static struct snd_pcm_hardware snd_usX2Y_2c =
855{ 877{
856 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 878 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
857 SNDRV_PCM_INFO_BLOCK_TRANSFER | 879 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -872,11 +894,11 @@ static snd_pcm_hardware_t snd_usX2Y_2c =
872 894
873 895
874 896
875static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) 897static int snd_usX2Y_pcm_open(struct snd_pcm_substream *substream)
876{ 898{
877 snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) 899 struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **)
878 snd_pcm_substream_chip(substream))[substream->stream]; 900 snd_pcm_substream_chip(substream))[substream->stream];
879 snd_pcm_runtime_t *runtime = substream->runtime; 901 struct snd_pcm_runtime *runtime = substream->runtime;
880 902
881 if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) 903 if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)
882 return -EBUSY; 904 return -EBUSY;
@@ -890,19 +912,18 @@ static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream)
890 912
891 913
892 914
893static int snd_usX2Y_pcm_close(snd_pcm_substream_t *substream) 915static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream)
894{ 916{
895 snd_pcm_runtime_t *runtime = substream->runtime; 917 struct snd_pcm_runtime *runtime = substream->runtime;
896 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 918 struct snd_usX2Y_substream *subs = runtime->private_data;
897 int err = 0;
898 919
899 subs->pcm_substream = NULL; 920 subs->pcm_substream = NULL;
900 921
901 return err; 922 return 0;
902} 923}
903 924
904 925
905static snd_pcm_ops_t snd_usX2Y_pcm_ops = 926static struct snd_pcm_ops snd_usX2Y_pcm_ops =
906{ 927{
907 .open = snd_usX2Y_pcm_open, 928 .open = snd_usX2Y_pcm_open,
908 .close = snd_usX2Y_pcm_close, 929 .close = snd_usX2Y_pcm_close,
@@ -918,7 +939,7 @@ static snd_pcm_ops_t snd_usX2Y_pcm_ops =
918/* 939/*
919 * free a usb stream instance 940 * free a usb stream instance
920 */ 941 */
921static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) 942static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream)
922{ 943{
923 if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { 944 if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) {
924 kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); 945 kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
@@ -928,23 +949,23 @@ static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream)
928 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; 949 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL;
929} 950}
930 951
931static void snd_usX2Y_pcm_private_free(snd_pcm_t *pcm) 952static void snd_usX2Y_pcm_private_free(struct snd_pcm *pcm)
932{ 953{
933 snd_usX2Y_substream_t **usX2Y_stream = pcm->private_data; 954 struct snd_usX2Y_substream **usX2Y_stream = pcm->private_data;
934 if (usX2Y_stream) 955 if (usX2Y_stream)
935 usX2Y_audio_stream_free(usX2Y_stream); 956 usX2Y_audio_stream_free(usX2Y_stream);
936} 957}
937 958
938static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int capture_endpoint) 959static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint)
939{ 960{
940 snd_pcm_t *pcm; 961 struct snd_pcm *pcm;
941 int err, i; 962 int err, i;
942 snd_usX2Y_substream_t **usX2Y_substream = 963 struct snd_usX2Y_substream **usX2Y_substream =
943 usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; 964 usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs;
944 965
945 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;
946 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { 967 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) {
947 usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL); 968 usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL);
948 if (NULL == usX2Y_substream[i]) { 969 if (NULL == usX2Y_substream[i]) {
949 snd_printk(KERN_ERR "cannot malloc\n"); 970 snd_printk(KERN_ERR "cannot malloc\n");
950 return -ENOMEM; 971 return -ENOMEM;
@@ -994,7 +1015,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c
994/* 1015/*
995 * create a chip instance and set its names. 1016 * create a chip instance and set its names.
996 */ 1017 */
997int usX2Y_audio_create(snd_card_t* card) 1018int usX2Y_audio_create(struct snd_card *card)
998{ 1019{
999 int err = 0; 1020 int err = 0;
1000 1021
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
index c5379280fab7..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
61static int usX2Y_usbpcm_urb_capt_retire(snd_usX2Y_substream_t *subs) 61static 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
93static inline int usX2Y_iso_frames_per_buffer(snd_pcm_runtime_t *runtime, usX2Ydev_t * usX2Y) 93static 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 */
108static int usX2Y_hwdep_urb_play_prepare(snd_usX2Y_substream_t *subs, 109static 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
147static inline void usX2Y_usbpcm_urb_capt_iso_advance(snd_usX2Y_substream_t *subs, struct urb *urb) 148static 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
169static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, 171static 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;
@@ -225,12 +228,15 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs,
225 228
226static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) 229static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs)
227{ 230{
228 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; 231 struct snd_usX2Y_substream *subs = urb->context;
229 usX2Ydev_t *usX2Y = subs->usX2Y; 232 struct usX2Ydev *usX2Y = subs->usX2Y;
230 snd_usX2Y_substream_t *capsubs, *capsubs2, *playbacksubs; 233 struct snd_usX2Y_substream *capsubs, *capsubs2, *playbacksubs;
231 234
232 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { 235 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) {
233 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);
234 return; 240 return;
235 } 241 }
236 if (unlikely(urb->status)) { 242 if (unlikely(urb->status)) {
@@ -264,7 +270,7 @@ static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs)
264} 270}
265 271
266 272
267static void usX2Y_hwdep_urb_release(struct urb** urb) 273static void usX2Y_hwdep_urb_release(struct urb **urb)
268{ 274{
269 usb_kill_urb(*urb); 275 usb_kill_urb(*urb);
270 usb_free_urb(*urb); 276 usb_free_urb(*urb);
@@ -274,7 +280,7 @@ static void usX2Y_hwdep_urb_release(struct urb** urb)
274/* 280/*
275 * release a substream 281 * release a substream
276 */ 282 */
277static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs) 283static void usX2Y_usbpcm_urbs_release(struct snd_usX2Y_substream *subs)
278{ 284{
279 int i; 285 int i;
280 snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint); 286 snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint);
@@ -282,7 +288,7 @@ static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs)
282 usX2Y_hwdep_urb_release(subs->urb + i); 288 usX2Y_hwdep_urb_release(subs->urb + i);
283} 289}
284 290
285static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y) 291static void usX2Y_usbpcm_subs_startup_finish(struct usX2Ydev * usX2Y)
286{ 292{
287 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete); 293 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete);
288 usX2Y->prepare_subs = NULL; 294 usX2Y->prepare_subs = NULL;
@@ -290,14 +296,14 @@ static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y)
290 296
291static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) 297static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs)
292{ 298{
293 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; 299 struct snd_usX2Y_substream *subs = urb->context;
294 usX2Ydev_t *usX2Y = subs->usX2Y; 300 struct usX2Ydev *usX2Y = subs->usX2Y;
295 snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; 301 struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs;
296 if (NULL != prepare_subs && 302 if (NULL != prepare_subs &&
297 urb->start_frame == prepare_subs->urb[0]->start_frame) { 303 urb->start_frame == prepare_subs->urb[0]->start_frame) {
298 atomic_inc(&prepare_subs->state); 304 atomic_inc(&prepare_subs->state);
299 if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) { 305 if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) {
300 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];
301 if (cap_subs2 != NULL) 307 if (cap_subs2 != NULL)
302 atomic_inc(&cap_subs2->state); 308 atomic_inc(&cap_subs2->state);
303 } 309 }
@@ -311,7 +317,7 @@ static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs)
311/* 317/*
312 * initialize a substream's urbs 318 * initialize a substream's urbs
313 */ 319 */
314static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) 320static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs)
315{ 321{
316 int i; 322 int i;
317 unsigned int pipe; 323 unsigned int pipe;
@@ -355,16 +361,16 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs)
355/* 361/*
356 * free the buffer 362 * free the buffer
357 */ 363 */
358static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) 364static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream)
359{ 365{
360 snd_pcm_runtime_t *runtime = substream->runtime; 366 struct snd_pcm_runtime *runtime = substream->runtime;
361 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data, 367 struct snd_usX2Y_substream *subs = runtime->private_data,
362 *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; 368 *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2];
363 down(&subs->usX2Y->prepare_mutex); 369 down(&subs->usX2Y->prepare_mutex);
364 snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream); 370 snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream);
365 371
366 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { 372 if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
367 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];
368 atomic_set(&subs->state, state_STOPPED); 374 atomic_set(&subs->state, state_STOPPED);
369 usX2Y_usbpcm_urbs_release(subs); 375 usX2Y_usbpcm_urbs_release(subs);
370 if (!cap_subs->pcm_substream || 376 if (!cap_subs->pcm_substream ||
@@ -379,7 +385,7 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream)
379 usX2Y_usbpcm_urbs_release(cap_subs2); 385 usX2Y_usbpcm_urbs_release(cap_subs2);
380 } 386 }
381 } else { 387 } else {
382 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];
383 if (atomic_read(&playback_subs->state) < state_PREPARED) { 389 if (atomic_read(&playback_subs->state) < state_PREPARED) {
384 atomic_set(&subs->state, state_STOPPED); 390 atomic_set(&subs->state, state_STOPPED);
385 if (NULL != cap_subs2) 391 if (NULL != cap_subs2)
@@ -393,20 +399,20 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream)
393 return snd_pcm_lib_free_pages(substream); 399 return snd_pcm_lib_free_pages(substream);
394} 400}
395 401
396static void usX2Y_usbpcm_subs_startup(snd_usX2Y_substream_t *subs) 402static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs)
397{ 403{
398 usX2Ydev_t * usX2Y = subs->usX2Y; 404 struct usX2Ydev * usX2Y = subs->usX2Y;
399 usX2Y->prepare_subs = subs; 405 usX2Y->prepare_subs = subs;
400 subs->urb[0]->start_frame = -1; 406 subs->urb[0]->start_frame = -1;
401 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()
402 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup); 408 usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup);
403} 409}
404 410
405static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) 411static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs)
406{ 412{
407 int p, u, err, 413 int p, u, err,
408 stream = subs->pcm_substream->stream; 414 stream = subs->pcm_substream->stream;
409 usX2Ydev_t *usX2Y = subs->usX2Y; 415 struct usX2Ydev *usX2Y = subs->usX2Y;
410 416
411 if (SNDRV_PCM_STREAM_CAPTURE == stream) { 417 if (SNDRV_PCM_STREAM_CAPTURE == stream) {
412 usX2Y->hwdep_pcm_shm->captured_iso_head = -1; 418 usX2Y->hwdep_pcm_shm->captured_iso_head = -1;
@@ -414,7 +420,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs)
414 } 420 }
415 421
416 for (p = 0; 3 >= (stream + p); p += 2) { 422 for (p = 0; 3 >= (stream + p); p += 2) {
417 snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; 423 struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p];
418 if (subs != NULL) { 424 if (subs != NULL) {
419 if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0) 425 if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0)
420 return err; 426 return err;
@@ -423,7 +429,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs)
423 } 429 }
424 430
425 for (p = 0; p < 4; p++) { 431 for (p = 0; p < 4; p++) {
426 snd_usX2Y_substream_t *subs = usX2Y->subs[p]; 432 struct snd_usX2Y_substream *subs = usX2Y->subs[p];
427 if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) 433 if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED)
428 goto start; 434 goto start;
429 } 435 }
@@ -433,7 +439,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs)
433 usX2Y_usbpcm_subs_startup(subs); 439 usX2Y_usbpcm_subs_startup(subs);
434 for (u = 0; u < NRURBS; u++) { 440 for (u = 0; u < NRURBS; u++) {
435 for (p = 0; 3 >= (stream + p); p += 2) { 441 for (p = 0; 3 >= (stream + p); p += 2) {
436 snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; 442 struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p];
437 if (subs != NULL) { 443 if (subs != NULL) {
438 struct urb *urb = subs->urb[u]; 444 struct urb *urb = subs->urb[u];
439 if (usb_pipein(urb->pipe)) { 445 if (usb_pipein(urb->pipe)) {
@@ -482,19 +488,19 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs)
482 * 488 *
483 * set format and initialize urbs 489 * set format and initialize urbs
484 */ 490 */
485static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) 491static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream)
486{ 492{
487 snd_pcm_runtime_t *runtime = substream->runtime; 493 struct snd_pcm_runtime *runtime = substream->runtime;
488 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 494 struct snd_usX2Y_substream *subs = runtime->private_data;
489 usX2Ydev_t *usX2Y = subs->usX2Y; 495 struct usX2Ydev *usX2Y = subs->usX2Y;
490 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];
491 int err = 0; 497 int err = 0;
492 snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); 498 snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream);
493 499
494 if (NULL == usX2Y->hwdep_pcm_shm) { 500 if (NULL == usX2Y->hwdep_pcm_shm) {
495 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)))
496 return -ENOMEM; 502 return -ENOMEM;
497 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));
498 } 504 }
499 505
500 down(&usX2Y->prepare_mutex); 506 down(&usX2Y->prepare_mutex);
@@ -508,7 +514,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream)
508 if (usX2Y->rate != runtime->rate) 514 if (usX2Y->rate != runtime->rate)
509 if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0) 515 if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0)
510 goto up_prepare_mutex; 516 goto up_prepare_mutex;
511 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");
512 if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs))) 519 if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs)))
513 goto up_prepare_mutex; 520 goto up_prepare_mutex;
514 } 521 }
@@ -516,8 +523,12 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream)
516 if (subs != capsubs) { 523 if (subs != capsubs) {
517 usX2Y->hwdep_pcm_shm->playback_iso_start = -1; 524 usX2Y->hwdep_pcm_shm->playback_iso_start = -1;
518 if (atomic_read(&subs->state) < state_PREPARED) { 525 if (atomic_read(&subs->state) < state_PREPARED) {
519 while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) { 526 while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) >
520 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);
521 if (msleep_interruptible(10)) { 532 if (msleep_interruptible(10)) {
522 err = -ERESTARTSYS; 533 err = -ERESTARTSYS;
523 goto up_prepare_mutex; 534 goto up_prepare_mutex;
@@ -526,7 +537,9 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream)
526 if (0 > (err = usX2Y_usbpcm_urbs_start(subs))) 537 if (0 > (err = usX2Y_usbpcm_urbs_start(subs)))
527 goto up_prepare_mutex; 538 goto up_prepare_mutex;
528 } 539 }
529 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);
530 } else 543 } else
531 usX2Y->hwdep_pcm_shm->capture_iso_start = -1; 544 usX2Y->hwdep_pcm_shm->capture_iso_start = -1;
532 545
@@ -535,7 +548,7 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream)
535 return err; 548 return err;
536} 549}
537 550
538static snd_pcm_hardware_t snd_usX2Y_4c = 551static struct snd_pcm_hardware snd_usX2Y_4c =
539{ 552{
540 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 553 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
541 SNDRV_PCM_INFO_BLOCK_TRANSFER | 554 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -556,11 +569,11 @@ static snd_pcm_hardware_t snd_usX2Y_4c =
556 569
557 570
558 571
559static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream) 572static int snd_usX2Y_usbpcm_open(struct snd_pcm_substream *substream)
560{ 573{
561 snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) 574 struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **)
562 snd_pcm_substream_chip(substream))[substream->stream]; 575 snd_pcm_substream_chip(substream))[substream->stream];
563 snd_pcm_runtime_t *runtime = substream->runtime; 576 struct snd_pcm_runtime *runtime = substream->runtime;
564 577
565 if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) 578 if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS))
566 return -EBUSY; 579 return -EBUSY;
@@ -574,17 +587,17 @@ static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream)
574} 587}
575 588
576 589
577static int snd_usX2Y_usbpcm_close(snd_pcm_substream_t *substream) 590static int snd_usX2Y_usbpcm_close(struct snd_pcm_substream *substream)
578{ 591{
579 snd_pcm_runtime_t *runtime = substream->runtime; 592 struct snd_pcm_runtime *runtime = substream->runtime;
580 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 593 struct snd_usX2Y_substream *subs = runtime->private_data;
581 594
582 subs->pcm_substream = NULL; 595 subs->pcm_substream = NULL;
583 return 0; 596 return 0;
584} 597}
585 598
586 599
587static snd_pcm_ops_t snd_usX2Y_usbpcm_ops = 600static struct snd_pcm_ops snd_usX2Y_usbpcm_ops =
588{ 601{
589 .open = snd_usX2Y_usbpcm_open, 602 .open = snd_usX2Y_usbpcm_open,
590 .close = snd_usX2Y_usbpcm_close, 603 .close = snd_usX2Y_usbpcm_close,
@@ -597,11 +610,11 @@ static snd_pcm_ops_t snd_usX2Y_usbpcm_ops =
597}; 610};
598 611
599 612
600static int usX2Y_pcms_lock_check(snd_card_t *card) 613static int usX2Y_pcms_lock_check(struct snd_card *card)
601{ 614{
602 struct list_head *list; 615 struct list_head *list;
603 snd_device_t *dev; 616 struct snd_device *dev;
604 snd_pcm_t *pcm; 617 struct snd_pcm *pcm;
605 int err = 0; 618 int err = 0;
606 list_for_each(list, &card->devices) { 619 list_for_each(list, &card->devices) {
607 dev = snd_device(list); 620 dev = snd_device(list);
@@ -617,7 +630,7 @@ static int usX2Y_pcms_lock_check(snd_card_t *card)
617 continue; 630 continue;
618 pcm = dev->device_data; 631 pcm = dev->device_data;
619 for (s = 0; s < 2; ++s) { 632 for (s = 0; s < 2; ++s) {
620 snd_pcm_substream_t *substream; 633 struct snd_pcm_substream *substream;
621 substream = pcm->streams[s].substream; 634 substream = pcm->streams[s].substream;
622 if (substream && substream->ffile != NULL) 635 if (substream && substream->ffile != NULL)
623 err = -EBUSY; 636 err = -EBUSY;
@@ -627,11 +640,11 @@ static int usX2Y_pcms_lock_check(snd_card_t *card)
627} 640}
628 641
629 642
630static void usX2Y_pcms_unlock(snd_card_t *card) 643static void usX2Y_pcms_unlock(struct snd_card *card)
631{ 644{
632 struct list_head *list; 645 struct list_head *list;
633 snd_device_t *dev; 646 struct snd_device *dev;
634 snd_pcm_t *pcm; 647 struct snd_pcm *pcm;
635 list_for_each(list, &card->devices) { 648 list_for_each(list, &card->devices) {
636 dev = snd_device(list); 649 dev = snd_device(list);
637 if (dev->type != SNDRV_DEV_PCM) 650 if (dev->type != SNDRV_DEV_PCM)
@@ -642,10 +655,10 @@ static void usX2Y_pcms_unlock(snd_card_t *card)
642} 655}
643 656
644 657
645static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file) 658static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file)
646{ 659{
647 // we need to be the first 660 // we need to be the first
648 snd_card_t *card = hw->card; 661 struct snd_card *card = hw->card;
649 int err = usX2Y_pcms_lock_check(card); 662 int err = usX2Y_pcms_lock_check(card);
650 if (0 == err) 663 if (0 == err)
651 usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; 664 usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS;
@@ -654,9 +667,9 @@ static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file)
654} 667}
655 668
656 669
657static int snd_usX2Y_hwdep_pcm_release(snd_hwdep_t *hw, struct file *file) 670static int snd_usX2Y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file)
658{ 671{
659 snd_card_t *card = hw->card; 672 struct snd_card *card = hw->card;
660 int err = usX2Y_pcms_lock_check(card); 673 int err = usX2Y_pcms_lock_check(card);
661 if (0 == err) 674 if (0 == err)
662 usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; 675 usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS;
@@ -684,7 +697,7 @@ static struct page * snd_usX2Y_hwdep_pcm_vm_nopage(struct vm_area_struct *area,
684 offset = area->vm_pgoff << PAGE_SHIFT; 697 offset = area->vm_pgoff << PAGE_SHIFT;
685 offset += address - area->vm_start; 698 offset += address - area->vm_start;
686 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); 699 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
687 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;
688 page = virt_to_page(vaddr); 701 page = virt_to_page(vaddr);
689 get_page(page); 702 get_page(page);
690 703
@@ -702,17 +715,17 @@ static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = {
702}; 715};
703 716
704 717
705static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) 718static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area)
706{ 719{
707 unsigned long size = (unsigned long)(area->vm_end - area->vm_start); 720 unsigned long size = (unsigned long)(area->vm_end - area->vm_start);
708 usX2Ydev_t *usX2Y = hw->private_data; 721 struct usX2Ydev *usX2Y = hw->private_data;
709 722
710 if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT)) 723 if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT))
711 return -EBUSY; 724 return -EBUSY;
712 725
713 /* if userspace tries to mmap beyond end of our buffer, fail */ 726 /* if userspace tries to mmap beyond end of our buffer, fail */
714 if (size > PAGE_ALIGN(sizeof(snd_usX2Y_hwdep_pcm_shm_t))) { 727 if (size > PAGE_ALIGN(sizeof(struct snd_usX2Y_hwdep_pcm_shm))) {
715 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));
716 return -EINVAL; 729 return -EINVAL;
717 } 730 }
718 731
@@ -726,19 +739,19 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct
726} 739}
727 740
728 741
729static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) 742static void snd_usX2Y_hwdep_pcm_private_free(struct snd_hwdep *hwdep)
730{ 743{
731 usX2Ydev_t *usX2Y = hwdep->private_data; 744 struct usX2Ydev *usX2Y = hwdep->private_data;
732 if (NULL != usX2Y->hwdep_pcm_shm) 745 if (NULL != usX2Y->hwdep_pcm_shm)
733 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));
734} 747}
735 748
736 749
737int usX2Y_hwdep_pcm_new(snd_card_t* card) 750int usX2Y_hwdep_pcm_new(struct snd_card *card)
738{ 751{
739 int err; 752 int err;
740 snd_hwdep_t *hw; 753 struct snd_hwdep *hw;
741 snd_pcm_t *pcm; 754 struct snd_pcm *pcm;
742 struct usb_device *dev = usX2Y(card)->chip.dev; 755 struct usb_device *dev = usX2Y(card)->chip.dev;
743 if (1 != nr_of_packs()) 756 if (1 != nr_of_packs())
744 return 0; 757 return 0;
@@ -783,7 +796,7 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card)
783 796
784#else 797#else
785 798
786int usX2Y_hwdep_pcm_new(snd_card_t* card) 799int usX2Y_hwdep_pcm_new(struct snd_card *card)
787{ 800{
788 return 0; 801 return 0;
789} 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};
21typedef struct snd_usX2Y_hwdep_pcm_shm snd_usX2Y_hwdep_pcm_shm_t;