From 56c4e9fa600557242d8b78f5fd8e32c2245b76fc Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Sun, 31 Oct 2010 21:09:34 +0000 Subject: Separate mas35xx lowlevel stuff. Move SH specific bits to target tree. FS#11189 by me. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28425 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/audio/dac3550a.c | 124 +++++++++ firmware/drivers/audio/mas35xx.c | 99 +++++++- firmware/drivers/dac.c | 119 --------- firmware/drivers/dac.h | 48 ---- firmware/drivers/mas.c | 485 ------------------------------------ firmware/drivers/tuner/s1a0903x01.c | 2 +- 6 files changed, 219 insertions(+), 658 deletions(-) create mode 100644 firmware/drivers/audio/dac3550a.c delete mode 100644 firmware/drivers/dac.c delete mode 100644 firmware/drivers/dac.h delete mode 100644 firmware/drivers/mas.c (limited to 'firmware/drivers') diff --git a/firmware/drivers/audio/dac3550a.c b/firmware/drivers/audio/dac3550a.c new file mode 100644 index 0000000000..e13602e481 --- /dev/null +++ b/firmware/drivers/audio/dac3550a.c @@ -0,0 +1,124 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: dac.c 17847 2008-06-28 18:10:04Z bagder $ + * + * 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 "stdbool.h" +#include "i2c.h" +#include "debug.h" +#include "dac3550a.h" + +static bool line_in_enabled = false; +static bool dac_enabled = false; + +/* convert tenth of dB volume (-780..+180) to dac3550 register value */ +int tenthdb2reg(int db) +{ + if (db < -540) /* 3 dB steps */ + return (db + 780) / 30; + else /* 1.5 dB steps */ + return (db + 660) / 15; +} + +int dac_volume(unsigned int left, unsigned int right, bool deemph) +{ + int ret = 0; + unsigned char buf[3]; + + i2c_begin(); + + if (left > 0x38) + left = 0x38; + if (right > 0x38) + right = 0x38; + + buf[0] = DAC_REG_WRITE | DAC_AVOL; + buf[1] = (left & 0x3f) | (deemph ? 0x40 : 0); + buf[2] = right & 0x3f; + + /* send write command */ + if (i2c_write(DAC_DEV_WRITE,buf,3)) + { + ret = -1; + } + + i2c_end(); + return ret; +} + +/****************************************************************** +** Bit6: 0 = 3V 1 = 5V +** Bit5: 0 = normal 1 = low power +** Bit4: 0 = AUX2 off 1 = AUX2 on +** Bit3: 0 = AUX1 off 1 = AUX1 on +** Bit2: 0 = DAC off 1 = DAC on +** Bit1: 0 = stereo 1 = mono +** Bit0: 0 = normal right amp 1 = inverted right amp +******************************************************************/ +/* dac_config is called once to initialize it. we will apply + our static settings because of the init flow. + dac_init -> dac_line_in -> mpeg_init -> dac_config +*/ +static int dac_config(void) +{ + int ret = 0; + unsigned char buf[2]; + + i2c_begin(); + + buf[0] = DAC_REG_WRITE | DAC_GCFG; + buf[1] = (dac_enabled ? 0x04 : 0) | + (line_in_enabled ? 0x08 : 0); + + /* send write command */ + if (i2c_write(DAC_DEV_WRITE,buf,2)) + { + ret = -1; + } + + i2c_end(); + return ret; +} + +void dac_enable(bool enable) +{ + dac_enabled = enable; + dac_config(); +} + +void dac_line_in(bool enable) +{ + line_in_enabled = enable; + dac_config(); +} + +void dac_init(void) +{ + unsigned char buf[2]; + + i2c_begin(); + + buf[0] = DAC_REG_WRITE | DAC_SR_REG; + buf[1] = 0x07; + + /* send write command */ + i2c_write(DAC_DEV_WRITE,buf,2); + i2c_end(); +} + diff --git a/firmware/drivers/audio/mas35xx.c b/firmware/drivers/audio/mas35xx.c index 342d8a3c2e..e6cc665109 100644 --- a/firmware/drivers/audio/mas35xx.c +++ b/firmware/drivers/audio/mas35xx.c @@ -23,8 +23,8 @@ ****************************************************************************/ #include "config.h" +#include "system.h" /* MAX MIN macros */ #include "audiohw.h" -#include "mas.h" const struct sound_settings_info audiohw_settings[] = { #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) @@ -56,10 +56,15 @@ const struct sound_settings_info audiohw_settings[] = { #endif }; - int channel_configuration = SOUND_CHAN_STEREO; int stereo_width = 100; +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) +unsigned long mdb_shape_shadow = 0; +unsigned long loudness_shadow = 0; +unsigned long shadow_io_control_main; +#endif + static void set_channel_config(void) { @@ -181,13 +186,97 @@ void audiohw_set_treble(int val) } #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) -void audiohw_set_volume(int val) { +void audiohw_set_volume(int val) +{ unsigned tmp = ((unsigned)(val + 115) & 0xff) << 8; mas_codec_writereg(MAS_REG_VOLUME_CONTROL, tmp); } -void audiohw_set_balance(int val) { +void audiohw_set_loudness(int value) +{ + loudness_shadow = (loudness_shadow & 0x04) | + (MAX(MIN(value * 4, 0x44), 0) << 8); + mas_codec_writereg(MAS_REG_KLOUDNESS, loudness_shadow); +} + +void audiohw_set_avc(int value) +{ + int tmp; + + static const uint16_t avc_vals[] = + { + (0x1 << 8) | (0x8 << 12), /* 20ms */ + (0x2 << 8) | (0x8 << 12), /* 2s */ + (0x4 << 8) | (0x8 << 12), /* 4s */ + (0x8 << 8) | (0x8 << 12), /* 8s */ + }; + switch (value) { + case 1: + case 2: + case 3: + case 4: + tmp = avc_vals[value -1]; + break; + case -1: /* turn off and then turn on again to decay quickly */ + tmp = mas_codec_readreg(MAS_REG_KAVC); + mas_codec_writereg(MAS_REG_KAVC, 0); + break; + default: /* off */ + tmp = 0; + break; + } + mas_codec_writereg(MAS_REG_KAVC, tmp); +} + +void audiohw_set_mdb_strength(int value) +{ + mas_codec_writereg(MAS_REG_KMDB_STR, (value & 0x7f) << 8); +} + +void audiohw_set_mdb_harmonics(int value) +{ + int tmp = value * 127 / 100; + mas_codec_writereg(MAS_REG_KMDB_HAR, (tmp & 0x7f) << 8); +} + +void audiohw_set_mdb_center(int value) +{ + mas_codec_writereg(MAS_REG_KMDB_FC, (value/10) << 8); +} + +void audiohw_set_mdb_shape(int value) +{ + mdb_shape_shadow = (mdb_shape_shadow & 0x02) | ((value/10) << 8); + mas_codec_writereg(MAS_REG_KMDB_SWITCH, mdb_shape_shadow); +} + +void audiohw_set_mdb_enable(int value) +{ + mdb_shape_shadow = (mdb_shape_shadow & ~0x02) | (value?2:0); + mas_codec_writereg(MAS_REG_KMDB_SWITCH, mdb_shape_shadow); +} + +void audiohw_set_superbass(int value) +{ + loudness_shadow = (loudness_shadow & ~0x04) | (value?4:0); + mas_codec_writereg(MAS_REG_KLOUDNESS, loudness_shadow); +} + +void audiohw_set_balance(int val) +{ unsigned tmp = ((unsigned)(val * 127 / 100) & 0xff) << 8; mas_codec_writereg(MAS_REG_BALANCE, tmp); } -#endif + +void audiohw_set_pitch(unsigned long val) +{ + mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1); + + /* We must tell the MAS that the frequency has changed. + * This will unfortunately cause a short silence. */ + + mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1); +} + +#endif /* CONFIG_CODEC == MAS3587F || CONFIG_CODEC == MAS3539F */ + diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c deleted file mode 100644 index f21ef9a802..0000000000 --- a/firmware/drivers/dac.c +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * 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 "stdbool.h" -#include "i2c.h" -#include "debug.h" -#include "dac.h" - -#ifdef HAVE_DAC3550A - -static bool line_in_enabled = false; -static bool dac_enabled = false; - - -int dac_volume(unsigned int left, unsigned int right, bool deemph) -{ - int ret = 0; - unsigned char buf[3]; - - i2c_begin(); - - if (left > 0x38) - left = 0x38; - if (right > 0x38) - right = 0x38; - - buf[0] = DAC_REG_WRITE | DAC_AVOL; - buf[1] = (left & 0x3f) | (deemph ? 0x40 : 0); - buf[2] = right & 0x3f; - - /* send write command */ - if (i2c_write(DAC_DEV_WRITE,buf,3)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -/****************************************************************** -** Bit6: 0 = 3V 1 = 5V -** Bit5: 0 = normal 1 = low power -** Bit4: 0 = AUX2 off 1 = AUX2 on -** Bit3: 0 = AUX1 off 1 = AUX1 on -** Bit2: 0 = DAC off 1 = DAC on -** Bit1: 0 = stereo 1 = mono -** Bit0: 0 = normal right amp 1 = inverted right amp -******************************************************************/ -/* dac_config is called once to initialize it. we will apply - our static settings because of the init flow. - dac_init -> dac_line_in -> mpeg_init -> dac_config -*/ -static int dac_config(void) -{ - int ret = 0; - unsigned char buf[2]; - - i2c_begin(); - - buf[0] = DAC_REG_WRITE | DAC_GCFG; - buf[1] = (dac_enabled ? 0x04 : 0) | - (line_in_enabled ? 0x08 : 0); - - /* send write command */ - if (i2c_write(DAC_DEV_WRITE,buf,2)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -void dac_enable(bool enable) -{ - dac_enabled = enable; - dac_config(); -} - -void dac_line_in(bool enable) -{ - line_in_enabled = enable; - dac_config(); -} - -void dac_init(void) -{ - unsigned char buf[2]; - - i2c_begin(); - - buf[0] = DAC_REG_WRITE | DAC_SR_REG; - buf[1] = 0x07; - - /* send write command */ - i2c_write(DAC_DEV_WRITE,buf,2); - i2c_end(); -} - -#endif diff --git a/firmware/drivers/dac.h b/firmware/drivers/dac.h deleted file mode 100644 index 121ce74e9d..0000000000 --- a/firmware/drivers/dac.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * 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. - * - ****************************************************************************/ -#ifndef _DAC_H_ -#define _DAC_H_ - -#include "config.h" - -#ifdef HAVE_DAC3550A - -/* - DAC I2C defs -*/ -#define DAC_ADR 0x9a -#define DAC_DEV_WRITE (DAC_ADR | 0x00) - -#define DAC_REG_WRITE 0xc0 - -/* registers..*/ -#define DAC_SR_REG 1 -#define DAC_AVOL 2 -#define DAC_GCFG 3 - -extern int dac_volume(unsigned int left, unsigned int right, bool deemph); -extern void dac_enable(bool enable); -extern void dac_line_in(bool enable); -extern void dac_init(void); - -#endif - -#endif diff --git a/firmware/drivers/mas.c b/firmware/drivers/mas.c deleted file mode 100644 index 4f384d3b98..0000000000 --- a/firmware/drivers/mas.c +++ /dev/null @@ -1,485 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * 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 "stdbool.h" -#include "config.h" -#include "sh7034.h" -#include "i2c.h" -#include "debug.h" -#include "mas.h" -#include "kernel.h" -#include "system.h" -#include "hwcompat.h" - -static int mas_devread(unsigned long *dest, int len); - -int mas_default_read(unsigned short *buf) -{ - unsigned char *dest = (unsigned char *)buf; - int ret = 0; - - i2c_begin(); - - i2c_start(); - i2c_outb(MAS_DEV_WRITE); - if (i2c_getack()) { - i2c_outb(MAS_DATA_READ); - if (i2c_getack()) { - i2c_start(); - i2c_outb(MAS_DEV_READ); - if (i2c_getack()) { - dest[0] = i2c_inb(0); - dest[1] = i2c_inb(1); - } - else - ret = -3; - } - else - ret = -2; - } - else - ret = -1; - - i2c_stop(); - - i2c_end(); - return ret; -} - -int mas_run(unsigned short address) -{ - int ret = 0; - unsigned char buf[3]; - - i2c_begin(); - - buf[0] = MAS_DATA_WRITE; - buf[1] = address >> 8; - buf[2] = address & 0xff; - - /* send run command */ - if (i2c_write(MAS_DEV_WRITE,buf,3)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -/* note: 'len' is number of 32-bit words, not number of bytes! */ -int mas_readmem(int bank, int addr, unsigned long* dest, int len) -{ - int ret = 0; - unsigned char buf[7]; - - i2c_begin(); - - buf[0] = MAS_DATA_WRITE; - buf[1] = bank?MAS_CMD_READ_D1_MEM:MAS_CMD_READ_D0_MEM; - buf[2] = 0x00; - buf[3] = (len & 0xff00) >> 8; - buf[4] = len & 0xff; - buf[5] = (addr & 0xff00) >> 8; - buf[6] = addr & 0xff; - - /* send read command */ - if (i2c_write(MAS_DEV_WRITE,buf,7)) - { - ret = -1; - } - - ret = mas_devread(dest, len); - - i2c_end(); - return ret; -} - -/* note: 'len' is number of 32-bit words, not number of bytes! */ -int mas_writemem(int bank, int addr, const unsigned long* src, int len) -{ - int ret = 0; - int i, j; - unsigned char buf[60]; - const unsigned char* ptr = (const unsigned char*)src; - - i2c_begin(); - - i=0; - buf[i++] = MAS_DATA_WRITE; - buf[i++] = bank?MAS_CMD_WRITE_D1_MEM:MAS_CMD_WRITE_D0_MEM; - buf[i++] = 0x00; - buf[i++] = (len & 0xff00) >> 8; - buf[i++] = len & 0xff; - buf[i++] = (addr & 0xff00) >> 8; - buf[i++] = addr & 0xff; - - j = 0; - while(len--) { -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - buf[i++] = 0; - buf[i++] = ptr[j+1]; - buf[i++] = ptr[j+2]; - buf[i++] = ptr[j+3]; -#else - buf[i++] = ptr[j+2]; - buf[i++] = ptr[j+3]; - buf[i++] = 0; - buf[i++] = ptr[j+1]; -#endif - j += 4; - } - - /* send write command */ - if (i2c_write(MAS_DEV_WRITE,buf,i)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -int mas_readreg(int reg) -{ - int ret = 0; - unsigned char buf[16]; - unsigned long value; - - i2c_begin(); - - buf[0] = MAS_DATA_WRITE; - buf[1] = MAS_CMD_READ_REG | (reg >> 4); - buf[2] = (reg & 0x0f) << 4; - - /* send read command */ - if (i2c_write(MAS_DEV_WRITE,buf,3)) - { - ret = -1; - } - else - { - if(mas_devread(&value, 1)) - { - ret = -2; - } - else - { - ret = value; - } - } - - i2c_end(); - return ret; -} - -int mas_writereg(int reg, unsigned int val) -{ - int ret = 0; - unsigned char buf[5]; - - i2c_begin(); - - buf[0] = MAS_DATA_WRITE; - buf[1] = MAS_CMD_WRITE_REG | (reg >> 4); -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - buf[2] = ((reg & 0x0f) << 4) | (val >> 16 & 0x0f); - buf[3] = (val >> 8) & 0xff; - buf[4] = val & 0xff; -#else - buf[2] = ((reg & 0x0f) << 4) | (val & 0x0f); - buf[3] = (val >> 12) & 0xff; - buf[4] = (val >> 4) & 0xff; -#endif - - /* send write command */ - if (i2c_write(MAS_DEV_WRITE,buf,5)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -/* note: 'len' is number of 32-bit words, not number of bytes! */ -static int mas_devread(unsigned long *dest, int len) -{ - int ret = 0; - unsigned char* ptr = (unsigned char*)dest; - int i; - - /* handle read-back */ - /* Remember, the MAS values are only 20 bits, so we set - the upper 12 bits to 0 */ - i2c_start(); - i2c_outb(MAS_DEV_WRITE); - if (i2c_getack()) { - i2c_outb(MAS_DATA_READ); - if (i2c_getack()) { - i2c_start(); - i2c_outb(MAS_DEV_READ); - if (i2c_getack()) { - for (i=0;len;i++) { - len--; -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - i2c_inb(0); /* Dummy read */ - ptr[i*4+0] = 0; - ptr[i*4+1] = i2c_inb(0) & 0x0f; - ptr[i*4+2] = i2c_inb(0); - if(len) - ptr[i*4+3] = i2c_inb(0); - else - ptr[i*4+3] = i2c_inb(1); /* NAK the last byte */ -#else - ptr[i*4+2] = i2c_inb(0); - ptr[i*4+3] = i2c_inb(0); - ptr[i*4+0] = i2c_inb(0); - if(len) - ptr[i*4+1] = i2c_inb(0); - else - ptr[i*4+1] = i2c_inb(1); /* NAK the last byte */ -#endif - } - } - else - ret = -3; - } - else - ret = -2; - } - else - ret = -1; - - i2c_stop(); - - return ret; -} - -void mas_reset(void) -{ - or_b(0x01, &PAIORH); - -#if CONFIG_CODEC == MAS3507D - /* PB5 is "MAS enable". make it GPIO output and high */ - PBCR2 &= ~0x0c00; - or_b(0x20, &PBIORL); - or_b(0x20, &PBDRL); - - and_b(~0x01, &PADRH); - sleep(HZ/100); - or_b(0x01, &PADRH); - sleep(HZ/5); -#elif (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - if (HW_MASK & ATA_ADDRESS_200) - { - and_b(~0x01, &PADRH); - sleep(HZ/100); - or_b(0x01, &PADRH); - sleep(HZ/5); - } - else - { - /* Older recorder models don't invert the POR signal */ - or_b(0x01, &PADRH); - sleep(HZ/100); - and_b(~0x01, &PADRH); - sleep(HZ/5); - } -#endif -} - -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) -int mas_direct_config_read(unsigned char reg) -{ - int ret = 0; - unsigned char tmp[2]; - - i2c_begin(); - - i2c_start(); - i2c_outb(MAS_DEV_WRITE); - if (i2c_getack()) { - i2c_outb(reg); - if (i2c_getack()) { - i2c_start(); - i2c_outb(MAS_DEV_READ); - if (i2c_getack()) { - tmp[0] = i2c_inb(0); - tmp[1] = i2c_inb(1); /* NAK the last byte */ - ret = (tmp[0] << 8) | tmp[1]; - } - else - ret = -3; - } - else - ret = -2; - } - else - ret = -1; - - i2c_stop(); - - i2c_end(); - return ret; -} - -int mas_direct_config_write(unsigned char reg, unsigned int val) -{ - int ret = 0; - unsigned char buf[3]; - - i2c_begin(); - - buf[0] = reg; - buf[1] = (val >> 8) & 0xff; - buf[2] = val & 0xff; - - /* send write command */ - if (i2c_write(MAS_DEV_WRITE,buf,3)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -int mas_codec_writereg(int reg, unsigned int val) -{ - int ret = 0; - unsigned char buf[5]; - - i2c_begin(); - - buf[0] = MAS_CODEC_WRITE; - buf[1] = (reg >> 8) & 0xff; - buf[2] = reg & 0xff; - buf[3] = (val >> 8) & 0xff; - buf[4] = val & 0xff; - - /* send write command */ - if (i2c_write(MAS_DEV_WRITE,buf,5)) - { - ret = -1; - } - - i2c_end(); - return ret; -} - -int mas_codec_readreg(int reg) -{ - int ret = 0; - unsigned char buf[16]; - unsigned char tmp[2]; - - i2c_begin(); - - buf[0] = MAS_CODEC_WRITE; - buf[1] = (reg >> 8) & 0xff; - buf[2] = reg & 0xff; - - /* send read command */ - if (i2c_write(MAS_DEV_WRITE,buf,3)) - { - ret = -1; - } - else - { - i2c_start(); - i2c_outb(MAS_DEV_WRITE); - if (i2c_getack()) { - i2c_outb(MAS_CODEC_READ); - if (i2c_getack()) { - i2c_start(); - i2c_outb(MAS_DEV_READ); - if (i2c_getack()) { - tmp[0] = i2c_inb(0); - tmp[1] = i2c_inb(1); /* NAK the last byte */ - ret = (tmp[0] << 8) | tmp[1]; - } - else - ret = -4; - } - else - ret = -3; - } - else - ret = -2; - - i2c_stop(); - } - - i2c_end(); - return ret; -} - -unsigned long mas_readver(void) -{ - int ret = 0; - unsigned char buf[16]; - unsigned long value; - - i2c_begin(); - - buf[0] = MAS_DATA_WRITE; - buf[1] = MAS_CMD_READ_IC_VER; - buf[2] = 0; - - /* send read command */ - if (i2c_write(MAS_DEV_WRITE,buf,3)) - { - ret = -1; - } - else - { - if(mas_devread(&value, 1)) - { - ret = -2; - } - else - { - ret = value; - } - } - - i2c_end(); - return ret; -} - -#endif - -#if CONFIG_TUNER & S1A0903X01 -static int pllfreq; - -void mas_store_pllfreq(int freq) -{ - pllfreq = freq; -} - -int mas_get_pllfreq(void) -{ - return pllfreq; -} -#endif - - - diff --git a/firmware/drivers/tuner/s1a0903x01.c b/firmware/drivers/tuner/s1a0903x01.c index 3a417d73af..2c93ebdaad 100644 --- a/firmware/drivers/tuner/s1a0903x01.c +++ b/firmware/drivers/tuner/s1a0903x01.c @@ -27,7 +27,7 @@ #include "tuner.h" /* tuner abstraction interface */ #include "fmradio.h" /* physical interface driver */ #include "sound.h" -#include "mas.h" +#include "mas35xx.h" #include "power.h" #define DEFAULT_IN1 0x100003 /* Mute */ -- cgit v1.2.3