From 249bba03f1051f4984538f66b9e7d36674c61e5c Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sat, 24 Dec 2011 11:56:46 +0000 Subject: 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 --- firmware/drivers/audio/as3514.c | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'firmware/drivers/audio') 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[] = { #endif }; +#ifndef SAMSUNG_YPR0 /* Shadow registers */ static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ @@ -110,7 +111,29 @@ static void as3514_write_masked(unsigned int reg, unsigned int bits, { as3514_write(reg, (as3514_regs[reg] & ~mask) | (bits & mask)); } +#else +static void as3514_write(unsigned int reg, unsigned int value) +{ + ascodec_write(reg, value); +} + +/* Helpers to set/clear bits */ +static void as3514_set(unsigned int reg, unsigned int bits) +{ + ascodec_write(reg, ascodec_read(reg) | bits); +} + +static void as3514_clear(unsigned int reg, unsigned int bits) +{ + ascodec_write(reg, ascodec_read(reg) & ~bits); +} +static void as3514_write_masked(unsigned int reg, unsigned int bits, + unsigned int mask) +{ + ascodec_write(reg, (ascodec_read(reg) & ~mask) | (bits & mask)); +} +#endif /* convert tenth of dB volume to master volume register value */ int tenthdb2master(int db) { @@ -145,8 +168,11 @@ int sound_val2phys(int setting, int value) */ void audiohw_preinit(void) { + +#ifndef SAMSUNG_YPR0 /* read all reg values */ ascodec_readbytes(0x0, AS3514_NUM_AUDIO_REGS, as3514_regs); +#endif #ifdef HAVE_AS3543 @@ -284,9 +310,14 @@ void audiohw_set_master_vol(int vol_l, int vol_r) #if CONFIG_CPU == AS3525v2 #define MIXER_MAX_VOLUME 0x1b #else /* lets leave the AS3514 alone until its better tested*/ +#ifdef SAMSUNG_YPR0 +#define MIXER_MAX_VOLUME 0x1a +#else #define MIXER_MAX_VOLUME 0x16 #endif +#endif +#ifndef SAMSUNG_YPR0 if (vol_r <= MIXER_MAX_VOLUME) { mix_r = vol_r; hph_r = 0; @@ -302,7 +333,16 @@ void audiohw_set_master_vol(int vol_l, int vol_r) mix_l = MIXER_MAX_VOLUME; hph_l = vol_l - MIXER_MAX_VOLUME; } - +#else +/* Okay. This is shit coded indeed. It is just a test. + Some considerations: Samsung keeps DAC constantly to 0x1a volume. It modifies only the headphone amp volume +*/ + + mix_r = 0x1a; + mix_l = 0x1a; + hph_l = vol_l; + hph_r = vol_r; +#endif as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK); as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK); -- cgit v1.2.3