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
This commit is contained in:
Szymon Dziok 2014-06-17 23:13:15 +00:00
parent 0c3dca1f33
commit eacd76cb80
11 changed files with 335 additions and 44 deletions

View file

@ -30,6 +30,25 @@ void audio_set_output_source(int source)
source = AUDIO_SRC_PLAYBACK;
} /* audio_set_output_source */
#ifdef HAVE_AK4537
void audio_input_mux(int source, unsigned flags)
{
(void)flags;
/* Prevent pops from unneeded switching */
static int last_source = AUDIO_SRC_PLAYBACK;
#ifdef HAVE_FMRADIO_REC
bool recording = flags & SRCF_RECORDING;
if ((source == AUDIO_SRC_FMRADIO) && (!recording))
audiohw_set_recvol(0, 0, AUDIO_GAIN_LINEIN); /* Set line-in vol to 0dB*/
#endif
if (source != last_source)
audiohw_set_recsrc(source);
last_source = source;
}
#else
void audio_input_mux(int source, unsigned flags)
{
(void)flags;
@ -132,4 +151,6 @@ void audio_input_mux(int source, unsigned flags)
last_source = source;
} /* audio_input_mux */
#endif
#endif /* INPUT_SRC_CAPS != 0 */

View file

@ -0,0 +1,120 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
* Physical interface of the Philips TEA5767 in Samsung YH-92x
*
* Copyright (C) 2014 by Szymon Dziok
*
* 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 "cpu.h"
#include "fmradio_3wire.h"
#define CLOCK_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x10)
#define CLOCK_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x10)
#define CLOCK_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10)
#define CLOCK_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10)
#define DATA (GPIOL_INPUT_VAL & 0x08)
#define DATA_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x08)
#define DATA_IN GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08)
#define DATA_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x08)
#define DATA_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x08)
#define DATA_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x08)
#define READWRITE_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x01)
#define READWRITE_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x01)
#define READWRITE_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x01)
#define READWRITE_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x01)
#define DELAY1 udelay(1)
#define DELAY2 udelay(2)
void fmradio_3wire_init(void)
{
READWRITE_EN;
READWRITE_OUT;
DATA_EN;
DATA_IN;
CLOCK_EN;
CLOCK_HI;
CLOCK_OUT;
DELAY2;
}
int fmradio_3wire_write(const unsigned char* buf)
{
int i, j;
CLOCK_LO;
READWRITE_LO;
DELAY2;
READWRITE_HI;
DELAY1;
DATA_OUT;
/* 5 bytes to the tuner */
for (j = 0; j < 5; j++)
{
for (i = 7; i >= 0; i--)
{
if ((buf[j] >> i) & 0x1) DATA_HI;
else DATA_LO;
DELAY1;
CLOCK_HI;
DELAY2;
CLOCK_LO;
DELAY1;
}
}
READWRITE_LO;
return j;
}
int fmradio_3wire_read(unsigned char* buf)
{
int i, j;
CLOCK_LO;
READWRITE_HI;
DELAY2;
READWRITE_LO;
DELAY2;
DATA_IN;
/* 5 bytes from the tuner */
for (j = 0; j < 5; j++)
{
buf[j] = 0;
for (i = 7; i >= 0; i--)
{
buf[j] |= ((DATA >> 3) << i);
CLOCK_HI;
DELAY2;
CLOCK_LO;
DELAY2;
}
}
READWRITE_HI;
return j;
}

View file

@ -20,7 +20,7 @@
****************************************************************************/
/* Created from power.c using some iPod code, and some custom stuff based on
GPIO analysis
GPIO analysis
*/
#include "config.h"
@ -32,9 +32,26 @@
#include "power.h"
#include "logf.h"
#include "usb.h"
#include "fmradio_3wire.h"
#if CONFIG_TUNER
bool tuner_power(bool status)
{
GPIO_SET_BITWISE(GPIOL_ENABLE, 0x04);
GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x04);
if (status)
GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x04);
else
GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x04);
return status;
}
#endif
void power_init(void)
{
#if CONFIG_TUNER
fmradio_3wire_init();
#endif
}
unsigned int power_input_status(void)