Index: apps/recorder/radio.c =================================================================== --- apps/recorder/radio.c (revision 22090) +++ apps/recorder/radio.c (working copy) @@ -115,6 +115,15 @@ #define FM_MODE #define FM_EXIT #define FM_PLAY + +#elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD) +#define FM_MENU +#define FM_PRESET +#define FM_STOP +#define FM_MODE +#define FM_EXIT +#define FM_PLAY + #endif #define RADIO_SCAN_MODE 0 Index: apps/keymaps/keymap-yh8xx_yh9xx.c =================================================================== --- apps/keymaps/keymap-yh8xx_yh9xx.c (revision 22090) +++ apps/keymaps/keymap-yh8xx_yh9xx.c (working copy) @@ -303,6 +303,26 @@ LAST_ITEM_IN_LIST }; /* button_context_keyboard */ +static const struct button_mapping button_context_radio[] = { + { ACTION_FM_PRESET, BUTTON_LEFT | BUTTON_REL, BUTTON_RIGHT }, + { ACTION_FM_MENU, BUTTON_LEFT | BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_FM_MODE, BUTTON_RIGHT | BUTTON_REL, BUTTON_NONE }, + { ACTION_FM_STOP, BUTTON_PLAY | BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_FM_EXIT, BUTTON_RIGHT | BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_FM_PLAY, BUTTON_PLAY | BUTTON_REL, BUTTON_PLAY }, + { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_PREV, BUTTON_REW, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_FFWD, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST + +}; + const struct button_mapping* get_context_mapping(int context) { switch (context) Index: firmware/export/config-yh920.h =================================================================== --- firmware/export/config-yh920.h (revision 22090) +++ firmware/export/config-yh920.h (working copy) @@ -13,7 +13,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN ) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ @@ -134,6 +134,10 @@ #define AB_REPEAT_ENABLE 1 +/* FM Tuner */ +#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER_XTAL 32768 + #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ Index: firmware/export/config-yh925.h =================================================================== --- firmware/export/config-yh925.h (revision 22090) +++ firmware/export/config-yh925.h (working copy) @@ -13,7 +13,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN ) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ @@ -131,6 +131,10 @@ #define AB_REPEAT_ENABLE 1 +/* FM Tuner */ +#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER_XTAL 32768 + #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ Index: firmware/export/config-yh820.h =================================================================== --- firmware/export/config-yh820.h (revision 22090) +++ firmware/export/config-yh820.h (working copy) @@ -13,7 +13,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN ) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ @@ -127,6 +127,10 @@ #define AB_REPEAT_ENABLE 1 +/* FM Tuner */ +#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER_XTAL 32768 + #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (revision 22090) +++ firmware/SOURCES (working copy) @@ -1369,6 +1369,7 @@ target/arm/usb-fw-pp502x.c target/arm/samsung/akcodec-yh82x_yh92x.c target/arm/samsung/button-yh82x_yh92x.c +target/arm/samsung/fmradio-yh82x_92x.c target/arm/samsung/power-yh82x_yh92x.c target/arm/samsung/yh820/backlight-yh820.c target/arm/samsung/yh820/lcd-yh820.c @@ -1386,6 +1387,7 @@ target/arm/usb-fw-pp502x.c target/arm/samsung/akcodec-yh82x_yh92x.c target/arm/samsung/button-yh82x_yh92x.c +target/arm/samsung/fmradio-yh82x_92x.c target/arm/samsung/power-yh82x_yh92x.c target/arm/samsung/yh920/backlight-yh920.c target/arm/samsung/yh920/lcd-yh920.c @@ -1402,6 +1404,7 @@ target/arm/usb-fw-pp502x.c target/arm/samsung/akcodec-yh82x_yh92x.c target/arm/samsung/button-yh82x_yh92x.c +target/arm/samsung/fmradio-yh82x_92x.c target/arm/samsung/power-yh82x_yh92x.c target/arm/samsung/yh925/backlight-yh925.c target/arm/samsung/yh925/lcd-yh925.c Index: firmware/target/arm/samsung/power-yh82x_yh92x.c =================================================================== --- firmware/target/arm/samsung/power-yh82x_yh92x.c (revision 22090) +++ firmware/target/arm/samsung/power-yh82x_yh92x.c (working copy) @@ -75,3 +75,14 @@ while (1) DEV_RS = -1; } + +#if CONFIG_TUNER + +bool tuner_power(bool status) +{ + (void)status; + /* TODO: tuner power control */ + return true; +} + +#endif /* #if CONFIG_TUNER */ Index: firmware/target/arm/samsung/fmradio-yh82x_92x.c =================================================================== --- firmware/target/arm/samsung/fmradio-yh82x_92x.c (revision 0) +++ firmware/target/arm/samsung/fmradio-yh82x_92x.c (revision 0) @@ -0,0 +1,211 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Physical interface of the Philips TEA5767 in Samsung YH-820 YH-920 YH-925 + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * 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 "cpu.h" +#include "logf.h" +#include "system.h" +#include "fmradio_i2c.h" + +/* cute little functions, atomic read-modify-write */ + +#define SDA_OUTINIT GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x08) +#define SDA_HI_IN GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_EN, 0x08) +#define SDA_LO_OUT GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x08) +#define SDA (GPIOD_INPUT_VAL & 0x08) + +#define SCL_INPUT GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_EN, 0x10) +#define SCL_OUTPUT GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x10) +#define SCL_LO GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x10) +#define SCL_HI GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL,0x10) +#define SCL (GPIOD_INPUT_VAL & 0x10) + +#define DELAY udelay(2) + +static void fmradio_i2c_start(void) +{ + SCL_HI; + SCL_OUTPUT; + SDA_HI_IN; + SDA_OUTINIT; + DELAY; + SDA_LO_OUT; + DELAY; + SCL_LO; +} + +static void fmradio_i2c_stop(void) +{ + SDA_LO_OUT; + DELAY; + SCL_HI; + DELAY; + SDA_HI_IN; +} + +/* Generate ACK or NACK */ +static void fmradio_i2c_ack(bool nack) +{ + /* Here's the deal. The slave is slow, and sometimes needs to wait + before it can receive the acknowledge. Therefore it forces the clock + low until it is ready. We need to poll the clock line until it goes + high before we release the ack. + + In their infinite wisdom, iriver didn't pull up the SCL line, so + we have to drive the SCL high repeatedly to simulate a pullup. */ + + if (nack) + SDA_HI_IN; + else + SDA_LO_OUT; + DELAY; + + SCL_HI; + do + { + SCL_OUTPUT; /* Set the clock to output */ + SCL_INPUT; /* Set the clock to input */ + DELAY; + } + while(!SCL); /* and wait for the slave to release it */ + + SCL_OUTPUT; + SCL_LO; +} + +static int fmradio_i2c_getack(void) +{ + int ret = 1; + + /* Here's the deal. The slave is slow, and sometimes needs to wait + before it can send the acknowledge. Therefore it forces the clock + low until it is ready. We need to poll the clock line until it goes + high before we read the ack. + + In their infinite wisdom, iriver didn't pull up the SCL line, so + we have to drive the SCL high repeatedly to simulate a pullup. */ + + SDA_HI_IN; + DELAY; + + SCL_HI; /* set clock to high */ + do + { + SCL_OUTPUT; /* Set the clock to output */ + SCL_INPUT; /* Set the clock to input */ + DELAY; + } + while(!SCL); /* and wait for the slave to release it */ + + if (SDA) + ret = 0; /* ack failed */ + + SCL_OUTPUT; + SCL_LO; + + return ret; +} + +static void fmradio_i2c_outb(unsigned char byte) +{ + int i; + + /* clock out each bit, MSB first */ + for ( i=0x80; i; i>>=1 ) { + if ( i & byte ) + SDA_HI_IN; + else + SDA_LO_OUT; + DELAY; + SCL_HI; + DELAY; + SCL_LO; + + DELAY; + } +} + +static unsigned char fmradio_i2c_inb(void) +{ + int i; + unsigned char byte = 0; + + SDA_HI_IN; + /* clock in each bit, MSB first */ + for ( i=0x80; i; i>>=1 ) { + DELAY; + SCL_HI; + DELAY; + if ( SDA ) + byte |= i; + SCL_LO; + } + + return byte; +} + +int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) +{ + int i,x=0; + + fmradio_i2c_start(); + fmradio_i2c_outb(address & 0xfe); + if (fmradio_i2c_getack()) + { + for (i=0; i0; i--) + { + *buf++ = fmradio_i2c_inb(); + fmradio_i2c_ack(i == 1); + } + } + else + x=-1; + fmradio_i2c_stop(); + return x; +}