From: Jarvis Jang Date: Wed, 27 Sep 2017 09:00:37 +0000 (+0900) Subject: Modify sample rate entry function usage X-Git-Tag: 1.1_Public_Release~124^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7122998c70d0cf6af179ce7d0d4e1f8510a06d51;p=rtos%2Ftinyara.git Modify sample rate entry function usage --- diff --git a/os/drivers/audio/alc5658.c b/os/drivers/audio/alc5658.c index 244dbe9..4e30d7c 100644 --- a/os/drivers/audio/alc5658.c +++ b/os/drivers/audio/alc5658.c @@ -116,16 +116,17 @@ static const struct audio_ops_s g_audioops = { struct sample_rate_entry_s { uint16_t samprate; t_codec_init_script_entry *script; + int size; }; static const struct sample_rate_entry_s g_sample_entry[] = { - {AUDIO_SAMP_RATE_8K, codec_init_pll_8K}, - {AUDIO_SAMP_RATE_11K, codec_init_pll_11K}, - {AUDIO_SAMP_RATE_16K, codec_init_pll_16K}, - {AUDIO_SAMP_RATE_22K, codec_init_pll_22K}, - {AUDIO_SAMP_RATE_32K, codec_init_pll_32K}, - {AUDIO_SAMP_RATE_44K, codec_init_pll_44K}, - {AUDIO_SAMP_RATE_48K, codec_init_pll_48K}, + {AUDIO_SAMP_RATE_8K, codec_init_pll_8K, sizeof(codec_init_pll_8K)}, + {AUDIO_SAMP_RATE_11K, codec_init_pll_11K, sizeof(codec_init_pll_11K)}, + {AUDIO_SAMP_RATE_16K, codec_init_pll_16K, sizeof(codec_init_pll_16K)}, + {AUDIO_SAMP_RATE_22K, codec_init_pll_22K, sizeof(codec_init_pll_22K)}, + {AUDIO_SAMP_RATE_32K, codec_init_pll_32K, sizeof(codec_init_pll_32K)}, + {AUDIO_SAMP_RATE_44K, codec_init_pll_44K, sizeof(codec_init_pll_44K)}, + {AUDIO_SAMP_RATE_48K, codec_init_pll_48K, sizeof(codec_init_pll_48K)} }; /**************************************************************************** @@ -269,16 +270,16 @@ static void alc5658_exec_i2c_script(FAR struct alc5658_dev_s *priv, t_codec_init * Check the given sample rate's valididation with alc5658 and return specific script * ************************************************************************************/ -static t_codec_init_script_entry *alc5658_get_sample_rate_script(uint16_t sample_rate) +static int alc5658_get_sample_rate_script(uint16_t sample_rate) { int count = sizeof(g_sample_entry) / sizeof(struct sample_rate_entry_s); int i; for (i = 0; i < count; i++) { if (sample_rate == g_sample_entry[i].samprate) { - return g_sample_entry[i].script; + return i; } } - return NULL; + return -1; } /************************************************************************************ @@ -636,7 +637,7 @@ static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct } /* Check validation of sample rate first */ - if (alc5658_get_sample_rate_script(caps->ac_controls.hw[0]) == NULL) { + if (alc5658_get_sample_rate_script(caps->ac_controls.hw[0]) == -1) { auddbg("ERROR: Not supported Format: %lld\n", caps->ac_controls.hw[0]); return -EINVAL; } @@ -713,7 +714,7 @@ static int alc5658_start(FAR struct audio_lowerhalf_s *dev) { FAR struct alc5658_dev_s *priv = (FAR struct alc5658_dev_s *)dev; - t_codec_init_script_entry *sample; + int entry; if (priv->running) { return OK; } @@ -721,11 +722,12 @@ static int alc5658_start(FAR struct audio_lowerhalf_s *dev) audvdbg(" alc5658_start Entry\n"); alc5658_exec_i2c_script(priv, codec_init_inout_script1, sizeof(codec_init_inout_script1) / sizeof(t_codec_init_script_entry)); - sample = alc5658_get_sample_rate_script(priv->samprate); - if (sample == NULL) { + entry = alc5658_get_sample_rate_script(priv->samprate); + if (entry == -1) { return -EINVAL; } - alc5658_exec_i2c_script(priv, sample, sizeof(sample) / sizeof(t_codec_init_script_entry)); + + alc5658_exec_i2c_script(priv, g_sample_entry[entry].script, g_sample_entry[entry].size / sizeof(t_codec_init_script_entry)); alc5658_exec_i2c_script(priv, codec_init_inout_script2, sizeof(codec_init_inout_script2) / sizeof(t_codec_init_script_entry)); alc5658_setregs(priv);