diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-02-05 15:58:10 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-02-25 15:59:08 +0100 |
commit | 906e90eb7b036214b2ee48ad2219e1ef679ee7d1 (patch) | |
tree | 79d581f2d79a4a6ca4ad63824d0c3082c6c4d453 /firmware | |
parent | 58b226edc51f260a19cf0655bbec67622ebe7cef (diff) | |
download | rockbox-906e90eb7b036214b2ee48ad2219e1ef679ee7d1.tar.gz rockbox-906e90eb7b036214b2ee48ad2219e1ef679ee7d1.zip |
Move radio power handling from apps/ to drivers.
Remove direct calls to tuner_power(...) in apps/ and let
the driver manage tuner power with the RADIO_SLEEP setting.
Change-Id: I37cd0472e60db5d666dae1b9fe4755dd65c03edd
Reviewed-on: http://gerrit.rockbox.org/84
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/tuner/ipod_remote_tuner.c | 13 | ||||
-rw-r--r-- | firmware/drivers/tuner/lv24020lp.c | 3 | ||||
-rw-r--r-- | firmware/drivers/tuner/rda5802.c | 3 | ||||
-rw-r--r-- | firmware/drivers/tuner/s1a0903x01.c | 6 | ||||
-rw-r--r-- | firmware/drivers/tuner/si4700.c | 42 | ||||
-rw-r--r-- | firmware/drivers/tuner/tea5760uk.c | 2 | ||||
-rw-r--r-- | firmware/drivers/tuner/tea5767.c | 4 |
7 files changed, 39 insertions, 34 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c index ad84cb9890..8b599cb79c 100644 --- a/firmware/drivers/tuner/ipod_remote_tuner.c +++ b/firmware/drivers/tuner/ipod_remote_tuner.c | |||
@@ -31,8 +31,6 @@ | |||
31 | #include "settings.h" | 31 | #include "settings.h" |
32 | #include "power.h" | 32 | #include "power.h" |
33 | 33 | ||
34 | static bool powered = false; | ||
35 | |||
36 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; | 34 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; |
37 | /* temp var for tests to avoid looping execution in submenus settings*/ | 35 | /* temp var for tests to avoid looping execution in submenus settings*/ |
38 | static int mono_mode = -1, old_region = -1; | 36 | static int mono_mode = -1, old_region = -1; |
@@ -150,7 +148,6 @@ static void rmt_tuner_scan(int param) | |||
150 | iap_send_pkt(data1, sizeof(data1)); | 148 | iap_send_pkt(data1, sizeof(data1)); |
151 | } | 149 | } |
152 | 150 | ||
153 | #if 0 /* function is not used */ | ||
154 | static void rmt_tuner_mute(int value) | 151 | static void rmt_tuner_mute(int value) |
155 | { | 152 | { |
156 | /* mute flag off (play) */ | 153 | /* mute flag off (play) */ |
@@ -162,7 +159,6 @@ static void rmt_tuner_mute(int value) | |||
162 | } | 159 | } |
163 | iap_send_pkt(data, sizeof(data)); | 160 | iap_send_pkt(data, sizeof(data)); |
164 | } | 161 | } |
165 | #endif | ||
166 | 162 | ||
167 | static void rmt_tuner_region(int region) | 163 | static void rmt_tuner_region(int region) |
168 | { | 164 | { |
@@ -362,7 +358,7 @@ int ipod_rmt_tuner_set(int setting, int value) | |||
362 | case RADIO_MUTE: | 358 | case RADIO_MUTE: |
363 | { | 359 | { |
364 | /* mute flag sent to accessory */ | 360 | /* mute flag sent to accessory */ |
365 | /* rmt_tuner_mute(value); */ | 361 | rmt_tuner_mute(value); |
366 | break; | 362 | break; |
367 | } | 363 | } |
368 | 364 | ||
@@ -453,10 +449,3 @@ char* ipod_get_rds_info(int setting) | |||
453 | } | 449 | } |
454 | return text; | 450 | return text; |
455 | } | 451 | } |
456 | |||
457 | bool tuner_power(bool status) | ||
458 | { | ||
459 | bool oldstatus = powered; | ||
460 | powered = status; | ||
461 | return oldstatus; | ||
462 | } | ||
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c index 590ca9641e..34fa0df9e2 100644 --- a/firmware/drivers/tuner/lv24020lp.c +++ b/firmware/drivers/tuner/lv24020lp.c | |||
@@ -740,6 +740,8 @@ static int sd_setcmp(int regval) | |||
740 | 740 | ||
741 | static void set_sleep(bool sleep) | 741 | static void set_sleep(bool sleep) |
742 | { | 742 | { |
743 | if (sleep) | ||
744 | tuner_power(false); | ||
743 | if (sleep || tuner_awake()) | 745 | if (sleep || tuner_awake()) |
744 | return; | 746 | return; |
745 | 747 | ||
@@ -747,6 +749,7 @@ static void set_sleep(bool sleep) | |||
747 | (TUNER_PRESENT | TUNER_POWERED)) | 749 | (TUNER_PRESENT | TUNER_POWERED)) |
748 | return; | 750 | return; |
749 | 751 | ||
752 | tuner_power(true); | ||
750 | enable_afc(false); | 753 | enable_afc(false); |
751 | 754 | ||
752 | /* 2. Calibrate the IF frequency at 110 kHz: */ | 755 | /* 2. Calibrate the IF frequency at 110 kHz: */ |
diff --git a/firmware/drivers/tuner/rda5802.c b/firmware/drivers/tuner/rda5802.c index c07adc1f07..a6c73a5e21 100644 --- a/firmware/drivers/tuner/rda5802.c +++ b/firmware/drivers/tuner/rda5802.c | |||
@@ -177,9 +177,12 @@ static void rda5802_sleep(int snooze) | |||
177 | rda5802_write_clear(POWERCFG, POWERCFG_ENABLE); | 177 | rda5802_write_clear(POWERCFG, POWERCFG_ENABLE); |
178 | } | 178 | } |
179 | else { | 179 | else { |
180 | tuner_power(true); | ||
180 | rda5802_write_set(POWERCFG, POWERCFG_ENABLE); | 181 | rda5802_write_set(POWERCFG, POWERCFG_ENABLE); |
181 | } | 182 | } |
182 | rda5802_write_cache(); | 183 | rda5802_write_cache(); |
184 | if(snooze) | ||
185 | tuner_power(false); | ||
183 | } | 186 | } |
184 | 187 | ||
185 | bool rda5802_detect(void) | 188 | bool rda5802_detect(void) |
diff --git a/firmware/drivers/tuner/s1a0903x01.c b/firmware/drivers/tuner/s1a0903x01.c index 2c93ebdaad..91d1319fb5 100644 --- a/firmware/drivers/tuner/s1a0903x01.c +++ b/firmware/drivers/tuner/s1a0903x01.c | |||
@@ -47,12 +47,16 @@ int s1a0903x01_set(int setting, int value) | |||
47 | { | 47 | { |
48 | case RADIO_SLEEP: | 48 | case RADIO_SLEEP: |
49 | if (!value) | 49 | if (!value) |
50 | { /* wakeup: just unit */ | 50 | { |
51 | tuner_power(true); | ||
52 | /* wakeup: just unit */ | ||
51 | fm_in1 = DEFAULT_IN1; | 53 | fm_in1 = DEFAULT_IN1; |
52 | fm_in2 = DEFAULT_IN2; | 54 | fm_in2 = DEFAULT_IN2; |
53 | fmradio_set(1, fm_in1); | 55 | fmradio_set(1, fm_in1); |
54 | fmradio_set(2, fm_in2); | 56 | fmradio_set(2, fm_in2); |
55 | } | 57 | } |
58 | else | ||
59 | tuner_power(false); | ||
56 | /* else we have no sleep mode? */ | 60 | /* else we have no sleep mode? */ |
57 | break; | 61 | break; |
58 | 62 | ||
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c index 6966891a38..a5b004aef4 100644 --- a/firmware/drivers/tuner/si4700.c +++ b/firmware/drivers/tuner/si4700.c | |||
@@ -304,9 +304,20 @@ static void si4700_sleep(int snooze) | |||
304 | POWERCFG_DISABLE | POWERCFG_ENABLE); | 304 | POWERCFG_DISABLE | POWERCFG_ENABLE); |
305 | /* Bits self-clear once placed in powerdown. */ | 305 | /* Bits self-clear once placed in powerdown. */ |
306 | cache[POWERCFG] &= ~(POWERCFG_DISABLE | POWERCFG_ENABLE); | 306 | cache[POWERCFG] &= ~(POWERCFG_DISABLE | POWERCFG_ENABLE); |
307 | |||
308 | tuner_power(false); | ||
307 | } | 309 | } |
308 | else | 310 | else |
309 | { | 311 | { |
312 | tuner_power(true); | ||
313 | /* read all registers */ | ||
314 | si4700_read(16); | ||
315 | #ifdef SI4700_USE_INTERNAL_OSCILLATOR | ||
316 | /* Enable the internal oscillator | ||
317 | (Si4702-16 needs this register to be initialised to 0x100) */ | ||
318 | si4700_write_set(TEST1, TEST1_XOSCEN | 0x100); | ||
319 | sleep(HZ/2); | ||
320 | #endif | ||
310 | /** power up **/ | 321 | /** power up **/ |
311 | /* ENABLE high, DISABLE low */ | 322 | /* ENABLE high, DISABLE low */ |
312 | si4700_write_masked(POWERCFG, POWERCFG_ENABLE, | 323 | si4700_write_masked(POWERCFG, POWERCFG_ENABLE, |
@@ -354,26 +365,9 @@ bool si4700_detect(void) | |||
354 | 365 | ||
355 | void si4700_init(void) | 366 | void si4700_init(void) |
356 | { | 367 | { |
368 | mutex_init(&fmr_mutex); | ||
357 | /* check device id */ | 369 | /* check device id */ |
358 | if (si4700_detect()) { | 370 | if (si4700_detect()) { |
359 | mutex_init(&fmr_mutex); | ||
360 | |||
361 | tuner_power(true); | ||
362 | |||
363 | /* read all registers */ | ||
364 | si4700_read(16); | ||
365 | si4700_sleep(0); | ||
366 | |||
367 | #ifdef SI4700_USE_INTERNAL_OSCILLATOR | ||
368 | /* Enable the internal oscillator | ||
369 | (Si4702-16 needs this register to be initialised to 0x100) */ | ||
370 | si4700_write_set(TEST1, TEST1_XOSCEN | 0x100); | ||
371 | sleep(HZ/2); | ||
372 | #endif | ||
373 | |||
374 | si4700_sleep(1); | ||
375 | tuner_power(false); | ||
376 | |||
377 | #ifdef HAVE_RDS_CAP | 371 | #ifdef HAVE_RDS_CAP |
378 | si4700_rds_init(); | 372 | si4700_rds_init(); |
379 | #endif | 373 | #endif |
@@ -445,6 +439,9 @@ int si4700_set(int setting, int value) | |||
445 | { | 439 | { |
446 | int val = 1; | 440 | int val = 1; |
447 | 441 | ||
442 | if(!tuner_powered() && setting != RADIO_SLEEP) | ||
443 | return -1; | ||
444 | |||
448 | mutex_lock(&fmr_mutex); | 445 | mutex_lock(&fmr_mutex); |
449 | 446 | ||
450 | switch(setting) | 447 | switch(setting) |
@@ -483,7 +480,7 @@ int si4700_set(int setting, int value) | |||
483 | si4700_write_masked(POWERCFG, value ? POWERCFG_MONO : 0, | 480 | si4700_write_masked(POWERCFG, value ? POWERCFG_MONO : 0, |
484 | POWERCFG_MONO); | 481 | POWERCFG_MONO); |
485 | break; | 482 | break; |
486 | 483 | ||
487 | default: | 484 | default: |
488 | val = -1; | 485 | val = -1; |
489 | break; | 486 | break; |
@@ -499,12 +496,15 @@ int si4700_get(int setting) | |||
499 | { | 496 | { |
500 | int val = -1; /* default for unsupported query */ | 497 | int val = -1; /* default for unsupported query */ |
501 | 498 | ||
499 | if(!tuner_powered() && setting != RADIO_PRESENT) | ||
500 | return -1; | ||
501 | |||
502 | mutex_lock(&fmr_mutex); | 502 | mutex_lock(&fmr_mutex); |
503 | 503 | ||
504 | switch(setting) | 504 | switch(setting) |
505 | { | 505 | { |
506 | case RADIO_PRESENT: | 506 | case RADIO_PRESENT: |
507 | val = tuner_present ? 1 : 0; | 507 | val = tuner_present; |
508 | break; | 508 | break; |
509 | 509 | ||
510 | case RADIO_TUNED: | 510 | case RADIO_TUNED: |
@@ -526,7 +526,7 @@ int si4700_get(int setting) | |||
526 | case RADIO_RSSI_MAX: | 526 | case RADIO_RSSI_MAX: |
527 | val = RSSI_MAX; | 527 | val = RSSI_MAX; |
528 | break; | 528 | break; |
529 | 529 | ||
530 | #ifdef HAVE_RDS_CAP | 530 | #ifdef HAVE_RDS_CAP |
531 | case RADIO_EVENT: | 531 | case RADIO_EVENT: |
532 | { | 532 | { |
diff --git a/firmware/drivers/tuner/tea5760uk.c b/firmware/drivers/tuner/tea5760uk.c index c1dff598b3..0e2e208693 100644 --- a/firmware/drivers/tuner/tea5760uk.c +++ b/firmware/drivers/tuner/tea5760uk.c | |||
@@ -61,8 +61,10 @@ int tea5760_set(int setting, int value) | |||
61 | if (value) { | 61 | if (value) { |
62 | /* sleep / standby mode */ | 62 | /* sleep / standby mode */ |
63 | tea5760_set_clear(3, (1<<6), 0); | 63 | tea5760_set_clear(3, (1<<6), 0); |
64 | tuner_power(false); | ||
64 | } | 65 | } |
65 | else { | 66 | else { |
67 | tuner_power(true); | ||
66 | /* active mode */ | 68 | /* active mode */ |
67 | tea5760_set_clear(3, (1<<6), 1); | 69 | tea5760_set_clear(3, (1<<6), 1); |
68 | /* disable hard mute */ | 70 | /* disable hard mute */ |
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c index 3f3af68602..da12a9bb05 100644 --- a/firmware/drivers/tuner/tea5767.c +++ b/firmware/drivers/tuner/tea5767.c | |||
@@ -106,7 +106,11 @@ int tea5767_set(int setting, int value) | |||
106 | return -1; | 106 | return -1; |
107 | } | 107 | } |
108 | 108 | ||
109 | if(setting == RADIO_SLEEP && !value) | ||
110 | tuner_power(true); /* wakeup */ | ||
109 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | 111 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); |
112 | if(setting == RADIO_SLEEP && value) | ||
113 | tuner_power(false); /* sleep */ | ||
110 | return 1; | 114 | return 1; |
111 | } | 115 | } |
112 | 116 | ||