mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
IAP: First steps towards true multiport state
iap_reset_state() and iap_getc() are now passed the logical IAP port (0 is dock/only connector, 1 is headphone connector) Change-Id: I97421146a8cab032b90c9b4eb55b50aa00d73312
This commit is contained in:
parent
e2f2ee88c8
commit
0456ec5630
13 changed files with 32 additions and 20 deletions
|
@ -306,14 +306,14 @@ void iap_reset_auth(struct auth_t* auth)
|
|||
auth->next_section = 0;
|
||||
}
|
||||
|
||||
void iap_reset_state(int port)
|
||||
void iap_reset_state(IF_IAP_MP_NONVOID(int port))
|
||||
{
|
||||
if (!iap_running)
|
||||
return;
|
||||
|
||||
/* 0 is dock, 1 is headphone. This is for
|
||||
when we eventually maintain independent state */
|
||||
(void)port;
|
||||
IF_IAP_MP((void)port);
|
||||
|
||||
iap_reset_device(&device);
|
||||
iap_bitrate_set(global_settings.serial_bitrate);
|
||||
|
@ -593,7 +593,7 @@ void iap_send_pkt(const unsigned char * data, const int len)
|
|||
iap_send_tx();
|
||||
}
|
||||
|
||||
bool iap_getc(const unsigned char x)
|
||||
bool iap_getc(IF_IAP_MP(int port,) const unsigned char x)
|
||||
{
|
||||
struct state_t *s = &frame_state;
|
||||
static long pkt_timeout;
|
||||
|
@ -606,7 +606,7 @@ bool iap_getc(const unsigned char x)
|
|||
/* Packet timeouts only make sense while not waiting for the
|
||||
* sync byte */
|
||||
s->state = ST_SYNC;
|
||||
return iap_getc(x);
|
||||
return iap_getc(IF_IAP_MP(port,) x);
|
||||
}
|
||||
|
||||
|
||||
|
@ -633,7 +633,7 @@ bool iap_getc(const unsigned char x)
|
|||
s->state = ST_LEN;
|
||||
} else {
|
||||
s->state = ST_SYNC;
|
||||
return iap_getc(x);
|
||||
return iap_getc(IF_IAP_MP(port,) x);
|
||||
}
|
||||
break;
|
||||
case ST_LEN:
|
||||
|
|
|
@ -109,7 +109,7 @@ static int hp_detect_callback(struct timeout *tmo)
|
|||
|
||||
#if defined(IPOD_ACCESSORY_PROTOCOL) && (defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IPOD_MINI2G))
|
||||
if (id == SYS_PHONE_UNPLUGGED)
|
||||
iap_reset_state(1);
|
||||
iap_reset_state(IF_IAP_MP(1));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
#define ICODE_ATTR_TREMOR_NOT_MDCT
|
||||
|
||||
#define IPOD_ACCESSORY_PROTOCOL
|
||||
#define HAVE_IAP_MULTIPORT
|
||||
#define HAVE_SERIAL
|
||||
|
||||
#define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */
|
||||
|
|
|
@ -200,9 +200,9 @@
|
|||
#define ICODE_ATTR_TREMOR_NOT_MDCT
|
||||
|
||||
#define IPOD_ACCESSORY_PROTOCOL
|
||||
#define HAVE_IAP_MULTIPORT
|
||||
#define HAVE_SERIAL
|
||||
|
||||
|
||||
/* DMA is used only for reading on PP502x because although reads are ~8x faster
|
||||
* writes appear to be ~25% slower.
|
||||
*/
|
||||
|
|
|
@ -206,6 +206,7 @@
|
|||
#define ICODE_ATTR_TREMOR_NOT_MDCT
|
||||
|
||||
#define IPOD_ACCESSORY_PROTOCOL
|
||||
#define HAVE_IAP_MULTIPORT
|
||||
#define HAVE_SERIAL
|
||||
|
||||
#define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */
|
||||
|
|
|
@ -210,6 +210,7 @@
|
|||
#define ICODE_ATTR_TREMOR_NOT_MDCT
|
||||
|
||||
#define IPOD_ACCESSORY_PROTOCOL
|
||||
#define HAVE_IAP_MULTIPORT
|
||||
#define HAVE_SERIAL
|
||||
|
||||
#define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */
|
||||
|
|
|
@ -27,7 +27,15 @@
|
|||
/* This is the entire frame length, sync, length, payload and checksum */
|
||||
#define TX_BUFLEN 128
|
||||
|
||||
extern bool iap_getc(unsigned char x);
|
||||
#ifdef HAVE_IAP_MULTIPORT
|
||||
#define IF_IAP_MP(x...) x
|
||||
#define IF_IAP_MP_NONVOID(x...) x
|
||||
#else
|
||||
#define IF_IAP_MP(x...)
|
||||
#define IF_IAP_MP_NONVOID(x...) void
|
||||
#endif
|
||||
|
||||
extern bool iap_getc(IF_IAP_MP(int port,) unsigned char x);
|
||||
extern void iap_setup(int ratenum);
|
||||
extern void iap_bitrate_set(int ratenum);
|
||||
extern void iap_periodic(void);
|
||||
|
@ -37,6 +45,6 @@ const unsigned char *iap_get_serbuf(void);
|
|||
#ifdef HAVE_LINE_REC
|
||||
extern bool iap_record(bool onoff);
|
||||
#endif
|
||||
void iap_reset_state(int port); /* 0 is dock, 1 is headphone */
|
||||
void iap_reset_state(IF_IAP_MP_NONVOID(int port) ); /* 0 is dock, 1 is headphone */
|
||||
bool dbg_iap(void);
|
||||
#endif
|
||||
|
|
|
@ -188,11 +188,12 @@ void SERIAL_ISR(int port)
|
|||
static bool newpkt = true;
|
||||
char temp;
|
||||
|
||||
#if defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IPOD_MINI2G)
|
||||
#ifdef HAVE_IAP_MULTIPORT
|
||||
if (port && SERn != &SER1)
|
||||
SERn = &SER1;
|
||||
else if (!port && SERn != &SER0)
|
||||
SERn = &SER0;
|
||||
port = !port; /* UART0 is headphone, ie IAP1 */
|
||||
#else
|
||||
(void)port;
|
||||
#endif
|
||||
|
@ -261,7 +262,7 @@ void SERIAL_ISR(int port)
|
|||
}
|
||||
}
|
||||
}
|
||||
bool pkt = iap_getc(temp);
|
||||
bool pkt = iap_getc(IF_IAP_MP(port,) temp);
|
||||
if(newpkt && !pkt)
|
||||
SERn->autobaud = 0; /* Found good baud */
|
||||
newpkt = pkt;
|
||||
|
|
|
@ -180,7 +180,7 @@ void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
uartc_port_set_rx_mode(&ser_port, UCON_MODE_INTREQ);
|
||||
|
||||
/* enter SOF state */
|
||||
iap_getc(0xff);
|
||||
iap_getc(IF_IAP_MP(0,) 0xff);
|
||||
|
||||
abr_status = ABR_STATUS_SYNCING;
|
||||
sync_retry = 2; /* we are expecting [0xff] 0x55 */
|
||||
|
@ -190,7 +190,7 @@ void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
/* process received data */
|
||||
while (len--)
|
||||
{
|
||||
bool sync_done = !iap_getc(*data++);
|
||||
bool sync_done = !iap_getc(IF_IAP_MP(0,) *data++);
|
||||
|
||||
if (abr_status == ABR_STATUS_SYNCING)
|
||||
{
|
||||
|
|
|
@ -220,7 +220,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
uartc_port_set_rx_mode(&ser_port, UCON_MODE_INTREQ);
|
||||
|
||||
/* enter SOF state */
|
||||
iap_getc(0xff);
|
||||
iap_getc(IF_IAP_MP(0,) 0xff);
|
||||
|
||||
abr_status = ABR_STATUS_SYNCING;
|
||||
sync_retry = 2; /* we are expecting [0xff] 0x55 */
|
||||
|
@ -230,7 +230,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
/* process received data */
|
||||
while (len--)
|
||||
{
|
||||
bool sync_done = !iap_getc(*data++);
|
||||
bool sync_done = !iap_getc(IF_IAP_MP(0,) *data++);
|
||||
|
||||
if (abr_status == ABR_STATUS_SYNCING)
|
||||
{
|
||||
|
|
|
@ -220,7 +220,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
uartc_port_set_rx_mode(&ser_port, UCON_MODE_INTREQ);
|
||||
|
||||
/* enter SOF state */
|
||||
iap_getc(0xff);
|
||||
iap_getc(IF_IAP_MP(0,) 0xff);
|
||||
|
||||
abr_status = ABR_STATUS_SYNCING;
|
||||
sync_retry = 2; /* we are expecting [0xff] 0x55 */
|
||||
|
@ -230,7 +230,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
/* process received data */
|
||||
while (len--)
|
||||
{
|
||||
bool sync_done = !iap_getc(*data++);
|
||||
bool sync_done = !iap_getc(IF_IAP_MP(0,) *data++);
|
||||
|
||||
if (abr_status == ABR_STATUS_SYNCING)
|
||||
{
|
||||
|
|
|
@ -220,7 +220,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
uartc_port_set_rx_mode(&ser_port, UCON_MODE_INTREQ);
|
||||
|
||||
/* enter SOF state */
|
||||
iap_getc(0xff);
|
||||
iap_getc(IF_IAP_MP(0,) 0xff);
|
||||
|
||||
abr_status = ABR_STATUS_SYNCING;
|
||||
sync_retry = 2; /* we are expecting [0xff] 0x55 */
|
||||
|
@ -230,7 +230,7 @@ static void iap_rx_isr(int len, char *data, char *err, uint32_t abr_cnt)
|
|||
/* process received data */
|
||||
while (len--)
|
||||
{
|
||||
bool sync_done = !iap_getc(*data++);
|
||||
bool sync_done = !iap_getc(IF_IAP_MP(0,) *data++);
|
||||
|
||||
if (abr_status == ABR_STATUS_SYNCING)
|
||||
{
|
||||
|
|
|
@ -526,7 +526,7 @@ static void NORETURN_ATTR usb_thread(void)
|
|||
usb_stack_enable(false);
|
||||
|
||||
#ifdef IPOD_ACCESSORY_PROTOCOL
|
||||
iap_reset_state(0);
|
||||
iap_reset_state(IF_IAP_MP(0));
|
||||
#endif
|
||||
|
||||
/* Only disable the USB slave mode if we really have enabled
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue