diff options
Diffstat (limited to 'sound')
39 files changed, 360 insertions, 309 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index 4b20fa2b7e6d..17b8d47a5cd0 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -723,14 +723,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card, | |||
723 | { | 723 | { |
724 | struct snd_ctl_elem_value *control; | 724 | struct snd_ctl_elem_value *control; |
725 | int result; | 725 | int result; |
726 | 726 | ||
727 | control = kmalloc(sizeof(*control), GFP_KERNEL); | 727 | control = memdup_user(_control, sizeof(*control)); |
728 | if (control == NULL) | 728 | if (IS_ERR(control)) |
729 | return -ENOMEM; | 729 | return PTR_ERR(control); |
730 | if (copy_from_user(control, _control, sizeof(*control))) { | 730 | |
731 | kfree(control); | ||
732 | return -EFAULT; | ||
733 | } | ||
734 | snd_power_lock(card); | 731 | snd_power_lock(card); |
735 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); | 732 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); |
736 | if (result >= 0) | 733 | if (result >= 0) |
@@ -784,13 +781,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, | |||
784 | struct snd_card *card; | 781 | struct snd_card *card; |
785 | int result; | 782 | int result; |
786 | 783 | ||
787 | control = kmalloc(sizeof(*control), GFP_KERNEL); | 784 | control = memdup_user(_control, sizeof(*control)); |
788 | if (control == NULL) | 785 | if (IS_ERR(control)) |
789 | return -ENOMEM; | 786 | return PTR_ERR(control); |
790 | if (copy_from_user(control, _control, sizeof(*control))) { | 787 | |
791 | kfree(control); | ||
792 | return -EFAULT; | ||
793 | } | ||
794 | card = file->card; | 788 | card = file->card; |
795 | snd_power_lock(card); | 789 | snd_power_lock(card); |
796 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); | 790 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); |
@@ -916,13 +910,10 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, | |||
916 | if (op_flag > 0) { | 910 | if (op_flag > 0) { |
917 | if (size > 1024 * 128) /* sane value */ | 911 | if (size > 1024 * 128) /* sane value */ |
918 | return -EINVAL; | 912 | return -EINVAL; |
919 | new_data = kmalloc(size, GFP_KERNEL); | 913 | |
920 | if (new_data == NULL) | 914 | new_data = memdup_user(tlv, size); |
921 | return -ENOMEM; | 915 | if (IS_ERR(new_data)) |
922 | if (copy_from_user(new_data, tlv, size)) { | 916 | return PTR_ERR(new_data); |
923 | kfree(new_data); | ||
924 | return -EFAULT; | ||
925 | } | ||
926 | change = ue->tlv_data_size != size; | 917 | change = ue->tlv_data_size != size; |
927 | if (!change) | 918 | if (!change) |
928 | change = memcmp(ue->tlv_data, new_data, size); | 919 | change = memcmp(ue->tlv_data, new_data, size); |
diff --git a/sound/core/jack.c b/sound/core/jack.c index c8254c667c62..d54d1a05fe65 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -35,6 +35,9 @@ static int snd_jack_dev_free(struct snd_device *device) | |||
35 | { | 35 | { |
36 | struct snd_jack *jack = device->device_data; | 36 | struct snd_jack *jack = device->device_data; |
37 | 37 | ||
38 | if (jack->private_free) | ||
39 | jack->private_free(jack); | ||
40 | |||
38 | /* If the input device is registered with the input subsystem | 41 | /* If the input device is registered with the input subsystem |
39 | * then we need to use a different deallocator. */ | 42 | * then we need to use a different deallocator. */ |
40 | if (jack->registered) | 43 | if (jack->registered) |
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 36d7a5998234..08bfed594a83 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c | |||
@@ -232,14 +232,11 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, | |||
232 | if (! (runtime = substream->runtime)) | 232 | if (! (runtime = substream->runtime)) |
233 | return -ENOTTY; | 233 | return -ENOTTY; |
234 | 234 | ||
235 | data = kmalloc(sizeof(*data), GFP_KERNEL); | ||
236 | if (data == NULL) | ||
237 | return -ENOMEM; | ||
238 | /* only fifo_size is different, so just copy all */ | 235 | /* only fifo_size is different, so just copy all */ |
239 | if (copy_from_user(data, data32, sizeof(*data32))) { | 236 | data = memdup_user(data32, sizeof(*data32)); |
240 | err = -EFAULT; | 237 | if (IS_ERR(data)) |
241 | goto error; | 238 | return PTR_ERR(data); |
242 | } | 239 | |
243 | if (refine) | 240 | if (refine) |
244 | err = snd_pcm_hw_refine(substream, data); | 241 | err = snd_pcm_hw_refine(substream, data); |
245 | else | 242 | else |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index fbb2e391591e..63d088f2265f 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -209,9 +209,11 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
209 | { | 209 | { |
210 | struct snd_pcm_runtime *runtime = substream->runtime; | 210 | struct snd_pcm_runtime *runtime = substream->runtime; |
211 | snd_pcm_uframes_t pos; | 211 | snd_pcm_uframes_t pos; |
212 | snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt, hw_base; | 212 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_ptr_interrupt, hw_base; |
213 | snd_pcm_sframes_t delta; | 213 | snd_pcm_sframes_t hdelta, delta; |
214 | unsigned long jdelta; | ||
214 | 215 | ||
216 | old_hw_ptr = runtime->status->hw_ptr; | ||
215 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); | 217 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); |
216 | if (pos == SNDRV_PCM_POS_XRUN) { | 218 | if (pos == SNDRV_PCM_POS_XRUN) { |
217 | xrun(substream); | 219 | xrun(substream); |
@@ -247,7 +249,30 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
247 | new_hw_ptr = hw_base + pos; | 249 | new_hw_ptr = hw_base + pos; |
248 | } | 250 | } |
249 | } | 251 | } |
250 | if (delta > runtime->period_size) { | 252 | hdelta = new_hw_ptr - old_hw_ptr; |
253 | jdelta = jiffies - runtime->hw_ptr_jiffies; | ||
254 | if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { | ||
255 | delta = jdelta / | ||
256 | (((runtime->period_size * HZ) / runtime->rate) | ||
257 | + HZ/100); | ||
258 | hw_ptr_error(substream, | ||
259 | "hw_ptr skipping! [Q] " | ||
260 | "(pos=%ld, delta=%ld, period=%ld, " | ||
261 | "jdelta=%lu/%lu/%lu)\n", | ||
262 | (long)pos, (long)hdelta, | ||
263 | (long)runtime->period_size, jdelta, | ||
264 | ((hdelta * HZ) / runtime->rate), delta); | ||
265 | hw_ptr_interrupt = runtime->hw_ptr_interrupt + | ||
266 | runtime->period_size * delta; | ||
267 | if (hw_ptr_interrupt >= runtime->boundary) | ||
268 | hw_ptr_interrupt -= runtime->boundary; | ||
269 | /* rebase to interrupt position */ | ||
270 | hw_base = new_hw_ptr = hw_ptr_interrupt; | ||
271 | /* align hw_base to buffer_size */ | ||
272 | hw_base -= hw_base % runtime->buffer_size; | ||
273 | delta = 0; | ||
274 | } | ||
275 | if (delta > runtime->period_size + runtime->period_size / 2) { | ||
251 | hw_ptr_error(substream, | 276 | hw_ptr_error(substream, |
252 | "Lost interrupts? " | 277 | "Lost interrupts? " |
253 | "(stream=%i, delta=%ld, intr_ptr=%ld)\n", | 278 | "(stream=%i, delta=%ld, intr_ptr=%ld)\n", |
@@ -263,6 +288,7 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
263 | 288 | ||
264 | runtime->hw_ptr_base = hw_base; | 289 | runtime->hw_ptr_base = hw_base; |
265 | runtime->status->hw_ptr = new_hw_ptr; | 290 | runtime->status->hw_ptr = new_hw_ptr; |
291 | runtime->hw_ptr_jiffies = jiffies; | ||
266 | runtime->hw_ptr_interrupt = hw_ptr_interrupt; | 292 | runtime->hw_ptr_interrupt = hw_ptr_interrupt; |
267 | 293 | ||
268 | return snd_pcm_update_hw_ptr_post(substream, runtime); | 294 | return snd_pcm_update_hw_ptr_post(substream, runtime); |
@@ -275,6 +301,7 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
275 | snd_pcm_uframes_t pos; | 301 | snd_pcm_uframes_t pos; |
276 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; | 302 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; |
277 | snd_pcm_sframes_t delta; | 303 | snd_pcm_sframes_t delta; |
304 | unsigned long jdelta; | ||
278 | 305 | ||
279 | old_hw_ptr = runtime->status->hw_ptr; | 306 | old_hw_ptr = runtime->status->hw_ptr; |
280 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); | 307 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); |
@@ -286,14 +313,15 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
286 | new_hw_ptr = hw_base + pos; | 313 | new_hw_ptr = hw_base + pos; |
287 | 314 | ||
288 | delta = new_hw_ptr - old_hw_ptr; | 315 | delta = new_hw_ptr - old_hw_ptr; |
316 | jdelta = jiffies - runtime->hw_ptr_jiffies; | ||
289 | if (delta < 0) { | 317 | if (delta < 0) { |
290 | delta += runtime->buffer_size; | 318 | delta += runtime->buffer_size; |
291 | if (delta < 0) { | 319 | if (delta < 0) { |
292 | hw_ptr_error(substream, | 320 | hw_ptr_error(substream, |
293 | "Unexpected hw_pointer value [2] " | 321 | "Unexpected hw_pointer value [2] " |
294 | "(stream=%i, pos=%ld, old_ptr=%ld)\n", | 322 | "(stream=%i, pos=%ld, old_ptr=%ld, jdelta=%li)\n", |
295 | substream->stream, (long)pos, | 323 | substream->stream, (long)pos, |
296 | (long)old_hw_ptr); | 324 | (long)old_hw_ptr, jdelta); |
297 | return 0; | 325 | return 0; |
298 | } | 326 | } |
299 | hw_base += runtime->buffer_size; | 327 | hw_base += runtime->buffer_size; |
@@ -301,12 +329,13 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
301 | hw_base = 0; | 329 | hw_base = 0; |
302 | new_hw_ptr = hw_base + pos; | 330 | new_hw_ptr = hw_base + pos; |
303 | } | 331 | } |
304 | if (delta > runtime->period_size && runtime->periods > 1) { | 332 | if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { |
305 | hw_ptr_error(substream, | 333 | hw_ptr_error(substream, |
306 | "hw_ptr skipping! " | 334 | "hw_ptr skipping! " |
307 | "(pos=%ld, delta=%ld, period=%ld)\n", | 335 | "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu)\n", |
308 | (long)pos, (long)delta, | 336 | (long)pos, (long)delta, |
309 | (long)runtime->period_size); | 337 | (long)runtime->period_size, jdelta, |
338 | ((delta * HZ) / runtime->rate)); | ||
310 | return 0; | 339 | return 0; |
311 | } | 340 | } |
312 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 341 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
@@ -315,6 +344,7 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
315 | 344 | ||
316 | runtime->hw_ptr_base = hw_base; | 345 | runtime->hw_ptr_base = hw_base; |
317 | runtime->status->hw_ptr = new_hw_ptr; | 346 | runtime->status->hw_ptr = new_hw_ptr; |
347 | runtime->hw_ptr_jiffies = jiffies; | ||
318 | 348 | ||
319 | return snd_pcm_update_hw_ptr_post(substream, runtime); | 349 | return snd_pcm_update_hw_ptr_post(substream, runtime); |
320 | } | 350 | } |
@@ -1441,6 +1471,7 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, | |||
1441 | runtime->status->hw_ptr %= runtime->buffer_size; | 1471 | runtime->status->hw_ptr %= runtime->buffer_size; |
1442 | else | 1472 | else |
1443 | runtime->status->hw_ptr = 0; | 1473 | runtime->status->hw_ptr = 0; |
1474 | runtime->hw_ptr_jiffies = jiffies; | ||
1444 | snd_pcm_stream_unlock_irqrestore(substream, flags); | 1475 | snd_pcm_stream_unlock_irqrestore(substream, flags); |
1445 | return 0; | 1476 | return 0; |
1446 | } | 1477 | } |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index a151fb01ba82..fc6f98e257df 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -327,21 +327,16 @@ static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, | |||
327 | struct snd_pcm_hw_params *params; | 327 | struct snd_pcm_hw_params *params; |
328 | int err; | 328 | int err; |
329 | 329 | ||
330 | params = kmalloc(sizeof(*params), GFP_KERNEL); | 330 | params = memdup_user(_params, sizeof(*params)); |
331 | if (!params) { | 331 | if (IS_ERR(params)) |
332 | err = -ENOMEM; | 332 | return PTR_ERR(params); |
333 | goto out; | 333 | |
334 | } | ||
335 | if (copy_from_user(params, _params, sizeof(*params))) { | ||
336 | err = -EFAULT; | ||
337 | goto out; | ||
338 | } | ||
339 | err = snd_pcm_hw_refine(substream, params); | 334 | err = snd_pcm_hw_refine(substream, params); |
340 | if (copy_to_user(_params, params, sizeof(*params))) { | 335 | if (copy_to_user(_params, params, sizeof(*params))) { |
341 | if (!err) | 336 | if (!err) |
342 | err = -EFAULT; | 337 | err = -EFAULT; |
343 | } | 338 | } |
344 | out: | 339 | |
345 | kfree(params); | 340 | kfree(params); |
346 | return err; | 341 | return err; |
347 | } | 342 | } |
@@ -465,21 +460,16 @@ static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, | |||
465 | struct snd_pcm_hw_params *params; | 460 | struct snd_pcm_hw_params *params; |
466 | int err; | 461 | int err; |
467 | 462 | ||
468 | params = kmalloc(sizeof(*params), GFP_KERNEL); | 463 | params = memdup_user(_params, sizeof(*params)); |
469 | if (!params) { | 464 | if (IS_ERR(params)) |
470 | err = -ENOMEM; | 465 | return PTR_ERR(params); |
471 | goto out; | 466 | |
472 | } | ||
473 | if (copy_from_user(params, _params, sizeof(*params))) { | ||
474 | err = -EFAULT; | ||
475 | goto out; | ||
476 | } | ||
477 | err = snd_pcm_hw_params(substream, params); | 467 | err = snd_pcm_hw_params(substream, params); |
478 | if (copy_to_user(_params, params, sizeof(*params))) { | 468 | if (copy_to_user(_params, params, sizeof(*params))) { |
479 | if (!err) | 469 | if (!err) |
480 | err = -EFAULT; | 470 | err = -EFAULT; |
481 | } | 471 | } |
482 | out: | 472 | |
483 | kfree(params); | 473 | kfree(params); |
484 | return err; | 474 | return err; |
485 | } | 475 | } |
@@ -2593,13 +2583,11 @@ static int snd_pcm_playback_ioctl1(struct file *file, | |||
2593 | return -EFAULT; | 2583 | return -EFAULT; |
2594 | if (copy_from_user(&xfern, _xfern, sizeof(xfern))) | 2584 | if (copy_from_user(&xfern, _xfern, sizeof(xfern))) |
2595 | return -EFAULT; | 2585 | return -EFAULT; |
2596 | bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); | 2586 | |
2597 | if (bufs == NULL) | 2587 | bufs = memdup_user(xfern.bufs, |
2598 | return -ENOMEM; | 2588 | sizeof(void *) * runtime->channels); |
2599 | if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { | 2589 | if (IS_ERR(bufs)) |
2600 | kfree(bufs); | 2590 | return PTR_ERR(bufs); |
2601 | return -EFAULT; | ||
2602 | } | ||
2603 | result = snd_pcm_lib_writev(substream, bufs, xfern.frames); | 2591 | result = snd_pcm_lib_writev(substream, bufs, xfern.frames); |
2604 | kfree(bufs); | 2592 | kfree(bufs); |
2605 | __put_user(result, &_xfern->result); | 2593 | __put_user(result, &_xfern->result); |
@@ -2675,13 +2663,11 @@ static int snd_pcm_capture_ioctl1(struct file *file, | |||
2675 | return -EFAULT; | 2663 | return -EFAULT; |
2676 | if (copy_from_user(&xfern, _xfern, sizeof(xfern))) | 2664 | if (copy_from_user(&xfern, _xfern, sizeof(xfern))) |
2677 | return -EFAULT; | 2665 | return -EFAULT; |
2678 | bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); | 2666 | |
2679 | if (bufs == NULL) | 2667 | bufs = memdup_user(xfern.bufs, |
2680 | return -ENOMEM; | 2668 | sizeof(void *) * runtime->channels); |
2681 | if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { | 2669 | if (IS_ERR(bufs)) |
2682 | kfree(bufs); | 2670 | return PTR_ERR(bufs); |
2683 | return -EFAULT; | ||
2684 | } | ||
2685 | result = snd_pcm_lib_readv(substream, bufs, xfern.frames); | 2671 | result = snd_pcm_lib_readv(substream, bufs, xfern.frames); |
2686 | kfree(bufs); | 2672 | kfree(bufs); |
2687 | __put_user(result, &_xfern->result); | 2673 | __put_user(result, &_xfern->result); |
@@ -3312,18 +3298,12 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, | |||
3312 | int err; | 3298 | int err; |
3313 | 3299 | ||
3314 | params = kmalloc(sizeof(*params), GFP_KERNEL); | 3300 | params = kmalloc(sizeof(*params), GFP_KERNEL); |
3315 | if (!params) { | 3301 | if (!params) |
3316 | err = -ENOMEM; | 3302 | return -ENOMEM; |
3317 | goto out; | ||
3318 | } | ||
3319 | oparams = kmalloc(sizeof(*oparams), GFP_KERNEL); | ||
3320 | if (!oparams) { | ||
3321 | err = -ENOMEM; | ||
3322 | goto out; | ||
3323 | } | ||
3324 | 3303 | ||
3325 | if (copy_from_user(oparams, _oparams, sizeof(*oparams))) { | 3304 | oparams = memdup_user(_oparams, sizeof(*oparams)); |
3326 | err = -EFAULT; | 3305 | if (IS_ERR(oparams)) { |
3306 | err = PTR_ERR(oparams); | ||
3327 | goto out; | 3307 | goto out; |
3328 | } | 3308 | } |
3329 | snd_pcm_hw_convert_from_old_params(params, oparams); | 3309 | snd_pcm_hw_convert_from_old_params(params, oparams); |
@@ -3333,9 +3313,10 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, | |||
3333 | if (!err) | 3313 | if (!err) |
3334 | err = -EFAULT; | 3314 | err = -EFAULT; |
3335 | } | 3315 | } |
3316 | |||
3317 | kfree(oparams); | ||
3336 | out: | 3318 | out: |
3337 | kfree(params); | 3319 | kfree(params); |
3338 | kfree(oparams); | ||
3339 | return err; | 3320 | return err; |
3340 | } | 3321 | } |
3341 | 3322 | ||
@@ -3347,17 +3328,12 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, | |||
3347 | int err; | 3328 | int err; |
3348 | 3329 | ||
3349 | params = kmalloc(sizeof(*params), GFP_KERNEL); | 3330 | params = kmalloc(sizeof(*params), GFP_KERNEL); |
3350 | if (!params) { | 3331 | if (!params) |
3351 | err = -ENOMEM; | 3332 | return -ENOMEM; |
3352 | goto out; | 3333 | |
3353 | } | 3334 | oparams = memdup_user(_oparams, sizeof(*oparams)); |
3354 | oparams = kmalloc(sizeof(*oparams), GFP_KERNEL); | 3335 | if (IS_ERR(oparams)) { |
3355 | if (!oparams) { | 3336 | err = PTR_ERR(oparams); |
3356 | err = -ENOMEM; | ||
3357 | goto out; | ||
3358 | } | ||
3359 | if (copy_from_user(oparams, _oparams, sizeof(*oparams))) { | ||
3360 | err = -EFAULT; | ||
3361 | goto out; | 3337 | goto out; |
3362 | } | 3338 | } |
3363 | snd_pcm_hw_convert_from_old_params(params, oparams); | 3339 | snd_pcm_hw_convert_from_old_params(params, oparams); |
@@ -3367,9 +3343,10 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, | |||
3367 | if (!err) | 3343 | if (!err) |
3368 | err = -EFAULT; | 3344 | err = -EFAULT; |
3369 | } | 3345 | } |
3346 | |||
3347 | kfree(oparams); | ||
3370 | out: | 3348 | out: |
3371 | kfree(params); | 3349 | kfree(params); |
3372 | kfree(oparams); | ||
3373 | return err; | 3350 | return err; |
3374 | } | 3351 | } |
3375 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ | 3352 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ |
diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index 38693f47c262..c956fe462569 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c | |||
@@ -48,12 +48,11 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned | |||
48 | struct snd_seq_port_info *data; | 48 | struct snd_seq_port_info *data; |
49 | mm_segment_t fs; | 49 | mm_segment_t fs; |
50 | 50 | ||
51 | data = kmalloc(sizeof(*data), GFP_KERNEL); | 51 | data = memdup_user(data32, sizeof(*data32)); |
52 | if (! data) | 52 | if (IS_ERR(data)) |
53 | return -ENOMEM; | 53 | return PTR_ERR(data); |
54 | 54 | ||
55 | if (copy_from_user(data, data32, sizeof(*data32)) || | 55 | if (get_user(data->flags, &data32->flags) || |
56 | get_user(data->flags, &data32->flags) || | ||
57 | get_user(data->time_queue, &data32->time_queue)) | 56 | get_user(data->time_queue, &data32->time_queue)) |
58 | goto error; | 57 | goto error; |
59 | data->kernel = NULL; | 58 | data->kernel = NULL; |
diff --git a/sound/core/timer.c b/sound/core/timer.c index 3f0050d0b71e..8f8b17ac074d 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -1395,13 +1395,10 @@ static int snd_timer_user_ginfo(struct file *file, | |||
1395 | struct list_head *p; | 1395 | struct list_head *p; |
1396 | int err = 0; | 1396 | int err = 0; |
1397 | 1397 | ||
1398 | ginfo = kmalloc(sizeof(*ginfo), GFP_KERNEL); | 1398 | ginfo = memdup_user(_ginfo, sizeof(*ginfo)); |
1399 | if (! ginfo) | 1399 | if (IS_ERR(ginfo)) |
1400 | return -ENOMEM; | 1400 | return PTR_ERR(ginfo); |
1401 | if (copy_from_user(ginfo, _ginfo, sizeof(*ginfo))) { | 1401 | |
1402 | kfree(ginfo); | ||
1403 | return -EFAULT; | ||
1404 | } | ||
1405 | tid = ginfo->tid; | 1402 | tid = ginfo->tid; |
1406 | memset(ginfo, 0, sizeof(*ginfo)); | 1403 | memset(ginfo, 0, sizeof(*ginfo)); |
1407 | ginfo->tid = tid; | 1404 | ginfo->tid = tid; |
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 49037d074c71..bdc8dde4e4a2 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c | |||
@@ -684,15 +684,16 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int | |||
684 | 684 | ||
685 | static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) | 685 | static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) |
686 | { | 686 | { |
687 | int err = -ENOMEM; | 687 | int err; |
688 | unsigned char *kbuf = kmalloc(size, GFP_KERNEL); | 688 | unsigned char *kbuf; |
689 | if (kbuf) { | 689 | |
690 | if (copy_from_user(kbuf, buf, size)) | 690 | kbuf = memdup_user(buf, size); |
691 | err = -EFAULT; | 691 | if (IS_ERR(kbuf)) |
692 | else | 692 | return PTR_ERR(kbuf); |
693 | err = snd_sb_csp_load(p, kbuf, size, load_flags); | 693 | |
694 | kfree(kbuf); | 694 | err = snd_sb_csp_load(p, kbuf, size, load_flags); |
695 | } | 695 | |
696 | kfree(kbuf); | ||
696 | return err; | 697 | return err; |
697 | } | 698 | } |
698 | 699 | ||
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index a4345fc07561..2bb1cee09255 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c | |||
@@ -202,15 +202,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file, | |||
202 | "> 512 bytes to FX\n"); | 202 | "> 512 bytes to FX\n"); |
203 | return -EIO; | 203 | return -EIO; |
204 | } | 204 | } |
205 | page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL); | 205 | page_data = memdup_user((unsigned char __user *) |
206 | if (!page_data) | 206 | r.data[3], |
207 | return -ENOMEM; | 207 | r.data[2] * sizeof(short)); |
208 | if (copy_from_user (page_data, | 208 | if (IS_ERR(page_data)) |
209 | (unsigned char __user *) r.data[3], | 209 | return PTR_ERR(page_data); |
210 | r.data[2] * sizeof(short))) { | ||
211 | kfree(page_data); | ||
212 | return -EFAULT; | ||
213 | } | ||
214 | pd = page_data; | 210 | pd = page_data; |
215 | } | 211 | } |
216 | 212 | ||
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index beb312cca75b..5d4ff48c4345 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c | |||
@@ -1664,12 +1664,11 @@ snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file, | |||
1664 | break; | 1664 | break; |
1665 | 1665 | ||
1666 | case WFCTL_WFCMD: | 1666 | case WFCTL_WFCMD: |
1667 | wc = kmalloc(sizeof(*wc), GFP_KERNEL); | 1667 | wc = memdup_user(argp, sizeof(*wc)); |
1668 | if (! wc) | 1668 | if (IS_ERR(wc)) |
1669 | return -ENOMEM; | 1669 | return PTR_ERR(wc); |
1670 | if (copy_from_user (wc, argp, sizeof (*wc))) | 1670 | |
1671 | err = -EFAULT; | 1671 | if (wavefront_synth_control (acard, wc) < 0) |
1672 | else if (wavefront_synth_control (acard, wc) < 0) | ||
1673 | err = -EIO; | 1672 | err = -EIO; |
1674 | else if (copy_to_user (argp, wc, sizeof (*wc))) | 1673 | else if (copy_to_user (argp, wc, sizeof (*wc))) |
1675 | err = -EFAULT; | 1674 | err = -EFAULT; |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 191e1cd9997d..4b302d86f5f2 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -2493,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un | |||
2493 | case SNDRV_EMU10K1_IOCTL_CODE_POKE: | 2493 | case SNDRV_EMU10K1_IOCTL_CODE_POKE: |
2494 | if (!capable(CAP_SYS_ADMIN)) | 2494 | if (!capable(CAP_SYS_ADMIN)) |
2495 | return -EPERM; | 2495 | return -EPERM; |
2496 | icode = kmalloc(sizeof(*icode), GFP_KERNEL); | 2496 | |
2497 | if (icode == NULL) | 2497 | icode = memdup_user(argp, sizeof(*icode)); |
2498 | return -ENOMEM; | 2498 | if (IS_ERR(icode)) |
2499 | if (copy_from_user(icode, argp, sizeof(*icode))) { | 2499 | return PTR_ERR(icode); |
2500 | kfree(icode); | ||
2501 | return -EFAULT; | ||
2502 | } | ||
2503 | res = snd_emu10k1_icode_poke(emu, icode); | 2500 | res = snd_emu10k1_icode_poke(emu, icode); |
2504 | kfree(icode); | 2501 | kfree(icode); |
2505 | return res; | 2502 | return res; |
2506 | case SNDRV_EMU10K1_IOCTL_CODE_PEEK: | 2503 | case SNDRV_EMU10K1_IOCTL_CODE_PEEK: |
2507 | icode = kmalloc(sizeof(*icode), GFP_KERNEL); | 2504 | icode = memdup_user(argp, sizeof(*icode)); |
2508 | if (icode == NULL) | 2505 | if (IS_ERR(icode)) |
2509 | return -ENOMEM; | 2506 | return PTR_ERR(icode); |
2510 | if (copy_from_user(icode, argp, sizeof(*icode))) { | ||
2511 | kfree(icode); | ||
2512 | return -EFAULT; | ||
2513 | } | ||
2514 | res = snd_emu10k1_icode_peek(emu, icode); | 2507 | res = snd_emu10k1_icode_peek(emu, icode); |
2515 | if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { | 2508 | if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { |
2516 | kfree(icode); | 2509 | kfree(icode); |
@@ -2519,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un | |||
2519 | kfree(icode); | 2512 | kfree(icode); |
2520 | return res; | 2513 | return res; |
2521 | case SNDRV_EMU10K1_IOCTL_PCM_POKE: | 2514 | case SNDRV_EMU10K1_IOCTL_PCM_POKE: |
2522 | ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); | 2515 | ipcm = memdup_user(argp, sizeof(*ipcm)); |
2523 | if (ipcm == NULL) | 2516 | if (IS_ERR(ipcm)) |
2524 | return -ENOMEM; | 2517 | return PTR_ERR(ipcm); |
2525 | if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { | ||
2526 | kfree(ipcm); | ||
2527 | return -EFAULT; | ||
2528 | } | ||
2529 | res = snd_emu10k1_ipcm_poke(emu, ipcm); | 2518 | res = snd_emu10k1_ipcm_poke(emu, ipcm); |
2530 | kfree(ipcm); | 2519 | kfree(ipcm); |
2531 | return res; | 2520 | return res; |
2532 | case SNDRV_EMU10K1_IOCTL_PCM_PEEK: | 2521 | case SNDRV_EMU10K1_IOCTL_PCM_PEEK: |
2533 | ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); | 2522 | ipcm = memdup_user(argp, sizeof(*ipcm)); |
2534 | if (ipcm == NULL) | 2523 | if (IS_ERR(ipcm)) |
2535 | return -ENOMEM; | 2524 | return PTR_ERR(ipcm); |
2536 | if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { | ||
2537 | kfree(ipcm); | ||
2538 | return -EFAULT; | ||
2539 | } | ||
2540 | res = snd_emu10k1_ipcm_peek(emu, ipcm); | 2525 | res = snd_emu10k1_ipcm_peek(emu, ipcm); |
2541 | if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { | 2526 | if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { |
2542 | kfree(ipcm); | 2527 | kfree(ipcm); |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a4e5e5952115..8820faf6c9d8 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -642,19 +642,21 @@ static int get_codec_name(struct hda_codec *codec) | |||
642 | */ | 642 | */ |
643 | static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) | 643 | static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) |
644 | { | 644 | { |
645 | int i, total_nodes; | 645 | int i, total_nodes, function_id; |
646 | hda_nid_t nid; | 646 | hda_nid_t nid; |
647 | 647 | ||
648 | total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); | 648 | total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); |
649 | for (i = 0; i < total_nodes; i++, nid++) { | 649 | for (i = 0; i < total_nodes; i++, nid++) { |
650 | codec->function_id = snd_hda_param_read(codec, nid, | 650 | function_id = snd_hda_param_read(codec, nid, |
651 | AC_PAR_FUNCTION_TYPE) & 0xff; | 651 | AC_PAR_FUNCTION_TYPE) & 0xff; |
652 | switch (codec->function_id) { | 652 | switch (function_id) { |
653 | case AC_GRP_AUDIO_FUNCTION: | 653 | case AC_GRP_AUDIO_FUNCTION: |
654 | codec->afg = nid; | 654 | codec->afg = nid; |
655 | codec->function_id = function_id; | ||
655 | break; | 656 | break; |
656 | case AC_GRP_MODEM_FUNCTION: | 657 | case AC_GRP_MODEM_FUNCTION: |
657 | codec->mfg = nid; | 658 | codec->mfg = nid; |
659 | codec->function_id = function_id; | ||
658 | break; | 660 | break; |
659 | default: | 661 | default: |
660 | break; | 662 | break; |
@@ -2250,7 +2252,11 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, | |||
2250 | err = bus->ops.command(bus, res); | 2252 | err = bus->ops.command(bus, res); |
2251 | if (!err) { | 2253 | if (!err) { |
2252 | struct hda_cache_head *c; | 2254 | struct hda_cache_head *c; |
2253 | u32 key = build_cmd_cache_key(nid, verb); | 2255 | u32 key; |
2256 | /* parm may contain the verb stuff for get/set amp */ | ||
2257 | verb = verb | (parm >> 8); | ||
2258 | parm &= 0xff; | ||
2259 | key = build_cmd_cache_key(nid, verb); | ||
2254 | c = get_alloc_hash(&codec->cmd_cache, key); | 2260 | c = get_alloc_hash(&codec->cmd_cache, key); |
2255 | if (c) | 2261 | if (c) |
2256 | c->val = parm; | 2262 | c->val = parm; |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 7ba8db5d4c42..21e99cfa8c49 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -312,6 +312,8 @@ struct azx_dev { | |||
312 | unsigned int period_bytes; /* size of the period in bytes */ | 312 | unsigned int period_bytes; /* size of the period in bytes */ |
313 | unsigned int frags; /* number for period in the play buffer */ | 313 | unsigned int frags; /* number for period in the play buffer */ |
314 | unsigned int fifo_size; /* FIFO size */ | 314 | unsigned int fifo_size; /* FIFO size */ |
315 | unsigned long start_jiffies; /* start + minimum jiffies */ | ||
316 | unsigned long min_jiffies; /* minimum jiffies before position is valid */ | ||
315 | 317 | ||
316 | void __iomem *sd_addr; /* stream descriptor pointer */ | 318 | void __iomem *sd_addr; /* stream descriptor pointer */ |
317 | 319 | ||
@@ -330,7 +332,7 @@ struct azx_dev { | |||
330 | unsigned int opened :1; | 332 | unsigned int opened :1; |
331 | unsigned int running :1; | 333 | unsigned int running :1; |
332 | unsigned int irq_pending :1; | 334 | unsigned int irq_pending :1; |
333 | unsigned int irq_ignore :1; | 335 | unsigned int start_flag: 1; /* stream full start flag */ |
334 | /* | 336 | /* |
335 | * For VIA: | 337 | * For VIA: |
336 | * A flag to ensure DMA position is 0 | 338 | * A flag to ensure DMA position is 0 |
@@ -975,7 +977,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
975 | struct azx *chip = dev_id; | 977 | struct azx *chip = dev_id; |
976 | struct azx_dev *azx_dev; | 978 | struct azx_dev *azx_dev; |
977 | u32 status; | 979 | u32 status; |
978 | int i; | 980 | int i, ok; |
979 | 981 | ||
980 | spin_lock(&chip->reg_lock); | 982 | spin_lock(&chip->reg_lock); |
981 | 983 | ||
@@ -991,18 +993,14 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
991 | azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); | 993 | azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); |
992 | if (!azx_dev->substream || !azx_dev->running) | 994 | if (!azx_dev->substream || !azx_dev->running) |
993 | continue; | 995 | continue; |
994 | /* ignore the first dummy IRQ (due to pos_adj) */ | ||
995 | if (azx_dev->irq_ignore) { | ||
996 | azx_dev->irq_ignore = 0; | ||
997 | continue; | ||
998 | } | ||
999 | /* check whether this IRQ is really acceptable */ | 996 | /* check whether this IRQ is really acceptable */ |
1000 | if (azx_position_ok(chip, azx_dev)) { | 997 | ok = azx_position_ok(chip, azx_dev); |
998 | if (ok == 1) { | ||
1001 | azx_dev->irq_pending = 0; | 999 | azx_dev->irq_pending = 0; |
1002 | spin_unlock(&chip->reg_lock); | 1000 | spin_unlock(&chip->reg_lock); |
1003 | snd_pcm_period_elapsed(azx_dev->substream); | 1001 | snd_pcm_period_elapsed(azx_dev->substream); |
1004 | spin_lock(&chip->reg_lock); | 1002 | spin_lock(&chip->reg_lock); |
1005 | } else if (chip->bus && chip->bus->workq) { | 1003 | } else if (ok == 0 && chip->bus && chip->bus->workq) { |
1006 | /* bogus IRQ, process it later */ | 1004 | /* bogus IRQ, process it later */ |
1007 | azx_dev->irq_pending = 1; | 1005 | azx_dev->irq_pending = 1; |
1008 | queue_work(chip->bus->workq, | 1006 | queue_work(chip->bus->workq, |
@@ -1088,7 +1086,6 @@ static int azx_setup_periods(struct azx *chip, | |||
1088 | bdl = (u32 *)azx_dev->bdl.area; | 1086 | bdl = (u32 *)azx_dev->bdl.area; |
1089 | ofs = 0; | 1087 | ofs = 0; |
1090 | azx_dev->frags = 0; | 1088 | azx_dev->frags = 0; |
1091 | azx_dev->irq_ignore = 0; | ||
1092 | pos_adj = bdl_pos_adj[chip->dev_index]; | 1089 | pos_adj = bdl_pos_adj[chip->dev_index]; |
1093 | if (pos_adj > 0) { | 1090 | if (pos_adj > 0) { |
1094 | struct snd_pcm_runtime *runtime = substream->runtime; | 1091 | struct snd_pcm_runtime *runtime = substream->runtime; |
@@ -1109,7 +1106,6 @@ static int azx_setup_periods(struct azx *chip, | |||
1109 | &bdl, ofs, pos_adj, 1); | 1106 | &bdl, ofs, pos_adj, 1); |
1110 | if (ofs < 0) | 1107 | if (ofs < 0) |
1111 | goto error; | 1108 | goto error; |
1112 | azx_dev->irq_ignore = 1; | ||
1113 | } | 1109 | } |
1114 | } else | 1110 | } else |
1115 | pos_adj = 0; | 1111 | pos_adj = 0; |
@@ -1155,6 +1151,9 @@ static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev) | |||
1155 | while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && | 1151 | while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && |
1156 | --timeout) | 1152 | --timeout) |
1157 | ; | 1153 | ; |
1154 | |||
1155 | /* reset first position - may not be synced with hw at this time */ | ||
1156 | *azx_dev->posbuf = 0; | ||
1158 | } | 1157 | } |
1159 | 1158 | ||
1160 | /* | 1159 | /* |
@@ -1409,7 +1408,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) | |||
1409 | snd_pcm_set_sync(substream); | 1408 | snd_pcm_set_sync(substream); |
1410 | mutex_unlock(&chip->open_mutex); | 1409 | mutex_unlock(&chip->open_mutex); |
1411 | 1410 | ||
1412 | azx_stream_reset(chip, azx_dev); | ||
1413 | return 0; | 1411 | return 0; |
1414 | } | 1412 | } |
1415 | 1413 | ||
@@ -1474,6 +1472,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) | |||
1474 | unsigned int bufsize, period_bytes, format_val; | 1472 | unsigned int bufsize, period_bytes, format_val; |
1475 | int err; | 1473 | int err; |
1476 | 1474 | ||
1475 | azx_stream_reset(chip, azx_dev); | ||
1477 | format_val = snd_hda_calc_stream_format(runtime->rate, | 1476 | format_val = snd_hda_calc_stream_format(runtime->rate, |
1478 | runtime->channels, | 1477 | runtime->channels, |
1479 | runtime->format, | 1478 | runtime->format, |
@@ -1502,6 +1501,8 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) | |||
1502 | return err; | 1501 | return err; |
1503 | } | 1502 | } |
1504 | 1503 | ||
1504 | azx_dev->min_jiffies = (runtime->period_size * HZ) / | ||
1505 | (runtime->rate * 2); | ||
1505 | azx_setup_controller(chip, azx_dev); | 1506 | azx_setup_controller(chip, azx_dev); |
1506 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 1507 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
1507 | azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; | 1508 | azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; |
@@ -1518,13 +1519,14 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1518 | struct azx *chip = apcm->chip; | 1519 | struct azx *chip = apcm->chip; |
1519 | struct azx_dev *azx_dev; | 1520 | struct azx_dev *azx_dev; |
1520 | struct snd_pcm_substream *s; | 1521 | struct snd_pcm_substream *s; |
1521 | int start, nsync = 0, sbits = 0; | 1522 | int rstart = 0, start, nsync = 0, sbits = 0; |
1522 | int nwait, timeout; | 1523 | int nwait, timeout; |
1523 | 1524 | ||
1524 | switch (cmd) { | 1525 | switch (cmd) { |
1526 | case SNDRV_PCM_TRIGGER_START: | ||
1527 | rstart = 1; | ||
1525 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 1528 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
1526 | case SNDRV_PCM_TRIGGER_RESUME: | 1529 | case SNDRV_PCM_TRIGGER_RESUME: |
1527 | case SNDRV_PCM_TRIGGER_START: | ||
1528 | start = 1; | 1530 | start = 1; |
1529 | break; | 1531 | break; |
1530 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1532 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
@@ -1554,6 +1556,10 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1554 | if (s->pcm->card != substream->pcm->card) | 1556 | if (s->pcm->card != substream->pcm->card) |
1555 | continue; | 1557 | continue; |
1556 | azx_dev = get_azx_dev(s); | 1558 | azx_dev = get_azx_dev(s); |
1559 | if (rstart) { | ||
1560 | azx_dev->start_flag = 1; | ||
1561 | azx_dev->start_jiffies = jiffies + azx_dev->min_jiffies; | ||
1562 | } | ||
1557 | if (start) | 1563 | if (start) |
1558 | azx_stream_start(chip, azx_dev); | 1564 | azx_stream_start(chip, azx_dev); |
1559 | else | 1565 | else |
@@ -1703,6 +1709,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) | |||
1703 | { | 1709 | { |
1704 | unsigned int pos; | 1710 | unsigned int pos; |
1705 | 1711 | ||
1712 | if (azx_dev->start_flag && | ||
1713 | time_before_eq(jiffies, azx_dev->start_jiffies)) | ||
1714 | return -1; /* bogus (too early) interrupt */ | ||
1715 | azx_dev->start_flag = 0; | ||
1716 | |||
1706 | pos = azx_get_position(chip, azx_dev); | 1717 | pos = azx_get_position(chip, azx_dev); |
1707 | if (chip->position_fix == POS_FIX_AUTO) { | 1718 | if (chip->position_fix == POS_FIX_AUTO) { |
1708 | if (!pos) { | 1719 | if (!pos) { |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 38ad3f7b040f..9bcd8ab5a27f 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -3977,6 +3977,14 @@ static int patch_ad1884a(struct hda_codec *codec) | |||
3977 | spec->input_mux = &ad1884a_laptop_capture_source; | 3977 | spec->input_mux = &ad1884a_laptop_capture_source; |
3978 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; | 3978 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; |
3979 | codec->patch_ops.init = ad1884a_hp_init; | 3979 | codec->patch_ops.init = ad1884a_hp_init; |
3980 | /* set the upper-limit for mixer amp to 0dB for avoiding the | ||
3981 | * possible damage by overloading | ||
3982 | */ | ||
3983 | snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT, | ||
3984 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | | ||
3985 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
3986 | (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
3987 | (1 << AC_AMPCAP_MUTE_SHIFT)); | ||
3980 | break; | 3988 | break; |
3981 | case AD1884A_MOBILE: | 3989 | case AD1884A_MOBILE: |
3982 | spec->mixers[0] = ad1884a_mobile_mixers; | 3990 | spec->mixers[0] = ad1884a_mobile_mixers; |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 1f2ad76ca94b..56ce19e68cb5 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -350,12 +350,20 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
350 | } | 350 | } |
351 | 351 | ||
352 | #ifdef CONFIG_SND_JACK | 352 | #ifdef CONFIG_SND_JACK |
353 | static void conexant_free_jack_priv(struct snd_jack *jack) | ||
354 | { | ||
355 | struct conexant_jack *jacks = jack->private_data; | ||
356 | jacks->nid = 0; | ||
357 | jacks->jack = NULL; | ||
358 | } | ||
359 | |||
353 | static int conexant_add_jack(struct hda_codec *codec, | 360 | static int conexant_add_jack(struct hda_codec *codec, |
354 | hda_nid_t nid, int type) | 361 | hda_nid_t nid, int type) |
355 | { | 362 | { |
356 | struct conexant_spec *spec; | 363 | struct conexant_spec *spec; |
357 | struct conexant_jack *jack; | 364 | struct conexant_jack *jack; |
358 | const char *name; | 365 | const char *name; |
366 | int err; | ||
359 | 367 | ||
360 | spec = codec->spec; | 368 | spec = codec->spec; |
361 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | 369 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
@@ -368,7 +376,12 @@ static int conexant_add_jack(struct hda_codec *codec, | |||
368 | jack->nid = nid; | 376 | jack->nid = nid; |
369 | jack->type = type; | 377 | jack->type = type; |
370 | 378 | ||
371 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); | 379 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
380 | if (err < 0) | ||
381 | return err; | ||
382 | jack->jack->private_data = jack; | ||
383 | jack->jack->private_free = conexant_free_jack_priv; | ||
384 | return 0; | ||
372 | } | 385 | } |
373 | 386 | ||
374 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | 387 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) |
@@ -455,8 +468,10 @@ static void conexant_free(struct hda_codec *codec) | |||
455 | if (spec->jacks.list) { | 468 | if (spec->jacks.list) { |
456 | struct conexant_jack *jacks = spec->jacks.list; | 469 | struct conexant_jack *jacks = spec->jacks.list; |
457 | int i; | 470 | int i; |
458 | for (i = 0; i < spec->jacks.used; i++) | 471 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
459 | snd_device_free(codec->bus->card, &jacks[i].jack); | 472 | if (jacks->jack) |
473 | snd_device_free(codec->bus->card, jacks->jack); | ||
474 | } | ||
460 | snd_array_free(&spec->jacks); | 475 | snd_array_free(&spec->jacks); |
461 | } | 476 | } |
462 | #endif | 477 | #endif |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f35e58a2d921..6ed787eedd06 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -8742,10 +8742,9 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8742 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), | 8742 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), |
8743 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), | 8743 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
8744 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), | 8744 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
8745 | SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550", | 8745 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", |
8746 | ALC883_FUJITSU_PI2515), | 8746 | ALC883_FUJITSU_PI2515), |
8747 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), | 8747 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx", |
8748 | SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", | ||
8749 | ALC888_FUJITSU_XA3530), | 8748 | ALC888_FUJITSU_XA3530), |
8750 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), | 8749 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
8751 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), | 8750 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 61996a2f45df..917bc5d3ac2c 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -3076,6 +3076,11 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | |||
3076 | unsigned int wid_caps; | 3076 | unsigned int wid_caps; |
3077 | 3077 | ||
3078 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { | 3078 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
3079 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { | ||
3080 | wid_caps = get_wcaps(codec, pins[i]); | ||
3081 | if (wid_caps & AC_WCAP_UNSOL_CAP) | ||
3082 | spec->hp_detect = 1; | ||
3083 | } | ||
3079 | nid = dac_nids[i]; | 3084 | nid = dac_nids[i]; |
3080 | if (!nid) | 3085 | if (!nid) |
3081 | continue; | 3086 | continue; |
@@ -3119,11 +3124,6 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | |||
3119 | err = create_controls_idx(codec, name, idx, nid, 3); | 3124 | err = create_controls_idx(codec, name, idx, nid, 3); |
3120 | if (err < 0) | 3125 | if (err < 0) |
3121 | return err; | 3126 | return err; |
3122 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { | ||
3123 | wid_caps = get_wcaps(codec, pins[i]); | ||
3124 | if (wid_caps & AC_WCAP_UNSOL_CAP) | ||
3125 | spec->hp_detect = 1; | ||
3126 | } | ||
3127 | } | 3127 | } |
3128 | } | 3128 | } |
3129 | return 0; | 3129 | return 0; |
@@ -3851,6 +3851,15 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, | |||
3851 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | 3851 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
3852 | } | 3852 | } |
3853 | 3853 | ||
3854 | #ifdef CONFIG_SND_JACK | ||
3855 | static void stac92xx_free_jack_priv(struct snd_jack *jack) | ||
3856 | { | ||
3857 | struct sigmatel_jack *jacks = jack->private_data; | ||
3858 | jacks->nid = 0; | ||
3859 | jacks->jack = NULL; | ||
3860 | } | ||
3861 | #endif | ||
3862 | |||
3854 | static int stac92xx_add_jack(struct hda_codec *codec, | 3863 | static int stac92xx_add_jack(struct hda_codec *codec, |
3855 | hda_nid_t nid, int type) | 3864 | hda_nid_t nid, int type) |
3856 | { | 3865 | { |
@@ -3860,6 +3869,7 @@ static int stac92xx_add_jack(struct hda_codec *codec, | |||
3860 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 3869 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
3861 | int connectivity = get_defcfg_connect(def_conf); | 3870 | int connectivity = get_defcfg_connect(def_conf); |
3862 | char name[32]; | 3871 | char name[32]; |
3872 | int err; | ||
3863 | 3873 | ||
3864 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) | 3874 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
3865 | return 0; | 3875 | return 0; |
@@ -3876,10 +3886,15 @@ static int stac92xx_add_jack(struct hda_codec *codec, | |||
3876 | snd_hda_get_jack_connectivity(def_conf), | 3886 | snd_hda_get_jack_connectivity(def_conf), |
3877 | snd_hda_get_jack_location(def_conf)); | 3887 | snd_hda_get_jack_location(def_conf)); |
3878 | 3888 | ||
3879 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); | 3889 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
3880 | #else | 3890 | if (err < 0) { |
3881 | return 0; | 3891 | jack->nid = 0; |
3892 | return err; | ||
3893 | } | ||
3894 | jack->jack->private_data = jack; | ||
3895 | jack->jack->private_free = stac92xx_free_jack_priv; | ||
3882 | #endif | 3896 | #endif |
3897 | return 0; | ||
3883 | } | 3898 | } |
3884 | 3899 | ||
3885 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, | 3900 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
@@ -4138,8 +4153,10 @@ static void stac92xx_free_jacks(struct hda_codec *codec) | |||
4138 | if (!codec->bus->shutdown && spec->jacks.list) { | 4153 | if (!codec->bus->shutdown && spec->jacks.list) { |
4139 | struct sigmatel_jack *jacks = spec->jacks.list; | 4154 | struct sigmatel_jack *jacks = spec->jacks.list; |
4140 | int i; | 4155 | int i; |
4141 | for (i = 0; i < spec->jacks.used; i++) | 4156 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
4142 | snd_device_free(codec->bus->card, &jacks[i].jack); | 4157 | if (jacks->jack) |
4158 | snd_device_free(codec->bus->card, jacks->jack); | ||
4159 | } | ||
4143 | } | 4160 | } |
4144 | snd_array_free(&spec->jacks); | 4161 | snd_array_free(&spec->jacks); |
4145 | #endif | 4162 | #endif |
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 57648810eaf1..8042d5398892 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -355,6 +355,9 @@ struct ichdev { | |||
355 | unsigned int fragsize1; | 355 | unsigned int fragsize1; |
356 | unsigned int position; | 356 | unsigned int position; |
357 | unsigned int pos_shift; | 357 | unsigned int pos_shift; |
358 | unsigned int last_pos; | ||
359 | unsigned long last_pos_jiffies; | ||
360 | unsigned int jiffy_to_bytes; | ||
358 | int frags; | 361 | int frags; |
359 | int lvi; | 362 | int lvi; |
360 | int lvi_frag; | 363 | int lvi_frag; |
@@ -838,7 +841,10 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd | |||
838 | ichdev->suspended = 0; | 841 | ichdev->suspended = 0; |
839 | /* fallthru */ | 842 | /* fallthru */ |
840 | case SNDRV_PCM_TRIGGER_START: | 843 | case SNDRV_PCM_TRIGGER_START: |
844 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
841 | val = ICH_IOCE | ICH_STARTBM; | 845 | val = ICH_IOCE | ICH_STARTBM; |
846 | ichdev->last_pos = ichdev->position; | ||
847 | ichdev->last_pos_jiffies = jiffies; | ||
842 | break; | 848 | break; |
843 | case SNDRV_PCM_TRIGGER_SUSPEND: | 849 | case SNDRV_PCM_TRIGGER_SUSPEND: |
844 | ichdev->suspended = 1; | 850 | ichdev->suspended = 1; |
@@ -849,9 +855,6 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd | |||
849 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 855 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
850 | val = ICH_IOCE; | 856 | val = ICH_IOCE; |
851 | break; | 857 | break; |
852 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
853 | val = ICH_IOCE | ICH_STARTBM; | ||
854 | break; | ||
855 | default: | 858 | default: |
856 | return -EINVAL; | 859 | return -EINVAL; |
857 | } | 860 | } |
@@ -1045,6 +1048,7 @@ static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream) | |||
1045 | ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; | 1048 | ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; |
1046 | } | 1049 | } |
1047 | snd_intel8x0_setup_periods(chip, ichdev); | 1050 | snd_intel8x0_setup_periods(chip, ichdev); |
1051 | ichdev->jiffy_to_bytes = (runtime->rate * 4 * ichdev->pos_shift) / HZ; | ||
1048 | return 0; | 1052 | return 0; |
1049 | } | 1053 | } |
1050 | 1054 | ||
@@ -1053,7 +1057,7 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs | |||
1053 | struct intel8x0 *chip = snd_pcm_substream_chip(substream); | 1057 | struct intel8x0 *chip = snd_pcm_substream_chip(substream); |
1054 | struct ichdev *ichdev = get_ichdev(substream); | 1058 | struct ichdev *ichdev = get_ichdev(substream); |
1055 | size_t ptr1, ptr; | 1059 | size_t ptr1, ptr; |
1056 | int civ, timeout = 100; | 1060 | int civ, timeout = 10; |
1057 | unsigned int position; | 1061 | unsigned int position; |
1058 | 1062 | ||
1059 | spin_lock(&chip->reg_lock); | 1063 | spin_lock(&chip->reg_lock); |
@@ -1069,9 +1073,19 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs | |||
1069 | ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) | 1073 | ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) |
1070 | break; | 1074 | break; |
1071 | } while (timeout--); | 1075 | } while (timeout--); |
1072 | ptr1 <<= ichdev->pos_shift; | 1076 | if (ptr1 != 0) { |
1073 | ptr = ichdev->fragsize1 - ptr1; | 1077 | ptr1 <<= ichdev->pos_shift; |
1074 | ptr += position; | 1078 | ptr = ichdev->fragsize1 - ptr1; |
1079 | ptr += position; | ||
1080 | ichdev->last_pos = ptr; | ||
1081 | ichdev->last_pos_jiffies = jiffies; | ||
1082 | } else { | ||
1083 | ptr1 = jiffies - ichdev->last_pos_jiffies; | ||
1084 | if (ptr1) | ||
1085 | ptr1 -= 1; | ||
1086 | ptr = ichdev->last_pos + ptr1 * ichdev->jiffy_to_bytes; | ||
1087 | ptr %= ichdev->size; | ||
1088 | } | ||
1075 | spin_unlock(&chip->reg_lock); | 1089 | spin_unlock(&chip->reg_lock); |
1076 | if (ptr >= ichdev->size) | 1090 | if (ptr >= ichdev->size) |
1077 | return 0; | 1091 | return 0; |
@@ -1840,6 +1854,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { | |||
1840 | }, | 1854 | }, |
1841 | { | 1855 | { |
1842 | .subvendor = 0x1028, | 1856 | .subvendor = 0x1028, |
1857 | .subdevice = 0x016a, | ||
1858 | .name = "Dell Inspiron 8600", /* STAC9750/51 */ | ||
1859 | .type = AC97_TUNE_HP_ONLY | ||
1860 | }, | ||
1861 | { | ||
1862 | .subvendor = 0x1028, | ||
1843 | .subdevice = 0x0186, | 1863 | .subdevice = 0x0186, |
1844 | .name = "Dell Latitude D810", /* cf. Malone #41015 */ | 1864 | .name = "Dell Latitude D810", /* cf. Malone #41015 */ |
1845 | .type = AC97_TUNE_HP_MUTE_LED | 1865 | .type = AC97_TUNE_HP_MUTE_LED |
@@ -1882,12 +1902,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { | |||
1882 | }, | 1902 | }, |
1883 | { | 1903 | { |
1884 | .subvendor = 0x103c, | 1904 | .subvendor = 0x103c, |
1885 | .subdevice = 0x0934, | ||
1886 | .name = "HP nx8220", | ||
1887 | .type = AC97_TUNE_MUTE_LED | ||
1888 | }, | ||
1889 | { | ||
1890 | .subvendor = 0x103c, | ||
1891 | .subdevice = 0x129d, | 1905 | .subdevice = 0x129d, |
1892 | .name = "HP xw8000", | 1906 | .name = "HP xw8000", |
1893 | .type = AC97_TUNE_HP_ONLY | 1907 | .type = AC97_TUNE_HP_ONLY |
@@ -2661,12 +2675,14 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) | |||
2661 | struct snd_pcm_substream *subs; | 2675 | struct snd_pcm_substream *subs; |
2662 | struct ichdev *ichdev; | 2676 | struct ichdev *ichdev; |
2663 | unsigned long port; | 2677 | unsigned long port; |
2664 | unsigned long pos, t; | 2678 | unsigned long pos, pos1, t; |
2665 | struct timeval start_time, stop_time; | 2679 | int civ, timeout = 1000, attempt = 1; |
2680 | struct timespec start_time, stop_time; | ||
2666 | 2681 | ||
2667 | if (chip->ac97_bus->clock != 48000) | 2682 | if (chip->ac97_bus->clock != 48000) |
2668 | return; /* specified in module option */ | 2683 | return; /* specified in module option */ |
2669 | 2684 | ||
2685 | __again: | ||
2670 | subs = chip->pcm[0]->streams[0].substream; | 2686 | subs = chip->pcm[0]->streams[0].substream; |
2671 | if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { | 2687 | if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { |
2672 | snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); | 2688 | snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); |
@@ -2674,7 +2690,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) | |||
2674 | } | 2690 | } |
2675 | ichdev = &chip->ichd[ICHD_PCMOUT]; | 2691 | ichdev = &chip->ichd[ICHD_PCMOUT]; |
2676 | ichdev->physbuf = subs->dma_buffer.addr; | 2692 | ichdev->physbuf = subs->dma_buffer.addr; |
2677 | ichdev->size = chip->ichd[ICHD_PCMOUT].fragsize = INTEL8X0_TESTBUF_SIZE; | 2693 | ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE; |
2678 | ichdev->substream = NULL; /* don't process interrupts */ | 2694 | ichdev->substream = NULL; /* don't process interrupts */ |
2679 | 2695 | ||
2680 | /* set rate */ | 2696 | /* set rate */ |
@@ -2693,16 +2709,31 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) | |||
2693 | iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); | 2709 | iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); |
2694 | iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); | 2710 | iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); |
2695 | } | 2711 | } |
2696 | do_gettimeofday(&start_time); | 2712 | do_posix_clock_monotonic_gettime(&start_time); |
2697 | spin_unlock_irq(&chip->reg_lock); | 2713 | spin_unlock_irq(&chip->reg_lock); |
2698 | msleep(50); | 2714 | msleep(50); |
2699 | spin_lock_irq(&chip->reg_lock); | 2715 | spin_lock_irq(&chip->reg_lock); |
2700 | /* check the position */ | 2716 | /* check the position */ |
2701 | pos = ichdev->fragsize1; | 2717 | do { |
2702 | pos -= igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << ichdev->pos_shift; | 2718 | civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); |
2703 | pos += ichdev->position; | 2719 | pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); |
2720 | if (pos1 == 0) { | ||
2721 | udelay(10); | ||
2722 | continue; | ||
2723 | } | ||
2724 | if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) && | ||
2725 | pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) | ||
2726 | break; | ||
2727 | } while (timeout--); | ||
2728 | if (pos1 == 0) { /* oops, this value is not reliable */ | ||
2729 | pos = 0; | ||
2730 | } else { | ||
2731 | pos = ichdev->fragsize1; | ||
2732 | pos -= pos1 << ichdev->pos_shift; | ||
2733 | pos += ichdev->position; | ||
2734 | } | ||
2704 | chip->in_measurement = 0; | 2735 | chip->in_measurement = 0; |
2705 | do_gettimeofday(&stop_time); | 2736 | do_posix_clock_monotonic_gettime(&stop_time); |
2706 | /* stop */ | 2737 | /* stop */ |
2707 | if (chip->device_type == DEVICE_ALI) { | 2738 | if (chip->device_type == DEVICE_ALI) { |
2708 | iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); | 2739 | iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); |
@@ -2717,19 +2748,37 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) | |||
2717 | iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); | 2748 | iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); |
2718 | spin_unlock_irq(&chip->reg_lock); | 2749 | spin_unlock_irq(&chip->reg_lock); |
2719 | 2750 | ||
2751 | if (pos == 0) { | ||
2752 | snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n"); | ||
2753 | __retry: | ||
2754 | if (attempt < 2) { | ||
2755 | attempt++; | ||
2756 | goto __again; | ||
2757 | } | ||
2758 | return; | ||
2759 | } | ||
2760 | |||
2761 | pos /= 4; | ||
2720 | t = stop_time.tv_sec - start_time.tv_sec; | 2762 | t = stop_time.tv_sec - start_time.tv_sec; |
2721 | t *= 1000000; | 2763 | t *= 1000000; |
2722 | t += stop_time.tv_usec - start_time.tv_usec; | 2764 | t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000; |
2723 | printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t); | 2765 | printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); |
2724 | if (t == 0) { | 2766 | if (t == 0) { |
2725 | snd_printk(KERN_ERR "?? calculation error..\n"); | 2767 | snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n"); |
2726 | return; | 2768 | goto __retry; |
2727 | } | 2769 | } |
2728 | pos = (pos / 4) * 1000; | 2770 | pos *= 1000; |
2729 | pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; | 2771 | pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; |
2730 | if (pos < 40000 || pos >= 60000) | 2772 | if (pos < 40000 || pos >= 60000) { |
2731 | /* abnormal value. hw problem? */ | 2773 | /* abnormal value. hw problem? */ |
2732 | printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); | 2774 | printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); |
2775 | goto __retry; | ||
2776 | } else if (pos > 40500 && pos < 41500) | ||
2777 | /* first exception - 41000Hz reference clock */ | ||
2778 | chip->ac97_bus->clock = 41000; | ||
2779 | else if (pos > 43600 && pos < 44600) | ||
2780 | /* second exception - 44100HZ reference clock */ | ||
2781 | chip->ac97_bus->clock = 44100; | ||
2733 | else if (pos < 47500 || pos > 48500) | 2782 | else if (pos < 47500 || pos > 48500) |
2734 | /* not 48000Hz, tuning the clock.. */ | 2783 | /* not 48000Hz, tuning the clock.. */ |
2735 | chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; | 2784 | chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 9c09b94f0cf8..90f4df7fd906 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -283,7 +283,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
283 | break; | 283 | break; |
284 | case SND_SOC_DAIFMT_DSP_B: | 284 | case SND_SOC_DAIFMT_DSP_B: |
285 | regs->srgr2 |= FPER(wlen * channels - 1); | 285 | regs->srgr2 |= FPER(wlen * channels - 1); |
286 | regs->srgr1 |= FWID(wlen * channels - 2); | 286 | regs->srgr1 |= FWID(0); |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | 289 | ||
@@ -302,6 +302,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
302 | { | 302 | { |
303 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 303 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
304 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 304 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
305 | unsigned int temp_fmt = fmt; | ||
305 | 306 | ||
306 | if (mcbsp_data->configured) | 307 | if (mcbsp_data->configured) |
307 | return 0; | 308 | return 0; |
@@ -328,6 +329,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
328 | /* 0-bit data delay */ | 329 | /* 0-bit data delay */ |
329 | regs->rcr2 |= RDATDLY(0); | 330 | regs->rcr2 |= RDATDLY(0); |
330 | regs->xcr2 |= XDATDLY(0); | 331 | regs->xcr2 |= XDATDLY(0); |
332 | /* Invert FS polarity configuration */ | ||
333 | temp_fmt ^= SND_SOC_DAIFMT_NB_IF; | ||
331 | break; | 334 | break; |
332 | default: | 335 | default: |
333 | /* Unsupported data format */ | 336 | /* Unsupported data format */ |
@@ -351,7 +354,7 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
351 | } | 354 | } |
352 | 355 | ||
353 | /* Set bit clock (CLKX/CLKR) and FS polarities */ | 356 | /* Set bit clock (CLKX/CLKR) and FS polarities */ |
354 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | 357 | switch (temp_fmt & SND_SOC_DAIFMT_INV_MASK) { |
355 | case SND_SOC_DAIFMT_NB_NF: | 358 | case SND_SOC_DAIFMT_NB_NF: |
356 | /* | 359 | /* |
357 | * Normal BCLK + FS. | 360 | * Normal BCLK + FS. |
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index a952a4eb3361..a4e149b7f0eb 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c | |||
@@ -62,7 +62,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream, | |||
62 | /* Set codec DAI configuration */ | 62 | /* Set codec DAI configuration */ |
63 | err = snd_soc_dai_set_fmt(codec_dai, | 63 | err = snd_soc_dai_set_fmt(codec_dai, |
64 | SND_SOC_DAIFMT_DSP_B | | 64 | SND_SOC_DAIFMT_DSP_B | |
65 | SND_SOC_DAIFMT_NB_IF | | 65 | SND_SOC_DAIFMT_NB_NF | |
66 | SND_SOC_DAIFMT_CBM_CFM); | 66 | SND_SOC_DAIFMT_CBM_CFM); |
67 | if (err < 0) { | 67 | if (err < 0) { |
68 | printk(KERN_ERR "can't set codec DAI configuration\n"); | 68 | printk(KERN_ERR "can't set codec DAI configuration\n"); |
@@ -72,7 +72,7 @@ static int osk_hw_params(struct snd_pcm_substream *substream, | |||
72 | /* Set cpu DAI configuration */ | 72 | /* Set cpu DAI configuration */ |
73 | err = snd_soc_dai_set_fmt(cpu_dai, | 73 | err = snd_soc_dai_set_fmt(cpu_dai, |
74 | SND_SOC_DAIFMT_DSP_B | | 74 | SND_SOC_DAIFMT_DSP_B | |
75 | SND_SOC_DAIFMT_NB_IF | | 75 | SND_SOC_DAIFMT_NB_NF | |
76 | SND_SOC_DAIFMT_CBM_CFM); | 76 | SND_SOC_DAIFMT_CBM_CFM); |
77 | if (err < 0) { | 77 | if (err < 0) { |
78 | printk(KERN_ERR "can't set cpu DAI configuration\n"); | 78 | printk(KERN_ERR "can't set cpu DAI configuration\n"); |
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c index f7c4544f7859..0625c342a1c9 100644 --- a/sound/soc/pxa/magician.c +++ b/sound/soc/pxa/magician.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include <sound/soc.h> | 27 | #include <sound/soc.h> |
28 | #include <sound/soc-dapm.h> | 28 | #include <sound/soc-dapm.h> |
29 | 29 | ||
30 | #include <mach/pxa-regs.h> | ||
31 | #include <mach/hardware.h> | ||
32 | #include <mach/magician.h> | 30 | #include <mach/magician.h> |
33 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
34 | #include "../codecs/uda1380.h" | 32 | #include "../codecs/uda1380.h" |
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 308a657928d2..de2254475d52 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c | |||
@@ -806,6 +806,7 @@ static int pxa_ssp_probe(struct platform_device *pdev, | |||
806 | goto err_priv; | 806 | goto err_priv; |
807 | } | 807 | } |
808 | 808 | ||
809 | priv->dai_fmt = (unsigned int) -1; | ||
809 | dai->private_data = priv; | 810 | dai->private_data = priv; |
810 | 811 | ||
811 | return 0; | 812 | return 0; |
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 2f3a21eee051..df494d1e346f 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig | |||
@@ -1,10 +1,10 @@ | |||
1 | config SND_S3C24XX_SOC | 1 | config SND_S3C24XX_SOC |
2 | tristate "SoC Audio for the Samsung S3CXXXX chips" | 2 | tristate "SoC Audio for the Samsung S3CXXXX chips" |
3 | depends on ARCH_S3C2410 || ARCH_S3C64XX | 3 | depends on ARCH_S3C2410 |
4 | help | 4 | help |
5 | Say Y or M if you want to add support for codecs attached to | 5 | Say Y or M if you want to add support for codecs attached to |
6 | the S3C24XX and S3C64XX AC97, I2S or SSP interface. You will | 6 | the S3C24XX AC97 or I2S interfaces. You will also need to |
7 | also need to select the audio interfaces to support below. | 7 | select the audio interfaces to support below. |
8 | 8 | ||
9 | config SND_S3C24XX_SOC_I2S | 9 | config SND_S3C24XX_SOC_I2S |
10 | tristate | 10 | tristate |
diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c index 32063790d95b..93e6c87b7399 100644 --- a/sound/soc/s3c24xx/jive_wm8750.c +++ b/sound/soc/s3c24xx/jive_wm8750.c | |||
@@ -69,8 +69,8 @@ static int jive_hw_params(struct snd_pcm_substream *substream, | |||
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | 71 | ||
72 | s3c_i2sv2_calc_rate(&div, NULL, params_rate(params), | 72 | s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params), |
73 | s3c2412_get_iisclk()); | 73 | s3c2412_get_iisclk()); |
74 | 74 | ||
75 | /* set codec DAI configuration */ | 75 | /* set codec DAI configuration */ |
76 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | | 76 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | |
@@ -145,8 +145,9 @@ static struct snd_soc_dai_link jive_dai = { | |||
145 | }; | 145 | }; |
146 | 146 | ||
147 | /* jive audio machine driver */ | 147 | /* jive audio machine driver */ |
148 | static struct snd_soc_machine snd_soc_machine_jive = { | 148 | static struct snd_soc_card snd_soc_machine_jive = { |
149 | .name = "Jive", | 149 | .name = "Jive", |
150 | .platform = &s3c24xx_soc_platform, | ||
150 | .dai_link = &jive_dai, | 151 | .dai_link = &jive_dai, |
151 | .num_links = 1, | 152 | .num_links = 1, |
152 | }; | 153 | }; |
@@ -157,9 +158,8 @@ static struct wm8750_setup_data jive_wm8750_setup = { | |||
157 | 158 | ||
158 | /* jive audio subsystem */ | 159 | /* jive audio subsystem */ |
159 | static struct snd_soc_device jive_snd_devdata = { | 160 | static struct snd_soc_device jive_snd_devdata = { |
160 | .machine = &snd_soc_machine_jive, | 161 | .card = &snd_soc_machine_jive, |
161 | .platform = &s3c24xx_soc_platform, | 162 | .codec_dev = &soc_codec_dev_wm8750, |
162 | .codec_dev = &soc_codec_dev_wm8750_spi, | ||
163 | .codec_data = &jive_wm8750_setup, | 163 | .codec_data = &jive_wm8750_setup, |
164 | }; | 164 | }; |
165 | 165 | ||
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index 295a4c910262..689ffcd17e1f 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c | |||
@@ -473,9 +473,9 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, | |||
473 | /* default table of all avaialable root fs divisors */ | 473 | /* default table of all avaialable root fs divisors */ |
474 | static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; | 474 | static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; |
475 | 475 | ||
476 | int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, | 476 | int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, |
477 | unsigned int *fstab, | 477 | unsigned int *fstab, |
478 | unsigned int rate, struct clk *clk) | 478 | unsigned int rate, struct clk *clk) |
479 | { | 479 | { |
480 | unsigned long clkrate = clk_get_rate(clk); | 480 | unsigned long clkrate = clk_get_rate(clk); |
481 | unsigned int div; | 481 | unsigned int div; |
@@ -531,7 +531,7 @@ int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, | |||
531 | 531 | ||
532 | return 0; | 532 | return 0; |
533 | } | 533 | } |
534 | EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate); | 534 | EXPORT_SYMBOL_GPL(s3c_i2sv2_iis_calc_rate); |
535 | 535 | ||
536 | int s3c_i2sv2_probe(struct platform_device *pdev, | 536 | int s3c_i2sv2_probe(struct platform_device *pdev, |
537 | struct snd_soc_dai *dai, | 537 | struct snd_soc_dai *dai, |
@@ -624,10 +624,12 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai) | |||
624 | 624 | ||
625 | int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) | 625 | int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) |
626 | { | 626 | { |
627 | dai->ops.trigger = s3c2412_i2s_trigger; | 627 | struct snd_soc_dai_ops *ops = dai->ops; |
628 | dai->ops.hw_params = s3c2412_i2s_hw_params; | 628 | |
629 | dai->ops.set_fmt = s3c2412_i2s_set_fmt; | 629 | ops->trigger = s3c2412_i2s_trigger; |
630 | dai->ops.set_clkdiv = s3c2412_i2s_set_clkdiv; | 630 | ops->hw_params = s3c2412_i2s_hw_params; |
631 | ops->set_fmt = s3c2412_i2s_set_fmt; | ||
632 | ops->set_clkdiv = s3c2412_i2s_set_clkdiv; | ||
631 | 633 | ||
632 | dai->suspend = s3c2412_i2s_suspend; | 634 | dai->suspend = s3c2412_i2s_suspend; |
633 | dai->resume = s3c2412_i2s_resume; | 635 | dai->resume = s3c2412_i2s_resume; |
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index 1ca3cdaa8213..b7e0b3f0bfc8 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c | |||
@@ -33,8 +33,8 @@ | |||
33 | 33 | ||
34 | #include <plat/regs-s3c2412-iis.h> | 34 | #include <plat/regs-s3c2412-iis.h> |
35 | 35 | ||
36 | #include <plat/regs-gpio.h> | ||
37 | #include <plat/audio.h> | 36 | #include <plat/audio.h> |
37 | #include <mach/regs-gpio.h> | ||
38 | #include <mach/dma.h> | 38 | #include <mach/dma.h> |
39 | 39 | ||
40 | #include "s3c24xx-pcm.h" | 40 | #include "s3c24xx-pcm.h" |
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile index 23dadd5a11cd..388999653aaa 100644 --- a/sound/usb/caiaq/Makefile +++ b/sound/usb/caiaq/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o | 1 | snd-usb-caiaq-y := device.o audio.o midi.o control.o |
2 | snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o | 2 | snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += input.o |
3 | 3 | ||
4 | obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o | 4 | obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o |
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/audio.c index 08d51e0c9fea..3f45c0fe61ab 100644 --- a/sound/usb/caiaq/caiaq-audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -16,20 +16,14 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/spinlock.h> | ||
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
24 | #include <linux/spinlock.h> | ||
25 | #include <sound/core.h> | 22 | #include <sound/core.h> |
26 | #include <sound/initval.h> | ||
27 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
28 | #include <sound/rawmidi.h> | ||
29 | #include <linux/input.h> | ||
30 | 24 | ||
31 | #include "caiaq-device.h" | 25 | #include "device.h" |
32 | #include "caiaq-audio.h" | 26 | #include "audio.h" |
33 | 27 | ||
34 | #define N_URBS 32 | 28 | #define N_URBS 32 |
35 | #define CLOCK_DRIFT_TOLERANCE 5 | 29 | #define CLOCK_DRIFT_TOLERANCE 5 |
diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/audio.h index 8ab1f8d9529e..8ab1f8d9529e 100644 --- a/sound/usb/caiaq/caiaq-audio.h +++ b/sound/usb/caiaq/audio.h | |||
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/control.c index e92c2bbf4fe9..537102ba6b9d 100644 --- a/sound/usb/caiaq/caiaq-control.c +++ b/sound/usb/caiaq/control.c | |||
@@ -18,17 +18,13 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
22 | #include <sound/control.h> | ||
23 | #include <sound/core.h> | 23 | #include <sound/core.h> |
24 | #include <sound/initval.h> | ||
25 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
26 | #include <sound/rawmidi.h> | ||
27 | #include <sound/control.h> | ||
28 | #include <linux/input.h> | ||
29 | 25 | ||
30 | #include "caiaq-device.h" | 26 | #include "device.h" |
31 | #include "caiaq-control.h" | 27 | #include "control.h" |
32 | 28 | ||
33 | #define CNT_INTVAL 0x10000 | 29 | #define CNT_INTVAL 0x10000 |
34 | 30 | ||
diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/control.h index 2e7ab1aa4fb3..2e7ab1aa4fb3 100644 --- a/sound/usb/caiaq/caiaq-control.h +++ b/sound/usb/caiaq/control.h | |||
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/device.c index cf573a982fdc..6d517705da0e 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -19,27 +19,20 @@ | |||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
25 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/module.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/usb.h> | 26 | #include <linux/usb.h> |
27 | #include <linux/input.h> | ||
28 | #include <linux/spinlock.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/initval.h> | 27 | #include <sound/initval.h> |
28 | #include <sound/core.h> | ||
31 | #include <sound/pcm.h> | 29 | #include <sound/pcm.h> |
32 | #include <sound/rawmidi.h> | ||
33 | #include <sound/control.h> | ||
34 | |||
35 | #include "caiaq-device.h" | ||
36 | #include "caiaq-audio.h" | ||
37 | #include "caiaq-midi.h" | ||
38 | #include "caiaq-control.h" | ||
39 | 30 | ||
40 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 31 | #include "device.h" |
41 | #include "caiaq-input.h" | 32 | #include "audio.h" |
42 | #endif | 33 | #include "midi.h" |
34 | #include "control.h" | ||
35 | #include "input.h" | ||
43 | 36 | ||
44 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
45 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13"); | 38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13"); |
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/device.h index 4cce1ad7493d..4cce1ad7493d 100644 --- a/sound/usb/caiaq/caiaq-device.h +++ b/sound/usb/caiaq/device.h | |||
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/input.c index f743847a5e5a..a48d309bd94c 100644 --- a/sound/usb/caiaq/caiaq-input.c +++ b/sound/usb/caiaq/input.c | |||
@@ -17,17 +17,12 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/input.h> | ||
23 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
24 | #include <linux/usb/input.h> | 21 | #include <linux/usb/input.h> |
25 | #include <linux/spinlock.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/rawmidi.h> | ||
28 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
29 | #include "caiaq-device.h" | 23 | |
30 | #include "caiaq-input.h" | 24 | #include "device.h" |
25 | #include "input.h" | ||
31 | 26 | ||
32 | static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; | 27 | static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; |
33 | static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, | 28 | static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, |
diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/input.h index ced535577864..ced535577864 100644 --- a/sound/usb/caiaq/caiaq-input.h +++ b/sound/usb/caiaq/input.h | |||
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/midi.c index f19fd360c936..8fa8cd88d763 100644 --- a/sound/usb/caiaq/caiaq-midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -16,20 +16,13 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/usb.h> | 19 | #include <linux/usb.h> |
24 | #include <linux/input.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/rawmidi.h> | 20 | #include <sound/rawmidi.h> |
21 | #include <sound/core.h> | ||
28 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
29 | 23 | ||
30 | #include "caiaq-device.h" | 24 | #include "device.h" |
31 | #include "caiaq-midi.h" | 25 | #include "midi.h" |
32 | |||
33 | 26 | ||
34 | static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) | 27 | static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) |
35 | { | 28 | { |
diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/midi.h index 9d16db027fc3..9d16db027fc3 100644 --- a/sound/usb/caiaq/caiaq-midi.h +++ b/sound/usb/caiaq/midi.h | |||
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 98276aafefe6..012ff1f6f8af 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, | |||
349 | if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) | 349 | if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) |
350 | return -ENOTTY; | 350 | return -ENOTTY; |
351 | 351 | ||
352 | cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); | 352 | cfg = memdup_user((void *)arg, sizeof(*cfg)); |
353 | if (!cfg) | 353 | if (IS_ERR(cfg)) |
354 | return -ENOMEM; | 354 | return PTR_ERR(cfg); |
355 | 355 | ||
356 | if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) { | ||
357 | err = -EFAULT; | ||
358 | goto free; | ||
359 | } | ||
360 | if (cfg->version != USB_STREAM_INTERFACE_VERSION) { | 356 | if (cfg->version != USB_STREAM_INTERFACE_VERSION) { |
361 | err = -ENXIO; | 357 | err = -ENXIO; |
362 | goto free; | 358 | goto free; |
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 4af8740db717..f3d8f71265dd 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c | |||
@@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, | |||
203 | 203 | ||
204 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { | 204 | if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { |
205 | struct usb_device* dev = priv->chip.dev; | 205 | struct usb_device* dev = priv->chip.dev; |
206 | char *buf = kmalloc(dsp->length, GFP_KERNEL); | 206 | char *buf; |
207 | if (!buf) | 207 | |
208 | return -ENOMEM; | 208 | buf = memdup_user(dsp->image, dsp->length); |
209 | if (copy_from_user(buf, dsp->image, dsp->length)) { | 209 | if (IS_ERR(buf)) |
210 | kfree(buf); | 210 | return PTR_ERR(buf); |
211 | return -EFAULT; | 211 | |
212 | } | ||
213 | err = usb_set_interface(dev, 0, 1); | 212 | err = usb_set_interface(dev, 0, 1); |
214 | if (err) | 213 | if (err) |
215 | snd_printk(KERN_ERR "usb_set_interface error \n"); | 214 | snd_printk(KERN_ERR "usb_set_interface error \n"); |