diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-05-03 18:08:00 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-05-03 18:08:00 +0000 |
commit | d989f19eda42aa0fbd2430400faace2a51df4e98 (patch) | |
tree | eed93c636d47a4f34fba1de857530c2f29780a5b /firmware | |
parent | 441a8d8054f4cb16f7e7ee5adb06614821e89527 (diff) | |
download | rockbox-d989f19eda42aa0fbd2430400faace2a51df4e98.tar.gz rockbox-d989f19eda42aa0fbd2430400faace2a51df4e98.zip |
No more ear doctor visits after powering/unpowering the Gigabeat. Cleanup a little too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13312 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/wm8751.c | 84 | ||||
-rw-r--r-- | firmware/export/wm8751.h | 1 | ||||
-rw-r--r-- | firmware/powermgmt.c | 21 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c | 10 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/wmcodec-meg-fx.c | 31 |
5 files changed, 52 insertions, 95 deletions
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c index 21ff4728b3..2f79f27c7c 100644 --- a/firmware/drivers/audio/wm8751.c +++ b/firmware/drivers/audio/wm8751.c | |||
@@ -78,53 +78,45 @@ static int tone_tenthdb2hw(int value) | |||
78 | 78 | ||
79 | void audiohw_reset(void); | 79 | void audiohw_reset(void); |
80 | 80 | ||
81 | /* Silently enable / disable audio output */ | 81 | /* Reset and power up the WM8751 */ |
82 | void audiohw_enable_output(bool enable) | 82 | void audiohw_preinit(void) |
83 | { | 83 | { |
84 | if (enable) | 84 | /* |
85 | { | 85 | * 1. Switch on power supplies. |
86 | /* reset the I2S controller into known state */ | 86 | * By default the WM8751 is in Standby Mode, the DAC is |
87 | i2s_reset(); | 87 | * digitally muted and the Audio Interface, Line outputs |
88 | 88 | * and Headphone outputs are all OFF (DACMU = 1 Power | |
89 | /* | 89 | * Management registers 1 and 2 are all zeros). |
90 | * 1. Switch on power supplies. | 90 | */ |
91 | * By default the WM87551L is in Standby Mode, the DAC is | 91 | wmcodec_write(RESET, RESET_RESET); /*Reset*/ |
92 | * digitally muted and the Audio Interface, Line outputs | 92 | |
93 | * and Headphone outputs are all OFF (DACMU = 1 Power | 93 | /* 2. Enable Vmid and VREF. */ |
94 | * Management registers 1 and 2 are all zeros). | 94 | wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_5K); |
95 | */ | 95 | |
96 | wmcodec_write(RESET, RESET_RESET); /*Reset*/ | 96 | /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ |
97 | 97 | /* IWL=00(16 bit) FORMAT=10(I2S format) */ | |
98 | /* 2. Enable Vmid and VREF. */ | 98 | wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | |
99 | wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_500K); | 99 | AINTFCE_FORMAT_I2S); |
100 | 100 | } | |
101 | /* From app notes: allow Vref to stabilize to reduce clicks */ | 101 | |
102 | sleep(HZ/2); | 102 | /* Enable DACs and audio output after a short delay */ |
103 | 103 | void audiohw_postinit(void) | |
104 | /* 3. Enable DACs as required. */ | 104 | { |
105 | wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR); | 105 | /* From app notes: allow Vref to stabilize to reduce clicks */ |
106 | 106 | sleep(HZ); | |
107 | /* 4. Enable line and / or headphone output buffers as required. */ | 107 | |
108 | wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR | | 108 | /* 3. Enable DACs as required. */ |
109 | PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | | 109 | wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR); |
110 | PWRMGMT2_ROUT2); | 110 | |
111 | 111 | /* 4. Enable line and / or headphone output buffers as required. */ | |
112 | /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ | 112 | wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR | |
113 | /* IWL=00(16 bit) FORMAT=10(I2S format) */ | 113 | PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | |
114 | wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | | 114 | PWRMGMT2_ROUT2); |
115 | AINTFCE_FORMAT_I2S); | 115 | |
116 | 116 | wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT); | |
117 | /* Keep it quiet */ | 117 | wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT); |
118 | wmcodec_write(LOUT1, LOUT1_BITS | OUTPUT_MUTED); | 118 | |
119 | wmcodec_write(ROUT1, ROUT1_BITS | OUTPUT_MUTED); | 119 | audiohw_mute(false); |
120 | wmcodec_write(LOUT2, LOUT2_BITS | OUTPUT_MUTED); | ||
121 | wmcodec_write(ROUT2, ROUT2_BITS | OUTPUT_MUTED); | ||
122 | |||
123 | wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT); | ||
124 | wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT); | ||
125 | } | ||
126 | |||
127 | audiohw_mute(!enable); | ||
128 | } | 120 | } |
129 | 121 | ||
130 | int audiohw_set_master_vol(int vol_l, int vol_r) | 122 | int audiohw_set_master_vol(int vol_l, int vol_r) |
diff --git a/firmware/export/wm8751.h b/firmware/export/wm8751.h index 244d378b26..efeaa3609d 100644 --- a/firmware/export/wm8751.h +++ b/firmware/export/wm8751.h | |||
@@ -28,6 +28,7 @@ extern int tenthdb2mixer(int db); | |||
28 | 28 | ||
29 | extern void audiohw_reset(void); | 29 | extern void audiohw_reset(void); |
30 | extern int audiohw_init(void); | 30 | extern int audiohw_init(void); |
31 | extern void audiohw_preinit(void); | ||
31 | extern void audiohw_enable_output(bool enable); | 32 | extern void audiohw_enable_output(bool enable); |
32 | extern int audiohw_set_master_vol(int vol_l, int vol_r); | 33 | extern int audiohw_set_master_vol(int vol_l, int vol_r); |
33 | extern int audiohw_set_lineout_vol(int vol_l, int vol_r); | 34 | extern int audiohw_set_lineout_vol(int vol_l, int vol_r); |
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 3d87773394..000a8bb2ec 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -40,17 +40,7 @@ | |||
40 | #if CONFIG_TUNER | 40 | #if CONFIG_TUNER |
41 | #include "fmradio.h" | 41 | #include "fmradio.h" |
42 | #endif | 42 | #endif |
43 | #ifdef HAVE_UDA1380 | 43 | #include "sound.h" |
44 | #include "uda1380.h" | ||
45 | #elif defined(HAVE_TLV320) | ||
46 | #include "tlv320.h" | ||
47 | #elif defined(HAVE_WM8758) | ||
48 | #include "wm8758.h" | ||
49 | #elif defined(HAVE_WM8975) | ||
50 | #include "wm8975.h" | ||
51 | #elif defined(HAVE_WM8731) | ||
52 | #include "wm8731l.h" | ||
53 | #endif | ||
54 | #ifdef HAVE_LCD_BITMAP | 44 | #ifdef HAVE_LCD_BITMAP |
55 | #include "font.h" | 45 | #include "font.h" |
56 | #endif | 46 | #endif |
@@ -1323,15 +1313,10 @@ void shutdown_hw(void) | |||
1323 | 1313 | ||
1324 | #if CONFIG_CODEC != SWCODEC | 1314 | #if CONFIG_CODEC != SWCODEC |
1325 | mp3_shutdown(); | 1315 | mp3_shutdown(); |
1326 | #endif | 1316 | #else |
1327 | |||
1328 | #ifdef HAVE_UDA1380 | ||
1329 | audiohw_close(); | ||
1330 | #elif defined(HAVE_TLV320) | ||
1331 | audiohw_close(); | ||
1332 | #elif defined(HAVE_WM8758) || defined(HAVE_WM8975) | defined(HAVE_WM8731) | ||
1333 | audiohw_close(); | 1317 | audiohw_close(); |
1334 | #endif | 1318 | #endif |
1319 | |||
1335 | /* If HD is still active we try to wait for spindown, otherwise the | 1320 | /* If HD is still active we try to wait for spindown, otherwise the |
1336 | shutdown_timeout in power_thread_sleep will force a power off */ | 1321 | shutdown_timeout in power_thread_sleep will force a power off */ |
1337 | while(ata_disk_is_active()) | 1322 | while(ata_disk_is_active()) |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c index 45558767d3..09f846d645 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/pcm-meg-fx.c | |||
@@ -31,8 +31,8 @@ | |||
31 | #define GIGABEAT_44100HZ (0x11 << 1) | 31 | #define GIGABEAT_44100HZ (0x11 << 1) |
32 | #define GIGABEAT_88200HZ (0x1f << 1) | 32 | #define GIGABEAT_88200HZ (0x1f << 1) |
33 | 33 | ||
34 | static int pcm_freq = HW_SAMPR_DEFAULT; /* 44.1 is default */ | 34 | static int pcm_freq = 0; /* 44.1 is default */ |
35 | static int sr_ctrl = GIGABEAT_44100HZ; | 35 | static int sr_ctrl = 0; |
36 | #define FIFO_COUNT ((IISFCON >> 6) & 0x01F) | 36 | #define FIFO_COUNT ((IISFCON >> 6) & 0x01F) |
37 | 37 | ||
38 | /* number of bytes in FIFO */ | 38 | /* number of bytes in FIFO */ |
@@ -71,11 +71,10 @@ void pcm_init(void) | |||
71 | pcm_paused = false; | 71 | pcm_paused = false; |
72 | pcm_callback_for_more = NULL; | 72 | pcm_callback_for_more = NULL; |
73 | 73 | ||
74 | audiohw_init(); | ||
75 | audiohw_enable_output(true); | ||
76 | |||
77 | pcm_set_frequency(SAMPR_44); | 74 | pcm_set_frequency(SAMPR_44); |
78 | 75 | ||
76 | audiohw_init(); | ||
77 | |||
79 | /* init GPIO */ | 78 | /* init GPIO */ |
80 | GPCCON = (GPCCON & ~(3<<14)) | (1<<14); | 79 | GPCCON = (GPCCON & ~(3<<14)) | (1<<14); |
81 | GPCDAT |= 1<<7; | 80 | GPCDAT |= 1<<7; |
@@ -92,6 +91,7 @@ void pcm_init(void) | |||
92 | void pcm_postinit(void) | 91 | void pcm_postinit(void) |
93 | { | 92 | { |
94 | audiohw_postinit(); | 93 | audiohw_postinit(); |
94 | pcm_apply_settings(); | ||
95 | } | 95 | } |
96 | 96 | ||
97 | void pcm_play_dma_start(const void *addr, size_t size) | 97 | void pcm_play_dma_start(const void *addr, size_t size) |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/wmcodec-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/wmcodec-meg-fx.c index fe42b7527a..be23fa1783 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/wmcodec-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/wmcodec-meg-fx.c | |||
@@ -23,33 +23,14 @@ | |||
23 | * KIND, either express or implied. | 23 | * KIND, either express or implied. |
24 | * | 24 | * |
25 | ****************************************************************************/ | 25 | ****************************************************************************/ |
26 | #include "lcd.h" | ||
27 | #include "cpu.h" | 26 | #include "cpu.h" |
28 | #include "kernel.h" | 27 | #include "kernel.h" |
29 | #include "thread.h" | 28 | #include "sound.h" |
30 | #include "power.h" | ||
31 | #include "debug.h" | ||
32 | #include "system.h" | ||
33 | #include "sprintf.h" | ||
34 | #include "button.h" | ||
35 | #include "string.h" | ||
36 | #include "file.h" | ||
37 | #include "buffer.h" | ||
38 | #include "audio.h" | ||
39 | #include "i2c.h" | 29 | #include "i2c.h" |
40 | #include "i2c-meg-fx.h" | 30 | #include "i2c-meg-fx.h" |
41 | /* | ||
42 | * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit | ||
43 | */ | ||
44 | void i2s_reset(void) | ||
45 | { | ||
46 | } | ||
47 | 31 | ||
48 | /* | 32 | int audiohw_init(void) |
49 | * Initialise the WM8975 for playback via headphone and line out. | 33 | { |
50 | * Note, I'm using the WM8750 datasheet as its apparently close. | ||
51 | */ | ||
52 | int audiohw_init(void) { | ||
53 | /* reset I2C */ | 34 | /* reset I2C */ |
54 | i2c_init(); | 35 | i2c_init(); |
55 | 36 | ||
@@ -58,11 +39,9 @@ int audiohw_init(void) { | |||
58 | GPCCON |= (1 << 10); | 39 | GPCCON |= (1 << 10); |
59 | GPCDAT |= (1 << 5); | 40 | GPCDAT |= (1 << 5); |
60 | 41 | ||
61 | return 0; | 42 | audiohw_preinit(); |
62 | } | ||
63 | 43 | ||
64 | void audiohw_postinit(void) | 44 | return 0; |
65 | { | ||
66 | } | 45 | } |
67 | 46 | ||
68 | void wmcodec_write(int reg, int data) | 47 | void wmcodec_write(int reg, int data) |