summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorSzymon Dziok <b0hoon@o2.pl>2014-06-17 23:13:15 +0000
committerSzymon Dziok <b0hoon@o2.pl>2014-06-18 18:06:17 +0000
commiteacd76cb80db12adcce74980e69d116911a8cde7 (patch)
tree239344e3f9053a75eeab4253f39f6b1dae749aa6 /firmware/drivers
parent0c3dca1f33596cb10345601de32d681ed6ece972 (diff)
downloadrockbox-eacd76cb80db12adcce74980e69d116911a8cde7.zip
rockbox-eacd76cb80db12adcce74980e69d116911a8cde7.tar.gz
rockbox-eacd76cb80db12adcce74980e69d116911a8cde7.tar.bz2
rockbox-eacd76cb80db12adcce74980e69d116911a8cde7.tar.xz
Radio and radio recording for Samsung YH-920.
There is no simple method to detect radio through the 3-wire interface, so it's not implemented for the YH-925 for now. YH-920 always has a radio. Change-Id: Iea484d752915fcd40dbbbd7dbbf13e81aaf548db
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/audio/ak4537.c114
-rw-r--r--firmware/drivers/tuner/tea5767.c31
2 files changed, 105 insertions, 40 deletions
diff --git a/firmware/drivers/audio/ak4537.c b/firmware/drivers/audio/ak4537.c
index bea3dc7..a42b134 100644
--- a/firmware/drivers/audio/ak4537.c
+++ b/firmware/drivers/audio/ak4537.c
@@ -221,34 +221,64 @@ void audiohw_set_frequency(int fsel)
}
#if defined(HAVE_RECORDING)
-void audiohw_enable_recording(bool source_mic)
+void audiohw_set_recsrc(int source)
{
- if (source_mic)
+ switch(source)
{
- /* enable mic power supply */
+ case AUDIO_SRC_PLAYBACK:
+ /* disable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
- /* additionally select external mic */
- akc_set(AK4537_MIC, MPWRE | MSEL);
+ akc_clear(AK4537_MIC, MPWRE);
#else
- akc_set(AK4537_MIC, MPWRI);
+ akc_clear(AK4537_MIC, MPWRI);
#endif
+ /* power down ADC, mic preamp and line amp */
+ akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL);
+ akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR);
- /* mic out is connected to line1 input */
- akc_clear(AK4537_PM3, INL | INR);
+ /* break ADC -> DAC connection */
+ akc_clear(AK4537_MODE2, LOOP);
+
+ break;
+
+#if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
+ case AUDIO_SRC_FMRADIO:
+ /* disable mic power supply */
+#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
+ akc_clear(AK4537_MIC, MPWRE);
+#else
+ akc_clear(AK4537_MIC, MPWRI);
+#endif
+ /* disable mic preamp */
+ akc_clear(AK4537_PM1, PMMICL);
+ /* Select line2 input: Radio */
+ akc_set(AK4537_PM3, INL | INR);
/* route ALC output to ADC input */
akc_set(AK4537_MIC, MICAD);
/* set ALC (automatic level control) to manual mode */
akc_clear(AK4537_ALC1, ALC1);
- /* set gain control to 'dependent' (left&right at the same time) */
- akc_clear(AK4537_MIC, IPGAC);
- /* power up mic preamp, left channel ADC and line in */
- akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL);
- /* power up right channel ADC and line in */
+
+ /* set gain control to independent left & right gain */
+ akc_set(AK4537_MIC, IPGAC);
+
+ /* power up left channel input and ADC */
+ akc_set(AK4537_PM1, PMADL | PMIPGL);
+ /* power up right channel input and ADC */
akc_set(AK4537_PM3, PMADR | PMIPGR);
- }
- else
- {
+
+ /* set line in vol = 0 dB */
+ akc_write(AK4537_IPGAL, 0x2f);
+ akc_write(AK4537_IPGAR, 0x2f);
+
+ /* ADC -> DAC, external data to DAC ignored */
+ akc_set(AK4537_MODE2, LOOP);
+
+ break;
+#endif /* INPUT_SRC_CAPS & SRC_CAP_FMRADIO */
+
+#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
+ case AUDIO_SRC_LINEIN:
/* disable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
akc_clear(AK4537_MIC, MPWRE);
@@ -272,25 +302,44 @@ void audiohw_enable_recording(bool source_mic)
akc_set(AK4537_PM1, PMADL | PMIPGL);
/* power up right channel input and ADC */
akc_set(AK4537_PM3, PMADR | PMIPGR);
- }
- /* ADC -> DAC, external data to DAC ignored */
- akc_set(AK4537_MODE2, LOOP);
-}
-void audiohw_disable_recording(void)
-{
- /* disable mic power supply */
+ /* ADC -> DAC, external data to DAC ignored */
+ akc_set(AK4537_MODE2, LOOP);
+
+ break;
+#endif /* INPUT_SRC_CAPS & SRC_CAP_LINEIN */
+
+#if (INPUT_SRC_CAPS & SRC_CAP_MIC)
+ case AUDIO_SRC_MIC:
+ /* enable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
- akc_clear(AK4537_MIC, MPWRE);
+ /* additionally select external mic */
+ akc_set(AK4537_MIC, MPWRE | MSEL);
#else
- akc_clear(AK4537_MIC, MPWRI);
+ akc_set(AK4537_MIC, MPWRI);
#endif
- /* power down ADC, mic preamp and line amp */
- akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL);
- akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR);
- /* break ADC -> DAC connection */
- akc_clear(AK4537_MODE2, LOOP);
+ /* mic out is connected to line1 input */
+ akc_clear(AK4537_PM3, INL | INR);
+
+ /* route ALC output to ADC input */
+ akc_set(AK4537_MIC, MICAD);
+ /* set ALC (automatic level control) to manual mode */
+ akc_clear(AK4537_ALC1, ALC1);
+ /* set gain control to 'dependent' (left&right at the same time) */
+ akc_clear(AK4537_MIC, IPGAC);
+ /* power up mic preamp, left channel ADC and line in */
+ akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL);
+ /* power up right channel ADC and line in */
+ akc_set(AK4537_PM3, PMADR | PMIPGR);
+
+ /* ADC -> DAC, external data to DAC ignored */
+ akc_set(AK4537_MODE2, LOOP);
+
+ break;
+#endif /* INPUT_SRC_CAPS & SRC_CAP_MIC) */
+
+ } /* switch(source) */
}
void audiohw_set_recvol(int left, int right, int type)
@@ -331,9 +380,4 @@ void audiohw_set_recvol(int left, int right, int type)
return;
}
}
-
-void audiohw_set_monitor(bool enable)
-{
- (void)enable;
-}
#endif /* HAVE_RECORDING */
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c
index d0041f9..74adb54 100644
--- a/firmware/drivers/tuner/tea5767.c
+++ b/firmware/drivers/tuner/tea5767.c
@@ -27,7 +27,9 @@
#include "power.h"
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio.h"
-#include "fmradio_i2c.h" /* physical interface driver */
+#include "fmradio_i2c.h" /* physical interface driver - i2c */
+#include "fmradio_3wire.h" /* physical interface driver - 3-wire bus */
+
#if defined(PHILIPS_HDD1630) || defined(ONDA_VX747) || defined(ONDA_VX777) || defined(PHILIPS_HDD6330)
#define I2C_ADR 0x60
@@ -109,7 +111,11 @@ int tea5767_set(int setting, int value)
if(setting == RADIO_SLEEP && !value)
tuner_power(true); /* wakeup */
+#if defined(CONFIG_TUNER_3WIRE)
+ fmradio_3wire_write(write_bytes);
+#else
fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
+#endif
if(setting == RADIO_SLEEP && value)
tuner_power(false); /* sleep */
return 1;
@@ -121,7 +127,11 @@ int tea5767_get(int setting)
unsigned char read_bytes[5];
int val = -1; /* default for unsupported query */
+#if defined(CONFIG_TUNER_3WIRE)
+ fmradio_3wire_read(read_bytes);
+#else
fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes));
+#endif
switch(setting)
{
@@ -141,7 +151,7 @@ int tea5767_get(int setting)
case RADIO_STEREO:
val = read_bytes[2] >> 7;
break;
-
+
case RADIO_RSSI:
val = 10 + 3*(read_bytes[3] >> 4);
break;
@@ -161,15 +171,22 @@ int tea5767_get(int setting)
void tea5767_init(void)
{
/* save binsize by only detecting presence for targets where it may be absent */
-#if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)
+#if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || defined(SAMSUNG_YH920)
unsigned char buf[5];
unsigned char chipid;
/* init chipid register with 0xFF in case fmradio_i2c_read fails silently */
buf[3] = 0xFF;
tuner_power(true);
- if (fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)) < 0) {
- /* no i2c device detected */
+
+#if defined(CONFIG_TUNER_3WIRE)
+ int res = fmradio_3wire_read(buf);
+#else
+ int res = fmradio_i2c_read(I2C_ADR, buf, sizeof(buf));
+#endif
+
+ if (res < 0) {
+ /* no device detected on bus */
tuner_present = false;
} else {
/* check chip id */
@@ -182,6 +199,10 @@ void tea5767_init(void)
void tea5767_dbg_info(struct tea5767_dbg_info *info)
{
+#if defined(CONFIG_TUNER_3WIRE)
+ fmradio_3wire_read(info->read_regs);
+#else
fmradio_i2c_read(I2C_ADR, info->read_regs, 5);
+#endif
memcpy(info->write_regs, write_bytes, 5);
}