[Armadeus-commitlog] SF.net SVN: armadeus: [616] trunk/buildroot/package
Brought to you by:
sszy
|
From: <ar...@us...> - 2007-08-08 17:10:40
|
Revision: 616
http://armadeus.svn.sourceforge.net/armadeus/?rev=616&view=rev
Author: artemys
Date: 2007-08-08 10:10:41 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
[BUILDROOT] Add quick and dirty way to compile alsa-driver for APF9328
Added Paths:
-----------
trunk/buildroot/package/alsa-driver/
trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-add-tsc2102.patch
trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-rules.patch
trunk/buildroot/package/alsa-driver/alsa-driver.mk
trunk/buildroot/package/alsa-driver/imx-ssi_registers.h
trunk/buildroot/package/alsa-driver/imx-tsc2102.c
trunk/buildroot/package/alsa-driver/imx-tsc2102.h
trunk/buildroot/package/alsa-driver/imx1-ssi.c
trunk/buildroot/package/alsa-driver/imx1-ssi.h
trunk/buildroot/package/alsa-driver/imx1-ssi_types.h
Added: trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-add-tsc2102.patch
===================================================================
--- trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-add-tsc2102.patch (rev 0)
+++ trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-add-tsc2102.patch 2007-08-08 17:10:41 UTC (rev 616)
@@ -0,0 +1,282 @@
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/acinclude.m4 alsa-driver-1.0.14.mod/acinclude.m4
+--- alsa-driver-1.0.14/acinclude.m4 2007-06-04 09:28:55.000000000 +0200
++++ alsa-driver-1.0.14.mod/acinclude.m4 2007-08-06 20:08:44.000000000 +0200
+@@ -186,6 +186,7 @@
+ CONFIG_SND_AOA_SOUNDBUS_I2S=""
+ CONFIG_ARM=""
+ CONFIG_SND_SA11XX_UDA1341=""
++ CONFIG_SND_IMX_TSC2102=""
+ CONFIG_ARCH_SA1100=""
+ CONFIG_L3=""
+ CONFIG_SND_ARMAACI=""
+@@ -1962,6 +1963,18 @@
+ probed=0
+ fi
+ fi
++ if test "$card" = "all" -o "$card" = "imx-tsc"; then
++ if ( test "$CONFIG_SOUND" = "y" -o "$CONFIG_SOUND" = "m" ) &&
++ ( test "$CONFIG_ARM" = "y" -o "$CONFIG_ARM" = "m" ) &&
++ ( test "$CONFIG_ARCH_SA1100" = "y" -o "$CONFIG_ARCH_SA1100" = "m" ); then
++ CONFIG_SND_TIMER="m"
++ CONFIG_SND_PCM="m"
++ CONFIG_SND_IMX_TSC2102="m"
++ probed=1
++ elif test -z "$probed"; then
++ probed=0
++ fi
++ fi
+ if test "$card" = "all" -o "$card" = "armaaci"; then
+ if ( test "$CONFIG_SOUND" = "y" -o "$CONFIG_SOUND" = "m" ) &&
+ ( test "$CONFIG_ARM" = "y" -o "$CONFIG_ARM" = "m" ) &&
+@@ -2928,6 +2941,9 @@
+ if test -n "$CONFIG_SND_SA11XX_UDA1341"; then
+ AC_DEFINE(CONFIG_SND_SA11XX_UDA1341_MODULE)
+ fi
++if test -n "$CONFIG_SND_IMX_TSC2102"; then
++ AC_DEFINE(CONFIG_SND_IMX_TSC2102_MODULE)
++fi
+ if test -n "$CONFIG_SND_ARMAACI"; then
+ AC_DEFINE(CONFIG_SND_ARMAACI_MODULE)
+ fi
+@@ -3306,6 +3322,7 @@
+ AC_SUBST(CONFIG_SND_AOA_SOUNDBUS_I2S)
+ AC_SUBST(CONFIG_ARM)
+ AC_SUBST(CONFIG_SND_SA11XX_UDA1341)
++AC_SUBST(CONFIG_SND_IMX_TSC2102)
+ AC_SUBST(CONFIG_ARCH_SA1100)
+ AC_SUBST(CONFIG_L3)
+ AC_SUBST(CONFIG_SND_ARMAACI)
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/alsa-kernel/arm/Kconfig alsa-driver-1.0.14.mod/alsa-kernel/arm/Kconfig
+--- alsa-driver-1.0.14/alsa-kernel/arm/Kconfig 2007-06-04 09:28:52.000000000 +0200
++++ alsa-driver-1.0.14.mod/alsa-kernel/arm/Kconfig 2007-08-07 11:56:04.000000000 +0200
+@@ -33,4 +33,11 @@
+ Say Y or M if you want to support any AC97 codec attached to
+ the PXA2xx AC97 interface.
+
++config SND_IMX_TSC2102
++ tristate "TSC2102 driver for the i.MXL"
++ depends on ARCH_IMX && SND
++ help
++ Say Y or M if you want to support TSC2102 codec attached to
++ the i.MXL SSI interface.
++
+ endmenu
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/alsa-kernel/arm/Makefile alsa-driver-1.0.14.mod/alsa-kernel/arm/Makefile
+--- alsa-driver-1.0.14/alsa-kernel/arm/Makefile 2007-06-04 09:28:52.000000000 +0200
++++ alsa-driver-1.0.14.mod/alsa-kernel/arm/Makefile 2007-08-08 11:39:22.000000000 +0200
+@@ -12,4 +12,12 @@
+ snd-pxa2xx-pcm-objs := pxa2xx-pcm.o
+
+ obj-$(CONFIG_SND_PXA2XX_AC97) += snd-pxa2xx-ac97.o
++#obj-m += snd-pxa2xx-ac97.o
+ snd-pxa2xx-ac97-objs := pxa2xx-ac97.o
++
++#obj-$(CONFIG_SND_IMX_TSC2102) += snd-imx-tsc.o
++obj-m += snd-imx-tsc.o
++snd-imx-tsc-objs := imx-tsc2102.o
++
++obj-m += snd-imx1-ssi.o
++snd-imx1-ssi-objs := imx1-ssi.o
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/alsa-kernel/Kconfig alsa-driver-1.0.14.mod/alsa-kernel/Kconfig
+--- alsa-driver-1.0.14/alsa-kernel/Kconfig 2007-06-04 09:28:52.000000000 +0200
++++ alsa-driver-1.0.14.mod/alsa-kernel/Kconfig 2007-08-07 11:53:32.000000000 +0200
+@@ -32,7 +32,7 @@
+ Kernel patches and supporting utilities to do that are in the pcsp
+ package, available at <ftp://ftp.infradead.org/pub/pcsp/>.
+
+-source "sound/oss/dmasound/Kconfig"
++#source "sound/oss/dmasound/Kconfig"
+
+ if !M68K
+
+@@ -91,7 +91,7 @@
+ help
+ Say 'Y' or 'M' to enable Open Sound System drivers.
+
+-source "sound/oss/Kconfig"
++#source "sound/oss/Kconfig"
+
+ endmenu
+
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/alsa-kernel/Makefile alsa-driver-1.0.14.mod/alsa-kernel/Makefile
+--- alsa-driver-1.0.14/alsa-kernel/Makefile 2007-06-04 09:28:52.000000000 +0200
++++ alsa-driver-1.0.14.mod/alsa-kernel/Makefile 2007-08-07 12:03:05.000000000 +0200
+@@ -5,7 +5,8 @@
+ obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o
+ obj-$(CONFIG_SOUND_PRIME) += oss/
+ obj-$(CONFIG_DMASOUND) += oss/
+-obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/
++#obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/
++obj-y += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ sparc/ parisc/ pcmcia/ mips/ soc/
+ obj-$(CONFIG_SND_AOA) += aoa/
+
+ # This one must be compilable even if sound is configured out
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/arm/imx1-ssi.c alsa-driver-1.0.14.mod/arm/imx1-ssi.c
+--- alsa-driver-1.0.14/arm/imx1-ssi.c 1970-01-01 01:00:00.000000000 +0100
++++ alsa-driver-1.0.14.mod/arm/imx1-ssi.c 2007-08-07 10:40:54.000000000 +0200
+@@ -0,0 +1,2 @@
++#include "../alsa-kernel/arm/imx1-ssi.c"
++EXPORT_NO_SYMBOLS;
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/arm/imx-tsc2102.c alsa-driver-1.0.14.mod/arm/imx-tsc2102.c
+--- alsa-driver-1.0.14/arm/imx-tsc2102.c 1970-01-01 01:00:00.000000000 +0100
++++ alsa-driver-1.0.14.mod/arm/imx-tsc2102.c 2007-08-07 10:41:25.000000000 +0200
+@@ -0,0 +1,2 @@
++#include "../alsa-kernel/arm/imx-tsc2102.c"
++EXPORT_NO_SYMBOLS;
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/configure alsa-driver-1.0.14.mod/configure
+--- alsa-driver-1.0.14/configure 2007-06-04 09:29:01.000000000 +0200
++++ alsa-driver-1.0.14.mod/configure 2007-08-06 20:11:32.000000000 +0200
+@@ -836,6 +836,7 @@
+ CONFIG_SND_AOA_SOUNDBUS
+ CONFIG_SND_AOA_SOUNDBUS_I2S
+ CONFIG_SND_SA11XX_UDA1341
++CONFIG_SND_IMX_TSC2102
+ CONFIG_SND_ARMAACI
+ CONFIG_ARM_AMBA
+ CONFIG_SND_PXA2XX_PCM
+@@ -4356,6 +4357,7 @@
+ CONFIG_SND_AOA_SOUNDBUS_I2S=""
+ CONFIG_ARM=""
+ CONFIG_SND_SA11XX_UDA1341=""
++ CONFIG_SND_IMX_TSC2102=""
+ CONFIG_ARCH_SA1100=""
+ CONFIG_L3=""
+ CONFIG_SND_ARMAACI=""
+@@ -7343,6 +7345,7 @@
+ CONFIG_ARM=
+ CONFIG_ARCH_SA1100=
+ CONFIG_ARCH_PXA=
++CONFIG_ARCH_IMX=
+ CONFIG_PPC=
+ CONFIG_SPARC32=
+ CONFIG_SPARC64=
+@@ -7360,8 +7363,8 @@
+ KERNDIR=$CONFIG_SND_KERNELDIR
+ fi
+ if test "$cross_compiling" = yes; then
+- { echo "$as_me:$LINENO: result: unknown" >&5
+-echo "${ECHO_T}unknown" >&6; };processor=""
++ { echo "$as_me:$LINENO: result: imx" >&5
++echo "${ECHO_T}unknown" >&6; };processor="imx"
+
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+@@ -7447,6 +7450,8 @@
+ fprintf(file, "sa1100");
+ #elif defined(CONFIG_ARCH_PXA)
+ fprintf(file, "pxa");
++#elif defined(CONFIG_ARCH_IMX)
++ fprintf(file, "imx");
+ #elif defined(CONFIG_ARM_AMBA)
+ fprintf(file, "amba");
+ #elif defined(CONFIG_PARISC)
+@@ -7502,7 +7507,6 @@
+
+
+ CFLAGS="$ac_save_CFLAGS"
+-rm -f processor.id
+ c_opts=""
+ KLD=ld
+ ARCH=
+@@ -7734,6 +7738,14 @@
+ CONFIG_ARCH_PXA=y
+ test "$CONFIG_ISA" = "probe" && CONFIG_ISA=
+ ;;
++ imx)
++ ARCH=arm
++ c_opts="-O2 -mapcs-32 -march=armv4 -msoft-float"
++ CONFIG_ARM=y
++ # CONFIG_L3=y
++ CONFIG_ARCH_IMX=y
++ test "$CONFIG_ISA" = "probe" && CONFIG_ISA=
++ ;;
+ amba)
+ ARCH=arm
+ c_opts="-O2 -mapcs-32 -march=armv4 -Wa,-mxscale -mshort-load-bytes -msoft-float"
+@@ -14464,6 +14476,18 @@
+ probed=0
+ fi
+ fi
++ if test "$card" = "all" -o "$card" = "imx-tsc"; then
++ if ( test "$CONFIG_SOUND" = "y" -o "$CONFIG_SOUND" = "m" ) &&
++ ( test "$CONFIG_ARM" = "y" -o "$CONFIG_ARM" = "m" ) &&
++ ( test "$CONFIG_ARCH_IMX" = "y" -o "$CONFIG_ARCH_IMX" = "m" ); then
++ CONFIG_SND_TIMER="m"
++ CONFIG_SND_PCM="m"
++ CONFIG_SND_IMX_TSC2102="m"
++ probed=1
++ elif test -z "$probed"; then
++ probed=0
++ fi
++ fi
+ if test "$card" = "all" -o "$card" = "armaaci"; then
+ if ( test "$CONFIG_SOUND" = "y" -o "$CONFIG_SOUND" = "m" ) &&
+ ( test "$CONFIG_ARM" = "y" -o "$CONFIG_ARM" = "m" ) &&
+@@ -15889,6 +15913,12 @@
+ _ACEOF
+
+ fi
++if test -n "$CONFIG_SND_IMX_TSC2102"; then
++ cat >>confdefs.h <<\_ACEOF
++#define CONFIG_SND_IMX_TSC2102_MODULE 1
++_ACEOF
++
++fi
+ if test -n "$CONFIG_SND_ARMAACI"; then
+ cat >>confdefs.h <<\_ACEOF
+ #define CONFIG_SND_ARMAACI_MODULE 1
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/configure.in alsa-driver-1.0.14.mod/configure.in
+--- alsa-driver-1.0.14/configure.in 2007-06-04 09:28:51.000000000 +0200
++++ alsa-driver-1.0.14.mod/configure.in 2007-08-06 19:22:43.000000000 +0200
+@@ -918,6 +918,8 @@
+ fprintf(file, "sa1100");
+ #elif defined(CONFIG_ARCH_PXA)
+ fprintf(file, "pxa");
++#elif defined(CONFIG_ARCH_IMX)
++ fprintf(file, "imx");
+ #elif defined(CONFIG_ARM_AMBA)
+ fprintf(file, "amba");
+ #elif defined(CONFIG_PARISC)
+@@ -941,7 +943,6 @@
+ AC_MSG_RESULT(unknown);processor=""
+ )
+ CFLAGS="$ac_save_CFLAGS"
+-rm -f processor.id
+ c_opts=""
+ KLD=ld
+ ARCH=
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/toplevel.config alsa-driver-1.0.14.mod/toplevel.config
+--- alsa-driver-1.0.14/toplevel.config 2007-08-08 18:33:37.000000000 +0200
++++ alsa-driver-1.0.14.mod/toplevel.config 2007-08-07 12:52:01.000000000 +0200
+@@ -182,8 +182,10 @@
+ CONFIG_SND_AOA_TOONIE=
+ CONFIG_SND_AOA_SOUNDBUS=
+ CONFIG_SND_AOA_SOUNDBUS_I2S=
+-CONFIG_ARM=
++CONFIG_ARM=y
++CONFIG_MACH_APF9328=y
+ CONFIG_SND_SA11XX_UDA1341=
++CONFIG_SND_IMX_TSC2102=m
+ CONFIG_ARCH_SA1100=
+ CONFIG_L3=
+ CONFIG_SND_ARMAACI=
+@@ -191,6 +193,7 @@
+ CONFIG_SND_PXA2XX_PCM=
+ CONFIG_SND_PXA2XX_AC97=
+ CONFIG_ARCH_PXA=
++CONFIG_ARCH_IMX=y
+ CONFIG_SND_S3C2410=
+ CONFIG_ARCH_S3C2410=
+ CONFIG_I2C_SENSOR=
+diff -urN -X linux-2.6.18.1/Documentation/dontdiff alsa-driver-1.0.14/toplevel.config.in alsa-driver-1.0.14.mod/toplevel.config.in
+--- alsa-driver-1.0.14/toplevel.config.in 2007-06-04 09:28:55.000000000 +0200
++++ alsa-driver-1.0.14.mod/toplevel.config.in 2007-08-06 20:02:26.000000000 +0200
+@@ -184,6 +184,7 @@
+ CONFIG_SND_AOA_SOUNDBUS_I2S=@CONFIG_SND_AOA_SOUNDBUS_I2S@
+ CONFIG_ARM=@CONFIG_ARM@
+ CONFIG_SND_SA11XX_UDA1341=@CONFIG_SND_SA11XX_UDA1341@
++CONFIG_SND_IMX_TSC2102=@CONFIG_SND_IMX_TSC2102@
+ CONFIG_ARCH_SA1100=@CONFIG_ARCH_SA1100@
+ CONFIG_L3=@CONFIG_L3@
+ CONFIG_SND_ARMAACI=@CONFIG_SND_ARMAACI@
+Binary files alsa-driver-1.0.14/utils/mod-deps and alsa-driver-1.0.14.mod/utils/mod-deps differ
Added: trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-rules.patch
===================================================================
--- trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-rules.patch (rev 0)
+++ trunk/buildroot/package/alsa-driver/alsa-driver-armadeus-rules.patch 2007-08-08 17:10:41 UTC (rev 616)
@@ -0,0 +1,11 @@
+--- alsa-driver-1.0.14/Rules.make 2007-06-04 09:28:51.000000000 +0200
++++ alsa-driver-1.0.14.working/Rules.make 2007-08-01 12:47:03.000000000 +0200
+@@ -158,7 +158,7 @@
+
+ $(ld-multi-used-m) : %.o: $(ld-multi-objs-m)
+ rm -f $@
+- $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs) $(extra-$(basename $@)-objs), $^)
++ arm-linux-ld $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs) $(extra-$(basename $@)-objs), $^)
+
+ #
+ # This make dependencies quickly
Added: trunk/buildroot/package/alsa-driver/alsa-driver.mk
===================================================================
--- trunk/buildroot/package/alsa-driver/alsa-driver.mk (rev 0)
+++ trunk/buildroot/package/alsa-driver/alsa-driver.mk 2007-08-08 17:10:41 UTC (rev 616)
@@ -0,0 +1,83 @@
+#############################################################
+#
+# alsa-driver
+#
+#############################################################
+ALSA_DRIVER_VERSION:=1.0.14
+ALSA_DRIVER_SOURCE:=alsa-driver-$(ALSA_DRIVER_VERSION).tar.bz2
+ALSA_DRIVER_SITE:=ftp://ftp.alsa-project.org/pub/driver
+ALSA_DRIVER_DIR:=$(BUILD_DIR)/alsa-driver-$(ALSA_DRIVER_VERSION)
+ALSA_DRIVER_CAT:=bzcat
+ALSA_DRIVER_BINARY:=libasound.so.2.0.0
+ALSA_DRIVER_TARGET_BINARY:=usr/lib/$(ALSA_DRIVER_BINARY)
+
+$(DL_DIR)/$(ALSA_DRIVER_SOURCE):
+ $(WGET) -P $(DL_DIR) $(ALSA_DRIVER_SITE)/$(ALSA_DRIVER_SOURCE)
+
+$(ALSA_DRIVER_DIR)/.unpacked: $(DL_DIR)/$(ALSA_DRIVER_SOURCE)
+ $(ALSA_DRIVER_CAT) $(DL_DIR)/$(ALSA_DRIVER_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
+ toolchain/patch-kernel.sh $(ALSA_DRIVER_DIR) package/alsa-driver/ alsa-driver-$(ALSA_DRIVER_VERSION)\*.patch*
+ toolchain/patch-kernel.sh $(ALSA_DRIVER_DIR) package/alsa-driver/ alsa-driver-armadeus\*.patch
+ # Copy our custom drivers (until they are integrated in alsa mainline)
+ cp -f package/alsa-driver/imx* $(ALSA_DRIVER_DIR)/alsa-kernel/arm/
+# $(CONFIG_UPDATE) $(ALSA_DRIVER_DIR)
+ touch $@
+
+$(ALSA_DRIVER_DIR)/.configured: $(ALSA_DRIVER_DIR)/.unpacked
+ (cd $(ALSA_DRIVER_DIR); rm -rf config.cache; \
+ $(TARGET_CONFIGURE_ARGS) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ LDFLAGS="$(TARGET_LDFLAGS)" \
+ ./configure \
+ --target=$(GNU_TARGET_NAME) \
+ --host=$(GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --disable-docs \
+ --with-sequencer=yes \
+ --with-isapnp=no \
+ --with-oss=yes \
+ --with-kernel=${BUILD_DIR}/linux-2.6.18.1 \
+ --with-kernel-version=2.6.18.1 \
+ --with-cards=all \
+ );
+ touch $@
+
+$(ALSA_DRIVER_DIR)/modules/snd-imx-tsc.o: $(ALSA_DRIVER_DIR)/.configured
+ (export PATH=${PATH}:${STAGING_DIR}/bin ; \
+ $(MAKE) -C $(ALSA_DRIVER_DIR) \
+ );
+
+# $(STAGING_DIR)/$(ALSA_DRIVER_TARGET_BINARY): $(ALSA_DRIVER_DIR)/src/.libs/$(ALSA_DRIVER_BINARY)
+# $(MAKE) DESTDIR=$(STAGING_DIR) -C $(ALSA_DRIVER_DIR) install
+# $(SED) "s,^libdir=.*,libdir=\'$(STAGING_DIR)/usr/lib\',g" $(STAGING_DIR)/usr/lib/libasound.la
+#
+# $(TARGET_DIR)/$(ALSA_DRIVER_TARGET_BINARY): $(STAGING_DIR)/$(ALSA_DRIVER_TARGET_BINARY)
+# mkdir -p $(TARGET_DIR)/usr/share/alsa
+# mkdir -p $(TARGET_DIR)/usr/lib/alsa-lib
+# cp -dpf $(STAGING_DIR)/lib/libasound.so* $(TARGET_DIR)/usr/lib/
+# cp -rdpf $(STAGING_DIR)/usr/share/alsa/* $(TARGET_DIR)/usr/share/alsa/
+# cp -rdpf $(STAGING_DIR)/usr/lib/alsa-lib/* $(TARGET_DIR)/usr/lib/alsa-lib/
+# -$(STRIP) --strip-unneeded $(TARGET_DIR)/usr/lib/libasound.so*
+# -$(STRIP) --strip-unneeded $(TARGET_DIR)/usr/lib/alsa-lib/*.so
+# touch -c $@
+
+alsa-driver: uclibc linux $(ALSA_DRIVER_DIR)/modules/snd-imx-tsc.o
+
+alsa-driver-clean:
+ rm -f $(TARGET_DIR)/$(ALSA_DRIVER_TARGET_BINARY)
+ -$(MAKE) -C $(ALSA_DRIVER_DIR) clean
+
+alsa-driver-dirclean:
+ rm -rf $(ALSA_DRIVER_DIR)
+
+#############################################################
+#
+# Toplevel Makefile options
+#
+#############################################################
+ifeq ($(strip $(BR2_PACKAGE_ALSA_DRIVER)),y)
+TARGETS+=alsa-driver
+endif
\ No newline at end of file
Added: trunk/buildroot/package/alsa-driver/imx-ssi_registers.h
===================================================================
--- trunk/buildroot/package/alsa-driver/imx-ssi_registers.h (rev 0)
+++ trunk/buildroot/package/alsa-driver/imx-ssi_registers.h 2007-08-08 17:10:41 UTC (rev 616)
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
+*/
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+*/
+
+ /*!
+ * @file ../ssi/registers.h
+ * @brief This header file contains SSI driver low level definition to access module registers.
+ *
+ * @ingroup SSI
+ */
+
+#ifndef __MXC_SSI_REGISTERS_H__
+#define __MXC_SSI_REGISTERS_H__
+
+/*!
+ * This include to define bool type, false and true definitions.
+ */
+#include <asm/hardware.h>
+
+#define SPBA_CPU_SSI 0x07
+
+#define MXC_SSISTX0 0x00
+#define MXC_SSISTX1 0x04
+#define MXC_SSISRX0 0x08
+#define MXC_SSISRX1 0x0C
+#define MXC_SSISCR 0x10
+#define MXC_SSISISR 0x14
+#define MXC_SSISIER 0x18
+#define MXC_SSISTCR 0x1C
+#define MXC_SSISRCR 0x20
+#define MXC_SSISTCCR 0x24
+#define MXC_SSISRCCR 0x28
+#define MXC_SSISFCSR 0x2C
+#define MXC_SSISTR 0x30
+#define MXC_SSISOR 0x34
+#define MXC_SSISACNT 0x38
+#define MXC_SSISACADD 0x3C
+#define MXC_SSISACDAT 0x40
+#define MXC_SSISATAG 0x44
+#define MXC_SSISTMSK 0x48
+#define MXC_SSISRMSK 0x4C
+
+/*! SSI1 registers offset*/
+#define MXC_SSI1STX0 0x00
+#define MXC_SSI1STX1 0x04
+#define MXC_SSI1SRX0 0x08
+#define MXC_SSI1SRX1 0x0C
+#define MXC_SSI1SCR 0x10
+#define MXC_SSI1SISR 0x14
+#define MXC_SSI1SIER 0x18
+#define MXC_SSI1STCR 0x1C
+#define MXC_SSI1SRCR 0x20
+#define MXC_SSI1STCCR 0x24
+#define MXC_SSI1SRCCR 0x28
+#define MXC_SSI1SFCSR 0x2C
+#define MXC_SSI1STR 0x30
+#define MXC_SSI1SOR 0x34
+#define MXC_SSI1SACNT 0x38
+#define MXC_SSI1SACADD 0x3C
+#define MXC_SSI1SACDAT 0x40
+#define MXC_SSI1SATAG 0x44
+#define MXC_SSI1STMSK 0x48
+#define MXC_SSI1SRMSK 0x4C
+
+/*! SSI2 registers offset*/
+#define MXC_SSI2STX0 0x00
+#define MXC_SSI2STX1 0x04
+#define MXC_SSI2SRX0 0x08
+#define MXC_SSI2SRX1 0x0C
+#define MXC_SSI2SCR 0x10
+#define MXC_SSI2SISR 0x14
+#define MXC_SSI2SIER 0x18
+#define MXC_SSI2STCR 0x1C
+#define MXC_SSI2SRCR 0x20
+#define MXC_SSI2STCCR 0x24
+#define MXC_SSI2SRCCR 0x28
+#define MXC_SSI2SFCSR 0x2C
+#define MXC_SSI2STR 0x30
+#define MXC_SSI2SOR 0x34
+#define MXC_SSI2SACNT 0x38
+#define MXC_SSI2SACADD 0x3C
+#define MXC_SSI2SACDAT 0x40
+#define MXC_SSI2SATAG 0x44
+#define MXC_SSI2STMSK 0x48
+#define MXC_SSI2SRMSK 0x4C
+
+/*!
+ * SCR Register bit shift definitions
+ */
+#define SSI_ENABLE_SHIFT 0
+#define SSI_TRANSMIT_ENABLE_SHIFT 1
+#define SSI_RECEIVE_ENABLE_SHIFT 2
+#define SSI_NETWORK_MODE_SHIFT 3
+#define SSI_SYNCHRONOUS_MODE_SHIFT 4
+#define SSI_I2S_MODE_SHIFT 5
+#define SSI_SYSTEM_CLOCK_SHIFT 7
+#define SSI_TWO_CHANNEL_SHIFT 8
+#define SSI_CLOCK_IDLE_SHIFT 9
+
+/*!
+ * STCR & SRCR Registers bit shift definitions
+ */
+#define SSI_EARLY_FRAME_SYNC_SHIFT 0
+#define SSI_FRAME_SYNC_LENGTH_SHIFT 1
+#define SSI_FRAME_SYNC_INVERT_SHIFT 2
+#define SSI_CLOCK_POLARITY_SHIFT 3
+#define SSI_SHIFT_DIRECTION_SHIFT 4
+#define SSI_CLOCK_DIRECTION_SHIFT 5
+#define SSI_FRAME_DIRECTION_SHIFT 6
+#define SSI_FIFO_ENABLE_0_SHIFT 7
+#define SSI_FIFO_ENABLE_1_SHIFT 8
+#define SSI_BIT_0_SHIFT 9
+// For Armadeus i.MXL
+#define SSI_FIFO_ENABLE_SHIFT 7
+
+/*!
+ * STCCR & SRCCR Registers bit shift definitions
+ */
+#define SSI_PRESCALER_MODULUS_SHIFT 0
+#define SSI_FRAME_RATE_DIVIDER_SHIFT 8
+#define SSI_WORD_LENGTH_SHIFT 13
+#define SSI_PRESCALER_RANGE_SHIFT 17
+#define SSI_DIVIDE_BY_TWO_SHIFT 18
+#define SSI_FRAME_DIVIDER_MASK 31
+#define SSI_MIN_FRAME_DIVIDER_RATIO 1
+#define SSI_MAX_FRAME_DIVIDER_RATIO 32
+#define SSI_PRESCALER_MODULUS_MASK 255
+#define SSI_MIN_PRESCALER_MODULUS_RATIO 1
+#define SSI_MAX_PRESCALER_MODULUS_RATIO 256
+#define SSI_WORD_LENGTH_MASK 15
+/*!
+ * SISR Register definition
+ */
+#define SSI_IRQ_STATUS_NUMBER 19
+
+/*!
+ * SFCSR Register bit shift definitions
+ */
+#define SSI_RX_FIFO_1_COUNT_SHIFT 28
+#define SSI_TX_FIFO_1_COUNT_SHIFT 24
+#define SSI_RX_FIFO_1_WATERMARK_SHIFT 20
+#define SSI_TX_FIFO_1_WATERMARK_SHIFT 16
+#define SSI_RX_FIFO_0_COUNT_SHIFT 12
+#define SSI_TX_FIFO_0_COUNT_SHIFT 8
+#define SSI_RX_FIFO_0_WATERMARK_SHIFT 4
+#define SSI_TX_FIFO_0_WATERMARK_SHIFT 0
+#define SSI_MIN_FIFO_WATERMARK 0
+#define SSI_MAX_FIFO_WATERMARK 8
+// For Armadeus i.MXL:
+#define SSI_RX_FIFO_COUNT_SHIFT 28
+#define SSI_TX_FIFO_COUNT_SHIFT 24
+#define SSI_RX_FIFO_WATERMARK_SHIFT 20
+#define SSI_TX_FIFO_WATERMARK_SHIFT 16
+
+
+/*!
+ * SSI Option Register (SOR) bit shift definitions
+ */
+#define SSI_FRAME_SYN_RESET_SHIFT 0
+#define SSI_WAIT_SHIFT 1
+#define SSI_INIT_SHIFT 3
+#define SSI_TRANSMITTER_CLEAR_SHIFT 4
+#define SSI_RECEIVER_CLEAR_SHIFT 5
+#define SSI_CLOCK_OFF_SHIFT 6
+#define SSI_WAIT_STATE_MASK 0x3
+
+/*!
+ * SSI AC97 Control Register (SACNT) bit shift definitions
+ */
+#define AC97_MODE_ENABLE_SHIFT 0
+#define AC97_VARIABLE_OPERATION_SHIFT 1
+#define AC97_TAG_IN_FIFO_SHIFT 2
+#define AC97_READ_COMMAND_SHIFT 3
+#define AC97_WRITE_COMMAND_SHIFT 4
+#define AC97_FRAME_RATE_DIVIDER_SHIFT 5
+#define AC97_FRAME_RATE_MASK 0x3F
+
+/*!
+ * SSI Test Register (STR) bit shift definitions
+ */
+#define SSI_TEST_MODE_SHIFT 15
+#define SSI_RCK2TCK_SHIFT 14
+#define SSI_RFS2TFS_SHIFT 13
+#define SSI_RXSTATE_SHIFT 8
+#define SSI_TXD2RXD_SHIFT 7
+#define SSI_TCK2RCK_SHIFT 6
+#define SSI_TFS2RFS_SHIFT 5
+#define SSI_TXSTATE_SHIFT 0
+
+#endif /* __MXC_SSI_REGISTERS_H__ */
+
Added: trunk/buildroot/package/alsa-driver/imx-tsc2102.c
===================================================================
--- trunk/buildroot/package/alsa-driver/imx-tsc2102.c (rev 0)
+++ trunk/buildroot/package/alsa-driver/imx-tsc2102.c 2007-08-08 17:10:41 UTC (rev 616)
@@ -0,0 +1,3131 @@
+/*
+ * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+ /*!
+ * @defgroup SOUND_DRV MXC Sound Driver for ALSA
+ */
+
+ /*!
+ * @file mxc-alsa-pmic.c
+ * @brief this fle mxc-alsa-pmic.c
+ * @brief this file implements the mxc sound driver interface for ALSA.
+ * The mxc sound driver supports mono/stereo recording (there are
+ * some limitations due to hardware), mono/stereo playback and
+ * audio mixing.
+ * Recording supports 8000 khz and 16000 khz sample rate.
+ * Playback supports 8000, 11025, 16000, 22050, 24000, 32000,
+ * 44100, 48000 Hz for mono and stereo.
+ * This file also handles the software mixer and abstraction APIs
+ * that control the volume,balance,mono-adder,input and output
+ * devices for PMIC.
+ * These mixer controls shall be accessible thru alsa as well as
+ * OSS emulation modes
+ *
+ * @ingroup SOUND_DRV
+ */
+#define DEBUG
+
+#include <sound/driver.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/soundcard.h>
+
+#ifdef CONFIG_PM
+#include <linux/pm.h>
+#endif /* CONFIG_PM */
+
+#include <asm/arch/dma.h>
+/*#include <asm/arch/spba.h>
+#include <asm/arch/clock.h>
+*/
+#include <asm/mach-types.h>
+
+/*#include <ssi/ssi.h>
+#include <ssi/registers.h>
+#include <dam/dam.h>
+#include <asm/arch/pmic_external.h>
+#include <asm/arch/pmic_audio.h>
+*/
+#include "imx-ssi_registers.h"
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/initval.h>
+#include <sound/control.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/imx-dma.h>
+#include "imx1-ssi.h"
+/*#include "mxc-alsa-pmic.h"
+#include "mxc-alsa-common.h"
+*/
+#include <linux/fs.h>
+/*
+ * PMIC driver buffer policy.
+ * Customize here if the sound is not correct
+ */
+#define MAX_BUFFER_SIZE 16384
+#define DMA_BUF_SIZE 8192
+#define MIN_PERIOD_SIZE 64
+#define MIN_PERIOD 2
+#define MAX_PERIOD 255
+
+#define AUD_MUX_CONF 0x0031010
+#define MASK_2_TS 0xfffffffc
+#define MASK_1_TS 0xfffffffe
+#define SOUND_CARD_NAME "MXC"
+
+/*!
+ * These defines enable DMA chaining for playback
+ * and capture respectively.
+ */
+#define MXC_SOUND_PLAYBACK_CHAIN_DMA_EN 1
+#define MXC_SOUND_CAPTURE_CHAIN_DMA_EN 1
+
+/*!
+ * ID for this card
+ */
+static char *id = NULL;
+
+#define MXC_ALSA_MAX_PCM_DEV 1 /*2*/
+#define MXC_ALSA_MAX_PLAYBACK 1 /*2*/
+#define MXC_ALSA_MAX_CAPTURE 1
+
+/*!
+ * This structure is the global configuration of the soundcard
+ * that are accessed by the mixer as well as by the playback/recording
+ * stream. This contains various volume, balance, mono adder settings
+ *
+ */
+typedef struct audio_mixer_control {
+
+ /*!
+ * This variable holds the current active output device(s)
+ */
+ int output_device;
+
+ /*!
+ * This variable holds the current active input device.
+ */
+ int input_device;
+
+ /* Used only for playback/recording on codec .. Use 1 for playback
+ * and 0 for recording*/
+ int direction;
+
+ /*!
+ * This variable holds the current source for active ouput device(s)
+ */
+/* OUTPUT_SOURCE source_for_output[OP_MAXDEV];
+*/
+ /*!
+ * This variable says if a given output device is part of an ongoing
+ * playback. This variable will be set and reset by the playback stream
+ * when stream is activated and when stream is closed. This shall also
+ * be set and reset my mixer functions for enabling/disabling output devs
+ */
+/* int output_active[OP_MAXDEV];
+*/
+ /*!
+ * This variable holds the current volume for active input device.
+ * This maps to the input gain of recording device
+ */
+ int input_volume;
+
+ /*!
+ * This variable holds the current volume for playback devices.
+ */
+ //int output_volume[OP_MAXDEV];
+ int master_volume_out;
+
+ /*!
+ * This variable holds the balance setting for the mixer out.
+ * The range is 0 to 100. 50 means both L and R equal.
+ * < 50 attenuates left side and > 50 attenualtes right side
+ */
+ int mixer_balance;
+
+ /*!
+ * This variable holds the current mono adder config.
+ */
+/* PMIC_AUDIO_MONO_ADDER_MODE mixer_mono_adder;
+*/
+ /*!
+ * Semaphore used to control the access to this structure.
+ */
+ struct semaphore sem;
+
+ /*!
+ * These variables are set by PCM stream and mixer when the voice codec's / ST dac's outputs are
+ * connected to the analog mixer of PMIC audio chip
+ */
+ int codec_out_to_mixer;
+ int stdac_out_to_mixer;
+
+ int codec_playback_active;
+ int codec_capture_active;
+ int stdac_playback_active;
+
+/* PMIC_AUDIO_HANDLE stdac_handle;
+ PMIC_AUDIO_HANDLE voice_codec_handle;
+*/
+} audio_mixer_control_t;
+
+/*!
+ * This structure stores current state of audio configuration
+ * soundcard wrt a specific stream (playback on different DACs, recording on the codec etc).
+ * It is used to set/get current values and are NOT accessed by the Mixer. This structure shall
+ * be retrieved thru pcm substream pointer and hence the mixer component will have no access
+ * to it. There will be as many structures as the number of streams. In our case it's 3. Codec playback
+ * STDAC playback and voice codec recording.
+ * This structure will be used at the beginning of activating a stream to configure audio chip.
+ *
+ */
+typedef struct pmic_audio_device {
+
+/* PMIC_AUDIO_HANDLE handle;
+*/ /*!
+ * This variable holds the sample rate currently being used.
+ */
+ int sample_rate;
+
+ /*!
+ * This variable holds the current protocol PMIC is using.
+ * PMIC can use one of three protocols at any given time:
+ * normal, network and I2S.
+ */
+ int protocol;
+
+ /*!
+ * This variables tells us whether PMIC runs in
+ * master mode (PMIC generates audio clocks)or slave mode (AP side
+ * generates audio clocks)
+ *
+ * Currently the default mode is master mode because PMIC clocks have
+ * higher precision.
+ */
+ int mode;
+
+ /* This variable holds the value representing the
+ * base clock PMIC will use to generate internal
+ * clocks (BCL clock and FrameSync clock)
+ */
+ int pll;
+
+ /*!
+ * This variable holds the SSI to which PMIC is currently connected.
+ */
+ int ssi;
+
+ /*!
+ * This variable tell us whether bit clock is inverted or not.
+ */
+ int bcl_inverted;
+
+ /*!
+ * This variable tell us whether frame clock is inverted or not.
+ */
+ int fs_inverted;
+
+ /*!
+ * This variable holds the pll used for PMIC audio operations.
+ */
+ int pll_rate;
+
+ /*!
+ * This variable holds the filter that PMIC is applying to
+ * CODEC operations.
+ */
+ int codec_filter;
+
+} pmic_audio_device_t;
+
+/*!
+ * This structure represents an audio stream in term of
+ * channel DMA, HW configuration on PMIC and on AudioMux/SSI
+ */
+typedef struct audio_stream {
+ /*!
+ * identification string
+ */
+ char *id;
+
+ /*!
+ * numeric identification
+ */
+ int stream_id;
+
+ /*!
+ * SSI ID on the ARM side
+ */
+ int ssi;
+
+ /*!
+ * DAM port on the ARM side
+ */
+ int dam_port;
+
+ /*!
+ * device identifier for DMA
+ */
+ int dma_wchannel;
+
+ /*!
+ * we are using this stream for transfer now
+ */
+ int active:1;
+
+ /*!
+ * current transfer period
+ */
+ int period;
+
+ /*!
+ * current count of transfered periods
+ */
+ int periods;
+
+ /*!
+ * are we recording - flag used to do DMA trans. for sync
+ */
+ int tx_spin;
+
+ /*!
+ * Previous offset value for resume
+ */
+ unsigned int old_offset;
+#if 0
+ /*!
+ * Path for this stream
+ */
+ device_data_t stream_device;
+#endif
+
+ /*!
+ * pmic audio chip stream specific configuration
+ */
+ pmic_audio_device_t pmic_audio_device;
+
+ /*!
+ * for locking in DMA operations
+ */
+ spinlock_t dma_lock;
+
+ /*!
+ * Alsa substream pointer
+ */
+ struct snd_pcm_substream *stream;
+} audio_stream_t;
+
+/*!
+ * This structure represents the PMIC sound card with its
+ * 2 streams (StDac and Codecs) and its shared parameters
+ */
+typedef struct snd_card_mxc_pmic_audio {
+ /*!
+ * ALSA sound card handle
+ */
+ struct snd_card *card;
+
+ /*!
+ * ALSA pcm driver type handle
+ */
+ struct snd_pcm *pcm[MXC_ALSA_MAX_PCM_DEV];
+
+ /*!
+ * playback & capture streams handle
+ * We can support a maximum of two playback streams (voice-codec
+ * and ST-DAC) and 1 recording stream
+ */
+ audio_stream_t s[MXC_ALSA_MAX_CAPTURE + MXC_ALSA_MAX_PLAYBACK];
+
+} mxc_pmic_audio_t;
+
+/*!
+ * pmic audio chip parameters for IP/OP and volume controls
+ */
+audio_mixer_control_t audio_mixer_control;
+
+/*!
+ * Global variable that represents the PMIC soundcard
+ * with its 2 availables stream devices: stdac and codec
+ */
+mxc_pmic_audio_t *mxc_audio = NULL;
+
+/*!
+ * Supported playback rates array
+ */
+static unsigned int playback_rates_stereo[] = {
+ 8000,
+ 11025,
+ 12000,
+ 16000,
+ 22050,
+ 24000,
+ 32000,
+ 44100,
+ 48000,
+};
+
+/*static unsigned int playback_rates_mono[] = {
+ 8000,
+ 16000,
+};
+*/
+/*!
+ * Supported capture rates array
+ */
+static unsigned int capture_rates[] = {
+ 8000,
+ 16000,
+};
+
+/*!
+ * this structure represents the sample rates supported
+ * by PMIC for playback operations on StDac.
+ */
+static struct snd_pcm_hw_constraint_list hw_playback_rates_stereo = {
+ .count = ARRAY_SIZE(playback_rates_stereo),
+ .list = playback_rates_stereo,
+ .mask = 0,
+};
+
+/*!
+ * this structure represents the sample rates supported
+ * by PMIC for playback operations on Voice codec.
+ */
+/*static snd_pcm_hw_constraint_list_t hw_playback_rates_mono = {
+ .count = ARRAY_SIZE(playback_rates_mono),
+ .list = playback_rates_mono,
+ .mask = 0,
+};
+*/
+/*!
+ * this structure represents the sample rates supported
+ * by PMIC for capture operations on Codec.
+ */
+static struct snd_pcm_hw_constraint_list hw_capture_rates = {
+ .count = ARRAY_SIZE(capture_rates),
+ .list = capture_rates,
+ .mask = 0,
+};
+
+
+/*!
+ * This structure reprensents the capabilities of the driver
+ * in capture mode.
+ * It is used by ALSA framework.
+ */
+static struct snd_pcm_hardware snd_mxc_pmic_capture = {
+ .info = (SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,
+ .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
+ .rate_min = 8000,
+ .rate_max = 16000,
+ .channels_min = 1,
+ .channels_max = 1,
+ .buffer_bytes_max = MAX_BUFFER_SIZE,
+ .period_bytes_min = MIN_PERIOD_SIZE,
+ .period_bytes_max = DMA_BUF_SIZE,
+ .periods_min = MIN_PERIOD,
+ .periods_max = MAX_PERIOD,
+ .fifo_size = 0,
+
+};
+
+/*!
+ * This structure reprensents the capabilities of the driver
+ * in playback mode for ST-Dac.
+ * It is used by ALSA framework.
+ */
+static struct snd_pcm_hardware snd_mxc_pmic_playback_stereo = {
+ .info = (SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,
+ .rates = (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_CONTINUOUS),
+ .rate_min = 8000,
+ .rate_max = 48000,
+ .channels_min = 2,
+ .channels_max = 2,
+ .buffer_bytes_max = MAX_BUFFER_SIZE,
+ .period_bytes_min = MIN_PERIOD_SIZE,
+ .period_bytes_max = DMA_BUF_SIZE,
+ .periods_min = MIN_PERIOD,
+ .periods_max = MAX_PERIOD,
+ .fifo_size = 8,
+
+};
+
+/*!
+ * This structure reprensents the capabilities of the driver
+ * in playback mode for Voice-codec.
+ * It is used by ALSA framework.
+ */
+/*static snd_pcm_hardware_t snd_mxc_pmic_playback_mono = {
+ .info = (SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
+ .formats = SNDRV_PCM_FMTBIT_S16_LE,
+ .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
+ .rate_min = 8000,
+ .rate_max = 16000,
+ .channels_min = 1,
+ .channels_max = 1,
+ .buffer_bytes_max = MAX_BUFFER_SIZE,
+ .period_bytes_min = MIN_PERIOD_SIZE,
+ .period_bytes_max = DMA_BUF_SIZE,
+ .periods_min = MIN_PERIOD,
+ .periods_max = MAX_PERIOD,
+ .fifo_size = 0,
+
+};
+*/
+
+static struct platform_device *device;
+/*!
+ * This function configures audio multiplexer to support
+ * audio data routing in PMIC master mode.
+ *
+ * @param ssi SSI of the ARM to connect to the DAM.
+ */
+void configure_dam_pmic_master(int ssi)
+{
+/* int source_port;
+ int target_port;
+
+ if (ssi == SSI1) {
+ pr_debug("DAM: port 1 -> port 4\n");
+ source_port = port_1;
+ target_port = port_4;
+ } else {
+ pr_debug("DAM: port 2 -> port 5\n");
+ source_port = port_2;
+ target_port = port_5;
+ }
+
+ dam_reset_register(source_port);
+ dam_reset_register(target_port);
+
+ dam_select_mode(source_port, normal_mode);
+ dam_select_mode(target_port, internal_network_mode);
+
+ dam_set_synchronous(source_port, true);
+ dam_set_synchronous(target_port, true);
+
+ dam_select_RxD_source(source_port, target_port);
+ dam_select_RxD_source(target_port, source_port);
+
+ dam_select_TxFS_direction(source_port, signal_out);
+ dam_select_TxFS_source(source_port, false, target_port);
+
+ dam_select_TxClk_direction(source_port, signal_out);
+ dam_select_TxClk_source(source_port, false, target_port);
+
+ dam_select_RxFS_direction(source_port, signal_out);
+ dam_select_RxFS_source(source_port, false, target_port);
+
+ dam_select_RxClk_direction(source_port, signal_out);
+ dam_select_RxClk_source(source_port, false, target_port);
+
+ dam_set_internal_network_mode_mask(target_port, 0xfc);
+
+ writel(AUD_MUX_CONF, IO_ADDRESS(AUDMUX_BASE_ADDR) + 0x38);
+*/
+}
+
+/*!
+ * This function normalizes speed given by the user
+ * if speed is not supported, the function will
+ * calculate the nearest one.
+ *
+ * @param speed speed requested by the user.
+ *
+ * @return The normalized speed.
+ */
+int adapt_speed(int speed)
+{
+
+ /* speeds from 8k to 48k */
+ if (speed >= (44100 + 48000) / 2) {
+ speed = 48000;
+ } else if (speed >= (32000 + 44100) / 2) {
+ speed = 44100;
+ } else if (speed >= (24000 + 32000) / 2) {
+ speed = 32000;
+ } else if (speed >= (22050 + 24000) / 2) {
+ speed = 24000;
+ } else if (speed >= (16000 + 22050) / 2) {
+ speed = 22050;
+ } else if (speed >= (12000 + 16000) / 2) {
+ speed = 16000;
+ } else if (speed >= (11025 + 12000) / 2) {
+ speed = 12000;
+ } else if (speed >= (8000 + 11025) / 2) {
+ speed = 11025;
+ } else {
+ speed = 8000;
+ }
+ return speed;
+}
+
+/*!
+ * This function configures the SSI in order to receive audio
+ * from PMIC (recording). Configuration of SSI consists mainly in
+ * setting the following:
+ *
+ * 1) SSI to use (SSI1 or SSI2)
+ * 2) SSI mode (normal or network. We use always network mode)
+ * 3) SSI STCCR register settings, which control the sample rate (BCL and
+ * FS clocks)
+ * 4) Watermarks for SSI FIFOs as well as timeslots to be used.
+ * 5) Enable SSI.
+ *
+ * @param substream pointer to the structure of the current stream.
+ */
+void configure_ssi_rx(struct snd_pcm_substream * substream)
+{
+ mxc_pmic_audio_t *chip;
+ audio_stream_t *s;
+ int ssi;
+
+ chip = snd_pcm_substream_chip(substream);
+ s = &chip->s[substream->pstr->stream];
+ ssi = s->ssi;
+
+ pr_debug("configure_ssi_rx: SSI %d\n", ssi + 1);
+
+ ssi_enable(ssi, false);
+ ssi_synchronous_mode(ssi, true);
+ ssi_network_mode(ssi, true);
+ ssi_i2s_mode(ssi, i2s_master);
+ ssi_system_clock(ssi, true); /*debug*/
+
+/* if (machine_is_mx27ads()) {
+ ssi_tx_clock_divide_by_two(ssi, 0);
+ ssi_tx_clock_prescaler(ssi, 0);
+ ssi_tx_frame_rate(ssi, 2);
+ }
+*/
+
+ ssi_tx_early_frame_sync(ssi, ssi_frame_sync_one_bit_before);
+ ssi_tx_frame_sync_length(ssi, ssi_frame_sync_one_bit);
+ ssi_tx_word_length(ssi, ssi_16_bits);
+
+ ssi_rx_early_frame_sync(ssi, ssi_frame_sync_one_bit_before);
+ ssi_rx_frame_sync_length(ssi, ssi_frame_sync_one_bit);
+ ssi_rx_fifo_enable(ssi, /*ssi_fifo_0,*/ true);
+ ssi_rx_bit0(ssi, true);
+
+ ssi_rx_fifo_full_watermark(ssi, /*ssi_fifo_0, RX_WATERMARK*/ 6);
+
+ /* We never use the divider by 2 implemented in SSI */
+ /*ssi_rx_clock_divide_by_two(ssi, 0);*/
+
+ /* Set prescaler range (a fixed divide-by-eight prescaler
+ * in series with the variable prescaler) to 0 as we don't
+ * need it.
+ */
+ ssi_rx_clock_prescaler(ssi, 0);
+
+ /* Currently, only supported sample length is 16 bits */
+ ssi_rx_word_length(ssi, ssi_16_bits);
+
+ /* set direction of clocks ("externally" means that clocks come
+ * from PMIC to MCU)
+ */
+ ssi_rx_frame_direction(ssi, ssi_tx_rx_externally);
+ ssi_rx_clock_direction(ssi, ssi_tx_rx_externally);
+
+ /* Frame Rate Divider Control.
+ * In Normal mode, this ratio determines the word
+ * transfer rate. In Network mode, this ration sets
+ * the number of words per frame.
+ */
+ ssi_rx_frame_rate(ssi, 2);
+
+ ssi_enable(ssi, true);
+}
+
+/*!
+ * This function configures the SSI in order to
+ * send data to PMIC. Configuration of SSI consists
+ * mainly in setting the following:
+ *
+ * 1) SSI to use (SSI1 or SSI2)
+ * 2) SSI mode (normal for normal use e.g. playback, network for mixing)
+ * 3) SSI STCCR register settings, which control the sample rate (BCL and
+ * FS clocks)
+ * 4) Watermarks for SSI FIFOs as well as timeslots to be used.
+ * 5) Enable SSI.
+ *
+ * @param substream pointer to the structure of the current stream.
+ */
+void configure_ssi_tx(struct snd_pcm_substream * substream)
+{
+ mxc_pmic_audio_t *chip;
+ audio_stream_t *s;
+ struct snd_pcm_runtime *runtime;
+ int ssi;
+ int device, stream_id = -1;
+ int perclock3;
+ device = substream->pcm->device;
+ if (device == 0)
+ stream_id = 0;
+ else if (device == 1)
+ stream_id = 2;
+
+ chip = snd_pcm_substream_chip(substream);
+ s = &chip->s[stream_id];
+ runtime = substream->runtime;
+ ssi = s->ssi;
+
+ pr_debug("configure_ssi_tx: SSI %d\n", ssi + 1);
+
+ ssi_enable(ssi, false);
+ ssi_synchronous_mode(ssi, true);
+
+/* if (runtime->channels == 1) {
+ ssi_network_mode(ssi, false);
+ } else {
+ ssi_network_mode(ssi, true);
+ }
+*/
+ /* added */
+ ssi_network_mode(ssi, true);
+ ssi_i2s_mode(ssi, i2s_master);
+ ssi_system_clock(ssi, true); /*debug*/
+
+ ssi_tx_early_frame_sync(ssi, ssi_frame_sync_one_bit_before);
+ ssi_tx_frame_sync_length(ssi, ssi_frame_sync_one_bit);
+ ssi_tx_fifo_enable(ssi, /*ssi_fifo_0,*/ true);
+ ssi_tx_bit0(ssi, true);
+
+ ssi_tx_fifo_empty_watermark(ssi, /*ssi_fifo_0, TX_WATERMARK*/ 4);
+
+ /* We never use the divider by 2 implemented in SSI */
+ /*ssi_tx_clock_divide_by_two(ssi, 0);*/
+
+ /*ssi_tx_clock_prescaler(ssi, 0);*/
+
+ /*Currently, only supported sample length is 16 bits */
+ ssi_tx_word_length(ssi, ssi_16_bits);
+
+ /* clocks are being provided by PMIC */
+ ssi_tx_frame_direction(ssi, ssi_tx_rx_externally);
+ ssi_tx_clock_direction(ssi, ssi_tx_rx_externally);
+
+/* if (runtime->channels == 1) {
+ ssi_tx_frame_rate(ssi, 1);
+ } else {
+ ssi_tx_frame_rate(ssi, 2);
+ }
+*/
+ pr_debug("rate: %d\n", runtime->rate);
+ runtime->rate = adapt_speed(runtime->rate);
+ perclock3 = imx_get_perclk3();
+ pr_debug("perclock3: %d rate: %d\n", perclock3, runtime->rate);
+ pr_debug("psr: %d \n", ((perclock3/ runtime->rate)%256));
+ if (0 != ((perclock3/ runtime->rate)%256))
+ {
+ pr_debug("pm: %d \n", ((perclock3/ runtime->rate)/8));
+ ssi_tx_clock_prescaler(ssi, 1);
+ ssi_tx_prescaler_modulus(ssi, ((perclock3/ runtime->rate)/8)-1);
+ }
+ else
+ {
+ pr_debug("pm: %d \n", ((perclock3/ runtime->rate)));
+ ssi_tx_clock_prescaler(ssi, 0);
+ ssi_tx_prescaler_modulus(ssi, (perclock3/ runtime->rate)-1);
+ }
+
+
+ ssi_tx_frame_rate(ssi, 2);
+ ssi_enable(ssi, true);
+}
+
+
+/*!
+ * This function get values to be put in PMIC registers.
+ * This values represents the sample rate that PMIC
+ * should use for current playback or recording.
+ *
+ * @param substream pointer to the structure of the current stream.
+ */
+void normalize_speed_for_pmic(struct snd_pcm_substream * substream)
+{
+ mxc_pmic_audio_t *chip;
+ audio_stream_t *s;
+ pmic_audio_device_t *pmic_device;
+ struct snd_pcm_runtime *runtime;
+ int device, stream_id = -1;
+ device = substream->pcm->device;
+ if (device == 0) {
+ if ((audio_mixer_control.codec_capture_active == 1)
+ && (substream->stream == 1)) {
+ stream_id = 1;
+ } else
+ stream_id = 0;
+ } else {
+ stream_id = 2;
+ }
+
+ chip = snd_pcm_substream_chip(substream);
+ s = &chip->s[stream_id];
+ pmic_device = &s->pmic_audio_device;
+ runtime = substream->runtime;
+
+ /* As the driver allows continuous sample rate, we must adapt the rate */
+ runtime->rate = adapt_speed(runtime->rate);
+
+ /*if (pmic_device->handle == audio_mixer_control.voice_codec_handle) {
+ switch (runtime->rate) {
+ case 8000:
+ pmic_device->sample_rate = VCODEC_RATE_8_KHZ;
+ break;
+ case 16000:
+ pmic_device->sample_rate = VCODEC_RATE_16_KHZ;
+ break;
+ default:
+ pmic_device->sample_rate = VCODEC_RATE_8_KHZ;
+ break;
+ }
+
+ } else if (pmic_device->handle == audio_mixer_control.stdac_handle) {
+ switch (runtime->rate) {
+ case 8000:
+ pmic_device->sample_rate = STDAC_RATE_8_KHZ;
+ break;
+
+ case 11025:
+ pmic_device->sample_rate = STDAC_RATE_11_025_KHZ;
+ break;
+
+ case 16000:
+ pmic_device->sample_rate = STDAC_RATE_16_KHZ;
+ break;
+
+ case 22050:
+ pmic_device->sample_rate = STDAC_RATE_22_050_KHZ;
+ break;
+
+ case 24000:
+ pmic_device->sample_rate = STDAC_RATE_24_KHZ;
+ break;
+
+ case 32000:
+ pmic_device->sample_rate = STDAC_RATE_32_KHZ;
+ break;
+
+ case 44100:
+ pmic_device->sample_rate = STDAC_RATE_44_1_KHZ;
+ break;
+
+ case 48000:
+ pmic_device->sample_rate = STDAC_RATE_48_KHZ;
+ break;
+
+ default:
+ pmic_device->sample_rate = STDAC_RATE_8_KHZ;
+ }
+ }
+*/
+}
+
+/*!
+ * This function configures number of channels for next audio operation
+ * (recording/playback) Number of channels define if sound is stereo
+ * or mono.
+ *
+ * @param substream pointer to the structure of the current stream.
+ *
+ */
+void set_pmic_channels(struct snd_pcm_substream * substream)
+{
+ mxc_pmic_audio_t *chip;
+ audio_stream_t *s;
+ struct snd_pcm_runtime *runtime;
+
+ chip = snd_pcm_substream_chip(substream);
+ s = &chip->s[substream->pstr->stream];
+ runtime = substream->runtime;
+
+/* if (runtime->channels == 2) {
+ ssi_tx_mask_time_slot(s->ssi, MASK_2_TS);
+ ssi_rx_mask_time_slot(s->ssi, MASK_2_TS);
+ } else {
+ ssi_tx_mask_time_slot(s->ssi, MASK_1_TS);
+ ssi_rx_mask_time_slot(s->ssi, MASK_1_TS);
+ }
+*/
+}
+
+/*!
+ * This function sets the input device in PMIC. It takes an
+ * ALSA value and modifies registers using pmic-specific values.
+ *
+ * @param handle Handle to the PMIC device opened
+ * @param val ALSA value. This value defines the input device that
+ * PMIC should activate to get audio signal (recording)
+ * @param enable Whether to enable or diable the input
+ */
+/*int set_mixer_input_device(PMIC_AUDIO_HANDLE handle, INPUT_DEVICES dev,
+ bool enable)
+{
+
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ if (handle != NULL) {
+ if (audio_mixer_control.input_device & SOUND_MASK_PHONEIN) {
+ pmic_audio_vcodec_set_mic(handle, MIC1_LEFT,
+ MIC1_RIGHT_MIC_MONO);
+ pmic_audio_vcodec_enable_micbias(handle, MIC_BIAS1);
+ } else {
+ pmic_audio_vcodec_set_mic_on_off(handle,
+ MIC1_LEFT,
+ MIC1_RIGHT_MIC_MONO);
+ pmic_audio_vcodec_disable_micbias(handle, MIC_BIAS1);
+ }
+ if (audio_mixer_control.input_device & SOUND_MASK_MIC) {
+ pmic_audio_vcodec_set_mic(handle, NO_MIC, MIC2_AUX);
+ pmic_audio_vcodec_enable_micbias(handle, MIC_BIAS2);
+ } else {
+ pmic_audio_vcodec_set_mic_on_off(handle, NO_MIC,
+ MIC2_AUX);
+ pmic_audio_vcodec_disable_micbias(handle, MIC_BIAS2);
+ }
+ if (audio_mixer_control.input_device & SOUND_MASK_LINE) {
+ pmic_audio_vcodec_set_mic(handle, NO_MIC, TXIN_EXT);
+ } else {
+ pmic_audio_vcodec_set_mic_on_off(handle, NO_MIC,
+ TXIN_EXT);
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+
+ }
+ switch (dev) {
+ case IP_HANDSET:
+ pr_debug("Input: SOUND_MASK_PHONEIN \n");
+ if (handle == NULL) {
+ if (enable) {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic(handle,
+ MIC1_LEFT,
+ MIC1_RIGHT_MIC_MONO);
+ pmic_audio_vcodec_enable_micbias(handle,
+ MIC_BIAS1);
+ }
+ audio_mixer_control.input_device |=
+ SOUND_MASK_PHONEIN;
+ } else {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic_on_off(handle,
+ MIC1_LEFT,
+ MIC1_RIGHT_MIC_MONO);
+ pmic_audio_vcodec_disable_micbias
+ (handle, MIC_BIAS1);
+ }
+ audio_mixer_control.input_device &=
+ ~SOUND_MASK_PHONEIN;
+ }
+ }
+ break;
+
+ case IP_HEADSET:
+ if (handle == NULL) {
+ if (enable) {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic(handle,
+ NO_MIC,
+ MIC2_AUX);
+ pmic_audio_vcodec_enable_micbias(handle,
+ MIC_BIAS2);
+ }
+ audio_mixer_control.input_device |=
+ SOUND_MASK_MIC;
+ } else {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic_on_off(handle,
+ NO_MIC,
+ MIC2_AUX);
+ pmic_audio_vcodec_disable_micbias
+ (handle, MIC_BIAS2);
+ }
+ audio_mixer_control.input_device &=
+ ~SOUND_MASK_MIC;
+ }
+ // Enable Mic with MIC2_AUX
+ }
+ break;
+
+ case IP_LINEIN:
+ if (handle == NULL) {
+ if (enable) {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic(handle,
+ NO_MIC,
+ TXIN_EXT);
+ }
+ audio_mixer_control.input_device |=
+ SOUND_MASK_LINE;
+ } else {
+ if (audio_mixer_control.codec_capture_active) {
+ handle =
+ audio_mixer_control.
+ voice_codec_handle;
+ pmic_audio_vcodec_set_mic_on_off(handle,
+ NO_MIC,
+ TXIN_EXT);
+ }
+ audio_mixer_control.input_device &=
+ ~SOUND_MASK_LINE;
+ }
+ }
+ break;
+
+ default:
+ up(&audio_mixer_control.sem);
+ return -1;
+ break;
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+}
+*/
+int get_mixer_input_device(void)
+{
+ int val;
+ val = audio_mixer_control.input_device;
+ return val;
+}
+
+/*!
+ * This function sets the PMIC input device's gain.
+ * Note that the gain is the input volume
+ *
+ * @param handle Handle to the opened PMIC device
+ * @param val gain to be applied. This value can go
+ * from 0 (mute) to 100 (max gain)
+ */
+/*int set_mixer_input_gain(PMIC_AUDIO_HANDLE handle, int val)
+{
+ int leftdb, rightdb;
+ int left, right;
+
+ left = (val & 0x00ff);
+ right = ((val & 0xff00) >> 8);
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ leftdb = (left * PMIC_INPUT_VOLUME_MAX) / INPUT_VOLUME_MAX;
+ rightdb = (right * PMIC_INPUT_VOLUME_MAX) / INPUT_VOLUME_MAX;
+ audio_mixer_control.input_volume = val;
+ if (audio_mixer_control.voice_codec_handle == handle) {
+ pmic_audio_vcodec_set_record_gain(handle, VOLTAGE_TO_VOLTAGE,
+ leftdb, VOLTAGE_TO_VOLTAGE,
+ rightdb);
+ } else if ((handle == NULL)
+ && (audio_mixer_control.codec_capture_active)) {
+ pmic_audio_vcodec_set_record_gain(audio_mixer_control.
+ voice_codec_handle,
+ VOLTAGE_TO_VOLTAGE, leftdb,
+ VOLTAGE_TO_VOLTAGE, rightdb);
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+}
+*/
+int get_mixer_input_gain(void)
+{
+ int val;
+ val = audio_mixer_control.input_volume;
+ return val;
+}
+
+/*!
+ * This function sets the PMIC output device's volume.
+ *
+ * @param handle Handle to the PMIC device opened
+ * @param volume ALSA value. This value defines the playback volume
+ * @param dev which output device gets affected by this volume
+ *
+ */
+
+/*int set_mixer_output_volume(PMIC_AUDIO_HANDLE handle, int volume,
+ OUTPUT_DEVICES dev)
+{
+ int leftdb, rightdb;
+ int right, left;
+
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ left = (volume & 0x00ff);
+ right = ((volume & 0xff00) >> 8);
+
+ leftdb = (left * PMIC_OUTPUT_VOLUME_MAX) / OUTPUT_VOLUME_MAX;
+ rightdb = (right * PMIC_OUTPUT_VOLUME_MAX) / OUTPUT_VOLUME_MAX;
+ if (handle == NULL) {
+*/ /* Invoked by mixer */
+/* audio_mixer_control.master_volume_out = volume;
+ if (audio_mixer_control.codec_playback_active)
+ pmic_audio_output_set_pgaGain(audio_mixer_control.
+ voice_codec_handle,
+ rightdb);
+ if (audio_mixer_control.stdac_playback_active)
+ pmic_audio_output_set_pgaGain(audio_mixer_control.
+ stdac_handle, rightdb);
+
+ } else {
+*/ /* change the required volume */
+/* audio_mixer_control.master_volume_out = volume;
+ pmic_audio_output_set_pgaGain(handle, rightdb);
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+}
+*/
+int get_mixer_output_volume(void)
+{
+ int val;
+ val = audio_mixer_control.master_volume_out;
+ return val;
+}
+
+/*!
+ * This function sets the PMIC output device's balance.
+ *
+ * @param bal Balance to be applied. This value can go
+ * from 0 (Left atten) to 100 (Right atten)
+ * 50 is both equal
+ */
+int set_mixer_output_balance(int bal)
+{
+/* int channel = 0;
+ PMIC_AUDIO_OUTPUT_BALANCE_GAIN b_gain;
+ PMIC_AUDIO_HANDLE handle;
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ // Convert ALSA value to PMIC value i.e. atten and channel value
+ if (bal < 0)
+ bal = 0;
+ if (bal > 100)
+ bal = 100;
+ if (bal < 50) {
+ channel = 1;
+ } else {
+ bal = 100 - bal;
+ channel = 0;
+ }
+
+ b_gain = bal / 8;
+
+ audio_mixer_control.mixer_balance = bal;
+ if (audio_mixer_control.codec_playback_active) {
+ handle = audio_mixer_control.voice_codec_handle;
+ // Use codec's handle to set balance
+ } else if (audio_mixer_control.stdac_playback_active) {
+ handle = audio_mixer_control.stdac_handle;
+ // Use STDac's handle to set balance
+ } else {
+ up(&audio_mixer_control.sem);
+ return 0;
+ }
+ if (channel == 0)
+ pmic_audio_output_set_balance(handle, BAL_GAIN_0DB, b_gain);
+ else
+ pmic_audio_output_set_balance(handle, b_gain, BAL_GAIN_0DB);
+ up(&audio_mixer_control.sem);
+*/ return 0;
+}
+
+int get_mixer_output_balance(void)
+{
+ int val;
+ val = audio_mixer_control.mixer_balance;
+ return val;
+}
+
+/*!
+ * This function sets the PMIC output device's mono adder config.
+ *
+ * @param mode Mono adder mode to be set
+ */
+/*int set_mixer_output_mono_adder(PMIC_AUDIO_MONO_ADDER_MODE mode)
+{
+ PMIC_AUDIO_HANDLE handle;
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ audio_mixer_control.mixer_mono_adder = mode;
+ if (audio_mixer_control.codec_playback_active) {
+ handle = audio_mixer_control.voice_codec_handle;
+ // Use codec's handle to set balance
+ pmic_audio_output_enable_mono_adder(audio_mixer_control.
+ voice_codec_handle, mode);
+ } else if (audio_mixer_control.stdac_playback_active) {
+ handle = audio_mixer_control.stdac_handle;
+ pmic_audio_output_enable_mono_adder(audio_mixer_control.
+ stdac_handle, mode);
+ // Use STDac's handle to set balance
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+}
+*/
+/*int get_mixer_output_mono_adder(void)
+{
+ int val;
+ val = audio_mixer_control.mixer_mono_adder;
+ return val;
+}
+*/
+/*!
+ * This function sets the output device(s) in PMIC. It takes an
+ * ALSA value and modifies registers using PMIC-specific values.
+ *
+ * @param handle handle to the device already opened
+ * @param src Source connected to o/p device
+ * @param dev Output device to be enabled
+ * @param enable Enable or disable the device
+ *
+ */
+/*int set_mixer_output_device(PMIC_AUDIO_HANDLE handle, OUTPUT_SOURCE src,
+ OUTPUT_DEVICES dev, bool enable)
+{
+ PMIC_AUDIO_OUTPUT_PORT port;
+ if (down_interruptible(&audio_mixer_control.sem))
+ return -EINTR;
+ if (!((src == CODEC_DIR_OUT) || (src == MIXER_OUT))) {
+ up(&audio_mixer_control.sem);
+ return -1;
+ }
+ if (handle != (PMIC_AUDIO_HANDLE) NULL) {
+*/ /* Invoked by playback stream */
+/* if (audio_mixer_control.output_device & SOUND_MASK_PHONEOUT) {
+ audio_mixer_control.output_active[OP_EARPIECE] = 1;
+ pmic_audio_output_set_port(handle, MONO_SPEAKER);
+ }
+ if (audio_mixer_control.output_device & SOUND_MASK_SPEAKER) {
+ audio_mixer_control.output_active[OP_HANDSFREE] = 1;
+ pmic_audio_output_set_port(handle, MONO_LOUDSPEAKER);
+ }
+ if (audio_mixer_control.output_device & SOUND_MASK_VOLUME) {
+ audio_mixer_control.output_active[OP_HEADSET] = 1;
+ pmic_audio_output_set_port(handle,
+ STEREO_HEADSET_LEFT |
+ STEREO_HEADSET_RIGHT);
+ }
+ if (audio_mixer_control.output_device & SOUND_MASK_PCM) {
+ audio_mixer_control.output_active[OP_LINEOUT] = 1;
+ pmic_audio_output_set_port(handle,
+ STEREO_OUT_LEFT |
+ STEREO_OUT_RIGHT);
+ }
+ } else {
+ switch (dev) {
+ case OP_EARPIECE:
+ if (enable) {
+ audio_mixer_control.output_device |=
+ SOUND_MASK_PHONEOUT;
+ audio_mixer_control.source_for_output[dev] =
+ src;
+ } else {
+ audio_mixer_control.output_device &=
+ ~SOUND_MASK_PHONEOUT;
+ }
+ port = MONO_SPEAKER;
+ break;
+ case OP_HANDSFREE:
+ if (enable) {
+ audio_mixer_control.output_device |=
+ SOUND_MASK_SPEAKER;
+ audio_mixer_control.source_for_output[dev] =
+ src;
+ } else {
+ audio_mixer_control.output_device &=
+ ~SOUND_MASK_SPEAKER;
+ }
+ port = MONO_LOUDSPEAKER;
+ break;
+ case OP_HEADSET:
+ if (enable) {
+ audio_mixer_control.output_device |=
+ SOUND_MASK_VOLUME;
+ audio_mixer_control.source_for_output[dev] =
+ src;
+ } else {
+ audio_mixer_control.output_device &=
+ ~SOUND_MASK_VOLUME;
+ }
+ port = STEREO_HEADSET_LEFT | STEREO_HEADSET_RIGHT;
+ break;
+ case OP_LINEOUT:
+ if (enable) {
+ audio_mixer_control.output_device |=
+ SOUND_MASK_PCM;
+ audio_mixer_control.source_for_output[dev] =
+ src;
+ } else {
+ audio_mixer_control.output_device &=
+ ~SOUND_MASK_PCM;
+ }
+ port = STEREO_OUT_LEFT | STEREO_OUT_RIGHT;
+ break;
+ default:
+ up(&audio_mixer_control.sem);
+ return -1;
+ break;
+ }
+*/ /* Invoked by mixer .. little tricky to handle over here */
+/* if (audio_mixer_control.codec_playback_active) {
+ if (enable) {
+ audio_mixer_control.output_active[dev] = 1;
+ pmic_audio_output_set_port(audio_mixer_control.
+ voice_codec_handle,
+ port);
+ } else {
+ audio_mixer_control.output_active[dev] = 0;
+ pmic_audio_output_clear_port
+ (audio_mixer_control.voice_codec_handle,
+ port);
+ }
+ }
+ if (audio_mixer_control.stdac_playback_active) {
+ if (enable) {
+ audio_mixer_control.output_active[dev] = 1;
+ pmic_audio_output_set_port(audio_mixer_control.
+ stdac_handle, port);
+ } else {
+ audio_mixer_control.output_active[dev] = 0;
+ pmic_audio_output_clear_port
+ (audio_mixer_control.stdac_handle, port);
+ }
+ }
+
+ }
+ up(&audio_mixer_control.sem);
+ return 0;
+ // Set O/P device with handle and port
+
+}
+*/
+int get_mixer_output_device(void)
+{
+ int val;
+ val = audio_mixer_control.output_device;
+ return val;
+}
+
+/*!
+ * This function configures the CODEC for playback/recording.
+ *
+ * main configured elements are:
+ * - audio path on PMIC
+ * - external clock to generate BC and FS clocks
+ * - PMIC mode (master or slave)
+ * - protocol
+ * - sample rate
+ *
+ * @param substream pointer to the structure of the current stream.
+ * @param stream_id index into the audio_stream array.
+ */
+void configure_codec(struct snd_pcm_substream * substream, int stream_id)
+{
+ mxc_pmic_audio_t *chip;
+ audio_stream_t *s;
+ pmic_audio_device_t *pmic;
+// PMIC_AUDIO_HANDLE handle;
+// int ssi_bus;
+
+ chip = snd_pcm_substream_chip(substream);
+ s = &chip->s[stream_id];
+ pmic = &s->pmic_audio_device;
+/* handle = audio_mixer_control.voice_codec_handle;
+
+ ssi_bus = (pmic->ssi == SSI1) ? AUDIO_DATA_BUS_1 : AUDIO_DATA_BUS_2;
+
+ pmic_audio_output_enable_phantom_ground(handle);
+ pmic_audio_vcodec_set_rxtx_timeslot(handle, USE_TS0);
+ pmic_audio_vcodec_enable_mixer(handle, USE_TS1, VCODEC_NO_MIX,
+ VCODEC_MIX_OUT_0DB);
+ pmic_audio_set_protocol(handle, ssi_bus, pmic->protocol, pmic->mode,
+ USE_4_TIMESLOTS);
+
+ msl...
[truncated message content] |