diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-12-24 11:56:46 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-12-24 11:56:46 +0000 |
commit | 249bba03f1051f4984538f66b9e7d36674c61e5c (patch) | |
tree | b9a0d78e05269ed2043521ab0dfdad83aeaf2aff /firmware/drivers/audio/as3514.c | |
parent | 567e0ad93ef3048f2266932b10dcdb309b1a77c9 (diff) | |
download | rockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.tar.gz rockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.zip |
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio/as3514.c')
-rw-r--r-- | firmware/drivers/audio/as3514.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 64531cfc2b..0fe3070c19 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c | |||
@@ -78,6 +78,7 @@ const struct sound_settings_info audiohw_settings[] = { | |||
78 | #endif | 78 | #endif |
79 | }; | 79 | }; |
80 | 80 | ||
81 | #ifndef SAMSUNG_YPR0 | ||
81 | /* Shadow registers */ | 82 | /* Shadow registers */ |
82 | static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ | 83 | static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ |
83 | 84 | ||
@@ -110,7 +111,29 @@ static void as3514_write_masked(unsigned int reg, unsigned int bits, | |||
110 | { | 111 | { |
111 | as3514_write(reg, (as3514_regs[reg] & ~mask) | (bits & mask)); | 112 | as3514_write(reg, (as3514_regs[reg] & ~mask) | (bits & mask)); |
112 | } | 113 | } |
114 | #else | ||
115 | static void as3514_write(unsigned int reg, unsigned int value) | ||
116 | { | ||
117 | ascodec_write(reg, value); | ||
118 | } | ||
119 | |||
120 | /* Helpers to set/clear bits */ | ||
121 | static void as3514_set(unsigned int reg, unsigned int bits) | ||
122 | { | ||
123 | ascodec_write(reg, ascodec_read(reg) | bits); | ||
124 | } | ||
125 | |||
126 | static void as3514_clear(unsigned int reg, unsigned int bits) | ||
127 | { | ||
128 | ascodec_write(reg, ascodec_read(reg) & ~bits); | ||
129 | } | ||
113 | 130 | ||
131 | static void as3514_write_masked(unsigned int reg, unsigned int bits, | ||
132 | unsigned int mask) | ||
133 | { | ||
134 | ascodec_write(reg, (ascodec_read(reg) & ~mask) | (bits & mask)); | ||
135 | } | ||
136 | #endif | ||
114 | /* convert tenth of dB volume to master volume register value */ | 137 | /* convert tenth of dB volume to master volume register value */ |
115 | int tenthdb2master(int db) | 138 | int tenthdb2master(int db) |
116 | { | 139 | { |
@@ -145,8 +168,11 @@ int sound_val2phys(int setting, int value) | |||
145 | */ | 168 | */ |
146 | void audiohw_preinit(void) | 169 | void audiohw_preinit(void) |
147 | { | 170 | { |
171 | |||
172 | #ifndef SAMSUNG_YPR0 | ||
148 | /* read all reg values */ | 173 | /* read all reg values */ |
149 | ascodec_readbytes(0x0, AS3514_NUM_AUDIO_REGS, as3514_regs); | 174 | ascodec_readbytes(0x0, AS3514_NUM_AUDIO_REGS, as3514_regs); |
175 | #endif | ||
150 | 176 | ||
151 | #ifdef HAVE_AS3543 | 177 | #ifdef HAVE_AS3543 |
152 | 178 | ||
@@ -284,9 +310,14 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
284 | #if CONFIG_CPU == AS3525v2 | 310 | #if CONFIG_CPU == AS3525v2 |
285 | #define MIXER_MAX_VOLUME 0x1b | 311 | #define MIXER_MAX_VOLUME 0x1b |
286 | #else /* lets leave the AS3514 alone until its better tested*/ | 312 | #else /* lets leave the AS3514 alone until its better tested*/ |
313 | #ifdef SAMSUNG_YPR0 | ||
314 | #define MIXER_MAX_VOLUME 0x1a | ||
315 | #else | ||
287 | #define MIXER_MAX_VOLUME 0x16 | 316 | #define MIXER_MAX_VOLUME 0x16 |
288 | #endif | 317 | #endif |
318 | #endif | ||
289 | 319 | ||
320 | #ifndef SAMSUNG_YPR0 | ||
290 | if (vol_r <= MIXER_MAX_VOLUME) { | 321 | if (vol_r <= MIXER_MAX_VOLUME) { |
291 | mix_r = vol_r; | 322 | mix_r = vol_r; |
292 | hph_r = 0; | 323 | hph_r = 0; |
@@ -302,7 +333,16 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
302 | mix_l = MIXER_MAX_VOLUME; | 333 | mix_l = MIXER_MAX_VOLUME; |
303 | hph_l = vol_l - MIXER_MAX_VOLUME; | 334 | hph_l = vol_l - MIXER_MAX_VOLUME; |
304 | } | 335 | } |
305 | 336 | #else | |
337 | /* Okay. This is shit coded indeed. It is just a test. | ||
338 | Some considerations: Samsung keeps DAC constantly to 0x1a volume. It modifies only the headphone amp volume | ||
339 | */ | ||
340 | |||
341 | mix_r = 0x1a; | ||
342 | mix_l = 0x1a; | ||
343 | hph_l = vol_l; | ||
344 | hph_r = vol_r; | ||
345 | #endif | ||
306 | 346 | ||
307 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); | 347 | as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); |
308 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); | 348 | as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); |