diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2011-04-24 20:22:38 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2011-04-24 20:22:38 +0000 |
commit | 4c1de9c015c96ac8c7c964f1868545369135a7ec (patch) | |
tree | 795681f64579f45e37f52531b0600c6c5135827b /apps | |
parent | a602f46d69d9d18756b7f317470f654f695faa80 (diff) | |
download | rockbox-4c1de9c015c96ac8c7c964f1868545369135a7ec.tar.gz rockbox-4c1de9c015c96ac8c7c964f1868545369135a7ec.zip |
iap: add more comments to iap command and responses
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29779 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/iap.c | 105 |
1 files changed, 68 insertions, 37 deletions
diff --git a/apps/iap.c b/apps/iap.c index ecf70b2e69..d237825796 100644 --- a/apps/iap.c +++ b/apps/iap.c | |||
@@ -188,6 +188,7 @@ void iap_periodic(void) | |||
188 | if(!iap_setupflag) return; | 188 | if(!iap_setupflag) return; |
189 | if(!iap_pollspeed) return; | 189 | if(!iap_pollspeed) return; |
190 | 190 | ||
191 | /* PlayStatusChangeNotification */ | ||
191 | unsigned char data[] = {0x04, 0x00, 0x27, 0x04, 0x00, 0x00, 0x00, 0x00}; | 192 | unsigned char data[] = {0x04, 0x00, 0x27, 0x04, 0x00, 0x00, 0x00, 0x00}; |
192 | unsigned long time_elapsed = audio_current_track()->elapsed; | 193 | unsigned long time_elapsed = audio_current_track()->elapsed; |
193 | 194 | ||
@@ -470,14 +471,16 @@ static void iap_handlepkt_mode3(void) | |||
470 | unsigned int cmd = serbuf[2]; | 471 | unsigned int cmd = serbuf[2]; |
471 | switch (cmd) | 472 | switch (cmd) |
472 | { | 473 | { |
473 | /* some kind of status packet? */ | 474 | /* GetCurrentEQProfileIndex */ |
474 | case 0x01: | 475 | case 0x01: |
475 | { | 476 | { |
477 | /* RetCurrentEQProfileIndex */ | ||
476 | unsigned char data[] = {0x03, 0x02, 0x00, 0x00, 0x00, 0x00}; | 478 | unsigned char data[] = {0x03, 0x02, 0x00, 0x00, 0x00, 0x00}; |
477 | iap_send_pkt(data, sizeof(data)); | 479 | iap_send_pkt(data, sizeof(data)); |
478 | break; | 480 | break; |
479 | } | 481 | } |
480 | 482 | ||
483 | /* SetRemoteEventNotification */ | ||
481 | case 0x08: | 484 | case 0x08: |
482 | { | 485 | { |
483 | /* ACK */ | 486 | /* ACK */ |
@@ -486,6 +489,7 @@ static void iap_handlepkt_mode3(void) | |||
486 | break; | 489 | break; |
487 | } | 490 | } |
488 | 491 | ||
492 | /* GetiPodStateInfo */ | ||
489 | case 0x0C: | 493 | case 0x0C: |
490 | { | 494 | { |
491 | /* request ipod volume */ | 495 | /* request ipod volume */ |
@@ -495,7 +499,8 @@ static void iap_handlepkt_mode3(void) | |||
495 | } | 499 | } |
496 | break; | 500 | break; |
497 | } | 501 | } |
498 | /* get volume from accessory */ | 502 | |
503 | /* SetiPodStateInfo */ | ||
499 | case 0x0E: | 504 | case 0x0E: |
500 | { | 505 | { |
501 | if (serbuf[3] == 0x04) | 506 | if (serbuf[3] == 0x04) |
@@ -519,15 +524,17 @@ static void iap_handlepkt_mode4(void) | |||
519 | unsigned int cmd = (serbuf[2] << 8) | serbuf[3]; | 524 | unsigned int cmd = (serbuf[2] << 8) | serbuf[3]; |
520 | switch (cmd) | 525 | switch (cmd) |
521 | { | 526 | { |
522 | /* Get data updated??? flag */ | 527 | /* GetAudioBookSpeed */ |
523 | case 0x0009: | 528 | case 0x0009: |
524 | { | 529 | { |
530 | /* ReturnAudioBookSpeed */ | ||
525 | unsigned char data[] = {0x04, 0x00, 0x0A, 0x00}; | 531 | unsigned char data[] = {0x04, 0x00, 0x0A, 0x00}; |
526 | data[3] = iap_updateflag ? 0 : 1; | 532 | data[3] = iap_updateflag ? 0 : 1; |
527 | iap_send_pkt(data, sizeof(data)); | 533 | iap_send_pkt(data, sizeof(data)); |
528 | break; | 534 | break; |
529 | } | 535 | } |
530 | /* Set data updated??? flag */ | 536 | |
537 | /* SetAudioBookSpeed */ | ||
531 | case 0x000B: | 538 | case 0x000B: |
532 | { | 539 | { |
533 | iap_updateflag = serbuf[4] ? 0 : 1; | 540 | iap_updateflag = serbuf[4] ? 0 : 1; |
@@ -535,16 +542,20 @@ static void iap_handlepkt_mode4(void) | |||
535 | cmd_ok_mode4(cmd); | 542 | cmd_ok_mode4(cmd); |
536 | break; | 543 | break; |
537 | } | 544 | } |
538 | /* Get iPod size? */ | 545 | |
546 | /* RequestProtocolVersion */ | ||
539 | case 0x0012: | 547 | case 0x0012: |
540 | { | 548 | { |
549 | /* ReturnProtocolVersion */ | ||
541 | unsigned char data[] = {0x04, 0x00, 0x13, 0x01, 0x0B}; | 550 | unsigned char data[] = {0x04, 0x00, 0x13, 0x01, 0x0B}; |
542 | iap_send_pkt(data, sizeof(data)); | 551 | iap_send_pkt(data, sizeof(data)); |
543 | break; | 552 | break; |
544 | } | 553 | } |
545 | /* Get count of given types */ | 554 | |
555 | /* GetNumberCategorizedDBRecords */ | ||
546 | case 0x0018: | 556 | case 0x0018: |
547 | { | 557 | { |
558 | /* ReturnNumberCategorizedDBRecords */ | ||
548 | unsigned char data[] = {0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00}; | 559 | unsigned char data[] = {0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00}; |
549 | unsigned long num = 0; | 560 | unsigned long num = 0; |
550 | switch(serbuf[4]) /* type number */ | 561 | switch(serbuf[4]) /* type number */ |
@@ -562,9 +573,11 @@ static void iap_handlepkt_mode4(void) | |||
562 | iap_send_pkt(data, sizeof(data)); | 573 | iap_send_pkt(data, sizeof(data)); |
563 | break; | 574 | break; |
564 | } | 575 | } |
565 | /* Get time and status */ | 576 | |
577 | /* GetPlayStatus */ | ||
566 | case 0x001C: | 578 | case 0x001C: |
567 | { | 579 | { |
580 | /* ReturnPlayStatus */ | ||
568 | unsigned char data[] = {0x04, 0x00, 0x1D, 0x00, 0x00, 0x00, | 581 | unsigned char data[] = {0x04, 0x00, 0x1D, 0x00, 0x00, 0x00, |
569 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 582 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
570 | struct mp3entry *id3 = audio_current_track(); | 583 | struct mp3entry *id3 = audio_current_track(); |
@@ -586,9 +599,11 @@ static void iap_handlepkt_mode4(void) | |||
586 | iap_send_pkt(data, sizeof(data)); | 599 | iap_send_pkt(data, sizeof(data)); |
587 | break; | 600 | break; |
588 | } | 601 | } |
589 | /* Get current pos in playlist */ | 602 | |
603 | /* GetCurrentPlayingTrackIndex */ | ||
590 | case 0x001E: | 604 | case 0x001E: |
591 | { | 605 | { |
606 | /* ReturnCurrentPlayingTrackIndex */ | ||
592 | unsigned char data[] = {0x04, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00}; | 607 | unsigned char data[] = {0x04, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00}; |
593 | long playlist_pos = playlist_next(0); | 608 | long playlist_pos = playlist_next(0); |
594 | playlist_pos -= playlist_get_first_index(NULL); | 609 | playlist_pos -= playlist_get_first_index(NULL); |
@@ -601,11 +616,12 @@ static void iap_handlepkt_mode4(void) | |||
601 | iap_send_pkt(data, sizeof(data)); | 616 | iap_send_pkt(data, sizeof(data)); |
602 | break; | 617 | break; |
603 | } | 618 | } |
604 | /* Get title of a song number */ | 619 | |
620 | /* GetIndexedPlayingTrackTitle */ | ||
605 | case 0x0020: | 621 | case 0x0020: |
606 | /* Get artist of a song number */ | 622 | /* GetIndexedPlayingTrackArtistName */ |
607 | case 0x0022: | 623 | case 0x0022: |
608 | /* Get album of a song number */ | 624 | /* GetIndexedPlayingTrackAlbumName */ |
609 | case 0x0024: | 625 | case 0x0024: |
610 | { | 626 | { |
611 | unsigned char data[70] = {0x04, 0x00, 0xFF}; | 627 | unsigned char data[70] = {0x04, 0x00, 0xFF}; |
@@ -615,7 +631,7 @@ static void iap_handlepkt_mode4(void) | |||
615 | long tracknum = (signed long)serbuf[4] << 24 | | 631 | long tracknum = (signed long)serbuf[4] << 24 | |
616 | (signed long)serbuf[5] << 16 | | 632 | (signed long)serbuf[5] << 16 | |
617 | (signed long)serbuf[6] << 8 | serbuf[7]; | 633 | (signed long)serbuf[6] << 8 | serbuf[7]; |
618 | data[2] = serbuf[3] + 1; | 634 | data[2] = cmd + 1; |
619 | memcpy(&id3, audio_current_track(), sizeof(id3)); | 635 | memcpy(&id3, audio_current_track(), sizeof(id3)); |
620 | tracknum += playlist_get_first_index(NULL); | 636 | tracknum += playlist_get_first_index(NULL); |
621 | if(tracknum >= playlist_amount()) | 637 | if(tracknum >= playlist_amount()) |
@@ -634,37 +650,36 @@ static void iap_handlepkt_mode4(void) | |||
634 | } | 650 | } |
635 | 651 | ||
636 | /* Return the requested track data */ | 652 | /* Return the requested track data */ |
637 | switch(serbuf[3]) | 653 | switch(cmd) |
638 | { | 654 | { |
639 | case 0x20: | 655 | case 0x20: |
640 | len = strlcpy((char *)&data[3], id3.title, 64); | 656 | len = strlcpy((char *)&data[3], id3.title, 64); |
641 | iap_send_pkt(data, 4+len); | 657 | iap_send_pkt(data, 4+len); |
642 | break; | 658 | break; |
643 | case 0x22: | 659 | case 0x22: |
644 | len = strlcpy((char *)&data[3], id3.artist, 64); | 660 | len = strlcpy((char *)&data[3], id3.artist, 64); |
645 | iap_send_pkt(data, 4+len); | 661 | iap_send_pkt(data, 4+len); |
646 | break; | 662 | break; |
647 | case 0x24: | 663 | case 0x24: |
648 | len = strlcpy((char *)&data[3], id3.album, 64); | 664 | len = strlcpy((char *)&data[3], id3.album, 64); |
649 | iap_send_pkt(data, 4+len); | 665 | iap_send_pkt(data, 4+len); |
650 | break; | 666 | break; |
651 | } | 667 | } |
652 | break; | 668 | break; |
653 | } | 669 | } |
654 | /* Set polling mode */ | 670 | |
671 | /* SetPlayStatusChangeNotification */ | ||
655 | case 0x0026: | 672 | case 0x0026: |
656 | { | 673 | { |
657 | iap_pollspeed = serbuf[4] ? 1 : 0; | 674 | iap_pollspeed = serbuf[4] ? 1 : 0; |
658 | /*respond with cmd ok packet */ | 675 | /* respond with cmd ok packet */ |
659 | cmd_ok_mode4(cmd); | 676 | cmd_ok_mode4(cmd); |
660 | break; | 677 | break; |
661 | } | 678 | } |
662 | /* AiR playback control */ | 679 | |
680 | /* PlayControl */ | ||
663 | case 0x0029: | 681 | case 0x0029: |
664 | { | 682 | { |
665 | /* respond with cmd ok packet */ | ||
666 | unsigned char data[] = {0x04, 0x00, 0x01, 0x00, 0x00, 0x29}; | ||
667 | iap_send_pkt(data, sizeof(data)); | ||
668 | switch(serbuf[4]) | 683 | switch(serbuf[4]) |
669 | { | 684 | { |
670 | case 0x01: /* play/pause */ | 685 | case 0x01: /* play/pause */ |
@@ -705,17 +720,22 @@ static void iap_handlepkt_mode4(void) | |||
705 | if(iap_pollspeed) iap_pollspeed = 1; | 720 | if(iap_pollspeed) iap_pollspeed = 1; |
706 | break; | 721 | break; |
707 | } | 722 | } |
723 | /* respond with cmd ok packet */ | ||
724 | cmd_ok_mode4(cmd); | ||
708 | break; | 725 | break; |
709 | } | 726 | } |
710 | /* Get shuffle mode */ | 727 | |
728 | /* GetShuffle */ | ||
711 | case 0x002C: | 729 | case 0x002C: |
712 | { | 730 | { |
731 | /* ReturnShuffle */ | ||
713 | unsigned char data[] = {0x04, 0x00, 0x2D, 0x00}; | 732 | unsigned char data[] = {0x04, 0x00, 0x2D, 0x00}; |
714 | data[3] = global_settings.playlist_shuffle ? 1 : 0; | 733 | data[3] = global_settings.playlist_shuffle ? 1 : 0; |
715 | iap_send_pkt(data, sizeof(data)); | 734 | iap_send_pkt(data, sizeof(data)); |
716 | break; | 735 | break; |
717 | } | 736 | } |
718 | /* Set shuffle mode */ | 737 | |
738 | /* SetShuffle */ | ||
719 | case 0x002E: | 739 | case 0x002E: |
720 | { | 740 | { |
721 | if(serbuf[4] && !global_settings.playlist_shuffle) | 741 | if(serbuf[4] && !global_settings.playlist_shuffle) |
@@ -733,14 +753,15 @@ static void iap_handlepkt_mode4(void) | |||
733 | playlist_sort(NULL, true); | 753 | playlist_sort(NULL, true); |
734 | } | 754 | } |
735 | 755 | ||
736 | |||
737 | /* respond with cmd ok packet */ | 756 | /* respond with cmd ok packet */ |
738 | cmd_ok_mode4(cmd); | 757 | cmd_ok_mode4(cmd); |
739 | break; | 758 | break; |
740 | } | 759 | } |
741 | /* Get repeat mode */ | 760 | |
761 | /* GetRepeat */ | ||
742 | case 0x002F: | 762 | case 0x002F: |
743 | { | 763 | { |
764 | /* ReturnRepeat */ | ||
744 | unsigned char data[] = {0x04, 0x00, 0x30, 0x00}; | 765 | unsigned char data[] = {0x04, 0x00, 0x30, 0x00}; |
745 | if(global_settings.repeat_mode == REPEAT_OFF) | 766 | if(global_settings.repeat_mode == REPEAT_OFF) |
746 | data[3] = 0; | 767 | data[3] = 0; |
@@ -751,7 +772,8 @@ static void iap_handlepkt_mode4(void) | |||
751 | iap_send_pkt(data, sizeof(data)); | 772 | iap_send_pkt(data, sizeof(data)); |
752 | break; | 773 | break; |
753 | } | 774 | } |
754 | /* Set repeat mode */ | 775 | |
776 | /* SetRepeat */ | ||
755 | case 0x0031: | 777 | case 0x0031: |
756 | { | 778 | { |
757 | int oldmode = global_settings.repeat_mode; | 779 | int oldmode = global_settings.repeat_mode; |
@@ -772,10 +794,12 @@ static void iap_handlepkt_mode4(void) | |||
772 | /* respond with cmd ok packet */ | 794 | /* respond with cmd ok packet */ |
773 | cmd_ok_mode4(cmd); | 795 | cmd_ok_mode4(cmd); |
774 | break; | 796 | break; |
775 | } | 797 | } |
776 | /* Get Screen Size */ | 798 | |
799 | /* GetMonoDisplayImageLimits */ | ||
777 | case 0x0033: | 800 | case 0x0033: |
778 | { | 801 | { |
802 | /* ReturnMonoDisplayImageLimits */ | ||
779 | unsigned char data[] = {0x04, 0x00, 0x34, | 803 | unsigned char data[] = {0x04, 0x00, 0x34, |
780 | LCD_WIDTH >> 8, LCD_WIDTH & 0xff, | 804 | LCD_WIDTH >> 8, LCD_WIDTH & 0xff, |
781 | LCD_HEIGHT >> 8, LCD_HEIGHT & 0xff, | 805 | LCD_HEIGHT >> 8, LCD_HEIGHT & 0xff, |
@@ -783,9 +807,11 @@ static void iap_handlepkt_mode4(void) | |||
783 | iap_send_pkt(data, sizeof(data)); | 807 | iap_send_pkt(data, sizeof(data)); |
784 | break; | 808 | break; |
785 | } | 809 | } |
786 | /* Get number songs in current playlist */ | 810 | |
811 | /* GetNumPlayingTracks */ | ||
787 | case 0x0035: | 812 | case 0x0035: |
788 | { | 813 | { |
814 | /* ReturnNumPlayingTracks */ | ||
789 | unsigned char data[] = {0x04, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; | 815 | unsigned char data[] = {0x04, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; |
790 | unsigned long playlist_amt = playlist_amount(); | 816 | unsigned long playlist_amt = playlist_amount(); |
791 | data[3] = playlist_amt >> 24; | 817 | data[3] = playlist_amt >> 24; |
@@ -794,8 +820,9 @@ static void iap_handlepkt_mode4(void) | |||
794 | data[6] = playlist_amt; | 820 | data[6] = playlist_amt; |
795 | iap_send_pkt(data, sizeof(data)); | 821 | iap_send_pkt(data, sizeof(data)); |
796 | break; | 822 | break; |
797 | } | 823 | } |
798 | /* Jump to track number in current playlist */ | 824 | |
825 | /* SetCurrentPlayingTrack */ | ||
799 | case 0x0037: | 826 | case 0x0037: |
800 | { | 827 | { |
801 | int paused = (is_wps_fading() || (audio_status() & AUDIO_STATUS_PAUSE)); | 828 | int paused = (is_wps_fading() || (audio_status() & AUDIO_STATUS_PAUSE)); |
@@ -811,6 +838,7 @@ static void iap_handlepkt_mode4(void) | |||
811 | cmd_ok_mode4(cmd); | 838 | cmd_ok_mode4(cmd); |
812 | break; | 839 | break; |
813 | } | 840 | } |
841 | |||
814 | default: | 842 | default: |
815 | { | 843 | { |
816 | /* default response is with cmd ok packet */ | 844 | /* default response is with cmd ok packet */ |
@@ -825,25 +853,28 @@ static void iap_handlepkt_mode7(void) | |||
825 | unsigned int cmd = serbuf[2]; | 853 | unsigned int cmd = serbuf[2]; |
826 | switch (cmd) | 854 | switch (cmd) |
827 | { | 855 | { |
828 | /* tuner capabilities */ | 856 | /* RetTunerCaps */ |
829 | case 0x02: | 857 | case 0x02: |
830 | { | 858 | { |
831 | /* do nothing */ | 859 | /* do nothing */ |
832 | 860 | ||
861 | /* GetAccessoryInfo */ | ||
833 | unsigned char data[] = {0x00, 0x27, 0x00}; | 862 | unsigned char data[] = {0x00, 0x27, 0x00}; |
834 | iap_send_pkt(data, sizeof(data)); | 863 | iap_send_pkt(data, sizeof(data)); |
835 | break; | 864 | break; |
836 | } | 865 | } |
837 | /* actual tuner frequency */ | 866 | |
867 | /* RetTunerFreq */ | ||
838 | case 0x0A: | 868 | case 0x0A: |
839 | /* fall through */ | 869 | /* fall through */ |
840 | /* tuner frequency from scan */ | 870 | /* TunerSeekDone */ |
841 | case 0x13: | 871 | case 0x13: |
842 | { | 872 | { |
843 | rmt_tuner_freq(serbuf); | 873 | rmt_tuner_freq(serbuf); |
844 | break; | 874 | break; |
845 | } | 875 | } |
846 | /* RDS station name 0x21 1E 00 + ASCII text*/ | 876 | |
877 | /* RdsReadyNotify, RDS station name 0x21 1E 00 + ASCII text*/ | ||
847 | case 0x21: | 878 | case 0x21: |
848 | { | 879 | { |
849 | rmt_tuner_rds_data(serbuf); | 880 | rmt_tuner_rds_data(serbuf); |