rockbox/firmware/drivers/tuner/stfm1000.c
Amaury Pouly f7132e4044 Fix copyright headers
Change-Id: Ie65920b1192e9b737fcc2554d280fbcedfa39800
2012-12-29 01:40:35 +01:00

76 lines
No EOL
2.2 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 by Amaury Pouly
*
* 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 <string.h>
#include "kernel.h"
#include "power.h"
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio.h"
#include "fmradio_i2c.h" /* physical interface driver */
#include "stfm1000.h"
#define STFM100_I2C_ADDR 0xc0
#define CHIPID 0x80
static int stfm1000_read_reg(uint8_t reg, uint32_t *val)
{
uint8_t buf[4];
buf[0] = reg;
int ret = fmradio_i2c_write(STFM100_I2C_ADDR, buf, 1);
if(ret < 0) return ret;
ret = fmradio_i2c_read(STFM100_I2C_ADDR, buf, 4);
*val = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
return ret;
}
static int stfm1000_write_reg(uint8_t reg, uint32_t val)
{
uint8_t buf[5];
buf[0] = reg;
buf[1] = val & 0xff; buf[2] = (val >> 8) & 0xff;
buf[3] = (val >> 16) & 0xff; buf[4] = (val >> 24) & 0xff;
return fmradio_i2c_write(STFM100_I2C_ADDR, buf, 5);
}
void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo)
{
memset(nfo, 0, sizeof(struct stfm1000_dbg_info));
stfm1000_read_reg(CHIPID, &nfo->chipid);
}
void stfm1000_init(void)
{
}
int stfm1000_set(int setting, int value)
{
(void) setting;
(void) value;
return -1;
}
int stfm1000_get(int setting)
{
(void) setting;
return -1;
}