FS#9609 FM radio support for the Gigabeat S, seeking/scanning is not yet

implemented but manual tuning works nicely. Thanks to Rafaël Carré,
Bertrik Sikken and Robert Menes for suggestions and debugging help.



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19372 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2008-12-09 20:48:04 +00:00
parent a13c162719
commit 65f61d6cce
13 changed files with 354 additions and 9 deletions

View file

@ -0,0 +1,56 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Nils Wallménius
*
* 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 "wm8978.h"
#include "audio.h"
void audio_set_output_source(int source)
{
(void)source; /* TODO */
}
void audio_input_mux(int source, unsigned int flags)
{
(void)flags;
switch (source)
{
case AUDIO_SRC_PLAYBACK:
/* deselect bypass patths and set volume to -15dB */
wmc_clear(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (7<<2));
wmc_clear(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (7<<2));
/* disable L2/R2 inputs and boost stage */
wmc_clear(WMC_POWER_MANAGEMENT2,
WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR);
break;
case AUDIO_SRC_FMRADIO:
/* enable L2/R2 inputs and boost stage */
wmc_set(WMC_POWER_MANAGEMENT2,
WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR);
/* select bypass patths and set volume to 0dB */
wmc_set(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (5<<2));
wmc_set(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (5<<2));
break;
default:
source = AUDIO_SRC_PLAYBACK;
}
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
* Physical interface of the SI4700 in the Gigabeat S
*
* Copyright (C) 2008 by Nils Wallménius
*
* 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 "i2c-imx31.h"
#include "fmradio_i2c.h"
struct i2c_node si4700_i2c_node =
{
.num = I2C2_NUM,
.ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
/* Just hard-code for now - scaling may require
* updating */
.addr = (0x20),
};
int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
{
(void)address;
i2c_write(&si4700_i2c_node, buf, count);
return 0;
}
int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
{
(void)address;
i2c_read(&si4700_i2c_node, -1, buf, count);
return 0;
}

View file

@ -26,6 +26,9 @@
#include "backlight-target.h"
#include "avic-imx31.h"
#include "mc13783.h"
#include "i2c-imx31.h"
extern struct i2c_node si4700_i2c_node;
static bool charger_detect = false;
@ -79,6 +82,33 @@ bool ide_powered(void)
return (GPIO3_DR & (1 << 5)) != 0;
}
#if CONFIG_TUNER
bool tuner_power(bool status)
{
if (status)
{
/* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */
i2c_enable_node(&si4700_i2c_node, true);
/* enable the fm chip */
imx31_regmod32(&GPIO1_DR, (1 << 26), (1 << 26));
/* enable CLK32KMCU clock */
mc13783_set(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
}
else
{
/* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */
i2c_enable_node(&si4700_i2c_node, false);
/* disable the fm chip */
imx31_regmod32(&GPIO1_DR, 0, (1 << 26));
/* disable CLK32KMCU clock */
mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
}
return true;
}
#endif /* #if CONFIG_TUNER */
void power_off(void)
{
/* Cut backlight */