static int q6venc_open(struct inode *inode, struct file *file) { struct q6venc_dev *q6venc; int err; q6venc = kzalloc(sizeof(struct q6venc_dev), GFP_KERNEL); if (!q6venc) { pr_err("%s: Unable to allocate memory for q6venc_dev\n", __func__); return -ENOMEM; } file->private_data = q6venc; init_waitqueue_head(&q6venc->encode_wq); mutex_init(&q6venc->lock); spin_lock_init(&q6venc->done_lock); q6venc->venc = dal_attach(DALDEVICEID_VENC_DEVICE, DALDEVICEID_VENC_PORTNAME, 1, callback, q6venc); if (!q6venc->venc) { pr_err("%s: dal_attach failed\n", __func__); err = -EIO; goto err_dal_attach; } q6venc->cb_ev_data.enc_cb_handle = VENC_CB_EVENT_ID; err = dal_call_f5(q6venc->venc, VENC_DALRPC_SET_CB_CHANNEL, &q6venc->cb_ev_data, sizeof(q6venc->cb_ev_data)); if (err) { pr_err("%s: set_cb_channgel failed\n", __func__); goto err_dal_call_set_cb; } pr_info("%s() handle=%p enc_cb=%08x\n", __func__, q6venc->venc, q6venc->cb_ev_data.enc_cb_handle); return 0; err_dal_call_set_cb: dal_detach(q6venc->venc); err_dal_attach: file->private_data = NULL; mutex_destroy(&q6venc->lock); kfree(q6venc); return err; }
static int q6audio_init(void) { struct audio_client *ac = 0; int res; mutex_lock(&audio_lock); if (ac_control) { res = 0; goto done; } pr_info("audio: init: codecs\n"); icodec_rx_clk = clk_get(0, "icodec_rx_clk"); icodec_tx_clk = clk_get(0, "icodec_tx_clk"); ecodec_clk = clk_get(0, "ecodec_clk"); sdac_clk = clk_get(0, "sdac_clk"); audio_data = dma_alloc_coherent(NULL, 4096, &audio_phys, GFP_KERNEL); adsp = dal_attach(AUDIO_DAL_DEVICE, AUDIO_DAL_PORT, callback, 0); if (!adsp) { pr_err("audio_init: cannot attach to adsp\n"); res = -ENODEV; goto done; } pr_info("audio: init: INIT\n"); audio_init(adsp); dal_trace(adsp); ac = audio_client_alloc(0); if (!ac) { pr_err("audio_init: cannot allocate client\n"); res = -ENOMEM; goto done; } pr_info("audio: init: OPEN control\n"); if (audio_open_control(ac)) { pr_err("audio_init: cannot open control channel\n"); res = -ENODEV; goto done; } pr_info("audio: init: attach ACDB\n"); acdb = dal_attach(ACDB_DAL_DEVICE, ACDB_DAL_PORT, 0, 0); if (!acdb) { pr_err("audio_init: cannot attach to acdb channel\n"); res = -ENODEV; goto done; } pr_info("audio: init: attach ADIE\n"); adie = dal_attach(ADIE_DAL_DEVICE, ADIE_DAL_PORT, 0, 0); if (!adie) { pr_err("audio_init: cannot attach to adie\n"); res = -ENODEV; goto done; } if (analog_ops->init) analog_ops->init(); res = 0; ac_control = ac; wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "audio_pcm_suspend"); done: if ((res < 0) && ac) audio_client_free(ac); mutex_unlock(&audio_lock); return res; }