diff options
Diffstat (limited to 'firmware/backlight.c')
-rw-r--r-- | firmware/backlight.c | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c index 1ec8bf0933..8f5116b769 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #ifdef HAVE_REMOTE_LCD | 37 | #ifdef HAVE_REMOTE_LCD |
38 | #include "lcd-remote.h" | 38 | #include "lcd-remote.h" |
39 | #endif | 39 | #endif |
40 | #if defined(TARGET_TREE) && !defined(SIMULATOR) | 40 | #ifndef SIMULATOR |
41 | #include "backlight-target.h" | 41 | #include "backlight-target.h" |
42 | #endif | 42 | #endif |
43 | 43 | ||
@@ -58,39 +58,9 @@ static inline void __backlight_set_brightness(int val) | |||
58 | (void)val; | 58 | (void)val; |
59 | } | 59 | } |
60 | #endif | 60 | #endif |
61 | |||
62 | #else | ||
63 | /* Basic low-level code that simply switches backlight on or off. Probably | ||
64 | * a nice candidate for inclusion in the target/ dir. */ | ||
65 | #ifndef TARGET_TREE | ||
66 | static inline void __backlight_on(void) | ||
67 | { | ||
68 | #if CONFIG_BACKLIGHT == BL_RTC | ||
69 | /* Enable square wave */ | ||
70 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); | ||
71 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ | ||
72 | and_b(~0x40, &PADRH); /* drive and set low */ | ||
73 | or_b(0x40, &PAIORH); | ||
74 | #elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */ | ||
75 | or_b(0x40, &PADRH); /* drive it high */ | ||
76 | #endif | ||
77 | } | ||
78 | |||
79 | static inline void __backlight_off(void) | ||
80 | { | ||
81 | #if CONFIG_BACKLIGHT == BL_RTC | ||
82 | /* Disable square wave */ | ||
83 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | ||
84 | #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */ | ||
85 | and_b(~0x40, &PAIORH); /* let it float (up) */ | ||
86 | #elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */ | ||
87 | and_b(~0x40, &PADRH); /* drive it low */ | ||
88 | #endif | ||
89 | } | ||
90 | #endif | ||
91 | #endif /* SIMULATOR */ | 61 | #endif /* SIMULATOR */ |
92 | 62 | ||
93 | #if CONFIG_BACKLIGHT && !defined(BOOTLOADER) | 63 | #if defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER) |
94 | 64 | ||
95 | const signed char backlight_timeout_value[19] = | 65 | const signed char backlight_timeout_value[19] = |
96 | { | 66 | { |
@@ -558,23 +528,15 @@ void backlight_init(void) | |||
558 | queue_init(&backlight_queue, true); | 528 | queue_init(&backlight_queue, true); |
559 | queue_set_irq_safe(&backlight_queue, true); | 529 | queue_set_irq_safe(&backlight_queue, true); |
560 | 530 | ||
561 | #ifdef SIMULATOR | 531 | #ifndef SIMULATOR |
562 | /* do nothing */ | ||
563 | #elif defined(__BACKLIGHT_INIT) | ||
564 | /* Remove the __BACKLIGHT_INIT references when __backlight_init is | ||
565 | available on all backlighted targets. Take them out of the | ||
566 | backlight-target.h files as well */ | ||
567 | if (__backlight_init()) | 532 | if (__backlight_init()) |
568 | { | 533 | { |
569 | # if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) | 534 | # ifdef HAVE_BACKLIGHT_PWM_FADING |
570 | /* If backlight is already on, don't fade in. */ | 535 | /* If backlight is already on, don't fade in. */ |
571 | bl_dim_current = BL_PWM_COUNT; | 536 | bl_dim_current = BL_PWM_COUNT; |
572 | bl_dim_target = BL_PWM_COUNT; | 537 | bl_dim_target = BL_PWM_COUNT; |
573 | # endif | 538 | # endif |
574 | } | 539 | } |
575 | #elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI | ||
576 | PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */ | ||
577 | or_b(0x40, &PAIORH); /* ..and output */ | ||
578 | #endif | 540 | #endif |
579 | backlight_on(); | 541 | backlight_on(); |
580 | #ifdef HAVE_REMOTE_LCD | 542 | #ifdef HAVE_REMOTE_LCD |
@@ -806,16 +768,14 @@ void backlight_set_brightness(int val) | |||
806 | } | 768 | } |
807 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | 769 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
808 | 770 | ||
809 | #else /* (CONFIG_BACKLIGHT == 0) || defined(BOOTLOADER) | 771 | #else /* !defined(HAVE_BACKLIGHT) || defined(BOOTLOADER) |
810 | -- no backlight, empty dummy functions */ | 772 | -- no backlight, empty dummy functions */ |
811 | 773 | ||
812 | #if defined(BOOTLOADER) && CONFIG_BACKLIGHT | 774 | #if defined(BOOTLOADER) && defined(HAVE_BACKLIGHT) |
813 | void backlight_init(void) | 775 | void backlight_init(void) |
814 | { | 776 | { |
815 | #ifdef __BACKLIGHT_INIT | ||
816 | __backlight_init(); | 777 | __backlight_init(); |
817 | __backlight_on(); | 778 | __backlight_on(); |
818 | #endif | ||
819 | } | 779 | } |
820 | #endif | 780 | #endif |
821 | 781 | ||
@@ -832,4 +792,4 @@ bool is_remote_backlight_on(void) {return true;} | |||
832 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | 792 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
833 | void backlight_set_brightness(int val) { (void)val; } | 793 | void backlight_set_brightness(int val) { (void)val; } |
834 | #endif | 794 | #endif |
835 | #endif /* CONFIG_BACKLIGHT && !defined(BOOTLOADER) */ | 795 | #endif /* defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER) */ |