diff options
-rw-r--r-- | apps/debug_menu.c | 20 | ||||
-rw-r--r-- | firmware/drivers/tuner/lv24020lp.c | 152 | ||||
-rw-r--r-- | firmware/export/lv24020lp.h | 9 | ||||
-rw-r--r-- | firmware/export/power.h | 1 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/power-e200.c | 15 | ||||
-rw-r--r-- | firmware/tuner.c | 14 |
6 files changed, 149 insertions, 62 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 93004d818a..736c2054d1 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1942,11 +1942,10 @@ static bool dbg_save_roms(void) | |||
1942 | 1942 | ||
1943 | #ifndef SIMULATOR | 1943 | #ifndef SIMULATOR |
1944 | #if CONFIG_TUNER | 1944 | #if CONFIG_TUNER |
1945 | int radio_lines = 0; | ||
1946 | static int radio_callback(int btn, struct gui_synclist *lists) | 1945 | static int radio_callback(int btn, struct gui_synclist *lists) |
1947 | { | 1946 | { |
1948 | (void)btn;(void)lists; | 1947 | int radio_lines = 0; |
1949 | radio_lines = 0; | 1948 | |
1950 | if (radio_hardware_present()) | 1949 | if (radio_hardware_present()) |
1951 | { | 1950 | { |
1952 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, | 1951 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
@@ -1966,10 +1965,14 @@ static int radio_callback(int btn, struct gui_synclist *lists) | |||
1966 | "if_set: %d Hz", (lv24020lp_get(LV24020LP_IF_SET) ) ); | 1965 | "if_set: %d Hz", (lv24020lp_get(LV24020LP_IF_SET) ) ); |
1967 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, | 1966 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
1968 | "sd_set: %d Hz", (lv24020lp_get(LV24020LP_SD_SET) ) ); | 1967 | "sd_set: %d Hz", (lv24020lp_get(LV24020LP_SD_SET) ) ); |
1968 | |||
1969 | if (btn != ACTION_STD_CANCEL) | ||
1970 | btn = ACTION_REDRAW; | ||
1969 | #endif | 1971 | #endif |
1970 | #if (CONFIG_TUNER & S1A0903X01) | 1972 | #if (CONFIG_TUNER & S1A0903X01) |
1971 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, | 1973 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
1972 | "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL)); | 1974 | "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL)); |
1975 | /* This one doesn't return dynamic data atm */ | ||
1973 | #endif | 1976 | #endif |
1974 | #if (CONFIG_TUNER & TEA5767) | 1977 | #if (CONFIG_TUNER & TEA5767) |
1975 | struct tea5767_dbg_info info; | 1978 | struct tea5767_dbg_info info; |
@@ -1985,16 +1988,21 @@ static int radio_callback(int btn, struct gui_synclist *lists) | |||
1985 | (unsigned)info.write_regs[0], (unsigned)info.write_regs[1], | 1988 | (unsigned)info.write_regs[0], (unsigned)info.write_regs[1], |
1986 | (unsigned)info.write_regs[2], (unsigned)info.write_regs[3], | 1989 | (unsigned)info.write_regs[2], (unsigned)info.write_regs[3], |
1987 | (unsigned)info.write_regs[4]); | 1990 | (unsigned)info.write_regs[4]); |
1991 | |||
1992 | if (btn != ACTION_STD_CANCEL) | ||
1993 | btn = ACTION_REDRAW; | ||
1988 | #endif | 1994 | #endif |
1989 | btn = ACTION_REDRAW; | 1995 | |
1996 | gui_synclist_set_nb_items(lists, radio_lines); | ||
1990 | } | 1997 | } |
1991 | else | 1998 | else |
1992 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, "HW detected: no"); | 1999 | snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "HW detected: no"); |
2000 | |||
1993 | return btn; | 2001 | return btn; |
1994 | } | 2002 | } |
1995 | static bool dbg_fm_radio(void) | 2003 | static bool dbg_fm_radio(void) |
1996 | { | 2004 | { |
1997 | dbg_list("FM Radio",radio_lines, 1, | 2005 | dbg_list("FM Radio", 1, 1, |
1998 | radio_callback, dbg_listmessage_getname); | 2006 | radio_callback, dbg_listmessage_getname); |
1999 | return false; | 2007 | return false; |
2000 | } | 2008 | } |
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c index 9ec68f9a27..79d38443f2 100644 --- a/firmware/drivers/tuner/lv24020lp.c +++ b/firmware/drivers/tuner/lv24020lp.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "thread.h" | 24 | #include "thread.h" |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "tuner.h" /* tuner abstraction interface */ | 26 | #include "tuner.h" /* tuner abstraction interface */ |
27 | #include "power.h" | ||
27 | #include "fmradio.h" /* physical interface driver */ | 28 | #include "fmradio.h" /* physical interface driver */ |
28 | #include "sound.h" | 29 | #include "sound.h" |
29 | #include "pp5024.h" | 30 | #include "pp5024.h" |
@@ -31,6 +32,8 @@ | |||
31 | 32 | ||
32 | #ifndef BOOTLOADER | 33 | #ifndef BOOTLOADER |
33 | 34 | ||
35 | static struct mutex tuner_mtx; | ||
36 | |||
34 | #if 0 | 37 | #if 0 |
35 | /* define to enable tuner logging */ | 38 | /* define to enable tuner logging */ |
36 | #define SANYO_TUNER_LOG | 39 | #define SANYO_TUNER_LOG |
@@ -338,6 +341,10 @@ static void lv24020lp_write(unsigned int address, unsigned int data) | |||
338 | break; | 341 | break; |
339 | } | 342 | } |
340 | 343 | ||
344 | /* Check if interface is turned on */ | ||
345 | if (!(tuner_status & TUNER_POWERED)) | ||
346 | return; | ||
347 | |||
341 | address = lv24020lp_begin_write(address); | 348 | address = lv24020lp_begin_write(address); |
342 | 349 | ||
343 | /* data first */ | 350 | /* data first */ |
@@ -365,6 +372,10 @@ static unsigned int lv24020lp_read(unsigned int address) | |||
365 | int i; | 372 | int i; |
366 | unsigned int toread; | 373 | unsigned int toread; |
367 | 374 | ||
375 | /* Check if interface is turned on */ | ||
376 | if (!(tuner_status & TUNER_POWERED)) | ||
377 | return 0; | ||
378 | |||
368 | address = lv24020lp_begin_write(address); | 379 | address = lv24020lp_begin_write(address); |
369 | 380 | ||
370 | /* address */ | 381 | /* address */ |
@@ -433,9 +444,6 @@ static int tuner_measure(unsigned char type, int scale, int duration) | |||
433 | { | 444 | { |
434 | int64_t finval; | 445 | int64_t finval; |
435 | 446 | ||
436 | if (!tuner_awake()) | ||
437 | return 0; | ||
438 | |||
439 | /* enable measuring */ | 447 | /* enable measuring */ |
440 | lv24020lp_write_or(MSRC_SEL, type); | 448 | lv24020lp_write_or(MSRC_SEL, type); |
441 | lv24020lp_write_and(CNT_CTRL, ~CNT_SEL); | 449 | lv24020lp_write_and(CNT_CTRL, ~CNT_SEL); |
@@ -463,19 +471,20 @@ static int tuner_measure(unsigned char type, int scale, int duration) | |||
463 | else | 471 | else |
464 | finval = scale*finval / duration; | 472 | finval = scale*finval / duration; |
465 | 473 | ||
474 | /* This function takes a loooong time and other stuff needs | ||
475 | running by now */ | ||
476 | yield(); | ||
477 | |||
466 | return (int)finval; | 478 | return (int)finval; |
467 | } | 479 | } |
468 | 480 | ||
469 | /* set the FM oscillator frequency */ | 481 | /* set the FM oscillator frequency */ |
470 | static void set_frequency(int freq) | 482 | static bool set_frequency(int freq) |
471 | { | 483 | { |
472 | int coef, cap_value, osc_value; | 484 | int coef, cap_value, osc_value; |
473 | int f1, f2, x1, x2; | 485 | int f1, f2, x1, x2; |
474 | int count; | 486 | int count; |
475 | 487 | ||
476 | if (!tuner_awake()) | ||
477 | return; | ||
478 | |||
479 | TUNER_LOG_OPEN(); | 488 | TUNER_LOG_OPEN(); |
480 | 489 | ||
481 | TUNER_LOG("set_frequency(%d)\n", freq); | 490 | TUNER_LOG("set_frequency(%d)\n", freq); |
@@ -579,6 +588,8 @@ static void set_frequency(int freq) | |||
579 | TUNER_LOG("\n"); | 588 | TUNER_LOG("\n"); |
580 | 589 | ||
581 | TUNER_LOG_SYNC(); | 590 | TUNER_LOG_SYNC(); |
591 | |||
592 | return true; | ||
582 | } | 593 | } |
583 | 594 | ||
584 | static void fine_step_tune(int (*setcmp)(int regval), int regval, int step) | 595 | static void fine_step_tune(int (*setcmp)(int regval), int regval, int step) |
@@ -639,10 +650,10 @@ static int if_setcmp(int regval) | |||
639 | /* This register is bounces around by a few hundred Hz and doesn't seem | 650 | /* This register is bounces around by a few hundred Hz and doesn't seem |
640 | to be precisely tuneable. Just do 110000 +/- 500 since it's not very | 651 | to be precisely tuneable. Just do 110000 +/- 500 since it's not very |
641 | critical it seems. */ | 652 | critical it seems. */ |
642 | if (abs(if_set - 109500) <= 500) | 653 | if (abs(if_set - 110000) <= 500) |
643 | return 0; | 654 | return 0; |
644 | 655 | ||
645 | return if_set < 109500 ? -1 : 1; | 656 | return if_set < 110000 ? -1 : 1; |
646 | } | 657 | } |
647 | 658 | ||
648 | static int sd_setcmp(int regval) | 659 | static int sd_setcmp(int regval) |
@@ -666,8 +677,6 @@ static void set_sleep(bool sleep) | |||
666 | (TUNER_PRESENT | TUNER_POWERED)) | 677 | (TUNER_PRESENT | TUNER_POWERED)) |
667 | return; | 678 | return; |
668 | 679 | ||
669 | tuner_status |= TUNER_AWAKE; | ||
670 | |||
671 | enable_afc(false); | 680 | enable_afc(false); |
672 | 681 | ||
673 | /* 2. Calibrate the IF frequency at 110 kHz: */ | 682 | /* 2. Calibrate the IF frequency at 110 kHz: */ |
@@ -702,9 +711,79 @@ static void set_sleep(bool sleep) | |||
702 | lv24020lp_write(STEREO_CTRL, FMCS_SET(7) | AUTOSSR); | 711 | lv24020lp_write(STEREO_CTRL, FMCS_SET(7) | AUTOSSR); |
703 | lv24020lp_write(PW_SCTRL, SS_CTRL_SET(3) | SM_CTRL_SET(1) | | 712 | lv24020lp_write(PW_SCTRL, SS_CTRL_SET(3) | SM_CTRL_SET(1) | |
704 | PW_RAD); | 713 | PW_RAD); |
714 | |||
715 | tuner_status |= TUNER_AWAKE; | ||
716 | } | ||
717 | |||
718 | static int lp24020lp_tuned(void) | ||
719 | { | ||
720 | return RSS_FS(lv24020lp_read(RADIO_STAT)) < 0x1f; | ||
721 | } | ||
722 | |||
723 | static int lv24020lp_debug_info(int setting) | ||
724 | { | ||
725 | int val = -1; | ||
726 | |||
727 | if (setting >= LV24020LP_DEBUG_FIRST && setting <= LV24020LP_DEBUG_LAST) | ||
728 | { | ||
729 | val = 0; | ||
730 | |||
731 | if (tuner_awake()) | ||
732 | { | ||
733 | switch (setting) | ||
734 | { | ||
735 | /* tuner-specific debug info */ | ||
736 | case LV24020LP_CTRL_STAT: | ||
737 | val = lv24020lp_read(CTRL_STAT); | ||
738 | break; | ||
739 | |||
740 | case LV24020LP_REG_STAT: | ||
741 | val = lv24020lp_read(RADIO_STAT); | ||
742 | break; | ||
743 | |||
744 | case LV24020LP_MSS_FM: | ||
745 | val = tuner_measure(MSS_FM, 1, 16); | ||
746 | break; | ||
747 | |||
748 | case LV24020LP_MSS_IF: | ||
749 | val = tuner_measure(MSS_IF, 1000, 16); | ||
750 | break; | ||
751 | |||
752 | case LV24020LP_MSS_SD: | ||
753 | val = tuner_measure(MSS_SD, 1000, 16); | ||
754 | break; | ||
755 | |||
756 | case LV24020LP_IF_SET: | ||
757 | val = if_set; | ||
758 | break; | ||
759 | |||
760 | case LV24020LP_SD_SET: | ||
761 | val = sd_set; | ||
762 | break; | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | |||
767 | return val; | ||
705 | } | 768 | } |
706 | 769 | ||
707 | /** Public interfaces **/ | 770 | /** Public interfaces **/ |
771 | void lv24020lp_init(void) | ||
772 | { | ||
773 | mutex_init(&tuner_mtx); | ||
774 | } | ||
775 | |||
776 | void lv24020lp_lock(void) | ||
777 | { | ||
778 | mutex_lock(&tuner_mtx); | ||
779 | } | ||
780 | |||
781 | void lv24020lp_unlock(void) | ||
782 | { | ||
783 | mutex_unlock(&tuner_mtx); | ||
784 | } | ||
785 | |||
786 | /* This function expects the driver to be locked externally */ | ||
708 | void lv24020lp_power(bool status) | 787 | void lv24020lp_power(bool status) |
709 | { | 788 | { |
710 | static const unsigned char tuner_defaults[][2] = | 789 | static const unsigned char tuner_defaults[][2] = |
@@ -734,7 +813,7 @@ void lv24020lp_power(bool status) | |||
734 | 813 | ||
735 | if (status) | 814 | if (status) |
736 | { | 815 | { |
737 | tuner_status |= TUNER_POWERED | TUNER_PRESENCE_CHECKED; | 816 | tuner_status |= (TUNER_PRESENCE_CHECKED | TUNER_POWERED); |
738 | 817 | ||
739 | /* if tuner is present, CHIP ID is 0x09 */ | 818 | /* if tuner is present, CHIP ID is 0x09 */ |
740 | if (lv24020lp_read(CHIP_ID) == 0x09) | 819 | if (lv24020lp_read(CHIP_ID) == 0x09) |
@@ -750,16 +829,16 @@ void lv24020lp_power(bool status) | |||
750 | lv24020lp_write(tuner_defaults[i][0], tuner_defaults[i][1]); | 829 | lv24020lp_write(tuner_defaults[i][0], tuner_defaults[i][1]); |
751 | 830 | ||
752 | /* Complete the startup calibration if the tuner is woken */ | 831 | /* Complete the startup calibration if the tuner is woken */ |
753 | udelay(100000); | 832 | sleep(HZ/10); |
754 | } | 833 | } |
755 | } | 834 | } |
756 | else | 835 | else |
757 | { | 836 | { |
837 | tuner_status &= ~(TUNER_POWERED | TUNER_AWAKE); | ||
838 | |||
758 | /* Power off */ | 839 | /* Power off */ |
759 | if (tuner_status & TUNER_PRESENT) | 840 | if (tuner_status & TUNER_PRESENT) |
760 | lv24020lp_write_and(PW_SCTRL, ~PW_RAD); | 841 | lv24020lp_write_and(PW_SCTRL, ~PW_RAD); |
761 | |||
762 | tuner_status &= ~(TUNER_POWERED | TUNER_AWAKE); | ||
763 | } | 842 | } |
764 | } | 843 | } |
765 | 844 | ||
@@ -767,6 +846,8 @@ int lv24020lp_set(int setting, int value) | |||
767 | { | 846 | { |
768 | int val = 1; | 847 | int val = 1; |
769 | 848 | ||
849 | mutex_lock(&tuner_mtx); | ||
850 | |||
770 | switch(setting) | 851 | switch(setting) |
771 | { | 852 | { |
772 | case RADIO_SLEEP: | 853 | case RADIO_SLEEP: |
@@ -780,7 +861,7 @@ int lv24020lp_set(int setting, int value) | |||
780 | case RADIO_SCAN_FREQUENCY: | 861 | case RADIO_SCAN_FREQUENCY: |
781 | /* TODO: really implement this */ | 862 | /* TODO: really implement this */ |
782 | set_frequency(value); | 863 | set_frequency(value); |
783 | val = lv24020lp_get(RADIO_TUNED); | 864 | val = lp24020lp_tuned(); |
784 | break; | 865 | break; |
785 | 866 | ||
786 | case RADIO_MUTE: | 867 | case RADIO_MUTE: |
@@ -791,13 +872,11 @@ int lv24020lp_set(int setting, int value) | |||
791 | break; | 872 | break; |
792 | 873 | ||
793 | case RADIO_REGION: | 874 | case RADIO_REGION: |
794 | { | ||
795 | if (lv24020lp_region_data[value]) | 875 | if (lv24020lp_region_data[value]) |
796 | lv24020lp_write_or(AUDIO_CTRL2, DEEMP); | 876 | lv24020lp_write_or(AUDIO_CTRL2, DEEMP); |
797 | else | 877 | else |
798 | lv24020lp_write_and(AUDIO_CTRL2, ~DEEMP); | 878 | lv24020lp_write_and(AUDIO_CTRL2, ~DEEMP); |
799 | break; | 879 | break; |
800 | } | ||
801 | 880 | ||
802 | case RADIO_FORCE_MONO: | 881 | case RADIO_FORCE_MONO: |
803 | if (value) | 882 | if (value) |
@@ -807,9 +886,11 @@ int lv24020lp_set(int setting, int value) | |||
807 | break; | 886 | break; |
808 | 887 | ||
809 | default: | 888 | default: |
810 | val = -1; | 889 | value = -1; |
811 | } | 890 | } |
812 | 891 | ||
892 | mutex_unlock(&tuner_mtx); | ||
893 | |||
813 | return val; | 894 | return val; |
814 | } | 895 | } |
815 | 896 | ||
@@ -817,11 +898,13 @@ int lv24020lp_get(int setting) | |||
817 | { | 898 | { |
818 | int val = -1; | 899 | int val = -1; |
819 | 900 | ||
901 | mutex_lock(&tuner_mtx); | ||
902 | |||
820 | switch(setting) | 903 | switch(setting) |
821 | { | 904 | { |
822 | case RADIO_TUNED: | 905 | case RADIO_TUNED: |
823 | /* TODO: really implement this */ | 906 | /* TODO: really implement this */ |
824 | val = RSS_FS(lv24020lp_read(RADIO_STAT)) < 0x1f; | 907 | val = lp24020lp_tuned(); |
825 | break; | 908 | break; |
826 | 909 | ||
827 | case RADIO_STEREO: | 910 | case RADIO_STEREO: |
@@ -833,38 +916,21 @@ int lv24020lp_get(int setting) | |||
833 | bool fmstatus = true; | 916 | bool fmstatus = true; |
834 | 917 | ||
835 | if (!(tuner_status & TUNER_PRESENCE_CHECKED)) | 918 | if (!(tuner_status & TUNER_PRESENCE_CHECKED)) |
836 | fmstatus = tuner_power(true); | 919 | fmstatus = tuner_power_nolock(true); |
837 | 920 | ||
838 | val = (tuner_status & TUNER_PRESENT) != 0; | 921 | val = (tuner_status & TUNER_PRESENT) != 0; |
839 | 922 | ||
840 | if (!fmstatus) | 923 | if (!fmstatus) |
841 | tuner_power(false); | 924 | tuner_power_nolock(false); |
842 | break; | 925 | break; |
843 | } | 926 | } |
844 | 927 | ||
845 | /* tuner-specific debug info */ | 928 | default: |
846 | case LV24020LP_CTRL_STAT: | 929 | val = lv24020lp_debug_info(setting); |
847 | return lv24020lp_read(CTRL_STAT); | ||
848 | |||
849 | case LV24020LP_REG_STAT: | ||
850 | return lv24020lp_read(RADIO_STAT); | ||
851 | |||
852 | case LV24020LP_MSS_FM: | ||
853 | return tuner_measure(MSS_FM, 1, 16); | ||
854 | |||
855 | case LV24020LP_MSS_IF: | ||
856 | return tuner_measure(MSS_IF, 1000, 16); | ||
857 | |||
858 | case LV24020LP_MSS_SD: | ||
859 | return tuner_measure(MSS_SD, 1000, 16); | ||
860 | |||
861 | case LV24020LP_IF_SET: | ||
862 | return if_set; | ||
863 | |||
864 | case LV24020LP_SD_SET: | ||
865 | return sd_set; | ||
866 | } | 930 | } |
867 | 931 | ||
932 | mutex_unlock(&tuner_mtx); | ||
933 | |||
868 | return val; | 934 | return val; |
869 | } | 935 | } |
870 | #endif /* BOOTLOADER */ | 936 | #endif /* BOOTLOADER */ |
diff --git a/firmware/export/lv24020lp.h b/firmware/export/lv24020lp.h index 0fc39b18df..7d24435353 100644 --- a/firmware/export/lv24020lp.h +++ b/firmware/export/lv24020lp.h | |||
@@ -32,16 +32,17 @@ | |||
32 | #define LV24020LP_IF_SET (RADIO_GET_CHIP_FIRST+5) | 32 | #define LV24020LP_IF_SET (RADIO_GET_CHIP_FIRST+5) |
33 | #define LV24020LP_SD_SET (RADIO_GET_CHIP_FIRST+6) | 33 | #define LV24020LP_SD_SET (RADIO_GET_CHIP_FIRST+6) |
34 | 34 | ||
35 | struct lv24020lp_region_data | 35 | #define LV24020LP_DEBUG_FIRST LV24020LP_CTRL_STAT |
36 | { | 36 | #define LV24020LP_DEBUG_LAST LV24020LP_SD_SET |
37 | unsigned char deemphasis; | ||
38 | } __attribute__((packed)); | ||
39 | 37 | ||
40 | const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS]; | 38 | const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS]; |
41 | 39 | ||
42 | int lv24020lp_set(int setting, int value); | 40 | int lv24020lp_set(int setting, int value); |
43 | int lv24020lp_get(int setting); | 41 | int lv24020lp_get(int setting); |
44 | void lv24020lp_power(bool status); | 42 | void lv24020lp_power(bool status); |
43 | void lv24020lp_init(void); | ||
44 | void lv24020lp_lock(void); | ||
45 | void lv24020lp_unlock(void); | ||
45 | 46 | ||
46 | #ifndef CONFIG_TUNER_MULTI | 47 | #ifndef CONFIG_TUNER_MULTI |
47 | #define tuner_set lv24020lp_set | 48 | #define tuner_set lv24020lp_set |
diff --git a/firmware/export/power.h b/firmware/export/power.h index 8ecff6c51e..fbc3ded3c1 100644 --- a/firmware/export/power.h +++ b/firmware/export/power.h | |||
@@ -49,6 +49,7 @@ bool spdif_powered(void); | |||
49 | 49 | ||
50 | #if CONFIG_TUNER | 50 | #if CONFIG_TUNER |
51 | extern bool tuner_power(bool status); | 51 | extern bool tuner_power(bool status); |
52 | extern bool tuner_power_nolock(bool status); | ||
52 | extern bool tuner_powered(void); | 53 | extern bool tuner_powered(void); |
53 | #endif | 54 | #endif |
54 | 55 | ||
diff --git a/firmware/target/arm/sandisk/sansa-e200/power-e200.c b/firmware/target/arm/sandisk/sansa-e200/power-e200.c index 002dcb8407..2745f0ba50 100644 --- a/firmware/target/arm/sandisk/sansa-e200/power-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/power-e200.c | |||
@@ -66,9 +66,11 @@ void ide_power_enable(bool on) | |||
66 | /** Tuner **/ | 66 | /** Tuner **/ |
67 | static bool powered = false; | 67 | static bool powered = false; |
68 | 68 | ||
69 | bool tuner_power(bool status) | 69 | bool tuner_power_nolock(bool status) |
70 | { | 70 | { |
71 | bool old_status = powered; | 71 | bool old_status; |
72 | |||
73 | old_status = powered; | ||
72 | 74 | ||
73 | if (status != old_status) | 75 | if (status != old_status) |
74 | { | 76 | { |
@@ -115,6 +117,15 @@ bool tuner_power(bool status) | |||
115 | return old_status; | 117 | return old_status; |
116 | } | 118 | } |
117 | 119 | ||
120 | bool tuner_power(bool status) | ||
121 | { | ||
122 | bool old_status; | ||
123 | lv24020lp_lock(); | ||
124 | old_status = tuner_power_nolock(status); | ||
125 | lv24020lp_unlock(); | ||
126 | return old_status; | ||
127 | } | ||
128 | |||
118 | bool tuner_powered(void) | 129 | bool tuner_powered(void) |
119 | { | 130 | { |
120 | return powered; | 131 | return powered; |
diff --git a/firmware/tuner.c b/firmware/tuner.c index 1ee42a5355..4f3ddc0c73 100644 --- a/firmware/tuner.c +++ b/firmware/tuner.c | |||
@@ -60,13 +60,15 @@ const struct tea5767_region_data tea5767_region_data[TUNER_NUM_REGIONS] = | |||
60 | #ifdef CONFIG_TUNER_MULTI | 60 | #ifdef CONFIG_TUNER_MULTI |
61 | int (*tuner_set)(int setting, int value); | 61 | int (*tuner_set)(int setting, int value); |
62 | int (*tuner_get)(int setting); | 62 | int (*tuner_get)(int setting); |
63 | #define TUNER_TYPE_CASE(type, set, get, region_data) \ | 63 | #define TUNER_TYPE_CASE(type, set, get, ...) \ |
64 | case type: \ | 64 | case type: \ |
65 | tuner_set = set; \ | 65 | tuner_set = set; \ |
66 | tuner_get = get; \ | 66 | tuner_get = get; \ |
67 | __VA_ARGS__; \ | ||
67 | break; | 68 | break; |
68 | #else | 69 | #else |
69 | #define TUNER_TYPE_CASE(type, set, get, region_data) | 70 | #define TUNER_TYPE_CASE(type, set, get, ...) \ |
71 | __VA_ARGS__; | ||
70 | #endif /* CONFIG_TUNER_MULTI */ | 72 | #endif /* CONFIG_TUNER_MULTI */ |
71 | 73 | ||
72 | void tuner_init(void) | 74 | void tuner_init(void) |
@@ -79,19 +81,17 @@ void tuner_init(void) | |||
79 | TUNER_TYPE_CASE(LV24020LP, | 81 | TUNER_TYPE_CASE(LV24020LP, |
80 | lv24020lp_set, | 82 | lv24020lp_set, |
81 | lv24020lp_get, | 83 | lv24020lp_get, |
82 | lv24020lp_region_data) | 84 | lv24020lp_init()) |
83 | #endif | 85 | #endif |
84 | #if (CONFIG_TUNER & TEA5767) | 86 | #if (CONFIG_TUNER & TEA5767) |
85 | TUNER_TYPE_CASE(TEA5767, | 87 | TUNER_TYPE_CASE(TEA5767, |
86 | tea5767_set, | 88 | tea5767_set, |
87 | tea5767_get, | 89 | tea5767_get) |
88 | tea5767_region_data) | ||
89 | #endif | 90 | #endif |
90 | #if (CONFIG_TUNER & S1A0903X01) | 91 | #if (CONFIG_TUNER & S1A0903X01) |
91 | TUNER_TYPE_CASE(S1A0903X01, | 92 | TUNER_TYPE_CASE(S1A0903X01, |
92 | s1a0903x01_set, | 93 | s1a0903x01_set, |
93 | s1a0903x01_get, | 94 | s1a0903x01_get) |
94 | NULL) | ||
95 | #endif | 95 | #endif |
96 | } | 96 | } |
97 | } | 97 | } |