From 0260852771aef7a6e9045684f0c3d0d7e01909f7 Mon Sep 17 00:00:00 2001 From: Laurent Gautier Date: Tue, 1 Dec 2009 17:54:40 +0000 Subject: Add support for the ipod FM remote to the 4G, Color, 5G, nano 1G with RDS git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23805 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config-ipod4g.h | 6 ++- firmware/export/config-ipodcolor.h | 6 ++- firmware/export/config-ipodnano.h | 6 ++- firmware/export/config-ipodvideo.h | 6 ++- firmware/export/config.h | 1 + firmware/export/iap.h | 5 +++ firmware/export/ipod_remote_tuner.h | 75 +++++++++++++++++++++++++++++++++++++ firmware/export/tuner.h | 21 ++++++++++- 8 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 firmware/export/ipod_remote_tuner.h (limited to 'firmware/export') diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h index c00a6788c6..e6bdc35bd8 100644 --- a/firmware/export/config-ipod4g.h +++ b/firmware/export/config-ipod4g.h @@ -18,7 +18,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_44) @@ -144,6 +144,10 @@ #define CURRENT_RECORD 35 /* FIXME: this needs adjusting */ #endif +/* Define Apple remote tuner */ +#define CONFIG_TUNER IPOD_REMOTE_TUNER +#define HAVE_RDS_CAP + /* Define this if you have a PortalPlayer PP5020 */ #define CONFIG_CPU PP5020 diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h index 751522d47b..0f1de4fdba 100644 --- a/firmware/export/config-ipodcolor.h +++ b/firmware/export/config-ipodcolor.h @@ -18,7 +18,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_44) @@ -121,6 +121,10 @@ /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER +/* Define Apple remote tuner */ +#define CONFIG_TUNER IPOD_REMOTE_TUNER +#define HAVE_RDS_CAP + /* Define this if you have a PortalPlayer PP5020 */ #define CONFIG_CPU PP5020 diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h index 68ed152cda..e1ec1afa86 100644 --- a/firmware/export/config-ipodnano.h +++ b/firmware/export/config-ipodnano.h @@ -18,7 +18,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_44) @@ -134,6 +134,10 @@ #define CURRENT_RECORD 35 /* FIXME: this needs adjusting */ #endif +/* Define Apple remote tuner */ +#define CONFIG_TUNER IPOD_REMOTE_TUNER +#define HAVE_RDS_CAP + /* Define this if you have a PortalPlayer PP5022 */ #define CONFIG_CPU PP5022 diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h index f00de9cbfd..59ac6466e5 100644 --- a/firmware/export/config-ipodvideo.h +++ b/firmware/export/config-ipodvideo.h @@ -18,7 +18,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ @@ -155,6 +155,10 @@ #define CURRENT_RECORD 35 /* FIXME: this needs adjusting */ #endif +/* Define Apple remote tuner */ +#define CONFIG_TUNER IPOD_REMOTE_TUNER +#define HAVE_RDS_CAP + /* Define this if you have a PortalPlayer PP5022 */ #define CONFIG_CPU PP5022 diff --git a/firmware/export/config.h b/firmware/export/config.h index 9c7beca2bd..088cab7212 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -40,6 +40,7 @@ #define SI4700 0x08 /* Silicon Labs */ #define TEA5760 0x10 /* Philips */ #define LV240000 0x20 /* Sanyo */ +#define IPOD_REMOTE_TUNER 0x40 /* Apple */ /* CONFIG_CODEC */ #define MAS3587F 3587 diff --git a/firmware/export/iap.h b/firmware/export/iap.h index e945d0c979..d00e5f398a 100644 --- a/firmware/export/iap.h +++ b/firmware/export/iap.h @@ -20,6 +20,9 @@ #ifndef __IAP_H__ #define __IAP_H__ +#define RX_BUFLEN 260 +#define TX_BUFLEN 128 + extern int iap_getc(unsigned char x); extern void iap_write_pkt(unsigned char data, int len); extern void iap_setup(int ratenum); @@ -27,5 +30,7 @@ extern void iap_bitrate_set(int ratenum); extern void iap_periodic(void); extern void iap_handlepkt(void); extern void iap_track_changed(void *ignored); +extern void iap_send_pkt(const unsigned char * data, int len); +extern unsigned char serbuf[RX_BUFLEN]; #endif diff --git a/firmware/export/ipod_remote_tuner.h b/firmware/export/ipod_remote_tuner.h new file mode 100644 index 0000000000..28fcfe1e93 --- /dev/null +++ b/firmware/export/ipod_remote_tuner.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: ipod_remote_tuner.h + * Tuner header for the ipod remote tuner and others remote tuners + * + * Copyright (C) 2009 Laurent Gautier + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _IPOD_REMOTE_TUNER_H_ +#define _IPOD_REMOTE_TUNER_H_ + +#define HAVE_RADIO_REGION +#define TIMEOUT_VALUE 20 + +extern int radio_present; +extern int tuner_frequency; +extern int tuner_signal_power; +extern int radio_tuned; + +/* update tuner state: plugged or unplugged when in radio mode */ +extern void rmt_tuner_region(int region); +extern void rmt_tuner_set_freq(int curr_freq); +extern void rmt_tuner_freq(void); +extern void rmt_tuner_scan(int direction); + +/* tuner mode state: ON or OFF */ +extern void rmt_tuner_sleep(int state); + +/* parameters are stereo/mono, deemphasis, delta freq... */ +extern void rmt_tuner_set_param(unsigned char tuner_param); + +extern void rmt_tuner_mute(int value); +extern void rmt_tuner_signal_power(unsigned char value); + +extern void rmt_tuner_rds_data(void); + +struct rmt_tuner_region_data +{ + /* 0: 50us, 1: 75us */ + unsigned char deemphasis; + /* 0: europe, 1: japan (BL in TEA spec)*/ + unsigned char band; + /* 0: us/australia (200kHz), 1: europe/japan (100kHz), 2: (50kHz) */ + unsigned char spacing; +} __attribute__((packed)); + +extern const struct rmt_tuner_region_data + rmt_tuner_region_data[TUNER_NUM_REGIONS]; + +int ipod_rmt_tuner_set(int setting, int value); +int ipod_rmt_tuner_get(int setting); +char* ipod_get_rds_info(int setting); + + +#ifndef CONFIG_TUNER_MULTI +#define tuner_set ipod_rmt_tuner_set +#define tuner_get ipod_rmt_tuner_get +#define tuner_get_rds_info ipod_get_rds_info +#endif + +#endif /* _IPOD_REMOTE_TUNER_H_ */ diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h index b27e660667..63392160e5 100644 --- a/firmware/export/tuner.h +++ b/firmware/export/tuner.h @@ -33,7 +33,7 @@ enum RADIO_MUTE, RADIO_FORCE_MONO, RADIO_SCAN_FREQUENCY, - + /* Put new general-purpose settings above this line */ __RADIO_SET_STANDARD_LAST }; @@ -44,11 +44,25 @@ enum RADIO_PRESENT = 0, RADIO_TUNED, RADIO_STEREO, + /* RADIO_EVENT is an event that requests a screen update */ + RADIO_EVENT, /* Put new general-purpose readback values above this line */ __RADIO_GET_STANDARD_LAST }; +#ifdef HAVE_RDS_CAP +/** Readback from the tuner RDS layer **/ +enum +{ + RADIO_RDS_NAME, + RADIO_RDS_TEXT, + + /* Put new general-purpose readback values above this line */ + __RADIO_GET_RDS_INFO_STANDARD_LAST +}; +#endif + /** Tuner regions **/ /* Basic region information */ @@ -114,6 +128,11 @@ extern int (*tuner_get)(int setting); #include "si4700.h" #endif +/* Apple remote tuner */ +#if (CONFIG_TUNER & IPOD_REMOTE_TUNER) +#include "ipod_remote_tuner.h" +#endif + #endif /* SIMULATOR */ /* Additional messages that get enumerated after tuner driver headers */ -- cgit v1.2.3