aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSebastian Reimers <sebastian.reimers@googlemail.com>2014-07-03 14:15:28 -0400
committerFelipe Balbi <balbi@ti.com>2014-07-16 13:50:40 -0400
commit55f7840ac4c6224263d88014b69f8cd35fa66817 (patch)
tree5999cdb78ed8853c5395d46a368bbab40e4e650e /drivers/usb
parentc9d872592611b98d3481e978f93b90a5fa194252 (diff)
usb: gadget: f_uac2: Fix pcm sample size selection
The pcm playback and capture sample size format was fixed SNDRV_PCM_FMTBIT_S16_LE. This patch respects also 16, 24 and 32 bit p_ssize and c_ssize values. Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sebastian Reimers <sebastian.reimers@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/function/f_uac2.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 6261db4a9910..3ed89ecc8d6d 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -348,14 +348,34 @@ static int uac2_pcm_open(struct snd_pcm_substream *substream)
348 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 348 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
349 spin_lock_init(&uac2->p_prm.lock); 349 spin_lock_init(&uac2->p_prm.lock);
350 runtime->hw.rate_min = p_srate; 350 runtime->hw.rate_min = p_srate;
351 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! p_ssize ! */ 351 switch (p_ssize) {
352 case 3:
353 runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
354 break;
355 case 4:
356 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
357 break;
358 default:
359 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
360 break;
361 }
352 runtime->hw.channels_min = num_channels(p_chmask); 362 runtime->hw.channels_min = num_channels(p_chmask);
353 runtime->hw.period_bytes_min = 2 * uac2->p_prm.max_psize 363 runtime->hw.period_bytes_min = 2 * uac2->p_prm.max_psize
354 / runtime->hw.periods_min; 364 / runtime->hw.periods_min;
355 } else { 365 } else {
356 spin_lock_init(&uac2->c_prm.lock); 366 spin_lock_init(&uac2->c_prm.lock);
357 runtime->hw.rate_min = c_srate; 367 runtime->hw.rate_min = c_srate;
358 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! c_ssize ! */ 368 switch (c_ssize) {
369 case 3:
370 runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
371 break;
372 case 4:
373 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
374 break;
375 default:
376 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
377 break;
378 }
359 runtime->hw.channels_min = num_channels(c_chmask); 379 runtime->hw.channels_min = num_channels(c_chmask);
360 runtime->hw.period_bytes_min = 2 * uac2->c_prm.max_psize 380 runtime->hw.period_bytes_min = 2 * uac2->c_prm.max_psize
361 / runtime->hw.periods_min; 381 / runtime->hw.periods_min;