usb: gadget: audio: Set default sample_rate to 16KHz
Change both playback and capture default sample rate to 16Khz to support better audio quality. Change-Id: If0c53321ba25730119131057d4b906dade65878f Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
This commit is contained in:
parent
0ab0c5080b
commit
4bca454cce
|
@ -42,11 +42,11 @@ static int req_playback_count = 48;
|
|||
module_param(req_playback_count, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(req_playback_count, "ISO OUT endpoint (playback) request count");
|
||||
|
||||
static int audio_playback_buf_size = 64*32;
|
||||
static int audio_playback_buf_size = 64 * PLAYBACK_EP_MAX_PACKET_SIZE;
|
||||
module_param(audio_playback_buf_size, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(audio_playback_buf_size, "Audio buffer size");
|
||||
|
||||
#define CAPTURE_EP_MAX_PACKET_SIZE 16
|
||||
#define CAPTURE_EP_MAX_PACKET_SIZE 32
|
||||
static int req_capture_buf_size = CAPTURE_EP_MAX_PACKET_SIZE;
|
||||
module_param(req_capture_buf_size, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(req_capture_buf_size, "ISO IN endpoint (capture) request buffer size");
|
||||
|
@ -55,7 +55,7 @@ static int req_capture_count = 48;
|
|||
module_param(req_capture_count, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(req_capture_count, "ISO IN endpoint (capture) request count");
|
||||
|
||||
static int audio_capture_buf_size = 64*16;
|
||||
static int audio_capture_buf_size = 64 * CAPTURE_EP_MAX_PACKET_SIZE;
|
||||
module_param(audio_capture_buf_size, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(audio_capture_buf_size, "Microphone Audio buffer size");
|
||||
|
||||
|
@ -1148,10 +1148,14 @@ static void f_audio_build_desc(struct f_audio *audio)
|
|||
rate = u_audio_get_playback_rate(card);
|
||||
sam_freq = speaker_as_type_i_desc.tSamFreq[0];
|
||||
memcpy(sam_freq, &rate, 3);
|
||||
/* Update maxP as per sample rate, bInterval assumed as 1msec */
|
||||
speaker_as_ep_out_desc.wMaxPacketSize = (rate / 1000) * 2;
|
||||
|
||||
rate = u_audio_get_capture_rate(card);
|
||||
sam_freq = microphone_as_type_i_desc.tSamFreq[0];
|
||||
memcpy(sam_freq, &rate, 3);
|
||||
/* Update maxP as per sample rate, bInterval assumed as 1msec */
|
||||
microphone_as_ep_in_desc.wMaxPacketSize = (rate / 1000) * 2;
|
||||
|
||||
/* Todo: Set Sample bits and other parameters */
|
||||
|
||||
|
|
|
@ -45,6 +45,10 @@ static char *fn_cntl = FILE_CONTROL;
|
|||
module_param(fn_cntl, charp, S_IRUGO);
|
||||
MODULE_PARM_DESC(fn_cntl, "Control device file name");
|
||||
|
||||
static unsigned sample_rate = 16000;
|
||||
module_param(sample_rate, uint, S_IRUGO|S_IWUSR);
|
||||
MODULE_PARM_DESC(sample_rate, "Sample rate for playback and capture");
|
||||
|
||||
static struct gaudio *the_card;
|
||||
|
||||
static bool audio_reinit;
|
||||
|
@ -152,13 +156,13 @@ static int playback_prepare_params(struct gaudio_snd_dev *snd)
|
|||
/*
|
||||
* SNDRV_PCM_ACCESS_RW_INTERLEAVED,
|
||||
* SNDRV_PCM_FORMAT_S16_LE
|
||||
* CHANNELS: 2
|
||||
* RATE: 8000
|
||||
* CHANNELS: 1
|
||||
* RATE: 16K default, user configurable
|
||||
*/
|
||||
snd->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
|
||||
snd->format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
snd->channels = 2;
|
||||
snd->rate = 8000;
|
||||
snd->channels = 1;
|
||||
snd->rate = sample_rate;
|
||||
|
||||
params = kzalloc(sizeof(*params), GFP_KERNEL);
|
||||
if (!params)
|
||||
|
@ -244,12 +248,12 @@ static int capture_prepare_params(struct gaudio_snd_dev *snd)
|
|||
* SNDRV_PCM_ACCESS_RW_INTERLEAVED,
|
||||
* SNDRV_PCM_FORMAT_S16_LE
|
||||
* CHANNELS: 1
|
||||
* RATE: 8000
|
||||
* RATE: 16K default, user configurable
|
||||
*/
|
||||
snd->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
|
||||
snd->format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
snd->channels = 1;
|
||||
snd->rate = 8000;
|
||||
snd->rate = sample_rate;
|
||||
|
||||
params = kzalloc(sizeof(*params), GFP_KERNEL);
|
||||
if (!params) {
|
||||
|
@ -334,13 +338,13 @@ static int playback_default_hw_params(struct gaudio_snd_dev *snd)
|
|||
/*
|
||||
* SNDRV_PCM_ACCESS_RW_INTERLEAVED,
|
||||
* SNDRV_PCM_FORMAT_S16_LE
|
||||
* CHANNELS: 2
|
||||
* RATE: 8000
|
||||
* CHANNELS: 1
|
||||
* RATE: 16K default, user configurable
|
||||
*/
|
||||
snd->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
|
||||
snd->format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
snd->channels = 2;
|
||||
snd->rate = 8000;
|
||||
snd->channels = 1;
|
||||
snd->rate = sample_rate;
|
||||
|
||||
params = kzalloc(sizeof(*params), GFP_KERNEL);
|
||||
if (!params)
|
||||
|
@ -378,12 +382,12 @@ static int capture_default_hw_params(struct gaudio_snd_dev *snd)
|
|||
* SNDRV_PCM_ACCESS_RW_INTERLEAVED,
|
||||
* SNDRV_PCM_FORMAT_S16_LE
|
||||
* CHANNELS: 1
|
||||
* RATE: 8000
|
||||
* RATE: 16K default, user configurable
|
||||
*/
|
||||
snd->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
|
||||
snd->format = SNDRV_PCM_FORMAT_S16_LE;
|
||||
snd->channels = 1;
|
||||
snd->rate = 8000;
|
||||
snd->rate = sample_rate;
|
||||
|
||||
params = kzalloc(sizeof(*params), GFP_KERNEL);
|
||||
if (!params)
|
||||
|
|
Loading…
Reference in New Issue