[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    dave: r18940 - in trunk: apps firmware firmware/drivers/audio
From:       mailer () svn ! rockbox ! org
Date:       2008-10-31 0:16:43
Message-ID: 200810310016.m9V0Ghti031558 () giant ! haxx ! se
[Download RAW message or body]

Date: 2008-10-31 01:16:42 +0100 (Fri, 31 Oct 2008)
New Revision: 18940

Log Message:
Abstract the PortalPlayer AS3514 handling with an "ascodec" API - inspired by the \
wmcodec API used with the Wolfson codecs.  The intention is to implement this API for \
the AS3525 and then share code with the Sansa V2 ports.

Added:
   trunk/firmware/export/ascodec.h
   trunk/firmware/target/arm/ascodec-pp.c
   trunk/firmware/target/arm/ascodec-target.h
Modified:
   trunk/apps/debug_menu.c
   trunk/firmware/SOURCES
   trunk/firmware/drivers/audio/as3514.c
   trunk/firmware/drivers/rtc/rtc_as3514.c
   trunk/firmware/export/as3514.h
   trunk/firmware/target/arm/adc-as3514.c
   trunk/firmware/target/arm/i2c-pp.c
   trunk/firmware/target/arm/philips/sa9200/backlight-sa9200.c
   trunk/firmware/target/arm/philips/sa9200/power-sa9200.c
   trunk/firmware/target/arm/sandisk/backlight-c200_e200.c
   trunk/firmware/target/arm/sandisk/power-c200_e200.c
   trunk/firmware/usbstack/usb_core.c

Modified: trunk/apps/debug_menu.c
===================================================================
--- trunk/apps/debug_menu.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/apps/debug_menu.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -103,7 +103,7 @@
 #endif
 
 #if defined(SANSA_E200) || defined(PHILIPS_SA9200)
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 #endif
 
@@ -1228,7 +1228,9 @@
         lcd_puts(0, line++, buf);
         snprintf(buf, sizeof(buf), "ADC_VBAT:     %4d", adc_read(ADC_VBAT));
         lcd_puts(0, line++, buf);
-        snprintf(buf, sizeof(buf), "CHARGER: %02X/%02X", \
i2c_readbyte(AS3514_I2C_ADDR, AS3514_CHARGER), i2c_readbyte(AS3514_I2C_ADDR, \
AS3514_IRQ_ENRD0)); +        snprintf(buf, sizeof(buf), "CHARGER: %02X/%02X", 
+                                   ascodec_read(AS3514_CHARGER), 
+                                   ascodec_read(AS3514_IRQ_ENRD0));
         lcd_puts(0, line++, buf);
 #endif
 #endif

Modified: trunk/firmware/SOURCES
===================================================================
--- trunk/firmware/SOURCES	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/SOURCES	2008-10-31 00:16:42 UTC (rev 18940)
@@ -460,6 +460,7 @@
 target/arm/ata-sd-pp.c
 target/arm/sandisk/sansa-e200/lcd-e200.c
 target/arm/adc-as3514.c
+target/arm/ascodec-pp.c
 target/arm/sandisk/backlight-c200_e200.c
 target/arm/usb-fw-pp502x.c
 target/arm/sandisk/sansa-e200/button-e200.c
@@ -478,6 +479,7 @@
 target/arm/sandisk/sansa-c200/lcd-c200.c
 target/arm/sandisk/sansa-c200/lcd-as-c200.S
 target/arm/adc-as3514.c
+target/arm/ascodec-pp.c
 target/arm/sandisk/backlight-c200_e200.c
 target/arm/usb-fw-pp502x.c
 target/arm/sandisk/sansa-c200/button-c200.c
@@ -495,6 +497,7 @@
 target/arm/ata-sd-pp.c
 target/arm/philips/sa9200/lcd-sa9200.c
 target/arm/adc-as3514.c
+target/arm/ascodec-pp.c
 target/arm/philips/sa9200/backlight-sa9200.c
 target/arm/usb-fw-pp502x.c
 target/arm/philips/sa9200/button-sa9200.c

Modified: trunk/firmware/drivers/audio/as3514.c
===================================================================
--- trunk/firmware/drivers/audio/as3514.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/drivers/audio/as3514.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -29,7 +29,7 @@
 
 #include "audiohw.h"
 #include "i2s.h"
-#include "i2c-pp.h"
+#include "ascodec.h"
 
 const struct sound_settings_info audiohw_settings[] = {
     [SOUND_VOLUME]        = {"dB",   0,   1, -74,   6, -25},
@@ -71,7 +71,7 @@
  */
 static void as3514_write(unsigned int reg, unsigned int value)
 {
-    if (pp_i2c_send(AS3514_I2C_ADDR, reg, value) != 2)
+    if (ascodec_write(reg, value) != 2)
     {
         DEBUGF("as3514 error reg=0x%02x", reg);
     }
@@ -135,36 +135,10 @@
 /*
  * Initialise the PP I2C and I2S.
  */
-void audiohw_init(void)
+void audiohw_preinit(void)
 {
     unsigned int i;
 
-    /* normal outputs for CDI and I2S pin groups */
-    DEV_INIT2 &= ~0x300;
-
-    /*mini2?*/
-    DEV_INIT1 &=~0x3000000;
-    /*mini2?*/
-
-    /* device reset */
-    DEV_RS |= DEV_I2S;
-    DEV_RS &=~DEV_I2S;
-
-    /* I2S device reset */
-    DEV_RS |= DEV_I2S;
-    DEV_RS &=~DEV_I2S;
-
-    /* I2S device enable */
-    DEV_EN |= DEV_I2S;
-
-    /* enable external dev clock clocks */
-    DEV_EN |= DEV_EXTCLOCKS;
-
-    /* external dev clock to 24MHz */
-    outl(inl(0x70000018) & ~0xc, 0x70000018);
-
-    i2s_reset();
-
     /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */
 
     /* Turn on SUM, DAC */
@@ -199,14 +173,10 @@
     /* read all reg values */
     for (i = 0; i < ARRAYLEN(as3514.regs); i++)
     {
-        as3514.regs[i] = i2c_readbyte(AS3514_I2C_ADDR, i);
+        as3514.regs[i] = ascodec_read(i);
     }
 }
 
-void audiohw_postinit(void)
-{
-}
-
 /* Silently enable / disable audio output */
 void audiohw_enable_output(bool enable)
 {

Modified: trunk/firmware/drivers/rtc/rtc_as3514.c
===================================================================
--- trunk/firmware/drivers/rtc/rtc_as3514.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/drivers/rtc/rtc_as3514.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -22,6 +22,7 @@
 #include "rtc.h"
 #include "i2c-pp.h"
 #include "as3514.h"
+#include "ascodec.h"
 
 #define MINUTE_SECONDS      60
 #define HOUR_SECONDS        3600
@@ -57,7 +58,7 @@
     
     /* RTC_AS3514's slave address is 0x46*/
     for (i=0;i<4;i++){
-        tmp[i] = i2c_readbyte(AS3514_I2C_ADDR, AS3514_RTC_0 + i);
+        tmp[i] = ascodec_read(AS3514_RTC_0 + i);
     }
     seconds = tmp[0] + (tmp[1]<<8) + (tmp[2]<<16) + (tmp[3]<<24);
     
@@ -162,7 +163,7 @@
 
     /* Send data to RTC */
     for (i=0;i<4;i++){
-        pp_i2c_send(AS3514_I2C_ADDR, AS3514_RTC_0 + i, ((seconds >> (8 * i)) & \
0xff)); +        ascodec_write(AS3514_RTC_0 + i, ((seconds >> (8 * i)) & 0xff));
     }
     return 1;
 }

Modified: trunk/firmware/export/as3514.h
===================================================================
--- trunk/firmware/export/as3514.h	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/export/as3514.h	2008-10-31 00:16:42 UTC (rev 18940)
@@ -79,8 +79,4 @@
 #define VOLUME_MIN -735
 #define VOLUME_MAX   60
 
-#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
-#define AS3514_I2C_ADDR 0x46
-#endif
-
 #endif /* _AS3514_H */

Added: trunk/firmware/export/ascodec.h
===================================================================
--- trunk/firmware/export/ascodec.h	                        (rev 0)
+++ trunk/firmware/export/ascodec.h	2008-10-31 00:16:42 UTC (rev 18940)
@@ -0,0 +1,27 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Dave Chapman
+ *
+ * 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_H
+#define _ASCODEC_H
+
+#include "ascodec-target.h"
+
+#endif


Property changes on: trunk/firmware/export/ascodec.h
___________________________________________________________________
Added: svn:keywords
   + Author Id Date Revision

Modified: trunk/firmware/target/arm/adc-as3514.c
===================================================================
--- trunk/firmware/target/arm/adc-as3514.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/target/arm/adc-as3514.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -20,7 +20,7 @@
  ****************************************************************************/
 #include "adc.h"
 #include "kernel.h"
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 
 /* Read 10-bit channel data */
@@ -30,21 +30,21 @@
 
     if ((unsigned)channel < NUM_ADC_CHANNELS)
     {
-        i2c_lock();
+        ascodec_lock();
 
         /* Select channel */
-        if (pp_i2c_send( AS3514_I2C_ADDR, AS3514_ADC_0, (channel << 4)) >= 0)
+        if (ascodec_write(AS3514_ADC_0, (channel << 4)) >= 0)
         {
             unsigned char buf[2];
 
             /* Read data */
-            if (i2c_readbytes( AS3514_I2C_ADDR, AS3514_ADC_0, 2, buf) >= 0)
+            if (ascodec_readbytes(AS3514_ADC_0, 2, buf) >= 0)
             {
                 data = (((buf[0] & 0x3) << 8) | buf[1]);
             }
         }
 
-        i2c_unlock();
+        ascodec_unlock();
     }
     
     return data;

Added: trunk/firmware/target/arm/ascodec-pp.c
===================================================================
--- trunk/firmware/target/arm/ascodec-pp.c	                        (rev 0)
+++ trunk/firmware/target/arm/ascodec-pp.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -0,0 +1,66 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   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.
+ *
+ ****************************************************************************/
+#include "cpu.h"
+#include "system.h"
+
+#include "audiohw.h"
+#include "i2s.h"
+
+/*
+ * Initialise the PP I2C and I2S.
+ */
+void audiohw_init(void)
+{
+    /* normal outputs for CDI and I2S pin groups */
+    DEV_INIT2 &= ~0x300;
+
+    /*mini2?*/
+    DEV_INIT1 &=~0x3000000;
+    /*mini2?*/
+
+    /* device reset */
+    DEV_RS |= DEV_I2S;
+    DEV_RS &=~DEV_I2S;
+
+    /* I2S device reset */
+    DEV_RS |= DEV_I2S;
+    DEV_RS &=~DEV_I2S;
+
+    /* I2S device enable */
+    DEV_EN |= DEV_I2S;
+
+    /* enable external dev clock clocks */
+    DEV_EN |= DEV_EXTCLOCKS;
+
+    /* external dev clock to 24MHz */
+    outl(inl(0x70000018) & ~0xc, 0x70000018);
+
+    i2s_reset();
+
+    audiohw_preinit();
+}
+
+void audiohw_postinit(void)
+{
+}


Property changes on: trunk/firmware/target/arm/ascodec-pp.c
___________________________________________________________________
Added: svn:keywords
   + Author Id Date Revision

Added: trunk/firmware/target/arm/ascodec-target.h
===================================================================
--- trunk/firmware/target/arm/ascodec-target.h	                        (rev 0)
+++ trunk/firmware/target/arm/ascodec-target.h	2008-10-31 00:16:42 UTC (rev 18940)
@@ -0,0 +1,69 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   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"
+
+#ifdef CPU_PP
+/* TODO: This header is actually portalplayer specific, and should be
+ * moved into an appropriate subdir  */
+
+#include "i2c-pp.h"
+
+#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
+#define AS3514_I2C_ADDR 0x46
+#else
+#error Unknown target!
+#endif
+
+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();
+}
+
+#endif /* CPU_PP */
+
+#endif /* !_ASCODEC_TARGET_H */


Property changes on: trunk/firmware/target/arm/ascodec-target.h
___________________________________________________________________
Added: svn:keywords
   + Author Id Date Revision

Modified: trunk/firmware/target/arm/i2c-pp.c
===================================================================
--- trunk/firmware/target/arm/i2c-pp.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/target/arm/i2c-pp.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -32,6 +32,7 @@
 #include "logf.h"
 #include "system.h"
 #include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 
 /* Local functions definitions */
@@ -230,7 +231,7 @@
     outl(0, 0x600060a4);
     outl(0x1e, 0x600060a4);
 
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_SUPERVISOR, 5);
+    ascodec_write(AS3514_SUPERVISOR, 5);
 #endif
 #endif
 

Modified: trunk/firmware/target/arm/philips/sa9200/backlight-sa9200.c
===================================================================
--- trunk/firmware/target/arm/philips/sa9200/backlight-sa9200.c	2008-10-30 21:00:17 \
                UTC (rev 18939)
+++ trunk/firmware/target/arm/philips/sa9200/backlight-sa9200.c	2008-10-31 00:16:42 \
UTC (rev 18940) @@ -23,7 +23,7 @@
 #include "system.h"
 #include "lcd.h"
 #include "backlight.h"
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 
 static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
@@ -46,12 +46,12 @@
 #ifdef HAVE_LCD_ENABLE
     lcd_enable(true); /* power on lcd + visible display */
 #endif
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness);
+    ascodec_write(AS3514_DCDC15, backlight_brightness);
 }
 
 void _backlight_off(void)
 {
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0);
+    ascodec_write(AS3514_DCDC15, 0x0);
 #ifdef HAVE_LCD_ENABLE
     lcd_enable(false); /* power off visible display */
 #endif

