static void sms_ir_rc5_event(struct smscore_device_t *coredev, u32 toggle, u32 addr, u32 cmd) { bool toggle_changed; u16 keycode; sms_log("IR RC5 word: address %d, command %d, toggle %d", addr, cmd, toggle); toggle_changed = ir_toggle != toggle; /* keep toggle */ ir_toggle = toggle; if (addr != keyboard_layout_maps[coredev->ir.ir_kb_type].rc5_kbd_address) return; /* Check for valid address */ keycode = keyboard_layout_maps [coredev->ir.ir_kb_type].keyboard_layout_map[cmd]; if (!toggle_changed && (keycode != KEY_VOLUMEUP && keycode != KEY_VOLUMEDOWN)) return; /* accept only repeated volume, reject other keys */ sms_log("kernel input keycode (from ir) %d", keycode); input_report_key(coredev->ir.input_dev, keycode, 1); input_sync(coredev->ir.input_dev); }
CDF_STATUS sme_remain_on_chn_ready(tHalHandle hHal, uint8_t *pMsg) { tpAniSirGlobal pMac = PMAC_STRUCT(hHal); CDF_STATUS status = CDF_STATUS_SUCCESS; tListElem *pEntry = NULL; tSmeCmd *pCommand = NULL; tCsrRoamInfo RoamInfo; struct sir_roc_rsp *rsp = (struct sir_roc_rsp *)pMsg; csr_get_active_scan_entry(pMac, rsp->scan_id, &pEntry); if (!pEntry) { sms_log(pMac, LOGE, FL("No cmd found in active list.")); return status; } sms_log(pMac, LOG1, FL("Ready Ind %d %d"), rsp->session_id, rsp->scan_id); pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); if (eSmeCommandRemainOnChannel == pCommand->command) { RoamInfo.roc_scan_id = rsp->scan_id; /* forward the indication to HDD */ RoamInfo.pRemainCtx = pCommand->u.remainChlCmd.callbackCtx; csr_roam_call_callback(pMac, rsp->session_id, &RoamInfo, 0, eCSR_ROAM_REMAIN_CHAN_READY, 0); } return status; }
CDF_STATUS p2p_process_remain_on_channel_cmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn) { CDF_STATUS status = CDF_STATUS_E_FAILURE; tSirRemainOnChnReq *pMsg; uint32_t len; tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, p2pRemainonChn->sessionId); if (!pSession) { sms_log(pMac, LOGE, FL(" session %d not found "), p2pRemainonChn->sessionId); goto error; } if (!pSession->sessionActive) { sms_log(pMac, LOGE, FL(" session %d is invalid or listen is disabled "), p2pRemainonChn->sessionId); goto error; } len = sizeof(tSirRemainOnChnReq) + pMac->p2pContext.probeRspIeLength; if (len > 0xFFFF) { /*In coming len for Msg is more then 16bit value */ sms_log(pMac, LOGE, FL(" Message length is very large, %d"), len); goto error; } pMsg = cdf_mem_malloc(len); if (NULL == pMsg) goto error; else { CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, "%s call", __func__); cdf_mem_set(pMsg, sizeof(tSirRemainOnChnReq), 0); pMsg->messageType = eWNI_SME_REMAIN_ON_CHANNEL_REQ; pMsg->length = (uint16_t) len; cdf_copy_macaddr(&pMsg->selfMacAddr, &pSession->selfMacAddr); pMsg->chnNum = p2pRemainonChn->u.remainChlCmd.chn; pMsg->phyMode = p2pRemainonChn->u.remainChlCmd.phyMode; pMsg->duration = p2pRemainonChn->u.remainChlCmd.duration; pMsg->sessionId = p2pRemainonChn->sessionId; pMsg->isProbeRequestAllowed = p2pRemainonChn->u.remainChlCmd.isP2PProbeReqAllowed; pMsg->scan_id = p2pRemainonChn->u.remainChlCmd.scan_id; if (pMac->p2pContext.probeRspIeLength) cdf_mem_copy((void *)pMsg->probeRspIe, (void *)pMac->p2pContext.probeRspIe, pMac->p2pContext.probeRspIeLength); status = cds_send_mb_message_to_mac(pMsg); } error: if (CDF_STATUS_E_FAILURE == status) csr_release_roc_req_cmd(pMac); return status; }
int sms_ir_init(struct smscore_device_t *coredev) { int err; int board_id = smscore_get_board_id(coredev); struct rc_dev *dev; sms_log("Allocating rc device"); dev = rc_allocate_device(); if (!dev) { sms_err("Not enough memory"); return -ENOMEM; } coredev->ir.controller = 0; coredev->ir.timeout = IR_DEFAULT_TIMEOUT; sms_log("IR port %d, timeout %d ms", coredev->ir.controller, coredev->ir.timeout); snprintf(coredev->ir.name, sizeof(coredev->ir.name), "SMS IR (%s)", sms_get_board(board_id)->name); strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys)); dev->input_name = coredev->ir.name; dev->input_phys = coredev->ir.phys; dev->dev.parent = coredev->device; #if 0 dev->input_id.bustype = BUS_USB; dev->input_id.version = 1; dev->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); dev->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct); #endif dev->priv = coredev; dev->driver_type = RC_DRIVER_IR_RAW; dev->allowed_protos = RC_TYPE_ALL; dev->map_name = sms_get_board(board_id)->rc_codes; dev->driver_name = MODULE_NAME; sms_log("Input device (IR) %s is set for key events", dev->input_name); err = rc_register_device(dev); if (err < 0) { sms_err("Failed to register device"); rc_free_device(dev); return err; } coredev->ir.dev = dev; return 0; }
void sms_ir_exit(struct smscore_device_t *coredev) { if (coredev->ir.dev) rc_unregister_device(coredev->ir.dev); sms_log(""); }
CDF_STATUS sme_mgmt_frm_ind(tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm) { tpAniSirGlobal pMac = PMAC_STRUCT(hHal); CDF_STATUS status = CDF_STATUS_SUCCESS; tCsrRoamInfo pRoamInfo = { 0 }; uint8_t i = 0; uint32_t SessionId = pSmeMgmtFrm->sessionId; pRoamInfo.nFrameLength = pSmeMgmtFrm->mesgLen - sizeof(tSirSmeMgmtFrameInd); pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf; pRoamInfo.frameType = pSmeMgmtFrm->frameType; pRoamInfo.rxChan = pSmeMgmtFrm->rxChan; pRoamInfo.rxRssi = pSmeMgmtFrm->rxRssi; if (CSR_IS_SESSION_ANY(SessionId)) { for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { if (CSR_IS_SESSION_VALID(pMac, i)) { SessionId = i; break; } } } if (i == CSR_ROAM_SESSION_MAX) { sms_log(pMac, LOGE, FL("No valid sessions found.")); return CDF_STATUS_E_FAILURE; } /* forward the mgmt frame to HDD */ csr_roam_call_callback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_INDICATE_MGMT_FRAME, 0); return status; }
CDF_STATUS sme_remain_on_chn_rsp(tpAniSirGlobal pMac, uint8_t *pMsg) { CDF_STATUS status = CDF_STATUS_SUCCESS; tListElem *pEntry = NULL; tSmeCmd *pCommand = NULL; bool fFound; remainOnChanCallback callback = NULL; struct sir_roc_rsp *rsp = (struct sir_roc_rsp *)pMsg; csr_get_active_scan_entry(pMac, rsp->scan_id, &pEntry); if (!pEntry) { sms_log(pMac, LOGE, FL("No cmd found in active list.")); return status; } pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); if (eSmeCommandRemainOnChannel != pCommand->command) return status; callback = pCommand->u.remainChlCmd.callback; if (callback) callback(pMac, pCommand->u.remainChlCmd.callbackCtx, rsp->status, rsp->scan_id); fFound = csr_ll_remove_entry(&pMac->sme.smeScanCmdActiveList, pEntry, LL_ACCESS_LOCK); if (fFound) { /* Now put this command back on the avilable command list */ sme_release_command(pMac, pCommand); } sme_process_pending_queue(pMac); return status; }
/* taken from ir-functions.c */ static u32 ir_rc5_decode(unsigned int code) { /* unsigned int org_code = code;*/ unsigned int pair; unsigned int rc5 = 0; int i; for (i = 0; i < 14; ++i) { pair = code & 0x3; code >>= 2; rc5 <<= 1; switch (pair) { case 0: case 2: break; case 1: rc5 |= 1; break; case 3: /* dprintk(1, "ir-common: ir_rc5_decode(%x) bad code\n", org_code);*/ sms_log("bad code"); return 0; } } /* dprintk(1, "ir-common: code=%x, rc5=%x, start=%x, toggle=%x, address=%x, " "instr=%x\n", rc5, org_code, RC5_START(rc5), RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5)); */ return rc5; }
void sms_ir_exit(struct smscore_device_t *coredev) { if (coredev->ir.input_dev) ir_input_unregister(coredev->ir.input_dev); sms_log(""); }
int sms_ir_init(struct smscore_device_t *coredev) { struct input_dev *input_dev; sms_log("Allocating input device"); input_dev = input_allocate_device(); if (!input_dev) { sms_err("Not enough memory"); return -ENOMEM; } coredev->ir.input_dev = input_dev; coredev->ir.ir_kb_type = sms_get_board(smscore_get_board_id(coredev))->ir_kb_type; coredev->ir.keyboard_layout_map = keyboard_layout_maps[coredev->ir.ir_kb_type]. keyboard_layout_map; sms_log("IR remote keyboard type is %d", coredev->ir.ir_kb_type); coredev->ir.controller = 0; /* Todo: vega/nova SPI number */ coredev->ir.timeout = IR_DEFAULT_TIMEOUT; sms_log("IR port %d, timeout %d ms", coredev->ir.controller, coredev->ir.timeout); snprintf(coredev->ir.name, IR_DEV_NAME_MAX_LEN, "SMS IR w/kbd type %d", coredev->ir.ir_kb_type); input_dev->name = coredev->ir.name; input_dev->phys = coredev->ir.name; input_dev->dev.parent = coredev->device; /* Key press events only */ input_dev->evbit[0] = BIT_MASK(EV_KEY); input_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); sms_log("Input device (IR) %s is set for key events", input_dev->name); if (input_register_device(input_dev)) { sms_err("Failed to register device"); input_free_device(input_dev); return -EACCES; } return 0; }
int sms_ir_init(struct smscore_device_t *coredev) { struct input_dev *input_dev; int board_id = smscore_get_board_id(coredev); sms_log("Allocating input device"); input_dev = input_allocate_device(); if (!input_dev) { sms_err("Not enough memory"); return -ENOMEM; } coredev->ir.input_dev = input_dev; coredev->ir.controller = 0; /* Todo: vega/nova SPI number */ coredev->ir.timeout = IR_DEFAULT_TIMEOUT; sms_log("IR port %d, timeout %d ms", coredev->ir.controller, coredev->ir.timeout); snprintf(coredev->ir.name, sizeof(coredev->ir.name), "SMS IR (%s)", sms_get_board(board_id)->name); strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys)); input_dev->name = coredev->ir.name; input_dev->phys = coredev->ir.phys; input_dev->dev.parent = coredev->device; coredev->ir.props.priv = coredev; coredev->ir.props.driver_type = RC_DRIVER_IR_RAW; coredev->ir.props.allowed_protos = IR_TYPE_ALL; sms_log("Input device (IR) %s is set for key events", input_dev->name); if (ir_input_register(input_dev, sms_get_board(board_id)->rc_codes, &coredev->ir.props, MODULE_NAME)) { sms_err("Failed to register device"); input_free_device(input_dev); return -EACCES; } return 0; }
/* --------------------------------------------------------------------------- \fn p2p_remain_on_channel \brief API to post the remain on channel command. \param hHal - The handle returned by mac_open. \param sessinId - HDD session ID. \param channel - Channel to remain on channel. \param duration - Duration for which we should remain on channel \param callback - callback function. \param pContext - argument to the callback function \return CDF_STATUS -------------------------------------------------------------------------------*/ CDF_STATUS p2p_remain_on_channel(tHalHandle hHal, uint8_t sessionId, uint8_t channel, uint32_t duration, remainOnChanCallback callback, void *pContext, uint8_t isP2PProbeReqAllowed, uint32_t scan_id) { CDF_STATUS status = CDF_STATUS_SUCCESS; tpAniSirGlobal pMac = PMAC_STRUCT(hHal); tSmeCmd *pRemainChlCmd = NULL; uint32_t phyMode; pRemainChlCmd = sme_get_command_buffer(pMac); if (pRemainChlCmd == NULL) return CDF_STATUS_E_FAILURE; if (SIR_BAND_5_GHZ == get_rf_band(channel)) { phyMode = WNI_CFG_PHY_MODE_11A; } else { phyMode = WNI_CFG_PHY_MODE_11G; } cfg_set_int(pMac, WNI_CFG_PHY_MODE, phyMode); do { /* call set in context */ pRemainChlCmd->command = eSmeCommandRemainOnChannel; pRemainChlCmd->sessionId = sessionId; pRemainChlCmd->u.remainChlCmd.chn = channel; pRemainChlCmd->u.remainChlCmd.duration = duration; pRemainChlCmd->u.remainChlCmd.isP2PProbeReqAllowed = isP2PProbeReqAllowed; pRemainChlCmd->u.remainChlCmd.callback = callback; pRemainChlCmd->u.remainChlCmd.callbackCtx = pContext; pRemainChlCmd->u.remainChlCmd.scan_id = scan_id; /* Put it at the head of the Q if we just finish finding the peer and ready to send a frame */ status = csr_queue_sme_command(pMac, pRemainChlCmd, false); } while (0); sms_log(pMac, LOGW, "exiting function %s", __func__); return (status); }
static void sms_rc5_accumulate_bits(struct smscore_device_t *coredev, s32 ir_sample) { #define RC5_TIME_GRANULARITY 200 #define RC5_DEF_BIT_TIME 889 #define RC5_MAX_SAME_BIT_CONT 4 #define RC5_WORD_LEN 27 /* 28 bit */ u32 i, j; s32 delta_time; u32 time = (ir_sample > 0) ? ir_sample : (0-ir_sample); u32 level = (ir_sample < 0) ? 0 : 1; for (i = RC5_MAX_SAME_BIT_CONT; i > 0; i--) { delta_time = time - (i*RC5_DEF_BIT_TIME) + RC5_TIME_GRANULARITY; if (delta_time < 0) continue; /* not so many consecutive bits */ if (delta_time > (2 * RC5_TIME_GRANULARITY)) { /* timeout */ if (ir_pos == (RC5_WORD_LEN-1)) /* complete last bit */ RC5_PUSH_BIT(ir_word, level, ir_pos) if (ir_pos == RC5_WORD_LEN) sms_rc5_parse_word(coredev); else if (ir_pos) /* timeout within a word */ sms_log("IR error parsing a word"); ir_pos = 0; ir_word = 0; /* sms_log("timeout %d", time); */ break; } /* The time is within the range of this number of bits */ for (j = 0 ; j < i ; j++) RC5_PUSH_BIT(ir_word, level, ir_pos) break; } }