enum handler_return smd_irq_handler(void* data) { smd_channel_info_t *ch = (smd_channel_info_t*)data; if(ch->current_state == SMD_SS_CLOSED) { free(smd_channel_alloc_entry); event_signal(&smd_closed, false); return INT_NO_RESCHEDULE; } if(ch->port_info->ch1.state_updated) ch->port_info->ch1.state_updated = 0; /* Should we have to use a do while and change states until we complete */ if(ch->current_state != ch->port_info->ch1.stream_state) { smd_set_state(ch, ch->port_info->ch1.stream_state, 0); } if(ch->current_state == SMD_SS_CLOSING) { smd_set_state(ch, SMD_SS_CLOSED, 1); smd_notify_rpm(); dprintf(CRITICAL,"Channel alloc freed\n"); } return INT_NO_RESCHEDULE; }
int smd_init(smd_channel_info_t *ch, uint32_t ch_type) { unsigned ret = 0; smd_channel_alloc_entry = (smd_channel_alloc_entry_t*)memalign(CACHE_LINE, SMD_CHANNEL_ALLOC_MAX); ASSERT(smd_channel_alloc_entry); ret = smem_read_alloc_entry(SMEM_CHANNEL_ALLOC_TBL, (void*)smd_channel_alloc_entry, SMD_CHANNEL_ALLOC_MAX); if(ret) { dprintf(CRITICAL,"ERROR reading smem channel alloc tbl\n"); return -1; } smd_get_channel_info(ch, ch_type); register_int_handler(SMD_IRQ, smd_irq_handler, ch); unmask_interrupt(SMD_IRQ); smd_set_state(ch, SMD_SS_OPENING, 1); smd_notify_rpm(); return 0; }
void smd_uninit(smd_channel_info_t *ch) { event_init(&smd_closed, false, EVENT_FLAG_AUTOUNSIGNAL); smd_set_state(ch, SMD_SS_CLOSING, 1); smd_notify_rpm(); /* Wait for the SMD-RPM channel to be closed */ event_wait(&smd_closed); }
int smd_init(smd_channel_info_t *ch, uint32_t ch_type) { unsigned ret = 0; int chnl_found = 0; uint64_t timeout = SMD_CHANNEL_ACCESS_RETRY; smd_channel_alloc_entry = (smd_channel_alloc_entry_t*)memalign(CACHE_LINE, SMD_CHANNEL_ALLOC_MAX); ASSERT(smd_channel_alloc_entry); dprintf(INFO, "Waiting for the RPM to populate smd channel table\n"); do { ret = smem_read_alloc_entry(SMEM_CHANNEL_ALLOC_TBL, (void*)smd_channel_alloc_entry, SMD_CHANNEL_ALLOC_MAX); if(ret) { dprintf(CRITICAL,"ERROR reading smem channel alloc tbl\n"); return -1; } chnl_found = smd_get_channel_info(ch, ch_type); timeout--; udelay(10); } while(timeout && chnl_found); if (!timeout) { dprintf(CRITICAL, "Apps timed out waiting for RPM-->APPS channel entry\n"); ASSERT(0); } register_int_handler(SMD_IRQ, smd_irq_handler, ch); smd_set_state(ch, SMD_SS_OPENING, 1); smd_notify_rpm(); unmask_interrupt(SMD_IRQ); return 0; }
void smd_uninit(smd_channel_info_t *ch) { smd_set_state(ch, SMD_SS_CLOSING, 1); smd_notify_rpm(); }