summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx747
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx747')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c100
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c6
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c2
4 files changed, 85 insertions, 24 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
index 501a90551e..208236ef95 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
@@ -23,60 +23,119 @@
#include "jz4740.h"
#include "backlight-target.h"
-#define PWM_CHN 7 /* PWM_CHN7 == GPIO(32*3 + 31) */
-#define __gpio_as_PWM_CHN __gpio_as_pwm7
+/* PWM_CHN7 == GPIO(32*3 + 31) */
+#define BACKLIGHT_GPIO (32*3+31)
+#define BACKLIGHT_PWM 7
+#define SW_PWM 1
+
+#if SW_PWM
+
+static bool backlight_on;
+
+static void set_backlight(int val)
+{
+(void)val;
+}
+
+bool _backlight_init(void)
+{
+ __gpio_as_output(BACKLIGHT_GPIO);
+ __gpio_set_pin(BACKLIGHT_GPIO);
+
+ backlight_on = true;
+
+ return true;
+}
+
+bool backlight_enabled(void)
+{
+ return backlight_on;
+}
+
+void _backlight_on(void)
+{
+ __gpio_set_pin(BACKLIGHT_GPIO);
+ backlight_on = true;
+}
+
+void _backlight_off(void)
+{
+ __gpio_clear_pin(BACKLIGHT_GPIO);
+ backlight_on = false;
+}
+
+#else
+
+static int old_val;
static void set_backlight(int val)
{
+ if(val == old_val)
+ return;
+
/* Taken from the OF */
int tmp;
tmp = (val/2 + __cpm_get_rtcclk()) / val;
if(tmp > 0xFFFF)
tmp = 0xFFFF;
- __tcu_set_half_data(PWM_CHN, (tmp * val * 1374389535) >> 5);
- __tcu_set_full_data(PWM_CHN, tmp);
+ __tcu_set_half_data(BACKLIGHT_PWM, (tmp * val * 1374389535) >> 5);
+ __tcu_set_full_data(BACKLIGHT_PWM, tmp);
+
+ old_val = val;
}
static void set_backlight_on(void)
{
- __tcu_start_timer_clock(PWM_CHN);
+ if(old_val == MAX_BRIGHTNESS_SETTING)
+ return;
+
+ __tcu_start_timer_clock(BACKLIGHT_PWM);
set_backlight(MAX_BRIGHTNESS_SETTING);
- __tcu_set_count(PWM_CHN, 0);
- __tcu_start_counter(PWM_CHN);
+ __tcu_set_count(BACKLIGHT_PWM, 0);
+ __tcu_start_counter(BACKLIGHT_PWM);
- __tcu_enable_pwm_output(PWM_CHN);
+ __tcu_enable_pwm_output(BACKLIGHT_PWM);
}
static void set_backlight_off(void)
{
- __tcu_stop_counter(PWM_CHN);
- __tcu_disable_pwm_output(PWM_CHN);
- __tcu_stop_timer_clock(PWM_CHN);
+ __tcu_stop_counter(BACKLIGHT_PWM);
+ __tcu_disable_pwm_output(BACKLIGHT_PWM);
+ __tcu_stop_timer_clock(BACKLIGHT_PWM);
+
+ old_val = -1;
}
bool _backlight_init(void)
{
- __gpio_as_PWM_CHN();
- __tcu_start_timer_clock(PWM_CHN);
+ __gpio_as_pwm(BACKLIGHT_PWM);
+ __tcu_start_timer_clock(BACKLIGHT_PWM);
- __tcu_stop_counter(PWM_CHN);
- __tcu_disable_pwm_output(PWM_CHN);
+ __tcu_stop_counter(BACKLIGHT_PWM);
+ __tcu_disable_pwm_output(BACKLIGHT_PWM);
- __tcu_init_pwm_output_low(PWM_CHN);
- __tcu_select_rtcclk(PWM_CHN);
- __tcu_select_clk_div1(PWM_CHN);
+ __tcu_init_pwm_output_low(BACKLIGHT_PWM);
+ __tcu_select_rtcclk(BACKLIGHT_PWM);
+ __tcu_select_clk_div1(BACKLIGHT_PWM);
- __tcu_mask_half_match_irq(PWM_CHN);
- __tcu_mask_full_match_irq(PWM_CHN);
+ __tcu_mask_half_match_irq(BACKLIGHT_PWM);
+ __tcu_mask_full_match_irq(BACKLIGHT_PWM);
+
+ old_val = -1;
set_backlight_on();
return true;
}
+bool backlight_enabled(void)
+{
+ return old_val > -1 ? true : false;
+}
+
void _backlight_on(void)
{
set_backlight_on();
@@ -86,6 +145,7 @@ void _backlight_off(void)
{
set_backlight_off();
}
+#endif /* !SW_PWM */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
void _backlight_set_brightness(int brightness)
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 4170f96cc0..f3f17f024e 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
@@ -33,5 +33,6 @@ 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/lcd-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
index f7c6a137fc..40d9bb6106 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
@@ -204,7 +204,7 @@ static void _set_lcd_clock(void)
__cpm_stop_lcd();
pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */
pll_div = pll_div ? 1 : 2 ;
- val = ( __cpm_get_pllout()/pll_div ) / 336000000;
+ val = ( __cpm_get_pllout()/pll_div ) / __cpm_get_pclk();
val--;
if ( val > 0x1ff )
val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */
@@ -235,8 +235,8 @@ void lcd_set_target(short x, short y, short width, short height)
SLCD_SEND_COMMAND(REG_RAM_VADDR_START, x); /* x_start */
SLCD_SEND_COMMAND(REG_RAM_VADDR_END, x+width-1); /* x_end */
#endif
- SLCD_SEND_COMMAND(REG_RAM_HADDR_SET, x); /* set cursor at x_start */
- SLCD_SEND_COMMAND(REG_RAM_VADDR_SET, y); /* set cursor at y_start */
+ SLCD_SEND_COMMAND(REG_RAM_HADDR_SET, y); /* set cursor at x_start */
+ SLCD_SEND_COMMAND(REG_RAM_VADDR_SET, x); /* set cursor at y_start */
SLCD_SET_COMMAND(REG_RW_GRAM); /* write data to GRAM */
}
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 0271fd1b96..95c2f84a7e 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
@@ -47,7 +47,7 @@
BTN_MENU | BTN_VOL_UP)
-#define TS_AD_COUNT 5
+#define TS_AD_COUNT 3
#define SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT)
#define SADC_CFG_INIT ( \