summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/codec-jz4740.c92
-rw-r--r--firmware/target/mips/ingenic_jz47xx/i2c-jz4740.c16
-rw-r--r--firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c9
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c21
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c27
6 files changed, 82 insertions, 86 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c
index 0b187be1cc..05ca2d02d4 100644
--- a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c
@@ -40,11 +40,13 @@ const struct sound_settings_info audiohw_settings[] = {
#endif
};
+#if 0
static unsigned short codec_volume;
static unsigned short codec_base_gain;
static unsigned short codec_mic_gain;
+static int HP_register_value;
+#endif
static bool HP_on_off_flag;
-static int HP_register_value;
static void i2s_codec_set_samplerate(unsigned short rate);
@@ -77,7 +79,7 @@ static void i2s_codec_init(void)
i2s_codec_reset();
//REG_ICDC_CDCCR2 = (ICDC_CDCCR2_AINVOL(ICDC_CDCCR2_AINVOL_DB(0)) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_48)
- REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(23) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44)
+ REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(14) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44)
| ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_6));
REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST);
@@ -101,6 +103,7 @@ static void i2s_codec_init(void)
HP_on_off_flag = 1; /* HP is on */
}
+#if 0
static void i2s_codec_set_mic(unsigned short v) /* 0 <= v <= 100 */
{
v &= 0xff;
@@ -201,48 +204,6 @@ static unsigned short i2s_codec_get_volume(void)
return val;
}
-static void i2s_codec_set_samplerate(unsigned short rate)
-{
- unsigned short speed = 0;
-
- switch (rate)
- {
- case 8000:
- speed = 0 << 8;
- break;
- case 11025:
- speed = 1 << 8;
- break;
- case 12000:
- speed = 2 << 8;
- break;
- case 16000:
- speed = 3 << 8;
- break;
- case 22050:
- speed = 4 << 8;
- break;
- case 24000:
- speed = 5 << 8;
- break;
- case 32000:
- speed = 6 << 8;
- break;
- case 44100:
- speed = 7 << 8;
- break;
- case 48000:
- speed = 8 << 8;
- break;
- default:
- break;
- }
- REG_ICDC_CDCCR2 |= 0x00000f00;
-
- speed |= 0xfffff0ff;
- REG_ICDC_CDCCR2 &= speed;
-}
-
static void HP_turn_on(void)
{
//see 1.3.4.1
@@ -274,7 +235,6 @@ static void HP_turn_on(void)
HP_register_value = REG_ICDC_CDCCR1;*/
//see 1.3.4.3
-
}
@@ -302,7 +262,49 @@ static void HP_turn_off(void)
REG_ICDC_CDCCR1 |= 0x00000002;*/
//see 1.3.4.3
+}
+#endif
+static void i2s_codec_set_samplerate(unsigned short rate)
+{
+ unsigned short speed = 0;
+
+ switch (rate)
+ {
+ case 8000:
+ speed = 0 << 8;
+ break;
+ case 11025:
+ speed = 1 << 8;
+ break;
+ case 12000:
+ speed = 2 << 8;
+ break;
+ case 16000:
+ speed = 3 << 8;
+ break;
+ case 22050:
+ speed = 4 << 8;
+ break;
+ case 24000:
+ speed = 5 << 8;
+ break;
+ case 32000:
+ speed = 6 << 8;
+ break;
+ case 44100:
+ speed = 7 << 8;
+ break;
+ case 48000:
+ speed = 8 << 8;
+ break;
+ default:
+ break;
+ }
+ REG_ICDC_CDCCR2 |= 0x00000f00;
+
+ speed |= 0xfffff0ff;
+ REG_ICDC_CDCCR2 &= speed;
}
void audiohw_mute(bool mute)
diff --git a/firmware/target/mips/ingenic_jz47xx/i2c-jz4740.c b/firmware/target/mips/ingenic_jz47xx/i2c-jz4740.c
index b97448f4bb..5df0e90683 100644
--- a/firmware/target/mips/ingenic_jz47xx/i2c-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/i2c-jz4740.c
@@ -74,6 +74,7 @@ static int i2c_put_data(unsigned char data)
return -1;
}
+#if 0
static int i2c_put_data_nack(unsigned char data)
{
unsigned int timeout = TIMEOUT*10;
@@ -86,6 +87,7 @@ static int i2c_put_data_nack(unsigned char data)
return 0;
}
+#endif
static int i2c_get_data(unsigned char *data, int ack)
{
@@ -111,13 +113,17 @@ static int i2c_get_data(unsigned char *data, int ack)
return -1;
}
+void i2c_setclk(unsigned int i2cclk)
+{
+ __i2c_set_clk(__cpm_get_i2sclk(), i2cclk);
+}
+
/*
* I2C interface
*/
void i2c_open(void)
{
- /* TODO */
- //__i2c_set_clk(jz_clocks.extalclk, 10000); /* default 10 KHz */
+ i2c_setclk(10000); /* default 10 KHz */
__i2c_enable();
}
@@ -127,12 +133,6 @@ void i2c_close(void)
__i2c_disable();
}
-void i2c_setclk(unsigned int i2cclk)
-{
- /* TODO */
- //__i2c_set_clk(jz_clocks.extalclk, i2cclk);
-}
-
int i2c_read(int device, unsigned char *buf, int count)
{
int cnt = count;
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
index 3d93feac04..d9eb3ecdef 100644
--- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
@@ -25,10 +25,9 @@
#include "lcd-target.h"
#include "system.h"
#include "kernel.h"
-#include "backlight-target.h"
/*
- Warning: code behaviour is unpredictable when threads get switched in IRQ mode!
+ Warning: code behaviour is unpredictable when switch_thread() gets called in IRQ mode!
So don't update the LCD in an interrupt handler!
*/
@@ -42,6 +41,7 @@ void lcd_init_device(void)
__cpm_start_lcd();
lcd_init_controller();
__cpm_stop_lcd();
+
lcd_is_on = true;
mutex_init(&lcd_mtx);
wakeup_init(&lcd_wkup);
@@ -71,7 +71,7 @@ bool lcd_enabled(void)
/* Update a fraction of the display. */
void lcd_update_rect(int x, int y, int width, int height)
{
-x=0;y=0;width=LCD_WIDTH;height=LCD_HEIGHT;
+x=0;y=0;width=LCD_WIDTH;height=LCD_HEIGHT; /* HACK! */
mutex_lock(&lcd_mtx);
__cpm_start_lcd();
@@ -133,12 +133,13 @@ void DMA_CALLBACK(DMA_LCD_CHANNEL)(void)
This must be called after all other LCD functions that change the display. */
void lcd_update(void)
{
- if (!lcd_is_on || !backlight_enabled())
+ if(!lcd_is_on)
return;
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
+/* TODO: use IPU */
void lcd_blit_yuv(unsigned char * const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height)
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
index eec48768b2..72e469977b 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
@@ -27,12 +27,11 @@
#define BACKLIGHT_GPIO (32*3+31)
#define BACKLIGHT_PWM 7
+/* TODO: use HW PWM */
#define SW_PWM 1
-
#if SW_PWM
static bool backlight_on;
-
static void set_backlight(int val)
{
(void)val;
@@ -48,20 +47,19 @@ bool _backlight_init(void)
return true;
}
-bool backlight_enabled(void)
-{
- return backlight_on;
-}
-
void _backlight_on(void)
{
- __gpio_set_pin(BACKLIGHT_GPIO);
+ if(!backlight_on)
+ __gpio_set_pin(BACKLIGHT_GPIO);
+
backlight_on = true;
}
void _backlight_off(void)
{
- __gpio_clear_pin(BACKLIGHT_GPIO);
+ if(backlight_on)
+ __gpio_clear_pin(BACKLIGHT_GPIO);
+
backlight_on = false;
}
@@ -131,11 +129,6 @@ bool _backlight_init(void)
return true;
}
-bool backlight_enabled(void)
-{
- return old_val > -1 ? true : false;
-}
-
void _backlight_on(void)
{
set_backlight_on();
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
index c6647fa9da..4170f96cc0 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
@@ -29,12 +29,9 @@
#include <stdbool.h>
-/*
bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int brightness);
-bool backlight_enabled(void);
-*/
#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index 3dce73b05e..c9c264e26a 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -71,36 +71,36 @@ static struct mutex battery_mtx;
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
/* TODO */
- 1400
+ 1000
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
/* TODO */
- 1300
+ 900
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* TODO */
- { 1300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160 },
+ { 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000 },
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
{
/* TODO */
- 3300, 3680, 3740, 3760, 3780, 3810, 3870, 3930, 3970, 4070, 4160
+ 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000
};
/* VBAT = (BDATA/4096) * 7.5V */
-#define BATTERY_SCALE_FACTOR 7500
+#define BATTERY_SCALE_FACTOR 1875
/* Returns battery voltage from ADC [millivolts] */
unsigned int battery_adc_voltage(void)
{
- unsigned int dummy, timeout=1000;
+ unsigned int dummy, timeout=HZ/4;
mutex_lock(&battery_mtx);
@@ -114,18 +114,18 @@ unsigned int battery_adc_voltage(void)
while(bat_val == 0 && timeout--)
sleep(0);
- logf("%d %d", bat_val, (bat_val*BATTERY_SCALE_FACTOR)>>12);
+ logf("%d %d", bat_val, (bat_val*BATTERY_SCALE_FACTOR)>>10);
mutex_unlock(&battery_mtx);
- return (bat_val*BATTERY_SCALE_FACTOR)>>12;
+ return (bat_val*BATTERY_SCALE_FACTOR)>>10;
}
void button_init_device(void)
{
__cpm_start_sadc();
REG_SADC_ENA = 0;
- REG_SADC_STATE &= (~REG_SADC_STATE);
+ REG_SADC_STATE &= ~REG_SADC_STATE;
REG_SADC_CTRL = 0x1F;
REG_SADC_CFG = SADC_CFG_INIT;
@@ -134,8 +134,8 @@ void button_init_device(void)
REG_SADC_SAMETIME = 10;
REG_SADC_WAITTIME = 100;
- REG_SADC_STATE &= (~REG_SADC_STATE);
- REG_SADC_CTRL = (~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM));
+ REG_SADC_STATE &= ~REG_SADC_STATE;
+ REG_SADC_CTRL = ~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM);
REG_SADC_ENA = SADC_ENA_TSEN;
#ifdef ONDA_VX747
@@ -192,6 +192,9 @@ int button_read_device(int *data)
if( UNLIKELY(!is_backlight_on(true)) )
*data = 0;
}
+
+ if(ret & (BUTTON_VOL_DOWN|BUTTON_VOL_UP))
+ touchscreen_set_mode( touchscreen_get_mode() == TOUCHSCREEN_BUTTON ? TOUCHSCREEN_POINT : TOUCHSCREEN_BUTTON);
return ret;
}
@@ -205,7 +208,7 @@ void SADC(void)
sadcstate = REG_SADC_STATE;
state = REG_SADC_STATE & (~REG_SADC_CTRL);
REG_SADC_STATE &= sadcstate;
-
+
if(state & SADC_CTRL_PENDM)
{
/* Pen down IRQ */