int q6fm_close(struct audio_client *ac) { audio_rx_path_enable(0, 0); enable_aux_loopback(0); audio_client_free(ac); return 0; }
struct audio_client *q6fm_open(void) { struct audio_client *ac; if (q6audio_init()) return 0; /* if (audio_rx_device_id != ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO && audio_rx_device_id != ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO) return 0; */ ac = audio_client_alloc(0); if (!ac) return 0; ac->flags = AUDIO_FLAG_WRITE; audio_rx_path_enable(1, 0); enable_aux_loopback(1); return ac; }
static long q6_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int rc; uint32_t n; uint32_t id[2]; char filename[64]; switch (cmd) { case AUDIO_SWITCH_DEVICE: rc = copy_from_user(&id, (void *)arg, sizeof(id)); if (!rc) rc = q6audio_do_routing(id[0], id[1]); break; case AUDIO_SET_VOLUME: rc = copy_from_user(&n, (void *)arg, sizeof(n)); if (!rc) rc = q6audio_set_rx_volume(n); break; case AUDIO_SET_MUTE: rc = copy_from_user(&n, (void *)arg, sizeof(n)); if (!rc) rc = q6audio_set_tx_mute(n); break; case AUDIO_UPDATE_ACDB: rc = copy_from_user(&id, (void *)arg, sizeof(id)); if (!rc) rc = q6audio_update_acdb(id[0], id[1]); break; case AUDIO_START_VOICE: if (arg == 0) { id[0] = id[1] = 0; } else if (copy_from_user(&id, (void*) arg, sizeof(id))) { pr_info("voice: copy acdb_id from user failed\n"); rc = -EFAULT; break; } rc = q6_voice_start(id[0], id[1]); break; case AUDIO_STOP_VOICE: rc = q6_voice_stop(); break; case AUDIO_START_FM: rc = q6_fm_start(); break; case AUDIO_STOP_FM: rc = q6_fm_stop(); break; case AUDIO_REINIT_ACDB: rc = copy_from_user(&filename, (void *)arg, sizeof(filename)); if (!rc) rc = q6audio_reinit_acdb(filename); break; case AUDIO_ENABLE_AUXPGA_LOOPBACK: { uint32_t enable; if (copy_from_user(&enable, (void*) arg, sizeof(enable))) { rc = -EFAULT; break; } rc = enable_aux_loopback(enable); break; } default: rc = -EINVAL; } return rc; }
static int q6_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { int rc; uint32_t n; uint32_t id[2]; char filename[64]; // printk("$$$ AUDIO IOCTL=%08X\n", cmd); switch (cmd) { case AUDIO_SWITCH_DEVICE: rc = copy_from_user(&id, (void *)arg, sizeof(id)); AUDIO_INFO("SWITCH DEVICE %d, acdb %d\n", id[0], id[1]); if (!rc) rc = q6audio_do_routing(id[0], id[1]); break; case AUDIO_SET_VOLUME: rc = copy_from_user(&n, (void *)arg, sizeof(n)); if (!rc) rc = q6audio_set_rx_volume(n); break; case AUDIO_SET_MUTE: rc = copy_from_user(&n, (void *)arg, sizeof(n)); if (!rc) rc = q6audio_set_tx_mute(n); break; case AUDIO_UPDATE_ACDB: rc = copy_from_user(&id, (void *)arg, sizeof(id)); if (!rc) rc = q6audio_update_acdb(id[0], id[1]); break; case AUDIO_START_VOICE: if (arg == 0) { id[0] = id[1] = 0; } else if (copy_from_user(&id, (void*) arg, sizeof(id))) { pr_info("voice: copy acdb_id from user failed\n"); rc = -EFAULT; break; } AUDIO_INFO("voice: start\n"); rc = q6_voice_start(id[0], id[1]); break; case AUDIO_STOP_VOICE: AUDIO_INFO("voice: stop\n"); rc = q6_voice_stop(); break; case AUDIO_START_FM: AUDIO_INFO("FM: start\n"); rc = q6_fm_start(); break; case AUDIO_STOP_FM: AUDIO_INFO("FM: stop\n"); rc = q6_fm_stop(); break; case AUDIO_REINIT_ACDB: rc = copy_from_user(&filename, (void *)arg, sizeof(filename)); if (!rc) rc = q6audio_reinit_acdb(filename); break; case AUDIO_ENABLE_AUXPGA_LOOPBACK: { uint32_t enable; if (copy_from_user(&enable, (void*) arg, sizeof(enable))) { rc = -EFAULT; break; } AUDIO_INFO("audio_ctl: enable aux loopback %d\n", enable); rc = enable_aux_loopback(enable); break; } case AUDIO_SET_AUXPGA_GAIN: { int level; if (copy_from_user(&level, (void*) arg, sizeof(level))) { rc = -EFAULT; break; } AUDIO_INFO("audio_ctl: set aux gain %d\n", level); rc = set_aux_gain(level); break; } case AUDIO_SET_RX_MUTE: rc = copy_from_user(&n, (void *)arg, sizeof(n)); if (!rc) rc = q6audio_set_rx_mute(n); break; default: rc = -EINVAL; } return rc; }