Modified: trunk/firmware/target/arm/philips/sa9200/power-sa9200.c
===================================================================
--- trunk/firmware/target/arm/philips/sa9200/power-sa9200.c	2008-10-30 21:00:17 UTC \
                (rev 18939)
+++ trunk/firmware/target/arm/philips/sa9200/power-sa9200.c	2008-10-31 00:16:42 UTC \
(rev 18940) @@ -36,9 +36,9 @@
     char byte;
 
     /* Send shutdown command to PMU */
-    byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM);
+    byte = ascodec_read(AS3514_SYSTEM);
     byte &= ~0x1;   
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte);
+    ascodec_write(AS3514_SYSTEM, byte);
 
     /* Stop interrupts on both cores */
     disable_interrupt(IRQ_FIQ_STATUS);

Modified: trunk/firmware/target/arm/sandisk/backlight-c200_e200.c
===================================================================
--- trunk/firmware/target/arm/sandisk/backlight-c200_e200.c	2008-10-30 21:00:17 UTC \
                (rev 18939)
+++ trunk/firmware/target/arm/sandisk/backlight-c200_e200.c	2008-10-31 00:16:42 UTC \
(rev 18940) @@ -23,7 +23,7 @@
 #include "system.h"
 #include "lcd.h"
 #include "backlight.h"
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 
 static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
