static int htc_acdb_open(struct inode *inode, struct file *file)
{
	int reply_value = -1;
	int rc = -EIO;
	struct set_smem_req {
		struct rpc_request_hdr hdr;
		uint32_t size;
	} req_smem;

	struct set_smem_rep {
		struct rpc_reply_hdr hdr;
		int n;
	} rep_smem;

	D("open\n");

	mutex_lock(&api_lock);

	if (!htc_acdb_vir_addr) {
		if (is_rpc_connect() == -1)
			goto done;

		if (the_ops->get_smem_size)
			acdb_smem_size = the_ops->get_smem_size();
		else
			acdb_smem_size = HTC_DEF_ACDB_SMEM_SIZE;

		pr_info("%s: smem size %d\n", __func__, acdb_smem_size);

		req_smem.size = cpu_to_be32(acdb_smem_size);
		rep_smem.n = cpu_to_be32(reply_value);

		rc = msm_rpc_call_reply(endpoint,
					ONCRPC_ALLOC_ACDB_MEM_PROC,
					&req_smem, sizeof(req_smem),
					&rep_smem, sizeof(rep_smem),
					5 * HZ);

		reply_value = be32_to_cpu(rep_smem.n);
		if (reply_value != 0 || rc < 0) {
			E("open failed: ALLOC_ACDB_MEM_PROC error %d.\n", rc);
			goto done;
		}
		htc_acdb_vir_addr =
			(uint32_t)smem_alloc(SMEM_ID_VENDOR1,
					acdb_smem_size);
		if (!htc_acdb_vir_addr) {
			E("open failed: smem_alloc error\n");
			goto done;
		}
		htc_acdb_vir_addr = ((htc_acdb_vir_addr + 4095) & ~4095);
	}

	rc = 0;
done:
	mutex_unlock(&api_lock);
	return rc;
}
int set_aux_gain(int level)
{
	struct aux_gain_req {
		struct rpc_request_hdr hdr;
		int level;
	} aux_req;

	D("%s called %d\n", __func__, level);

	if (is_rpc_connect() == -1)
		return -1;

	aux_req.level = cpu_to_be32(level);
	return  msm_rpc_call(endpoint,
		ONCRPC_SET_AUX_PGA_GAIN_PROC,
		&aux_req, sizeof(aux_req), 5 * HZ);
}
int force_headset_speaker_on(int enable)
{
	struct speaker_headset_req {
		struct rpc_request_hdr hdr;
		uint32_t enable;
	} spkr_req;

	D("%s called %d\n", __func__, enable);

	if (is_rpc_connect() == -1)
		return -1;

	spkr_req.enable = cpu_to_be32(enable);
	return  msm_rpc_call(endpoint,
		ONCRPC_FORCE_HEADSET_SPEAKER_PROC,
		&spkr_req, sizeof(spkr_req), 5 * HZ);
}
int enable_aux_loopback(uint32_t enable)
{
	struct aux_loopback_req {
		struct rpc_request_hdr hdr;
		uint32_t enable;
	} aux_req;

	D("%s called %d\n", __func__, enable);

	if (is_rpc_connect() == -1)
		return -1;

	aux_req.enable = cpu_to_be32(enable);
	return  msm_rpc_call(endpoint,
		ONCRPC_ENABLE_AUX_PGA_LOOPBACK_PROC,
		&aux_req, sizeof(aux_req), 5 * HZ);
}