summaryrefslogtreecommitdiffstats
path: root/apps/iap/iap-lingo3.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-lingo3.c
parentdcdf2713f610cb3cfaa615ab9b8d4b9412e7a8b6 (diff)
downloadrockbox-77f8c9c9f12f1a520467868047574fe0af7a1556.tar.gz
rockbox-77f8c9c9f12f1a520467868047574fe0af7a1556.tar.bz2
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-lingo3.c')
-rw-r--r--apps/iap/iap-lingo3.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/apps/iap/iap-lingo3.c b/apps/iap/iap-lingo3.c
index 0ed3df118e..c7801fbce0 100644
--- a/apps/iap/iap-lingo3.c
+++ b/apps/iap/iap-lingo3.c
@@ -38,6 +38,9 @@
#include "settings.h"
#include "metadata.h"
#include "playback.h"
+#if CONFIG_TUNER
+#include "ipod_remote_tuner.h"
+#endif
/*
* This macro is meant to be used inside an IAP mode message handler.
@@ -262,7 +265,7 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
device.play_status = audio_status();
/* TODO: Fix this */
device.mute = false;
- device.volume = 0x80;
+ device.volume = global_settings.volume;
device.power_state = charger_input_state;
device.battery_level = battery_level();
/* TODO: Fix this */
@@ -299,8 +302,8 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
/* GetRemoteEventStatus (0x0A)
*
- * Request the events changed since the last call to GetREmoteEventStatus
- * or SetRemoteEventNotification
+ * Request the events changed since the last call to
+ * GetREmoteEventStatus or SetRemoteEventNotification
*
* Packet format (offset in buf[]: Description)
* 0x00: Lingo ID: Display Remote Lingo, always 0x03
@@ -434,15 +437,18 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
*/
case 0x04:
{
- /* Figuring out what the current volume is
- * seems to be tricky.
- * TODO: Fix.
- */
+ if (device.mute == false) {
+ /* Mute status False*/
+ IAP_TX_PUT(0x00);
+ /* Volume */
+ IAP_TX_PUT(0xFF & (int)((global_settings.volume + 90) * 2.65625));
- /* Mute status */
- IAP_TX_PUT(0x00);
- /* Volume */
- IAP_TX_PUT(0x80);
+ } else {
+ /* Mute status True*/
+ IAP_TX_PUT(0x01);
+ /* Volume should be 0 if muted */
+ IAP_TX_PUT(0x00);
+ }
iap_send_tx();
break;
@@ -620,15 +626,24 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
*/
case 0x10:
{
- /* TODO: See volume above */
- IAP_TX_PUT(0x00);
- IAP_TX_PUT(0x80);
- IAP_TX_PUT(0x80);
+ if (device.mute == false) {
+ /* Mute status False*/
+ IAP_TX_PUT(0x00);
+ /* Volume */
+ IAP_TX_PUT(0xFF & (int)((global_settings.volume + 90) * 2.65625));
+ IAP_TX_PUT(0xFF & (int)((global_settings.volume + 90) * 2.65625));
+
+ } else {
+ /* Mute status True*/
+ IAP_TX_PUT(0x01);
+ /* Volume should be 0 if muted */
+ IAP_TX_PUT(0x00);
+ IAP_TX_PUT(0x00);
+ }
iap_send_tx();
break;
}
-
default:
{
cmd_ack(cmd, IAP_ACK_BAD_PARAM);
@@ -746,14 +761,18 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
break;
}
- /* Volume/Mute
- * Data length: 2
- * TODO: Fix this
- */
case 0x04:
{
CHECKLEN(5);
- cmd_ack(cmd, IAP_ACK_CMD_FAILED);
+ if (buf[0x03]==0x00){
+ /* Not Muted */
+ global_settings.volume = (int) (buf[0x04]/2.65625)-90;
+ device.mute = false;
+ }
+ else {
+ device.mute = true;
+ }
+ cmd_ok(cmd);
break;
}
@@ -919,7 +938,16 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
case 0x10:
{
CHECKLEN(7);
- cmd_ack(cmd, IAP_ACK_CMD_FAILED);
+ if (buf[0x03]==0x00){
+ /* Not Muted */
+ global_settings.volume = (int) (buf[0x04]/2.65625)-90;
+ device.mute = false;
+ }
+ else {
+ device.mute = true;
+ }
+
+ cmd_ok(cmd);
break;
}
@@ -1499,9 +1527,8 @@ void iap_handlepkt_mode3(const unsigned int len, const unsigned char *buf)
{
#ifdef LOGF_ENABLE
logf("iap: Unsupported Mode03 Command");
-#else
- cmd_ack(cmd, IAP_ACK_BAD_PARAM);
#endif
+ cmd_ack(cmd, IAP_ACK_BAD_PARAM);
break;
}
}