Ejemplo n.º 1
0
int process_send_cmd(struct psh_ia_priv *psh_ia_data,
			int ch, struct ia_cmd *cmd, int len)
{
	int i, j;
	int ret = 0;
	u8 *pcmd = (u8 *)cmd;
	struct psh_msg in;

	if (ch == PSH2IA_CHANNEL0 && cmd->cmd_id == CMD_RESET) {
		intel_psh_ipc_disable_irq();
		ia_lbuf_read_reset(psh_ia_data->lbuf);
	}

	/* map from virtual channel to real channel */
	ch = ch - PSH2IA_CHANNEL0 + PSH_SEND_CH0;

	for (i = 0; i < len; i += 7) {
		u8 left = len - i;
		u8 *ptr = (u8 *)&in;

		memset(&in, 0, sizeof(in));

		if (left > 7) {
			left = 7;
			in.msg |= PSH_IPC_CONTINUE;
		}

		for (j = 0; j < left; j++) {
			if (j == 3)
				ptr++;
			*ptr = *pcmd;
			ptr++;
			pcmd++;
		}

		ret = intel_ia2psh_command(&in, NULL, ch, 1000000);
		if (ret) {
			psh_err("sendcmd %d by IPC %d failed!, ret=%d\n",
					cmd->cmd_id, ch, ret);
			ret = -EIO;
			goto f_out;
		}
	}

f_out:
	if (ch == PSH2IA_CHANNEL0 && cmd->cmd_id == CMD_RESET)
		intel_psh_ipc_enable_irq();
	return ret;
}
Ejemplo n.º 2
0
static int send_cmd(struct mcu_data *data,
		struct psh_msg *in, int ch, int wait)
{
	int ret;
	ret = intel_ia2psh_command(in, NULL, ch, 1000000);
	if (ret)
		return ret;

	if (wait) {
		ret = wait_for_completion_timeout(&data->cmp, 3 * HZ);
		if (ret == 0)
			return -ETIME;
	}

	return 0;
}