summaryrefslogtreecommitdiff
path: root/firmware/drivers/tuner/si4700.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-02-05 15:58:10 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-02-25 15:59:08 +0100
commit906e90eb7b036214b2ee48ad2219e1ef679ee7d1 (patch)
tree79d581f2d79a4a6ca4ad63824d0c3082c6c4d453 /firmware/drivers/tuner/si4700.c
parent58b226edc51f260a19cf0655bbec67622ebe7cef (diff)
downloadrockbox-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/drivers/tuner/si4700.c')
-rw-r--r--firmware/drivers/tuner/si4700.c42
1 files changed, 21 insertions, 21 deletions
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
355void si4700_init(void) 366void 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 {