summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c86
1 files changed, 51 insertions, 35 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 9deab7712a..598fa1a0eb 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,58 +23,74 @@
23#include "jz4740.h" 23#include "jz4740.h"
24#include "backlight-target.h" 24#include "backlight-target.h"
25 25
26#define GPIO_PWM 123 26#define GPIO_PWM (32*3)+31
27#define PWM_CHN 7 27#define PWM_CHN 7
28#define PWM_FULL 101 28#define __gpio_as_PWM_CHN __gpio_as_pwm7
29 29
30static void set_backlight(int unk, int val) 30static void set_backlight(int val)
31{ 31{
32 if(val == 0) 32 /* Taken from the OF */
33 __gpio_as_pwm7(); 33 int tmp;
34 else 34 tmp = (val/2 + __cpm_get_rtcclk()) / val;
35 { 35 if(tmp > 0xFFFF)
36 REG_TCU_TCSR(7) |= 2; 36 tmp = 0xFFFF;
37 REG_TCU_TCSR(7) &= ~0x100; 37
38 int tmp; 38 __tcu_set_half_data(PWM_CHN, (tmp * val * 1374389535) >> 5);
39 tmp = (unk/2 + __cpm_get_rtcclk()) / unk; 39 __tcu_set_full_data(PWM_CHN, tmp);
40 if(tmp > 0xFFFF)
41 tmp = 0xFFFF;
42
43 __tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5);
44 __tcu_set_full_data(7, tmp);
45
46 REG_TCU_TSCR = (1 << 7);
47 REG_TCU_TESR = (1 << 7);
48
49 __tcu_enable_pwm_output(7);
50 }
51 __tcu_set_count(7, 0);
52} 40}
53 41
54bool _backlight_init(void) 42static void set_backlight_on(void)
55{ 43{
56 __gpio_as_pwm7(); 44 __tcu_start_timer_clock(PWM_CHN);
57
58 __tcu_stop_counter(7);
59 __tcu_disable_pwm_output(7);
60
61 set_backlight(300, 7);
62 45
46 set_backlight(MAX_BRIGHTNESS_SETTING);
47
48 __tcu_set_count(PWM_CHN, 0);
49 __tcu_start_counter(PWM_CHN);
50
51 __tcu_enable_pwm_output(PWM_CHN);
52}
53
54static void set_backlight_off(void)
55{
56 __tcu_stop_counter(PWM_CHN);
57 __tcu_disable_pwm_output(PWM_CHN);
58 __tcu_stop_timer_clock(PWM_CHN);
59}
60
61bool _backlight_init(void)
62{
63 __gpio_as_PWM_CHN();
64 __tcu_start_timer_clock(PWM_CHN);
65
66 __tcu_stop_counter(PWM_CHN);
67 __tcu_disable_pwm_output(PWM_CHN);
68
69 __tcu_init_pwm_output_low(PWM_CHN);
70 __tcu_select_rtcclk(PWM_CHN);
71 __tcu_select_clk_div1(PWM_CHN);
72
73 __tcu_mask_half_match_irq(PWM_CHN);
74 __tcu_mask_full_match_irq(PWM_CHN);
75
76 set_backlight_on();
77
63 return true; 78 return true;
64} 79}
80
65void _backlight_on(void) 81void _backlight_on(void)
66{ 82{
67 set_backlight(300, 7); 83 set_backlight_on();
68} 84}
85
69void _backlight_off(void) 86void _backlight_off(void)
70{ 87{
71 set_backlight(300, 0); 88 set_backlight_off();
72} 89}
73 90
74#ifdef HAVE_BACKLIGHT_BRIGHTNESS 91#ifdef HAVE_BACKLIGHT_BRIGHTNESS
75void _backlight_set_brightness(int brightness) 92void _backlight_set_brightness(int brightness)
76{ 93{
77 (void)brightness; 94 set_backlight(brightness);
78 return;
79} 95}
80#endif 96#endif