From 3cad5573b68917442564dc4f210fac056447c5cd Mon Sep 17 00:00:00 2001 From: Lorenzo Miori Date: Sat, 7 Apr 2012 10:30:23 +0200 Subject: ypr0: This patch adds radio support to Samsung YP-R0 Basically it uses the default SI4700 radio chip driver, the only thing that's different is the I2C access, written specifically to interact with my kernel module. Next things to add are: - RDS support! Change-Id: I0ed125641e00f93124d7a34f90dd508e7f1db5a4 Signed-off-by: Lorenzo Miori --- firmware/target/hosted/ypr0/radio-ypr0.c | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 firmware/target/hosted/ypr0/radio-ypr0.c (limited to 'firmware/target/hosted/ypr0/radio-ypr0.c') diff --git a/firmware/target/hosted/ypr0/radio-ypr0.c b/firmware/target/hosted/ypr0/radio-ypr0.c new file mode 100644 index 0000000000..c3597bd18c --- /dev/null +++ b/firmware/target/hosted/ypr0/radio-ypr0.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 + * + * Copyright (c) 2012 Lorenzo Miori + * + * 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 +#include +#include +#include "stdint.h" +#include "string.h" + +#include "radio-ypr0.h" + +static int radio_dev = -1; + +void radiodev_open(void) { + radio_dev = open("/dev/si470x", O_RDWR); +} + +void radiodev_close(void) { + close(radio_dev); +} + +/* High-level registers access */ +void si4709_write_reg(int addr, uint16_t value) { + sSi4709_t r = { .addr = addr, .value = value }; + ioctl(radio_dev, IOCTL_SI4709_WRITE_BYTE, &r); +} + +uint16_t si4709_read_reg(int addr) { + sSi4709_t r = { .addr = addr, .value = 0 }; + ioctl(radio_dev, IOCTL_SI4709_READ_BYTE, &r); + return r.value; +} + +/* Low-level i2c channel access */ +int fmradio_i2c_write(unsigned char address, unsigned char* buf, int count) +{ + (void)address; + sSi4709_i2c_t r = { .size = count, .buf = buf }; + return ioctl(radio_dev, IOCTL_SI4709_I2C_WRITE, &r); +} + +int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) +{ + (void)address; + sSi4709_i2c_t r = { .size = count, .buf = buf }; + return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r); +} \ No newline at end of file -- cgit v1.2.3