@@ -46,12 +46,12 @@
 #ifdef HAVE_LCD_ENABLE
     lcd_enable(true); /* power on lcd + visible display */
 #endif
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness);
+    ascodec_write(AS3514_DCDC15, backlight_brightness);
 }
 
 void _backlight_off(void)
 {
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0);
+    ascodec_write(AS3514_DCDC15, 0x0);
 #ifdef HAVE_LCD_ENABLE
     lcd_enable(false); /* power off visible display */
 #endif

Modified: trunk/firmware/target/arm/sandisk/power-c200_e200.c
===================================================================
--- trunk/firmware/target/arm/sandisk/power-c200_e200.c	2008-10-30 21:00:17 UTC (rev \
                18939)
+++ trunk/firmware/target/arm/sandisk/power-c200_e200.c	2008-10-31 00:16:42 UTC (rev \
18940) @@ -22,7 +22,7 @@
 #include <stdbool.h>
 #include "system.h"
 #include "cpu.h"
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "tuner.h"
 #include "as3514.h"
 #include "power.h"
@@ -36,9 +36,9 @@
     char byte;
 
     /* Send shutdown command to PMU */
-    byte = i2c_readbyte(AS3514_I2C_ADDR, AS3514_SYSTEM);
+    byte = ascodec_read(AS3514_SYSTEM);
     byte &= ~0x1;   
