summaryrefslogtreecommitdiff
path: root/apps/iap/iap-core.c
diff options
context:
space:
mode:
authorLiveboxAndy <liveboxandy@gmail.com>2018-08-04 18:02:21 +0100
committerSolomon Peachy <pizza@shaftnet.org>2020-07-09 18:02:07 +0000
commit77f8c9c9f12f1a520467868047574fe0af7a1556 (patch)
tree2ae699fbdeca5aed4e28a1d5bc69915d5f6f5838 /apps/iap/iap-core.c
parentdcdf2713f610cb3cfaa615ab9b8d4b9412e7a8b6 (diff)
downloadrockbox-77f8c9c9f12f1a520467868047574fe0af7a1556.tar.gz
rockbox-77f8c9c9f12f1a520467868047574fe0af7a1556.zip
Update to allow the Apple Radio Remote to function on iPod Video 5G.
This was broken when the major update to iap was comitted. ia-lingo7.c created and various iap related files modified. On 4G, 6G and Nano 1/2Gen iPods the remote will function even though the radio won't. Tested on 4G Greyscale, 4G Color, 4G Photo, 4G Mini 1st Gen, 4G Mini 2Gen, Nano 1G, Nano 2G, Video 5G, Video 5.5G Change-Id: Ia74e3d07d9ab5edc6da8eafa96801ede722be331
Diffstat (limited to 'apps/iap/iap-core.c')
-rw-r--r--apps/iap/iap-core.c115
1 files changed, 64 insertions, 51 deletions
diff --git a/apps/iap/iap-core.c b/apps/iap/iap-core.c
index f8373bab83..885ba2c188 100644
--- a/apps/iap/iap-core.c
+++ b/apps/iap/iap-core.c
@@ -45,7 +45,9 @@
45#include "usb.h" 45#include "usb.h"
46 46
47#include "tuner.h" 47#include "tuner.h"
48#if CONFIG_TUNER
48#include "ipod_remote_tuner.h" 49#include "ipod_remote_tuner.h"
50#endif
49 51
50 52
51/* MS_TO_TICKS converts a milisecond time period into the 53/* MS_TO_TICKS converts a milisecond time period into the
@@ -164,7 +166,13 @@ unsigned char lingo_versions[32][2] = {
164 {1, 5}, /* Display remote lingo, 0x03 */ 166 {1, 5}, /* Display remote lingo, 0x03 */
165 {1, 12}, /* Extended Interface lingo, 0x04 */ 167 {1, 12}, /* Extended Interface lingo, 0x04 */
166 {1, 1}, /* RF/BT Transmitter lingo, 0x05 */ 168 {1, 1}, /* RF/BT Transmitter lingo, 0x05 */
167 {} /* All others are unsupported */ 169 {0, 0}, /* USB Host lingo, 0x06, disabled */
170#if CONFIG_TUNER
171 {1, 0}, /* RF Receiver lingo, 0x07 */
172#else
173 {0, 0}, /* RF Receiver lingo, 0x07 disabled */
174#endif
175 {} /* every other lingo, disabled */
168}; 176};
169 177
170/* states of the iap de-framing state machine */ 178/* states of the iap de-framing state machine */
@@ -308,6 +316,17 @@ static int iap_task(struct timeout *tmo)
308 return MS_TO_TICKS(100); 316 return MS_TO_TICKS(100);
309} 317}
310 318
319
320void iap_set_remote_volume(void)
321{
322 IAP_TX_INIT(0x03, 0x0D);
323 IAP_TX_PUT(0x04);
324 IAP_TX_PUT(0x00);
325 IAP_TX_PUT(0xFF & (int)((global_settings.volume + 90) * 2.65625));
326 iap_send_tx();
327}
328
329
311/* This thread is waiting for events posted to iap_queue and calls 330/* This thread is waiting for events posted to iap_queue and calls
312 * the appropriate subroutines in response 331 * the appropriate subroutines in response
313 */ 332 */
@@ -859,11 +878,15 @@ void iap_periodic(void)
859 878
860 /* Volume change notifications are sent every 100ms */ 879 /* Volume change notifications are sent every 100ms */
861 if (device.notifications & (BIT_N(4) | BIT_N(16))) { 880 if (device.notifications & (BIT_N(4) | BIT_N(16))) {
862 /* Currently we do not track volume changes, so this is 881 /* Currently we do not track volume changes for BIT_N(16),
863 * never sent.
864 * 882 *
865 * TODO: Fix volume tracking
866 */ 883 */
884 IAP_TX_INIT(0x03, 0x09);
885 IAP_TX_PUT(0x04);
886 IAP_TX_PUT(0x00);
887 IAP_TX_PUT(0xFF &(int)((global_settings.volume + 90) * 2.65625));
888 device.changed_notifications |= BIT_N(4);
889 iap_send_tx();
867 } 890 }
868 891
869 /* All other events are sent every 500ms */ 892 /* All other events are sent every 500ms */
@@ -972,9 +995,15 @@ void iap_periodic(void)
972 unsigned char play_status; 995 unsigned char play_status;
973 996
974 play_status = audio_status(); 997 play_status = audio_status();
975
976 if (device.play_status != play_status) 998 if (device.play_status != play_status)
977 { 999 {
1000 /* If play_status = PAUSE/STOP we should mute else
1001 * we should unmute
1002 * 0 = Stopped
1003 * 1 = Playing
1004 * 2 = Pause
1005 * 3 = Play/Pause
1006 */
978 IAP_TX_INIT(0x03, 0x09); 1007 IAP_TX_INIT(0x03, 0x09);
979 IAP_TX_PUT(0x03); 1008 IAP_TX_PUT(0x03);
980 if (play_status & AUDIO_STATUS_PLAY) { 1009 if (play_status & AUDIO_STATUS_PLAY) {
@@ -994,6 +1023,23 @@ void iap_periodic(void)
994 iap_send_tx(); 1023 iap_send_tx();
995 1024
996 device.play_status = play_status; 1025 device.play_status = play_status;
1026 if (play_status != 1) {
1027 /* Not Playing */
1028 audio_pause();
1029#if CONFIG_TUNER
1030 if (radio_present==1) {
1031 tuner_set(RADIO_MUTE,1);
1032 }
1033#endif
1034 } else {
1035 /* Playing */
1036 audio_resume();
1037#if CONFIG_TUNER
1038 if (radio_present==1) {
1039 tuner_set(RADIO_MUTE,0);
1040 }
1041#endif
1042 }
997 } 1043 }
998 } 1044 }
999 1045
@@ -1212,43 +1258,6 @@ static void iap_handlepkt_mode5(const unsigned int len, const unsigned char *buf
1212 } 1258 }
1213} 1259}
1214 1260
1215#if 0
1216static void iap_handlepkt_mode7(const unsigned int len, const unsigned char *buf)
1217{
1218 unsigned int cmd = buf[1];
1219 switch (cmd)
1220 {
1221 /* RetTunerCaps */
1222 case 0x02:
1223 {
1224 /* do nothing */
1225
1226 /* GetAccessoryInfo */
1227 unsigned char data[] = {0x00, 0x27, 0x00};
1228 iap_send_pkt(data, sizeof(data));
1229 break;
1230 }
1231
1232 /* RetTunerFreq */
1233 case 0x0A:
1234 /* fall through */
1235 /* TunerSeekDone */
1236 case 0x13:
1237 {
1238 rmt_tuner_freq(len, buf);
1239 break;
1240 }
1241
1242 /* RdsReadyNotify, RDS station name 0x21 1E 00 + ASCII text*/
1243 case 0x21:
1244 {
1245 rmt_tuner_rds_data(len, buf);
1246 break;
1247 }
1248 }
1249}
1250#endif
1251
1252void iap_handlepkt(void) 1261void iap_handlepkt(void)
1253{ 1262{
1254 int level; 1263 int level;
@@ -1271,17 +1280,21 @@ void iap_handlepkt(void)
1271 logf("R: %s", hexstring(iap_rxstart+2, (length))); 1280 logf("R: %s", hexstring(iap_rxstart+2, (length)));
1272#endif 1281#endif
1273 1282
1274 unsigned char mode = *(iap_rxstart+2); 1283 if (length != 0) {
1275 switch (mode) { 1284 unsigned char mode = *(iap_rxstart+2);
1276 case 0: iap_handlepkt_mode0(length, iap_rxstart+2); break; 1285 switch (mode) {
1286 case 0: iap_handlepkt_mode0(length, iap_rxstart+2); break;
1277#ifdef HAVE_LINE_REC 1287#ifdef HAVE_LINE_REC
1278 case 1: iap_handlepkt_mode1(length, iap_rxstart+2); break; 1288 case 1: iap_handlepkt_mode1(length, iap_rxstart+2); break;
1279#endif 1289#endif
1280 case 2: iap_handlepkt_mode2(length, iap_rxstart+2); break; 1290 case 2: iap_handlepkt_mode2(length, iap_rxstart+2); break;
1281 case 3: iap_handlepkt_mode3(length, iap_rxstart+2); break; 1291 case 3: iap_handlepkt_mode3(length, iap_rxstart+2); break;
1282 case 4: iap_handlepkt_mode4(length, iap_rxstart+2); break; 1292 case 4: iap_handlepkt_mode4(length, iap_rxstart+2); break;
1283 case 5: iap_handlepkt_mode5(length, iap_rxstart+2); break; 1293 case 5: iap_handlepkt_mode5(length, iap_rxstart+2); break;
1284 /* case 7: iap_handlepkt_mode7(length, iap_rxstart+2); break; */ 1294#if CONFIG_TUNER
1295 case 7: iap_handlepkt_mode7(length, iap_rxstart+2); break;
1296#endif
1297 }
1285 } 1298 }
1286 1299
1287 /* Remove the handled packet from the RX buffer 1300 /* Remove the handled packet from the RX buffer