From 85528242844b71ac45e5331363a48a2956c38275 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Sun, 8 Jan 2012 01:43:16 +0000 Subject: ascodec-target.h: remove move prototypes to ascodec.h move code to ascodec*.c YPR0: use adc-as3514.c instead of duplicating it TODO: merge as3514.h and ascodec.h ? git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31626 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 8 +- firmware/SOURCES | 1 + firmware/drivers/audio/as3514.c | 10 ++- firmware/export/ascodec.h | 37 ++++++++- firmware/target/arm/as3525/ascodec-as3525.c | 25 +++++- firmware/target/arm/as3525/ascodec-target.h | 96 --------------------- firmware/target/arm/as3525/backlight-e200v2-fuze.c | 2 +- firmware/target/arm/as3525/debug-as3525.c | 2 +- firmware/target/arm/as3525/power-as3525.c | 2 +- .../arm/as3525/sansa-c200v2/backlight-c200v2.c | 2 +- .../arm/as3525/sansa-clipplus/backlight-clip.c | 2 +- .../arm/as3525/sansa-clipv2/backlight-clipv2.c | 2 +- .../arm/as3525/sansa-clipzip/backlight-clipzip.c | 2 +- .../arm/as3525/sansa-fuzev2/backlight-fuzev2.c | 2 +- firmware/target/arm/as3525/system-as3525.c | 16 +++- firmware/target/arm/pp/ascodec-pp.c | 77 +++++++++++++---- firmware/target/arm/pp/ascodec-target.h | 97 ---------------------- firmware/target/arm/pp/i2c-pp.c | 3 +- firmware/target/hosted/ypr0/ascodec-target.h | 80 ------------------ firmware/target/hosted/ypr0/ascodec-ypr0.c | 37 +++++---- firmware/target/hosted/ypr0/backlight-ypr0.c | 3 +- firmware/target/hosted/ypr0/gpio_ypr0.c | 3 +- firmware/target/hosted/ypr0/gpio_ypr0.h | 3 +- firmware/target/hosted/ypr0/powermgmt-ypr0.c | 1 - firmware/target/hosted/ypr0/system-ypr0.c | 2 +- 25 files changed, 179 insertions(+), 336 deletions(-) delete mode 100644 firmware/target/arm/as3525/ascodec-target.h delete mode 100644 firmware/target/arm/pp/ascodec-target.h delete mode 100644 firmware/target/hosted/ypr0/ascodec-target.h diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 2a742408d2..e940d24fb0 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -108,11 +108,8 @@ #include "debug-target.h" #endif -#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \ - || (CONFIG_CPU == AS3525 && defined(CONFIG_CHARGING)) \ - || CONFIG_CPU == AS3525v2 +#if defined(HAVE_AS3514) && defined(CONFIG_CHARGING) #include "ascodec.h" -#include "as3514.h" #endif #ifdef IPOD_NANO2G @@ -1129,8 +1126,7 @@ static bool view_battery(void) lcd_puts(0, line++, "T Battery: ?"); } -#elif defined(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \ - CONFIG_CPU == AS3525v2 +#if defined(HAVE_AS3514) && defined(CONFIG_CHARGING) static const char * const chrgstate_strings[] = { [CHARGE_STATE_DISABLED - CHARGE_STATE_DISABLED]= "Disabled", diff --git a/firmware/SOURCES b/firmware/SOURCES index 2dd8b7b5b4..2c3f9ca0a7 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -64,6 +64,7 @@ target/hosted/sdl/app/button-application.c #endif #ifdef SAMSUNG_YPR0 +target/arm/adc-as3514.c #if (CONFIG_RTC == RTC_AS3514) drivers/rtc/rtc_as3514.c #else diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index f07ee80d3c..22609621df 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c @@ -252,8 +252,9 @@ void audiohw_postinit(void) /* wait until outputs have stabilized */ sleep(HZ/4); -#ifdef CPU_PP - ascodec_suppressor_on(false); +#ifdef SANSA_E200 /* check C200 */ + /* Release pop prevention */ + GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x08); #endif #if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200) @@ -334,8 +335,9 @@ void audiohw_close(void) /* mute headphones */ audiohw_mute(true); -#ifdef CPU_PP - ascodec_suppressor_on(true); +#ifdef SANSA_E200 /* check C200 */ + /* Set pop prevention */ + GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x08); #endif /* turn on common */ diff --git a/firmware/export/ascodec.h b/firmware/export/ascodec.h index 658153e420..3e104cbd07 100644 --- a/firmware/export/ascodec.h +++ b/firmware/export/ascodec.h @@ -23,13 +23,42 @@ #define _ASCODEC_H #include "config.h" +#include -#ifdef HAVE_AS3514 -#include "ascodec-target.h" +#include "as3514.h" + +#ifndef HAVE_AS3514 +# error Only for AS3514! +#endif + +void ascodec_init(void) INIT_ATTR; +void ascodec_close(void); + +void ascodec_lock(void); +void ascodec_unlock(void); + +int ascodec_write(unsigned int index, unsigned int value); + +int ascodec_read(unsigned int index); + +int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data); + +void ascodec_wait_adc_finished(void); + +#ifdef CONFIG_CHARGING +bool ascodec_endofch(void); +bool ascodec_chg_status(void); +void ascodec_monitor_endofch(void); +void ascodec_write_charger(int value); +int ascodec_read_charger(void); #endif -#ifdef SAMSUNG_YPR0 -#include "ascodec-target.h" +#ifdef HAVE_AS3543 +void ascodec_write_pmu(unsigned int index, unsigned int subreg, + unsigned int value); +int ascodec_read_pmu(unsigned int index, unsigned int subreg); #endif +void ascodec_suppressor_on(bool on); /* PP-only */ + #endif diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c index ddf6786409..be81178859 100644 --- a/firmware/target/arm/as3525/ascodec-as3525.c +++ b/firmware/target/arm/as3525/ascodec-as3525.c @@ -44,7 +44,7 @@ interrupt bit 7 is raised and DACNT is not decremented after the transfer. */ -#include "ascodec-target.h" +#include "ascodec.h" #include "clock-target.h" #include "kernel.h" #include "system.h" @@ -534,6 +534,29 @@ bool ascodec_chg_status(void) { return ascodec_enrd0_shadow & CHG_STATUS; } + +void ascodec_monitor_endofch(void) +{ + /* already enabled */ +} + +void ascodec_write_charger(int value) +{ +#if CONFIG_CPU == AS3525 + ascodec_write(AS3514_CHARGER, value); +#else + ascodec_write_pmu(AS3543_CHARGER, 1, value); +#endif +} + +int ascodec_read_charger(void) +{ +#if CONFIG_CPU == AS3525 + return ascodec_read(AS3514_CHARGER); +#else + return ascodec_read_pmu(AS3543_CHARGER, 1); +#endif +} #endif /* CONFIG_CHARGING */ /* diff --git a/firmware/target/arm/as3525/ascodec-target.h b/firmware/target/arm/as3525/ascodec-target.h deleted file mode 100644 index ece8c21dd0..0000000000 --- a/firmware/target/arm/as3525/ascodec-target.h +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Driver for AS3514 audio codec - * - * Copyright (c) 2007 Daniel Ankers - * Copyright (c) 2007 Christian Gmeiner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef _ASCODEC_TARGET_H -#define _ASCODEC_TARGET_H - -#ifndef SIMULATOR - -#include "config.h" -#include "as3514.h" -#include "kernel.h" /* for struct semaphore */ -#include "clock-target.h" /* for AS3525_I2C_PRESCALER */ -#include "system-arm.h" - -/* Charge Pump and Power management Settings */ -#define AS314_CP_DCDC3_SETTING \ - ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \ - (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \ - (0<<5) | /* LREG_CPnot Always write 0 */ \ - (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \ - (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\ - (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/ - -#define CVDD_1_20 0 -#define CVDD_1_15 1 -#define CVDD_1_10 2 -#define CVDD_1_05 3 - -void ascodec_init(void) INIT_ATTR; - -int ascodec_write(unsigned int index, unsigned int value); - -int ascodec_read(unsigned int index); - -int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data); - -void ascodec_lock(void); - -void ascodec_unlock(void); - -void ascodec_wait_adc_finished(void); - -static inline void ascodec_monitor_endofch(void) {} /* already enabled */ - -bool ascodec_endofch(void); - -bool ascodec_chg_status(void); - -#if CONFIG_CPU == AS3525v2 -void ascodec_write_pmu(unsigned int index, unsigned int subreg, - unsigned int value); -int ascodec_read_pmu(unsigned int index, unsigned int subreg); -#endif /* CONFIG_CPU == AS3525v2 */ - -static inline void ascodec_write_charger(int value) -{ -#if CONFIG_CPU == AS3525 - ascodec_write(AS3514_CHARGER, value); -#else - ascodec_write_pmu(AS3543_CHARGER, 1, value); -#endif -} - -static inline int ascodec_read_charger(void) -{ -#if CONFIG_CPU == AS3525 - return ascodec_read(AS3514_CHARGER); -#else - return ascodec_read_pmu(AS3543_CHARGER, 1); -#endif -} - -#endif /* !SIMULATOR */ - -#endif /* !_ASCODEC_TARGET_H */ diff --git a/firmware/target/arm/as3525/backlight-e200v2-fuze.c b/firmware/target/arm/as3525/backlight-e200v2-fuze.c index 61c2b1db79..91e1ef4d0c 100644 --- a/firmware/target/arm/as3525/backlight-e200v2-fuze.c +++ b/firmware/target/arm/as3525/backlight-e200v2-fuze.c @@ -23,7 +23,7 @@ #include "system.h" #include "lcd.h" #include "backlight.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "as3514.h" int buttonlight_is_on = 0; diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c index 783f3f68a4..3e546bb5e3 100644 --- a/firmware/target/arm/as3525/debug-as3525.c +++ b/firmware/target/arm/as3525/debug-as3525.c @@ -26,7 +26,7 @@ #include "system.h" #include "cpu.h" #include "pl180.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "adc.h" #include "storage.h" diff --git a/firmware/target/arm/as3525/power-as3525.c b/firmware/target/arm/as3525/power-as3525.c index 21ce98bd75..e6f1cfd24d 100644 --- a/firmware/target/arm/as3525/power-as3525.c +++ b/firmware/target/arm/as3525/power-as3525.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include #include "config.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "as3514.h" #include "power.h" diff --git a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c index 0f4dd4dbbb..1da57de93a 100644 --- a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c +++ b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c @@ -23,7 +23,7 @@ #include "system.h" #include "lcd.h" #include "backlight.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "as3514.h" int buttonlight_is_on = 0; diff --git a/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c b/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c index ef727608b5..e3b518b3f8 100644 --- a/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c +++ b/firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c @@ -22,7 +22,7 @@ #include "backlight-target.h" #include "lcd.h" #include "as3525v2.h" -#include "ascodec-target.h" +#include "ascodec.h" void _backlight_on(void) { diff --git a/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c b/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c index bf28bd6108..f4927ba5bf 100644 --- a/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c +++ b/firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c @@ -22,7 +22,7 @@ #include "backlight-target.h" #include "lcd.h" #include "as3525v2.h" -#include "ascodec-target.h" +#include "ascodec.h" void _backlight_on(void) { diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c index 589f80436e..fd44d76cac 100644 --- a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c +++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c @@ -24,7 +24,7 @@ #include "backlight-target.h" #include "lcd.h" #include "as3525v2.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "lcd-target.h" bool _backlight_init() diff --git a/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c index 68c626d829..a01b168b71 100644 --- a/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c +++ b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c @@ -23,7 +23,7 @@ #include "system.h" #include "lcd.h" #include "backlight.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "as3514.h" void _backlight_set_brightness(int brightness) diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 89a07939b6..01aaeaccbe 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -24,7 +24,7 @@ #include "kernel.h" #include "system.h" #include "panic.h" -#include "ascodec-target.h" +#include "ascodec.h" #include "adc.h" #include "dma-target.h" #include "clock-target.h" @@ -33,6 +33,20 @@ #include "backlight-target.h" #include "lcd.h" +/* Charge Pump and Power management Settings */ +#define AS314_CP_DCDC3_SETTING \ + ((0<<7) | /* CP_SW Auto-Switch Margin 0=200/300 1=150/255 */ \ + (0<<6) | /* CP_on 0=Normal op 1=Chg Pump Always On */ \ + (0<<5) | /* LREG_CPnot Always write 0 */ \ + (0<<3) | /* DCDC3p BVDD setting 3.6/3.2/3.1/3.0 */ \ + (1<<2) | /* LREG_off 1=Auto mode switching 0=Length Reg only*/\ + (0<<0) ) /* CVDDp Core Voltage Setting 1.2/1.15/1.10/1.05*/ + +#define CVDD_1_20 0 +#define CVDD_1_15 1 +#define CVDD_1_10 2 +#define CVDD_1_05 3 + #define default_interrupt(name) \ extern __attribute__((weak,alias("UIRQ"))) void name (void) diff --git a/firmware/target/arm/pp/ascodec-pp.c b/firmware/target/arm/pp/ascodec-pp.c index 49a69d1a11..eb8093c841 100644 --- a/firmware/target/arm/pp/ascodec-pp.c +++ b/firmware/target/arm/pp/ascodec-pp.c @@ -26,7 +26,8 @@ #include "audiohw.h" #include "i2s.h" -#include "ascodec-target.h" +#include "i2c-pp.h" +#include "ascodec.h" /* * Initialise the PP I2C and I2S. @@ -65,18 +66,64 @@ void audiohw_init(void) audiohw_preinit(); } -void ascodec_suppressor_on(bool on) +int ascodec_write(unsigned int reg, unsigned int value) { - /* CHECK: Good for c200 too? */ -#ifdef SANSA_E200 - if (on) { - /* Set pop prevention */ - GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x08); - } else { - /* Release pop prevention */ - GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x08); - } -#else - (void)on; -#endif -} + return pp_i2c_send(AS3514_I2C_ADDR, reg, value); +} + +int ascodec_read(unsigned int reg) +{ + return i2c_readbyte(AS3514_I2C_ADDR, reg); +} + +int ascodec_readbytes(unsigned int addr, unsigned int len, unsigned char *data) +{ + return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data); +} + +void ascodec_lock(void) +{ + i2c_lock(); +} + +void ascodec_unlock(void) +{ + i2c_unlock(); +} + +bool ascodec_chg_status(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; +} + +bool ascodec_endofch(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; +} + +void ascodec_monitor_endofch(void) +{ + ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); +} + +void ascodec_write_charger(int value) +{ + ascodec_write(AS3514_CHARGER, value); +} + +int ascodec_read_charger(void) +{ + return ascodec_read(AS3514_CHARGER); +} + +void ascodec_wait_adc_finished(void) +{ + /* + * FIXME: not implemented + * + * If irqs are not available on the target platform, + * this should be most likely implemented by polling + * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c + * is polling IRQ_ENDOFCH. + */ +} diff --git a/firmware/target/arm/pp/ascodec-target.h b/firmware/target/arm/pp/ascodec-target.h deleted file mode 100644 index e7fd1b3b35..0000000000 --- a/firmware/target/arm/pp/ascodec-target.h +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Driver for AS3514 audio codec - * - * Copyright (c) 2007 Daniel Ankers - * Copyright (c) 2007 Christian Gmeiner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef _ASCODEC_TARGET_H -#define _ASCODEC_TARGET_H - -#include "config.h" - -#include "as3514.h" -#include "i2c-pp.h" - -static inline int ascodec_write(unsigned int reg, unsigned int value) -{ - return pp_i2c_send(AS3514_I2C_ADDR, reg, value); -} - -static inline int ascodec_read(unsigned int reg) -{ - return i2c_readbyte(AS3514_I2C_ADDR, reg); -} - -static inline int ascodec_readbytes(int addr, int len, unsigned char *data) -{ - return i2c_readbytes(AS3514_I2C_ADDR, addr, len, data); -} - -static inline void ascodec_lock(void) -{ - i2c_lock(); -} - -static inline void ascodec_unlock(void) -{ - i2c_unlock(); -} - -static inline bool ascodec_chg_status(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; -} - -static inline bool ascodec_endofch(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; -} - -static inline void ascodec_monitor_endofch(void) -{ - ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); -} - -static inline void ascodec_wait_adc_finished(void) -{ - /* - * FIXME: not implemented - * - * If irqs are not available on the target platform, - * this should be most likely implemented by polling - * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c - * is polling IRQ_ENDOFCH. - */ -} - -static inline void ascodec_write_charger(int value) -{ - ascodec_write(AS3514_CHARGER, value); -} - -static inline int ascodec_read_charger(void) -{ - return ascodec_read(AS3514_CHARGER); -} - -extern void ascodec_suppressor_on(bool on); - -#endif /* !_ASCODEC_TARGET_H */ diff --git a/firmware/target/arm/pp/i2c-pp.c b/firmware/target/arm/pp/i2c-pp.c index 58740b5c66..192af0e304 100644 --- a/firmware/target/arm/pp/i2c-pp.c +++ b/firmware/target/arm/pp/i2c-pp.c @@ -33,8 +33,9 @@ #include "system.h" #include "i2c.h" #include "i2c-pp.h" +#ifdef HAVE_AS3514 #include "ascodec.h" -#include "as3514.h" +#endif #define I2C_CTRL (*(volatile unsigned char*)(I2C_BASE+0x00)) #define I2C_ADDR (*(volatile unsigned char*)(I2C_BASE+0x04)) diff --git a/firmware/target/hosted/ypr0/ascodec-target.h b/firmware/target/hosted/ypr0/ascodec-target.h deleted file mode 100644 index 2274d5f073..0000000000 --- a/firmware/target/hosted/ypr0/ascodec-target.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $ - * - * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 - * - * Copyright (c) 2011 Lorenzo Miori - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef _ASCODEC_TARGET_H -#define _ASCODEC_TARGET_H - -#include "as3514.h" -#include "kernel.h" -#include "adc.h" -#include "ascodec.h" - -int ascodec_init(void); -void ascodec_close(void); -int ascodec_write(unsigned int reg, unsigned int value); -int ascodec_read(unsigned int reg); -void ascodec_write_pmu(unsigned int index, unsigned int subreg, unsigned int value); -int ascodec_read_pmu(unsigned int index, unsigned int subreg); -int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data); -unsigned short adc_read(int channel); -void ascodec_lock(void); -void ascodec_unlock(void); - -static inline bool ascodec_chg_status(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; -} - -static inline bool ascodec_endofch(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; -} - -static inline void ascodec_monitor_endofch(void) -{ - ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); -} - -static inline void ascodec_wait_adc_finished(void) -{ - /* - * FIXME: not implemented - * - * If irqs are not available on the target platform, - * this should be most likely implemented by polling - * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c - * is polling IRQ_ENDOFCH. - */ -} - -static inline void ascodec_write_charger(int value) -{ - ascodec_write_pmu(AS3543_CHARGER, 1, value); -} - -static inline int ascodec_read_charger(void) -{ - return ascodec_read_pmu(AS3543_CHARGER, 1); -} - -#endif /* !_ASCODEC_TARGET_H */ diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/ypr0/ascodec-ypr0.c index ec5568554b..954b4d95ef 100644 --- a/firmware/target/hosted/ypr0/ascodec-ypr0.c +++ b/firmware/target/hosted/ypr0/ascodec-ypr0.c @@ -5,7 +5,6 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $ * * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 * @@ -28,7 +27,7 @@ #include "sys/ioctl.h" #include "stdlib.h" -#include "ascodec-target.h" +#include "ascodec.h" int afe_dev = -1; @@ -134,24 +133,32 @@ void ascodec_unlock(void) { } -/* Read 10-bit channel data */ -unsigned short adc_read(int channel) +bool ascodec_chg_status(void) { - if ((unsigned)channel >= NUM_ADC_CHANNELS) - return 0; + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; +} - /* Select channel */ - ascodec_write(AS3514_ADC_0, (channel << 4)); - unsigned char buf[2]; +bool ascodec_endofch(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; +} + +void ascodec_monitor_endofch(void) +{ + ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); +} - /* Read data */ - if (ascodec_readbytes(AS3514_ADC_0, 2, buf) < 0) - return 0; - /* decode to 10-bit and return */ - return (((buf[0] & 0x3) << 8) | buf[1]); +void ascodec_write_charger(int value) +{ + ascodec_write_pmu(AS3543_CHARGER, 1, value); +} + +int ascodec_read_charger(void) +{ + return ascodec_read_pmu(AS3543_CHARGER, 1); } -void adc_init(void) +void ascodec_wait_adc_finished(void) { } diff --git a/firmware/target/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c index 930b56be2e..551b386f19 100644 --- a/firmware/target/hosted/ypr0/backlight-ypr0.c +++ b/firmware/target/hosted/ypr0/backlight-ypr0.c @@ -5,7 +5,6 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: backlight-gigabeat-s.c 25800 2010-05-04 10:07:53Z jethead71 $ * * Copyright (C) 2011 by Lorenzo Miori * @@ -24,7 +23,7 @@ #include "backlight-target.h" #include "lcd.h" #include "as3514.h" -#include "ascodec-target.h" +#include "ascodec.h" #include #include "unistd.h" diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.c b/firmware/target/hosted/ypr0/gpio_ypr0.c index 9c3f186a6b..3ee371d562 100644 --- a/firmware/target/hosted/ypr0/gpio_ypr0.c +++ b/firmware/target/hosted/ypr0/gpio_ypr0.c @@ -5,7 +5,6 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $ * * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 * @@ -51,4 +50,4 @@ int gpio_control(int request, int num, int mode, int val) { R0GPIOInfo r = { .num = num, .mode = mode, .val = val, }; return ioctl(r0_gpio_dev, request, &r); -} \ No newline at end of file +} diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.h b/firmware/target/hosted/ypr0/gpio_ypr0.h index 9fc7444887..ddf7100b2f 100644 --- a/firmware/target/hosted/ypr0/gpio_ypr0.h +++ b/firmware/target/hosted/ypr0/gpio_ypr0.h @@ -5,7 +5,6 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $ * * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 * @@ -39,4 +38,4 @@ void gpio_close(void); int gpio_control_struct(int request, R0GPIOInfo pin); int gpio_control(int request, int num, int mode, int val); -#endif \ No newline at end of file +#endif diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c index 9c90f7ea02..6aba9c7ef5 100644 --- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c +++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c @@ -22,7 +22,6 @@ #include "powermgmt.h" #include "power.h" #include "file.h" -#include "ascodec-target.h" #include "as3514.h" #include "sc900776.h" diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c index 784b4fe48e..11275c7809 100644 --- a/firmware/target/hosted/ypr0/system-ypr0.c +++ b/firmware/target/hosted/ypr0/system-ypr0.c @@ -30,7 +30,7 @@ #include #endif -#include "ascodec-target.h" +#include "ascodec.h" #include "gpio_ypr0.h" void power_off(void) -- cgit v1.2.3