Refactored part of the code, added routines and minimal galaxys2 support
authorPaul Kocialkowski <contact@paulk.fr>
Sun, 7 Oct 2012 17:05:13 +0000 (19:05 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Sun, 7 Oct 2012 17:05:13 +0000 (19:05 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Android.mk
device/galaxys2.c [new file with mode: 0644]
include/yamaha-mc1n2-audio.h
yamaha-mc1n2-audio.c

index 41c1625..2b6adc4 100644 (file)
@@ -18,6 +18,7 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
+       device/galaxys2.c \
        yamaha-mc1n2-audio.c
 
 LOCAL_C_INCLUDES += \
diff --git a/device/galaxys2.c b/device/galaxys2.c
new file mode 100644 (file)
index 0000000..b1c938c
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define LOG_TAG "YAMAHA-MC1N2-AUDIO"
+#include <cutils/log.h>
+
+#include <yamaha-mc1n2-audio.h>
+
+struct yamaha_mc1n2_audio_routine_init galaxys2_routine_init = {
+       .dac_info = {
+               .bMasterSwap = MCDRV_DSWAP_OFF,
+               .bVoiceSwap = MCDRV_DSWAP_OFF,
+               .bDcCut = MCDRV_DCCUT_ON,
+       },
+
+       .adc_info = {
+               .bAgcAdjust = MCDRV_AGCADJ_0,
+               .bAgcOn = MCDRV_AGC_OFF,
+               .bMono = MCDRV_ADC_STEREO,
+       },
+
+       .sp_info = {
+               .bSwap = MCDRV_SPSWAP_OFF,
+       },
+
+       .pdm_info = {
+               .bClk = MCDRV_PDM_CLK_64,
+               .bAgcAdjust = MCDRV_AGCADJ_0,
+               .bAgcOn = MCDRV_AGC_OFF,
+               .bPdmEdge = MCDRV_PDMEDGE_LH,
+               .bPdmWait = MCDRV_PDMWAIT_10,
+               .bPdmSel = MCDRV_PDMSEL_L1R2,
+               .bMono = MCDRV_PDM_STEREO,
+       },
+
+       .dng_info = {
+               .abOnOff[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_ON,
+               .abThreshold[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_THRES_60,
+               .abHold[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_HOLD_500,
+               .abAttack[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_ATTACK_100,
+               .abRelease[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_RELEASE_940,
+               .abTarget[MCDRV_DNG_ITEM_HP] = MCDRV_DNG_TARGET_MUTE,
+
+               .abOnOff[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_ON,
+               .abThreshold[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_THRES_60,
+               .abHold[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_HOLD_500,
+               .abAttack[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_ATTACK_100,
+               .abRelease[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_RELEASE_940,
+               .abTarget[MCDRV_DNG_ITEM_SP] = MCDRV_DNG_TARGET_MUTE,
+
+               .abOnOff[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_ON,
+               .abThreshold[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_THRES_60,
+               .abHold[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_HOLD_500,
+               .abAttack[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_ATTACK_100,
+               .abRelease[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_RELEASE_940,
+               .abTarget[MCDRV_DNG_ITEM_RC] = MCDRV_DNG_TARGET_MUTE,
+       },
+
+       .syseq_info = {
+               .bOnOff = MCDRV_SYSEQ_OFF,
+               .abParam = {
+                       0x10, 0xc4, 0x50, 0x12, 0xc4,
+                       0x40, 0x02, 0xa9, 0x60, 0xed,
+                       0x3b, 0xc0, 0xfc, 0x92, 0x40
+               },
+       },
+};
+
+struct yamaha_mc1n2_audio_routine_route_init galaxys2_routine_route_init = {
+       .path_info = {
+               .asHpOut[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asHpOut[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asHpOut[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asHpOut[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asHpOut[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asHpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asHpOut[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asHpOut[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asHpOut[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asHpOut[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asHpOut[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asHpOut[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asHpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asHpOut[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asSpOut[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asSpOut[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asSpOut[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asSpOut[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asSpOut[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asSpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asSpOut[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asSpOut[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asSpOut[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asSpOut[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asSpOut[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asSpOut[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asSpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asSpOut[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asRcOut[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asRcOut[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asRcOut[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asRcOut[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asRcOut[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asRcOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asRcOut[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asLout1[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asLout1[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asLout1[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asLout1[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asLout1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asLout1[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asLout1[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asLout1[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asLout1[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asLout1[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asLout1[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asLout1[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asLout1[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asLout1[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asLout2[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asLout2[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asLout2[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asLout2[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asLout2[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asLout2[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asLout2[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asLout2[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asLout2[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asLout2[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asLout2[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asLout2[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asLout2[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asLout2[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asPeak[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asPeak[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asPeak[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asPeak[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
+               .asPeak[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asPeak[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asPeak[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asDit1[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asDit1[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asDit1[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asDit1[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asDit1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asDit1[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asDit1[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asDit2[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asDit2[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asDit2[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asDit2[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asDit2[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asDit2[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asDit2[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asDac[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asDac[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asDac[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asDac[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asDac[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asDac[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asDac[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asDac[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asDac[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asDac[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asDac[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asDac[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asDac[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asDac[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asAe[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asAe[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asAe[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asAe[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asAe[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asAe[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asAe[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asCdsp[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asCdsp[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asCdsp[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asCdsp[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
+               .asCdsp[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asCdsp[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asCdsp[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asCdsp[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asCdsp[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asCdsp[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asCdsp[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
+               .asCdsp[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asCdsp[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asCdsp[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asAdc0[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asAdc0[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asAdc0[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asAdc0[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asAdc0[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asAdc0[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+               .asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asAdc0[1].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asAdc0[1].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asAdc0[1].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asAdc0[1].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asAdc0[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asAdc0[1].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asAdc1[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asAdc1[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asAdc1[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asAdc1[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
+               .asAdc1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asAdc1[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asAdc1[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asMix[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asMix[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asMix[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asMix[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asMix[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asMix[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+
+               .asBias[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
+               .asBias[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
+               .asBias[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
+               .asBias[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF,
+               .asBias[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_OFF | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
+               .asBias[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
+               .asBias[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
+       },
+
+       .dac_info = {
+               .bMasterSwap = MCDRV_DSWAP_OFF,
+               .bVoiceSwap = MCDRV_DSWAP_OFF,
+               .bDcCut = MCDRV_DCCUT_ON,
+       },
+};
+
+struct yamaha_mc1n2_audio_device_ops galaxys2_ops = {
+       .hw_node = "/dev/snd/hwC0D0",
+       .routine = {
+               .init = &galaxys2_routine_init,
+               .route_init = &galaxys2_routine_route_init,
+       },
+};
+
+struct yamaha_mc1n2_audio_pdata galaxys2_pdata = {
+       .name = "galaxys2",
+       .ops = &galaxys2_ops,
+};
index 5852666..6856106 100644 (file)
 
 #include "mc1n2.h"
 
-#define HW_NODE_DEFAULT        "/dev/snd/hwC0D0"
+struct yamaha_mc1n2_audio_routine_init {
+       MCDRV_DAC_INFO dac_info;
+       MCDRV_ADC_INFO adc_info;
+       MCDRV_SP_INFO sp_info;
+       MCDRV_PDM_INFO pdm_info;
+       MCDRV_DNG_INFO dng_info;
+       MCDRV_SYSEQ_INFO syseq_info;
+};
 
-struct yamaha_mc1n2_audio_pdata {
+struct yamaha_mc1n2_audio_routine_route_init {
+       MCDRV_PATH_INFO path_info;
+       MCDRV_DAC_INFO dac_info;
+};
+
+struct yamaha_mc1n2_audio_routine {
+       struct yamaha_mc1n2_audio_routine_init *init;
+       struct yamaha_mc1n2_audio_routine_route_init *route_init;
+};
+
+struct yamaha_mc1n2_audio_device_ops {
        char *hw_node;
+       struct yamaha_mc1n2_audio_routine routine;
+};
+
+struct yamaha_mc1n2_audio_pdata {
+       char *name;
+       struct yamaha_mc1n2_audio_device_ops *ops;
 };
 
 /*
+ * Platforms
+ */
+
+extern struct yamaha_mc1n2_audio_pdata galaxys2_pdata;
+
+/*
  * Functions
  */
 
@@ -38,12 +67,16 @@ int yamaha_mc1n2_audio_ioctl_set_ctrl(struct yamaha_mc1n2_audio_pdata *pdata,
 int yamaha_mc1n2_audio_ioctl_notify(struct yamaha_mc1n2_audio_pdata *pdata,
        unsigned long command);
 
+// Routines
+int yamaha_mc1n2_audio_routine_init(struct yamaha_mc1n2_audio_pdata *pdata);
+int yamaha_mc1n2_audio_routine_route_init(struct yamaha_mc1n2_audio_pdata *pdata);
+
 // Values configuration
-int yamaha_mc1n2_audio_set_hw_node(struct yamaha_mc1n2_audio_pdata *pdata, char *node);
 char *yamaha_mc1n2_audio_get_hw_node(struct yamaha_mc1n2_audio_pdata *pdata);
 
 // Init/Deinit
-int yamaha_mc1n2_audio_init(struct yamaha_mc1n2_audio_pdata **pdata_p);
-int yamaha_mc1n2_audio_deinit(struct yamaha_mc1n2_audio_pdata *pdata);
+int yamaha_mc1n2_audio_start(struct yamaha_mc1n2_audio_pdata **pdata_p,
+       char *device_name);
+int yamaha_mc1n2_audio_stop(struct yamaha_mc1n2_audio_pdata *pdata);
 
 #endif
index 15b3c90..0a00c14 100644 (file)
 
 #include <linux/ioctl.h>
 
-#define LOG_TAG "YAMAHA-MC1N2-AUDIO"
+#define LOG_TAG "Yamaha-MC1N2-Audio"
 #include <cutils/log.h>
 
 #include <yamaha-mc1n2-audio.h>
 
+struct yamaha_mc1n2_audio_pdata *yamaha_mc1n2_audio_platforms[] = {
+       &galaxys2_pdata,
+};
+
+int yamaha_mc1n2_audio_platforms_count = sizeof(yamaha_mc1n2_audio_platforms) /
+       sizeof(struct yamaha_mc1n2_audio_pdata *);
+
 /*
  * IOCTL
  */
@@ -56,12 +63,14 @@ int yamaha_mc1n2_audio_ioctl(struct yamaha_mc1n2_audio_pdata *pdata,
                return -1;
        }
 
-       rc = ioctl(hw_fd, command, &hw_ctrl);
+       rc = ioctl(hw_fd, command, hw_ctrl);
        if(rc < 0) {
                LOGE("%s: error, ioctl on hw_node failed (rc is %d)!", __func__, rc);
                return -1;
        }
 
+       close(hw_fd);
+
        return rc;
 }
 
@@ -96,63 +105,159 @@ int yamaha_mc1n2_audio_ioctl_notify(struct yamaha_mc1n2_audio_pdata *pdata,
 }
 
 /*
- * Values configuration
+ * Routines
  */
 
-int yamaha_mc1n2_audio_set_hw_node(struct yamaha_mc1n2_audio_pdata *pdata, char *node)
+int yamaha_mc1n2_audio_routine_init(struct yamaha_mc1n2_audio_pdata *pdata)
 {
-       if(pdata == NULL || node == NULL)
+       struct yamaha_mc1n2_audio_routine_init *routine = NULL;
+       int rc = -1;
+
+       if(pdata == NULL || pdata->ops == NULL)
+               return -1;
+
+       routine = pdata->ops->routine.init;
+       if(routine == NULL)
                return -1;
 
-       if(pdata->hw_node != NULL) {
-               LOGD("%s: previous node was: %s", __func__, pdata->hw_node);
-               free(pdata->hw_node);
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DAC,
+               &routine->dac_info, 0x07);
+       if(rc < 0) {
+               LOGE("SET_DAC IOCTL failed, aborting!");
+               return -1;
        }
 
-       pdata->hw_node = strdup(node);
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_ADC,
+               &routine->adc_info, 0x07);
+       if(rc < 0) {
+               LOGE("SET_ADC IOCTL failed, aborting!");
+               return -1;
+       }
 
-       LOGD("%s: setting node to: %s", __func__, pdata->hw_node);
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_SP,
+               &routine->sp_info, 0x00);
+       if(rc < 0) {
+               LOGE("SET_SP IOCTL failed, aborting!");
+               return -1;
+       }
+
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_PDM,
+               &routine->pdm_info, 0x7f);
+       if(rc < 0) {
+               LOGE("SET_PDM IOCTL failed, aborting!");
+               return -1;
+       }
+
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DNG,
+               &routine->dng_info, 0x3f3f3f);
+       if(rc < 0) {
+               LOGE("SET_DNG IOCTL failed, aborting!");
+               return -1;
+       }
+
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_SYSEQ,
+               &routine->syseq_info, 0x03);
+       if(rc < 0) {
+               LOGE("SET_SYSEQ IOCTL failed, aborting!");
+               return -1;
+       }
 
        return 0;
 }
 
+int yamaha_mc1n2_audio_routine_route_init(struct yamaha_mc1n2_audio_pdata *pdata)
+{
+       struct yamaha_mc1n2_audio_routine_route_init *routine = NULL;
+       int rc = -1;
+
+       if(pdata == NULL || pdata->ops == NULL)
+               return -1;
+
+       routine = pdata->ops->routine.route_init;
+       if(routine == NULL)
+               return -1;
+
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_PATH,
+               &routine->path_info, 0x00);
+       if(rc < 0) {
+               LOGE("SET_PATH IOCTL failed, aborting!");
+               return -1;
+       }
+
+       rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DAC,
+               &routine->dac_info, 0x07);
+       if(rc < 0) {
+               LOGE("SET_DAC IOCTL failed, aborting!");
+               return -1;
+       }
+
+       return 0;
+}
+
+/*
+ * Values configuration
+ */
+
 char *yamaha_mc1n2_audio_get_hw_node(struct yamaha_mc1n2_audio_pdata *pdata)
 {
        if(pdata == NULL)
                return NULL;
 
-       return pdata->hw_node;
+       return pdata->ops->hw_node;
 }
 
 /*
  * Init/Deinit
  */
 
-int yamaha_mc1n2_audio_init(struct yamaha_mc1n2_audio_pdata **pdata_p)
+struct yamaha_mc1n2_audio_pdata *yamaha_mc1n2_audio_platform_get(
+       char *device_name)
+{
+       int i;
+
+       if(device_name == NULL)
+               return NULL;
+
+       LOGD("Found %d registered platforms",
+               yamaha_mc1n2_audio_platforms_count);
+
+       for(i=0 ; i < yamaha_mc1n2_audio_platforms_count ; i++) {
+               if(yamaha_mc1n2_audio_platforms[i] != NULL &&
+                       yamaha_mc1n2_audio_platforms[i]->name != NULL) {
+                       if(strcmp(yamaha_mc1n2_audio_platforms[i]->name, device_name) == 0) {
+                               return yamaha_mc1n2_audio_platforms[i];
+                       }
+               }
+       }
+
+       return NULL;
+}
+
+
+int yamaha_mc1n2_audio_start(struct yamaha_mc1n2_audio_pdata **pdata_p,
+       char *device_name)
 {
        struct yamaha_mc1n2_audio_pdata *pdata = NULL;
+       int rc;
 
-       if(pdata_p == NULL)
+       if(pdata_p == NULL || device_name == NULL)
                return -1;
 
-       pdata = calloc(1, sizeof(struct yamaha_mc1n2_audio_pdata));
+       pdata = yamaha_mc1n2_audio_platform_get(device_name);
+       if(pdata == NULL) {
+               LOGE("Unable to find requested platform: %s", device_name);
+               return -1;
+       }
 
-       yamaha_mc1n2_audio_set_hw_node(pdata, HW_NODE_DEFAULT);
+       *pdata_p = pdata;
 
        return 0;
 }
 
-int yamaha_mc1n2_audio_deinit(struct yamaha_mc1n2_audio_pdata *pdata)
+int yamaha_mc1n2_audio_stop(struct yamaha_mc1n2_audio_pdata *pdata)
 {
        if(pdata == NULL)
                return -1;
 
-       if(pdata->hw_node)
-               free(pdata->hw_node);
-
-       memset(pdata, 0, sizeof(struct yamaha_mc1n2_audio_pdata));
-
-       free(pdata);
-
        return 0;
 }