diff options
Diffstat (limited to 'firmware/drivers/tuner')
-rw-r--r-- | firmware/drivers/tuner/ipod_remote_tuner.c | 33 | ||||
-rw-r--r-- | firmware/drivers/tuner/si4700.c | 87 |
2 files changed, 23 insertions, 97 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c index 8b599cb79c..e283ddfb68 100644 --- a/firmware/drivers/tuner/ipod_remote_tuner.c +++ b/firmware/drivers/tuner/ipod_remote_tuner.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "adc.h" | 30 | #include "adc.h" |
31 | #include "settings.h" | 31 | #include "settings.h" |
32 | #include "power.h" | 32 | #include "power.h" |
33 | #include "rds.h" | ||
33 | 34 | ||
34 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; | 35 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; |
35 | /* temp var for tests to avoid looping execution in submenus settings*/ | 36 | /* temp var for tests to avoid looping execution in submenus settings*/ |
@@ -40,7 +41,6 @@ int radio_present = 0; | |||
40 | static int tuner_frequency = 0; | 41 | static int tuner_frequency = 0; |
41 | static int tuner_signal_power = 0; | 42 | static int tuner_signal_power = 0; |
42 | static bool radio_tuned = false; | 43 | static bool radio_tuned = false; |
43 | static bool rds_event = false; | ||
44 | 44 | ||
45 | static char rds_radioname[9]; | 45 | static char rds_radioname[9]; |
46 | static char rds_radioinfo[65]; | 46 | static char rds_radioinfo[65]; |
@@ -90,6 +90,7 @@ static void rmt_tuner_sleep(int state) | |||
90 | { | 90 | { |
91 | if (state == 0) | 91 | if (state == 0) |
92 | { | 92 | { |
93 | rds_init(); | ||
93 | tuner_param = 0x00; | 94 | tuner_param = 0x00; |
94 | old_tuner_param = 0xFF; | 95 | old_tuner_param = 0xFF; |
95 | mono_mode = -1; | 96 | mono_mode = -1; |
@@ -273,13 +274,12 @@ void rmt_tuner_rds_data(unsigned int len, const unsigned char *buf) | |||
273 | { | 274 | { |
274 | if (buf[2] == 0x1E) | 275 | if (buf[2] == 0x1E) |
275 | { | 276 | { |
276 | strlcpy(rds_radioname,buf+4,8); | 277 | rds_push_info(RDS_INFO_PS, (uintptr_t)(buf+4), 8); |
277 | } | 278 | } |
278 | else if(buf[2] == 0x04) | 279 | else if(buf[2] == 0x04) |
279 | { | 280 | { |
280 | strlcpy(rds_radioinfo,buf+4,len-4); | 281 | rds_push_info(RDS_INFO_RT, (uintptr_t)(buf+4), len-4); |
281 | } | 282 | } |
282 | rds_event = true; | ||
283 | } | 283 | } |
284 | 284 | ||
285 | /* tuner abstraction layer: set something to the tuner */ | 285 | /* tuner abstraction layer: set something to the tuner */ |
@@ -421,31 +421,6 @@ int ipod_rmt_tuner_get(int setting) | |||
421 | case RADIO_STEREO: | 421 | case RADIO_STEREO: |
422 | val = true; | 422 | val = true; |
423 | break; | 423 | break; |
424 | |||
425 | case RADIO_EVENT: | ||
426 | if (rds_event) | ||
427 | { | ||
428 | val = 1; | ||
429 | rds_event = false; | ||
430 | } | ||
431 | break; | ||
432 | } | 424 | } |
433 | return val; | 425 | return val; |
434 | } | 426 | } |
435 | |||
436 | char* ipod_get_rds_info(int setting) | ||
437 | { | ||
438 | char *text = NULL; | ||
439 | |||
440 | switch(setting) | ||
441 | { | ||
442 | case RADIO_RDS_NAME: | ||
443 | text = rds_radioname; | ||
444 | break; | ||
445 | |||
446 | case RADIO_RDS_TEXT: | ||
447 | text = rds_radioinfo; | ||
448 | break; | ||
449 | } | ||
450 | return text; | ||
451 | } | ||
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c index 90d8df27dc..c7d942f293 100644 --- a/firmware/drivers/tuner/si4700.c +++ b/firmware/drivers/tuner/si4700.c | |||
@@ -213,9 +213,6 @@ | |||
213 | static bool tuner_present = false; | 213 | static bool tuner_present = false; |
214 | static uint16_t cache[16]; | 214 | static uint16_t cache[16]; |
215 | static struct mutex fmr_mutex SHAREDBSS_ATTR; | 215 | static struct mutex fmr_mutex SHAREDBSS_ATTR; |
216 | #ifdef HAVE_RDS_CAP | ||
217 | static int rds_event = 0; | ||
218 | #endif | ||
219 | 216 | ||
220 | /* reads <len> registers from radio at offset 0x0A into cache */ | 217 | /* reads <len> registers from radio at offset 0x0A into cache */ |
221 | static void si4700_read(int len) | 218 | static void si4700_read(int len) |
@@ -373,6 +370,7 @@ void si4700_init(void) | |||
373 | si4700_sleep(1); | 370 | si4700_sleep(1); |
374 | 371 | ||
375 | #ifdef HAVE_RDS_CAP | 372 | #ifdef HAVE_RDS_CAP |
373 | rds_init(); | ||
376 | si4700_rds_init(); | 374 | si4700_rds_init(); |
377 | #endif | 375 | #endif |
378 | } | 376 | } |
@@ -528,21 +526,6 @@ int si4700_get(int setting) | |||
528 | case RADIO_RSSI_MAX: | 526 | case RADIO_RSSI_MAX: |
529 | val = RSSI_MAX; | 527 | val = RSSI_MAX; |
530 | break; | 528 | break; |
531 | |||
532 | #ifdef HAVE_RDS_CAP | ||
533 | case RADIO_EVENT: | ||
534 | { | ||
535 | #ifdef RDS_ISR_PROCESSING | ||
536 | int oldlevel = disable_irq_save(); | ||
537 | #endif | ||
538 | val = rds_event; | ||
539 | rds_event = 0; | ||
540 | #ifdef RDS_ISR_PROCESSING | ||
541 | restore_irq(oldlevel); | ||
542 | #endif | ||
543 | break; | ||
544 | } | ||
545 | #endif | ||
546 | } | 529 | } |
547 | 530 | ||
548 | mutex_unlock(&fmr_mutex); | 531 | mutex_unlock(&fmr_mutex); |
@@ -567,77 +550,45 @@ void si4700_dbg_info(struct si4700_dbg_info *nfo) | |||
567 | 550 | ||
568 | #ifdef HAVE_RDS_CAP | 551 | #ifdef HAVE_RDS_CAP |
569 | 552 | ||
570 | #ifdef RDS_ISR_PROCESSING | 553 | #if (CONFIG_RDS & RDS_CFG_ISR) |
571 | /* Read raw RDS info for processing - in ISR */ | 554 | static unsigned char isr_regbuf[(RDSD - STATUSRSSI + 1) * 2]; |
572 | 555 | ||
573 | /* Assumes regbuf is 32 bytes */ | 556 | /* Called by RDS interrupt on target */ |
574 | void si4700_rds_read_raw_async(void) | 557 | void si4700_rds_interrupt(void) |
575 | { | 558 | { |
576 | si4700_read_raw_async((RDSD - STATUSRSSI + 1) * 2); | 559 | si4700_rds_read_raw_async(isr_regbuf, sizeof (isr_regbuf)); |
577 | } | 560 | } |
578 | 561 | ||
579 | void si4700_rds_read_raw_async_complete(unsigned char *regbuf, | 562 | /* Handle RDS event from ISR */ |
580 | uint16_t data[4]) | 563 | void si4700_rds_process(void) |
581 | { | 564 | { |
582 | const int index = (RDSA - STATUSRSSI) * 2; | 565 | uint16_t rds_data[4]; |
566 | int index = (RDSA - STATUSRSSI) * 2; | ||
583 | 567 | ||
584 | for (int i = 0; i < 4; i++) { | 568 | for (int i = 0; i < 4; i++) { |
585 | data[i] = regbuf[index] << 8 | regbuf[index + 1]; | 569 | rds_data[i] = isr_regbuf[index] << 8 | isr_regbuf[index + 1]; |
586 | regbuf += 2; | 570 | index += 2; |
587 | } | 571 | } |
588 | } | ||
589 | 572 | ||
590 | /* Set the event flag */ | 573 | rds_process(rds_data); |
591 | void si4700_rds_set_event(void) | ||
592 | { | ||
593 | rds_event = 1; | ||
594 | } | 574 | } |
595 | 575 | ||
596 | #else /* ndef RDS_ISR_PROCESSING */ | 576 | #else /* !(CONFIG_RDS & RDS_CFG_ISR) */ |
597 | /* Read raw RDS info for processing */ | ||
598 | bool si4700_rds_read_raw(uint16_t data[4]) | ||
599 | { | ||
600 | bool retval = false; | ||
601 | 577 | ||
578 | /* Handle RDS event from thread */ | ||
579 | void si4700_rds_process(void) | ||
580 | { | ||
602 | mutex_lock(&fmr_mutex); | 581 | mutex_lock(&fmr_mutex); |
603 | 582 | ||
604 | if (tuner_powered()) | 583 | if (tuner_powered()) |
605 | { | 584 | { |
606 | si4700_read_reg(RDSD); | 585 | si4700_read_reg(RDSD); |
607 | memcpy(data, &cache[RDSA], 4 * sizeof (uint16_t)); | 586 | rds_process(&cache[RDSA]); |
608 | retval = true; | ||
609 | } | 587 | } |
610 | 588 | ||
611 | mutex_unlock(&fmr_mutex); | 589 | mutex_unlock(&fmr_mutex); |
612 | |||
613 | return retval; | ||
614 | } | ||
615 | |||
616 | /* Set the event flag */ | ||
617 | void si4700_rds_set_event(void) | ||
618 | { | ||
619 | mutex_lock(&fmr_mutex); | ||
620 | rds_event = 1; | ||
621 | mutex_unlock(&fmr_mutex); | ||
622 | } | 590 | } |
623 | #endif /* RDS_ISR_PROCESSING */ | 591 | #endif /* (CONFIG_RDS & RDS_CFG_ISR) */ |
624 | 592 | ||
625 | char * si4700_get_rds_info(int setting) | ||
626 | { | ||
627 | char *text = NULL; | ||
628 | |||
629 | switch(setting) | ||
630 | { | ||
631 | case RADIO_RDS_NAME: | ||
632 | text = rds_get_ps(); | ||
633 | break; | ||
634 | |||
635 | case RADIO_RDS_TEXT: | ||
636 | text = rds_get_rt(); | ||
637 | break; | ||
638 | } | ||
639 | |||
640 | return text; | ||
641 | } | ||
642 | #endif /* HAVE_RDS_CAP */ | 593 | #endif /* HAVE_RDS_CAP */ |
643 | 594 | ||