diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2011-02-28 12:27:07 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-28 18:24:17 -0500 |
commit | a75af07718d2f2552f7b9e9c7e3799485b8b9329 (patch) | |
tree | 7d152cfbd7b7fb2304e5a75daee8cdb39aa7ca64 /drivers/staging | |
parent | c750665850dfed34d3ff0f73ddf367cc7b729b77 (diff) |
staging/easycap: add first level indentation to easycap_sound.c
Add the first level indentation to easycap_sound.c with astyle -t8.
41 lines over 80 characters were left out for further fix
Cc: Mike Thomas <rmthomas@sciolus.org>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/easycap/easycap_sound.c | 1164 |
1 files changed, 572 insertions, 592 deletions
diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c index 0d647c81ed5..86b9ae0366d 100644 --- a/drivers/staging/easycap/easycap_sound.c +++ b/drivers/staging/easycap/easycap_sound.c | |||
@@ -47,8 +47,9 @@ static const struct snd_pcm_hardware alsa_hardware = { | |||
47 | .rate_max = 48000, | 47 | .rate_max = 48000, |
48 | .channels_min = 2, | 48 | .channels_min = 2, |
49 | .channels_max = 2, | 49 | .channels_max = 2, |
50 | .buffer_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * | 50 | .buffer_bytes_max = PAGE_SIZE * |
51 | AUDIO_FRAGMENT_MANY, | 51 | PAGES_PER_AUDIO_FRAGMENT * |
52 | AUDIO_FRAGMENT_MANY, | ||
52 | .period_bytes_min = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT, | 53 | .period_bytes_min = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT, |
53 | .period_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * 2, | 54 | .period_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * 2, |
54 | .periods_min = AUDIO_FRAGMENT_MANY, | 55 | .periods_min = AUDIO_FRAGMENT_MANY, |
@@ -67,64 +68,64 @@ static const struct snd_pcm_hardware alsa_hardware = { | |||
67 | void | 68 | void |
68 | easycap_alsa_complete(struct urb *purb) | 69 | easycap_alsa_complete(struct urb *purb) |
69 | { | 70 | { |
70 | struct easycap *peasycap; | 71 | struct easycap *peasycap; |
71 | struct snd_pcm_substream *pss; | 72 | struct snd_pcm_substream *pss; |
72 | struct snd_pcm_runtime *prt; | 73 | struct snd_pcm_runtime *prt; |
73 | int dma_bytes, fragment_bytes; | 74 | int dma_bytes, fragment_bytes; |
74 | int isfragment; | 75 | int isfragment; |
75 | u8 *p1, *p2; | 76 | u8 *p1, *p2; |
76 | s16 tmp; | 77 | s16 tmp; |
77 | int i, j, more, much, rc; | 78 | int i, j, more, much, rc; |
78 | #ifdef UPSAMPLE | 79 | #ifdef UPSAMPLE |
79 | int k; | 80 | int k; |
80 | s16 oldaudio, newaudio, delta; | 81 | s16 oldaudio, newaudio, delta; |
81 | #endif /*UPSAMPLE*/ | 82 | #endif /*UPSAMPLE*/ |
82 | 83 | ||
83 | JOT(16, "\n"); | 84 | JOT(16, "\n"); |
84 | 85 | ||
85 | if (NULL == purb) { | 86 | if (NULL == purb) { |
86 | SAY("ERROR: purb is NULL\n"); | 87 | SAY("ERROR: purb is NULL\n"); |
87 | return; | 88 | return; |
88 | } | 89 | } |
89 | peasycap = purb->context; | 90 | peasycap = purb->context; |
90 | if (NULL == peasycap) { | 91 | if (NULL == peasycap) { |
91 | SAY("ERROR: peasycap is NULL\n"); | 92 | SAY("ERROR: peasycap is NULL\n"); |
92 | return; | 93 | return; |
93 | } | 94 | } |
94 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 95 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
95 | SAY("ERROR: bad peasycap\n"); | 96 | SAY("ERROR: bad peasycap\n"); |
96 | return; | 97 | return; |
97 | } | 98 | } |
98 | much = 0; | 99 | much = 0; |
99 | if (peasycap->audio_idle) { | 100 | if (peasycap->audio_idle) { |
100 | JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n", | 101 | JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n", |
101 | peasycap->audio_idle, peasycap->audio_isoc_streaming); | 102 | peasycap->audio_idle, peasycap->audio_isoc_streaming); |
102 | if (peasycap->audio_isoc_streaming) | 103 | if (peasycap->audio_isoc_streaming) |
103 | goto resubmit; | 104 | goto resubmit; |
104 | } | 105 | } |
105 | /*---------------------------------------------------------------------------*/ | 106 | /*---------------------------------------------------------------------------*/ |
106 | pss = peasycap->psubstream; | 107 | pss = peasycap->psubstream; |
107 | if (NULL == pss) | 108 | if (NULL == pss) |
108 | goto resubmit; | 109 | goto resubmit; |
109 | prt = pss->runtime; | 110 | prt = pss->runtime; |
110 | if (NULL == prt) | 111 | if (NULL == prt) |
111 | goto resubmit; | 112 | goto resubmit; |
112 | dma_bytes = (int)prt->dma_bytes; | 113 | dma_bytes = (int)prt->dma_bytes; |
113 | if (0 == dma_bytes) | 114 | if (0 == dma_bytes) |
114 | goto resubmit; | 115 | goto resubmit; |
115 | fragment_bytes = 4 * ((int)prt->period_size); | 116 | fragment_bytes = 4 * ((int)prt->period_size); |
116 | if (0 == fragment_bytes) | 117 | if (0 == fragment_bytes) |
117 | goto resubmit; | 118 | goto resubmit; |
118 | /* -------------------------------------------------------------------------*/ | 119 | /* -------------------------------------------------------------------------*/ |
119 | if (purb->status) { | 120 | if (purb->status) { |
120 | if ((-ESHUTDOWN == purb->status) || (-ENOENT == purb->status)) { | 121 | if ((-ESHUTDOWN == purb->status) || (-ENOENT == purb->status)) { |
121 | JOM(16, "urb status -ESHUTDOWN or -ENOENT\n"); | 122 | JOM(16, "urb status -ESHUTDOWN or -ENOENT\n"); |
122 | return; | 123 | return; |
124 | } | ||
125 | SAM("ERROR: non-zero urb status: -%s: %d\n", | ||
126 | strerror(purb->status), purb->status); | ||
127 | goto resubmit; | ||
123 | } | 128 | } |
124 | SAM("ERROR: non-zero urb status: -%s: %d\n", | ||
125 | strerror(purb->status), purb->status); | ||
126 | goto resubmit; | ||
127 | } | ||
128 | /*---------------------------------------------------------------------------*/ | 129 | /*---------------------------------------------------------------------------*/ |
129 | /* | 130 | /* |
130 | * PROCEED HERE WHEN NO ERROR | 131 | * PROCEED HERE WHEN NO ERROR |
@@ -132,352 +133,342 @@ if (purb->status) { | |||
132 | /*---------------------------------------------------------------------------*/ | 133 | /*---------------------------------------------------------------------------*/ |
133 | 134 | ||
134 | #ifdef UPSAMPLE | 135 | #ifdef UPSAMPLE |
135 | oldaudio = peasycap->oldaudio; | 136 | oldaudio = peasycap->oldaudio; |
136 | #endif /*UPSAMPLE*/ | 137 | #endif /*UPSAMPLE*/ |
137 | 138 | ||
138 | for (i = 0; i < purb->number_of_packets; i++) { | 139 | for (i = 0; i < purb->number_of_packets; i++) { |
139 | if (purb->iso_frame_desc[i].status < 0) { | 140 | if (purb->iso_frame_desc[i].status < 0) { |
140 | SAM("-%s: %d\n", | 141 | SAM("-%s: %d\n", |
141 | strerror(purb->iso_frame_desc[i].status), | 142 | strerror(purb->iso_frame_desc[i].status), |
142 | purb->iso_frame_desc[i].status); | 143 | purb->iso_frame_desc[i].status); |
143 | } | 144 | } |
144 | if (!purb->iso_frame_desc[i].status) { | 145 | if (!purb->iso_frame_desc[i].status) { |
145 | more = purb->iso_frame_desc[i].actual_length; | 146 | more = purb->iso_frame_desc[i].actual_length; |
146 | if (!more) | 147 | if (!more) |
147 | peasycap->audio_mt++; | 148 | peasycap->audio_mt++; |
148 | else { | 149 | else { |
149 | if (peasycap->audio_mt) { | 150 | if (peasycap->audio_mt) { |
150 | JOM(12, "%4i empty audio urb frames\n", | 151 | JOM(12, "%4i empty audio urb frames\n", |
151 | peasycap->audio_mt); | 152 | peasycap->audio_mt); |
152 | peasycap->audio_mt = 0; | 153 | peasycap->audio_mt = 0; |
153 | } | 154 | } |
154 | 155 | ||
155 | p1 = (u8 *)(purb->transfer_buffer + | 156 | p1 = (u8 *)(purb->transfer_buffer + |
156 | purb->iso_frame_desc[i].offset); | 157 | purb->iso_frame_desc[i].offset); |
157 | 158 | ||
158 | /*---------------------------------------------------------------------------*/ | 159 | /* |
159 | /* | 160 | * COPY more BYTES FROM ISOC BUFFER |
160 | * COPY more BYTES FROM ISOC BUFFER TO THE DMA BUFFER, | 161 | * TO THE DMA BUFFER, CONVERTING |
161 | * CONVERTING 8-BIT MONO TO 16-BIT SIGNED LITTLE-ENDIAN SAMPLES IF NECESSARY | 162 | * 8-BIT MONO TO 16-BIT SIGNED |
162 | */ | 163 | * LITTLE-ENDIAN SAMPLES IF NECESSARY |
163 | /*---------------------------------------------------------------------------*/ | 164 | */ |
164 | while (more) { | 165 | while (more) { |
165 | if (0 > more) { | 166 | if (0 > more) { |
166 | SAM("MISTAKE: more is negative\n"); | 167 | SAM("MISTAKE: more is negative\n"); |
167 | return; | 168 | return; |
168 | } | 169 | } |
169 | much = dma_bytes - peasycap->dma_fill; | 170 | much = dma_bytes - peasycap->dma_fill; |
170 | if (0 > much) { | 171 | if (0 > much) { |
171 | SAM("MISTAKE: much is negative\n"); | 172 | SAM("MISTAKE: much is negative\n"); |
172 | return; | 173 | return; |
173 | } | 174 | } |
174 | if (0 == much) { | 175 | if (0 == much) { |
175 | peasycap->dma_fill = 0; | 176 | peasycap->dma_fill = 0; |
176 | peasycap->dma_next = fragment_bytes; | 177 | peasycap->dma_next = fragment_bytes; |
177 | JOM(8, "wrapped dma buffer\n"); | 178 | JOM(8, "wrapped dma buffer\n"); |
178 | } | 179 | } |
179 | if (false == peasycap->microphone) { | 180 | if (false == peasycap->microphone) { |
180 | if (much > more) | 181 | if (much > more) |
181 | much = more; | 182 | much = more; |
182 | memcpy(prt->dma_area + | 183 | memcpy(prt->dma_area + |
183 | peasycap->dma_fill, | 184 | peasycap->dma_fill, |
184 | p1, much); | 185 | p1, much); |
185 | p1 += much; | 186 | p1 += much; |
186 | more -= much; | 187 | more -= much; |
187 | } else { | 188 | } else { |
188 | #ifdef UPSAMPLE | 189 | #ifdef UPSAMPLE |
189 | if (much % 16) | 190 | if (much % 16) |
190 | JOM(8, "MISTAKE? much" | 191 | JOM(8, "MISTAKE? much" |
191 | " is not divisible by 16\n"); | 192 | " is not divisible by 16\n"); |
192 | if (much > (16 * | 193 | if (much > (16 * more)) |
193 | more)) | 194 | much = 16 * |
194 | much = 16 * | 195 | more; |
195 | more; | 196 | p2 = (u8 *)(prt->dma_area + peasycap->dma_fill); |
196 | p2 = (u8 *)(prt->dma_area + | 197 | |
197 | peasycap->dma_fill); | 198 | for (j = 0; j < (much/16); j++) { |
198 | 199 | newaudio = ((int) *p1) - 128; | |
199 | for (j = 0; j < (much/16); j++) { | 200 | newaudio = 128 * newaudio; |
200 | newaudio = ((int) *p1) - 128; | 201 | |
201 | newaudio = 128 * | 202 | delta = (newaudio - oldaudio) / 4; |
202 | newaudio; | 203 | tmp = oldaudio + delta; |
203 | 204 | ||
204 | delta = (newaudio - oldaudio) | 205 | for (k = 0; k < 4; k++) { |
205 | / 4; | 206 | *p2 = (0x00FF & tmp); |
206 | tmp = oldaudio + delta; | 207 | *(p2 + 1) = (0xFF00 & tmp) >> 8; |
207 | 208 | p2 += 2; | |
208 | for (k = 0; k < 4; k++) { | 209 | *p2 = (0x00FF & tmp); |
209 | *p2 = (0x00FF & tmp); | 210 | *(p2 + 1) = (0xFF00 & tmp) >> 8; |
210 | *(p2 + 1) = (0xFF00 & | 211 | p2 += 2; |
211 | tmp) >> 8; | 212 | tmp += delta; |
212 | p2 += 2; | 213 | } |
214 | p1++; | ||
215 | more--; | ||
216 | oldaudio = tmp; | ||
217 | } | ||
218 | #else /*!UPSAMPLE*/ | ||
219 | if (much > (2 * more)) | ||
220 | much = 2 * more; | ||
221 | p2 = (u8 *)(prt->dma_area + peasycap->dma_fill); | ||
222 | |||
223 | for (j = 0; j < (much / 2); j++) { | ||
224 | tmp = ((int) *p1) - 128; | ||
225 | tmp = 128 * tmp; | ||
213 | *p2 = (0x00FF & tmp); | 226 | *p2 = (0x00FF & tmp); |
214 | *(p2 + 1) = (0xFF00 & | 227 | *(p2 + 1) = (0xFF00 & tmp) >> 8; |
215 | tmp) >> 8; | 228 | p1++; |
216 | p2 += 2; | 229 | p2 += 2; |
217 | tmp += delta; | 230 | more--; |
218 | } | 231 | } |
219 | p1++; | ||
220 | more--; | ||
221 | oldaudio = tmp; | ||
222 | } | ||
223 | #else /*!UPSAMPLE*/ | ||
224 | if (much > (2 * more)) | ||
225 | much = 2 * more; | ||
226 | p2 = (u8 *)(prt->dma_area + | ||
227 | peasycap->dma_fill); | ||
228 | |||
229 | for (j = 0; j < (much / 2); j++) { | ||
230 | tmp = ((int) *p1) - 128; | ||
231 | tmp = 128 * tmp; | ||
232 | *p2 = (0x00FF & tmp); | ||
233 | *(p2 + 1) = (0xFF00 & tmp) >> | ||
234 | 8; | ||
235 | p1++; p2 += 2; | ||
236 | more--; | ||
237 | } | ||
238 | #endif /*UPSAMPLE*/ | 232 | #endif /*UPSAMPLE*/ |
239 | } | ||
240 | peasycap->dma_fill += much; | ||
241 | if (peasycap->dma_fill >= peasycap->dma_next) { | ||
242 | isfragment = peasycap->dma_fill / | ||
243 | fragment_bytes; | ||
244 | if (0 > isfragment) { | ||
245 | SAM("MISTAKE: isfragment is " | ||
246 | "negative\n"); | ||
247 | return; | ||
248 | } | 233 | } |
249 | peasycap->dma_read = (isfragment | 234 | peasycap->dma_fill += much; |
250 | - 1) * fragment_bytes; | 235 | if (peasycap->dma_fill >= peasycap->dma_next) { |
251 | peasycap->dma_next = (isfragment | 236 | isfragment = peasycap->dma_fill / fragment_bytes; |
252 | + 1) * fragment_bytes; | 237 | if (0 > isfragment) { |
253 | if (dma_bytes < peasycap->dma_next) { | 238 | SAM("MISTAKE: isfragment is " |
254 | peasycap->dma_next = | 239 | "negative\n"); |
255 | fragment_bytes; | 240 | return; |
256 | } | 241 | } |
257 | if (0 <= peasycap->dma_read) { | 242 | peasycap->dma_read = (isfragment - 1) * fragment_bytes; |
258 | JOM(8, "snd_pcm_period_elap" | 243 | peasycap->dma_next = (isfragment + 1) * fragment_bytes; |
259 | "sed(), %i=" | 244 | if (dma_bytes < peasycap->dma_next) |
260 | "isfragment\n", | 245 | peasycap->dma_next = fragment_bytes; |
261 | isfragment); | 246 | |
262 | snd_pcm_period_elapsed(pss); | 247 | if (0 <= peasycap->dma_read) { |
248 | JOM(8, "snd_pcm_period_elap" | ||
249 | "sed(), %i=" | ||
250 | "isfragment\n", | ||
251 | isfragment); | ||
252 | snd_pcm_period_elapsed(pss); | ||
253 | } | ||
263 | } | 254 | } |
264 | } | 255 | } |
265 | } | 256 | } |
257 | } else { | ||
258 | JOM(12, "discarding audio samples because " | ||
259 | "%i=purb->iso_frame_desc[i].status\n", | ||
260 | purb->iso_frame_desc[i].status); | ||
266 | } | 261 | } |
267 | } else { | ||
268 | JOM(12, "discarding audio samples because " | ||
269 | "%i=purb->iso_frame_desc[i].status\n", | ||
270 | purb->iso_frame_desc[i].status); | ||
271 | } | ||
272 | 262 | ||
273 | #ifdef UPSAMPLE | 263 | #ifdef UPSAMPLE |
274 | peasycap->oldaudio = oldaudio; | 264 | peasycap->oldaudio = oldaudio; |
275 | #endif /*UPSAMPLE*/ | 265 | #endif /*UPSAMPLE*/ |
276 | 266 | ||
277 | } | 267 | } |
278 | /*---------------------------------------------------------------------------*/ | 268 | /*---------------------------------------------------------------------------*/ |
279 | /* | 269 | /* |
280 | * RESUBMIT THIS URB | 270 | * RESUBMIT THIS URB |
281 | */ | 271 | */ |
282 | /*---------------------------------------------------------------------------*/ | 272 | /*---------------------------------------------------------------------------*/ |
283 | resubmit: | 273 | resubmit: |
284 | if (peasycap->audio_isoc_streaming) { | 274 | if (peasycap->audio_isoc_streaming) { |
285 | rc = usb_submit_urb(purb, GFP_ATOMIC); | 275 | rc = usb_submit_urb(purb, GFP_ATOMIC); |
286 | if (rc) { | 276 | if (rc) { |
287 | if ((-ENODEV != rc) && (-ENOENT != rc)) { | 277 | if ((-ENODEV != rc) && (-ENOENT != rc)) { |
288 | SAM("ERROR: while %i=audio_idle, " | 278 | SAM("ERROR: while %i=audio_idle, " |
289 | "usb_submit_urb() failed " | 279 | "usb_submit_urb() failed " |
290 | "with rc: -%s :%d\n", peasycap->audio_idle, | 280 | "with rc: -%s :%d\n", peasycap->audio_idle, |
291 | strerror(rc), rc); | 281 | strerror(rc), rc); |
282 | } | ||
283 | if (0 < peasycap->audio_isoc_streaming) | ||
284 | (peasycap->audio_isoc_streaming)--; | ||
292 | } | 285 | } |
293 | if (0 < peasycap->audio_isoc_streaming) | ||
294 | (peasycap->audio_isoc_streaming)--; | ||
295 | } | 286 | } |
296 | } | 287 | return; |
297 | return; | ||
298 | } | 288 | } |
299 | /*****************************************************************************/ | 289 | /*****************************************************************************/ |
300 | static int easycap_alsa_open(struct snd_pcm_substream *pss) | 290 | static int easycap_alsa_open(struct snd_pcm_substream *pss) |
301 | { | 291 | { |
302 | struct snd_pcm *psnd_pcm; | 292 | struct snd_pcm *psnd_pcm; |
303 | struct snd_card *psnd_card; | 293 | struct snd_card *psnd_card; |
304 | struct easycap *peasycap; | 294 | struct easycap *peasycap; |
305 | |||
306 | JOT(4, "\n"); | ||
307 | if (NULL == pss) { | ||
308 | SAY("ERROR: pss is NULL\n"); | ||
309 | return -EFAULT; | ||
310 | } | ||
311 | psnd_pcm = pss->pcm; | ||
312 | if (NULL == psnd_pcm) { | ||
313 | SAY("ERROR: psnd_pcm is NULL\n"); | ||
314 | return -EFAULT; | ||
315 | } | ||
316 | psnd_card = psnd_pcm->card; | ||
317 | if (NULL == psnd_card) { | ||
318 | SAY("ERROR: psnd_card is NULL\n"); | ||
319 | return -EFAULT; | ||
320 | } | ||
321 | 295 | ||
322 | peasycap = psnd_card->private_data; | 296 | JOT(4, "\n"); |
323 | if (NULL == peasycap) { | 297 | if (NULL == pss) { |
324 | SAY("ERROR: peasycap is NULL\n"); | 298 | SAY("ERROR: pss is NULL\n"); |
325 | return -EFAULT; | 299 | return -EFAULT; |
326 | } | 300 | } |
327 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 301 | psnd_pcm = pss->pcm; |
328 | SAY("ERROR: bad peasycap\n"); | 302 | if (NULL == psnd_pcm) { |
329 | return -EFAULT; | 303 | SAY("ERROR: psnd_pcm is NULL\n"); |
330 | } | 304 | return -EFAULT; |
331 | if (peasycap->psnd_card != psnd_card) { | 305 | } |
332 | SAM("ERROR: bad peasycap->psnd_card\n"); | 306 | psnd_card = psnd_pcm->card; |
333 | return -EFAULT; | 307 | if (NULL == psnd_card) { |
334 | } | 308 | SAY("ERROR: psnd_card is NULL\n"); |
335 | if (NULL != peasycap->psubstream) { | 309 | return -EFAULT; |
336 | SAM("ERROR: bad peasycap->psubstream\n"); | 310 | } |
337 | return -EFAULT; | 311 | |
338 | } | 312 | peasycap = psnd_card->private_data; |
339 | pss->private_data = peasycap; | 313 | if (NULL == peasycap) { |
340 | peasycap->psubstream = pss; | 314 | SAY("ERROR: peasycap is NULL\n"); |
341 | pss->runtime->hw = peasycap->alsa_hardware; | 315 | return -EFAULT; |
342 | pss->runtime->private_data = peasycap; | 316 | } |
343 | pss->private_data = peasycap; | 317 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
344 | 318 | SAY("ERROR: bad peasycap\n"); | |
345 | if (0 != easycap_sound_setup(peasycap)) { | 319 | return -EFAULT; |
346 | JOM(4, "ending unsuccessfully\n"); | 320 | } |
347 | return -EFAULT; | 321 | if (peasycap->psnd_card != psnd_card) { |
348 | } | 322 | SAM("ERROR: bad peasycap->psnd_card\n"); |
349 | JOM(4, "ending successfully\n"); | 323 | return -EFAULT; |
350 | return 0; | 324 | } |
325 | if (NULL != peasycap->psubstream) { | ||
326 | SAM("ERROR: bad peasycap->psubstream\n"); | ||
327 | return -EFAULT; | ||
328 | } | ||
329 | pss->private_data = peasycap; | ||
330 | peasycap->psubstream = pss; | ||
331 | pss->runtime->hw = peasycap->alsa_hardware; | ||
332 | pss->runtime->private_data = peasycap; | ||
333 | pss->private_data = peasycap; | ||
334 | |||
335 | if (0 != easycap_sound_setup(peasycap)) { | ||
336 | JOM(4, "ending unsuccessfully\n"); | ||
337 | return -EFAULT; | ||
338 | } | ||
339 | JOM(4, "ending successfully\n"); | ||
340 | return 0; | ||
351 | } | 341 | } |
352 | /*****************************************************************************/ | 342 | /*****************************************************************************/ |
353 | static int easycap_alsa_close(struct snd_pcm_substream *pss) | 343 | static int easycap_alsa_close(struct snd_pcm_substream *pss) |
354 | { | 344 | { |
355 | struct easycap *peasycap; | 345 | struct easycap *peasycap; |
356 | 346 | ||
357 | JOT(4, "\n"); | 347 | JOT(4, "\n"); |
358 | if (NULL == pss) { | 348 | if (NULL == pss) { |
359 | SAY("ERROR: pss is NULL\n"); | 349 | SAY("ERROR: pss is NULL\n"); |
360 | return -EFAULT; | 350 | return -EFAULT; |
361 | } | 351 | } |
362 | peasycap = snd_pcm_substream_chip(pss); | 352 | peasycap = snd_pcm_substream_chip(pss); |
363 | if (NULL == peasycap) { | 353 | if (NULL == peasycap) { |
364 | SAY("ERROR: peasycap is NULL\n"); | 354 | SAY("ERROR: peasycap is NULL\n"); |
365 | return -EFAULT; | 355 | return -EFAULT; |
366 | } | 356 | } |
367 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 357 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
368 | SAY("ERROR: bad peasycap\n"); | 358 | SAY("ERROR: bad peasycap\n"); |
369 | return -EFAULT; | 359 | return -EFAULT; |
370 | } | 360 | } |
371 | pss->private_data = NULL; | 361 | pss->private_data = NULL; |
372 | peasycap->psubstream = NULL; | 362 | peasycap->psubstream = NULL; |
373 | JOT(4, "ending successfully\n"); | 363 | JOT(4, "ending successfully\n"); |
374 | return 0; | 364 | return 0; |
375 | } | 365 | } |
376 | /*****************************************************************************/ | 366 | /*****************************************************************************/ |
377 | static int easycap_alsa_vmalloc(struct snd_pcm_substream *pss, size_t sz) | 367 | static int easycap_alsa_vmalloc(struct snd_pcm_substream *pss, size_t sz) |
378 | { | 368 | { |
379 | struct snd_pcm_runtime *prt; | 369 | struct snd_pcm_runtime *prt; |
380 | JOT(4, "\n"); | 370 | JOT(4, "\n"); |
381 | 371 | ||
382 | if (NULL == pss) { | 372 | if (NULL == pss) { |
383 | SAY("ERROR: pss is NULL\n"); | 373 | SAY("ERROR: pss is NULL\n"); |
384 | return -EFAULT; | 374 | return -EFAULT; |
385 | } | 375 | } |
386 | prt = pss->runtime; | 376 | prt = pss->runtime; |
387 | if (NULL == prt) { | 377 | if (NULL == prt) { |
388 | SAY("ERROR: substream.runtime is NULL\n"); | 378 | SAY("ERROR: substream.runtime is NULL\n"); |
389 | return -EFAULT; | 379 | return -EFAULT; |
390 | } | 380 | } |
391 | if (prt->dma_area) { | 381 | if (prt->dma_area) { |
392 | if (prt->dma_bytes > sz) | 382 | if (prt->dma_bytes > sz) |
393 | return 0; | 383 | return 0; |
394 | vfree(prt->dma_area); | 384 | vfree(prt->dma_area); |
395 | } | 385 | } |
396 | prt->dma_area = vmalloc(sz); | 386 | prt->dma_area = vmalloc(sz); |
397 | if (NULL == prt->dma_area) | 387 | if (NULL == prt->dma_area) |
398 | return -ENOMEM; | 388 | return -ENOMEM; |
399 | prt->dma_bytes = sz; | 389 | prt->dma_bytes = sz; |
400 | return 0; | 390 | return 0; |
401 | } | 391 | } |
402 | /*****************************************************************************/ | 392 | /*****************************************************************************/ |
403 | static int easycap_alsa_hw_params(struct snd_pcm_substream *pss, | 393 | static int easycap_alsa_hw_params(struct snd_pcm_substream *pss, |
404 | struct snd_pcm_hw_params *phw) | 394 | struct snd_pcm_hw_params *phw) |
405 | { | 395 | { |
406 | int rc; | 396 | int rc; |
407 | 397 | ||
408 | JOT(4, "%i\n", (params_buffer_bytes(phw))); | 398 | JOT(4, "%i\n", (params_buffer_bytes(phw))); |
409 | if (NULL == pss) { | 399 | if (NULL == pss) { |
410 | SAY("ERROR: pss is NULL\n"); | 400 | SAY("ERROR: pss is NULL\n"); |
411 | return -EFAULT; | 401 | return -EFAULT; |
412 | } | 402 | } |
413 | rc = easycap_alsa_vmalloc(pss, params_buffer_bytes(phw)); | 403 | rc = easycap_alsa_vmalloc(pss, params_buffer_bytes(phw)); |
414 | if (rc) | 404 | if (rc) |
415 | return rc; | 405 | return rc; |
416 | return 0; | 406 | return 0; |
417 | } | 407 | } |
418 | /*****************************************************************************/ | 408 | /*****************************************************************************/ |
419 | static int easycap_alsa_hw_free(struct snd_pcm_substream *pss) | 409 | static int easycap_alsa_hw_free(struct snd_pcm_substream *pss) |
420 | { | 410 | { |
421 | struct snd_pcm_runtime *prt; | 411 | struct snd_pcm_runtime *prt; |
422 | JOT(4, "\n"); | 412 | JOT(4, "\n"); |
423 | 413 | ||
424 | if (NULL == pss) { | 414 | if (NULL == pss) { |
425 | SAY("ERROR: pss is NULL\n"); | 415 | SAY("ERROR: pss is NULL\n"); |
426 | return -EFAULT; | 416 | return -EFAULT; |
427 | } | 417 | } |
428 | prt = pss->runtime; | 418 | prt = pss->runtime; |
429 | if (NULL == prt) { | 419 | if (NULL == prt) { |
430 | SAY("ERROR: substream.runtime is NULL\n"); | 420 | SAY("ERROR: substream.runtime is NULL\n"); |
431 | return -EFAULT; | 421 | return -EFAULT; |
432 | } | 422 | } |
433 | if (NULL != prt->dma_area) { | 423 | if (NULL != prt->dma_area) { |
434 | JOT(8, "prt->dma_area = %p\n", prt->dma_area); | 424 | JOT(8, "prt->dma_area = %p\n", prt->dma_area); |
435 | vfree(prt->dma_area); | 425 | vfree(prt->dma_area); |
436 | prt->dma_area = NULL; | 426 | prt->dma_area = NULL; |
437 | } else | 427 | } else |
438 | JOT(8, "dma_area already freed\n"); | 428 | JOT(8, "dma_area already freed\n"); |
439 | return 0; | 429 | return 0; |
440 | } | 430 | } |
441 | /*****************************************************************************/ | 431 | /*****************************************************************************/ |
442 | static int easycap_alsa_prepare(struct snd_pcm_substream *pss) | 432 | static int easycap_alsa_prepare(struct snd_pcm_substream *pss) |
443 | { | 433 | { |
444 | struct easycap *peasycap; | 434 | struct easycap *peasycap; |
445 | struct snd_pcm_runtime *prt; | 435 | struct snd_pcm_runtime *prt; |
446 | 436 | ||
447 | JOT(4, "\n"); | 437 | JOT(4, "\n"); |
448 | if (NULL == pss) { | 438 | if (NULL == pss) { |
449 | SAY("ERROR: pss is NULL\n"); | 439 | SAY("ERROR: pss is NULL\n"); |
450 | return -EFAULT; | 440 | return -EFAULT; |
451 | } | 441 | } |
452 | prt = pss->runtime; | 442 | prt = pss->runtime; |
453 | peasycap = snd_pcm_substream_chip(pss); | 443 | peasycap = snd_pcm_substream_chip(pss); |
454 | if (NULL == peasycap) { | 444 | if (NULL == peasycap) { |
455 | SAY("ERROR: peasycap is NULL\n"); | 445 | SAY("ERROR: peasycap is NULL\n"); |
456 | return -EFAULT; | 446 | return -EFAULT; |
457 | } | 447 | } |
458 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 448 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
459 | SAY("ERROR: bad peasycap\n"); | 449 | SAY("ERROR: bad peasycap\n"); |
460 | return -EFAULT; | 450 | return -EFAULT; |
461 | } | 451 | } |
462 | 452 | ||
463 | JOM(16, "ALSA decides %8i Hz=rate\n", (int)pss->runtime->rate); | 453 | JOM(16, "ALSA decides %8i Hz=rate\n", pss->runtime->rate); |
464 | JOM(16, "ALSA decides %8i =period_size\n", (int)pss->runtime->period_size); | 454 | JOM(16, "ALSA decides %8ld =period_size\n", pss->runtime->period_size); |
465 | JOM(16, "ALSA decides %8i =periods\n", (int)pss->runtime->periods); | 455 | JOM(16, "ALSA decides %8i =periods\n", pss->runtime->periods); |
466 | JOM(16, "ALSA decides %8i =buffer_size\n", (int)pss->runtime->buffer_size); | 456 | JOM(16, "ALSA decides %8ld =buffer_size\n", pss->runtime->buffer_size); |
467 | JOM(16, "ALSA decides %8i =dma_bytes\n", (int)pss->runtime->dma_bytes); | 457 | JOM(16, "ALSA decides %8zd =dma_bytes\n", pss->runtime->dma_bytes); |
468 | JOM(16, "ALSA decides %8i =boundary\n", (int)pss->runtime->boundary); | 458 | JOM(16, "ALSA decides %8ld =boundary\n", pss->runtime->boundary); |
469 | JOM(16, "ALSA decides %8i =period_step\n", (int)pss->runtime->period_step); | 459 | JOM(16, "ALSA decides %8i =period_step\n", pss->runtime->period_step); |
470 | JOM(16, "ALSA decides %8i =sample_bits\n", (int)pss->runtime->sample_bits); | 460 | JOM(16, "ALSA decides %8i =sample_bits\n", pss->runtime->sample_bits); |
471 | JOM(16, "ALSA decides %8i =frame_bits\n", (int)pss->runtime->frame_bits); | 461 | JOM(16, "ALSA decides %8i =frame_bits\n", pss->runtime->frame_bits); |
472 | JOM(16, "ALSA decides %8i =min_align\n", (int)pss->runtime->min_align); | 462 | JOM(16, "ALSA decides %8ld =min_align\n", pss->runtime->min_align); |
473 | JOM(12, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base); | 463 | JOM(12, "ALSA decides %8ld =hw_ptr_base\n", pss->runtime->hw_ptr_base); |
474 | JOM(12, "ALSA decides %8i =hw_ptr_interrupt\n", | 464 | JOM(12, "ALSA decides %8ld =hw_ptr_interrupt\n", |
475 | (int)pss->runtime->hw_ptr_interrupt); | 465 | pss->runtime->hw_ptr_interrupt); |
476 | if (prt->dma_bytes != 4 * ((int)prt->period_size) * ((int)prt->periods)) { | 466 | |
477 | SAY("MISTAKE: unexpected ALSA parameters\n"); | 467 | if (prt->dma_bytes != 4 * ((int)prt->period_size) * ((int)prt->periods)) { |
478 | return -ENOENT; | 468 | SAY("MISTAKE: unexpected ALSA parameters\n"); |
479 | } | 469 | return -ENOENT; |
480 | return 0; | 470 | } |
471 | return 0; | ||
481 | } | 472 | } |
482 | /*****************************************************************************/ | 473 | /*****************************************************************************/ |
483 | static int easycap_alsa_ack(struct snd_pcm_substream *pss) | 474 | static int easycap_alsa_ack(struct snd_pcm_substream *pss) |
@@ -487,81 +478,81 @@ static int easycap_alsa_ack(struct snd_pcm_substream *pss) | |||
487 | /*****************************************************************************/ | 478 | /*****************************************************************************/ |
488 | static int easycap_alsa_trigger(struct snd_pcm_substream *pss, int cmd) | 479 | static int easycap_alsa_trigger(struct snd_pcm_substream *pss, int cmd) |
489 | { | 480 | { |
490 | struct easycap *peasycap; | 481 | struct easycap *peasycap; |
491 | int retval; | 482 | int retval; |
492 | |||
493 | JOT(4, "%i=cmd cf %i=START %i=STOP\n", cmd, SNDRV_PCM_TRIGGER_START, | ||
494 | SNDRV_PCM_TRIGGER_STOP); | ||
495 | if (NULL == pss) { | ||
496 | SAY("ERROR: pss is NULL\n"); | ||
497 | return -EFAULT; | ||
498 | } | ||
499 | peasycap = snd_pcm_substream_chip(pss); | ||
500 | if (NULL == peasycap) { | ||
501 | SAY("ERROR: peasycap is NULL\n"); | ||
502 | return -EFAULT; | ||
503 | } | ||
504 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | ||
505 | SAY("ERROR: bad peasycap\n"); | ||
506 | return -EFAULT; | ||
507 | } | ||
508 | 483 | ||
509 | switch (cmd) { | 484 | JOT(4, "%i=cmd cf %i=START %i=STOP\n", cmd, SNDRV_PCM_TRIGGER_START, |
510 | case SNDRV_PCM_TRIGGER_START: { | 485 | SNDRV_PCM_TRIGGER_STOP); |
511 | peasycap->audio_idle = 0; | 486 | if (NULL == pss) { |
512 | break; | 487 | SAY("ERROR: pss is NULL\n"); |
513 | } | 488 | return -EFAULT; |
514 | case SNDRV_PCM_TRIGGER_STOP: { | 489 | } |
515 | peasycap->audio_idle = 1; | 490 | peasycap = snd_pcm_substream_chip(pss); |
516 | break; | 491 | if (NULL == peasycap) { |
517 | } | 492 | SAY("ERROR: peasycap is NULL\n"); |
518 | default: | 493 | return -EFAULT; |
519 | retval = -EINVAL; | 494 | } |
520 | } | 495 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
521 | return 0; | 496 | SAY("ERROR: bad peasycap\n"); |
497 | return -EFAULT; | ||
498 | } | ||
499 | |||
500 | switch (cmd) { | ||
501 | case SNDRV_PCM_TRIGGER_START: { | ||
502 | peasycap->audio_idle = 0; | ||
503 | break; | ||
504 | } | ||
505 | case SNDRV_PCM_TRIGGER_STOP: { | ||
506 | peasycap->audio_idle = 1; | ||
507 | break; | ||
508 | } | ||
509 | default: | ||
510 | retval = -EINVAL; | ||
511 | } | ||
512 | return 0; | ||
522 | } | 513 | } |
523 | /*****************************************************************************/ | 514 | /*****************************************************************************/ |
524 | static snd_pcm_uframes_t easycap_alsa_pointer(struct snd_pcm_substream *pss) | 515 | static snd_pcm_uframes_t easycap_alsa_pointer(struct snd_pcm_substream *pss) |
525 | { | 516 | { |
526 | struct easycap *peasycap; | 517 | struct easycap *peasycap; |
527 | snd_pcm_uframes_t offset; | 518 | snd_pcm_uframes_t offset; |
528 | 519 | ||
529 | JOT(16, "\n"); | 520 | JOT(16, "\n"); |
530 | if (NULL == pss) { | 521 | if (NULL == pss) { |
531 | SAY("ERROR: pss is NULL\n"); | 522 | SAY("ERROR: pss is NULL\n"); |
532 | return -EFAULT; | 523 | return -EFAULT; |
533 | } | 524 | } |
534 | peasycap = snd_pcm_substream_chip(pss); | 525 | peasycap = snd_pcm_substream_chip(pss); |
535 | if (NULL == peasycap) { | 526 | if (NULL == peasycap) { |
536 | SAY("ERROR: peasycap is NULL\n"); | 527 | SAY("ERROR: peasycap is NULL\n"); |
537 | return -EFAULT; | 528 | return -EFAULT; |
538 | } | 529 | } |
539 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 530 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
540 | SAY("ERROR: bad peasycap\n"); | 531 | SAY("ERROR: bad peasycap\n"); |
541 | return -EFAULT; | 532 | return -EFAULT; |
542 | } | 533 | } |
543 | if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) { | 534 | if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) { |
544 | JOM(8, "returning -EIO because " | 535 | JOM(8, "returning -EIO because " |
545 | "%i=audio_idle %i=audio_eof\n", | 536 | "%i=audio_idle %i=audio_eof\n", |
546 | peasycap->audio_idle, peasycap->audio_eof); | 537 | peasycap->audio_idle, peasycap->audio_eof); |
547 | return -EIO; | 538 | return -EIO; |
548 | } | 539 | } |
549 | /*---------------------------------------------------------------------------*/ | 540 | /*---------------------------------------------------------------------------*/ |
550 | if (0 > peasycap->dma_read) { | 541 | if (0 > peasycap->dma_read) { |
551 | JOM(8, "returning -EBUSY\n"); | 542 | JOM(8, "returning -EBUSY\n"); |
552 | return -EBUSY; | 543 | return -EBUSY; |
553 | } | 544 | } |
554 | offset = ((snd_pcm_uframes_t)peasycap->dma_read)/4; | 545 | offset = ((snd_pcm_uframes_t)peasycap->dma_read)/4; |
555 | JOM(8, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base); | 546 | JOM(8, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base); |
556 | JOM(8, "ALSA decides %8i =hw_ptr_interrupt\n", | 547 | JOM(8, "ALSA decides %8i =hw_ptr_interrupt\n", |
557 | (int)pss->runtime->hw_ptr_interrupt); | 548 | (int)pss->runtime->hw_ptr_interrupt); |
558 | JOM(8, "%7i=offset %7i=dma_read %7i=dma_next\n", | 549 | JOM(8, "%7i=offset %7i=dma_read %7i=dma_next\n", |
559 | (int)offset, peasycap->dma_read, peasycap->dma_next); | 550 | (int)offset, peasycap->dma_read, peasycap->dma_next); |
560 | return offset; | 551 | return offset; |
561 | } | 552 | } |
562 | /*****************************************************************************/ | 553 | /*****************************************************************************/ |
563 | static struct page *easycap_alsa_page(struct snd_pcm_substream *pss, | 554 | static struct page * |
564 | unsigned long offset) | 555 | easycap_alsa_page(struct snd_pcm_substream *pss, unsigned long offset) |
565 | { | 556 | { |
566 | return vmalloc_to_page(pss->runtime->dma_area + offset); | 557 | return vmalloc_to_page(pss->runtime->dma_area + offset); |
567 | } | 558 | } |
@@ -589,37 +580,36 @@ static struct snd_pcm_ops easycap_alsa_pcm_ops = { | |||
589 | /*---------------------------------------------------------------------------*/ | 580 | /*---------------------------------------------------------------------------*/ |
590 | int easycap_alsa_probe(struct easycap *peasycap) | 581 | int easycap_alsa_probe(struct easycap *peasycap) |
591 | { | 582 | { |
592 | int rc; | 583 | int rc; |
593 | struct snd_card *psnd_card; | 584 | struct snd_card *psnd_card; |
594 | struct snd_pcm *psnd_pcm; | 585 | struct snd_pcm *psnd_pcm; |
595 | 586 | ||
596 | if (NULL == peasycap) { | 587 | if (NULL == peasycap) { |
597 | SAY("ERROR: peasycap is NULL\n"); | 588 | SAY("ERROR: peasycap is NULL\n"); |
598 | return -ENODEV; | 589 | return -ENODEV; |
599 | } | 590 | } |
600 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { | 591 | if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { |
601 | SAY("ERROR: bad peasycap\n"); | 592 | SAY("ERROR: bad peasycap\n"); |
602 | return -EFAULT; | 593 | return -EFAULT; |
603 | } | 594 | } |
604 | if (0 > peasycap->minor) { | 595 | if (0 > peasycap->minor) { |
605 | SAY("ERROR: no minor\n"); | 596 | SAY("ERROR: no minor\n"); |
606 | return -ENODEV; | 597 | return -ENODEV; |
607 | } | 598 | } |
608 | 599 | ||
609 | peasycap->alsa_hardware = alsa_hardware; | 600 | peasycap->alsa_hardware = alsa_hardware; |
610 | if (true == peasycap->microphone) { | 601 | if (true == peasycap->microphone) { |
611 | peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_32000; | 602 | peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_32000; |
612 | peasycap->alsa_hardware.rate_min = 32000; | 603 | peasycap->alsa_hardware.rate_min = 32000; |
613 | peasycap->alsa_hardware.rate_max = 32000; | 604 | peasycap->alsa_hardware.rate_max = 32000; |
614 | } else { | 605 | } else { |
615 | peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_48000; | 606 | peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_48000; |
616 | peasycap->alsa_hardware.rate_min = 48000; | 607 | peasycap->alsa_hardware.rate_min = 48000; |
617 | peasycap->alsa_hardware.rate_max = 48000; | 608 | peasycap->alsa_hardware.rate_max = 48000; |
618 | } | 609 | } |
619 | 610 | ||
620 | if (0 != snd_card_create(SNDRV_DEFAULT_IDX1, "easycap_alsa", | 611 | if (0 != snd_card_create(SNDRV_DEFAULT_IDX1, "easycap_alsa", |
621 | THIS_MODULE, 0, | 612 | THIS_MODULE, 0, &psnd_card)) { |
622 | &psnd_card)) { | ||
623 | SAY("ERROR: Cannot do ALSA snd_card_create()\n"); | 613 | SAY("ERROR: Cannot do ALSA snd_card_create()\n"); |
624 | return -EFAULT; | 614 | return -EFAULT; |
625 | } | 615 | } |
@@ -641,7 +631,7 @@ if (true == peasycap->microphone) { | |||
641 | } | 631 | } |
642 | 632 | ||
643 | snd_pcm_set_ops(psnd_pcm, SNDRV_PCM_STREAM_CAPTURE, | 633 | snd_pcm_set_ops(psnd_pcm, SNDRV_PCM_STREAM_CAPTURE, |
644 | &easycap_alsa_pcm_ops); | 634 | &easycap_alsa_pcm_ops); |
645 | psnd_pcm->info_flags = 0; | 635 | psnd_pcm->info_flags = 0; |
646 | strcpy(&psnd_pcm->name[0], &psnd_card->id[0]); | 636 | strcpy(&psnd_pcm->name[0], &psnd_card->id[0]); |
647 | psnd_pcm->private_data = peasycap; | 637 | psnd_pcm->private_data = peasycap; |
@@ -654,10 +644,10 @@ if (true == peasycap->microphone) { | |||
654 | snd_card_free(psnd_card); | 644 | snd_card_free(psnd_card); |
655 | return -EFAULT; | 645 | return -EFAULT; |
656 | } else { | 646 | } else { |
657 | ; | 647 | ; |
658 | SAM("registered %s\n", &psnd_card->id[0]); | 648 | SAM("registered %s\n", &psnd_card->id[0]); |
659 | } | 649 | } |
660 | return 0; | 650 | return 0; |
661 | } | 651 | } |
662 | #endif /*! CONFIG_EASYCAP_OSS */ | 652 | #endif /*! CONFIG_EASYCAP_OSS */ |
663 | 653 | ||
@@ -675,50 +665,50 @@ return 0; | |||
675 | int | 665 | int |
676 | easycap_sound_setup(struct easycap *peasycap) | 666 | easycap_sound_setup(struct easycap *peasycap) |
677 | { | 667 | { |
678 | int rc; | 668 | int rc; |
679 | 669 | ||
680 | JOM(4, "starting initialization\n"); | 670 | JOM(4, "starting initialization\n"); |
681 | 671 | ||
682 | if (NULL == peasycap) { | 672 | if (NULL == peasycap) { |
683 | SAY("ERROR: peasycap is NULL.\n"); | 673 | SAY("ERROR: peasycap is NULL.\n"); |
684 | return -EFAULT; | 674 | return -EFAULT; |
685 | } | 675 | } |
686 | if (NULL == peasycap->pusb_device) { | 676 | if (NULL == peasycap->pusb_device) { |
687 | SAM("ERROR: peasycap->pusb_device is NULL\n"); | 677 | SAM("ERROR: peasycap->pusb_device is NULL\n"); |
688 | return -ENODEV; | 678 | return -ENODEV; |
689 | } | 679 | } |
690 | JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device); | 680 | JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device); |
691 | 681 | ||
692 | rc = audio_setup(peasycap); | 682 | rc = audio_setup(peasycap); |
693 | JOM(8, "audio_setup() returned %i\n", rc); | 683 | JOM(8, "audio_setup() returned %i\n", rc); |
694 | 684 | ||
695 | if (NULL == peasycap->pusb_device) { | 685 | if (NULL == peasycap->pusb_device) { |
696 | SAM("ERROR: peasycap->pusb_device has become NULL\n"); | 686 | SAM("ERROR: peasycap->pusb_device has become NULL\n"); |
697 | return -ENODEV; | 687 | return -ENODEV; |
698 | } | 688 | } |
699 | /*---------------------------------------------------------------------------*/ | 689 | /*---------------------------------------------------------------------------*/ |
700 | if (NULL == peasycap->pusb_device) { | 690 | if (NULL == peasycap->pusb_device) { |
701 | SAM("ERROR: peasycap->pusb_device has become NULL\n"); | 691 | SAM("ERROR: peasycap->pusb_device has become NULL\n"); |
702 | return -ENODEV; | 692 | return -ENODEV; |
703 | } | 693 | } |
704 | rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, | 694 | rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, |
705 | peasycap->audio_altsetting_on); | 695 | peasycap->audio_altsetting_on); |
706 | JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface, | 696 | JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface, |
707 | peasycap->audio_altsetting_on, rc); | 697 | peasycap->audio_altsetting_on, rc); |
708 | 698 | ||
709 | rc = wakeup_device(peasycap->pusb_device); | 699 | rc = wakeup_device(peasycap->pusb_device); |
710 | JOM(8, "wakeup_device() returned %i\n", rc); | 700 | JOM(8, "wakeup_device() returned %i\n", rc); |
711 | 701 | ||
712 | peasycap->audio_eof = 0; | 702 | peasycap->audio_eof = 0; |
713 | peasycap->audio_idle = 0; | 703 | peasycap->audio_idle = 0; |
714 | 704 | ||
715 | peasycap->timeval1.tv_sec = 0; | 705 | peasycap->timeval1.tv_sec = 0; |
716 | peasycap->timeval1.tv_usec = 0; | 706 | peasycap->timeval1.tv_usec = 0; |
717 | 707 | ||
718 | submit_audio_urbs(peasycap); | 708 | submit_audio_urbs(peasycap); |
719 | 709 | ||
720 | JOM(4, "finished initialization\n"); | 710 | JOM(4, "finished initialization\n"); |
721 | return 0; | 711 | return 0; |
722 | } | 712 | } |
723 | /*****************************************************************************/ | 713 | /*****************************************************************************/ |
724 | /*---------------------------------------------------------------------------*/ | 714 | /*---------------------------------------------------------------------------*/ |
@@ -729,112 +719,103 @@ return 0; | |||
729 | int | 719 | int |
730 | submit_audio_urbs(struct easycap *peasycap) | 720 | submit_audio_urbs(struct easycap *peasycap) |
731 | { | 721 | { |
732 | struct data_urb *pdata_urb; | 722 | struct data_urb *pdata_urb; |
733 | struct urb *purb; | 723 | struct urb *purb; |
734 | struct list_head *plist_head; | 724 | struct list_head *plist_head; |
735 | int j, isbad, nospc, m, rc; | 725 | int j, isbad, nospc, m, rc; |
736 | int isbuf; | 726 | int isbuf; |
737 | 727 | ||
738 | if (NULL == peasycap) { | 728 | if (NULL == peasycap) { |
739 | SAY("ERROR: peasycap is NULL\n"); | 729 | SAY("ERROR: peasycap is NULL\n"); |
740 | return -EFAULT; | 730 | return -EFAULT; |
741 | } | 731 | } |
742 | if (NULL == peasycap->purb_audio_head) { | 732 | if (NULL == peasycap->purb_audio_head) { |
743 | SAM("ERROR: peasycap->urb_audio_head uninitialized\n"); | 733 | SAM("ERROR: peasycap->urb_audio_head uninitialized\n"); |
744 | return -EFAULT; | 734 | return -EFAULT; |
745 | } | 735 | } |
746 | if (NULL == peasycap->pusb_device) { | 736 | if (NULL == peasycap->pusb_device) { |
747 | SAM("ERROR: peasycap->pusb_device is NULL\n"); | 737 | SAM("ERROR: peasycap->pusb_device is NULL\n"); |
748 | return -EFAULT; | 738 | return -EFAULT; |
749 | } | 739 | } |
750 | if (!peasycap->audio_isoc_streaming) { | 740 | if (!peasycap->audio_isoc_streaming) { |
751 | JOM(4, "initial submission of all audio urbs\n"); | 741 | JOM(4, "initial submission of all audio urbs\n"); |
752 | rc = usb_set_interface(peasycap->pusb_device, | 742 | rc = usb_set_interface(peasycap->pusb_device, |
753 | peasycap->audio_interface, | 743 | peasycap->audio_interface, |
754 | peasycap->audio_altsetting_on); | 744 | peasycap->audio_altsetting_on); |
755 | JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", | 745 | JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", |
756 | peasycap->audio_interface, | 746 | peasycap->audio_interface, |
757 | peasycap->audio_altsetting_on, rc); | 747 | peasycap->audio_altsetting_on, rc); |
758 | 748 | ||
759 | isbad = 0; nospc = 0; m = 0; | 749 | isbad = 0; |
760 | list_for_each(plist_head, (peasycap->purb_audio_head)) { | 750 | nospc = 0; |
761 | pdata_urb = list_entry(plist_head, struct data_urb, list_head); | 751 | m = 0; |
762 | if (NULL != pdata_urb) { | 752 | list_for_each(plist_head, (peasycap->purb_audio_head)) { |
763 | purb = pdata_urb->purb; | 753 | pdata_urb = list_entry(plist_head, struct data_urb, list_head); |
764 | if (NULL != purb) { | 754 | if (NULL != pdata_urb) { |
765 | isbuf = pdata_urb->isbuf; | 755 | purb = pdata_urb->purb; |
766 | 756 | if (NULL != purb) { | |
767 | purb->interval = 1; | 757 | isbuf = pdata_urb->isbuf; |
768 | purb->dev = peasycap->pusb_device; | 758 | |
769 | purb->pipe = | 759 | purb->interval = 1; |
770 | usb_rcvisocpipe(peasycap->pusb_device, | 760 | purb->dev = peasycap->pusb_device; |
771 | peasycap->audio_endpointnumber); | 761 | purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, |
772 | purb->transfer_flags = URB_ISO_ASAP; | 762 | peasycap->audio_endpointnumber); |
773 | purb->transfer_buffer = | 763 | purb->transfer_flags = URB_ISO_ASAP; |
774 | peasycap->audio_isoc_buffer[isbuf].pgo; | 764 | purb->transfer_buffer = peasycap->audio_isoc_buffer[isbuf].pgo; |
775 | purb->transfer_buffer_length = | 765 | purb->transfer_buffer_length = peasycap->audio_isoc_buffer_size; |
776 | peasycap->audio_isoc_buffer_size; | ||
777 | #ifdef CONFIG_EASYCAP_OSS | 766 | #ifdef CONFIG_EASYCAP_OSS |
778 | purb->complete = easyoss_complete; | 767 | purb->complete = easyoss_complete; |
779 | #else /* CONFIG_EASYCAP_OSS */ | 768 | #else /* CONFIG_EASYCAP_OSS */ |
780 | purb->complete = easycap_alsa_complete; | 769 | purb->complete = easycap_alsa_complete; |
781 | #endif /* CONFIG_EASYCAP_OSS */ | 770 | #endif /* CONFIG_EASYCAP_OSS */ |
782 | purb->context = peasycap; | 771 | purb->context = peasycap; |
783 | purb->start_frame = 0; | 772 | purb->start_frame = 0; |
784 | purb->number_of_packets = | 773 | purb->number_of_packets = peasycap->audio_isoc_framesperdesc; |
785 | peasycap->audio_isoc_framesperdesc; | 774 | for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) { |
786 | for (j = 0; j < peasycap-> | 775 | purb->iso_frame_desc[j].offset = j * peasycap->audio_isoc_maxframesize; |
787 | audio_isoc_framesperdesc; | 776 | purb->iso_frame_desc[j].length = peasycap->audio_isoc_maxframesize; |
788 | j++) { | 777 | } |
789 | purb->iso_frame_desc[j].offset = j * | ||
790 | peasycap-> | ||
791 | audio_isoc_maxframesize; | ||
792 | purb->iso_frame_desc[j].length = | ||
793 | peasycap-> | ||
794 | audio_isoc_maxframesize; | ||
795 | } | ||
796 | 778 | ||
797 | rc = usb_submit_urb(purb, GFP_KERNEL); | 779 | rc = usb_submit_urb(purb, GFP_KERNEL); |
798 | if (rc) { | 780 | if (rc) { |
799 | isbad++; | 781 | isbad++; |
800 | SAM("ERROR: usb_submit_urb() failed" | 782 | SAM("ERROR: usb_submit_urb() failed" |
801 | " for urb with rc: -%s: %d\n", | 783 | " for urb with rc: -%s: %d\n", |
802 | strerror(rc), rc); | 784 | strerror(rc), rc); |
785 | } else { | ||
786 | m++; | ||
787 | } | ||
803 | } else { | 788 | } else { |
804 | m++; | 789 | isbad++; |
805 | } | 790 | } |
806 | } else { | 791 | } else { |
807 | isbad++; | 792 | isbad++; |
808 | } | 793 | } |
809 | } else { | ||
810 | isbad++; | ||
811 | } | 794 | } |
812 | } | 795 | if (nospc) { |
813 | if (nospc) { | 796 | SAM("-ENOSPC=usb_submit_urb() for %i urbs\n", nospc); |
814 | SAM("-ENOSPC=usb_submit_urb() for %i urbs\n", nospc); | 797 | SAM("..... possibly inadequate USB bandwidth\n"); |
815 | SAM("..... possibly inadequate USB bandwidth\n"); | 798 | peasycap->audio_eof = 1; |
816 | peasycap->audio_eof = 1; | 799 | } |
817 | } | 800 | if (isbad) { |
818 | if (isbad) { | 801 | JOM(4, "attempting cleanup instead of submitting\n"); |
819 | JOM(4, "attempting cleanup instead of submitting\n"); | 802 | list_for_each(plist_head, (peasycap->purb_audio_head)) { |
820 | list_for_each(plist_head, (peasycap->purb_audio_head)) { | 803 | pdata_urb = list_entry(plist_head, struct data_urb, list_head); |
821 | pdata_urb = list_entry(plist_head, struct data_urb, | 804 | if (NULL != pdata_urb) { |
822 | list_head); | 805 | purb = pdata_urb->purb; |
823 | if (NULL != pdata_urb) { | 806 | if (NULL != purb) |
824 | purb = pdata_urb->purb; | 807 | usb_kill_urb(purb); |
825 | if (NULL != purb) | 808 | } |
826 | usb_kill_urb(purb); | ||
827 | } | 809 | } |
810 | peasycap->audio_isoc_streaming = 0; | ||
811 | } else { | ||
812 | peasycap->audio_isoc_streaming = m; | ||
813 | JOM(4, "submitted %i audio urbs\n", m); | ||
828 | } | 814 | } |
829 | peasycap->audio_isoc_streaming = 0; | 815 | } else |
830 | } else { | 816 | JOM(4, "already streaming audio urbs\n"); |
831 | peasycap->audio_isoc_streaming = m; | ||
832 | JOM(4, "submitted %i audio urbs\n", m); | ||
833 | } | ||
834 | } else | ||
835 | JOM(4, "already streaming audio urbs\n"); | ||
836 | 817 | ||
837 | return 0; | 818 | return 0; |
838 | } | 819 | } |
839 | /*****************************************************************************/ | 820 | /*****************************************************************************/ |
840 | /*---------------------------------------------------------------------------*/ | 821 | /*---------------------------------------------------------------------------*/ |
@@ -845,38 +826,37 @@ return 0; | |||
845 | int | 826 | int |
846 | kill_audio_urbs(struct easycap *peasycap) | 827 | kill_audio_urbs(struct easycap *peasycap) |
847 | { | 828 | { |
848 | int m; | 829 | int m; |
849 | struct list_head *plist_head; | 830 | struct list_head *plist_head; |
850 | struct data_urb *pdata_urb; | 831 | struct data_urb *pdata_urb; |
851 | 832 | ||
852 | if (NULL == peasycap) { | 833 | if (NULL == peasycap) { |
853 | SAY("ERROR: peasycap is NULL\n"); | 834 | SAY("ERROR: peasycap is NULL\n"); |
854 | return -EFAULT; | 835 | return -EFAULT; |
855 | } | 836 | } |
856 | if (peasycap->audio_isoc_streaming) { | 837 | if (peasycap->audio_isoc_streaming) { |
857 | if (NULL != peasycap->purb_audio_head) { | 838 | if (NULL != peasycap->purb_audio_head) { |
858 | peasycap->audio_isoc_streaming = 0; | 839 | peasycap->audio_isoc_streaming = 0; |
859 | JOM(4, "killing audio urbs\n"); | 840 | JOM(4, "killing audio urbs\n"); |
860 | m = 0; | 841 | m = 0; |
861 | list_for_each(plist_head, (peasycap->purb_audio_head)) { | 842 | list_for_each(plist_head, (peasycap->purb_audio_head)) { |
862 | pdata_urb = list_entry(plist_head, struct data_urb, | 843 | pdata_urb = list_entry(plist_head, struct data_urb, list_head); |
863 | list_head); | 844 | if (NULL != pdata_urb) { |
864 | if (NULL != pdata_urb) { | 845 | if (NULL != pdata_urb->purb) { |
865 | if (NULL != pdata_urb->purb) { | 846 | usb_kill_urb(pdata_urb->purb); |
866 | usb_kill_urb(pdata_urb->purb); | 847 | m++; |
867 | m++; | 848 | } |
868 | } | 849 | } |
869 | } | 850 | } |
851 | JOM(4, "%i audio urbs killed\n", m); | ||
852 | } else { | ||
853 | SAM("ERROR: peasycap->purb_audio_head is NULL\n"); | ||
854 | return -EFAULT; | ||
870 | } | 855 | } |
871 | JOM(4, "%i audio urbs killed\n", m); | ||
872 | } else { | 856 | } else { |
873 | SAM("ERROR: peasycap->purb_audio_head is NULL\n"); | 857 | JOM(8, "%i=audio_isoc_streaming, no audio urbs killed\n", |
874 | return -EFAULT; | 858 | peasycap->audio_isoc_streaming); |
875 | } | 859 | } |
876 | } else { | 860 | return 0; |
877 | JOM(8, "%i=audio_isoc_streaming, no audio urbs killed\n", | ||
878 | peasycap->audio_isoc_streaming); | ||
879 | } | ||
880 | return 0; | ||
881 | } | 861 | } |
882 | /*****************************************************************************/ | 862 | /*****************************************************************************/ |