summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-03-31 21:57:53 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2013-04-11 11:18:23 +0200
commita924df8d6ddfa4372ce6b49c312e1da1ffceb2ad (patch)
treec5d977120d5dc629d9778c4ee7ab84284458503e
parentf49e75053198cc24aff92e9045795e011fa25083 (diff)
downloadrockbox-a924df8.tar.gz
rockbox-a924df8.tar.bz2
rockbox-a924df8.zip
rk27xx: implement radio support
Change-Id: I59d3905e9b2a3df8aa235e424c7a6e0eff6d73e9 Reviewed-on: http://gerrit.rockbox.org/427 Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com> Tested-by: Marcin Bukat <marcin.bukat@gmail.com>
-rw-r--r--apps/keymaps/keymap-rk27xx-generic.c19
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/drivers/audio/rk27xx_codec.c18
-rw-r--r--firmware/export/config/rk27generic.h4
-rw-r--r--firmware/target/arm/rk27xx/audio-rk27xx.c52
-rw-r--r--firmware/target/arm/rk27xx/rk27generic/fmradio-i2c-rk27generic.c39
-rw-r--r--firmware/target/arm/rk27xx/rk27generic/power-rk27generic.c6
7 files changed, 136 insertions, 4 deletions
diff --git a/apps/keymaps/keymap-rk27xx-generic.c b/apps/keymaps/keymap-rk27xx-generic.c
index a709df6156..7a4545b246 100644
--- a/apps/keymaps/keymap-rk27xx-generic.c
+++ b/apps/keymaps/keymap-rk27xx-generic.c
@@ -66,7 +66,21 @@ static const struct button_mapping button_context_wps[] = {
LAST_ITEM_IN_LIST
}; /* button_context_wps */
+#ifdef CONFIG_TUNER
+static const struct button_mapping button_context_radio[] = {
+ { ACTION_FM_MENU, BUTTON_M|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_FM_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_SETTINGS_INC, BUTTON_VOL|BUTTON_FF, BUTTON_NONE },
+ { ACTION_SETTINGS_INCREPEAT, BUTTON_VOL|BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_SETTINGS_DEC, BUTTON_VOL|BUTTON_REW, BUTTON_NONE },
+ { ACTION_SETTINGS_DECREPEAT, BUTTON_VOL|BUTTON_REW|BUTTON_REPEAT,BUTTON_NONE },
+ { ACTION_FM_EXIT, BUTTON_M|BUTTON_REL, BUTTON_M },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
+}; /* button_context_radio */
+#endif
/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
const struct button_mapping* get_context_mapping(int context)
@@ -77,7 +91,10 @@ const struct button_mapping* get_context_mapping(int context)
return button_context_standard;
case CONTEXT_WPS:
return button_context_wps;
-
+#ifdef CONFIG_TUNER
+ case CONTEXT_FM:
+ return button_context_radio;
+#endif
case CONTEXT_TREE:
case CONTEXT_LIST:
case CONTEXT_MAINMENU:
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 8ba45af533..92b2f5f87b 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1509,6 +1509,7 @@ target/arm/s5l8702/ipod6g/piezo-ipod6g.c
#endif
#if CONFIG_CPU == RK27XX
+target/arm/rk27xx/audio-rk27xx.c
target/arm/rk27xx/kernel-rk27xx.c
target/arm/rk27xx/system-rk27xx.c
target/arm/rk27xx/backlight-rk27xx.c
@@ -1532,6 +1533,7 @@ target/arm/rk27xx/rk27generic/button-rk27generic.c
target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
target/arm/rk27xx/rk27generic/power-rk27generic.c
target/arm/rk27xx/rk27generic/lcd-rk27generic.c
+target/arm/rk27xx/rk27generic/fmradio-i2c-rk27generic.c
#endif
#if CONFIG_CPU == JZ4732
diff --git a/firmware/drivers/audio/rk27xx_codec.c b/firmware/drivers/audio/rk27xx_codec.c
index cfb98a9227..462565e8aa 100644
--- a/firmware/drivers/audio/rk27xx_codec.c
+++ b/firmware/drivers/audio/rk27xx_codec.c
@@ -55,12 +55,14 @@ static int codec_read(uint8_t reg, uint8_t *val)
}
#endif
+static uint8_t cr1_sel = DACSEL;
+
static void audiohw_mute(bool mute)
{
if (mute)
- codec_write(CR1, SB_MICBIAS|DAC_MUTE|DACSEL);
+ codec_write(CR1, SB_MICBIAS|DAC_MUTE|cr1_sel);
else
- codec_write(CR1, SB_MICBIAS|DACSEL);
+ codec_write(CR1, SB_MICBIAS|cr1_sel);
}
/* public functions */
@@ -109,7 +111,7 @@ void audiohw_postinit(void)
udelay(1000);
/* power up output stage */
- codec_write(PMR1, SB_ADC|SB_IN1|SB_IN2|SB_MIC|SB_IND);
+ codec_write(PMR1, SB_ADC|SB_MIC|SB_IND);
sleep(HZ/10);
GPIO_PDDR |= (1<<7); /* PD7 high */
@@ -159,5 +161,15 @@ void audiohw_set_master_vol(int vol_l, int vol_r)
codec_write(CGR9, vol_r);
codec_write(CGR8, vol_l);
+ codec_write(CGR5, vol_r);
+ codec_write(CGR4, vol_l);
+ codec_write(CGR3, vol_r);
+ codec_write(CGR2, vol_l);
}
}
+
+void audiohw_set_monitor(bool enable)
+{
+ cr1_sel = enable ? BYPASS1|BYPASS2 : DACSEL;
+ codec_write(CR1, cr1_sel|SB_MICBIAS);
+}
diff --git a/firmware/export/config/rk27generic.h b/firmware/export/config/rk27generic.h
index 10fbd451e4..9a4326358f 100644
--- a/firmware/export/config/rk27generic.h
+++ b/firmware/export/config/rk27generic.h
@@ -13,6 +13,7 @@
/* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */
/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
+#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
/* define the bitmask of hardware sample rates */
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
@@ -106,6 +107,9 @@
/* Define the type of audio codec */
#define HAVE_RK27XX_CODEC
+#define CONFIG_TUNER TEA5767
+#define CONFIG_TUNER_XTAL 32768
+
/* #define HAVE_PCM_DMA_ADDRESS */
/* Define this for LCD backlight available */
diff --git a/firmware/target/arm/rk27xx/audio-rk27xx.c b/firmware/target/arm/rk27xx/audio-rk27xx.c
new file mode 100644
index 0000000000..76be4a907a
--- /dev/null
+++ b/firmware/target/arm/rk27xx/audio-rk27xx.c
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 by Amaury Pouly
+ *
+ * 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 "config.h"
+#include "system.h"
+#include "audiohw.h"
+#include "audio.h"
+
+static int input_source = AUDIO_SRC_PLAYBACK;
+static unsigned input_flags = 0;
+static int output_source = AUDIO_SRC_PLAYBACK;
+
+static void select_audio_path(void)
+{
+ if(input_source == AUDIO_SRC_PLAYBACK)
+ audiohw_set_monitor(false);
+ else
+ audiohw_set_monitor(true);
+}
+
+void audio_input_mux(int source, unsigned flags)
+{
+ (void) source;
+ (void) flags;
+ input_source = source;
+ input_flags = flags;
+ select_audio_path();
+}
+
+void audio_set_output_source(int source)
+{
+ (void) source;
+ output_source = source;
+ select_audio_path();
+}
diff --git a/firmware/target/arm/rk27xx/rk27generic/fmradio-i2c-rk27generic.c b/firmware/target/arm/rk27xx/rk27generic/fmradio-i2c-rk27generic.c
new file mode 100644
index 0000000000..4ab171cd5a
--- /dev/null
+++ b/firmware/target/arm/rk27xx/rk27generic/fmradio-i2c-rk27generic.c
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 by Amaury Pouly
+ *
+ * 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 "config.h"
+#include "system.h"
+#include "fmradio_i2c.h"
+#include "i2c-rk27xx.h"
+
+void fmradio_i2c_init(void)
+{
+}
+
+int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
+{
+ return i2c_write(address, -1, count, buf);
+}
+
+int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
+{
+ return i2c_read(address, -1, count, buf);
+}
diff --git a/firmware/target/arm/rk27xx/rk27generic/power-rk27generic.c b/firmware/target/arm/rk27xx/rk27generic/power-rk27generic.c
index 68594d0f0e..d3feb41597 100644
--- a/firmware/target/arm/rk27xx/rk27generic/power-rk27generic.c
+++ b/firmware/target/arm/rk27xx/rk27generic/power-rk27generic.c
@@ -38,6 +38,12 @@ void power_init(void)
GPIO_PCCON |= (1<<0);
}
+bool tuner_power(bool status)
+{
+ (void) status;
+ return true;
+}
+
unsigned int power_input_status(void)
{
return (usb_detect() == USB_INSERTED) ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;