-    pp_i2c_send(AS3514_I2C_ADDR, AS3514_SYSTEM, byte);
+    ascodec_write(AS3514_SYSTEM, byte);
 
     /* Stop interrupts on both cores */
     disable_interrupt(IRQ_FIQ_STATUS);

Modified: trunk/firmware/usbstack/usb_core.c
===================================================================
--- trunk/firmware/usbstack/usb_core.c	2008-10-30 21:00:17 UTC (rev 18939)
+++ trunk/firmware/usbstack/usb_core.c	2008-10-31 00:16:42 UTC (rev 18940)
@@ -46,7 +46,7 @@
 /* TODO: Move target-specific stuff somewhere else (serial number reading) */
 
 #ifdef HAVE_AS3514
-#include "i2c-pp.h"
+#include "ascodec.h"
 #include "as3514.h"
 #endif
 
@@ -274,7 +274,7 @@
     short* p = &usb_string_iSerial.wString[1];
     int i;
 
-    i2c_readbytes(AS3514_I2C_ADDR, AS3514_UID_0, 0x10, serial);
+    ascodec_readbytes(AS3514_UID_0, 0x10, serial);
     for (i = 0; i < 16; i++) {
         *p++ = hex[(serial[i] >> 4) & 0xF];
         *p++ = hex[(serial[i] >> 0) & 0xF];

_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
http://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic