--- /dev/null
+Hyunseok Lee <hs7388.lee at samsung.com>
--- /dev/null
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+lib_LTLIBRARIES = libtizen-audio.la
+
+libtizen_audio_la_SOURCES = tizen-audio.c \
+ tizen-audio-session.c \
+ tizen-audio-device.c \
+ tizen-audio-stream.c \
+ tizen-audio-util.c
+libtizen_audio_la_LDFLAGS = $(AM_LDFLAGS) -disable-static -avoid-version
+libtizen_audio_la_LIBADD = $(AM_LDADD) $(ASOUNDLIB_LIBS) $(VCONF_LIBS) $(DLOG_LIBS) $(INIPARSER_LIBS)
+libtizen_audio_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS) $(VCONF_CFLAGS) $(DLOG_CFLAGS) $(INIPARSER_CFLAGS)
+libtizen_audio_la_CFLAGS += -DUSE_DLOG
+
+
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
--- /dev/null
+/*
+ * YMU831 ASoC codec driver
+ *
+ * Copyright (c) 2012 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 ASOC_H
+#define ASOC_H
+
+#include <linux/ioctl.h>
+
+/*
+ * dai: set_clkdiv
+ */
+/* div_id */
+#define MC_ASOC_BCLK_MULT 5
+
+/* div for MC_ASOC_BCLK_MULT */
+#define MC_ASOC_LRCK_X64 (0)
+#define MC_ASOC_LRCK_X48 (1)
+#define MC_ASOC_LRCK_X32 (2)
+#define MC_ASOC_LRCK_X512 (3)
+#define MC_ASOC_LRCK_X256 (4)
+#define MC_ASOC_LRCK_X192 (5)
+#define MC_ASOC_LRCK_X128 (6)
+#define MC_ASOC_LRCK_X96 (7)
+#define MC_ASOC_LRCK_X24 (8)
+#define MC_ASOC_LRCK_X16 (9)
+
+/*
+ * hwdep: ioctl
+ */
+#define MC_ASOC_MAGIC 'N'
+#define MC_ASOC_IOCTL_SET_CTRL (1)
+#define MC_ASOC_IOCTL_READ_REG (2)
+#define MC_ASOC_IOCTL_WRITE_REG (3)
+#define MC_ASOC_IOCTL_NOTIFY_HOLD (4)
+#define MC_ASOC_IOCTL_GET_DSP_DATA (5)
+#define MC_ASOC_IOCTL_SET_DSP_DATA (6)
+
+#define YMC_IOCTL_SET_CTRL \
+ _IOW(MC_ASOC_MAGIC, MC_ASOC_IOCTL_SET_CTRL, ymc_ctrl_args_t)
+
+#define YMC_IOCTL_READ_REG \
+ _IOWR(MC_ASOC_MAGIC, MC_ASOC_IOCTL_READ_REG, ymc_reg_args_t)
+
+#define YMC_IOCTL_WRITE_REG \
+ _IOWR(MC_ASOC_MAGIC, MC_ASOC_IOCTL_WRITE_REG, ymc_reg_args_t)
+
+#define YMC_IOCTL_NOTIFY_HOLD \
+ _IOWR(MC_ASOC_MAGIC, MC_ASOC_IOCTL_NOTIFY_HOLD, unsigned long)
+#define YMC_IOCTL_GET_DSP_DATA \
+ _IOWR(MC_ASOC_MAGIC, MC_ASOC_IOCTL_GET_DSP_DATA, \
+ ymc_dspdata_args_t)
+#define YMC_IOCTL_SET_DSP_DATA \
+ _IOWR(MC_ASOC_MAGIC, MC_ASOC_IOCTL_SET_DSP_DATA, \
+ ymc_dspdata_args_t)
+
+typedef struct _ymc_ctrl_args {
+ void *param;
+ unsigned long size;
+ unsigned long option;
+} ymc_ctrl_args_t;
+
+typedef struct _ymc_reg_args {
+ unsigned char bRegType;
+ unsigned char bAddress;
+ unsigned char bData;
+} ymc_reg_args_t;
+
+typedef struct _ymc_dspdata_args {
+ unsigned char *buf;
+ unsigned long bufsize;
+ unsigned long size;
+} ymc_dspdata_args_t;
+
+#define YMC_DSP_OUTPUT_BASE (0x00000000)
+#define YMC_DSP_OUTPUT_SP (0x00000001)
+#define YMC_DSP_OUTPUT_RC (0x00000002)
+#define YMC_DSP_OUTPUT_HP (0x00000003)
+#define YMC_DSP_OUTPUT_LO1 (0x00000004)
+#define YMC_DSP_OUTPUT_LO2 (0x00000005)
+#define YMC_DSP_OUTPUT_BT (0x00000006)
+
+#define YMC_DSP_INPUT_BASE (0x00000010)
+#define YMC_DSP_INPUT_MAINMIC (0x00000020)
+#define YMC_DSP_INPUT_SUBMIC (0x00000030)
+#define YMC_DSP_INPUT_2MIC (0x00000040)
+#define YMC_DSP_INPUT_HEADSET_MIC (0x00000050)
+#define YMC_DSP_INPUT_BLUETOOTH_MIC (0x00000060)
+#define YMC_DSP_INPUT_LINEIN1 (0x00000070)
+#define YMC_DSP_INPUT_LINEIN2 (0x00000080)
+
+#define YMC_DSP_VOICECALL_BASE_1MIC (0x00000100)
+#define YMC_DSP_VOICECALL_BASE_2MIC (0x00000200)
+#define YMC_DSP_VOICECALL_SP_1MIC (0x00000300)
+#define YMC_DSP_VOICECALL_SP_2MIC (0x00000400)
+#define YMC_DSP_VOICECALL_RC_1MIC (0x00000500)
+#define YMC_DSP_VOICECALL_RC_2MIC (0x00000600)
+#define YMC_DSP_VOICECALL_HP_1MIC (0x00000700)
+#define YMC_DSP_VOICECALL_HP_2MIC (0x00000800)
+#define YMC_DSP_VOICECALL_LO1_1MIC (0x00000900)
+#define YMC_DSP_VOICECALL_LO1_2MIC (0x00000A00)
+#define YMC_DSP_VOICECALL_LO2_1MIC (0x00000B00)
+#define YMC_DSP_VOICECALL_LO2_2MIC (0x00000C00)
+#define YMC_DSP_VOICECALL_HEADSET (0x00000D00)
+#define YMC_DSP_VOICECALL_HEADBT (0x00000E00)
+#define YMC_DSP_VOICECALL_BASE_COMMON (0x00000F00)
+
+#define YMC_NOTITY_HOLD_OFF (0)
+#define YMC_NOTITY_HOLD_ON (1)
+
+#endif
--- /dev/null
+<manifest>
+ <define>
+ <domain name="audio-hal"/>
+ <request>
+ <smack request="system::vconf" type="arwxt"/>
+ <smack request="system::vconf_multimedia" type="arwxt"/>
+ </request>
+ </define>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+#!/bin/sh
+
+# autogen.sh -- Autotools bootstrapping
+#
+
+libtoolize --copy --force
+aclocal && \
+autoheader && \
+autoconf && \
+automake --add-missing --copy
--- /dev/null
+AC_PREREQ([2.67])
+
+AC_INIT([libaudiofilters-sec], [0.1])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_CONFIG_HEADERS([config.h])
+
+AC_CONFIG_MACRO_DIR([m4])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+AC_PROG_AWK
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+PKG_PROG_PKG_CONFIG
+
+# Checks for libraries.
+
+PKG_CHECK_MODULES(ASOUNDLIB, alsa >= 1.0.24)
+AC_SUBST(ASOUNDLIB_CFLAGS)
+AC_SUBST(ASOUNDLIB_LIBS)
+
+PKG_CHECK_MODULES(VCONF, vconf)
+AC_SUBST(VCONF_CFLAGS)
+AC_SUBST(VCONF_LIBS)
+
+PKG_CHECK_MODULES(INIPARSER, iniparser)
+AC_SUBST(INIPARSER_CFLAGS)
+AC_SUBST(INIPARSER_LIBS)
+
+PKG_CHECK_MODULES(DLOG, dlog)
+AC_SUBST(DLOG_CFLAGS)
+AC_SUBST(DLOG_LIBS)
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+
+AC_CONFIG_FILES([ \
+ Makefile
+ ])
+AC_OUTPUT
--- /dev/null
+Name: audio-hal-e3250
+Summary: TIZEN Audio HAL for Exynos3250
+Version: 0.2.13
+Release: 0
+Group: System/Libraries
+License: Apache-2.0
+URL: http://tizen.org
+Source0: audio-hal-e3250-%{version}.tar.gz
+BuildRequires: pkgconfig(alsa)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(iniparser)
+BuildRequires: pkgconfig(dlog)
+
+%description
+TIZEN Audio HAL for Exynos3250
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS –DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+
+%autogen
+%configure
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%manifest audio-hal-e3250.manifest
+%defattr(-,root,root,-)
+/usr/lib/libtizen-audio.so
+%{_datadir}/license/%{name}
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "tizen-audio-internal.h"
+
+audio_return_t _audio_device_init (audio_mgr_t *am)
+{
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ am->device.active_in = AUDIO_DEVICE_IN_NONE;
+ am->device.active_out = AUDIO_DEVICE_OUT_NONE;
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t _audio_device_deinit (audio_mgr_t *am)
+{
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_set_route (void *userdata, uint32_t session, uint32_t subsession, uint32_t device_in, uint32_t device_out, uint32_t route_flag)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+ bool update_volume = false;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_INFO("session:%d,%d in:%d out:%d flag:0x%x", session, subsession, device_in, device_out, route_flag);
+
+ if (am->device.active_out != device_out)
+ update_volume = true;
+
+ am->device.active_in = device_in;
+ am->device.active_out = device_out;
+
+ /* Volume level should be updated if device changed */
+ if (update_volume)
+ audio_ret = _audio_update_volume_level(am);
+
+ return audio_ret;
+}
--- /dev/null
+#ifndef footizenaudiointernalfoo
+#define footizenaudiointernalfoo
+
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dlog.h>
+#include <alsa/asoundlib.h>
+
+#include "tizen-audio.h"
+
+/* Debug */
+
+#define AUDIO_DEBUG
+#define AUDIO_DUMP_STR_LEN 256
+#ifdef USE_DLOG
+#ifdef DLOG_TAG
+#undef DLOG_TAG
+#endif
+#define DLOG_TAG "AUDIO_HAL"
+#define AUDIO_LOG_ERROR(...) SLOG(LOG_ERROR, DLOG_TAG, __VA_ARGS__)
+#define AUDIO_LOG_WARN(...) SLOG(LOG_WARN, DLOG_TAG, __VA_ARGS__)
+#define AUDIO_LOG_INFO(...) SLOG(LOG_INFO, DLOG_TAG, __VA_ARGS__)
+#define AUDIO_LOG_DEBUG(...) SLOG(LOG_DEBUG, DLOG_TAG, __VA_ARGS__)
+#define AUDIO_LOG_VERBOSE(...) SLOG(LOG_DEBUG, DLOG_TAG, __VA_ARGS__)
+#else
+#define AUDIO_LOG_ERROR(...) fprintf(stderr, __VA_ARGS__)
+#define AUDIO_LOG_WARN(...) fprintf(stderr, __VA_ARGS__)
+#define AUDIO_LOG_INFO(...) fprintf(stdout, __VA_ARGS__)
+#define AUDIO_LOG_DEBUG(...) fprintf(stdout, __VA_ARGS__)
+#define AUDIO_LOG_VERBOSE(...) fprintf(stdout, __VA_ARGS__)
+#endif
+
+#define AUDIO_RETURN_IF_FAIL(expr, val) do { \
+ if (!expr) { \
+ AUDIO_LOG_ERROR("%s failed", #expr); \
+ return; \
+ } \
+} while (0)
+#define AUDIO_RETURN_VAL_IF_FAIL(expr, val) do { \
+ if (!expr) { \
+ AUDIO_LOG_ERROR("%s failed", #expr); \
+ return val; \
+ } \
+} while (0)
+
+/* Session */
+typedef struct audio_session_mgr {
+ audio_session_t session;
+ audio_subsession_t subsession;
+} audio_session_mgr_t;
+
+
+/* Device */
+
+typedef struct audio_device_mgr {
+ audio_device_in_t active_in;
+ audio_device_out_t active_out;
+} audio_device_mgr_t;
+
+
+/* Stream */
+
+#define AUDIO_VOLUME_LEVEL_MAX 16
+
+typedef struct audio_volume_gain_table {
+ double volume[AUDIO_VOLUME_TYPE_MAX][AUDIO_VOLUME_LEVEL_MAX];
+ uint32_t volume_level_max[AUDIO_VOLUME_LEVEL_MAX];
+ double gain[AUDIO_GAIN_TYPE_MAX];
+} audio_volume_gain_table_t;
+
+enum {
+ AUDIO_VOLUME_DEVICE_SPEAKER,
+ AUDIO_VOLUME_DEVICE_RECEIVER,
+ AUDIO_VOLUME_DEVICE_EARJACK,
+ AUDIO_VOLUME_DEVICE_BT_SCO,
+ AUDIO_VOLUME_DEVICE_BT_A2DP,
+ AUDIO_VOLUME_DEVICE_DOCK,
+ AUDIO_VOLUME_DEVICE_HDMI,
+ AUDIO_VOLUME_DEVICE_MIRRORING,
+ AUDIO_VOLUME_DEVICE_USB,
+ AUDIO_VOLUME_DEVICE_MULTIMEDIA_DOCK,
+ AUDIO_VOLUME_DEVICE_MAX,
+};
+
+typedef struct audio_stream_mgr {
+ uint32_t volume_level[AUDIO_VOLUME_TYPE_MAX];
+ audio_volume_gain_table_t *volume_gain_table;
+} audio_stream_mgr_t;
+
+typedef struct audio_mixer_mgr {
+ snd_ctl_t* mixer;
+ pthread_mutex_t mutex;
+} audio_mixer_mgr_t;
+
+/* Overall */
+
+typedef struct audio_mgr {
+ audio_device_mgr_t device;
+ audio_stream_mgr_t stream;
+ audio_session_mgr_t session;
+ audio_mixer_mgr_t mixer;
+} audio_mgr_t;
+
+audio_return_t _audio_stream_init (audio_mgr_t *am);
+audio_return_t _audio_stream_deinit (audio_mgr_t *am);
+audio_return_t _audio_update_volume_level (audio_mgr_t *am);
+
+audio_return_t _audio_device_init (audio_mgr_t *am);
+audio_return_t _audio_device_deinit (audio_mgr_t * am);
+
+audio_return_t _audio_session_init (audio_mgr_t *am);
+audio_return_t _audio_session_deinit (audio_mgr_t *am);
+
+#define MIXER_SPK_VOLUME "Speaker Volume"
+#define CDSP_VOLUME "CDSP Volume"
+#define MIXER_MIC1_SWITCH "Mic1 Switch"
+#define MIXER_MIC2_SWITCH "Mic2 Switch"
+
+audio_return_t _audio_util_init (audio_mgr_t *am);
+audio_return_t _audio_util_deinit (audio_mgr_t *am);
+audio_return_t _audio_mixer_control_set_value(audio_mgr_t *am, const char *ctl_name, int val);
+audio_return_t _audio_mixer_control_get_value(audio_mgr_t *am, const char *ctl_name, int *val);
+
+#endif
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tizen-audio-internal.h"
+
+audio_return_t _audio_session_init (audio_mgr_t *am)
+{
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ am->session.session = AUDIO_SESSION_MEDIA;
+ am->session.subsession = AUDIO_SUBSESSION_NONE;
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t _audio_session_deinit (audio_mgr_t *am)
+{
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_set_session (void *userdata, uint32_t session, uint32_t subsession)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ AUDIO_LOG_INFO("session:%d,%d", session, subsession);
+
+ if (session == AUDIO_SESSION_VOICE_RECOGNITION && am->session.session != AUDIO_SESSION_VOICE_RECOGNITION) {
+ uint32_t volume_level = 0;
+
+ /* voice recognition start */
+ audio_get_volume_level(userdata, AUDIO_VOLUME_TYPE_SVOICE, &volume_level);
+ audio_ret = audio_set_volume_level(userdata, NULL, AUDIO_VOLUME_TYPE_SVOICE, volume_level);
+ } else if (session != AUDIO_SESSION_VOICE_RECOGNITION && am->session.session == AUDIO_SESSION_VOICE_RECOGNITION) {
+ /* voice recognition end */
+ }
+
+ am->session.session = session;
+ am->session.subsession = subsession;
+
+ return audio_ret;
+}
+
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <math.h>
+#include <vconf.h>
+#include <iniparser.h>
+
+#include "tizen-audio-internal.h"
+
+#define VOLUME_INI_CSC_PATH "/opt/system/csc-default/usr/tuning/mmfw_audio_volume.ini"
+#define VOLUME_INI_DEFAULT_PATH "/usr/etc/mmfw_audio_volume.ini"
+#define VOLUME_INI_TEMP_PATH "/opt/system/mmfw_audio_volume.ini"
+#define VOLUME_VALUE_MAX (1.0f)
+#define GAIN_VALUE_MAX (1.0f)
+
+enum {
+ STREAM_DEVICE_SPEAKER,
+ STREAM_DEVICE_BLUETOOTH,
+ STREAM_DEVICE_MAX,
+};
+
+static const char *g_volume_vconf[AUDIO_VOLUME_TYPE_MAX] = {
+ "file/private/sound/volume/system", /* AUDIO_VOLUME_TYPE_SYSTEM */
+ "file/private/sound/volume/notification", /* AUDIO_VOLUME_TYPE_NOTIFICATION */
+ "file/private/sound/volume/alarm", /* AUDIO_VOLUME_TYPE_ALARM */
+ "file/private/sound/volume/ringtone", /* AUDIO_VOLUME_TYPE_RINGTONE */
+ "file/private/sound/volume/media", /* AUDIO_VOLUME_TYPE_MEDIA */
+ "file/private/sound/volume/call", /* AUDIO_VOLUME_TYPE_CALL */
+ "file/private/sound/volume/voip", /* AUDIO_VOLUME_TYPE_VOIP */
+ "file/private/sound/volume/svoice", /* AUDIO_VOLUME_TYPE_SVOICE */
+ "file/private/sound/volume/fixed", /* AUDIO_VOLUME_TYPE_FIXED */
+ "file/private/sound/volume/java" /* AUDIO_VOLUME_TYPE_EXT_JAVA */
+};
+
+static inline uint8_t __get_volume_dev_index(audio_mgr_t *am, uint32_t volume_type)
+{
+ return 0;
+}
+
+static const uint8_t __get_stream_dev_index (uint32_t device_out)
+{
+ switch (device_out) {
+ case AUDIO_DEVICE_OUT_SPEAKER: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_RECEIVER: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_WIRED_ACCESSORY: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_BT_SCO: return STREAM_DEVICE_BLUETOOTH;
+ case AUDIO_DEVICE_OUT_BT_A2DP: return STREAM_DEVICE_BLUETOOTH;
+ case AUDIO_DEVICE_OUT_DOCK: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_HDMI: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_MIRRORING: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_USB_AUDIO: return STREAM_DEVICE_SPEAKER;
+ case AUDIO_DEVICE_OUT_MULTIMEDIA_DOCK: return STREAM_DEVICE_SPEAKER;
+ default:
+ AUDIO_LOG_DEBUG("invalid device_out:%d", device_out);
+ break;
+ }
+
+ return STREAM_DEVICE_SPEAKER;
+}
+
+static const char *__get_device_string_by_idx (uint32_t dev_idx)
+{
+ switch (dev_idx) {
+ case STREAM_DEVICE_SPEAKER: return "speaker";
+ case STREAM_DEVICE_BLUETOOTH: return "btheadset";
+ default: return "invalid";
+ }
+}
+
+static const char *__get_direction_string_by_idx (uint32_t dir_idx)
+{
+ switch (dir_idx) {
+ case AUDIO_DIRECTION_NONE: return "none";
+ case AUDIO_DIRECTION_IN: return "in";
+ case AUDIO_DIRECTION_OUT: return "out";
+ default: return "invalid";
+ }
+}
+
+static const char *__get_volume_type_string_by_idx (uint32_t vol_type_idx)
+{
+ switch (vol_type_idx) {
+ case AUDIO_VOLUME_TYPE_SYSTEM: return "system";
+ case AUDIO_VOLUME_TYPE_NOTIFICATION: return "notification";
+ case AUDIO_VOLUME_TYPE_ALARM: return "alarm";
+ case AUDIO_VOLUME_TYPE_RINGTONE: return "ringtone";
+ case AUDIO_VOLUME_TYPE_MEDIA: return "media";
+ case AUDIO_VOLUME_TYPE_CALL: return "call";
+ case AUDIO_VOLUME_TYPE_VOIP: return "voip";
+ case AUDIO_VOLUME_TYPE_SVOICE: return "svoice";
+ case AUDIO_VOLUME_TYPE_FIXED: return "fixed";
+ case AUDIO_VOLUME_TYPE_EXT_JAVA: return "java";
+ default: return "invalid";
+ }
+}
+
+static const char *__get_gain_type_string_by_idx (uint32_t gain_type_idx)
+{
+ switch (gain_type_idx) {
+ case AUDIO_GAIN_TYPE_DEFAULT: return "default";
+ case AUDIO_GAIN_TYPE_DIALER: return "dialer";
+ case AUDIO_GAIN_TYPE_TOUCH: return "touch";
+ case AUDIO_GAIN_TYPE_AF: return "af";
+ case AUDIO_GAIN_TYPE_SHUTTER1: return "shutter1";
+ case AUDIO_GAIN_TYPE_SHUTTER2: return "shutter2";
+ case AUDIO_GAIN_TYPE_CAMCODING: return "camcording";
+ case AUDIO_GAIN_TYPE_MIDI: return "midi";
+ case AUDIO_GAIN_TYPE_BOOTING: return "booting";
+ case AUDIO_GAIN_TYPE_VIDEO: return "video";
+ case AUDIO_GAIN_TYPE_TTS: return "tts";
+ default: return "invalid";
+ }
+}
+
+static void __dump_info(char *dump, audio_info_t *info)
+{
+ int len;
+
+ if (info->device.api == AUDIO_DEVICE_API_ALSA) {
+ len = sprintf(dump, "device:alsa(%d.%d)", info->device.alsa.card_idx, info->device.alsa.device_idx);
+ } else if (info->device.api == AUDIO_DEVICE_API_ALSA) {
+ len = sprintf(dump, "device:bluez(%s,nrec:%d)", info->device.bluez.protocol, info->device.bluez.nrec);
+ } else {
+ len = sprintf(dump, "device:unknown");
+ }
+
+ if (len > 0)
+ dump += len;
+
+ len = sprintf(dump, "stream:%s(%dhz,%dch,vol:%s,gain:%s)",
+ info->stream.name ? info->stream.name : "null", info->stream.samplerate, info->stream.channels,
+ __get_volume_type_string_by_idx(info->stream.volume_type), __get_gain_type_string_by_idx(info->stream.gain_type));
+
+ if (len > 0)
+ dump += len;
+
+ *dump = '\0';
+}
+
+#ifdef AUDIO_DEBUG
+static void __dump_tb (audio_mgr_t *am)
+{
+ audio_volume_gain_table_t *volume_gain_table = am->stream.volume_gain_table;
+ uint32_t dev_idx, vol_type_idx, vol_level_idx, gain_type_idx;
+ const char *gain_type_str[] = {
+ "def", /* AUDIO_GAIN_TYPE_DEFAULT */
+ "dial", /* AUDIO_GAIN_TYPE_DIALER */
+ "touch", /* AUDIO_GAIN_TYPE_TOUCH */
+ "af", /* AUDIO_GAIN_TYPE_AF */
+ "shut1", /* AUDIO_GAIN_TYPE_SHUTTER1 */
+ "shut2", /* AUDIO_GAIN_TYPE_SHUTTER2 */
+ "cam", /* AUDIO_GAIN_TYPE_CAMCODING */
+ "midi", /* AUDIO_GAIN_TYPE_MIDI */
+ "boot", /* AUDIO_GAIN_TYPE_BOOTING */
+ "video", /* AUDIO_GAIN_TYPE_VIDEO */
+ "tts", /* AUDIO_GAIN_TYPE_TTS */
+ };
+ char dump_str[AUDIO_DUMP_STR_LEN], *dump_str_ptr;
+
+ /* Dump volume table */
+ AUDIO_LOG_DEBUG("<<<<< volume table >>>>>");
+
+ for (dev_idx = 0; dev_idx < STREAM_DEVICE_MAX; dev_idx++) {
+ const char *dev_str = __get_device_string_by_idx(dev_idx);
+
+ AUDIO_LOG_DEBUG("<< %s >>", dev_str);
+
+ for (vol_type_idx = 0; vol_type_idx < AUDIO_VOLUME_TYPE_MAX; vol_type_idx++) {
+ const char *vol_type_str = __get_volume_type_string_by_idx(vol_type_idx);
+
+ dump_str_ptr = &dump_str[0];
+ memset(dump_str, 0x00, sizeof(char) * sizeof(dump_str));
+ snprintf(dump_str_ptr, 8, "%6s:", vol_type_str);
+ dump_str_ptr += strlen(dump_str_ptr);
+
+ for (vol_level_idx = 0; vol_level_idx < volume_gain_table->volume_level_max[vol_type_idx]; vol_level_idx++) {
+ snprintf(dump_str_ptr, 6, "%01.2f ", volume_gain_table->volume[vol_type_idx][vol_level_idx]);
+ dump_str_ptr += strlen(dump_str_ptr);
+ }
+ AUDIO_LOG_DEBUG("%s", dump_str);
+ }
+ volume_gain_table++;
+ }
+
+ volume_gain_table = am->stream.volume_gain_table;
+
+ /* Dump gain table */
+ AUDIO_LOG_DEBUG("<<<<< gain table >>>>>");
+
+ dump_str_ptr = &dump_str[0];
+ memset(dump_str, 0x00, sizeof(char) * sizeof(dump_str));
+
+ snprintf(dump_str_ptr, 11, "%10s", " ");
+ dump_str_ptr += strlen(dump_str_ptr);
+
+ for (gain_type_idx = 0; gain_type_idx < AUDIO_GAIN_TYPE_MAX; gain_type_idx++) {
+ snprintf(dump_str_ptr, 7, "%5s ", gain_type_str[gain_type_idx]);
+ dump_str_ptr += strlen(dump_str_ptr);
+ }
+ AUDIO_LOG_DEBUG("%s", dump_str);
+
+ for (dev_idx = 0; dev_idx < STREAM_DEVICE_MAX; dev_idx++) {
+ const char *dev_str = __get_device_string_by_idx(dev_idx);
+
+ dump_str_ptr = &dump_str[0];
+ memset(dump_str, 0x00, sizeof(char) * sizeof(dump_str));
+
+ snprintf(dump_str_ptr, 11, "%9s:", dev_str);
+ dump_str_ptr += strlen(dump_str_ptr);
+
+ for (gain_type_idx = 0; gain_type_idx < AUDIO_GAIN_TYPE_MAX; gain_type_idx++) {
+ snprintf(dump_str_ptr, 7, "%01.3f ", volume_gain_table->gain[gain_type_idx]);
+ dump_str_ptr += strlen(dump_str_ptr);
+ }
+ AUDIO_LOG_DEBUG("%s", dump_str);
+
+ volume_gain_table++;
+ }
+}
+#endif
+
+static audio_return_t __load_volume_gain_table_from_ini (audio_mgr_t *am)
+{
+ dictionary * dict = NULL;
+ uint32_t dev_idx, vol_type_idx, vol_level_idx, gain_type_idx;
+ audio_volume_gain_table_t *volume_gain_table = am->stream.volume_gain_table;
+
+ dict = iniparser_load(VOLUME_INI_TEMP_PATH);
+ if (!dict) {
+ AUDIO_LOG_DEBUG("Use csc & default volume&gain ini file");
+ dict = iniparser_load(VOLUME_INI_CSC_PATH);
+ if (!dict) {
+ AUDIO_LOG_DEBUG("Use default volume&gain ini file");
+ dict = iniparser_load(VOLUME_INI_DEFAULT_PATH);
+ if (!dict) {
+ AUDIO_LOG_WARN("Loading volume&gain table from ini file failed");
+ return AUDIO_ERR_UNDEFINED;
+ }
+ }
+ }
+ for (dev_idx = 0; dev_idx < STREAM_DEVICE_MAX; dev_idx++) {
+ const char delimiter[] = ", ";
+ char *key, *list_str, *token, *ptr = NULL;
+ const char *dev_str = __get_device_string_by_idx(dev_idx);
+
+ /* Load volume table */
+ for (vol_type_idx = 0; vol_type_idx < AUDIO_VOLUME_TYPE_MAX; vol_type_idx++) {
+ const char *vol_type_str = __get_volume_type_string_by_idx(vol_type_idx);
+
+ volume_gain_table->volume_level_max[vol_type_idx] = 0;
+
+ key = malloc(strlen(dev_str) + strlen(vol_type_str) + 2);
+ if (key) {
+ sprintf(key, "%s:%s", dev_str, vol_type_str);
+ list_str = iniparser_getstr(dict, key);
+ if (list_str) {
+ token = strtok_r(list_str, delimiter, &ptr);
+ while (token) {
+ /* convert dB volume to linear volume */
+ volume_gain_table->volume[vol_type_idx][volume_gain_table->volume_level_max[vol_type_idx]++] = pow(10.0, (atof(token) - 100) / 20.0);
+ token = strtok_r(NULL, delimiter, &ptr);
+ }
+ } else {
+ audio_volume_gain_table_t *volume_gain_table_spk = &am->stream.volume_gain_table[STREAM_DEVICE_SPEAKER];
+
+ volume_gain_table->volume_level_max[vol_type_idx] = volume_gain_table_spk->volume_level_max[vol_type_idx];
+ memcpy((double *)&volume_gain_table->volume[vol_type_idx][0], (double *)&volume_gain_table_spk->volume[vol_type_idx][0], AUDIO_VOLUME_LEVEL_MAX * sizeof(double));
+ }
+ free(key);
+ }
+ }
+
+ /* Load gain table */
+ volume_gain_table->gain[AUDIO_GAIN_TYPE_DEFAULT] = GAIN_VALUE_MAX;
+ for (gain_type_idx = AUDIO_GAIN_TYPE_DEFAULT + 1; gain_type_idx < AUDIO_GAIN_TYPE_MAX; gain_type_idx++) {
+ const char *gain_type_str = __get_gain_type_string_by_idx(gain_type_idx);
+
+ key = malloc(strlen(dev_str) + strlen("gain") + strlen(gain_type_str) + 3);
+ if (key) {
+ sprintf(key, "%s:gain_%s", dev_str, gain_type_str);
+ token = iniparser_getstr(dict, key);
+ if (token) {
+ volume_gain_table->gain[gain_type_idx] = atof(token);
+ } else {
+ volume_gain_table->gain[gain_type_idx] = GAIN_VALUE_MAX;
+ }
+ free(key);
+ } else {
+ volume_gain_table->gain[gain_type_idx] = GAIN_VALUE_MAX;
+ }
+ }
+ volume_gain_table++;
+ }
+
+ iniparser_freedict(dict);
+#ifdef AUDIO_DEBUG
+ __dump_tb(am);
+#endif
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t _audio_stream_init (audio_mgr_t *am)
+{
+ int i, value;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ for (i = 0; i < AUDIO_VOLUME_TYPE_MAX; i++) {
+ /* Get volume value string from VCONF */
+ if (vconf_get_int(g_volume_vconf[i], &value) != 0) {
+ AUDIO_LOG_ERROR("vconf_get_int(%s) failed", g_volume_vconf[i]);
+ continue;
+ }
+ AUDIO_LOG_INFO("read vconf. %s = %d", g_volume_vconf[i], value);
+
+ am->stream.volume_level[i] = value;
+ }
+
+ if (!(am->stream.volume_gain_table = malloc(STREAM_DEVICE_MAX * sizeof(audio_volume_gain_table_t)))) {
+ AUDIO_LOG_ERROR("volume_gain_table malloc failed");
+ return AUDIO_ERR_RESOURCE;
+ }
+
+ return __load_volume_gain_table_from_ini(am);
+}
+
+audio_return_t _audio_stream_deinit (audio_mgr_t *am)
+{
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ if (am->stream.volume_gain_table) {
+ free(am->stream.volume_gain_table);
+ am->stream.volume_gain_table = NULL;
+ }
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_get_volume_level_max (void *userdata, uint32_t volume_type, uint32_t *level)
+{
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+ audio_volume_gain_table_t *volume_gain_table;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(am->stream.volume_gain_table, AUDIO_ERR_PARAMETER);
+
+ /* Get max volume level by device & type */
+ volume_gain_table = am->stream.volume_gain_table + __get_stream_dev_index(am->device.active_out);
+ *level = volume_gain_table->volume_level_max[volume_type];
+
+ /* temporary fix for SVoice */
+ if (volume_type == AUDIO_VOLUME_TYPE_VOIP) {
+ *level = 7;
+ }
+
+ AUDIO_LOG_DEBUG("get_volume_level_max:%s=>%d", __get_volume_type_string_by_idx(volume_type), *level);
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_get_volume_level (void *userdata, uint32_t volume_type, uint32_t *level)
+{
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ *level = am->stream.volume_level[volume_type];
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_get_volume_value (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t level, double *value)
+{
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+ audio_volume_gain_table_t *volume_gain_table;
+ char dump_str[AUDIO_DUMP_STR_LEN];
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+ AUDIO_RETURN_VAL_IF_FAIL(am->stream.volume_gain_table, AUDIO_ERR_PARAMETER);
+
+ /* Get basic volume by device & type & level */
+ volume_gain_table = am->stream.volume_gain_table + __get_stream_dev_index(am->device.active_out);
+ if (volume_gain_table->volume_level_max[volume_type] < level)
+ *value = VOLUME_VALUE_MAX;
+ else
+ *value = volume_gain_table->volume[volume_type][level];
+ if (info) {
+ __dump_info(&dump_str[0], info);
+
+ *value *= volume_gain_table->gain[info->stream.gain_type];
+
+ AUDIO_LOG_DEBUG("get_volume_value:%d(%s)=>%f %s", level, __get_volume_type_string_by_idx(volume_type), *value, &dump_str[0]);
+ } else {
+ AUDIO_LOG_DEBUG("get_volume_value:%d(%s)=>%f", level, __get_volume_type_string_by_idx(volume_type), *value);
+ }
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_set_volume_level (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t level)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ if (info == NULL) {
+ double volume_linear = 1.0f, volume_db = 0.0f;
+ int volume_value = 0;
+
+ /* Update volume level */
+ am->stream.volume_level[volume_type] = level;
+
+ if ((volume_type == AUDIO_VOLUME_TYPE_CALL && am->session.session == AUDIO_SESSION_VOICECALL)
+ || (volume_type == AUDIO_VOLUME_TYPE_VOIP && am->session.session == AUDIO_SESSION_VOIP)
+ || (volume_type == AUDIO_VOLUME_TYPE_SVOICE && am->session.session == AUDIO_SESSION_VOICE_RECOGNITION)) {
+#if 0 /* NOT NEED set for alsa lib */
+ audio_get_volume_value(userdata, info, volume_type, level, &volume_linear);
+ volume_db = 20.0 * log10(volume_linear);
+
+ /* 0x00~0x2E : min(-96dB) step(0dB)
+ 0x2F~0x43 : min(-36dB) step(1dB)
+ 0x44~0x57 : min(-15.5dB) step(0.5dB)
+ 0x58~0x6F : min(-5.75dB) step(0.25dB) */
+ if (volume_db >= -5.75)
+ volume_value = 0x58 + (volume_db + 5.75) / 0.25;
+ else if (volume_db >= -15.5)
+ volume_value = 0x44 + (volume_db + 15.5) / 0.5;
+ else if (volume_db >= -36)
+ volume_value = 0x2F + (volume_db + 36) / 1;
+
+ audio_ret = _audio_mixer_control_set_value(am, MIXER_SPK_VOLUME, volume_value); */
+#endif
+ AUDIO_LOG_INFO("set_volume_level:%d(%s)", level, __get_volume_type_string_by_idx(volume_type));
+
+ /* cdsp volume range 0~5 */
+ audio_ret = _audio_mixer_control_set_value(am, CDSP_VOLUME, level-1);
+ } else {
+#ifdef AUDIO_DEBUG
+ AUDIO_LOG_DEBUG("skip set_volume_level:%d(%s)", level, __get_volume_type_string_by_idx(volume_type));
+#endif
+ }
+ }
+
+ return audio_ret;
+}
+
+audio_return_t _audio_update_volume_level (audio_mgr_t *am)
+{
+ int i;
+
+ for (i = 0; i < AUDIO_VOLUME_TYPE_MAX; i++) {
+ /* Update vconf */
+ if (vconf_set_int(g_volume_vconf[i], am->stream.volume_level[i]) != 0) {
+ AUDIO_LOG_ERROR("vconf_set_int(%s) failed", g_volume_vconf[i]);
+ continue;
+ }
+ }
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_get_mute (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t direction, uint32_t *mute)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ if (info == NULL) {
+ const char *ctl_name = NULL;
+
+ if (volume_type == AUDIO_VOLUME_TYPE_CALL) {
+ int mute_mic1 = 0, mute_mic2 = 0;
+
+ audio_ret = _audio_mixer_control_get_value(am, MIXER_MIC1_SWITCH, &mute_mic1);
+ if (AUDIO_IS_ERROR(audio_ret))
+ return audio_ret;
+ audio_ret = _audio_mixer_control_get_value(am, MIXER_MIC2_SWITCH, &mute_mic2);
+ *mute = !(mute_mic1 & mute_mic2);
+
+ AUDIO_LOG_INFO("get_mute:%s,%s=>%d(ret:0x%x)", __get_volume_type_string_by_idx(volume_type), __get_direction_string_by_idx(direction), *mute, audio_ret);
+ } else {
+#ifdef AUDIO_DEBUG
+ AUDIO_LOG_DEBUG("skip get_mute:%s,%s=>%d(ret:0x%x)", __get_volume_type_string_by_idx(volume_type), __get_direction_string_by_idx(direction), *mute, audio_ret);
+#endif
+ }
+ }
+
+ return audio_ret;
+}
+
+audio_return_t audio_set_mute (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t direction, uint32_t mute)
+{
+ audio_return_t audio_ret = AUDIO_RET_OK;
+ audio_mgr_t *am = (audio_mgr_t *)userdata;
+
+ AUDIO_RETURN_VAL_IF_FAIL(am, AUDIO_ERR_PARAMETER);
+
+ if (info == NULL) {
+ double volume_linear = 1.0f, volume_db = 0.0f;
+ int volume_value = 0;
+
+ if (volume_type == AUDIO_VOLUME_TYPE_CALL) {
+ AUDIO_LOG_INFO("set_mute:%d(%s,%s)", mute, __get_volume_type_string_by_idx(volume_type), __get_direction_string_by_idx(direction));
+
+ audio_ret = _audio_mixer_control_set_value(am, MIXER_MIC1_SWITCH, (int)!mute);
+ if (AUDIO_IS_ERROR(audio_ret))
+ return audio_ret;
+ audio_ret = _audio_mixer_control_set_value(am, MIXER_MIC2_SWITCH, (int)!mute);
+ }
+ }
+
+ return audio_ret;
+}
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+#include "tizen-audio-internal.h"
+
+audio_return_t _audio_util_init (audio_mgr_t *am)
+{
+ char *card_name = 0;
+ int ret = 0;
+
+ pthread_mutex_init(&am->mixer.mutex, NULL);
+ snd_card_get_name(0, &card_name);
+ if (!card_name)
+ card_name = "default";
+ ret = snd_ctl_open(&am->mixer.mixer, card_name, 0);
+ if (ret < 0 || !am->mixer.mixer) {
+ AUDIO_LOG_ERROR("mixer_open failed");
+ return AUDIO_ERR_RESOURCE;
+ }
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t _audio_util_deinit (audio_mgr_t *am)
+{
+ pthread_mutex_destroy(&am->mixer.mutex);
+ snd_ctl_close(am->mixer.mixer);
+ am->mixer.mixer = NULL;
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t _audio_mixer_control_get_value(audio_mgr_t *am, const char *ctl_name, int *val)
+{
+ audio_return_t ret = AUDIO_RET_USE_HW_CONTROL;
+ snd_ctl_elem_value_t *control;
+ snd_ctl_elem_id_t *id;
+ snd_ctl_elem_info_t *info;
+ snd_ctl_elem_type_t type;
+ int count = 0, i = 0;
+
+ pthread_mutex_lock(&am->mixer.mutex);
+
+ snd_ctl_elem_id_alloca(&id);
+ snd_ctl_elem_info_alloca(&info);
+ snd_ctl_elem_value_alloca(&control);
+
+ snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_id_set_name(id, ctl_name);
+
+ snd_ctl_elem_info_set_id(info, id);
+ if (snd_ctl_elem_info(am->mixer.mixer, info) < 0) {
+ AUDIO_LOG_ERROR("snd_ctl_elem_info %s failed", ctl_name);
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+ snd_ctl_elem_info_get_id(info, id);
+
+ type = snd_ctl_elem_info_get_type(info);
+ count = snd_ctl_elem_info_get_count(info);
+
+ snd_ctl_elem_value_set_id(control, id);
+
+ if(snd_ctl_elem_read(am->mixer.mixer, control) < 0) {
+ AUDIO_LOG_ERROR("snd_ctl_elem_read failed \n");
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+
+ switch (type) {
+ case SND_CTL_ELEM_TYPE_BOOLEAN:
+ *val = snd_ctl_elem_value_get_boolean(control, i);
+ break;
+ case SND_CTL_ELEM_TYPE_INTEGER:
+ for (i = 0; i < count; i++)
+ *val = snd_ctl_elem_value_get_integer(control, i);
+ break;
+ default:
+ AUDIO_LOG_WARN("unsupported control element type\n");
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+
+ AUDIO_LOG_DEBUG("mixer_ctl_get %s=%d success", ctl_name, *val);
+
+exit:
+ pthread_mutex_unlock(&am->mixer.mutex);
+
+ return ret;
+}
+
+audio_return_t _audio_mixer_control_set_value(audio_mgr_t *am, const char *ctl_name, int val)
+{
+ audio_return_t ret = AUDIO_RET_USE_HW_CONTROL;
+ int mixer_ret = -1;
+ snd_ctl_elem_value_t *control;
+ snd_ctl_elem_id_t *id;
+ snd_ctl_elem_info_t *info;
+ snd_ctl_elem_type_t type;
+ int count = 0, i = 0;
+
+ pthread_mutex_lock(&am->mixer.mutex);
+
+ snd_ctl_elem_id_alloca(&id);
+ snd_ctl_elem_info_alloca(&info);
+ snd_ctl_elem_value_alloca(&control);
+
+ snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_id_set_name(id, ctl_name);
+
+ snd_ctl_elem_info_set_id(info, id);
+ if (snd_ctl_elem_info(am->mixer.mixer, info) < 0) {
+ AUDIO_LOG_ERROR("snd_ctl_elem_info %s failed", ctl_name);
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+ snd_ctl_elem_info_get_id(info, id);
+
+ type = snd_ctl_elem_info_get_type(info);
+ count = snd_ctl_elem_info_get_count(info);
+
+ snd_ctl_elem_value_set_id(control, id);
+
+ snd_ctl_elem_read(am->mixer.mixer, control);
+
+ switch (type) {
+ case SND_CTL_ELEM_TYPE_BOOLEAN:
+ for (i = 0; i < count; i++)
+ snd_ctl_elem_value_set_boolean(control, i, val);
+ break;
+ case SND_CTL_ELEM_TYPE_INTEGER:
+ for (i = 0; i < count; i++)
+ snd_ctl_elem_value_set_integer(control, i,val);
+ break;
+ default:
+ AUDIO_LOG_WARN("unsupported control element type\n");
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+
+ if (snd_ctl_elem_write(am->mixer.mixer, control) < 0) {
+ AUDIO_LOG_ERROR("snd_ctl_elem_write failed \n");
+ ret = AUDIO_ERR_IOCTL;
+ goto exit;
+ }
+
+ AUDIO_LOG_DEBUG("set_mixer %s=%d success", ctl_name, val);
+
+exit:
+ pthread_mutex_unlock(&am->mixer.mutex);
+
+ return ret;
+}
--- /dev/null
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "tizen-audio-internal.h"
+
+int audio_get_revision (void)
+{
+ return AUDIO_REVISION;
+}
+
+audio_return_t audio_init (void **userdata)
+{
+ audio_mgr_t *am;
+ audio_return_t ret = AUDIO_RET_OK;
+
+ if (!(am = malloc(sizeof(audio_mgr_t)))) {
+ AUDIO_LOG_ERROR("am malloc failed");
+ return AUDIO_ERR_RESOURCE;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_session_init(am)))) {
+ AUDIO_LOG_ERROR("session init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_device_init(am)))) {
+ AUDIO_LOG_ERROR("device init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_stream_init(am)))) {
+ AUDIO_LOG_ERROR("stream init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_util_init(am)))) {
+ AUDIO_LOG_ERROR("mixer init failed");
+ goto error_exit;
+ }
+
+ *userdata = (void *)am;
+ return AUDIO_RET_OK;
+
+error_exit:
+ if (am)
+ free(am);
+
+ return ret;
+}
+
+audio_return_t audio_deinit (void **userdata)
+{
+ audio_mgr_t *am = (audio_mgr_t *)*userdata;
+
+ if (am) {
+ _audio_session_deinit(am);
+ _audio_device_deinit(am);
+ _audio_stream_deinit(am);
+ _audio_util_deinit(am);
+ free(am);
+ *userdata = NULL;
+ }
+
+ return AUDIO_RET_OK;
+}
+
+audio_return_t audio_reset (void **userdata)
+{
+ audio_mgr_t *am = (audio_mgr_t *)*userdata;
+ audio_return_t ret = AUDIO_RET_OK;
+
+ if (am) {
+ _audio_device_deinit(am);
+ _audio_stream_deinit(am);
+ _audio_util_deinit(am);
+
+ if (AUDIO_IS_ERROR((ret = _audio_session_init(am)))) {
+ AUDIO_LOG_ERROR("session init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_device_init(am)))) {
+ AUDIO_LOG_ERROR("device init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_stream_init(am)))) {
+ AUDIO_LOG_ERROR("stream init failed");
+ goto error_exit;
+ }
+ if (AUDIO_IS_ERROR((ret = _audio_util_init(am)))) {
+ AUDIO_LOG_ERROR("mixer init failed");
+ goto error_exit;
+ }
+ }
+
+ return AUDIO_RET_OK;
+
+error_exit:
+ if (am)
+ free(am);
+ *userdata = NULL;
+
+ return ret;
+}
--- /dev/null
+#ifndef footizenaudiofoo
+#define footizenaudiofoo
+
+/*
+ * audio-hal
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunseok Lee <hs7388.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#define AUDIO_REVISION 1
+
+/* Error code */
+
+#define AUDIO_IS_ERROR(ret) (ret < 0)
+
+typedef enum audio_return {
+ AUDIO_RET_OK = 0,
+ AUDIO_RET_USE_HW_CONTROL = (int32_t)0x40001000,
+ AUDIO_ERR_UNDEFINED = (int32_t)0x80001000,
+ AUDIO_ERR_RESOURCE = (int32_t)0x80001001,
+ AUDIO_ERR_PARAMETER = (int32_t)0x80001002,
+ AUDIO_ERR_IOCTL = (int32_t)0x80001003,
+} audio_return_t ;
+
+
+/* Session */
+typedef enum audio_session {
+ AUDIO_SESSION_MEDIA,
+ AUDIO_SESSION_VOICECALL,
+ AUDIO_SESSION_VIDEOCALL,
+ AUDIO_SESSION_VOIP,
+ AUDIO_SESSION_FMRADIO,
+ AUDIO_SESSION_CAMCORDER,
+ AUDIO_SESSION_NOTIFICATION,
+ AUDIO_SESSION_ALARM,
+ AUDIO_SESSION_EMERGENCY,
+ AUDIO_SESSION_VOICE_RECOGNITION,
+ AUDIO_SESSION_MAX
+} audio_session_t;
+
+/* Sub session */
+typedef enum audio_subsession {
+ AUDIO_SUBSESSION_NONE,
+ AUDIO_SUBSESSION_VOICE,
+ AUDIO_SUBSESSION_RINGTONE,
+ AUDIO_SUBSESSION_MEDIA,
+ AUDIO_SUBSESSION_VR_INIT,
+ AUDIO_SUBSESSION_VR_NORMAL,
+ AUDIO_SUBSESSION_VR_DRIVE,
+ AUDIO_SUBSESSION_STEREO_REC,
+ AUDIO_SUBSESSION_AM_PLAY,
+ AUDIO_SUBSESSION_AM_REC,
+ AUDIO_SUBSESSION_MAX
+} audio_subsession_t;
+
+
+/* Direction */
+typedef enum audio_direction {
+ AUDIO_DIRECTION_NONE,
+ AUDIO_DIRECTION_IN, /**< Capture */
+ AUDIO_DIRECTION_OUT, /**< Playback */
+} audio_direction_t;
+
+
+/* Device */
+
+typedef enum audio_device_in {
+ AUDIO_DEVICE_IN_NONE,
+ AUDIO_DEVICE_IN_MIC, /**< Device builtin mic. */
+ AUDIO_DEVICE_IN_WIRED_ACCESSORY, /**< Wired input devices */
+ AUDIO_DEVICE_IN_BT_SCO, /**< Bluetooth SCO device */
+ AUDIO_DEVICE_IN_MAX,
+} audio_device_in_t;
+
+typedef enum audio_device_out {
+ AUDIO_DEVICE_OUT_NONE,
+ AUDIO_DEVICE_OUT_SPEAKER, /**< Device builtin speaker */
+ AUDIO_DEVICE_OUT_RECEIVER, /**< Device builtin receiver */
+ AUDIO_DEVICE_OUT_WIRED_ACCESSORY, /**< Wired output devices such as headphone, headset, and so on. */
+ AUDIO_DEVICE_OUT_BT_SCO, /**< Bluetooth SCO device */
+ AUDIO_DEVICE_OUT_BT_A2DP, /**< Bluetooth A2DP device */
+ AUDIO_DEVICE_OUT_DOCK, /**< DOCK device */
+ AUDIO_DEVICE_OUT_HDMI, /**< HDMI device */
+ AUDIO_DEVICE_OUT_MIRRORING, /**< MIRRORING device */
+ AUDIO_DEVICE_OUT_USB_AUDIO, /**< USB Audio device */
+ AUDIO_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Multimedia DOCK device */
+ AUDIO_DEVICE_OUT_MAX,
+} audio_device_out_t;
+
+typedef enum audio_route_flag {
+ AUDIO_ROUTE_FLAG_NONE = 0,
+ AUDIO_ROUTE_FLAG_DUAL_OUT = 0x00000001,
+ AUDIO_ROUTE_FLAG_NOISE_REDUCTION = 0x00000002,
+ AUDIO_ROUTE_FLAG_EXTRA_VOL = 0x00000004,
+ AUDIO_ROUTE_FLAG_WB = 0x00000008,
+ AUDIO_ROUTE_FLAG_SVOICE_COMMAND = 0x00010000,
+ AUDIO_ROUTE_FLAG_SVOICE_WAKEUP = 0x00020000,
+} audio_route_flag_t;
+
+typedef enum audio_device_api {
+ AUDIO_DEVICE_API_UNKNOWN,
+ AUDIO_DEVICE_API_ALSA,
+ AUDIO_DEVICE_API_BLUEZ,
+} audio_device_api_t;
+
+typedef struct audio_device_alsa_info {
+ uint32_t card_idx;
+ uint32_t device_idx;
+} audio_device_alsa_info_t;
+
+typedef struct audio_device_bluz_info {
+ char *protocol;
+ uint32_t nrec;
+} audio_device_bluez_info_t;
+
+typedef struct audio_device_info {
+ audio_device_api_t api;
+ union {
+ audio_device_alsa_info_t alsa;
+ audio_device_bluez_info_t bluez;
+ };
+} audio_device_info_t;
+
+
+/* Stream */
+
+typedef enum audio_volume {
+ AUDIO_VOLUME_TYPE_SYSTEM, /**< System volume type */
+ AUDIO_VOLUME_TYPE_NOTIFICATION, /**< Notification volume type */
+ AUDIO_VOLUME_TYPE_ALARM, /**< Alarm volume type */
+ AUDIO_VOLUME_TYPE_RINGTONE, /**< Ringtone volume type */
+ AUDIO_VOLUME_TYPE_MEDIA, /**< Media volume type */
+ AUDIO_VOLUME_TYPE_CALL, /**< Call volume type */
+ AUDIO_VOLUME_TYPE_VOIP, /**< VOIP volume type */
+ AUDIO_VOLUME_TYPE_SVOICE, /**< SVOICE volume type */
+ AUDIO_VOLUME_TYPE_FIXED, /**< Volume type for fixed acoustic level */
+ AUDIO_VOLUME_TYPE_EXT_JAVA, /**< External system volume for Java */
+ AUDIO_VOLUME_TYPE_MAX, /**< Volume type count */
+} audio_volume_t;
+
+typedef enum audio_gain {
+ AUDIO_GAIN_TYPE_DEFAULT,
+ AUDIO_GAIN_TYPE_DIALER,
+ AUDIO_GAIN_TYPE_TOUCH,
+ AUDIO_GAIN_TYPE_AF,
+ AUDIO_GAIN_TYPE_SHUTTER1,
+ AUDIO_GAIN_TYPE_SHUTTER2,
+ AUDIO_GAIN_TYPE_CAMCODING,
+ AUDIO_GAIN_TYPE_MIDI,
+ AUDIO_GAIN_TYPE_BOOTING,
+ AUDIO_GAIN_TYPE_VIDEO,
+ AUDIO_GAIN_TYPE_TTS,
+ AUDIO_GAIN_TYPE_MAX,
+} audio_gain_t;
+
+#if 0 // TODO : need to consider */
+typedef enum audio_volume_format {
+ AUDIO_VOLUME_FORMAT_LINEAR, /**< Linear format (double) */
+ AUDIO_VOLUME_FORMAT_DECIBEL, /**< Decibel format (double) */
+ AUDIO_VOLUME_FORMAT_PA, /**< PulseAudio format (pa_volume_t) */
+} audio_volume_format_t;
+
+typedef struct audio_volume_value {
+ audio_volume_format format;
+ union {
+ double linear;
+ double decibel;
+ uint32_t pa;
+ } value;
+} audio_volume_value_t;
+#endif
+
+typedef struct audio_stream_info {
+ const char *name;
+ uint32_t samplerate;
+ uint8_t channels;
+ uint32_t volume_type;
+ uint32_t gain_type;
+} audio_stream_info_t ;
+
+
+/* Overall */
+
+typedef struct audio_info {
+ audio_device_info_t device;
+ audio_stream_info_t stream;
+} audio_info_t;
+
+int audio_get_revision (void);
+audio_return_t audio_init (void **userdata);
+audio_return_t audio_deinit (void **userdata);
+audio_return_t audio_reset (void **userdata);
+audio_return_t audio_get_volume_level_max (void *userdata, uint32_t volume_type, uint32_t *level);
+audio_return_t audio_get_volume_level (void *userdata, uint32_t volume_type, uint32_t *level);
+audio_return_t audio_get_volume_value (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t level, double *value);
+audio_return_t audio_set_volume_level (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t level);
+audio_return_t audio_get_mute (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t direction, uint32_t *mute);
+audio_return_t audio_set_mute (void *userdata, audio_info_t *info, uint32_t volume_type, uint32_t direction, uint32_t mute);
+audio_return_t audio_set_session (void *userdata, uint32_t session, uint32_t subsession);
+audio_return_t audio_set_route (void *userdata, uint32_t session, uint32_t subsession, uint32_t device_in, uint32_t device_out, uint32_t route_flag);
+audio_return_t audio_set_ecrx_device(void *userdata);
+
+
+#endif