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>
This commit is contained in:
parent
f49e750531
commit
a924df8d6d
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue