summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/wm8978.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-12 11:01:07 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-12 11:01:07 +0000
commite69d567d9ebf7d236ff9663b11ac396cc71dcd75 (patch)
tree093b9d1bc979d79be1fcd0daac1d8daf8ac55503 /firmware/drivers/audio/wm8978.c
parent0ad97d13fc52b28de566dc0ddaf7245583eec2cc (diff)
downloadrockbox-e69d567d9ebf7d236ff9663b11ac396cc71dcd75.tar.gz
rockbox-e69d567d9ebf7d236ff9663b11ac396cc71dcd75.zip
Bring consistency to pcm implementation and samplerate handling. Less low-level duplication. A small test_sampr fix so it works on coldfire again.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19400 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio/wm8978.c')
-rw-r--r--firmware/drivers/audio/wm8978.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/firmware/drivers/audio/wm8978.c b/firmware/drivers/audio/wm8978.c
index 6a7c974f43..d8bf05063f 100644
--- a/firmware/drivers/audio/wm8978.c
+++ b/firmware/drivers/audio/wm8978.c
@@ -363,9 +363,9 @@ void audiohw_mute(bool mute)
363 } 363 }
364} 364}
365 365
366void audiohw_set_frequency(int sampling_control) 366void audiohw_set_frequency(int fsel)
367{ 367{
368 /* For 16.9344MHz MCLK */ 368 /* For 16.9344MHz MCLK, codec as master. */
369 static const struct 369 static const struct
370 { 370 {
371 uint32_t plln : 8; 371 uint32_t plln : 8;
@@ -374,7 +374,7 @@ void audiohw_set_frequency(int sampling_control)
374 uint32_t pllk3 : 9; 374 uint32_t pllk3 : 9;
375 unsigned char mclkdiv; 375 unsigned char mclkdiv;
376 unsigned char filter; 376 unsigned char filter;
377 } sctrl_table[HW_NUM_FREQ] = 377 } srctrl_table[HW_NUM_FREQ] =
378 { 378 {
379 [HW_FREQ_8] = /* PLL = 65.536MHz */ 379 [HW_FREQ_8] = /* PLL = 65.536MHz */
380 { 380 {
@@ -450,16 +450,14 @@ void audiohw_set_frequency(int sampling_control)
450 unsigned int plln; 450 unsigned int plln;
451 unsigned int mclkdiv; 451 unsigned int mclkdiv;
452 452
453 if ((unsigned)sampling_control >= ARRAYLEN(sctrl_table)) 453 if ((unsigned)fsel >= HW_NUM_FREQ)
454 sampling_control = HW_FREQ_DEFAULT; 454 fsel = HW_FREQ_DEFAULT;
455
456 455
457 /* Setup filters. */ 456 /* Setup filters. */
458 wmc_write(WMC_ADDITIONAL_CTRL, 457 wmc_write(WMC_ADDITIONAL_CTRL, srctrl_table[fsel].filter);
459 sctrl_table[sampling_control].filter);
460 458
461 plln = sctrl_table[sampling_control].plln; 459 plln = srctrl_table[fsel].plln;
462 mclkdiv = sctrl_table[sampling_control].mclkdiv; 460 mclkdiv = srctrl_table[fsel].mclkdiv;
463 461
464 if (plln != 0) 462 if (plln != 0)
465 { 463 {
@@ -467,9 +465,9 @@ void audiohw_set_frequency(int sampling_control)
467 465
468 /* Program PLL. */ 466 /* Program PLL. */
469 wmc_write(WMC_PLL_N, plln); 467 wmc_write(WMC_PLL_N, plln);
470 wmc_write(WMC_PLL_K1, sctrl_table[sampling_control].pllk1); 468 wmc_write(WMC_PLL_K1, srctrl_table[fsel].pllk1);
471 wmc_write(WMC_PLL_K2, sctrl_table[sampling_control].pllk2); 469 wmc_write(WMC_PLL_K2, srctrl_table[fsel].pllk2);
472 wmc_write(WMC_PLL_K3, sctrl_table[sampling_control].pllk3); 470 wmc_write(WMC_PLL_K3, srctrl_table[fsel].pllk3);
473 471
474 /* Turn on PLL. */ 472 /* Turn on PLL. */
475 wmc_set(WMC_POWER_MANAGEMENT1, WMC_PLLEN); 473 wmc_set(WMC_POWER_MANAGEMENT1, WMC_PLLEN);