mc1n2: Opensource audio HAL from Replicant
Thanks to Paul Kocialkowski of the Replicant project for this work. Original sources: https://gitorious.org/replicant/hardware_tinyalsa-audio http://git.paulk.fr/gitweb/?p=yamaha-mc1n2-audio.git;a=summary Change-Id: Ia3d89c67d64decb56e3d6518c5f382d38e5a1fa9
This commit is contained in:
parent
fd9472ca4b
commit
cdc1a96ac0
@ -90,10 +90,8 @@ BOARD_USE_METADATABUFFERTYPE := true
|
||||
BOARD_USES_MFC_FPS := true
|
||||
|
||||
# Audio
|
||||
BOARD_USE_YAMAHAPLAYER := true
|
||||
BOARD_USE_SAMSUNG_SEPARATEDSTREAM := true
|
||||
BOARD_HAS_SAMSUNG_VOLUME_BUG := true
|
||||
COMMON_GLOBAL_CFLAGS += -DICS_AUDIO_BLOB
|
||||
BOARD_USE_TINYALSA_AUDIO := true
|
||||
BOARD_USE_YAMAHA_MC1N2_AUDIO := true
|
||||
|
||||
# RIL
|
||||
BOARD_MOBILEDATA_INTERFACE_NAME := "pdp0"
|
||||
|
14
common.mk
14
common.mk
@ -24,7 +24,8 @@ PRODUCT_COPY_FILES := \
|
||||
|
||||
# Audio
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/samsung/galaxys2-common/configs/asound.conf:system/etc/asound.conf
|
||||
device/samsung/galaxys2-common/configs/tinyalsa-audio.xml:system/etc/tinyalsa-audio.xml \
|
||||
device/samsung/galaxys2-common/configs/audio_policy.conf:system/etc/audio_policy.conf
|
||||
|
||||
# Vold and Storage
|
||||
PRODUCT_COPY_FILES += \
|
||||
@ -52,17 +53,22 @@ PRODUCT_COPY_FILES += \
|
||||
|
||||
# Packages
|
||||
PRODUCT_PACKAGES := \
|
||||
audio.a2dp.default \
|
||||
libaudiohw_legacy \
|
||||
camera.exynos4 \
|
||||
libsurfaceflinger_client \
|
||||
com.android.future.usb.accessory \
|
||||
SamsungServiceMode \
|
||||
Torch \
|
||||
TvOut
|
||||
|
||||
# Audio Packages
|
||||
PRODUCT_PACKAGES += \
|
||||
audio.primary.exynos4 \
|
||||
audio.a2dp.default \
|
||||
audio.usb.default \
|
||||
libaudiohw_legacy
|
||||
|
||||
# HAL
|
||||
PRODUCT_PACKAGES += \
|
||||
camera.exynos4 \
|
||||
gralloc.exynos4 \
|
||||
hwcomposer.exynos4 \
|
||||
libnetcmdiface \
|
||||
|
82
configs/audio_policy.conf
Normal file
82
configs/audio_policy.conf
Normal file
@ -0,0 +1,82 @@
|
||||
# Global configuration section: lists input and output devices always present on the device
|
||||
# as well as the output device selected by default.
|
||||
# Devices are designated by a string that corresponds to the enum in audio.h
|
||||
|
||||
global_configuration {
|
||||
attached_output_devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER
|
||||
default_output_device AUDIO_DEVICE_OUT_SPEAKER
|
||||
attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC
|
||||
}
|
||||
|
||||
# audio hardware module section: contains descriptors for all audio hw modules present on the
|
||||
# device. Each hw module node is named after the corresponding hw module library base name.
|
||||
# For instance, "primary" corresponds to audio.primary.<device>.so.
|
||||
# The "primary" module is mandatory and must include at least one output with
|
||||
# AUDIO_OUTPUT_FLAG_PRIMARY flag.
|
||||
# Each module descriptor contains one or more output profile descriptors and zero or more
|
||||
# input profile descriptors. Each profile lists all the parameters supported by a given output
|
||||
# or input stream category.
|
||||
# The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding
|
||||
# to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n".
|
||||
|
||||
audio_hw_modules {
|
||||
primary {
|
||||
outputs {
|
||||
primary {
|
||||
sampling_rates 44100
|
||||
channel_masks AUDIO_CHANNEL_OUT_STEREO
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET
|
||||
flags AUDIO_OUTPUT_FLAG_PRIMARY
|
||||
}
|
||||
# deep_buffer {
|
||||
# sampling_rates 44100
|
||||
# channel_masks AUDIO_CHANNEL_OUT_STEREO
|
||||
# formats AUDIO_FORMAT_PCM_16_BIT
|
||||
# devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE
|
||||
# flags AUDIO_OUTPUT_FLAG_DEEP_BUFFER
|
||||
# }
|
||||
# hdmi {
|
||||
# sampling_rates 44100|48000
|
||||
# channel_masks dynamic
|
||||
# formats AUDIO_FORMAT_PCM_16_BIT
|
||||
# devices AUDIO_DEVICE_OUT_AUX_DIGITAL
|
||||
# flags AUDIO_OUTPUT_FLAG_DIRECT
|
||||
# }
|
||||
}
|
||||
inputs {
|
||||
primary {
|
||||
sampling_rates 8000|11025|16000|22050|24000|32000|44100|48000
|
||||
channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_WIRED_HEADSET
|
||||
}
|
||||
}
|
||||
}
|
||||
a2dp {
|
||||
outputs {
|
||||
a2dp {
|
||||
sampling_rates 44100
|
||||
channel_masks AUDIO_CHANNEL_OUT_STEREO
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
devices AUDIO_DEVICE_OUT_ALL_A2DP
|
||||
}
|
||||
}
|
||||
}
|
||||
usb {
|
||||
outputs {
|
||||
usb_accessory {
|
||||
sampling_rates 44100
|
||||
channel_masks AUDIO_CHANNEL_OUT_STEREO
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
devices AUDIO_DEVICE_OUT_USB_ACCESSORY
|
||||
}
|
||||
usb_device {
|
||||
sampling_rates 44100
|
||||
channel_masks AUDIO_CHANNEL_OUT_STEREO
|
||||
formats AUDIO_FORMAT_PCM_16_BIT
|
||||
devices AUDIO_DEVICE_OUT_USB_DEVICE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
170
configs/tinyalsa-audio.xml
Normal file
170
configs/tinyalsa-audio.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<tinyalsa-audio device="Galaxy S2">
|
||||
<output card="0" device="0"
|
||||
rate="44100" channels="2" format="PCM_16"
|
||||
period_size="1024" period_count="4">
|
||||
|
||||
<device type="default">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Digital Volume" value="75" />
|
||||
<ctrl name="AD Digital Switch" value="on" />
|
||||
<ctrl name="AENG6 Volume" value="75" />
|
||||
<ctrl name="AENG6 Switch" value="on" />
|
||||
<ctrl name="DIR#0 Volume" value="75" />
|
||||
<ctrl name="DIR#0 Switch" value="on" />
|
||||
<ctrl name="DIR#1 Volume" value="75" />
|
||||
<ctrl name="DIR#1 Switch" value="on" />
|
||||
<ctrl name="DIR#2 Volume" value="75" />
|
||||
<ctrl name="DIR#2 Switch" value="on" />
|
||||
<ctrl name="DIR#0 ATT Volume" value="75" />
|
||||
<ctrl name="DIR#0 ATT Switch" value="on" />
|
||||
<ctrl name="DIR#1 ATT Volume" value="75" />
|
||||
<ctrl name="DIR#1 ATT Switch" value="on" />
|
||||
<ctrl name="DIR#2 ATT Volume" value="75" />
|
||||
<ctrl name="DIR#2 ATT Switch" value="on" />
|
||||
<ctrl name="Master Playback Volume" value="75" />
|
||||
<ctrl name="Master Playback Switch" value="on" />
|
||||
<ctrl name="DAC Playback Volume" value="75" />
|
||||
<ctrl name="DAC Playback Switch" value="on" />
|
||||
<ctrl name="DIT#0 Capture Volume" value="75" />
|
||||
<ctrl name="DIT#0 Capture Switch" value="on" />
|
||||
<ctrl name="DIT#1 Capture Volume" value="75" />
|
||||
<ctrl name="DIT#1 Capture Switch" value="on" />
|
||||
<ctrl name="DIT#2 Capture Volume" value="75" />
|
||||
<ctrl name="DIT#2 Capture Switch" value="on" />
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
<ctrl name="AD Analog Switch" value="on" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="earpiece">
|
||||
<path type="enable">
|
||||
<ctrl name="Receiver Playback Volume" value="31" />
|
||||
<ctrl name="Receiver Playback Switch" value="on" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="Receiver Playback Volume" value="0" />
|
||||
<ctrl name="Receiver Playback Switch" value="off" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="speaker">
|
||||
<path type="enable">
|
||||
<ctrl name="Speaker Playback Volume" value="26" />
|
||||
<ctrl name="Speaker Playback Switch" value="on" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="Speaker Playback Volume" value="0" />
|
||||
<ctrl name="Speaker Playback Switch" value="off" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="wired-headphone">
|
||||
<path type="enable">
|
||||
<ctrl name="Headphone Playback Volume" value="15" />
|
||||
<ctrl name="Headphone Playback Switch" value="on" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="Headphone Playback Volume" value="0" />
|
||||
<ctrl name="Headphone Playback Switch" value="off" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="wired-headset">
|
||||
<path type="enable">
|
||||
<ctrl name="Headphone Playback Volume" value="15" />
|
||||
<ctrl name="Headphone Playback Switch" value="on" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="Headphone Playback Volume" value="0" />
|
||||
<ctrl name="Headphone Playback Switch" value="off" />
|
||||
</path>
|
||||
</device>
|
||||
</output>
|
||||
|
||||
<input card="0" device="0"
|
||||
rate="44100" channels="2" format="PCM_16"
|
||||
period_size="1024" period_count="4">
|
||||
|
||||
<device type="builtin-mic">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Analog Volume" value="26" />
|
||||
<ctrl name="Mic 1 Gain Volume" value="2" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
<ctrl name="Mic 1 Gain Volume" value="0" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="wired-headset">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Analog Volume" value="26" />
|
||||
<ctrl name="Mic 2 Gain Volume" value="2" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
<ctrl name="Mic 2 Gain Volume" value="0" />
|
||||
</path>
|
||||
</device>
|
||||
</input>
|
||||
|
||||
<modem card="0" device="0">
|
||||
<device type="earpiece">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Digital Volume" value="84" />
|
||||
<ctrl name="DIR#1 Volume" value="80" />
|
||||
<ctrl name="Master Playback Volume" value="76" />
|
||||
<ctrl name="AD Analog Volume" value="22" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="AD Digital Volume" value="75" />
|
||||
<ctrl name="DIR#1 Volume" value="75" />
|
||||
<ctrl name="Master Playback Volume" value="75" />
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="speaker">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Digital Volume" value="80" />
|
||||
<ctrl name="Speaker Playback Volume" value="31" />
|
||||
<!-- <ctrl name="Mic 3 Gain Volume" value="3" /> -->
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="AD Digital Volume" value="75" />
|
||||
<ctrl name="Speaker Playback Volume" value="26" />
|
||||
<!-- <ctrl name="Mic 3 Gain Volume" value="0" /> -->
|
||||
</path>
|
||||
</device>
|
||||
<device type="wired-headphone">
|
||||
<path type="enable">
|
||||
<ctrl name="AD Digital Volume" value="84" />
|
||||
<ctrl name="Master Playback Volume" value="69" />
|
||||
<ctrl name="AD Analog Volume" value="22" />
|
||||
<ctrl name="Headphone Playback Volume" value="31" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="AD Digital Volume" value="75" />
|
||||
<ctrl name="Master Playback Volume" value="75" />
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
<ctrl name="Headphone Playback Volume" value="15" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="wired-headset">
|
||||
<path type="enable">
|
||||
<ctrl name="Master Playback Volume" value="69" />
|
||||
<ctrl name="AD Analog Volume" value="26" />
|
||||
<ctrl name="Headphone Playback Volume" value="31" />
|
||||
<ctrl name="Mic 2 Gain Volume" value="2" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="Master Playback Volume" value="75" />
|
||||
<ctrl name="AD Analog Volume" value="19" />
|
||||
<ctrl name="Headphone Playback Volume" value="15" />
|
||||
<ctrl name="Mic 2 Gain Volume" value="0" />
|
||||
</path>
|
||||
</device>
|
||||
<device type="bt-sco-headset">
|
||||
<path type="enable">
|
||||
<ctrl name="DIR#2 Volume" value="81" />
|
||||
</path>
|
||||
<path type="disable">
|
||||
<ctrl name="DIR#2 Volume" value="75" />
|
||||
</path>
|
||||
</device>
|
||||
</modem>
|
||||
</tinyalsa-audio>
|
@ -166,9 +166,6 @@
|
||||
<!-- Workaround for devices with broken keyboards -->
|
||||
<bool name="config_forceDisableHardwareKeyboard">true</bool>
|
||||
|
||||
<!-- If true, adds support for no delay A2DP in Samsung devices -->
|
||||
<bool name="config_noDelayInATwoDP">true</bool>
|
||||
|
||||
<!-- Boolean to enable stk functionality on Samsung phones -->
|
||||
<bool name="config_samsung_stk">true</bool>
|
||||
</resources>
|
||||
|
73
tinyalsa_audio/Android.mk
Normal file
73
tinyalsa_audio/Android.mk
Normal file
@ -0,0 +1,73 @@
|
||||
# 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/>.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifeq ($(strip $(BOARD_USE_TINYALSA_AUDIO)),true)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
audio_hw.c \
|
||||
audio_out.c \
|
||||
audio_in.c \
|
||||
audio_ril_interface.c \
|
||||
mixer.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
external/tinyalsa/include \
|
||||
external/expat/lib \
|
||||
system/media/audio_utils/include \
|
||||
system/media/audio_effects/include \
|
||||
hardware/tinyalsa-audio/include
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libc \
|
||||
libcutils \
|
||||
libutils \
|
||||
libexpat \
|
||||
libtinyalsa \
|
||||
libaudioutils \
|
||||
libdl
|
||||
|
||||
ifeq ($(strip $(BOARD_USE_YAMAHA_MC1N2_AUDIO)),true)
|
||||
LOCAL_CFLAGS += -DYAMAHA_MC1N2_AUDIO
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../yamaha-mc1n2-audio/include
|
||||
LOCAL_SHARED_LIBRARIES += libyamaha-mc1n2-audio
|
||||
|
||||
#this really needs to get cleaned up to properly inherit from -common
|
||||
ifeq ($(TARGET_DEVICE),n7000)
|
||||
LOCAL_CFLAGS += -DYAMAHA_MC1N2_AUDIO_DEVICE=\"galaxys2\"
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_DEVICE),i9100)
|
||||
LOCAL_CFLAGS += -DYAMAHA_MC1N2_AUDIO_DEVICE=\"galaxys2\"
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_DEVICE),i777)
|
||||
LOCAL_CFLAGS += -DYAMAHA_MC1N2_AUDIO_DEVICE=\"galaxys2\"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif
|
534
tinyalsa_audio/audio_hw.c
Normal file
534
tinyalsa_audio/audio_hw.c
Normal file
@ -0,0 +1,534 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
|
||||
*
|
||||
* This is based on Galaxy Nexus audio.primary.tuna implementation:
|
||||
* Copyright 2011, The Android Open-Source Project
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "TinyALSA-Audio Hardware"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <cutils/str_parms.h>
|
||||
#include <cutils/log.h>
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
#include <yamaha-mc1n2-audio.h>
|
||||
#endif
|
||||
|
||||
#include "audio_hw.h"
|
||||
#include "mixer.h"
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
|
||||
static uint32_t audio_hw_get_supported_devices(const struct audio_hw_device *dev)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
ALOGD("%s(%p)", __func__, dev);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
return (uint32_t) tinyalsa_mixer_get_supported_devices(device->mixer);
|
||||
}
|
||||
|
||||
static int audio_hw_init_check(const struct audio_hw_device *dev)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
ALOGD("%s(%p)", __func__, dev);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
audio_devices_t device_modem;
|
||||
|
||||
ALOGD("%s(%p, %f)++", __func__, dev, volume);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
if(volume != device->voice_volume) {
|
||||
pthread_mutex_lock(&device->lock);
|
||||
|
||||
if(device->mode == AUDIO_MODE_IN_CALL) {
|
||||
if(device->ril_interface != NULL)
|
||||
device_modem = device->ril_interface->device_current;
|
||||
else if(device->stream_out != NULL)
|
||||
device_modem = device->stream_out->device_current;
|
||||
else
|
||||
device_modem = AUDIO_DEVICE_OUT_EARPIECE;
|
||||
|
||||
tinyalsa_mixer_set_voice_volume(device->mixer,
|
||||
device_modem, volume);
|
||||
|
||||
if(device->ril_interface != NULL)
|
||||
audio_ril_interface_set_voice_volume(device->ril_interface, device_modem, volume);
|
||||
}
|
||||
|
||||
device->voice_volume = volume;
|
||||
|
||||
pthread_mutex_unlock(&device->lock);
|
||||
}
|
||||
|
||||
ALOGD("%s(%p, %f)--", __func__, dev, volume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_set_master_volume(struct audio_hw_device *dev, float volume)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
ALOGD("%s(%p, %f)++", __func__, dev, volume);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&device->lock);
|
||||
tinyalsa_mixer_set_master_volume(device->mixer, volume);
|
||||
pthread_mutex_unlock(&device->lock);
|
||||
|
||||
ALOGD("%s(%p, %f)--", __func__, dev, volume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_set_mode(struct audio_hw_device *dev, int mode)
|
||||
{
|
||||
struct tinyalsa_audio_ril_interface *ril_interface;
|
||||
struct tinyalsa_audio_device *device;
|
||||
audio_devices_t device_modem;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %d)++", __func__, dev, mode);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(mode != device->mode) {
|
||||
pthread_mutex_lock(&device->lock);
|
||||
|
||||
if(mode == AUDIO_MODE_IN_CALL) {
|
||||
tinyalsa_mixer_set_modem_state(device->mixer, 1);
|
||||
|
||||
if(device->stream_out != NULL)
|
||||
device_modem = device->stream_out->device_current;
|
||||
else
|
||||
device_modem = AUDIO_DEVICE_OUT_EARPIECE;
|
||||
|
||||
tinyalsa_mixer_set_device(device->mixer, device_modem);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
rc = yamaha_mc1n2_audio_modem_start(device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = audio_ril_interface_open((struct audio_hw_device *) device, device_modem, &ril_interface);
|
||||
if(rc < 0 || ril_interface == NULL) {
|
||||
ALOGE("Failed to open RIL interface");
|
||||
device->ril_interface = NULL;
|
||||
} else {
|
||||
device->ril_interface = ril_interface;
|
||||
|
||||
//Only enable dualmic for earpiece.
|
||||
if(device_modem == AUDIO_DEVICE_OUT_EARPIECE)
|
||||
audio_ril_interface_set_twomic(ril_interface,TWO_MIC_SOLUTION_ON);
|
||||
|
||||
if(device->voice_volume)
|
||||
audio_ril_interface_set_voice_volume(ril_interface, device_modem, device->voice_volume);
|
||||
}
|
||||
} else if(device->mode == AUDIO_MODE_IN_CALL) {
|
||||
tinyalsa_mixer_set_modem_state(device->mixer, 0);
|
||||
|
||||
/*
|
||||
* Should be safe to ALWAYS disable it on exit
|
||||
* But we should instrument secril-client to be sure
|
||||
* when this is/isn't controlled - FIXME
|
||||
*/
|
||||
if(device->ril_interface != NULL) {
|
||||
audio_ril_interface_set_twomic(device->ril_interface,TWO_MIC_SOLUTION_OFF);
|
||||
}
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
rc = yamaha_mc1n2_audio_modem_stop(device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
#endif
|
||||
|
||||
if(device->ril_interface != NULL) {
|
||||
audio_ril_interface_close((struct audio_hw_device *) device, device->ril_interface);
|
||||
}
|
||||
}
|
||||
|
||||
device->mode = mode;
|
||||
|
||||
pthread_mutex_unlock(&device->lock);
|
||||
}
|
||||
|
||||
ALOGD("%s(%p, %d)--", __func__, dev, mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
audio_devices_t device_modem;
|
||||
|
||||
ALOGD("%s(%p, %d)++", __func__, dev, state);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
if(device->mic_mute != state) {
|
||||
pthread_mutex_lock(&device->lock);
|
||||
|
||||
if(device->mode == AUDIO_MODE_IN_CALL) {
|
||||
if(device->ril_interface != NULL)
|
||||
device_modem = device->ril_interface->device_current;
|
||||
else if(device->stream_out != NULL)
|
||||
device_modem = device->stream_out->device_current;
|
||||
else
|
||||
device_modem = AUDIO_DEVICE_OUT_EARPIECE;
|
||||
|
||||
tinyalsa_mixer_set_mic_mute(device->mixer,
|
||||
device_modem, state);
|
||||
|
||||
if(device->ril_interface != NULL)
|
||||
audio_ril_interface_set_mic_mute(device->ril_interface, state);
|
||||
} else {
|
||||
if(device->stream_in != NULL) {
|
||||
tinyalsa_mixer_set_mic_mute(device->mixer,
|
||||
device->stream_in->device_current, state);
|
||||
}
|
||||
}
|
||||
|
||||
device->mic_mute = state;
|
||||
|
||||
pthread_mutex_unlock(&device->lock);
|
||||
}
|
||||
|
||||
ALOGD("%s(%p, %d)--", __func__, dev, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_get_mic_mute(const struct audio_hw_device *dev, bool *state)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
ALOGD("%s(%p, %p)", __func__, dev, state);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
*state = device->mic_mute;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_hw_set_parameters(struct audio_hw_device *dev,
|
||||
const char *kvpairs)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
struct str_parms *parms;
|
||||
char value_string[32] = { 0 };
|
||||
int value;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %s)++", __func__, dev, kvpairs);
|
||||
|
||||
if(dev == NULL || kvpairs == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
parms = str_parms_create_str(kvpairs);
|
||||
if(parms == NULL)
|
||||
return -1;
|
||||
|
||||
rc = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value_string, sizeof(value_string));
|
||||
if(rc < 0)
|
||||
goto error_params;
|
||||
|
||||
value = atoi(value_string);
|
||||
|
||||
pthread_mutex_lock(&device->lock);
|
||||
|
||||
if(audio_is_output_device((audio_devices_t) value)) {
|
||||
if(device->stream_out != NULL && device->stream_out->device_current != (audio_devices_t) value) {
|
||||
pthread_mutex_lock(&device->stream_out->lock);
|
||||
audio_out_set_route(device->stream_out, (audio_devices_t) value);
|
||||
pthread_mutex_unlock(&device->stream_out->lock);
|
||||
}
|
||||
if(device->ril_interface != NULL && device->ril_interface->device_current != (audio_devices_t) value) {
|
||||
audio_ril_interface_set_route(device->ril_interface, (audio_devices_t) value);
|
||||
}
|
||||
} else if(audio_is_input_device((audio_devices_t) value)) {
|
||||
if(device->stream_in != NULL && device->stream_in->device_current != (audio_devices_t) value) {
|
||||
pthread_mutex_lock(&device->stream_in->lock);
|
||||
audio_in_set_route(device->stream_in, (audio_devices_t) value);
|
||||
pthread_mutex_unlock(&device->stream_in->lock);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&device->lock);
|
||||
|
||||
str_parms_destroy(parms);
|
||||
|
||||
ALOGD("%s(%p, %s)--", __func__, dev, kvpairs);
|
||||
|
||||
return 0;
|
||||
|
||||
error_params:
|
||||
str_parms_destroy(parms);
|
||||
|
||||
ALOGD("%s(%p, %s)-- (PARAMETER ERROR)", __func__, dev, kvpairs);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *audio_hw_get_parameters(const struct audio_hw_device *dev,
|
||||
const char *keys)
|
||||
{
|
||||
ALOGD("%s(%p, %s)", __func__, dev, keys);
|
||||
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static size_t audio_hw_get_input_buffer_size(const struct audio_hw_device *dev,
|
||||
const struct audio_config *config)
|
||||
{
|
||||
struct tinyalsa_audio_device *device;
|
||||
struct tinyalsa_mixer_io_props *mixer_props;
|
||||
size_t size;
|
||||
|
||||
int channel_count = popcount(config->channel_mask);
|
||||
|
||||
ALOGD("%s(%p, %d, %d, %d)++", __func__, dev, config->sample_rate, config->format, channel_count);
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
if(device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
mixer_props = tinyalsa_mixer_get_input_props(device->mixer);
|
||||
if(mixer_props == NULL)
|
||||
return -1;
|
||||
|
||||
// Default value
|
||||
if(mixer_props->rate == 0)
|
||||
mixer_props->rate = 44100;
|
||||
|
||||
size = (mixer_props->period_size * config->sample_rate) / mixer_props->rate;
|
||||
size = ((size + 15) / 16) * 16;
|
||||
size = size * channel_count * audio_bytes_per_sample(config->format);
|
||||
|
||||
ALOGD("%s(%p, %d, %d, %d)--", __func__, dev, config->sample_rate, config->format, channel_count);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int audio_hw_dump(const audio_hw_device_t *device, int fd)
|
||||
{
|
||||
ALOGD("%s(%p, %d)", __func__, device, fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interface
|
||||
*/
|
||||
|
||||
int audio_hw_close(hw_device_t *device)
|
||||
{
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
|
||||
ALOGD("%s(%p)++", __func__, device);
|
||||
|
||||
if(device != NULL) {
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) device;
|
||||
|
||||
if(tinyalsa_audio_device->mixer != NULL) {
|
||||
tinyalsa_mixer_close(tinyalsa_audio_device->mixer);
|
||||
tinyalsa_audio_device->mixer = NULL;
|
||||
}
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
if(tinyalsa_audio_device->mc1n2_pdata != NULL) {
|
||||
yamaha_mc1n2_audio_stop(tinyalsa_audio_device->mc1n2_pdata);
|
||||
tinyalsa_audio_device->mc1n2_pdata = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
free(device);
|
||||
}
|
||||
|
||||
ALOGD("%s(%p)--", __func__, device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_hw_open(const hw_module_t *module, const char *name,
|
||||
hw_device_t **device)
|
||||
{
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device = NULL;
|
||||
struct tinyalsa_mixer *tinyalsa_mixer = NULL;
|
||||
struct audio_hw_device *dev;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %s, %p)++", __func__, module, name, device);
|
||||
|
||||
if(device == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if(strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
tinyalsa_audio_device = calloc(1, sizeof(struct tinyalsa_audio_device));
|
||||
if(tinyalsa_audio_device == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
dev = &(tinyalsa_audio_device->device);
|
||||
|
||||
dev->common.tag = HARDWARE_DEVICE_TAG;
|
||||
dev->common.version = AUDIO_DEVICE_API_VERSION_1_0;
|
||||
dev->common.module = (struct hw_module_t *) module;
|
||||
dev->common.close = audio_hw_close;
|
||||
|
||||
dev->get_supported_devices = audio_hw_get_supported_devices;
|
||||
dev->init_check = audio_hw_init_check;
|
||||
dev->set_voice_volume = audio_hw_set_voice_volume;
|
||||
dev->set_master_volume = audio_hw_set_master_volume;
|
||||
dev->set_mode = audio_hw_set_mode;
|
||||
dev->set_mic_mute = audio_hw_set_mic_mute;
|
||||
dev->get_mic_mute = audio_hw_get_mic_mute;
|
||||
dev->set_parameters = audio_hw_set_parameters;
|
||||
dev->get_parameters = audio_hw_get_parameters;
|
||||
dev->get_input_buffer_size = audio_hw_get_input_buffer_size;
|
||||
|
||||
dev->open_output_stream = audio_hw_open_output_stream;
|
||||
dev->close_output_stream = audio_hw_close_output_stream;
|
||||
|
||||
dev->open_input_stream = audio_hw_open_input_stream;
|
||||
dev->close_input_stream = audio_hw_close_input_stream;
|
||||
|
||||
dev->dump = audio_hw_dump;
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
rc = yamaha_mc1n2_audio_start(&tinyalsa_audio_device->mc1n2_pdata,
|
||||
YAMAHA_MC1N2_AUDIO_DEVICE);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to open Yamaha-MC1N2-Audio");
|
||||
goto error_device;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_init(tinyalsa_audio_device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to init Yamaha-MC1N2-Audio");
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = tinyalsa_mixer_open(&tinyalsa_mixer, TINYALSA_MIXER_CONFIG_FILE);
|
||||
if(rc < 0 || tinyalsa_mixer == NULL) {
|
||||
ALOGE("Failed to open mixer!");
|
||||
goto error_device;
|
||||
}
|
||||
|
||||
tinyalsa_audio_device->mixer = tinyalsa_mixer;
|
||||
|
||||
*device = &(dev->common);
|
||||
|
||||
ALOGD("%s(%p, %s, %p)--", __func__, module, name, device);
|
||||
|
||||
return 0;
|
||||
|
||||
error_device:
|
||||
*device = NULL;
|
||||
free(tinyalsa_audio_device);
|
||||
|
||||
ALOGD("%s(%p, %s, %p)-- (DEVICE ERROR)", __func__, module, name, device);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct hw_module_methods_t audio_hw_module_methods = {
|
||||
.open = audio_hw_open,
|
||||
};
|
||||
|
||||
struct audio_module HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.module_api_version = AUDIO_MODULE_API_VERSION_0_1,
|
||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||
.id = AUDIO_HARDWARE_MODULE_ID,
|
||||
.name = "TinyALSA-Audio",
|
||||
.author = "Paul Kocialkowski",
|
||||
.methods = &audio_hw_module_methods,
|
||||
},
|
||||
};
|
119
tinyalsa_audio/audio_hw.h
Normal file
119
tinyalsa_audio/audio_hw.h
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef TINYALSA_AUDIO_HW_H
|
||||
#define TINYALSA_AUDIO_HW_H
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/audio.h>
|
||||
#include <system/audio.h>
|
||||
|
||||
#include <audio_utils/resampler.h>
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
#include <yamaha-mc1n2-audio.h>
|
||||
#endif
|
||||
|
||||
#include "mixer.h"
|
||||
#include "audio_ril_interface.h"
|
||||
|
||||
struct tinyalsa_audio_stream_out {
|
||||
struct audio_stream_out stream;
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
struct tinyalsa_mixer_io_props *mixer_props;
|
||||
int rate;
|
||||
audio_channel_mask_t channel_mask;
|
||||
audio_format_t format;
|
||||
|
||||
audio_devices_t device_current;
|
||||
|
||||
struct resampler_itfe *resampler;
|
||||
|
||||
struct pcm *pcm;
|
||||
int standby;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
struct tinyalsa_audio_stream_in {
|
||||
struct audio_stream_in stream;
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
struct tinyalsa_mixer_io_props *mixer_props;
|
||||
int rate;
|
||||
|
||||
audio_channel_mask_t channel_mask;
|
||||
audio_format_t format;
|
||||
|
||||
audio_devices_t device_current;
|
||||
|
||||
struct resampler_itfe *resampler;
|
||||
struct resampler_buffer_provider buffer_provider;
|
||||
void *buffer;
|
||||
int frames_left;
|
||||
|
||||
struct pcm *pcm;
|
||||
int standby;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
struct tinyalsa_audio_device {
|
||||
struct audio_hw_device device;
|
||||
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
struct tinyalsa_audio_ril_interface *ril_interface;
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
struct yamaha_mc1n2_audio_pdata *mc1n2_pdata;
|
||||
#endif
|
||||
|
||||
struct tinyalsa_mixer *mixer;
|
||||
audio_mode_t mode;
|
||||
|
||||
float voice_volume;
|
||||
int mic_mute;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
int audio_out_set_route(struct tinyalsa_audio_stream_out *stream_out,
|
||||
audio_devices_t device);
|
||||
|
||||
void audio_hw_close_output_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_out *stream);
|
||||
int audio_hw_open_output_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
audio_output_flags_t flags,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_out **stream_out);
|
||||
|
||||
int audio_in_set_route(struct tinyalsa_audio_stream_in *stream_in,
|
||||
audio_devices_t device);
|
||||
|
||||
void audio_hw_close_input_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_in *stream);
|
||||
int audio_hw_open_input_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_in **stream_in);
|
||||
|
||||
#endif
|
812
tinyalsa_audio/audio_in.c
Normal file
812
tinyalsa_audio/audio_in.c
Normal file
@ -0,0 +1,812 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
|
||||
*
|
||||
* This is based on Galaxy Nexus audio.primary.tuna implementation:
|
||||
* Copyright 2011, The Android Open-Source Project
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "TinyALSA-Audio Input"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <cutils/str_parms.h>
|
||||
#include <cutils/log.h>
|
||||
|
||||
#define EFFECT_UUID_NULL EFFECT_UUID_NULL_IN
|
||||
#define EFFECT_UUID_NULL_STR EFFECT_UUID_NULL_STR_IN
|
||||
#include <audio_utils/resampler.h>
|
||||
#include "audio_hw.h"
|
||||
#include "mixer.h"
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
|
||||
int audio_in_pcm_open(struct tinyalsa_audio_stream_in *stream_in)
|
||||
{
|
||||
struct pcm *pcm = NULL;
|
||||
struct pcm_config pcm_config;
|
||||
|
||||
if(stream_in == NULL)
|
||||
return -1;
|
||||
|
||||
memset(&pcm_config, 0, sizeof(pcm_config));
|
||||
pcm_config.channels = popcount(stream_in->mixer_props->channel_mask);
|
||||
pcm_config.rate = stream_in->mixer_props->rate;
|
||||
switch(stream_in->mixer_props->format) {
|
||||
case AUDIO_FORMAT_PCM_16_BIT:
|
||||
pcm_config.format = PCM_FORMAT_S16_LE;
|
||||
break;
|
||||
case AUDIO_FORMAT_PCM_32_BIT:
|
||||
pcm_config.format = PCM_FORMAT_S32_LE;
|
||||
break;
|
||||
default:
|
||||
ALOGE("Invalid format: 0x%x", stream_in->mixer_props->format);
|
||||
return -1;
|
||||
}
|
||||
pcm_config.period_size = stream_in->mixer_props->period_size;
|
||||
pcm_config.period_count = stream_in->mixer_props->period_count;
|
||||
|
||||
pcm = pcm_open(stream_in->mixer_props->card,
|
||||
stream_in->mixer_props->device, PCM_IN, &pcm_config);
|
||||
|
||||
if(pcm == NULL || !pcm_is_ready(pcm)) {
|
||||
ALOGE("Unable to open pcm device: %s", pcm_get_error(pcm));
|
||||
return -1;
|
||||
}
|
||||
|
||||
stream_in->pcm = pcm;
|
||||
|
||||
if(stream_in->resampler != NULL)
|
||||
stream_in->resampler->reset(stream_in->resampler);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_in_pcm_close(struct tinyalsa_audio_stream_in *stream_in)
|
||||
{
|
||||
if(stream_in->pcm == NULL)
|
||||
return;
|
||||
|
||||
pcm_close(stream_in->pcm);
|
||||
stream_in->pcm = NULL;
|
||||
}
|
||||
|
||||
int audio_in_set_route(struct tinyalsa_audio_stream_in *stream_in,
|
||||
audio_devices_t device)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if(stream_in == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in->device_current = device;
|
||||
|
||||
if(device == 0) {
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
return stream_in->stream.common.standby((struct audio_stream *) stream_in);
|
||||
}
|
||||
|
||||
tinyalsa_mixer_set_device(stream_in->device->mixer, stream_in->device_current);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
yamaha_mc1n2_audio_set_route(stream_in->device->mc1n2_pdata, device);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_in_resampler_open(struct tinyalsa_audio_stream_in *stream_in)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if(stream_in == NULL)
|
||||
return -1;
|
||||
|
||||
rc = create_resampler(stream_in->mixer_props->rate,
|
||||
stream_in->rate,
|
||||
popcount(stream_in->mixer_props->channel_mask),
|
||||
RESAMPLER_QUALITY_DEFAULT,
|
||||
&stream_in->buffer_provider,
|
||||
&stream_in->resampler);
|
||||
if(rc < 0 || stream_in->resampler == NULL) {
|
||||
ALOGE("Failed to create resampler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
stream_in->buffer = malloc(stream_in->mixer_props->period_size *
|
||||
popcount(stream_in->mixer_props->channel_mask) *
|
||||
audio_bytes_per_sample(stream_in->mixer_props->format));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_in_resampler_close(struct tinyalsa_audio_stream_in *stream_in)
|
||||
{
|
||||
if(stream_in == NULL)
|
||||
return;
|
||||
|
||||
if(stream_in->resampler != NULL) {
|
||||
release_resampler(stream_in->resampler);
|
||||
stream_in->resampler = NULL;
|
||||
}
|
||||
|
||||
if(stream_in->buffer != NULL) {
|
||||
free(stream_in->buffer);
|
||||
stream_in->buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int audio_in_get_next_buffer(struct resampler_buffer_provider *buffer_provider,
|
||||
struct resampler_buffer *buffer)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
int rc;
|
||||
|
||||
if(buffer_provider == NULL || buffer == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) ((void *) buffer_provider -
|
||||
offsetof(struct tinyalsa_audio_stream_in, buffer_provider));
|
||||
|
||||
if(stream_in->frames_left == 0) {
|
||||
if(stream_in->pcm == NULL || !pcm_is_ready(stream_in->pcm)) {
|
||||
ALOGE("pcm device is not ready");
|
||||
goto error_pcm;
|
||||
}
|
||||
|
||||
rc = pcm_read(stream_in->pcm, stream_in->buffer,
|
||||
stream_in->mixer_props->period_size *
|
||||
popcount(stream_in->mixer_props->channel_mask) *
|
||||
audio_bytes_per_sample(stream_in->mixer_props->format));
|
||||
if(rc != 0) {
|
||||
ALOGE("pcm read failed!");
|
||||
goto error_pcm;
|
||||
}
|
||||
|
||||
stream_in->frames_left = stream_in->mixer_props->period_size;
|
||||
}
|
||||
|
||||
buffer->frame_count = (buffer->frame_count > stream_in->frames_left) ?
|
||||
stream_in->frames_left : buffer->frame_count;
|
||||
|
||||
buffer->raw = stream_in->buffer +
|
||||
(stream_in->mixer_props->period_size - stream_in->frames_left) *
|
||||
popcount(stream_in->mixer_props->channel_mask) *
|
||||
audio_bytes_per_sample(stream_in->mixer_props->format);
|
||||
|
||||
return 0;
|
||||
|
||||
error_pcm:
|
||||
buffer->raw = NULL;
|
||||
buffer->frame_count = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void audio_in_release_buffer(struct resampler_buffer_provider *buffer_provider,
|
||||
struct resampler_buffer *buffer)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
if(buffer_provider == NULL || buffer == NULL)
|
||||
return;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) ((void *) buffer_provider -
|
||||
offsetof(struct tinyalsa_audio_stream_in, buffer_provider));
|
||||
|
||||
stream_in->frames_left -= buffer->frame_count;
|
||||
}
|
||||
|
||||
int audio_in_read_process(struct tinyalsa_audio_stream_in *stream_in, void *buffer, int size)
|
||||
{
|
||||
size_t frames_out;
|
||||
|
||||
size_t frames_in;
|
||||
int size_in;
|
||||
void *buffer_in = NULL;
|
||||
|
||||
int frames_out_resampler;
|
||||
int size_out_resampler;
|
||||
void *buffer_out_resampler = NULL;
|
||||
|
||||
int frames_out_read;
|
||||
int size_out_read;
|
||||
void *buffer_out_read = NULL;
|
||||
|
||||
int frames_out_channels;
|
||||
int size_out_channels;
|
||||
void *buffer_out_channels = NULL;
|
||||
|
||||
int i, j;
|
||||
int rc;
|
||||
|
||||
if(stream_in == NULL || buffer == NULL || size <= 0)
|
||||
return -1;
|
||||
|
||||
frames_in = size / audio_stream_frame_size((struct audio_stream *) stream_in);
|
||||
|
||||
if(stream_in->resampler != NULL) {
|
||||
frames_out_resampler = frames_in;
|
||||
size_out_resampler = frames_out_resampler * popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format);
|
||||
buffer_out_resampler = calloc(1, size_out_resampler);
|
||||
|
||||
frames_out = 0;
|
||||
while(frames_out < frames_out_resampler) {
|
||||
frames_in = frames_out_resampler - frames_out;
|
||||
stream_in->resampler->resample_from_provider(stream_in->resampler,
|
||||
buffer_out_resampler + (size_out_resampler / frames_out_resampler) * frames_out,
|
||||
&frames_in);
|
||||
|
||||
frames_out += frames_in;
|
||||
}
|
||||
|
||||
frames_in = frames_out_resampler;
|
||||
size_in = size_out_resampler;
|
||||
buffer_in = buffer_out_resampler;
|
||||
} else {
|
||||
frames_out_read = frames_in;
|
||||
size_out_read = frames_out_read * popcount(stream_in->mixer_props->channel_mask) * audio_bytes_per_sample(stream_in->mixer_props->format);
|
||||
buffer_out_read = calloc(1, size_out_read);
|
||||
|
||||
if(stream_in->pcm == NULL || !pcm_is_ready(stream_in->pcm)) {
|
||||
ALOGE("pcm device is not ready");
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = pcm_read(stream_in->pcm, buffer_out_read, size_out_read);
|
||||
if(rc != 0) {
|
||||
ALOGE("pcm read failed!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
frames_in = frames_out_read;
|
||||
size_in = size_out_read;
|
||||
buffer_in = buffer_out_read;
|
||||
}
|
||||
|
||||
if(buffer_in == NULL)
|
||||
goto error;
|
||||
|
||||
//FIXME: This is only for PCM 16
|
||||
if(popcount(stream_in->channel_mask) < popcount(stream_in->mixer_props->channel_mask)) {
|
||||
frames_out_channels = frames_in;
|
||||
size_out_channels = frames_out_channels * audio_stream_frame_size((struct audio_stream *) stream_in);
|
||||
buffer_out_channels = calloc(1, size_out_channels);
|
||||
|
||||
int channels_count_in = popcount(stream_in->mixer_props->channel_mask);
|
||||
int channels_count_out = popcount(stream_in->channel_mask);
|
||||
int ratio = channels_count_in / channels_count_out;
|
||||
|
||||
int16_t *byte_in = (int16_t *) buffer_in;
|
||||
int16_t *byte_out = (int16_t *) buffer_out_channels;
|
||||
int16_t byte;
|
||||
|
||||
for(i=0 ; i < frames_out_channels * channels_count_out; i++) {
|
||||
byte = 0;
|
||||
for(j=0 ; j < ratio ; j++) {
|
||||
byte += *byte_in / ratio;
|
||||
byte_in++;
|
||||
}
|
||||
|
||||
*byte_out = byte;
|
||||
byte_out++;
|
||||
}
|
||||
|
||||
frames_in = frames_out_channels;
|
||||
size_in = size_out_channels;
|
||||
buffer_in = buffer_out_channels;
|
||||
} else if(popcount(stream_in->channel_mask) != popcount(stream_in->mixer_props->channel_mask)) {
|
||||
ALOGE("Asked for more channels than hardware can provide!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(buffer_in != NULL)
|
||||
memcpy(buffer, buffer_in, size);
|
||||
|
||||
if(buffer_out_resampler != NULL)
|
||||
free(buffer_out_resampler);
|
||||
if(buffer_out_read != NULL)
|
||||
free(buffer_out_read);
|
||||
if(buffer_out_channels != NULL)
|
||||
free(buffer_out_channels);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if(buffer_out_resampler != NULL)
|
||||
free(buffer_out_resampler);
|
||||
if(buffer_out_read != NULL)
|
||||
free(buffer_out_read);
|
||||
if(buffer_out_channels != NULL)
|
||||
free(buffer_out_channels);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t audio_in_get_sample_rate(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
if(stream == NULL)
|
||||
return 0;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
return stream_in->rate;
|
||||
}
|
||||
|
||||
static int audio_in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
ALOGD("%s(%p, %d)", __func__, stream, rate);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in->rate != (int) rate) {
|
||||
pthread_mutex_lock(&stream_in->lock);
|
||||
|
||||
stream_in->rate = rate;
|
||||
|
||||
if(stream_in->rate != stream_in->mixer_props->rate) {
|
||||
audio_in_resampler_close(stream_in);
|
||||
audio_in_resampler_open(stream_in);
|
||||
|
||||
stream_in->standby = 1;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t audio_in_get_buffer_size(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
size_t size;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
size = (stream_in->mixer_props->period_size * stream_in->rate) /
|
||||
stream_in->mixer_props->rate;
|
||||
size = ((size + 15) / 16) * 16;
|
||||
size = size * audio_stream_frame_size((struct audio_stream *) stream);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static uint32_t audio_in_get_channels(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
return stream_in->channel_mask;
|
||||
}
|
||||
|
||||
static audio_format_t audio_in_get_format(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
return stream_in->format;
|
||||
}
|
||||
|
||||
static int audio_in_set_format(struct audio_stream *stream, audio_format_t format)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
ALOGD("%s(%p, %d)", __func__, stream, format);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in->format != (audio_format_t) format) {
|
||||
pthread_mutex_lock(&stream_in->lock);
|
||||
|
||||
stream_in->format = format;
|
||||
|
||||
if(stream_in->format != stream_in->mixer_props->format)
|
||||
stream_in->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_in_standby(struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p)", __func__, stream);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
pthread_mutex_lock(&stream_in->lock);
|
||||
|
||||
if(stream_in->pcm != NULL)
|
||||
audio_in_pcm_close(stream_in);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
if(!stream_in->standby) {
|
||||
rc = yamaha_mc1n2_audio_input_stop(stream_in->device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
stream_in->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_in_dump(const struct audio_stream *stream, int fd)
|
||||
{
|
||||
ALOGD("%s(%p, %d)", __func__, stream, fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_in_set_parameters(struct audio_stream *stream, const char *kvpairs)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
struct str_parms *parms;
|
||||
char value_string[32] = { 0 };
|
||||
int value;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %s)", __func__, stream, kvpairs);
|
||||
|
||||
if(stream == NULL || kvpairs == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in->device == NULL || stream_in->device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
parms = str_parms_create_str(kvpairs);
|
||||
if(parms == NULL)
|
||||
return -1;
|
||||
|
||||
rc = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value_string, sizeof(value_string));
|
||||
if(rc < 0)
|
||||
goto error_params;
|
||||
|
||||
value = atoi(value_string);
|
||||
|
||||
pthread_mutex_lock(&stream_in->device->lock);
|
||||
|
||||
if(stream_in->device_current != (audio_devices_t) value) {
|
||||
pthread_mutex_lock(&stream_in->lock);
|
||||
audio_in_set_route(stream_in, (audio_devices_t) value);
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stream_in->device->lock);
|
||||
|
||||
str_parms_destroy(parms);
|
||||
|
||||
return 0;
|
||||
|
||||
error_params:
|
||||
str_parms_destroy(parms);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *audio_in_get_parameters(const struct audio_stream *stream,
|
||||
const char *keys)
|
||||
{
|
||||
ALOGD("%s(%p, %s)", __func__, stream, keys);
|
||||
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static int audio_in_set_gain(struct audio_stream_in *stream, float gain)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
|
||||
ALOGD("%s(%p, %f)", __func__, stream, gain);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in->device == NULL || stream_in->device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&stream_in->device->lock);
|
||||
tinyalsa_mixer_set_input_gain(stream_in->device->mixer,
|
||||
stream_in->device_current, gain);
|
||||
pthread_mutex_unlock(&stream_in->device->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t audio_in_read(struct audio_stream_in *stream,
|
||||
void *buffer, size_t bytes)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
int rc;
|
||||
|
||||
if(stream == NULL || buffer == NULL || bytes <= 0)
|
||||
return -1;
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in->device == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&stream_in->lock);
|
||||
|
||||
if(stream_in->standby) {
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
rc = yamaha_mc1n2_audio_input_start(stream_in->device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = audio_in_pcm_open(stream_in);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open pcm device");
|
||||
goto error;
|
||||
}
|
||||
|
||||
stream_in->standby = 0;
|
||||
}
|
||||
|
||||
rc = audio_in_read_process(stream_in, buffer, (int) bytes);
|
||||
if(rc < 0) {
|
||||
ALOGE("Read and process failed!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(stream_in->device != NULL && stream_in->device->mic_mute)
|
||||
memset(buffer, 0, bytes);
|
||||
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
|
||||
return bytes;
|
||||
|
||||
error:
|
||||
pthread_mutex_unlock(&stream_in->lock);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t audio_in_get_input_frames_lost(struct audio_stream_in *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGD("%s(%p, %p)", __func__, stream, effect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGD("%s(%p, %p)", __func__, stream, effect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interface
|
||||
*/
|
||||
|
||||
void audio_hw_close_input_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_in *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_in *stream_in;
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
|
||||
ALOGD("%s(%p)", __func__, stream);
|
||||
|
||||
stream_in = (struct tinyalsa_audio_stream_in *) stream;
|
||||
|
||||
if(stream_in != NULL && stream_in->resampler != NULL)
|
||||
audio_in_resampler_close(stream_in);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
if(stream_in != NULL && !stream_in->standby)
|
||||
yamaha_mc1n2_audio_input_stop(stream_in->device->mc1n2_pdata);
|
||||
#endif
|
||||
|
||||
if(stream != NULL)
|
||||
free(stream);
|
||||
|
||||
if(dev == NULL)
|
||||
return;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_device->lock);
|
||||
|
||||
tinyalsa_mixer_set_input_state(tinyalsa_audio_device->mixer, 0);
|
||||
tinyalsa_audio_device->stream_in = NULL;
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
}
|
||||
|
||||
int audio_hw_open_input_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_in **stream_in)
|
||||
{
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
struct tinyalsa_audio_stream_in *tinyalsa_audio_stream_in;
|
||||
struct audio_stream_in *stream;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %d, %p, %p)",
|
||||
__func__, dev, devices, config, stream_in);
|
||||
|
||||
if(dev == NULL || config == NULL || stream_in == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
*stream_in = NULL;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
tinyalsa_audio_stream_in = calloc(1, sizeof(struct tinyalsa_audio_stream_in));
|
||||
|
||||
if(tinyalsa_audio_stream_in == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
tinyalsa_audio_stream_in->device = tinyalsa_audio_device;
|
||||
tinyalsa_audio_device->stream_in = tinyalsa_audio_stream_in;
|
||||
stream = &(tinyalsa_audio_stream_in->stream);
|
||||
|
||||
stream->common.get_sample_rate = audio_in_get_sample_rate;
|
||||
stream->common.set_sample_rate = audio_in_set_sample_rate;
|
||||
stream->common.get_buffer_size = audio_in_get_buffer_size;
|
||||
stream->common.get_channels = audio_in_get_channels;
|
||||
stream->common.get_format = audio_in_get_format;
|
||||
stream->common.set_format = audio_in_set_format;
|
||||
stream->common.standby = audio_in_standby;
|
||||
stream->common.dump = audio_in_dump;
|
||||
stream->common.set_parameters = audio_in_set_parameters;
|
||||
stream->common.get_parameters = audio_in_get_parameters;
|
||||
stream->common.add_audio_effect = audio_in_add_audio_effect;
|
||||
stream->common.remove_audio_effect = audio_in_remove_audio_effect;
|
||||
stream->set_gain = audio_in_set_gain;
|
||||
stream->read = audio_in_read;
|
||||
stream->get_input_frames_lost = audio_in_get_input_frames_lost;
|
||||
|
||||
if(tinyalsa_audio_device->mixer == NULL)
|
||||
goto error_stream;
|
||||
|
||||
tinyalsa_audio_stream_in->mixer_props =
|
||||
tinyalsa_mixer_get_input_props(tinyalsa_audio_device->mixer);
|
||||
|
||||
if(tinyalsa_audio_stream_in->mixer_props == NULL)
|
||||
goto error_stream;
|
||||
|
||||
// Default values
|
||||
if(tinyalsa_audio_stream_in->mixer_props->rate == 0)
|
||||
tinyalsa_audio_stream_in->mixer_props->rate = 44100;
|
||||
if(tinyalsa_audio_stream_in->mixer_props->channel_mask == 0)
|
||||
tinyalsa_audio_stream_in->mixer_props->channel_mask = AUDIO_CHANNEL_IN_STEREO;
|
||||
if(tinyalsa_audio_stream_in->mixer_props->format == 0)
|
||||
tinyalsa_audio_stream_in->mixer_props->format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
|
||||
if(config->sample_rate == 0)
|
||||
tinyalsa_audio_stream_in->rate =
|
||||
tinyalsa_audio_stream_in->mixer_props->rate;
|
||||
else
|
||||
tinyalsa_audio_stream_in->rate = config->sample_rate;
|
||||
if(config->channel_mask == 0)
|
||||
tinyalsa_audio_stream_in->channel_mask =
|
||||
tinyalsa_audio_stream_in->mixer_props->channel_mask;
|
||||
else
|
||||
tinyalsa_audio_stream_in->channel_mask = config->channel_mask;
|
||||
if(config->format == 0)
|
||||
tinyalsa_audio_stream_in->format =
|
||||
tinyalsa_audio_stream_in->mixer_props->format;
|
||||
else
|
||||
tinyalsa_audio_stream_in->format = config->format;
|
||||
|
||||
tinyalsa_audio_stream_in->buffer_provider.get_next_buffer =
|
||||
audio_in_get_next_buffer;
|
||||
tinyalsa_audio_stream_in->buffer_provider.release_buffer =
|
||||
audio_in_release_buffer;
|
||||
|
||||
if(tinyalsa_audio_stream_in->rate != tinyalsa_audio_stream_in->mixer_props->rate) {
|
||||
rc = audio_in_resampler_open(tinyalsa_audio_stream_in);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open resampler!");
|
||||
goto error_stream;
|
||||
}
|
||||
}
|
||||
|
||||
config->sample_rate = tinyalsa_audio_stream_in->rate;
|
||||
config->channel_mask = tinyalsa_audio_stream_in->channel_mask;
|
||||
config->format = tinyalsa_audio_stream_in->format;
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_device->lock);
|
||||
|
||||
rc = tinyalsa_mixer_set_input_state(tinyalsa_audio_device->mixer, 1);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to set input state");
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
goto error_stream;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_stream_in->lock);
|
||||
|
||||
audio_in_set_route(tinyalsa_audio_stream_in, devices);
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
|
||||
rc = audio_in_pcm_open(tinyalsa_audio_stream_in);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open pcm device");
|
||||
pthread_mutex_unlock(&tinyalsa_audio_stream_in->lock);
|
||||
goto error_stream;
|
||||
}
|
||||
|
||||
audio_in_pcm_close(tinyalsa_audio_stream_in);
|
||||
|
||||
tinyalsa_audio_stream_in->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_stream_in->lock);
|
||||
|
||||
*stream_in = stream;
|
||||
|
||||
return 0;
|
||||
|
||||
error_stream:
|
||||
if(tinyalsa_audio_stream_in->resampler != NULL)
|
||||
audio_in_resampler_close(tinyalsa_audio_stream_in);
|
||||
free(tinyalsa_audio_stream_in);
|
||||
tinyalsa_audio_device->stream_in = NULL;
|
||||
|
||||
return -1;
|
||||
}
|
747
tinyalsa_audio/audio_out.c
Normal file
747
tinyalsa_audio/audio_out.c
Normal file
@ -0,0 +1,747 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
|
||||
*
|
||||
* This is based on Galaxy Nexus audio.primary.tuna implementation:
|
||||
* Copyright 2011, The Android Open-Source Project
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "TinyALSA-Audio Output"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <cutils/str_parms.h>
|
||||
#include <cutils/log.h>
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
#include <yamaha-mc1n2-audio.h>
|
||||
#endif
|
||||
|
||||
#define EFFECT_UUID_NULL EFFECT_UUID_NULL_OUT
|
||||
#define EFFECT_UUID_NULL_STR EFFECT_UUID_NULL_STR_OUT
|
||||
#include <audio_utils/resampler.h>
|
||||
#include "audio_hw.h"
|
||||
#include "mixer.h"
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
|
||||
int audio_out_pcm_open(struct tinyalsa_audio_stream_out *stream_out)
|
||||
{
|
||||
struct pcm *pcm = NULL;
|
||||
struct pcm_config pcm_config;
|
||||
|
||||
if(stream_out == NULL)
|
||||
return -1;
|
||||
|
||||
memset(&pcm_config, 0, sizeof(pcm_config));
|
||||
pcm_config.channels = popcount(stream_out->mixer_props->channel_mask);
|
||||
pcm_config.rate = stream_out->mixer_props->rate;
|
||||
switch(stream_out->mixer_props->format) {
|
||||
case AUDIO_FORMAT_PCM_16_BIT:
|
||||
pcm_config.format = PCM_FORMAT_S16_LE;
|
||||
break;
|
||||
case AUDIO_FORMAT_PCM_32_BIT:
|
||||
pcm_config.format = PCM_FORMAT_S32_LE;
|
||||
break;
|
||||
default:
|
||||
ALOGE("Invalid format: 0x%x", stream_out->mixer_props->format);
|
||||
return -1;
|
||||
}
|
||||
pcm_config.period_size = stream_out->mixer_props->period_size;
|
||||
pcm_config.period_count = stream_out->mixer_props->period_count;
|
||||
|
||||
pcm = pcm_open(stream_out->mixer_props->card,
|
||||
stream_out->mixer_props->device, PCM_OUT, &pcm_config);
|
||||
|
||||
if(pcm == NULL || !pcm_is_ready(pcm)) {
|
||||
ALOGE("Unable to open pcm device: %s", pcm_get_error(pcm));
|
||||
return -1;
|
||||
}
|
||||
|
||||
stream_out->pcm = pcm;
|
||||
|
||||
if(stream_out->resampler != NULL)
|
||||
stream_out->resampler->reset(stream_out->resampler);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_out_pcm_close(struct tinyalsa_audio_stream_out *stream_out)
|
||||
{
|
||||
if(stream_out->pcm == NULL)
|
||||
return;
|
||||
|
||||
pcm_close(stream_out->pcm);
|
||||
stream_out->pcm = NULL;
|
||||
}
|
||||
|
||||
int audio_out_set_route(struct tinyalsa_audio_stream_out *stream_out,
|
||||
audio_devices_t device)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if(stream_out == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out->device_current = device;
|
||||
|
||||
if(device == 0) {
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
return stream_out->stream.common.standby((struct audio_stream *) stream_out);
|
||||
}
|
||||
|
||||
tinyalsa_mixer_set_device(stream_out->device->mixer, stream_out->device_current);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
yamaha_mc1n2_audio_set_route(stream_out->device->mc1n2_pdata, device);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_out_resampler_open(struct tinyalsa_audio_stream_out *stream_out)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if(stream_out == NULL)
|
||||
return -1;
|
||||
|
||||
rc = create_resampler(stream_out->rate,
|
||||
stream_out->mixer_props->rate,
|
||||
popcount(stream_out->channel_mask),
|
||||
RESAMPLER_QUALITY_DEFAULT,
|
||||
NULL,
|
||||
&stream_out->resampler);
|
||||
if(rc < 0 || stream_out->resampler == NULL) {
|
||||
ALOGE("Failed to create resampler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void audio_out_resampler_close(struct tinyalsa_audio_stream_out *stream_out)
|
||||
{
|
||||
if(stream_out == NULL)
|
||||
return;
|
||||
|
||||
if(stream_out->resampler != NULL) {
|
||||
release_resampler(stream_out->resampler);
|
||||
stream_out->resampler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int audio_out_write_process(struct tinyalsa_audio_stream_out *stream_out, void *buffer, int size)
|
||||
{
|
||||
size_t frames_out;
|
||||
|
||||
size_t frames_in;
|
||||
int size_in;
|
||||
void *buffer_in = NULL;
|
||||
|
||||
int frames_out_resampler;
|
||||
int size_out_resampler;
|
||||
void *buffer_out_resampler = NULL;
|
||||
|
||||
int frames_out_channels;
|
||||
int size_out_channels;
|
||||
void *buffer_out_channels = NULL;
|
||||
|
||||
int i, j;
|
||||
int rc;
|
||||
|
||||
if(stream_out == NULL || buffer == NULL || size <= 0)
|
||||
return -1;
|
||||
|
||||
frames_in = size / audio_stream_frame_size((struct audio_stream *) stream_out);
|
||||
size_in = size;
|
||||
buffer_in = buffer;
|
||||
|
||||
if(stream_out->resampler != NULL) {
|
||||
frames_out_resampler = (frames_in * stream_out->mixer_props->rate) /
|
||||
stream_out->rate;
|
||||
frames_out_resampler = ((frames_out_resampler + 15) / 16) * 16;
|
||||
size_out_resampler = frames_out_resampler * audio_stream_frame_size((struct audio_stream *) stream_out);
|
||||
buffer_out_resampler = calloc(1, size_out_resampler);
|
||||
|
||||
frames_out = frames_out_resampler;
|
||||
stream_out->resampler->resample_from_input(stream_out->resampler,
|
||||
buffer_in, &frames_in, buffer_out_resampler, &frames_out);
|
||||
|
||||
frames_in = frames_out;
|
||||
size_in = frames_out * audio_stream_frame_size((struct audio_stream *) stream_out);
|
||||
buffer_in = buffer_out_resampler;
|
||||
}
|
||||
|
||||
if(buffer_in == NULL)
|
||||
goto error;
|
||||
|
||||
//FIXME: This is only for PCM 16
|
||||
if(popcount(stream_out->mixer_props->channel_mask) < popcount(stream_out->channel_mask)) {
|
||||
frames_out_channels = frames_in;
|
||||
size_out_channels = frames_out_channels * popcount(stream_out->mixer_props->channel_mask) * audio_bytes_per_sample(stream_out->mixer_props->format);
|
||||
buffer_out_channels = calloc(1, size_out_channels);
|
||||
|
||||
int channels_count_in = popcount(stream_out->channel_mask);
|
||||
int channels_count_out = popcount(stream_out->mixer_props->channel_mask);
|
||||
int ratio = channels_count_in / channels_count_out;
|
||||
|
||||
int16_t *byte_in = (int16_t *) buffer_in;
|
||||
int16_t *byte_out = (int16_t *) buffer_out_channels;
|
||||
int16_t byte;
|
||||
|
||||
for(i=0 ; i < frames_out_channels * channels_count_out; i++) {
|
||||
byte = 0;
|
||||
for(j=0 ; j < ratio ; j++) {
|
||||
byte += *byte_in / ratio;
|
||||
byte_in++;
|
||||
}
|
||||
|
||||
*byte_out = byte;
|
||||
byte_out++;
|
||||
}
|
||||
|
||||
frames_in = frames_out_channels;
|
||||
size_in = size_out_channels;
|
||||
buffer_in = buffer_out_channels;
|
||||
} else if(popcount(stream_out->channel_mask) != popcount(stream_out->mixer_props->channel_mask)) {
|
||||
ALOGE("Asked for more channels than software can provide!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(buffer_in != NULL) {
|
||||
if(stream_out->pcm == NULL || !pcm_is_ready(stream_out->pcm)) {
|
||||
ALOGE("pcm device is not ready");
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = pcm_write(stream_out->pcm, buffer_in, size_in);
|
||||
if(rc != 0) {
|
||||
ALOGE("pcm write failed!");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if(buffer_out_resampler != NULL)
|
||||
free(buffer_out_resampler);
|
||||
if(buffer_out_channels != NULL)
|
||||
free(buffer_out_channels);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if(buffer_out_resampler != NULL)
|
||||
free(buffer_out_resampler);
|
||||
if(buffer_out_channels != NULL)
|
||||
free(buffer_out_channels);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static uint32_t audio_out_get_sample_rate(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
|
||||
if(stream == NULL)
|
||||
return 0;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
return stream_out->rate;
|
||||
}
|
||||
|
||||
static int audio_out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
|
||||
ALOGD("%s(%p, %d)", __func__, stream, rate);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out->rate != (int) rate) {
|
||||
pthread_mutex_lock(&stream_out->lock);
|
||||
|
||||
stream_out->rate = rate;
|
||||
|
||||
if(stream_out->rate != stream_out->mixer_props->rate) {
|
||||
audio_out_resampler_close(stream_out);
|
||||
audio_out_resampler_open(stream_out);
|
||||
|
||||
stream_out->standby = 1;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t audio_out_get_buffer_size(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
size_t size;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
size = (stream_out->mixer_props->period_size * stream_out->rate) /
|
||||
stream_out->mixer_props->rate;
|
||||
size = ((size + 15) / 16) * 16;
|
||||
size = size * audio_stream_frame_size((struct audio_stream *) stream);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static uint32_t audio_out_get_channels(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
return stream_out->channel_mask;
|
||||
}
|
||||
|
||||
static audio_format_t audio_out_get_format(const struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
return stream_out->format;
|
||||
}
|
||||
|
||||
static int audio_out_set_format(struct audio_stream *stream, audio_format_t format)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
|
||||
ALOGD("%s(%p, %d)", __func__, stream, format);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out->format != (audio_format_t) format) {
|
||||
pthread_mutex_lock(&stream_out->lock);
|
||||
|
||||
stream_out->format = format;
|
||||
|
||||
if(stream_out->format != stream_out->mixer_props->format)
|
||||
stream_out->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_out_standby(struct audio_stream *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p)", __func__, stream);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
pthread_mutex_lock(&stream_out->lock);
|
||||
|
||||
if(stream_out->pcm != NULL)
|
||||
audio_out_pcm_close(stream_out);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
if(!stream_out->standby) {
|
||||
rc = yamaha_mc1n2_audio_output_stop(stream_out->device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
stream_out->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_out_dump(const struct audio_stream *stream, int fd)
|
||||
{
|
||||
ALOGD("%s(%p, %d)", __func__, stream, fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_out_set_parameters(struct audio_stream *stream, const char *kvpairs)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
struct str_parms *parms;
|
||||
char value_string[32] = { 0 };
|
||||
int value;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %s)", __func__, stream, kvpairs);
|
||||
|
||||
if(stream == NULL || kvpairs == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out->device == NULL || stream_out->device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
parms = str_parms_create_str(kvpairs);
|
||||
if(parms == NULL)
|
||||
return -1;
|
||||
|
||||
rc = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value_string, sizeof(value_string));
|
||||
if(rc < 0)
|
||||
goto error_params;
|
||||
|
||||
value = atoi(value_string);
|
||||
|
||||
pthread_mutex_lock(&stream_out->device->lock);
|
||||
|
||||
if(stream_out->device_current != (audio_devices_t) value) {
|
||||
pthread_mutex_lock(&stream_out->lock);
|
||||
audio_out_set_route(stream_out, (audio_devices_t) value);
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
}
|
||||
if(stream_out->device->ril_interface != NULL && stream_out->device->ril_interface->device_current != (audio_devices_t) value) {
|
||||
audio_ril_interface_set_route(stream_out->device->ril_interface, (audio_devices_t) value);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stream_out->device->lock);
|
||||
|
||||
str_parms_destroy(parms);
|
||||
|
||||
return 0;
|
||||
|
||||
error_params:
|
||||
str_parms_destroy(parms);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *audio_out_get_parameters(const struct audio_stream *stream, const char *keys)
|
||||
{
|
||||
ALOGD("%s(%p, %s)", __func__, stream, keys);
|
||||
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static uint32_t audio_out_get_latency(const struct audio_stream_out *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
uint32_t latency;
|
||||
|
||||
ALOGD("%s(%p)", __func__, stream);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
latency = (stream_out->mixer_props->period_size *
|
||||
stream_out->mixer_props->period_count * 1000) /
|
||||
stream_out->mixer_props->rate;
|
||||
|
||||
return latency;
|
||||
}
|
||||
|
||||
static int audio_out_set_volume(struct audio_stream_out *stream, float left,
|
||||
float right)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
float volume;
|
||||
|
||||
ALOGD("%s(%p, %f, %f)", __func__, stream, left, right);
|
||||
|
||||
if(stream == NULL)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out->device == NULL || stream_out->device->mixer == NULL)
|
||||
return -1;
|
||||
|
||||
volume = (left + right) / 2;
|
||||
|
||||
pthread_mutex_lock(&stream_out->device->lock);
|
||||
tinyalsa_mixer_set_output_volume(stream_out->device->mixer,
|
||||
stream_out->device_current, volume);
|
||||
pthread_mutex_unlock(&stream_out->device->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t audio_out_write(struct audio_stream_out *stream,
|
||||
const void *buffer, size_t bytes)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
int rc;
|
||||
|
||||
if(stream == NULL || buffer == NULL || bytes <= 0)
|
||||
return -1;
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out->device == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&stream_out->lock);
|
||||
|
||||
if(stream_out->standby) {
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
rc = yamaha_mc1n2_audio_output_start(stream_out->device->mc1n2_pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set Yamaha-MC1N2-Audio route");
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = audio_out_pcm_open(stream_out);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open pcm device");
|
||||
goto error;
|
||||
}
|
||||
|
||||
stream_out->standby = 0;
|
||||
}
|
||||
|
||||
rc = audio_out_write_process(stream_out, (void *) buffer, (int) bytes);
|
||||
if(rc < 0) {
|
||||
ALOGE("Process and write failed!");
|
||||
goto error;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
|
||||
return bytes;
|
||||
|
||||
error:
|
||||
pthread_mutex_unlock(&stream_out->lock);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int audio_out_get_render_position(const struct audio_stream_out *stream,
|
||||
uint32_t *dsp_frames)
|
||||
{
|
||||
ALOGD("%s(%p, %p)", __func__, stream, dsp_frames);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int audio_out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGD("%s(%p, %p)", __func__, stream, effect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int audio_out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGD("%s(%p, %p)", __func__, stream, effect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interface
|
||||
*/
|
||||
|
||||
void audio_hw_close_output_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_out *stream)
|
||||
{
|
||||
struct tinyalsa_audio_stream_out *stream_out;
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
|
||||
ALOGD("%s(%p)", __func__, stream);
|
||||
|
||||
stream_out = (struct tinyalsa_audio_stream_out *) stream;
|
||||
|
||||
if(stream_out != NULL && stream_out->resampler != NULL)
|
||||
audio_out_resampler_close(stream_out);
|
||||
|
||||
#ifdef YAMAHA_MC1N2_AUDIO
|
||||
if(stream_out != NULL && !stream_out->standby)
|
||||
yamaha_mc1n2_audio_output_stop(stream_out->device->mc1n2_pdata);
|
||||
#endif
|
||||
|
||||
if(stream != NULL)
|
||||
free(stream);
|
||||
|
||||
if(dev == NULL)
|
||||
return;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_device->lock);
|
||||
|
||||
tinyalsa_mixer_set_output_state(tinyalsa_audio_device->mixer, 0);
|
||||
tinyalsa_audio_device->stream_out = NULL;
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
}
|
||||
|
||||
int audio_hw_open_output_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
audio_output_flags_t flags,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_out **stream_out)
|
||||
{
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
struct tinyalsa_audio_stream_out *tinyalsa_audio_stream_out;
|
||||
struct audio_stream_out *stream;
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%p, %d, %p, %p)",
|
||||
__func__, dev, devices, config, stream_out);
|
||||
|
||||
if(dev == NULL || config == NULL || stream_out == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
//tuna added this for JB... but does it apply to us?
|
||||
*stream_out = NULL;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
tinyalsa_audio_stream_out = calloc(1, sizeof(struct tinyalsa_audio_stream_out));
|
||||
|
||||
if(tinyalsa_audio_stream_out == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
tinyalsa_audio_stream_out->device = tinyalsa_audio_device;
|
||||
tinyalsa_audio_device->stream_out = tinyalsa_audio_stream_out;
|
||||
stream = &(tinyalsa_audio_stream_out->stream);
|
||||
|
||||
stream->common.get_sample_rate = audio_out_get_sample_rate;
|
||||
stream->common.set_sample_rate = audio_out_set_sample_rate;
|
||||
stream->common.get_buffer_size = audio_out_get_buffer_size;
|
||||
stream->common.get_channels = audio_out_get_channels;
|
||||
stream->common.get_format = audio_out_get_format;
|
||||
stream->common.set_format = audio_out_set_format;
|
||||
stream->common.standby = audio_out_standby;
|
||||
stream->common.dump = audio_out_dump;
|
||||
stream->common.set_parameters = audio_out_set_parameters;
|
||||
stream->common.get_parameters = audio_out_get_parameters;
|
||||
stream->common.add_audio_effect = audio_out_add_audio_effect;
|
||||
stream->common.remove_audio_effect = audio_out_remove_audio_effect;
|
||||
stream->get_latency = audio_out_get_latency;
|
||||
stream->set_volume = audio_out_set_volume;
|
||||
stream->write = audio_out_write;
|
||||
stream->get_render_position = audio_out_get_render_position;
|
||||
|
||||
if(tinyalsa_audio_device->mixer == NULL)
|
||||
goto error_stream;
|
||||
|
||||
tinyalsa_audio_stream_out->mixer_props =
|
||||
tinyalsa_mixer_get_output_props(tinyalsa_audio_device->mixer);
|
||||
|
||||
if(tinyalsa_audio_stream_out->mixer_props == NULL)
|
||||
goto error_stream;
|
||||
|
||||
// Default values
|
||||
if(tinyalsa_audio_stream_out->mixer_props->rate == 0)
|
||||
tinyalsa_audio_stream_out->mixer_props->rate = 44100;
|
||||
if(tinyalsa_audio_stream_out->mixer_props->channel_mask == 0)
|
||||
tinyalsa_audio_stream_out->mixer_props->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
|
||||
if(tinyalsa_audio_stream_out->mixer_props->format == 0)
|
||||
tinyalsa_audio_stream_out->mixer_props->format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
|
||||
//Default incoming data will always be 44100Hz, stereo, PCM 16
|
||||
if(config->sample_rate == 0)
|
||||
tinyalsa_audio_stream_out->rate = 44100;
|
||||
else
|
||||
tinyalsa_audio_stream_out->rate = config->sample_rate;
|
||||
if(config->channel_mask == 0)
|
||||
tinyalsa_audio_stream_out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
|
||||
else
|
||||
tinyalsa_audio_stream_out->channel_mask = config->channel_mask;
|
||||
if(config->format == 0)
|
||||
tinyalsa_audio_stream_out->format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
else
|
||||
tinyalsa_audio_stream_out->format = config->format;
|
||||
|
||||
if(tinyalsa_audio_stream_out->rate != tinyalsa_audio_stream_out->mixer_props->rate) {
|
||||
rc = audio_out_resampler_open(tinyalsa_audio_stream_out);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open resampler!");
|
||||
goto error_stream;
|
||||
}
|
||||
}
|
||||
|
||||
config->sample_rate = (uint32_t) tinyalsa_audio_stream_out->rate;
|
||||
config->channel_mask = (uint32_t) tinyalsa_audio_stream_out->channel_mask;
|
||||
config->format = (uint32_t) tinyalsa_audio_stream_out->format;
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_device->lock);
|
||||
|
||||
rc = tinyalsa_mixer_set_output_state(tinyalsa_audio_device->mixer, 1);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to set output state");
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
goto error_stream;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&tinyalsa_audio_stream_out->lock);
|
||||
|
||||
audio_out_set_route(tinyalsa_audio_stream_out, devices);
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_device->lock);
|
||||
|
||||
rc = audio_out_pcm_open(tinyalsa_audio_stream_out);
|
||||
if(rc < 0) {
|
||||
ALOGE("Unable to open pcm device");
|
||||
pthread_mutex_unlock(&tinyalsa_audio_stream_out->lock);
|
||||
goto error_stream;
|
||||
}
|
||||
|
||||
audio_out_pcm_close(tinyalsa_audio_stream_out);
|
||||
|
||||
tinyalsa_audio_stream_out->standby = 1;
|
||||
|
||||
pthread_mutex_unlock(&tinyalsa_audio_stream_out->lock);
|
||||
|
||||
*stream_out = stream;
|
||||
|
||||
return 0;
|
||||
|
||||
error_stream:
|
||||
free(tinyalsa_audio_stream_out);
|
||||
tinyalsa_audio_device->stream_out = NULL;
|
||||
|
||||
return -1;
|
||||
}
|
374
tinyalsa_audio/audio_ril_interface.c
Normal file
374
tinyalsa_audio/audio_ril_interface.c
Normal file
@ -0,0 +1,374 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "TinyALSA-Audio RIL Interface"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#define EFFECT_UUID_NULL EFFECT_UUID_NULL_RIL
|
||||
#define EFFECT_UUID_NULL_STR EFFECT_UUID_NULL_STR_RIL
|
||||
#include "audio_hw.h"
|
||||
|
||||
#include "audio_ril_interface.h"
|
||||
|
||||
/* Function pointers */
|
||||
void *(*_ril_open_client)(void);
|
||||
int (*_ril_close_client)(void *);
|
||||
int (*_ril_connect)(void *);
|
||||
int (*_ril_is_connected)(void *);
|
||||
int (*_ril_disconnect)(void *);
|
||||
int (*_ril_set_call_volume)(void *, enum ril_sound_type, int);
|
||||
int (*_ril_set_call_audio_path)(void *, enum ril_audio_path);
|
||||
int (*_ril_set_call_clock_sync)(void *, enum ril_clock_state);
|
||||
int (*_ril_set_call_twomic)(void *, enum ril_twomic_device, enum ril_twomic_enable);
|
||||
int (*_ril_register_unsolicited_handler)(void *, int, void *);
|
||||
int (*_ril_get_wb_amr)(void *, void *);
|
||||
|
||||
#define VOLUME_STEPS_DEFAULT "5"
|
||||
#define VOLUME_STEPS_PROPERTY "ro.config.vc_call_vol_steps"
|
||||
|
||||
static int audio_ril_interface_connect_if_required(struct tinyalsa_audio_ril_interface *ril_interface)
|
||||
{
|
||||
if (_ril_is_connected(ril_interface->interface))
|
||||
return 0;
|
||||
|
||||
if (_ril_connect(ril_interface->interface) != RIL_CLIENT_ERR_SUCCESS) {
|
||||
ALOGE("ril_connect() failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get wb amr status to set pcm samplerate depending on
|
||||
wb amr status when ril is connected. */
|
||||
/* FIXME: AMR */
|
||||
#if 0
|
||||
if(_ril_get_wb_amr)
|
||||
_ril_get_wb_amr(ril_interface->client, ril_set_wb_amr_callback);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_ril_interface_set_mic_mute(struct tinyalsa_audio_ril_interface *ril_interface, bool state)
|
||||
{
|
||||
/*
|
||||
* If you look at the Replicant libaudio-ril-interface
|
||||
* this function is just stubbed out there. So let's not
|
||||
* bother with it
|
||||
*/
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int audio_ril_interface_set_voice_volume(struct tinyalsa_audio_ril_interface *ril_interface,
|
||||
audio_devices_t device, float volume)
|
||||
{
|
||||
int rc;
|
||||
|
||||
enum ril_sound_type sound_type;
|
||||
|
||||
if(ril_interface == NULL)
|
||||
return -1;
|
||||
|
||||
ALOGD("%s(%d, %f)", __func__, device, volume);
|
||||
|
||||
pthread_mutex_lock(&ril_interface->lock);
|
||||
|
||||
/* Should this be returning -1 when a failure occurs? */
|
||||
if (audio_ril_interface_connect_if_required(ril_interface))
|
||||
return 0;
|
||||
|
||||
if(_ril_set_call_volume == NULL)
|
||||
goto error;
|
||||
|
||||
switch((int) device) {
|
||||
case AUDIO_DEVICE_OUT_EARPIECE:
|
||||
sound_type = SOUND_TYPE_VOICE;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_SPEAKER:
|
||||
sound_type = SOUND_TYPE_SPEAKER;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_WIRED_HEADSET:
|
||||
case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
|
||||
sound_type = SOUND_TYPE_HEADSET;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
|
||||
sound_type = SOUND_TYPE_BTVOICE;
|
||||
break;
|
||||
default:
|
||||
sound_type = SOUND_TYPE_VOICE;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = _ril_set_call_volume(ril_interface->interface, sound_type,
|
||||
(int)(volume * ril_interface->volume_steps_max));
|
||||
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set RIL interface voice volume");
|
||||
goto error;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int audio_ril_interface_set_route(struct tinyalsa_audio_ril_interface *ril_interface, audio_devices_t device)
|
||||
{
|
||||
int rc;
|
||||
|
||||
enum ril_audio_path path;
|
||||
|
||||
ALOGD("%s(%d)", __func__, device);
|
||||
|
||||
if(ril_interface == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&ril_interface->lock);
|
||||
|
||||
/* Should this be returning -1 when a failure occurs? */
|
||||
if (audio_ril_interface_connect_if_required(ril_interface))
|
||||
return 0;
|
||||
|
||||
ril_interface->device_current = device;
|
||||
|
||||
if(_ril_set_call_audio_path == NULL)
|
||||
goto error;
|
||||
|
||||
switch((int) device) {
|
||||
case AUDIO_DEVICE_OUT_EARPIECE:
|
||||
path = SOUND_AUDIO_PATH_HANDSET;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_SPEAKER:
|
||||
path = SOUND_AUDIO_PATH_SPEAKER;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_WIRED_HEADSET:
|
||||
path = SOUND_AUDIO_PATH_HEADSET;
|
||||
break;
|
||||
case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
|
||||
path = SOUND_AUDIO_PATH_HEADPHONE;
|
||||
break;
|
||||
// FIXME: Bluetooth values/path relation
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
|
||||
path = SOUND_AUDIO_PATH_BLUETOOTH;
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
|
||||
case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
|
||||
path = SOUND_AUDIO_PATH_BLUETOOTH_NO_NR;
|
||||
break;
|
||||
default:
|
||||
path = SOUND_AUDIO_PATH_HANDSET;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = _ril_set_call_audio_path(ril_interface->interface,path);
|
||||
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set RIL interface route");
|
||||
goto error;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int audio_ril_interface_set_twomic(struct tinyalsa_audio_ril_interface *ril_interface, enum ril_twomic_enable twomic)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s(%d)", __func__, twomic);
|
||||
|
||||
if(ril_interface == NULL)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&ril_interface->lock);
|
||||
|
||||
/* Should this be returning -1 when a failure occurs? */
|
||||
if (audio_ril_interface_connect_if_required(ril_interface))
|
||||
return 0;
|
||||
|
||||
if(_ril_set_call_twomic == NULL)
|
||||
goto error;
|
||||
|
||||
rc = _ril_set_call_twomic(ril_interface->interface,AUDIENCE,twomic);
|
||||
|
||||
if(rc < 0) {
|
||||
ALOGE("Failed to set RIL interface route");
|
||||
goto error;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
pthread_mutex_unlock(&ril_interface->lock);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interface
|
||||
*/
|
||||
|
||||
void audio_ril_interface_close(struct audio_hw_device *dev,
|
||||
struct tinyalsa_audio_ril_interface *ril_interface)
|
||||
{
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
|
||||
ALOGD("%s(%p)", __func__, ril_interface);
|
||||
|
||||
if(ril_interface->dl_handle != NULL) {
|
||||
if ((_ril_disconnect(ril_interface->interface) != RIL_CLIENT_ERR_SUCCESS) ||
|
||||
(_ril_close_client(ril_interface->interface) != RIL_CLIENT_ERR_SUCCESS)) {
|
||||
ALOGE("ril_disconnect() or ril_close_client() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
dlclose(ril_interface->dl_handle);
|
||||
ril_interface->dl_handle = NULL;
|
||||
}
|
||||
|
||||
if(ril_interface != NULL)
|
||||
free(ril_interface);
|
||||
|
||||
if(dev == NULL)
|
||||
return;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
|
||||
tinyalsa_audio_device->ril_interface = NULL;
|
||||
}
|
||||
|
||||
int audio_ril_interface_open(struct audio_hw_device *dev, audio_devices_t device,
|
||||
struct tinyalsa_audio_ril_interface **ril_interface)
|
||||
{
|
||||
struct audio_ril_interface *(*audio_ril_interface_open)(void);
|
||||
|
||||
struct tinyalsa_audio_device *tinyalsa_audio_device;
|
||||
struct tinyalsa_audio_ril_interface *tinyalsa_audio_ril_interface;
|
||||
struct audio_ril_interface *interface;
|
||||
void *dl_handle;
|
||||
int rc;
|
||||
|
||||
char property[PROPERTY_VALUE_MAX];
|
||||
|
||||
ALOGD("%s(%p, %d, %p)", __func__, dev, device, ril_interface);
|
||||
|
||||
if(dev == NULL || ril_interface == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
|
||||
tinyalsa_audio_ril_interface = calloc(1, sizeof(struct tinyalsa_audio_ril_interface));
|
||||
|
||||
if(tinyalsa_audio_ril_interface == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
tinyalsa_audio_ril_interface->device = tinyalsa_audio_device;
|
||||
tinyalsa_audio_device->ril_interface = tinyalsa_audio_ril_interface;
|
||||
|
||||
dl_handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW);
|
||||
if(dl_handle == NULL) {
|
||||
ALOGE("Unable to dlopen lib: %s", RIL_CLIENT_LIBPATH);
|
||||
goto error_interface;
|
||||
}
|
||||
|
||||
_ril_open_client = dlsym(dl_handle, "OpenClient_RILD");
|
||||
_ril_close_client = dlsym(dl_handle, "CloseClient_RILD");
|
||||
_ril_connect = dlsym(dl_handle, "Connect_RILD");
|
||||
_ril_is_connected = dlsym(dl_handle, "isConnected_RILD");
|
||||
_ril_disconnect = dlsym(dl_handle, "Disconnect_RILD");
|
||||
_ril_set_call_volume = dlsym(dl_handle, "SetCallVolume");
|
||||
_ril_set_call_audio_path = dlsym(dl_handle, "SetCallAudioPath");
|
||||
_ril_set_call_clock_sync = dlsym(dl_handle, "SetCallClockSync");
|
||||
_ril_set_call_twomic = dlsym(dl_handle, "SetTwoMicControl");
|
||||
|
||||
_ril_register_unsolicited_handler = dlsym(dl_handle,
|
||||
"RegisterUnsolicitedHandler");
|
||||
/* since this function is not supported in all RILs, don't require it */
|
||||
_ril_get_wb_amr = dlsym(dl_handle, "GetWB_AMR");
|
||||
|
||||
if (!_ril_open_client || !_ril_close_client || !_ril_connect ||
|
||||
!_ril_is_connected || !_ril_disconnect || !_ril_set_call_volume ||
|
||||
!_ril_set_call_audio_path || !_ril_set_call_clock_sync ||
|
||||
!_ril_register_unsolicited_handler || !_ril_set_call_twomic) {
|
||||
ALOGE("Cannot get symbols from '%s'", RIL_CLIENT_LIBPATH);
|
||||
dlclose(dl_handle);
|
||||
goto error_interface;
|
||||
}
|
||||
|
||||
interface = _ril_open_client();
|
||||
if(interface == NULL) {
|
||||
ALOGE("Unable to open audio ril interface");
|
||||
goto error_interface;
|
||||
}
|
||||
|
||||
tinyalsa_audio_ril_interface->interface = interface;
|
||||
tinyalsa_audio_ril_interface->dl_handle = dl_handle;
|
||||
|
||||
property_get(VOLUME_STEPS_PROPERTY, property, VOLUME_STEPS_DEFAULT);
|
||||
tinyalsa_audio_ril_interface->volume_steps_max = atoi(property);
|
||||
/* this catches the case where VOLUME_STEPS_PROPERTY does not contain
|
||||
an integer */
|
||||
if (tinyalsa_audio_ril_interface->volume_steps_max == 0)
|
||||
tinyalsa_audio_ril_interface->volume_steps_max = atoi(VOLUME_STEPS_DEFAULT);
|
||||
|
||||
if(device) {
|
||||
tinyalsa_audio_ril_interface->device_current = device;
|
||||
audio_ril_interface_set_route(tinyalsa_audio_ril_interface, device);
|
||||
}
|
||||
|
||||
*ril_interface = tinyalsa_audio_ril_interface;
|
||||
|
||||
return 0;
|
||||
|
||||
error_interface:
|
||||
*ril_interface = NULL;
|
||||
free(tinyalsa_audio_ril_interface);
|
||||
tinyalsa_audio_device->ril_interface = NULL;
|
||||
|
||||
if(dl_handle != NULL)
|
||||
dlclose(dl_handle);
|
||||
|
||||
return -1;
|
||||
}
|
95
tinyalsa_audio/audio_ril_interface.h
Normal file
95
tinyalsa_audio/audio_ril_interface.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 "audio_hw.h"
|
||||
|
||||
#ifndef TINYALSA_AUDIO_RIL_INTERFACE_H
|
||||
#define TINYALSA_AUDIO_RIL_INTERFACE_H
|
||||
|
||||
struct tinyalsa_audio_ril_interface {
|
||||
void *interface;
|
||||
struct tinyalsa_audio_device *device;
|
||||
|
||||
int volume_steps_max;
|
||||
|
||||
void *dl_handle;
|
||||
|
||||
audio_devices_t device_current;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
#define RIL_CLIENT_LIBPATH "libsecril-client.so"
|
||||
|
||||
#define RIL_CLIENT_ERR_SUCCESS 0
|
||||
#define RIL_CLIENT_ERR_AGAIN 1
|
||||
#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized
|
||||
#define RIL_CLIENT_ERR_INVAL 3 // Invalid value
|
||||
#define RIL_CLIENT_ERR_CONNECT 4 // Connection error
|
||||
#define RIL_CLIENT_ERR_IO 5 // IO error
|
||||
#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available
|
||||
#define RIL_CLIENT_ERR_UNKNOWN 7
|
||||
|
||||
enum ril_sound_type {
|
||||
SOUND_TYPE_VOICE,
|
||||
SOUND_TYPE_SPEAKER,
|
||||
SOUND_TYPE_HEADSET,
|
||||
SOUND_TYPE_BTVOICE
|
||||
};
|
||||
|
||||
enum ril_audio_path {
|
||||
SOUND_AUDIO_PATH_HANDSET,
|
||||
SOUND_AUDIO_PATH_HEADSET,
|
||||
SOUND_AUDIO_PATH_SPEAKER,
|
||||
SOUND_AUDIO_PATH_BLUETOOTH,
|
||||
SOUND_AUDIO_PATH_BLUETOOTH_NO_NR,
|
||||
SOUND_AUDIO_PATH_HEADPHONE
|
||||
};
|
||||
|
||||
enum ril_clock_state {
|
||||
SOUND_CLOCK_STOP,
|
||||
SOUND_CLOCK_START
|
||||
};
|
||||
|
||||
/**
|
||||
* Two mic Solution control
|
||||
* Two MIC Solution Device
|
||||
*/
|
||||
enum ril_twomic_device {
|
||||
AUDIENCE,
|
||||
FORTEMEDIA
|
||||
};
|
||||
|
||||
/**
|
||||
* Two MIC Solution Report
|
||||
*/
|
||||
enum ril_twomic_enable {
|
||||
TWO_MIC_SOLUTION_OFF,
|
||||
TWO_MIC_SOLUTION_ON
|
||||
};
|
||||
|
||||
int audio_ril_interface_set_mic_mute(struct tinyalsa_audio_ril_interface *ril_interface, bool state);
|
||||
int audio_ril_interface_set_voice_volume(struct tinyalsa_audio_ril_interface *ril_interface, audio_devices_t device, float volume);
|
||||
int audio_ril_interface_set_route(struct tinyalsa_audio_ril_interface *ril_interface, audio_devices_t device);
|
||||
int audio_ril_interface_set_twomic(struct tinyalsa_audio_ril_interface *ril_interface, enum ril_twomic_enable);
|
||||
|
||||
void audio_ril_interface_close(struct audio_hw_device *dev,
|
||||
struct tinyalsa_audio_ril_interface *interface);
|
||||
int audio_ril_interface_open(struct audio_hw_device *dev, audio_devices_t device,
|
||||
struct tinyalsa_audio_ril_interface **ril_interface);
|
||||
|
||||
#endif
|
1318
tinyalsa_audio/mixer.c
Normal file
1318
tinyalsa_audio/mixer.c
Normal file
File diff suppressed because it is too large
Load Diff
126
tinyalsa_audio/mixer.h
Normal file
126
tinyalsa_audio/mixer.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef TINYALSA_AUDIO_MIXER_H
|
||||
#define TINYALSA_AUDIO_MIXER_H
|
||||
|
||||
#include <tinyalsa/asoundlib.h>
|
||||
|
||||
#include <hardware/audio.h>
|
||||
#include <system/audio.h>
|
||||
|
||||
#define TINYALSA_MIXER_CONFIG_FILE "/system/etc/tinyalsa-audio.xml"
|
||||
|
||||
struct list_head {
|
||||
struct list_head *prev;
|
||||
struct list_head *next;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
enum tinyalsa_mixer_data_type {
|
||||
MIXER_DATA_TYPE_CTRL,
|
||||
MIXER_DATA_TYPE_WRITE,
|
||||
MIXER_DATA_TYPE_MAX
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_data {
|
||||
enum tinyalsa_mixer_data_type type;
|
||||
char *name;
|
||||
char *value;
|
||||
char *attr;
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_device_props {
|
||||
audio_devices_t type;
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_device {
|
||||
struct tinyalsa_mixer_device_props props;
|
||||
struct list_head *enable;
|
||||
struct list_head *disable;
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_io_props {
|
||||
int card;
|
||||
int device;
|
||||
|
||||
int rate;
|
||||
audio_channel_mask_t channel_mask;
|
||||
audio_format_t format;
|
||||
|
||||
int period_size;
|
||||
int period_count;
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_io {
|
||||
struct tinyalsa_mixer_io_props props;
|
||||
struct tinyalsa_mixer_device *device_current;
|
||||
struct list_head *devices;
|
||||
int state;
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer {
|
||||
struct tinyalsa_mixer_io output;
|
||||
struct tinyalsa_mixer_io input;
|
||||
struct tinyalsa_mixer_io modem;
|
||||
struct mixer *mixer;
|
||||
};
|
||||
|
||||
enum tinyalsa_mixer_direction {
|
||||
TINYALSA_MIXER_DIRECTION_OUTPUT,
|
||||
TINYALSA_MIXER_DIRECTION_INPUT,
|
||||
TINYALSA_MIXER_DIRECTION_MODEM,
|
||||
TINYALSA_MIXER_DIRECTION_MAX
|
||||
};
|
||||
|
||||
struct tinyalsa_mixer_config_data {
|
||||
struct tinyalsa_mixer *mixer;
|
||||
struct tinyalsa_mixer_io_props io_props;
|
||||
struct tinyalsa_mixer_device_props device_props;
|
||||
enum tinyalsa_mixer_direction direction;
|
||||
|
||||
struct tinyalsa_mixer_device *device;
|
||||
struct list_head **list_start;
|
||||
struct list_head *list;
|
||||
};
|
||||
|
||||
int tinyalsa_mixer_set_output_state(struct tinyalsa_mixer *mixer, int state);
|
||||
int tinyalsa_mixer_set_input_state(struct tinyalsa_mixer *mixer, int state);
|
||||
int tinyalsa_mixer_set_modem_state(struct tinyalsa_mixer *mixer, int state);
|
||||
|
||||
int tinyalsa_mixer_set_device(struct tinyalsa_mixer *mixer, audio_devices_t device);
|
||||
|
||||
int tinyalsa_mixer_set_output_volume(struct tinyalsa_mixer *mixer,
|
||||
audio_devices_t device, float volume);
|
||||
int tinyalsa_mixer_set_master_volume(struct tinyalsa_mixer *mixer, float volume);
|
||||
int tinyalsa_mixer_set_mic_mute(struct tinyalsa_mixer *mixer,
|
||||
audio_devices_t device, int mute);
|
||||
int tinyalsa_mixer_set_input_gain(struct tinyalsa_mixer *mixer,
|
||||
audio_devices_t device, float gain);
|
||||
int tinyalsa_mixer_set_voice_volume(struct tinyalsa_mixer *mixer,
|
||||
audio_devices_t device, float volume);
|
||||
|
||||
audio_devices_t tinyalsa_mixer_get_supported_devices(struct tinyalsa_mixer *mixer);
|
||||
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_output_props(struct tinyalsa_mixer *mixer);
|
||||
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_input_props(struct tinyalsa_mixer *mixer);
|
||||
struct tinyalsa_mixer_io_props *tinyalsa_mixer_get_modem_props(struct tinyalsa_mixer *mixer);
|
||||
|
||||
void tinyalsa_mixer_close(struct tinyalsa_mixer *mixer);
|
||||
int tinyalsa_mixer_open(struct tinyalsa_mixer **mixer_p, char *config_file);
|
||||
|
||||
#endif
|
41
yamaha-mc1n2-audio/Android.mk
Normal file
41
yamaha-mc1n2-audio/Android.mk
Normal file
@ -0,0 +1,41 @@
|
||||
# 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/>.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifeq ($(strip $(BOARD_USE_YAMAHA_MC1N2_AUDIO)),true)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
device/galaxys2.c \
|
||||
yamaha-mc1n2-audio.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libc \
|
||||
libcutils \
|
||||
libutils
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_MODULE := libyamaha-mc1n2-audio
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif
|
860
yamaha-mc1n2-audio/device/galaxys2.c
Normal file
860
yamaha-mc1n2-audio/device/galaxys2.c
Normal file
@ -0,0 +1,860 @@
|
||||
/*
|
||||
* 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_params_init galaxys2_params_init = {
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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,
|
||||
|
||||
.asDit0[0].abSrcOnOff = { 0x00 },
|
||||
|
||||
.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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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,
|
||||
.asCdsp[2].abSrcOnOff = { 0x00 },
|
||||
.asCdsp[3].abSrcOnOff = { 0x00 },
|
||||
|
||||
.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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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 | MCDRV_SRC3_DIR0_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,
|
||||
},
|
||||
|
||||
.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_params_route galaxys2_params_routes[] = {
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_EARPIECE,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0,
|
||||
.abBex = { 0 },
|
||||
.abWide = { 0 },
|
||||
.abDrc = { 0 },
|
||||
.abEq5 = { 0 },
|
||||
.abEq3 = { 0 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asRcOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON | MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR0_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_SPEAKER,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0,
|
||||
.abBex = { 0 },
|
||||
.abWide = { 0 },
|
||||
.abDrc = { 0 },
|
||||
.abEq5 = { 0 },
|
||||
.abEq3 = { 0 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asSpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR0_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_WIRED_HEADPHONE,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asHpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR0_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_WIRED_HEADSET,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asHpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR0_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_IN_BUILTIN_MIC,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_INPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asDit0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_ON | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC1_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_IN_WIRED_HEADSET,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_INPUT,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asDit0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_OFF | MCDRV_SRC0_MIC2_OFF | MCDRV_SRC0_MIC1_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[1] = MCDRV_SRC1_LINE1_M_OFF | MCDRV_SRC1_LINE1_R_OFF | MCDRV_SRC1_LINE1_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[2] = MCDRV_SRC2_LINE2_M_OFF | MCDRV_SRC2_LINE2_R_OFF | MCDRV_SRC2_LINE2_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_DIRECT_OFF | MCDRV_SRC3_DIR2_OFF | MCDRV_SRC3_DIR1_OFF | MCDRV_SRC3_DIR0_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[4] = MCDRV_SRC4_ADC1_OFF | MCDRV_SRC4_ADC0_ON | MCDRV_SRC4_PDM_OFF | MCDRV_SRC4_DTMF_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_OFF | MCDRV_SRC5_DAC_R_OFF | MCDRV_SRC5_DAC_L_OFF,
|
||||
.path_info.asDit0[0].abSrcOnOff[6] = MCDRV_SRC6_CDSP_DIRECT_OFF | MCDRV_SRC6_CDSP_OFF | MCDRV_SRC6_AE_OFF | MCDRV_SRC6_MIX_OFF,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC2_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC2_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_EARPIECE,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0,
|
||||
.abBex = { 0 },
|
||||
.abWide = { 0 },
|
||||
.abDrc = { 0 },
|
||||
.abEq5 = { 0 },
|
||||
.abEq3 = { 0 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asRcOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON | MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asDit1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC0_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC1_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_WIRED_HEADPHONE,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asHpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON,
|
||||
.path_info.asDit1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC0_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC1_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC1_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_WIRED_HEADSET,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_L_ON,
|
||||
.path_info.asHpOut[1].abSrcOnOff[5] = MCDRV_SRC5_DAC_R_ON,
|
||||
.path_info.asDit1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC0_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC2_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC2_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_SPEAKER,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asSpOut[0].abSrcOnOff[5] = MCDRV_SRC5_DAC_M_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asDit1[0].abSrcOnOff[4] = MCDRV_SRC4_ADC0_ON,
|
||||
.path_info.asDac[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asAdc0[0].abSrcOnOff[0] = MCDRV_SRC0_MIC3_ON,
|
||||
.path_info.asAdc0[1].abSrcOnOff[0] = MCDRV_SRC0_MIC3_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
.device = AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
|
||||
.direction = YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
|
||||
.ae_info = {
|
||||
.bOnOff = 0x00,
|
||||
.abBex = { 0x00 },
|
||||
.abWide = { 0x00 },
|
||||
.abDrc = { 0x00 },
|
||||
.abEq5 = { 0x00 },
|
||||
.abEq3 = { 0x00 },
|
||||
},
|
||||
|
||||
.path_info.asHpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asHpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asSpOut[1].abSrcOnOff = { 0 },
|
||||
.path_info.asRcOut[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout1[1].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asLout2[1].abSrcOnOff = { 0 },
|
||||
.path_info.asPeak[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDit2[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[0].abSrcOnOff = { 0 },
|
||||
.path_info.asDac[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAe[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[0].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[1].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[2].abSrcOnOff = { 0 },
|
||||
.path_info.asCdsp[3].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[0].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc0[1].abSrcOnOff = { 0 },
|
||||
.path_info.asAdc1[0].abSrcOnOff = { 0 },
|
||||
.path_info.asMix[0].abSrcOnOff = { 0 },
|
||||
.path_info.asBias[0].abSrcOnOff = { 0 },
|
||||
|
||||
.path_info.asDit1[0].abSrcOnOff[3] = MCDRV_SRC3_DIR2_ON,
|
||||
.path_info.asDit2[0].abSrcOnOff[6] = MCDRV_SRC6_MIX_ON,
|
||||
.path_info.asMix[0].abSrcOnOff[3] = MCDRV_SRC3_DIR1_ON,
|
||||
|
||||
.dac_info = {
|
||||
.bMasterSwap = 0,
|
||||
.bVoiceSwap = 0,
|
||||
.bDcCut = 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_device_ops galaxys2_ops = {
|
||||
.hw_node = "/dev/snd/hwC0D0",
|
||||
.hw_fd = -1,
|
||||
.params = {
|
||||
.init = &galaxys2_params_init,
|
||||
.routes = &galaxys2_params_routes,
|
||||
.routes_count = sizeof(galaxys2_params_routes) /
|
||||
sizeof(struct yamaha_mc1n2_audio_params_route),
|
||||
},
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_pdata galaxys2_pdata = {
|
||||
.name = "galaxys2",
|
||||
.ops = &galaxys2_ops,
|
||||
};
|
124
yamaha-mc1n2-audio/include/mc1n2.h
Normal file
124
yamaha-mc1n2-audio/include/mc1n2.h
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* MC-1N2 ASoC codec driver
|
||||
*
|
||||
* Copyright (c) 2010-2011 Yamaha Corporation
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef MC1N2_H
|
||||
#define MC1N2_H
|
||||
|
||||
#include "mcdriver.h"
|
||||
#include <sound/asound.h>
|
||||
|
||||
/*
|
||||
* dai: set_sysclk
|
||||
*/
|
||||
/* clk_id */
|
||||
#define MC1N2_CLKI 0
|
||||
|
||||
/* default freq for MC1N2_CLKI */
|
||||
#define MC1N2_DEFAULT_CLKI 19200000
|
||||
|
||||
/*
|
||||
* dai: set_clkdiv
|
||||
*/
|
||||
/* div_id */
|
||||
#define MC1N2_CKSEL 0
|
||||
#define MC1N2_DIVR0 1
|
||||
#define MC1N2_DIVF0 2
|
||||
#define MC1N2_DIVR1 3
|
||||
#define MC1N2_DIVF1 4
|
||||
#define MC1N2_BCLK_MULT 5
|
||||
|
||||
/* div for MC1N2_BCLK_MULT */
|
||||
#define MC1N2_LRCK_X8 0
|
||||
#define MC1N2_LRCK_X16 1
|
||||
#define MC1N2_LRCK_X24 2
|
||||
#define MC1N2_LRCK_X32 3
|
||||
#define MC1N2_LRCK_X48 4
|
||||
#define MC1N2_LRCK_X64 5
|
||||
#define MC1N2_LRCK_X128 6
|
||||
#define MC1N2_LRCK_X256 7
|
||||
#define MC1N2_LRCK_X512 8
|
||||
|
||||
/*
|
||||
* hwdep: ioctl
|
||||
*/
|
||||
#define MC1N2_MAGIC 'N'
|
||||
#define MC1N2_IOCTL_NR_GET 1
|
||||
#define MC1N2_IOCTL_NR_SET 2
|
||||
#define MC1N2_IOCTL_NR_BOTH 3
|
||||
#define MC1N2_IOCTL_NR_NOTIFY 4
|
||||
|
||||
#define MC1N2_IOCTL_GET_CTRL \
|
||||
_IOR(MC1N2_MAGIC, MC1N2_IOCTL_NR_GET, struct mc1n2_ctrl_args)
|
||||
#define MC1N2_IOCTL_SET_CTRL \
|
||||
_IOW(MC1N2_MAGIC, MC1N2_IOCTL_NR_SET, struct mc1n2_ctrl_args)
|
||||
|
||||
#define MC1N2_IOCTL_READ_REG \
|
||||
_IOWR(MC1N2_MAGIC, MC1N2_IOCTL_NR_BOTH, struct mc1n2_ctrl_args)
|
||||
|
||||
#define MC1N2_IOCTL_NOTIFY \
|
||||
_IOW(MC1N2_MAGIC, MC1N2_IOCTL_NR_NOTIFY, struct mc1n2_ctrl_args)
|
||||
|
||||
struct mc1n2_ctrl_args {
|
||||
unsigned long dCmd;
|
||||
void *pvPrm;
|
||||
unsigned long dPrm;
|
||||
};
|
||||
|
||||
/*
|
||||
* MC1N2_IOCTL_NOTIFY dCmd definitions
|
||||
*/
|
||||
#define MCDRV_NOTIFY_CALL_START 0x00000000
|
||||
#define MCDRV_NOTIFY_CALL_STOP 0x00000001
|
||||
#define MCDRV_NOTIFY_MEDIA_PLAY_START 0x00000002
|
||||
#define MCDRV_NOTIFY_MEDIA_PLAY_STOP 0x00000003
|
||||
#define MCDRV_NOTIFY_FM_PLAY_START 0x00000004
|
||||
#define MCDRV_NOTIFY_FM_PLAY_STOP 0x00000005
|
||||
#define MCDRV_NOTIFY_BT_SCO_ENABLE 0x00000006
|
||||
#define MCDRV_NOTIFY_BT_SCO_DISABLE 0x00000007
|
||||
#define MCDRV_NOTIFY_VOICE_REC_START 0x00000008
|
||||
#define MCDRV_NOTIFY_VOICE_REC_STOP 0x00000009
|
||||
#define MCDRV_NOTIFY_HDMI_START 0x0000000A
|
||||
#define MCDRV_NOTIFY_HDMI_STOP 0x0000000B
|
||||
#define MCDRV_NOTIFY_RECOVER 0x0000000C
|
||||
#define MCDRV_NOTIFY_2MIC_CALL_START 0x0000000D
|
||||
|
||||
#define MC1N2_MODE_IDLE (0x00)
|
||||
#define MC1N2_MODE_CALL_ON (0x1<<0)
|
||||
#define MC1N2_MODE_FM_ON (0x1<<1)
|
||||
|
||||
/*
|
||||
* Setup parameters
|
||||
*/
|
||||
struct mc1n2_setup {
|
||||
MCDRV_INIT_INFO init;
|
||||
unsigned char pcm_extend[IOPORT_NUM];
|
||||
unsigned char pcm_hiz_redge[IOPORT_NUM];
|
||||
unsigned char pcm_hperiod[IOPORT_NUM];
|
||||
unsigned char slot[IOPORT_NUM][SNDRV_PCM_STREAM_LAST+1][DIO_CHANNELS];
|
||||
};
|
||||
|
||||
/*
|
||||
* Codec Status definitions (for backward compatibility)
|
||||
*/
|
||||
#define CMD_CODEC_EMERGENCY_RECOVERY 9 // Emergency recovery for Error like -EIO, -ESTRPIPE, and etc.
|
||||
|
||||
#endif
|
906
yamaha-mc1n2-audio/include/mcdriver.h
Normal file
906
yamaha-mc1n2-audio/include/mcdriver.h
Normal file
@ -0,0 +1,906 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright(c) 2010 Yamaha Corporation. All rights reserved.
|
||||
*
|
||||
* Module : mcdriver.h
|
||||
*
|
||||
* Description : MC Driver header
|
||||
*
|
||||
* Version : 1.0.0 2010.07.05
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _MCDRIVER_H_
|
||||
#define _MCDRIVER_H_
|
||||
|
||||
#include "mctypedef.h"
|
||||
|
||||
|
||||
|
||||
signed long McDrv_Ctrl( UINT32 dCmd, void* pvPrm, UINT32 dPrm );
|
||||
|
||||
|
||||
|
||||
|
||||
/* return value */
|
||||
#define MCDRV_SUCCESS ((SINT32)0)
|
||||
#define MCDRV_ERROR_ARGUMENT (-1)
|
||||
#define MCDRV_ERROR_TIMEOUT (-2)
|
||||
#define MCDRV_ERROR_INIT (-3)
|
||||
#define MCDRV_ERROR_RESOURCEOVER (-4)
|
||||
#define MCDRV_ERROR_STATE (-5)
|
||||
|
||||
#define MCDRV_ERROR (-10)
|
||||
|
||||
|
||||
/* dCmd */
|
||||
#define MCDRV_INIT (0)
|
||||
#define MCDRV_TERM (1)
|
||||
#define MCDRV_READ_REG (2)
|
||||
#define MCDRV_WRITE_REG (3)
|
||||
#define MCDRV_GET_PATH (4)
|
||||
#define MCDRV_SET_PATH (5)
|
||||
#define MCDRV_GET_VOLUME (6)
|
||||
#define MCDRV_SET_VOLUME (7)
|
||||
#define MCDRV_GET_DIGITALIO (8)
|
||||
#define MCDRV_SET_DIGITALIO (9)
|
||||
#define MCDRV_GET_DAC (10)
|
||||
#define MCDRV_SET_DAC (11)
|
||||
#define MCDRV_GET_ADC (12)
|
||||
#define MCDRV_SET_ADC (13)
|
||||
#define MCDRV_GET_SP (14)
|
||||
#define MCDRV_SET_SP (15)
|
||||
#define MCDRV_GET_DNG (16)
|
||||
#define MCDRV_SET_DNG (17)
|
||||
#define MCDRV_SET_AUDIOENGINE (18)
|
||||
#define MCDRV_SET_AUDIOENGINE_EX (19)
|
||||
#define MCDRV_SET_CDSP (20)
|
||||
#define MCDRV_GET_CDSP_PARAM (21)
|
||||
#define MCDRV_SET_CDSP_PARAM (22)
|
||||
#define MCDRV_REGISTER_CDSP_CB (23)
|
||||
#define MCDRV_GET_PDM (24)
|
||||
#define MCDRV_SET_PDM (25)
|
||||
#define MCDRV_SET_DTMF (26)
|
||||
#define MCDRV_CONFIG_GP (27)
|
||||
#define MCDRV_MASK_GP (28)
|
||||
#define MCDRV_GETSET_GP (29)
|
||||
#define MCDRV_GET_PEAK (30)
|
||||
#define MCDRV_IRQ (31)
|
||||
#define MCDRV_UPDATE_CLOCK (32)
|
||||
#define MCDRV_SWITCH_CLOCK (33)
|
||||
#define MCDRV_GET_SYSEQ (34)
|
||||
#define MCDRV_SET_SYSEQ (35)
|
||||
|
||||
/* pvPrm */
|
||||
/* init */
|
||||
/* MCDRV_INIT_INFO bCkSel setting */
|
||||
#define MCDRV_CKSEL_CMOS (0x00)
|
||||
#define MCDRV_CKSEL_TCXO (0xC0)
|
||||
#define MCDRV_CKSEL_CMOS_TCXO (0x80)
|
||||
#define MCDRV_CKSEL_TCXO_CMOS (0x40)
|
||||
|
||||
/* MCDRV_INIT_INFO bXXXHiz setting */
|
||||
#define MCDRV_DAHIZ_LOW (0)
|
||||
#define MCDRV_DAHIZ_HIZ (1)
|
||||
|
||||
/* CDRV_INIT_INFO bPcmHiz setting */
|
||||
#define MCDRV_PCMHIZ_LOW (0)
|
||||
#define MCDRV_PCMHIZ_HIZ (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bSvolStep setting */
|
||||
#define MCDRV_SVOLSTEP_0137 (0)
|
||||
#define MCDRV_SVOLSTEP_0274 (1)
|
||||
#define MCDRV_SVOLSTEP_0548 (2)
|
||||
#define MCDRV_SVOLSTEP_1096 (3)
|
||||
|
||||
/* MCDRV_INIT_INFO bLinexxDif setting */
|
||||
#define MCDRV_LINE_STEREO (0)
|
||||
#define MCDRV_LINE_DIF (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bSpmn setting */
|
||||
#define MCDRV_SPMN_ON (0)
|
||||
#define MCDRV_SPMN_OFF (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bMicxSng setting */
|
||||
#define MCDRV_MIC_DIF (0)
|
||||
#define MCDRV_MIC_SINGLE (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bPowerMode setting */
|
||||
#define MCDRV_POWMODE_NORMAL (0)
|
||||
#define MCDRV_POWMODE_CLKON (1)
|
||||
#define MCDRV_POWMODE_VREFON (2)
|
||||
#define MCDRV_POWMODE_CLKVREFON (3)
|
||||
#define MCDRV_POWMODE_FULL (4)
|
||||
|
||||
/* bSpHiz setting */
|
||||
#define MCDRV_SPHIZ_PULLDOWN (0)
|
||||
#define MCDRV_SPHIZ_HIZ (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bLdo setting */
|
||||
#define MCDRV_LDO_OFF (0)
|
||||
#define MCDRV_LDO_ON (1)
|
||||
|
||||
/* MCDRV_INIT_INFO bPadxFunc setting */
|
||||
#define MCDRV_PAD_GPIO (0)
|
||||
#define MCDRV_PAD_PDMCK (1)
|
||||
#define MCDRV_PAD_PDMDI (2)
|
||||
#define MCDRV_PAD_IRQ (3)
|
||||
|
||||
/* MCDRV_INIT_INFO bAvddLev/bVrefLev setting */
|
||||
#define MCDRV_OUTLEV_0 (0)
|
||||
#define MCDRV_OUTLEV_1 (1)
|
||||
#define MCDRV_OUTLEV_2 (2)
|
||||
#define MCDRV_OUTLEV_3 (3)
|
||||
#define MCDRV_OUTLEV_4 (4)
|
||||
#define MCDRV_OUTLEV_5 (5)
|
||||
#define MCDRV_OUTLEV_6 (6)
|
||||
#define MCDRV_OUTLEV_7 (7)
|
||||
|
||||
/* MCDRV_INIT_INFO bDclGain setting */
|
||||
#define MCDRV_DCLGAIN_0 (0)
|
||||
#define MCDRV_DCLGAIN_6 (1)
|
||||
#define MCDRV_DCLGAIN_12 (2)
|
||||
#define MCDRV_DCLGAIN_18 (3)
|
||||
|
||||
/* MCDRV_INIT_INFO bDclLimit setting */
|
||||
#define MCDRV_DCLLIMIT_0 (0)
|
||||
#define MCDRV_DCLLIMIT_116 (1)
|
||||
#define MCDRV_DCLLIMIT_250 (2)
|
||||
#define MCDRV_DCLLIMIT_602 (3)
|
||||
|
||||
/* MCDRV_INIT_INFO bCpMod setting */
|
||||
#define MCDRV_CPMOD_ON (0)
|
||||
#define MCDRV_CPMOD_OFF (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 dAdHpf;
|
||||
UINT32 dMic1Cin;
|
||||
UINT32 dMic2Cin;
|
||||
UINT32 dMic3Cin;
|
||||
UINT32 dLine1Cin;
|
||||
UINT32 dLine2Cin;
|
||||
UINT32 dVrefRdy1;
|
||||
UINT32 dVrefRdy2;
|
||||
UINT32 dHpRdy;
|
||||
UINT32 dSpRdy;
|
||||
UINT32 dPdm;
|
||||
UINT32 dAnaRdyInterval;
|
||||
UINT32 dSvolInterval;
|
||||
UINT32 dAnaRdyTimeOut;
|
||||
UINT32 dSvolTimeOut;
|
||||
} MCDRV_WAIT_TIME;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bCkSel;
|
||||
UINT8 bDivR0;
|
||||
UINT8 bDivF0;
|
||||
UINT8 bDivR1;
|
||||
UINT8 bDivF1;
|
||||
UINT8 bRange0;
|
||||
UINT8 bRange1;
|
||||
UINT8 bBypass;
|
||||
UINT8 bDioSdo0Hiz;
|
||||
UINT8 bDioSdo1Hiz;
|
||||
UINT8 bDioSdo2Hiz;
|
||||
UINT8 bDioClk0Hiz;
|
||||
UINT8 bDioClk1Hiz;
|
||||
UINT8 bDioClk2Hiz;
|
||||
UINT8 bPcmHiz;
|
||||
UINT8 bLineIn1Dif;
|
||||
UINT8 bLineIn2Dif;
|
||||
UINT8 bLineOut1Dif;
|
||||
UINT8 bLineOut2Dif;
|
||||
UINT8 bSpmn;
|
||||
UINT8 bMic1Sng;
|
||||
UINT8 bMic2Sng;
|
||||
UINT8 bMic3Sng;
|
||||
UINT8 bPowerMode;
|
||||
UINT8 bSpHiz;
|
||||
UINT8 bLdo;
|
||||
UINT8 bPad0Func;
|
||||
UINT8 bPad1Func;
|
||||
UINT8 bPad2Func;
|
||||
UINT8 bAvddLev;
|
||||
UINT8 bVrefLev;
|
||||
UINT8 bDclGain;
|
||||
UINT8 bDclLimit;
|
||||
UINT8 bCpMod;
|
||||
UINT8 bReserved1;
|
||||
UINT8 bReserved2;
|
||||
UINT8 bReserved3;
|
||||
UINT8 bReserved4;
|
||||
UINT8 bReserved5;
|
||||
MCDRV_WAIT_TIME sWaitTime;
|
||||
} MCDRV_INIT_INFO;
|
||||
|
||||
/* update clock */
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bCkSel;
|
||||
UINT8 bDivR0;
|
||||
UINT8 bDivF0;
|
||||
UINT8 bDivR1;
|
||||
UINT8 bDivF1;
|
||||
UINT8 bRange0;
|
||||
UINT8 bRange1;
|
||||
UINT8 bBypass;
|
||||
} MCDRV_CLOCK_INFO;
|
||||
|
||||
/* switch clock */
|
||||
/* MCDRV_CLKSW_INFO bClkSrc setting */
|
||||
#define MCDRV_CLKSW_CLKI0 (0x00)
|
||||
#define MCDRV_CLKSW_CLKI1 (0x01)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bClkSrc;
|
||||
} MCDRV_CLKSW_INFO;
|
||||
|
||||
/* set/get path */
|
||||
#define SOURCE_BLOCK_NUM (7)
|
||||
#define MCDRV_SRC_MIC1_BLOCK (0)
|
||||
#define MCDRV_SRC_MIC2_BLOCK (0)
|
||||
#define MCDRV_SRC_MIC3_BLOCK (0)
|
||||
#define MCDRV_SRC_LINE1_L_BLOCK (1)
|
||||
#define MCDRV_SRC_LINE1_R_BLOCK (1)
|
||||
#define MCDRV_SRC_LINE1_M_BLOCK (1)
|
||||
#define MCDRV_SRC_LINE2_L_BLOCK (2)
|
||||
#define MCDRV_SRC_LINE2_R_BLOCK (2)
|
||||
#define MCDRV_SRC_LINE2_M_BLOCK (2)
|
||||
#define MCDRV_SRC_DIR0_BLOCK (3)
|
||||
#define MCDRV_SRC_DIR1_BLOCK (3)
|
||||
#define MCDRV_SRC_DIR2_BLOCK (3)
|
||||
#define MCDRV_SRC_DIR2_DIRECT_BLOCK (3)
|
||||
#define MCDRV_SRC_DTMF_BLOCK (4)
|
||||
#define MCDRV_SRC_PDM_BLOCK (4)
|
||||
#define MCDRV_SRC_ADC0_BLOCK (4)
|
||||
#define MCDRV_SRC_ADC1_BLOCK (4)
|
||||
#define MCDRV_SRC_DAC_L_BLOCK (5)
|
||||
#define MCDRV_SRC_DAC_R_BLOCK (5)
|
||||
#define MCDRV_SRC_DAC_M_BLOCK (5)
|
||||
#define MCDRV_SRC_MIX_BLOCK (6)
|
||||
#define MCDRV_SRC_AE_BLOCK (6)
|
||||
#define MCDRV_SRC_CDSP_BLOCK (6)
|
||||
#define MCDRV_SRC_CDSP_DIRECT_BLOCK (6)
|
||||
|
||||
#define MCDRV_SRC0_MIC1_ON (0x01)
|
||||
#define MCDRV_SRC0_MIC1_OFF (0x02)
|
||||
#define MCDRV_SRC0_MIC2_ON (0x04)
|
||||
#define MCDRV_SRC0_MIC2_OFF (0x08)
|
||||
#define MCDRV_SRC0_MIC3_ON (0x10)
|
||||
#define MCDRV_SRC0_MIC3_OFF (0x20)
|
||||
#define MCDRV_SRC1_LINE1_L_ON (0x01)
|
||||
#define MCDRV_SRC1_LINE1_L_OFF (0x02)
|
||||
#define MCDRV_SRC1_LINE1_R_ON (0x04)
|
||||
#define MCDRV_SRC1_LINE1_R_OFF (0x08)
|
||||
#define MCDRV_SRC1_LINE1_M_ON (0x10)
|
||||
#define MCDRV_SRC1_LINE1_M_OFF (0x20)
|
||||
#define MCDRV_SRC2_LINE2_L_ON (0x01)
|
||||
#define MCDRV_SRC2_LINE2_L_OFF (0x02)
|
||||
#define MCDRV_SRC2_LINE2_R_ON (0x04)
|
||||
#define MCDRV_SRC2_LINE2_R_OFF (0x08)
|
||||
#define MCDRV_SRC2_LINE2_M_ON (0x10)
|
||||
#define MCDRV_SRC2_LINE2_M_OFF (0x20)
|
||||
#define MCDRV_SRC3_DIR0_ON (0x01)
|
||||
#define MCDRV_SRC3_DIR0_OFF (0x02)
|
||||
#define MCDRV_SRC3_DIR1_ON (0x04)
|
||||
#define MCDRV_SRC3_DIR1_OFF (0x08)
|
||||
#define MCDRV_SRC3_DIR2_ON (0x10)
|
||||
#define MCDRV_SRC3_DIR2_OFF (0x20)
|
||||
#define MCDRV_SRC3_DIR2_DIRECT_ON (0x40)
|
||||
#define MCDRV_SRC3_DIR2_DIRECT_OFF (0x80)
|
||||
#define MCDRV_SRC4_DTMF_ON (0x01)
|
||||
#define MCDRV_SRC4_DTMF_OFF (0x02)
|
||||
#define MCDRV_SRC4_PDM_ON (0x04)
|
||||
#define MCDRV_SRC4_PDM_OFF (0x08)
|
||||
#define MCDRV_SRC4_ADC0_ON (0x10)
|
||||
#define MCDRV_SRC4_ADC0_OFF (0x20)
|
||||
#define MCDRV_SRC4_ADC1_ON (0x40)
|
||||
#define MCDRV_SRC4_ADC1_OFF (0x80)
|
||||
#define MCDRV_SRC5_DAC_L_ON (0x01)
|
||||
#define MCDRV_SRC5_DAC_L_OFF (0x02)
|
||||
#define MCDRV_SRC5_DAC_R_ON (0x04)
|
||||
#define MCDRV_SRC5_DAC_R_OFF (0x08)
|
||||
#define MCDRV_SRC5_DAC_M_ON (0x10)
|
||||
#define MCDRV_SRC5_DAC_M_OFF (0x20)
|
||||
#define MCDRV_SRC6_MIX_ON (0x01)
|
||||
#define MCDRV_SRC6_MIX_OFF (0x02)
|
||||
#define MCDRV_SRC6_AE_ON (0x04)
|
||||
#define MCDRV_SRC6_AE_OFF (0x08)
|
||||
#define MCDRV_SRC6_CDSP_ON (0x10)
|
||||
#define MCDRV_SRC6_CDSP_OFF (0x20)
|
||||
#define MCDRV_SRC6_CDSP_DIRECT_ON (0x40)
|
||||
#define MCDRV_SRC6_CDSP_DIRECT_OFF (0x80)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 abSrcOnOff[SOURCE_BLOCK_NUM];
|
||||
} MCDRV_CHANNEL;
|
||||
|
||||
#define HP_PATH_CHANNELS (2)
|
||||
#define SP_PATH_CHANNELS (2)
|
||||
#define RC_PATH_CHANNELS (1)
|
||||
#define LOUT1_PATH_CHANNELS (2)
|
||||
#define LOUT2_PATH_CHANNELS (2)
|
||||
#define PEAK_PATH_CHANNELS (1)
|
||||
#define DIT0_PATH_CHANNELS (1)
|
||||
#define DIT1_PATH_CHANNELS (1)
|
||||
#define DIT2_PATH_CHANNELS (1)
|
||||
#define DAC_PATH_CHANNELS (2)
|
||||
#define AE_PATH_CHANNELS (1)
|
||||
#define CDSP_PATH_CHANNELS (4)
|
||||
#define ADC0_PATH_CHANNELS (2)
|
||||
#define ADC1_PATH_CHANNELS (1)
|
||||
#define MIX_PATH_CHANNELS (1)
|
||||
#define BIAS_PATH_CHANNELS (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MCDRV_CHANNEL asHpOut[HP_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asSpOut[SP_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asRcOut[RC_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asLout1[LOUT1_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asLout2[LOUT2_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asPeak[PEAK_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asDit0[DIT0_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asDit1[DIT1_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asDit2[DIT2_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asDac[DAC_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asAe[AE_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asCdsp[CDSP_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asAdc0[ADC0_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asAdc1[ADC1_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asMix[MIX_PATH_CHANNELS];
|
||||
MCDRV_CHANNEL asBias[BIAS_PATH_CHANNELS];
|
||||
} MCDRV_PATH_INFO;
|
||||
|
||||
/* set/get vol */
|
||||
#define MCDRV_VOL_UPDATE (0x0001)
|
||||
|
||||
#define AD0_VOL_CHANNELS (2)
|
||||
#define AD1_VOL_CHANNELS (1)
|
||||
#define AENG6_VOL_CHANNELS (2)
|
||||
#define PDM_VOL_CHANNELS (2)
|
||||
#define DTMF_VOL_CHANNELS (2)
|
||||
#define DIO0_VOL_CHANNELS (2)
|
||||
#define DIO1_VOL_CHANNELS (2)
|
||||
#define DIO2_VOL_CHANNELS (2)
|
||||
#define DTFM_VOL_CHANNELS (2)
|
||||
#define DAC_VOL_CHANNELS (2)
|
||||
|
||||
#define LIN1_VOL_CHANNELS (2)
|
||||
#define LIN2_VOL_CHANNELS (2)
|
||||
#define MIC1_VOL_CHANNELS (1)
|
||||
#define MIC2_VOL_CHANNELS (1)
|
||||
#define MIC3_VOL_CHANNELS (1)
|
||||
#define HP_VOL_CHANNELS (2)
|
||||
#define SP_VOL_CHANNELS (2)
|
||||
#define RC_VOL_CHANNELS (1)
|
||||
#define LOUT1_VOL_CHANNELS (2)
|
||||
#define LOUT2_VOL_CHANNELS (2)
|
||||
#define HPGAIN_VOL_CHANNELS (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SINT16 aswD_Ad0[AD0_VOL_CHANNELS];
|
||||
SINT16 aswD_Ad1[AD1_VOL_CHANNELS];
|
||||
SINT16 aswD_Aeng6[AENG6_VOL_CHANNELS];
|
||||
SINT16 aswD_Pdm[PDM_VOL_CHANNELS];
|
||||
SINT16 aswD_Dtmfb[DTMF_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir0[DIO0_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir1[DIO1_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir2[DIO2_VOL_CHANNELS];
|
||||
SINT16 aswD_Ad0Att[AD0_VOL_CHANNELS];
|
||||
SINT16 aswD_Ad1Att[AD1_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir0Att[DIO0_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir1Att[DIO1_VOL_CHANNELS];
|
||||
SINT16 aswD_Dir2Att[DIO2_VOL_CHANNELS];
|
||||
SINT16 aswD_SideTone[PDM_VOL_CHANNELS];
|
||||
SINT16 aswD_DtmfAtt[DTFM_VOL_CHANNELS];
|
||||
SINT16 aswD_DacMaster[DAC_VOL_CHANNELS];
|
||||
SINT16 aswD_DacVoice[DAC_VOL_CHANNELS];
|
||||
SINT16 aswD_DacAtt[DAC_VOL_CHANNELS];
|
||||
SINT16 aswD_Dit0[DIO0_VOL_CHANNELS];
|
||||
SINT16 aswD_Dit1[DIO1_VOL_CHANNELS];
|
||||
SINT16 aswD_Dit2[DIO2_VOL_CHANNELS];
|
||||
SINT16 aswA_Ad0[AD0_VOL_CHANNELS];
|
||||
SINT16 aswA_Ad1[AD1_VOL_CHANNELS];
|
||||
SINT16 aswA_Lin1[LIN1_VOL_CHANNELS];
|
||||
SINT16 aswA_Lin2[LIN2_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic1[MIC1_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic2[MIC2_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic3[MIC3_VOL_CHANNELS];
|
||||
SINT16 aswA_Hp[HP_VOL_CHANNELS];
|
||||
SINT16 aswA_Sp[SP_VOL_CHANNELS];
|
||||
SINT16 aswA_Rc[RC_VOL_CHANNELS];
|
||||
SINT16 aswA_Lout1[LOUT1_VOL_CHANNELS];
|
||||
SINT16 aswA_Lout2[LOUT2_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic1Gain[MIC1_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic2Gain[MIC2_VOL_CHANNELS];
|
||||
SINT16 aswA_Mic3Gain[MIC3_VOL_CHANNELS];
|
||||
SINT16 aswA_HpGain[HPGAIN_VOL_CHANNELS];
|
||||
} MCDRV_VOL_INFO;
|
||||
|
||||
/* set/get digitalio */
|
||||
#define MCDRV_DIO0_COM_UPDATE_FLAG ((UINT32)0x00000001)
|
||||
#define MCDRV_DIO0_DIR_UPDATE_FLAG ((UINT32)0x00000002)
|
||||
#define MCDRV_DIO0_DIT_UPDATE_FLAG ((UINT32)0x00000004)
|
||||
#define MCDRV_DIO1_COM_UPDATE_FLAG ((UINT32)0x00000008)
|
||||
#define MCDRV_DIO1_DIR_UPDATE_FLAG ((UINT32)0x00000010)
|
||||
#define MCDRV_DIO1_DIT_UPDATE_FLAG ((UINT32)0x00000020)
|
||||
#define MCDRV_DIO2_COM_UPDATE_FLAG ((UINT32)0x00000040)
|
||||
#define MCDRV_DIO2_DIR_UPDATE_FLAG ((UINT32)0x00000080)
|
||||
#define MCDRV_DIO2_DIT_UPDATE_FLAG ((UINT32)0x00000100)
|
||||
|
||||
/* MCDRV_DIO_COMMON bMasterSlave setting */
|
||||
#define MCDRV_DIO_SLAVE (0)
|
||||
#define MCDRV_DIO_MASTER (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bDigitalAutoFs setting */
|
||||
#define MCDRV_AUTOFS_OFF (0)
|
||||
#define MCDRV_AUTOFS_ON (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bFs setting */
|
||||
#define MCDRV_FS_48000 (0)
|
||||
#define MCDRV_FS_44100 (1)
|
||||
#define MCDRV_FS_32000 (2)
|
||||
#define MCDRV_FS_24000 (4)
|
||||
#define MCDRV_FS_22050 (5)
|
||||
#define MCDRV_FS_16000 (6)
|
||||
#define MCDRV_FS_12000 (8)
|
||||
#define MCDRV_FS_11025 (9)
|
||||
#define MCDRV_FS_8000 (10)
|
||||
|
||||
/* MCDRV_DIO_COMMON bBckFs setting */
|
||||
#define MCDRV_BCKFS_64 (0)
|
||||
#define MCDRV_BCKFS_48 (1)
|
||||
#define MCDRV_BCKFS_32 (2)
|
||||
#define MCDRV_BCKFS_512 (4)
|
||||
#define MCDRV_BCKFS_256 (5)
|
||||
#define MCDRV_BCKFS_128 (6)
|
||||
#define MCDRV_BCKFS_16 (7)
|
||||
|
||||
/* MCDRV_DIO_COMMON bInterface setting */
|
||||
#define MCDRV_DIO_DA (0)
|
||||
#define MCDRV_DIO_PCM (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bBckInvert setting */
|
||||
#define MCDRV_BCLK_NORMAL (0)
|
||||
#define MCDRV_BCLK_INVERT (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bPcmHizTim setting */
|
||||
#define MCDRV_PCMHIZTIM_FALLING (0)
|
||||
#define MCDRV_PCMHIZTIM_RISING (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bPcmClkDown setting */
|
||||
#define MCDRV_PCM_CLKDOWN_OFF (0)
|
||||
#define MCDRV_PCM_CLKDOWN_HALF (1)
|
||||
|
||||
/* MCDRV_DIO_COMMON bPcmFrame setting */
|
||||
#define MCDRV_PCM_SHORTFRAME (0)
|
||||
#define MCDRV_PCM_LONGFRAME (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bMasterSlave;
|
||||
UINT8 bAutoFs;
|
||||
UINT8 bFs;
|
||||
UINT8 bBckFs;
|
||||
UINT8 bInterface;
|
||||
UINT8 bBckInvert;
|
||||
UINT8 bPcmHizTim;
|
||||
UINT8 bPcmClkDown;
|
||||
UINT8 bPcmFrame;
|
||||
UINT8 bPcmHighPeriod;
|
||||
} MCDRV_DIO_COMMON;
|
||||
|
||||
/* MCDRV_DA_FORMAT bBitSel setting */
|
||||
#define MCDRV_BITSEL_16 (0)
|
||||
#define MCDRV_BITSEL_20 (1)
|
||||
#define MCDRV_BITSEL_24 (2)
|
||||
|
||||
/* MCDRV_DA_FORMAT bMode setting */
|
||||
#define MCDRV_DAMODE_HEADALIGN (0)
|
||||
#define MCDRV_DAMODE_I2S (1)
|
||||
#define MCDRV_DAMODE_TAILALIGN (2)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bBitSel;
|
||||
UINT8 bMode;
|
||||
} MCDRV_DA_FORMAT;
|
||||
|
||||
/* MCDRV_PCM_FORMAT bMono setting */
|
||||
#define MCDRV_PCM_STEREO (0)
|
||||
#define MCDRV_PCM_MONO (1)
|
||||
|
||||
/* MCDRV_PCM_FORMAT bOrder setting */
|
||||
#define MCDRV_PCM_MSB_FIRST (0)
|
||||
#define MCDRV_PCM_LSB_FIRST (1)
|
||||
#define MCDRV_PCM_MSB_FIRST_SIGN (2)
|
||||
#define MCDRV_PCM_LSB_FIRST_SIGN (3)
|
||||
#define MCDRV_PCM_MSB_FIRST_ZERO (4)
|
||||
#define MCDRV_PCM_LSB_FIRST_ZERO (5)
|
||||
|
||||
/* MCDRV_PCM_FORMAT bLaw setting */
|
||||
#define MCDRV_PCM_LINEAR (0)
|
||||
#define MCDRV_PCM_ALAW (1)
|
||||
#define MCDRV_PCM_MULAW (2)
|
||||
|
||||
/* MCDRV_PCM_FORMAT bBitSel setting */
|
||||
#define MCDRV_PCM_BITSEL_8 (0)
|
||||
#define MCDRV_PCM_BITSEL_13 (1)
|
||||
#define MCDRV_PCM_BITSEL_14 (2)
|
||||
#define MCDRV_PCM_BITSEL_16 (3)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bMono;
|
||||
UINT8 bOrder;
|
||||
UINT8 bLaw;
|
||||
UINT8 bBitSel;
|
||||
} MCDRV_PCM_FORMAT;
|
||||
|
||||
#define DIO_CHANNELS (2)
|
||||
typedef struct
|
||||
{
|
||||
UINT16 wSrcRate;
|
||||
MCDRV_DA_FORMAT sDaFormat;
|
||||
MCDRV_PCM_FORMAT sPcmFormat;
|
||||
UINT8 abSlot[DIO_CHANNELS];
|
||||
} MCDRV_DIO_DIR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 wSrcRate;
|
||||
MCDRV_DA_FORMAT sDaFormat;
|
||||
MCDRV_PCM_FORMAT sPcmFormat;
|
||||
UINT8 abSlot[DIO_CHANNELS];
|
||||
} MCDRV_DIO_DIT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MCDRV_DIO_COMMON sDioCommon;
|
||||
MCDRV_DIO_DIR sDir;
|
||||
MCDRV_DIO_DIT sDit;
|
||||
} MCDRV_DIO_PORT;
|
||||
|
||||
#define IOPORT_NUM (3)
|
||||
typedef struct
|
||||
{
|
||||
MCDRV_DIO_PORT asPortInfo[IOPORT_NUM];
|
||||
} MCDRV_DIO_INFO;
|
||||
|
||||
/* set dac */
|
||||
#define MCDRV_DAC_MSWP_UPDATE_FLAG ((UINT32)0x01)
|
||||
#define MCDRV_DAC_VSWP_UPDATE_FLAG ((UINT32)0x02)
|
||||
#define MCDRV_DAC_HPF_UPDATE_FLAG ((UINT32)0x04)
|
||||
|
||||
/* MCDRV_DAC_INFO bMasterSwap/bVoiceSwap setting */
|
||||
#define MCDRV_DSWAP_OFF (0)
|
||||
#define MCDRV_DSWAP_SWAP (1)
|
||||
#define MCDRV_DSWAP_MUTE (2)
|
||||
#define MCDRV_DSWAP_RMVCENTER (3)
|
||||
#define MCDRV_DSWAP_MONO (4)
|
||||
#define MCDRV_DSWAP_MONOHALF (5)
|
||||
#define MCDRV_DSWAP_BOTHL (6)
|
||||
#define MCDRV_DSWAP_BOTHR (7)
|
||||
|
||||
/* MCDRV_DAC_INFO bDcCut setting */
|
||||
#define MCDRV_DCCUT_ON (0)
|
||||
#define MCDRV_DCCUT_OFF (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bMasterSwap;
|
||||
UINT8 bVoiceSwap;
|
||||
UINT8 bDcCut;
|
||||
} MCDRV_DAC_INFO;
|
||||
|
||||
/* set adc */
|
||||
#define MCDRV_ADCADJ_UPDATE_FLAG ((UINT32)0x00000001)
|
||||
#define MCDRV_ADCAGC_UPDATE_FLAG ((UINT32)0x00000002)
|
||||
#define MCDRV_ADCMONO_UPDATE_FLAG ((UINT32)0x00000004)
|
||||
|
||||
/* MCDRV_ADC_INFO bAgcAdjust setting */
|
||||
#define MCDRV_AGCADJ_24 (0)
|
||||
#define MCDRV_AGCADJ_18 (1)
|
||||
#define MCDRV_AGCADJ_12 (2)
|
||||
#define MCDRV_AGCADJ_0 (3)
|
||||
|
||||
/* MCDRV_ADC_INFO bAgcOn setting */
|
||||
#define MCDRV_AGC_OFF (0)
|
||||
#define MCDRV_AGC_ON (1)
|
||||
|
||||
/* MCDRV_ADC_INFO bMono setting */
|
||||
#define MCDRV_ADC_STEREO (0)
|
||||
#define MCDRV_ADC_MONO (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bAgcAdjust;
|
||||
UINT8 bAgcOn;
|
||||
UINT8 bMono;
|
||||
} MCDRV_ADC_INFO;
|
||||
|
||||
/* set sp */
|
||||
/* MCDRV_SP_INFO bSwap setting */
|
||||
#define MCDRV_SPSWAP_OFF (0)
|
||||
#define MCDRV_SPSWAP_SWAP (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bSwap;
|
||||
} MCDRV_SP_INFO;
|
||||
|
||||
/* set dng */
|
||||
#define DNG_ITEM_NUM (3)
|
||||
#define MCDRV_DNG_ITEM_HP (0)
|
||||
#define MCDRV_DNG_ITEM_SP (1)
|
||||
#define MCDRV_DNG_ITEM_RC (2)
|
||||
|
||||
#define MCDRV_DNGSW_HP_UPDATE_FLAG ((UINT32)0x00000001)
|
||||
#define MCDRV_DNGTHRES_HP_UPDATE_FLAG ((UINT32)0x00000002)
|
||||
#define MCDRV_DNGHOLD_HP_UPDATE_FLAG ((UINT32)0x00000004)
|
||||
#define MCDRV_DNGATK_HP_UPDATE_FLAG ((UINT32)0x00000008)
|
||||
#define MCDRV_DNGREL_HP_UPDATE_FLAG ((UINT32)0x00000010)
|
||||
#define MCDRV_DNGTARGET_HP_UPDATE_FLAG ((UINT32)0x00000020)
|
||||
#define MCDRV_DNGSW_SP_UPDATE_FLAG ((UINT32)0x00000100)
|
||||
#define MCDRV_DNGTHRES_SP_UPDATE_FLAG ((UINT32)0x00000200)
|
||||
#define MCDRV_DNGHOLD_SP_UPDATE_FLAG ((UINT32)0x00000400)
|
||||
#define MCDRV_DNGATK_SP_UPDATE_FLAG ((UINT32)0x00000800)
|
||||
#define MCDRV_DNGREL_SP_UPDATE_FLAG ((UINT32)0x00001000)
|
||||
#define MCDRV_DNGTARGET_SP_UPDATE_FLAG ((UINT32)0x00002000)
|
||||
#define MCDRV_DNGSW_RC_UPDATE_FLAG ((UINT32)0x00010000)
|
||||
#define MCDRV_DNGTHRES_RC_UPDATE_FLAG ((UINT32)0x00020000)
|
||||
#define MCDRV_DNGHOLD_RC_UPDATE_FLAG ((UINT32)0x00040000)
|
||||
#define MCDRV_DNGATK_RC_UPDATE_FLAG ((UINT32)0x00080000)
|
||||
#define MCDRV_DNGREL_RC_UPDATE_FLAG ((UINT32)0x00100000)
|
||||
#define MCDRV_DNGTARGET_RC_UPDATE_FLAG ((UINT32)0x00200000)
|
||||
|
||||
/* MCDRV_DNG_INFO bOnOff setting */
|
||||
#define MCDRV_DNG_OFF (0)
|
||||
#define MCDRV_DNG_ON (1)
|
||||
|
||||
/* MCDRV_DNG_INFO bThreshold setting */
|
||||
#define MCDRV_DNG_THRES_30 (0)
|
||||
#define MCDRV_DNG_THRES_36 (1)
|
||||
#define MCDRV_DNG_THRES_42 (2)
|
||||
#define MCDRV_DNG_THRES_48 (3)
|
||||
#define MCDRV_DNG_THRES_54 (4)
|
||||
#define MCDRV_DNG_THRES_60 (5)
|
||||
#define MCDRV_DNG_THRES_66 (6)
|
||||
#define MCDRV_DNG_THRES_72 (7)
|
||||
#define MCDRV_DNG_THRES_78 (8)
|
||||
#define MCDRV_DNG_THRES_84 (9)
|
||||
|
||||
/* MCDRV_DNG_INFO bHold setting */
|
||||
#define MCDRV_DNG_HOLD_30 (0)
|
||||
#define MCDRV_DNG_HOLD_120 (1)
|
||||
#define MCDRV_DNG_HOLD_500 (2)
|
||||
|
||||
/* MCDRV_DNG_INFO bAttack setting */
|
||||
#define MCDRV_DNG_ATTACK_25 (0)
|
||||
#define MCDRV_DNG_ATTACK_100 (1)
|
||||
#define MCDRV_DNG_ATTACK_400 (2)
|
||||
#define MCDRV_DNG_ATTACK_800 (3)
|
||||
|
||||
/* MCDRV_DNG_INFO bRelease setting */
|
||||
#define MCDRV_DNG_RELEASE_7950 (0)
|
||||
#define MCDRV_DNG_RELEASE_470 (1)
|
||||
#define MCDRV_DNG_RELEASE_940 (2)
|
||||
|
||||
/* MCDRV_DNG_INFO bTarget setting */
|
||||
#define MCDRV_DNG_TARGET_6 (0)
|
||||
#define MCDRV_DNG_TARGET_9 (1)
|
||||
#define MCDRV_DNG_TARGET_12 (2)
|
||||
#define MCDRV_DNG_TARGET_15 (3)
|
||||
#define MCDRV_DNG_TARGET_18 (4)
|
||||
#define MCDRV_DNG_TARGET_MUTE (5)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 abOnOff[DNG_ITEM_NUM];
|
||||
UINT8 abThreshold[DNG_ITEM_NUM];
|
||||
UINT8 abHold[DNG_ITEM_NUM];
|
||||
UINT8 abAttack[DNG_ITEM_NUM];
|
||||
UINT8 abRelease[DNG_ITEM_NUM];
|
||||
UINT8 abTarget[DNG_ITEM_NUM];
|
||||
} MCDRV_DNG_INFO;
|
||||
|
||||
/* set audio engine */
|
||||
#define MCDRV_AEUPDATE_FLAG_BEXWIDE_ONOFF ((UINT32)0x00000001)
|
||||
#define MCDRV_AEUPDATE_FLAG_DRC_ONOFF ((UINT32)0x00000002)
|
||||
#define MCDRV_AEUPDATE_FLAG_EQ5_ONOFF ((UINT32)0x00000004)
|
||||
#define MCDRV_AEUPDATE_FLAG_EQ3_ONOFF ((UINT32)0x00000008)
|
||||
#define MCDRV_AEUPDATE_FLAG_BEX ((UINT32)0x00000010)
|
||||
#define MCDRV_AEUPDATE_FLAG_WIDE ((UINT32)0x00000020)
|
||||
#define MCDRV_AEUPDATE_FLAG_DRC ((UINT32)0x00000040)
|
||||
#define MCDRV_AEUPDATE_FLAG_EQ5 ((UINT32)0x00000080)
|
||||
#define MCDRV_AEUPDATE_FLAG_EQ3 ((UINT32)0x00000100)
|
||||
|
||||
/* MCDRV_AE_INFO bOnOff setting */
|
||||
#define MCDRV_BEXWIDE_ON (0x01)
|
||||
#define MCDRV_DRC_ON (0x02)
|
||||
#define MCDRV_EQ5_ON (0x04)
|
||||
#define MCDRV_EQ3_ON (0x08)
|
||||
|
||||
#define BEX_PARAM_SIZE (104)
|
||||
#define WIDE_PARAM_SIZE (20)
|
||||
#define DRC_PARAM_SIZE (256)
|
||||
#define EQ5_PARAM_SIZE (105)
|
||||
#define EQ3_PARAM_SIZE (75)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bOnOff;
|
||||
UINT8 abBex[BEX_PARAM_SIZE];
|
||||
UINT8 abWide[WIDE_PARAM_SIZE];
|
||||
UINT8 abDrc[DRC_PARAM_SIZE];
|
||||
UINT8 abEq5[EQ5_PARAM_SIZE];
|
||||
UINT8 abEq3[EQ3_PARAM_SIZE];
|
||||
} MCDRV_AE_INFO;
|
||||
|
||||
/* set cdsp param */
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bId;
|
||||
UINT8 abParam[16];
|
||||
} MCDRV_CDSPPARAM;
|
||||
|
||||
/* register cdsp cb */
|
||||
/* dEvtType */
|
||||
#define MCDRV_CDSP_EVT_ERROR (0)
|
||||
#define MCDRV_CDSP_EVT_PARAM (1)
|
||||
|
||||
/* dEvtPrm */
|
||||
#define MCDRV_CDSP_PRG_ERROR (0)
|
||||
#define MCDRV_CDSP_PRG_ERROR_FATAL (1)
|
||||
#define MCDRV_CDSP_SYS_ERROR (2)
|
||||
|
||||
/* set pdm */
|
||||
#define MCDRV_PDMCLK_UPDATE_FLAG ((UINT32)0x00000001)
|
||||
#define MCDRV_PDMADJ_UPDATE_FLAG ((UINT32)0x00000002)
|
||||
#define MCDRV_PDMAGC_UPDATE_FLAG ((UINT32)0x00000004)
|
||||
#define MCDRV_PDMEDGE_UPDATE_FLAG ((UINT32)0x00000008)
|
||||
#define MCDRV_PDMWAIT_UPDATE_FLAG ((UINT32)0x00000010)
|
||||
#define MCDRV_PDMSEL_UPDATE_FLAG ((UINT32)0x00000020)
|
||||
#define MCDRV_PDMMONO_UPDATE_FLAG ((UINT32)0x00000040)
|
||||
|
||||
/* MCDRV_PDM_INFO bClk setting */
|
||||
#define MCDRV_PDM_CLK_128 (1)
|
||||
#define MCDRV_PDM_CLK_64 (2)
|
||||
#define MCDRV_PDM_CLK_32 (3)
|
||||
|
||||
/* MCDRV_PDM_INFO bPdmEdge setting */
|
||||
#define MCDRV_PDMEDGE_LH (0)
|
||||
#define MCDRV_PDMEDGE_HL (1)
|
||||
|
||||
/* MCDRV_PDM_INFO bPdmWait setting */
|
||||
#define MCDRV_PDMWAIT_0 (0)
|
||||
#define MCDRV_PDMWAIT_1 (1)
|
||||
#define MCDRV_PDMWAIT_10 (2)
|
||||
#define MCDRV_PDMWAIT_20 (3)
|
||||
|
||||
/* MCDRV_PDM_INFO bPdmSel setting */
|
||||
#define MCDRV_PDMSEL_L1R2 (0)
|
||||
#define MCDRV_PDMSEL_L2R1 (1)
|
||||
#define MCDRV_PDMSEL_L1R1 (2)
|
||||
#define MCDRV_PDMSEL_L2R2 (3)
|
||||
|
||||
/* MCDRV_PDM_INFO bMono setting */
|
||||
#define MCDRV_PDM_STEREO (0)
|
||||
#define MCDRV_PDM_MONO (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bClk;
|
||||
UINT8 bAgcAdjust;
|
||||
UINT8 bAgcOn;
|
||||
UINT8 bPdmEdge;
|
||||
UINT8 bPdmWait;
|
||||
UINT8 bPdmSel;
|
||||
UINT8 bMono;
|
||||
} MCDRV_PDM_INFO;
|
||||
|
||||
/* set dtmf */
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bSinGen0Vol;
|
||||
UINT8 bSinGen1Vol;
|
||||
UINT16 wSinGen0Freq;
|
||||
UINT16 wSinGen1Freq;
|
||||
UINT8 bSinGenGate;
|
||||
UINT8 bSinGenMode;
|
||||
UINT8 bSinGenLoop;
|
||||
} MCDRV_DTMF_PARAM;
|
||||
|
||||
/* MCDRV_DTMF_INFO bOnOff setting */
|
||||
#define MCDRV_DTMF_ON (0)
|
||||
#define MCDRV_DTMF_OFF (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bOnOff;
|
||||
MCDRV_DTMF_PARAM sParam;
|
||||
} MCDRV_DTMF_INFO;
|
||||
|
||||
/* config gp */
|
||||
#define GPIO_PAD_NUM (2)
|
||||
|
||||
/* MCDRV_GP_MODE abGpDdr setting */
|
||||
#define MCDRV_GPDDR_IN (0)
|
||||
#define MCDRV_GPDDR_OUT (1)
|
||||
|
||||
/* MCDRV_GP_MODE abGpMode setting */
|
||||
#define MCDRV_GPMODE_RISING (0)
|
||||
#define MCDRV_GPMODE_FALLING (1)
|
||||
#define MCDRV_GPMODE_BOTH (2)
|
||||
|
||||
/* MCDRV_GP_MODE abGpHost setting */
|
||||
#define MCDRV_GPHOST_SCU (0)
|
||||
#define MCDRV_GPHOST_CDSP (1)
|
||||
|
||||
/* MCDRV_GP_MODE abGpInvert setting */
|
||||
#define MCDRV_GPINV_NORMAL (0)
|
||||
#define MCDRV_GPINV_INVERT (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 abGpDdr[GPIO_PAD_NUM];
|
||||
UINT8 abGpMode[GPIO_PAD_NUM];
|
||||
UINT8 abGpHost[GPIO_PAD_NUM];
|
||||
UINT8 abGpInvert[GPIO_PAD_NUM];
|
||||
} MCDRV_GP_MODE;
|
||||
|
||||
/* mask gp */
|
||||
#define MCDRV_GPMASK_OFF (0)
|
||||
#define MCDRV_GPMASK_ON (1)
|
||||
|
||||
#define MCDRV_GP_PAD0 ((UINT32)0)
|
||||
#define MCDRV_GP_PAD1 ((UINT32)1)
|
||||
|
||||
/* getset gp */
|
||||
#define MCDRV_GP_LOW (0)
|
||||
#define MCDRV_GP_HIGH (1)
|
||||
|
||||
/* get peak */
|
||||
#define PEAK_CHANNELS (2)
|
||||
typedef struct
|
||||
{
|
||||
SINT16 aswPeak[PEAK_CHANNELS];
|
||||
} MCDRV_PEAK;
|
||||
|
||||
/* set/get syseq */
|
||||
#define MCDRV_SYSEQ_ONOFF_UPDATE_FLAG ((UINT32)0x00000001)
|
||||
#define MCDRV_SYSEQ_PARAM_UPDATE_FLAG ((UINT32)0x00000002)
|
||||
|
||||
/* MCDRV_SYSEQ_INFO bOnOff setting */
|
||||
#define MCDRV_SYSEQ_OFF (0)
|
||||
#define MCDRV_SYSEQ_ON (1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bOnOff;
|
||||
UINT8 abParam[15];
|
||||
} MCDRV_SYSEQ_INFO;
|
||||
|
||||
/* read_reg, write_reg */
|
||||
#define MCDRV_REGTYPE_A (0)
|
||||
#define MCDRV_REGTYPE_B_BASE (1)
|
||||
#define MCDRV_REGTYPE_B_MIXER (2)
|
||||
#define MCDRV_REGTYPE_B_AE (3)
|
||||
#define MCDRV_REGTYPE_B_CDSP (4)
|
||||
#define MCDRV_REGTYPE_B_CODEC (5)
|
||||
#define MCDRV_REGTYPE_B_ANALOG (6)
|
||||
typedef struct
|
||||
{
|
||||
UINT8 bRegType;
|
||||
UINT8 bAddress;
|
||||
UINT8 bData;
|
||||
} MCDRV_REG_INFO;
|
||||
|
||||
|
||||
#endif /* _MCDRIVER_H_ */
|
38
yamaha-mc1n2-audio/include/mctypedef.h
Normal file
38
yamaha-mc1n2-audio/include/mctypedef.h
Normal file
@ -0,0 +1,38 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright(c) 2010 Yamaha Corporation. All rights reserved.
|
||||
*
|
||||
* Module : mctypedef.h
|
||||
*
|
||||
* Description : MC Device Type definitions
|
||||
*
|
||||
* Version : 1.0.0 2010.03.18
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _MCTYPEDEF_H_
|
||||
#define _MCTYPEDEF_H_
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#ifndef UINT8
|
||||
#define UINT8 unsigned char
|
||||
#endif
|
||||
#ifndef UINT16
|
||||
#define UINT16 unsigned short
|
||||
#endif
|
||||
#ifndef UINT32
|
||||
#define UINT32 unsigned long
|
||||
#endif
|
||||
#ifndef SINT8
|
||||
#define SINT8 signed char
|
||||
#endif
|
||||
#ifndef SINT16
|
||||
#define SINT16 signed short
|
||||
#endif
|
||||
#ifndef SINT32
|
||||
#define SINT32 signed long
|
||||
#endif
|
||||
|
||||
#endif /*_MCTYPEDEF_H_*/
|
113
yamaha-mc1n2-audio/include/yamaha-mc1n2-audio.h
Normal file
113
yamaha-mc1n2-audio/include/yamaha-mc1n2-audio.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef YAMAHA_MC1N2_AUDIO_H
|
||||
#define YAMAHA_MC1N2_AUDIO_H
|
||||
|
||||
#include <system/audio.h>
|
||||
|
||||
#include "mc1n2.h"
|
||||
|
||||
enum yamaha_mc1n2_audio_direction {
|
||||
YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT,
|
||||
YAMAHA_MC1N2_AUDIO_DIRECTION_INPUT,
|
||||
YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM,
|
||||
YAMAHA_MC1N2_AUDIO_DIRECTION_MAX
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_params_init {
|
||||
MCDRV_AE_INFO ae_info;
|
||||
MCDRV_PATH_INFO path_info;
|
||||
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_params_route {
|
||||
audio_devices_t device;
|
||||
enum yamaha_mc1n2_audio_direction direction;
|
||||
|
||||
MCDRV_AE_INFO ae_info;
|
||||
MCDRV_PATH_INFO path_info;
|
||||
MCDRV_DAC_INFO dac_info;
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_params {
|
||||
struct yamaha_mc1n2_audio_params_init *init;
|
||||
struct yamaha_mc1n2_audio_params_route *routes;
|
||||
int routes_count;
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_device_ops {
|
||||
char *hw_node;
|
||||
int hw_fd;
|
||||
struct yamaha_mc1n2_audio_params params;
|
||||
};
|
||||
|
||||
struct yamaha_mc1n2_audio_pdata {
|
||||
char *name;
|
||||
struct yamaha_mc1n2_audio_device_ops *ops;
|
||||
|
||||
audio_devices_t output_device;
|
||||
audio_devices_t input_device;
|
||||
|
||||
int output_state;
|
||||
int input_state;
|
||||
int modem_state;
|
||||
};
|
||||
|
||||
/*
|
||||
* Platforms
|
||||
*/
|
||||
|
||||
extern struct yamaha_mc1n2_audio_pdata galaxys2_pdata;
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
|
||||
// IOCTL
|
||||
int yamaha_mc1n2_audio_ioctl(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
int command, struct mc1n2_ctrl_args *hw_ctrl);
|
||||
int yamaha_mc1n2_audio_ioctl_set_ctrl(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
unsigned long command, void *data, unsigned long update_info);
|
||||
int yamaha_mc1n2_audio_ioctl_notify(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
unsigned long command);
|
||||
|
||||
// Routines
|
||||
int yamaha_mc1n2_audio_init(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_output_start(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_output_stop(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_input_start(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_input_stop(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_modem_start(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
int yamaha_mc1n2_audio_modem_stop(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
|
||||
// Values configuration
|
||||
int yamaha_mc1n2_audio_set_route(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
audio_devices_t device);
|
||||
char *yamaha_mc1n2_audio_get_hw_node(struct yamaha_mc1n2_audio_pdata *pdata);
|
||||
|
||||
// Init/Deinit
|
||||
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
|
674
yamaha-mc1n2-audio/yamaha-mc1n2-audio.c
Normal file
674
yamaha-mc1n2-audio/yamaha-mc1n2-audio.c
Normal file
@ -0,0 +1,674 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#define LOG_TAG "Yamaha-MC1N2-Audio"
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include <system/audio.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
|
||||
*/
|
||||
|
||||
int yamaha_mc1n2_audio_ioctl(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
int command, struct mc1n2_ctrl_args *hw_ctrl)
|
||||
{
|
||||
char *hw_node = NULL;
|
||||
int hw_fd = -1;
|
||||
int rc = -1;
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
hw_node = pdata->ops->hw_node;
|
||||
if(hw_node == NULL) {
|
||||
ALOGE("%s: error, missing hw_node!", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(pdata->ops->hw_fd <= 0) {
|
||||
hw_fd = open(hw_node, O_RDWR);
|
||||
if(hw_fd < 0) {
|
||||
ALOGE("%s: error, unable to open hw_node (fd is %d)!", __func__, hw_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pdata->ops->hw_fd = hw_fd;
|
||||
}
|
||||
|
||||
rc = ioctl(pdata->ops->hw_fd, command, hw_ctrl);
|
||||
if(rc < 0) {
|
||||
ALOGE("%s: error, ioctl on hw_node failed (rc is %d)!", __func__, rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_ioctl_set_ctrl(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
unsigned long command, void *data, unsigned long update_info)
|
||||
{
|
||||
struct mc1n2_ctrl_args hw_ctrl;
|
||||
|
||||
if(pdata == NULL)
|
||||
return -1;
|
||||
|
||||
memset(&hw_ctrl, 0, sizeof(hw_ctrl));
|
||||
hw_ctrl.dCmd = command;
|
||||
hw_ctrl.pvPrm = data;
|
||||
hw_ctrl.dPrm = update_info;
|
||||
|
||||
return yamaha_mc1n2_audio_ioctl(pdata, MC1N2_IOCTL_SET_CTRL, &hw_ctrl);
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_ioctl_notify(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
unsigned long command)
|
||||
{
|
||||
struct mc1n2_ctrl_args hw_ctrl;
|
||||
|
||||
if(pdata == NULL)
|
||||
return -1;
|
||||
|
||||
memset(&hw_ctrl, 0, sizeof(hw_ctrl));
|
||||
hw_ctrl.dCmd = command;
|
||||
|
||||
return yamaha_mc1n2_audio_ioctl(pdata, MC1N2_IOCTL_NOTIFY, &hw_ctrl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Routines
|
||||
*/
|
||||
|
||||
int yamaha_mc1n2_audio_init(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
struct yamaha_mc1n2_audio_params_init *params = NULL;
|
||||
int rc = -1;
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
params = pdata->ops->params.init;
|
||||
if(params == NULL)
|
||||
return -1;
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DAC,
|
||||
¶ms->dac_info, 0x07);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_DAC IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_ADC,
|
||||
¶ms->adc_info, 0x07);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_ADC IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_SP,
|
||||
¶ms->sp_info, 0x00);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_SP IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_PDM,
|
||||
¶ms->pdm_info, 0x7f);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_PDM IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DNG,
|
||||
¶ms->dng_info, 0x3f3f3f);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_DNG IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_SYSEQ,
|
||||
¶ms->syseq_info, 0x03);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_SYSEQ IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct yamaha_mc1n2_audio_params_route *
|
||||
yamaha_mc1n2_audio_params_route_find(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
audio_devices_t device, enum yamaha_mc1n2_audio_direction direction)
|
||||
{
|
||||
struct yamaha_mc1n2_audio_params_route *params = NULL;
|
||||
int params_count = 0;
|
||||
int i;
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return NULL;
|
||||
|
||||
ALOGD("(%s): device = %d, direction = %d",__func__,device,direction);
|
||||
|
||||
params = pdata->ops->params.routes;
|
||||
params_count = pdata->ops->params.routes_count;
|
||||
if(params == NULL || params_count <= 0)
|
||||
return NULL;
|
||||
|
||||
for(i=0 ; i < params_count ; i++) {
|
||||
if(params[i].device == device && params[i].direction == direction)
|
||||
return ¶ms[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_params_route_simple_array_merge(int length,
|
||||
unsigned char *array_src, unsigned char *array_dst)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(length <= 0 || array_src == NULL || array_dst == NULL)
|
||||
return -1;
|
||||
|
||||
for(i=0 ; i < length ; i++) {
|
||||
if(array_dst[i] == 0)
|
||||
array_dst[i] = array_src[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_params_route_path_array_merge(int length,
|
||||
unsigned char *array_src, unsigned char *array_dst)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char v;
|
||||
|
||||
if(length <= 0 || array_src == NULL || array_dst == NULL)
|
||||
return -1;
|
||||
|
||||
for(i=0 ; i < length ; i++) {
|
||||
if(array_dst[i] == 0) {
|
||||
array_dst[i] = array_src[i];
|
||||
} else {
|
||||
v = array_src[i];
|
||||
|
||||
for(j=0; j < 8 ; j++) {
|
||||
if((1 << j) & array_dst[i]) {
|
||||
if(j % 2 == 0)
|
||||
v &= ~(1 << (j+1));
|
||||
else
|
||||
v &= ~(1 << (j-1));
|
||||
|
||||
v |= (1 << j);
|
||||
}
|
||||
}
|
||||
|
||||
array_dst[i] = v;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_params_route_merge(
|
||||
struct yamaha_mc1n2_audio_params_route *params_src,
|
||||
struct yamaha_mc1n2_audio_params_route *params_dst)
|
||||
{
|
||||
if(params_src == NULL || params_dst == NULL)
|
||||
return -1;
|
||||
|
||||
// ae_info
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.bOnOff),
|
||||
¶ms_src->ae_info.bOnOff, ¶ms_dst->ae_info.bOnOff);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.abBex),
|
||||
params_src->ae_info.abBex, params_dst->ae_info.abBex);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.abWide),
|
||||
params_src->ae_info.abWide, params_dst->ae_info.abWide);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.abDrc),
|
||||
params_src->ae_info.abDrc, params_dst->ae_info.abDrc);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.abEq5),
|
||||
params_src->ae_info.abEq5, params_dst->ae_info.abEq5);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->ae_info.abEq3),
|
||||
params_src->ae_info.abEq3, params_dst->ae_info.abEq3);
|
||||
|
||||
// path_info
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asHpOut[0].abSrcOnOff),
|
||||
params_src->path_info.asHpOut[0].abSrcOnOff, params_dst->path_info.asHpOut[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asHpOut[1].abSrcOnOff),
|
||||
params_src->path_info.asHpOut[1].abSrcOnOff, params_dst->path_info.asHpOut[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asSpOut[0].abSrcOnOff),
|
||||
params_src->path_info.asSpOut[0].abSrcOnOff, params_dst->path_info.asSpOut[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asSpOut[1].abSrcOnOff),
|
||||
params_src->path_info.asSpOut[1].abSrcOnOff, params_dst->path_info.asSpOut[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asRcOut[0].abSrcOnOff),
|
||||
params_src->path_info.asRcOut[0].abSrcOnOff, params_dst->path_info.asRcOut[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asLout1[0].abSrcOnOff),
|
||||
params_src->path_info.asLout1[0].abSrcOnOff, params_dst->path_info.asLout1[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asLout1[1].abSrcOnOff),
|
||||
params_src->path_info.asLout1[1].abSrcOnOff, params_dst->path_info.asLout1[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asLout2[0].abSrcOnOff),
|
||||
params_src->path_info.asLout2[0].abSrcOnOff, params_dst->path_info.asLout2[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asLout2[1].abSrcOnOff),
|
||||
params_src->path_info.asLout2[1].abSrcOnOff, params_dst->path_info.asLout2[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asPeak[0].abSrcOnOff),
|
||||
params_src->path_info.asPeak[0].abSrcOnOff, params_dst->path_info.asPeak[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asDit0[0].abSrcOnOff),
|
||||
params_src->path_info.asDit0[0].abSrcOnOff, params_dst->path_info.asDit0[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asDit1[0].abSrcOnOff),
|
||||
params_src->path_info.asDit1[0].abSrcOnOff, params_dst->path_info.asDit1[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asDit2[0].abSrcOnOff),
|
||||
params_src->path_info.asDit2[0].abSrcOnOff, params_dst->path_info.asDit2[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asDac[0].abSrcOnOff),
|
||||
params_src->path_info.asDac[0].abSrcOnOff, params_dst->path_info.asDac[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asDac[1].abSrcOnOff),
|
||||
params_src->path_info.asDac[1].abSrcOnOff, params_dst->path_info.asDac[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asAe[0].abSrcOnOff),
|
||||
params_src->path_info.asAe[0].abSrcOnOff, params_dst->path_info.asAe[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asCdsp[0].abSrcOnOff),
|
||||
params_src->path_info.asCdsp[0].abSrcOnOff, params_dst->path_info.asCdsp[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asCdsp[1].abSrcOnOff),
|
||||
params_src->path_info.asCdsp[1].abSrcOnOff, params_dst->path_info.asCdsp[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asCdsp[2].abSrcOnOff),
|
||||
params_src->path_info.asCdsp[2].abSrcOnOff, params_dst->path_info.asCdsp[2].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asCdsp[3].abSrcOnOff),
|
||||
params_src->path_info.asCdsp[3].abSrcOnOff, params_dst->path_info.asCdsp[3].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asAdc0[0].abSrcOnOff),
|
||||
params_src->path_info.asAdc0[0].abSrcOnOff, params_dst->path_info.asAdc0[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asAdc0[1].abSrcOnOff),
|
||||
params_src->path_info.asAdc0[1].abSrcOnOff, params_dst->path_info.asAdc0[1].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asAdc1[0].abSrcOnOff),
|
||||
params_src->path_info.asAdc1[0].abSrcOnOff, params_dst->path_info.asAdc1[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asMix[0].abSrcOnOff),
|
||||
params_src->path_info.asMix[0].abSrcOnOff, params_dst->path_info.asMix[0].abSrcOnOff);
|
||||
yamaha_mc1n2_audio_params_route_path_array_merge(sizeof(params_src->path_info.asBias[0].abSrcOnOff),
|
||||
params_src->path_info.asBias[0].abSrcOnOff, params_dst->path_info.asBias[0].abSrcOnOff);
|
||||
|
||||
// dac_info
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->dac_info.bMasterSwap),
|
||||
¶ms_src->dac_info.bMasterSwap, ¶ms_dst->dac_info.bMasterSwap);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->dac_info.bVoiceSwap),
|
||||
¶ms_src->dac_info.bVoiceSwap, ¶ms_dst->dac_info.bVoiceSwap);
|
||||
yamaha_mc1n2_audio_params_route_simple_array_merge(sizeof(params_src->dac_info.bDcCut),
|
||||
¶ms_src->dac_info.bDcCut, ¶ms_dst->dac_info.bDcCut);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_route_start(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
struct yamaha_mc1n2_audio_params_route *params_route = NULL;
|
||||
struct yamaha_mc1n2_audio_params_init *params_init = NULL;
|
||||
struct yamaha_mc1n2_audio_params_route *params = NULL;
|
||||
struct yamaha_mc1n2_audio_params_route params_src;
|
||||
struct yamaha_mc1n2_audio_params_route params_dst;
|
||||
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
params_init = pdata->ops->params.init;
|
||||
if(params_init == NULL)
|
||||
return -1;
|
||||
|
||||
// Copy the init params
|
||||
memcpy(¶ms_src.ae_info, ¶ms_init->ae_info, sizeof(params_src.ae_info));
|
||||
memcpy(¶ms_src.path_info, ¶ms_init->path_info, sizeof(params_src.path_info));
|
||||
memcpy(¶ms_src.dac_info, ¶ms_init->dac_info, sizeof(params_src.dac_info));
|
||||
|
||||
output_merge:
|
||||
if(pdata->output_state) {
|
||||
params_route = yamaha_mc1n2_audio_params_route_find(pdata,
|
||||
pdata->output_device, YAMAHA_MC1N2_AUDIO_DIRECTION_OUTPUT);
|
||||
if(params_route == NULL)
|
||||
goto input_merge;
|
||||
|
||||
memcpy(¶ms_dst, params_route, sizeof(params_dst));
|
||||
yamaha_mc1n2_audio_params_route_merge(¶ms_src, ¶ms_dst);
|
||||
memcpy(¶ms_src, ¶ms_dst, sizeof(params_src));
|
||||
}
|
||||
|
||||
input_merge:
|
||||
if(pdata->input_state) {
|
||||
params_route = yamaha_mc1n2_audio_params_route_find(pdata,
|
||||
pdata->input_device, YAMAHA_MC1N2_AUDIO_DIRECTION_INPUT);
|
||||
if(params_route == NULL)
|
||||
goto modem_merge;
|
||||
|
||||
memcpy(¶ms_dst, params_route, sizeof(params_dst));
|
||||
yamaha_mc1n2_audio_params_route_merge(¶ms_src, ¶ms_dst);
|
||||
memcpy(¶ms_src, ¶ms_dst, sizeof(params_src));
|
||||
}
|
||||
|
||||
modem_merge:
|
||||
if(pdata->modem_state) {
|
||||
params_route = yamaha_mc1n2_audio_params_route_find(pdata,
|
||||
pdata->output_device, YAMAHA_MC1N2_AUDIO_DIRECTION_MODEM);
|
||||
if(params_route == NULL)
|
||||
goto route_start;
|
||||
|
||||
memcpy(¶ms_dst, params_route, sizeof(params_dst));
|
||||
yamaha_mc1n2_audio_params_route_merge(¶ms_src, ¶ms_dst);
|
||||
memcpy(¶ms_src, ¶ms_dst, sizeof(params_src));
|
||||
}
|
||||
|
||||
route_start:
|
||||
params = &(params_src);
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_AUDIOENGINE,
|
||||
¶ms->ae_info, 0x0f);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_AUDIOENGINE IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_PATH,
|
||||
¶ms->path_info, 0x00);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_PATH IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_set_ctrl(pdata, MCDRV_SET_DAC,
|
||||
¶ms->dac_info, 0x07);
|
||||
if(rc < 0) {
|
||||
ALOGE("SET_DAC IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_output_start(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->output_state = 1;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_MEDIA_PLAY_START);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_MEDIA_PLAY_START IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_output_stop(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->output_state = 0;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_MEDIA_PLAY_STOP);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_MEDIA_PLAY_STOP IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_input_start(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->input_state = 1;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_VOICE_REC_START);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_VOICE_REC_START IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_input_stop(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->input_state = 0;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_VOICE_REC_STOP);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_VOICE_REC_START IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_modem_start(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->modem_state = 1;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_CALL_START);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_CALL_START IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_modem_stop(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
pdata->modem_state = 0;
|
||||
|
||||
rc = yamaha_mc1n2_audio_route_start(pdata);
|
||||
if(rc < 0) {
|
||||
ALOGE("Route start failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = yamaha_mc1n2_audio_ioctl_notify(pdata, MCDRV_NOTIFY_CALL_STOP);
|
||||
if(rc < 0) {
|
||||
ALOGE("NOTIFY_CALL_START IOCTL failed, aborting!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Values configuration
|
||||
*/
|
||||
|
||||
int yamaha_mc1n2_audio_set_route(struct yamaha_mc1n2_audio_pdata *pdata,
|
||||
audio_devices_t device)
|
||||
{
|
||||
int changed = 0;
|
||||
|
||||
ALOGD("%s(%x)", __func__, device);
|
||||
|
||||
if(pdata == NULL)
|
||||
return -1;
|
||||
|
||||
if(audio_is_output_device(device) && pdata->output_device != device) {
|
||||
pdata->output_device = device;
|
||||
changed = 1;
|
||||
} else if(audio_is_input_device(device) && pdata->input_device != device) {
|
||||
pdata->input_device = device;
|
||||
changed = 1;
|
||||
}
|
||||
|
||||
if(changed && (pdata->output_state || pdata->input_state || pdata->modem_state))
|
||||
return yamaha_mc1n2_audio_route_start(pdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *yamaha_mc1n2_audio_get_hw_node(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
if(pdata == NULL)
|
||||
return NULL;
|
||||
|
||||
return pdata->ops->hw_node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Init/Deinit
|
||||
*/
|
||||
|
||||
struct yamaha_mc1n2_audio_pdata *yamaha_mc1n2_audio_platform_get(
|
||||
char *device_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(device_name == NULL)
|
||||
return NULL;
|
||||
|
||||
ALOGD("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;
|
||||
|
||||
ALOGD("%s(%s)", __func__, device_name);
|
||||
|
||||
if(pdata_p == NULL || device_name == NULL)
|
||||
return -1;
|
||||
|
||||
pdata = yamaha_mc1n2_audio_platform_get(device_name);
|
||||
if(pdata == NULL || pdata->ops == NULL) {
|
||||
ALOGE("Unable to find requested platform: %s", device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pdata->ops->hw_fd = -1;
|
||||
|
||||
*pdata_p = pdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yamaha_mc1n2_audio_stop(struct yamaha_mc1n2_audio_pdata *pdata)
|
||||
{
|
||||
ALOGD("%s()", __func__);
|
||||
|
||||
if(pdata == NULL || pdata->ops == NULL)
|
||||
return -1;
|
||||
|
||||
if(pdata->ops->hw_fd >= 0) {
|
||||
close(pdata->ops->hw_fd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user