From eacd76cb80db12adcce74980e69d116911a8cde7 Mon Sep 17 00:00:00 2001 From: Szymon Dziok Date: Tue, 17 Jun 2014 23:13:15 +0000 Subject: 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 --- firmware/target/arm/samsung/fmradio-yh92x.c | 120 ++++++++++++++++++++++++ firmware/target/arm/samsung/power-yh82x_yh92x.c | 19 +++- 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 firmware/target/arm/samsung/fmradio-yh92x.c (limited to 'firmware/target/arm/samsung') diff --git a/firmware/target/arm/samsung/fmradio-yh92x.c b/firmware/target/arm/samsung/fmradio-yh92x.c new file mode 100644 index 0000000000..4637aca287 --- /dev/null +++ b/firmware/target/arm/samsung/fmradio-yh92x.c @@ -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; +} diff --git a/firmware/target/arm/samsung/power-yh82x_yh92x.c b/firmware/target/arm/samsung/power-yh82x_yh92x.c index 021ddade4d..b6c18c5fd0 100644 --- a/firmware/target/arm/samsung/power-yh82x_yh92x.c +++ b/firmware/target/arm/samsung/power-yh82x_yh92x.c @@ -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) -- cgit v1.2.3