static void __write_to_lcd(mdev_t *dev, const char *line1, const char *line2) { mdev_t *i2c_dev; int temp; memset(lcd_buff, 0, sizeof(lcd_buff)); os_thread_sleep(os_msec_to_ticks(35)); i2c_dev = i2c_drv_open(dev->private_data, I2C_SLAVEADR(I2C_LCD_ADDR >> 1)); if (i2c_dev == NULL) { lcd_d("I2C driver init is required before open"); return; } lcd_buff[0] = LCD_CMD_CONFIG_MODE; /* Set DDRAM Address to line 1 * Bits: 1 AC6 AC5 AC4 AC3 AC2 AC1 AC0 * AC6-0: The address to be written to: * 00H: line 1 * 40H: line 2 */ lcd_buff[1] = 0x80; lcd_buff[2] = 0x06; /* Entry mode as mentioned above */ os_thread_sleep(os_msec_to_ticks(35)); temp = os_enter_critical_section(); i2c_drv_write(i2c_dev, (uint8_t *) lcd_buff, 2); os_exit_critical_section(temp); /* Write data */ lcd_buff[0] = LCD_CMD_DATA_MODE; if (line1) write_line1(lcd_buff, line1); if (line2) write_line2(lcd_buff, line2); os_thread_sleep(os_msec_to_ticks(35)); temp = os_enter_critical_section(); i2c_drv_write(i2c_dev, (uint8_t *) lcd_buff, end_of_line2(lcd_buff)); os_exit_critical_section(temp); i2c_drv_close(i2c_dev); }
void wmpanic() { wmlog("**** Panic from function: %p ****", "\n\r", __builtin_return_address(0)); /* Ensure that nothing runs after this */ os_enter_critical_section(); while (1) ; }
void _wm_assert(const char *filename, int lineno, const char* fail_cond) { wmprintf("\n\n\r*************** PANIC *************\n\r"); wmprintf("Filename : %s ( %d )\n\r", filename, lineno); wmprintf("Condition : %s\n\r", fail_cond); wmprintf("***********************************\n\r"); os_enter_critical_section(); for( ;; ); }
/*----------------------------------------------------------------------------+ | vid_atom_ttx_del_notify | NOTE: FOR USE WITH TTX DRIVER ONLY!!! Assumes all IRQs Removed were | EXCLUSIVELY added using the function vid_atom_ttx_add_notify(). +----------------------------------------------------------------------------*/ int vid_atom_ttx_del_notify(void(*fn)(unsigned int intreq),unsigned int mask) { int i,j; int rc; unsigned int state; unsigned int irq_removed=0; state = os_enter_critical_section(); rc = -1; /*--------------------------------------------------------------------------+ | search for the notify record +--------------------------------------------------------------------------*/ for(i=0; i<vid_atom_notify_ndx && rc!=0; i++) { if((vid_atom_notify[i].fn == fn) && ((vid_atom_notify[i].mask & mask) != 0)) { rc = 0; irq_removed = vid_atom_notify[i].mask; vid_atom_notify[i].mask &= ~mask; /* reset specified mask bits */ irq_removed ^= vid_atom_notify[i].mask; /* find irq removed */ if(vid_atom_notify[i].mask == 0) /* if zero, remove the handler */ { for(j=i+1; j<vid_atom_notify_ndx; j++,i++) { vid_atom_notify[i].fn = vid_atom_notify[j].fn; vid_atom_notify[i].mask = vid_atom_notify[j].mask; } vid_atom_notify[i].fn = 0; vid_atom_notify[i].mask = 0; vid_atom_notify_ndx--; } } } /*--------------------------------------------------------------------------+ | Calculate new Interrupt Mask +--------------------------------------------------------------------------*/ if (rc == 0) { mask = vid_atom_get_irq_mask() & (~irq_removed); for(i=0; i<vid_atom_notify_ndx; i++) { mask |= vid_atom_notify[i].mask; } vid_atom_set_irq_mask(mask); } os_leave_critical_section(state); return(rc); }
/*----------------------------------------------------------------------------+ | vid_atom_ttx_add_notify | NOTE: FOR USE WITH TTX DRIVER ONLY!!! +----------------------------------------------------------------------------*/ int vid_atom_ttx_add_notify(void(*fn)(unsigned int intreq),unsigned int mask) { int state; int i; if(mask & ~VID_NOTIFY_VALID_MASK || fn == 0) return(-1); state = os_enter_critical_section(); /*--------------------------------------------------------------------------+ | Test if notify function is already installed | If it is, "OR" the new mask with mask already installed +--------------------------------------------------------------------------*/ for(i=0; i<vid_atom_notify_ndx; i++) { if(vid_atom_notify[i].fn == fn) { vid_atom_notify[i].mask |= mask; vid_atom_set_irq_mask(mask | vid_atom_get_irq_mask()); os_leave_critical_section(state); return(0); /* max no notify functions reached */ } } /*--------------------------------------------------------------------------+ | see if maximum number of notify functions has been reached +--------------------------------------------------------------------------*/ if(i >= VID_NOTIFY_MAX) { os_leave_critical_section(state); return(-1); /* max no notify functions reached */ } /*--------------------------------------------------------------------------+ | Add new Notify Function to end of list +--------------------------------------------------------------------------*/ vid_atom_notify[i].fn = fn; vid_atom_notify[i].mask = mask; vid_atom_set_irq_mask(mask | vid_atom_get_irq_mask()); vid_atom_notify_ndx++; os_leave_critical_section(state); return(0); }
/***************************************************************************** ** Function: sci_osi_set_para_check ** ** Purpose: Set the current Smart Card parameters of check. ** ** Parameters: sci_id: zero-based number to identify smart card controller ** p_sci_parameters: input pointer to Smart Card parameters ** ** Returns: SCI_ERROR_OK: if successful ** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid or ** p_sci_parameters is zero. *****************************************************************************/ SCI_ERROR sci_osi_set_para_check(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters) { SCI_ERROR rc = SCI_ERROR_OK; ULONG k_state; if((p_sci_parameters->check == 1) || (p_sci_parameters->check == 2)) { if(sci_cb[sci_id].sci_parameters.check != p_sci_parameters->check) { k_state=os_enter_critical_section(); sci_atom_set_para_check(sci_id, p_sci_parameters); os_leave_critical_section(k_state); } } else { rc=SCI_ERROR_PARAMETER_OUT_OF_RANGE; } return(rc); }
/***************************************************************************** ** Function: sci_osi_set_para_EGT ** ** Purpose: Set the current Smart Card parameters of EGT. ** ** Parameters: sci_id: zero-based number to identify smart card controller ** p_sci_parameters: input pointer to Smart Card parameters ** ** Returns: SCI_ERROR_OK: if successful ** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid or ** p_sci_parameters is zero. *****************************************************************************/ SCI_ERROR sci_osi_set_para_EGT(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters) { SCI_ERROR rc = SCI_ERROR_OK; ULONG k_state; if((p_sci_parameters->EGT >= SCI_MIN_EGT) && (p_sci_parameters->EGT <= SCI_MAX_EGT)) { if(sci_cb[sci_id].sci_parameters.EGT != p_sci_parameters->EGT) { k_state = os_enter_critical_section(); sci_atom_set_para_EGT(sci_id, p_sci_parameters); os_leave_critical_section(k_state); } } else { rc=SCI_ERROR_PARAMETER_OUT_OF_RANGE; } return(rc); }
/***************************************************************************** ** Function: sci_osi_set_para_T ** ** Purpose: Set the current Smart Card parameters of T. ** ** Parameters: sci_id: zero-based number to identify smart card controller ** p_sci_parameters: input pointer to Smart Card parameters ** ** Returns: SCI_ERROR_OK: if successful ** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid or ** p_sci_parameters is zero. **************************************************************************/ SCI_ERROR sci_osi_set_para_T(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters) { SCI_ERROR rc = SCI_ERROR_OK; ULONG k_state; /* set the protocol T=0 or 1 of sci */ if((p_sci_parameters->T == 0) || (p_sci_parameters->T == 1)) { if(sci_cb[sci_id].sci_parameters.T != p_sci_parameters->T) { k_state = os_enter_critical_section(); sci_atom_set_para_T(sci_id, p_sci_parameters); os_leave_critical_section(k_state); } } else { rc=SCI_ERROR_PARAMETER_OUT_OF_RANGE; } return(rc); }
/***************************************************************************** ** Function: sci_osi_set_para_f ** ** Purpose: Set the current Smart Card parameters of f. ** ** Parameters: sci_id: zero-based number to identify smart card controller ** p_sci_parameters: input pointer to Smart Card parameters ** ** Returns: SCI_ERROR_OK: if successful ** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid or ** p_sci_parameters is zero. *****************************************************************************/ SCI_ERROR sci_osi_set_para_f(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters) { SCI_ERROR rc = SCI_ERROR_OK; ULONG k_state; /* set the f of sci */ if((p_sci_parameters->f >= SCI_MIN_F) && (p_sci_parameters->f <= SCI_MAX_F) && (p_sci_parameters->f <= (__STB_SYS_CLK / 2))) { if(sci_cb[sci_id].sci_parameters.f != p_sci_parameters->f) { k_state = os_enter_critical_section(); sci_atom_set_para_f(sci_id, p_sci_parameters); os_leave_critical_section(k_state); } } else { rc=SCI_ERROR_PARAMETER_OUT_OF_RANGE; } return(rc); }
/** * @brief This function processes the received buffer * * @param adapter A pointer to mlan_adapter * @param pmbuf A pointer to the received buffer * * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE */ mlan_status wlan_ops_sta_process_rx_packet(IN t_void * adapter, IN pmlan_buffer pmbuf) { pmlan_adapter pmadapter = (pmlan_adapter) adapter; mlan_status ret = MLAN_STATUS_SUCCESS; RxPD *prx_pd; RxPacketHdr_t *prx_pkt; pmlan_private priv = pmadapter->priv[pmbuf->bss_index]; t_u8 ta[MLAN_MAC_ADDR_LENGTH]; t_u16 rx_pkt_type = 0; /* wlan_mgmt_pkt *pmgmt_pkt_hdr = MNULL; */ ENTER(); prx_pd = (RxPD *) (pmbuf->pbuf + pmbuf->data_offset); /* Endian conversion */ endian_convert_RxPD(prx_pd); rx_pkt_type = prx_pd->rx_pkt_type; /* Note: We do not have data @ some offset of pbuf. pbuf only has RxPD */ /* prx_pkt = (RxPacketHdr_t *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset); */ prx_pkt = (RxPacketHdr_t *) pmbuf->pdesc; /* wmprintf("%p + %d: O: %d PL: %d DL: %d\n\r", */ /* pmbuf->pbuf, pmbuf->data_offset, */ /* prx_pd->rx_pkt_offset, prx_pd->rx_pkt_length, pmbuf->data_len); */ if ((prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length) > (t_u16) pmbuf->data_len) { PRINTM(MERROR, "Wrong rx packet: len=%d,rx_pkt_offset=%d," " rx_pkt_length=%d\n", pmbuf->data_len, prx_pd->rx_pkt_offset, prx_pd->rx_pkt_length); pmbuf->status_code = MLAN_ERROR_PKT_SIZE_INVALID; ret = MLAN_STATUS_FAILURE; wlan_free_mlan_buffer(pmadapter, pmbuf); goto done; } pmbuf->data_len = prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length; if (pmadapter->priv[pmbuf->bss_index]->mgmt_frame_passthru_mask && prx_pd->rx_pkt_type == PKT_TYPE_MGMT_FRAME) { /* Check if this is mgmt packet and needs to forwarded to app as an event */ /* fixme */ wmprintf("Is a management packet expected here?\n\r"); os_enter_critical_section(); while(1){} #ifndef CONFIG_MLAN_WMSDK /* Note: We do not have data @ some offset of pbuf. pbuf only has RxPD */ /* pmgmt_pkt_hdr = */ /* (wlan_mgmt_pkt *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset); */ pmgmt_pkt_hdr = (wlan_mgmt_pkt *)pmbuf->pdesc; pmgmt_pkt_hdr->frm_len = wlan_le16_to_cpu(pmgmt_pkt_hdr->frm_len); if ((pmgmt_pkt_hdr->wlan_header.frm_ctl & IEEE80211_FC_MGMT_FRAME_TYPE_MASK) == 0) wlan_process_802dot11_mgmt_pkt(pmadapter->priv[pmbuf->bss_index], (t_u8 *) & pmgmt_pkt_hdr-> wlan_header, pmgmt_pkt_hdr->frm_len + sizeof(wlan_mgmt_pkt) - sizeof(pmgmt_pkt_hdr->frm_len)); wlan_free_mlan_buffer(pmadapter, pmbuf); goto done; #endif /* CONFIG_MLAN_WMSDK */ } #ifdef DUMP_PACKET_MAC dump_mac_addr("Own: ", priv->curr_addr); dump_mac_addr("Dest: ", prx_pkt->eth803_hdr.dest_addr); #endif /* DUMP_PACKET_MAC */ /* * If the packet is not an unicast packet then send the packet * directly to os. Don't pass thru rx reordering */ if (!IS_11N_ENABLED(priv) || memcmp(priv->adapter, priv->curr_addr, prx_pkt->eth803_hdr.dest_addr, MLAN_MAC_ADDR_LENGTH)) { wlan_process_rx_packet(pmadapter, pmbuf); goto done; } if (queuing_ra_based(priv)) { memcpy(pmadapter, ta, prx_pkt->eth803_hdr.src_addr, MLAN_MAC_ADDR_LENGTH); } else { if ((rx_pkt_type != PKT_TYPE_BAR) && (prx_pd->priority < MAX_NUM_TID)) priv->rx_seq[prx_pd->priority] = prx_pd->seq_num; memcpy(pmadapter, ta, priv->curr_bss_params.bss_descriptor.mac_address, MLAN_MAC_ADDR_LENGTH); } /* Reorder and send to OS */ if ((ret = mlan_11n_rxreorder_pkt(priv, prx_pd->seq_num, prx_pd->priority, ta, (t_u8) prx_pd->rx_pkt_type, (void *) pmbuf)) || (rx_pkt_type == PKT_TYPE_BAR) ) { wlan_free_mlan_buffer(pmadapter, pmbuf); } done: LEAVE(); return (ret); }
int osd_atom_set_display_control(STB_OSD_DISPLAY_CONTROL_T cntl, UINT uAttr) { UINT32 flags; if(OSD_CNTL_BACKCOLOR == cntl) { UINT32 uDispM = MF_DCR(DCR_VID0_DISP_MODE); MT_DCR(DCR_VID0_DISP_MODE, ((uDispM&0xffff) | uAttr << 16)); } else { UINT32 uCntlReg = MF_DCR(DCR_VID0_OSD_MODE); PDEBUG("Control = 0x%8.8x, attr = 0x%8.8x, OSD_MODE = 0x%8.8x -> ", (UINT)cntl, uAttr, uCntlReg); switch(cntl) { case OSD_CNTL_AFVP: // Anti-flicker video plane, 0 disable, 1 enable uCntlReg = (uCntlReg & 0xffff7fff) | (uAttr ? 0x00008000 : 0); break; case OSD_CNTL_EDAF: // Enable display anti-flicker, 0 disable, 1 enable uCntlReg = (uCntlReg & 0xffdfffff) | (uAttr ? 0x00200000 : 0); break; case OSD_CNTL_AFDT: // Anti-flicker detection threshold, 2 bits attr uCntlReg = (uCntlReg & 0xfff3ffff) | ((uAttr&0x03) << 18); break; case OSD_CNTL_VPAFC: // Video plane anti-flicker correction, 2 bits attr uCntlReg = (uCntlReg & 0xfffcffff) | ((uAttr&0x03) << 16); break; case OSD_CNTL_E32BCO: // Enable 32bit color option, 0 no, 1 yes uCntlReg = (uCntlReg & 0xffefffff) | (uAttr ? 0x00100000 : 0); break; case OSD_CNTL_ANIM: // Animation mode, 0 no, 1 yes if(uAttr != 0) { // enable OSD animation interrupts from video decoder flags = os_enter_critical_section(); MT_DCR(VID_MASK, MF_DCR(VID_MASK) | DECOD_HOST_INT_OSD_DATA); os_leave_critical_section(flags); } else { // disable OSD animation interrupts from video decoder flags = os_enter_critical_section(); MT_DCR(VID_MASK, MF_DCR(VID_MASK) & ~DECOD_HOST_INT_OSD_DATA); os_leave_critical_section(flags); } uCntlReg = (uCntlReg & 0xfffffff7) | (uAttr ? 0x00000008 : 0); break; case OSD_CNTL_ANIMR: // Animation rate, 3 bits attr uCntlReg = (uCntlReg & 0xfffffff8) | (uAttr & 0x07); break; case OSD_CNTL_CHFSR: // Custom horizontal FIR scaling ratio, 9 bits attr -- BJC 102102 uCntlReg = (uCntlReg & 0x007fffff) | ((uAttr & 0x1ff) << 23); break; case OSD_CNTL_BACKCOLOR: // to get rid of compiler warning break; } PDEBUG(" 0x%8.8x\n", uCntlReg); MT_DCR(DCR_VID0_OSD_MODE, uCntlReg); } return 0; }