static int adie_svc_rpc_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int rc = 0; struct rpc_request_hdr *req; req = (struct rpc_request_hdr *)buffer; MM_DBG("procedure received to rpc cb %d\n", be32_to_cpu(req->procedure)); switch (be32_to_cpu(req->procedure)) { case ADIE_SVC_CLIENT_STATUS_FUNC_PTR_TYPE_PROC: rc = adie_svc_process_cb(client, buffer, in_size); break; default: MM_ERR("%s: procedure not supported %d\n", __func__, be32_to_cpu(req->procedure)); msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_PROC_UNAVAIL); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) MM_ERR("%s: sending reply failed: %d\n", __func__, rc); break; } return rc; }
static int hs_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int rc = -1; struct rpc_request_hdr *hdr = buffer; hdr->type = be32_to_cpu(hdr->type); hdr->xid = be32_to_cpu(hdr->xid); hdr->rpc_vers = be32_to_cpu(hdr->rpc_vers); hdr->prog = be32_to_cpu(hdr->prog); hdr->vers = be32_to_cpu(hdr->vers); hdr->procedure = be32_to_cpu(hdr->procedure); process_hs_rpc_request(hdr->procedure, (void *) (hdr + 1)); msm_rpc_start_accepted_reply(client, hdr->xid, RPC_ACCEPTSTAT_SUCCESS); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) { pr_err("%s: sending reply failed: %d\n", __func__, rc); return rc; } return 0; }
static int pcm_interface_process_callback_routine(struct msm_rpc_client *client, void *buffer, int in_size) { struct rpc_request_hdr *req; struct audio *audio = &the_audio; int rc = 0; req = (struct rpc_request_hdr *)buffer; MM_DBG("proc id = 0x%8x xid = 0x%8x size = 0x%8x\n", be32_to_cpu(req->procedure), be32_to_cpu(req->xid), in_size); switch (be32_to_cpu(req->procedure)) { /* Procedure which called every 20ms for PCM samples request*/ case SND_VOC_PCM_CLIENT_INPUT_FN_TYPE_PROC: process_callback(audio, buffer, in_size); break; default: MM_ERR("Not supported proceudure 0x%8x\n", be32_to_cpu(req->procedure)); /* Not supported RPC Procedure, send nagative code */ msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_PROC_UNAVAIL); msm_rpc_send_accepted_reply(client, 0); } return rc; }
static int vbus_notification_cb(struct msm_rpc_client *client, void *buffer, int in_size) { struct vbus_sn_notification_args *args; struct rpc_request_hdr *req = buffer; int rc; uint32_t accept_status; void (*cb_func)(int); uint32_t cb_id; int vbus; args = (struct vbus_sn_notification_args *) (req + 1); cb_id = be32_to_cpu(args->cb_id); vbus = be32_to_cpu(args->vbus); cb_func = msm_rpc_get_cb_func(client, cb_id); if (cb_func) { cb_func(!vbus); accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static int ping_mdm_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int rc = 0; struct rpc_request_hdr *req; req = (struct rpc_request_hdr *)buffer; switch (be32_to_cpu(req->procedure)) { case PING_MDM_CB_PROC: rc = ping_mdm_register_cb(client, buffer, in_size); break; case PING_MDM_DATA_CB_PROC: rc = ping_mdm_data_cb(client, buffer, in_size); break; default: pr_err("%s: procedure not supported %d\n", __func__, be32_to_cpu(req->procedure)); msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_PROC_UNAVAIL); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); break; } return rc; }
static int ping_mdm_register_cb(struct msm_rpc_client *client, void *buffer, int in_size) { int rc; uint32_t accept_status; struct rpc_request_hdr *req; struct ping_mdm_register_cb_arg arg, *buf_ptr; void *cb_func; req = (struct rpc_request_hdr *)buffer; buf_ptr = (struct ping_mdm_register_cb_arg *)(req + 1); arg.cb_id = be32_to_cpu(buf_ptr->cb_id); arg.val = be32_to_cpu(buf_ptr->val); cb_func = msm_rpc_get_cb_func(client, arg.cb_id); if (cb_func) { rc = ((int (*)(struct ping_mdm_register_cb_arg *, void *)) cb_func)(&arg, NULL); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static int msm_lightsensor_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int rc = 0; struct rpc_request_hdr *req; u32 procedure; u32 accept_status; req = (struct rpc_request_hdr *)buffer; procedure = be32_to_cpu(req->procedure); switch (procedure) { case LIGHTSENSOR_CB_TYPE_PROC: accept_status = RPC_ACCEPTSTAT_SUCCESS; break; default: accept_status = RPC_ACCEPTSTAT_PROC_UNAVAIL; pr_err("%s: ERROR. procedure (%d) not supported\n", __func__, procedure); break; } msm_rpc_start_accepted_reply(light_client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(light_client, 0); if (rc) pr_err("%s: FAIL: sending reply. rc=%d\n", __func__, rc); /*if (accept_status == RPC_ACCEPTSTAT_SUCCESS) msm_batt_update_psy_status();*/ return rc; }
/* Server will Callback this function and reply procedure code for checking it*/ static int batt_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int ret = 0; struct rpc_request_hdr *req; req = (struct rpc_request_hdr *)buffer; switch (be32_to_cpu(req->procedure)) { case CHARGER_NOTIFY_CB_PROC: schedule_work(&battery_data->work); pr_info("[BATT] batt_cb_func start +++++++++++ \n"); msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_SUCCESS); pr_info("[BATT] msm_rpc_send_accepted_reply start \n"); ret = msm_rpc_send_accepted_reply(client, 0); pr_info("[BATT] msm_rpc_send_accepted_reply done \n"); if (ret) pr_err("[BATT] msm_rpc_send_accepted_reply error \n"); break; default: pr_err("[BATT] %s: procedure not supported %d\n", __func__, be32_to_cpu(req->procedure)); break; } pr_info("[BATT] batt_cb_func finish ---------\n"); return ret; }
static int msmrtc_cb_func(struct msm_rpc_client *client, void *buffer, int size) { int rc = -1; struct rpc_request_hdr *recv = buffer; recv->xid = be32_to_cpu(recv->xid); recv->type = be32_to_cpu(recv->type); recv->rpc_vers = be32_to_cpu(recv->rpc_vers); recv->prog = be32_to_cpu(recv->prog); recv->vers = be32_to_cpu(recv->vers); recv->procedure = be32_to_cpu(recv->procedure); if (recv->procedure == RTC_EVENT_CB_PROC) process_cb_request((void *) (recv + 1)); msm_rpc_start_accepted_reply(client, recv->xid, RPC_ACCEPTSTAT_SUCCESS); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) { pr_debug("%s: sending reply failed: %d\n", __func__, rc); return rc; } return 0; }
static int ping_mdm_data_cb(struct msm_rpc_client *client, void *buffer, int in_size) { struct rpc_request_hdr *req; int rc, i; void *buf, *cb_func, *reply; uint32_t size, accept_status; struct ping_mdm_register_data_cb_cb_arg arg; struct ping_mdm_register_data_cb_cb_ret ret; req = (struct rpc_request_hdr *)buffer; buf = (void *)(req + 1); arg.cb_id = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (size) { arg.data = kmalloc((size * sizeof(*arg.data)), GFP_KERNEL); if (arg.data) for (i = 0; i < size; i++) arg.data[i] = be32_to_cpu(*((uint32_t *)buf + i)); } buf += sizeof(uint32_t) * size; arg.size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); arg.sum = be32_to_cpu(*(uint32_t *)buf); cb_func = msm_rpc_get_cb_func(client, arg.cb_id); if (cb_func) { rc = ((int (*) (struct ping_mdm_register_data_cb_cb_arg *, struct ping_mdm_register_data_cb_cb_ret *)) cb_func)(&arg, &ret); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; reply = msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); size = 0; if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { *(uint32_t *)reply = cpu_to_be32(ret.result); size = sizeof(uint32_t); } rc = msm_rpc_send_accepted_reply(client, size); if (rc) pr_err("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static int msm_fsusb_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { struct rpc_request_hdr *req; int rc; req = buffer; msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_SUCCESS); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) { pr_err("%s: sending reply failed: %d\n", __func__, rc); return rc; } switch (be32_to_cpu(req->procedure)) { case PM_APP_OTG_INIT_DONE_CB_PROC: { pr_debug("pm_app_otg_init_done callback received"); msm_fsusb_request_session(); break; } case PM_APP_OTG_HOST_INIT_CB_PROC: { pr_debug("pm_app_otg_host_init_cb_proc callback received"); host_ops->request(host_ops->handle, REQUEST_START); break; } case PM_APP_OTG_REMOTE_DEV_LOST_CB_PROC: { pr_debug("pm_app_otg_remote_dev_lost_cb_proc" " callback received"); msm_fsusb_acquire_bus(); host_ops->request(host_ops->handle, REQUEST_STOP); break; } case PM_APP_OTG_REMOTE_DEV_RESUMED_CB_PROC: { pr_debug("pm_app_otg_remote_dev_resumed_cb_proc" "callback received"); host_ops->request(host_ops->handle, REQUEST_RESUME); break; } case PM_APP_OTG_ERROR_NOTIFY_CB_PROC: { pr_err("pm_app_otg_error_notify_cb_proc callback received"); break; } default: pr_err("%s: unknown callback(proc = %d) received\n", __func__, req->procedure); } return 0; }
static int pm_app_usb_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) { int rc; struct rpc_request_hdr *req = buffer; switch (be32_to_cpu(req->procedure)) { case VBUS_SESS_VALID_CB_PROC: rc = vbus_notification_cb(client, buffer, in_size); break; default: pr_err("%s: procedure not supported %d\n", __func__, be32_to_cpu(req->procedure)); msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), RPC_ACCEPTSTAT_PROC_UNAVAIL); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); break; } return rc; }
static int adie_svc_process_cb(struct msm_rpc_client *client, void *buffer, int in_size) { int rc, id; uint32_t accept_status; struct rpc_request_hdr *req; struct adie_svc_client_register_cb_cb_args arg, *buf_ptr; req = (struct rpc_request_hdr *)buffer; for (id = 0; id < ADIE_SVC_MAX_CLIENTS; id++) { if (adie_client[id].rpc_client == client) break; } if (id == ADIE_SVC_MAX_CLIENTS) { MM_ERR("RPC reply with invalid rpc client\n"); accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto err; } buf_ptr = (struct adie_svc_client_register_cb_cb_args *)(req + 1); arg.cb_id = be32_to_cpu(buf_ptr->cb_id); arg.size = be32_to_cpu(buf_ptr->size); arg.client_id = be32_to_cpu(buf_ptr->client_id); arg.adie_block = be32_to_cpu(buf_ptr->adie_block); arg.status = be32_to_cpu(buf_ptr->status); arg.client_operation = be32_to_cpu(buf_ptr->client_operation); if (arg.cb_id != adie_client[id].cb_id) { MM_ERR("RPC reply with invalid invalid cb_id\n"); accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto err; } mutex_lock(&adie_client[id].lock); switch (arg.client_operation) { case ADIE_SVC_REGISTER_CLIENT: MM_DBG("ADIE_SVC_REGISTER_CLIENT callback\n"); adie_client[id].client_id = arg.client_id; break; case ADIE_SVC_DEREGISTER_CLIENT: MM_DBG("ADIE_SVC_DEREGISTER_CLIENT callback\n"); break; case ADIE_SVC_CONFIG_ADIE_BLOCK: MM_DBG("ADIE_SVC_CONFIG_ADIE_BLOCK callback\n"); if (adie_client[id].client_id != arg.client_id) { mutex_unlock(&adie_client[id].lock); accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto err; } break; default: accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto err; } adie_client[id].status = arg.status; adie_client[id].adie_svc_cb_done = 1; mutex_unlock(&adie_client[id].lock); wake_up(&adie_client[id].wq); accept_status = RPC_ACCEPTSTAT_SUCCESS; err: msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); rc = msm_rpc_send_accepted_reply(client, 0); if (rc) MM_ERR("%s: send accepted reply failed: %d\n", __func__, rc); return rc; }
static void process_callback(struct audio *audio, void *buffer, int in_size) { uint32_t accept_status = RPC_ACCEPTSTAT_SUCCESS; struct rpc_request_hdr *req; struct snd_voice_pcm_interface_ipclnt_fn_type_args arg, *buf_ptr; struct snd_voice_pcm_interface_ipclnt_fn_type_reply *reply; struct buffer *frame; uint32_t status; uint32_t pcm_data_len; req = (struct rpc_request_hdr *)buffer; buf_ptr = (struct snd_voice_pcm_interface_ipclnt_fn_type_args *)\ (req + 1); arg.callback_id = be32_to_cpu(buf_ptr->callback_id); arg.pcm_data_ptr_not_null = be32_to_cpu(buf_ptr->pcm_data_ptr_not_null); arg.pcm_data_max_length = be32_to_cpu(buf_ptr->pcm_data_max_length); MM_DBG("callback_id = 0x%8x pcm_data_ptr_not_null = 0x%8x"\ "pcm_data_max_length = 0x%8x\n", arg.callback_id,\ arg.pcm_data_ptr_not_null, arg.pcm_data_max_length); /* Flag interface as running */ if (!audio->running) audio->running = 1; if (!arg.pcm_data_ptr_not_null) { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; msm_rpc_start_accepted_reply(audio->client, be32_to_cpu(req->xid), accept_status); msm_rpc_send_accepted_reply(audio->client, 0); return; } reply = (struct snd_voice_pcm_interface_ipclnt_fn_type_reply *) msm_rpc_start_accepted_reply(audio->client, be32_to_cpu(req->xid), accept_status); frame = audio->out + audio->out_tail; /* If Data available, send data */ if (frame->used) { int i; unsigned short *src = frame->data; atomic_add(frame->used, &audio->out_bytes); status = VOICE_PCM_DATA_STATUS_AVAILABLE; pcm_data_len = MAX_VOC_FRAME_SIZE; xdr_send_int32(&audio->client->cb_xdr, &status); xdr_send_int32(&audio->client->cb_xdr, &pcm_data_len); /* Expected cb_xdr buffer size is more than PCM buffer size */ for (i = 0; i < MAX_VOC_FRAME_SIZE; i++, ++src) xdr_send_int16(&audio->client->cb_xdr, src); frame->used = 0; audio->out_tail = ((++audio->out_tail) % MAX_VOC_FRAMES); wake_up(&audio->wait); } else { status = VOICE_PCM_DATA_STATUS_UNAVAILABLE; pcm_data_len = 0; xdr_send_int32(&audio->client->cb_xdr, &status); xdr_send_int32(&audio->client->cb_xdr, &pcm_data_len); wake_up(&audio->wait); /* Flag all buffer completed */ if (audio->stopped) { audio->buffer_finished = 1; wake_up(&audio->stop_wait); } } MM_DBG("Provided PCM data = 0x%8x\n", reply->status); msm_rpc_send_accepted_reply(audio->client, 0); return; }
static int oem_rapi_client_cb(struct msm_rpc_client *client, void *buffer, int in_size) { struct rpc_request_hdr *req; void *buf, *cb_func, *reply; uint32_t cb_id, accept_status, size; int rc; struct oem_rapi_client_streaming_func_cb_arg arg; struct oem_rapi_client_streaming_func_cb_ret ret; arg.input = NULL; ret.out_len = NULL; ret.output = NULL; req = (struct rpc_request_hdr *)buffer; buf = (void *)(req + 1); /* cb_id */ cb_id = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* enum */ arg.event = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* handle */ arg.handle = (void *)be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* in_len */ arg.in_len = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); /* input */ size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (size) { arg.input = kmalloc(size, GFP_KERNEL); if (arg.input) memcpy(arg.input, buf, size); else { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } buf += size; if (size & 0x3) buf += 4 - (size & 0x3); /* out_len */ arg.out_len_valid = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (arg.out_len_valid) { ret.out_len = kmalloc(sizeof(*ret.out_len), GFP_KERNEL); if (!ret.out_len) { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } /* out */ arg.output_valid = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); if (arg.output_valid) { arg.output_size = be32_to_cpu(*(uint32_t *)buf); buf += sizeof(uint32_t); ret.output = kmalloc(arg.output_size, GFP_KERNEL); if (!ret.output) { accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; goto oem_rapi_send_ack; } } cb_func = msm_rpc_get_cb_func(client, cb_id); if (cb_func) { rc = ((int (*)(struct oem_rapi_client_streaming_func_cb_arg *, struct oem_rapi_client_streaming_func_cb_ret *)) cb_func)(&arg, &ret); if (rc) accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; else accept_status = RPC_ACCEPTSTAT_SUCCESS; } else accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; oem_rapi_send_ack: reply = msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), accept_status); size = 0; if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { *(uint32_t *)reply = cpu_to_be32((uint32_t)(ret.out_len != 0)); reply += sizeof(uint32_t); size += sizeof(uint32_t); if (ret.out_len) { *(uint32_t *)reply = cpu_to_be32(*ret.out_len); reply += sizeof(uint32_t); size += sizeof(uint32_t); } if (ret.output && ret.out_len) { *(uint32_t *)reply = cpu_to_be32((uint32_t)(*ret.out_len)); reply += sizeof(uint32_t); size += sizeof(uint32_t); memcpy(reply, ret.output, *ret.out_len); reply += *ret.out_len; size += *ret.out_len; if (*ret.out_len & 0x3) { memset(reply, 0, 4 - (*ret.out_len & 0x3)); reply += 4 - (*ret.out_len & 0x3); size += 4 - (*ret.out_len & 0x3); } } else { *(uint32_t *)reply = cpu_to_be32(0); reply += sizeof(uint32_t); size += sizeof(uint32_t); } } rc = msm_rpc_send_accepted_reply(client, size); if (rc) pr_err("%s: sending reply failed: %d\n", __func__, rc); kfree(arg.input); kfree(ret.out_len); kfree(ret.output); return 0; }