コード例 #1
0
void msm8k_audio_dev_work(struct work_struct *work)
{
	int rc;
	struct cad_open_struct_type  cos;
	struct msm8k_audio_dev_ctrl *ctrl = &g_ctrl;

	D("%s() running\n", __func__);

	cos.format = 0;
	cos.op_code = CAD_OPEN_OP_DEVICE_CTRL;
	ctrl->cad_ctrl_handle = cad_open(&cos);
	ctrl->current_rx_device = CAD_HW_DEVICE_ID_HANDSET_SPKR;
	ctrl->current_tx_device = CAD_HW_DEVICE_ID_HANDSET_MIC;

	if (ctrl->cad_ctrl_handle < 0)
		pr_err("Dev CTRL handle < 0\n");

	set_audio_ctrl_handle(ctrl->cad_ctrl_handle);

	rc = cad_ioctl(ctrl->cad_ctrl_handle,
			CAD_IOCTL_CMD_STREAM_START,
			NULL,
			0);
	if (rc)
		pr_err("%s: cad_ioctl() STREAM_START failed\n", __func__);

	ctrl->q6_initialized = 1;
	complete(&ctrl->q6_init_compl);

	D("%s() done\n", __func__);
}
static int __init msm8k_audio_dev_ctrl_init(void)
{
	struct cad_open_struct_type  cos;
	int rc;
	struct msm8k_audio_dev_ctrl *ctrl = &g_ctrl;

	D("%s\n", __func__);

	rc = misc_register(&msm8k_audio_dev_ctrl_misc);
	if (rc) {
		pr_err("failed to register audio control device\n");
		return CAD_RES_FAILURE;
	}

	cos.format = 0;
	cos.op_code = CAD_OPEN_OP_DEVICE_CTRL;
	ctrl->cad_ctrl_handle = cad_open(&cos);
	ctrl->current_rx_device = CAD_HW_DEVICE_ID_HANDSET_SPKR;
	ctrl->current_tx_device = CAD_HW_DEVICE_ID_HANDSET_MIC;

	if (ctrl->cad_ctrl_handle < 0) {
		pr_err("Dev CTRL handle < 0\n");
		return CAD_RES_FAILURE;
	}

	set_audio_ctrl_handle(ctrl->cad_ctrl_handle);

	rc = cad_ioctl(ctrl->cad_ctrl_handle,
			CAD_IOCTL_CMD_STREAM_START,
			NULL,
			0);
	if (rc) {
		pr_err("%s: cad_ioctl() STREAM_START failed\n", __func__);
		return CAD_RES_FAILURE;
	}

#ifdef CONFIG_PROC_FS
	create_proc_read_entry(MSM8K_AUDIO_PROC_NAME,
			0, NULL, msm8k_audio_dev_ctrl_read_proc, NULL);
#endif

	return rc;
}