分享

How do I change the DVSDK4 to DM365EVM board could operate with a built-in speaker (SPK1) and microp

 rookie 2012-06-22

How do I change the DVSDK4 to DM365EVM board could operate with a built-in speaker (SPK1) and microphone(MIC1).

 http://e2e./support/embedded/linux/f/354/t/83687.aspx

A list of related topics:

http://e2e./support/embedded/f/354/t/74345.aspx

http://e2e./support/embedded/f/354/t/68773.aspx (DVSDK is not v4)

http://e2e./support/embedded/f/354/t/7617.aspx (DVSDK is not v4)

http://e2e./support/embedded/f/354/p/56231/226155.aspx (very useful!! Mentioned that DVSDK is v4)

http://e2e./support/embedded/f/354/p/83687/289523.aspx

 

Attention! This article refers to the DVSDK version 4_00_00_22 (Oct 2010).

 

 

DM365EVM has a speaker (SPK1) and microphone (MIC1). However, the latest (at time of this publication) release DVSDK 4_00_00_22 (Oct 2010) only works with an external codec AIC (external inputs and outputs such as Mic, LineOut etc). And inside the DM365 processor we can see builtin audio codec which are connected to SPK1 and MIC1 and we would like to use it. What to do?

 

This article shows the steps of how to change something in DVSDK it to work with SPK1 and MIC1.

 

The first, built-in codec must be supported by the Linux kernel.

There are two projects of the Linux kernel for Davinci.

 

Khilman (at this moment, it uses 2.6.37 kernel)

You can see this via browser with this link.

http://git./?p=linux/kernel/git/khilman/linux-davinci.git;a=summary

Git access.

http://git./pub/scm/linux/kernel/git/khilman/linux-davinci.git

 

Arago (at this moment, it still uses 2.6.32 kernel)

http-view

http:///git/projects/linux-davinci.git?p=projects/linux-davinci.git;a=summary

git-access

http:///git/projects/linux-davinci.git

 

Support for built-in dm365 voice codec appeared in the Khilman kernel since 2.6.35

You can verify this.

Goto http://git./?p=linux/kernel/git/khilman/linux-davinci.git;a=summary

Select TAGS and then v2.6.34-davinci1

Click on 'tree' (http://git./?p=linux/kernel/git/khilman/linux-davinci.git;a=tree;h=fa4a60b8ea7b73821f3bacc8cc8a663c2704b1ea;hb=33bd223cd8f649be74975f9abc52c84f7a2ee8ab

)

Go to 'drivers' catalog, then select 'mfd'.

You can see some files, but 'davinci_voicecodec.c' does not exists.

Go back to the home page and select next TAG v2.6.35-rc1

Go to drivers/mfd via 'tree' and you can see that 'davinci_voicecodec.c' appears.

 

Since DVSDK based on ARAGO kernel 2.6.32, it does not support the built-in dm365 voice codec.

By the way, CQ93VC declared in ALSA 1.23, but the 2.6.32 kernel is ALSA 1.21.

 

There are two ways to resolve the problem.

 

The first, is to download the Khilman kernel (eg 2.6.36-davinci1). Configure it by selecting CQ93VC-codec instead of the AIC (running make menuconfig, selecting drivers, sound cards ..) and compile it in DVSDK4 (need to change Rules.make in DVSDK). And the system is started, the kernel initialization writes that used CQ93VC-codec and the sound system ALSA identified it as a sound card. But personally, I saw that this kernel is not quite compatible with DVSDK. I've had problems with the compilation of such things as CMEM, EDMA and other things needed for the demo applications included in the DVSDK.

 

The second way, is to modify the kernel source ARAGO (2.6.32) that come with DVSDK4. It is necessary that it now supports CQ93VC. It is this version I chose. It seemed to me that this way is more compatible with the existing system in DVSDK.

 

Let's begin our work!

Step 1: Preparation.

 

Baseline data.

The DM365EVM board (i have Rev.E) and DVSDK 4_00_00_22 (Oct 2010).

Installs and configures the DVSDK4 as written in the instructions.

Set the environment variable ${DVSDK}.

Check it, by typing...

host$ echo ${DVSDK}

It should specify the catalog where the DVSDK is installed.

Make sure that the string like 'export DVSDK=(path to DVSDK)' and path to CodeSourcery compiler is recorded in your '.bashrc' file in your home directory.

 

Look at 'psp' catalog in ${DVSDK}. There is a source directory of the Linux kernel.

It is called as 'linux-2.6.32-rc2-psp03.01.00.37'

The contents of this catalog we will change.

Therefore, make a backup of this catalog!

Keep a copy in the same psp-catalog as 'ORIGINAL_linux-2.6.32-rc2-psp03.01.00.37', for example.

 

Just in case, also made a copy of 'targetfs' because we are then in it also make a small change (You must be an root-user to make a copy of targetfs, because this catalog has 'root' as owner.)

 

 

Goto 'linux-devkit' catalog (it appears after the startup 'setup.sh' script to run)

host$ source environment-setup

Make sure that the beginning of a prompt is [linux-devkit].

Check 'EXEC_DIR=' entry (where to install output files) in 'Make.rules'.

Better to change this entry to where the files are installed somewhere in known location in your home catalog. For example '/home/user/davinci/install'.

Clear kernel.

[linux-devkit]> make linux_clean

Build kernel.

[linux-devkit]> make linux

Install kernel

[linux-devkit]> make linux_install

Copy 'uImage' from install catalog to 'tftpboot'. Change U-Boot environment for correct name of uImage. (You can rename image-file as 'uImage-aic' so in the future, you can quickly understand exactly what you want to use this kernel to work with AIC).

First time, I recomended use 'tftpboot' and 'NFS' options for rapid tests.

Reboot.

See kernel log.

---

ALSA device list:

#0: DaVinci EVM (tlv320aic3x)

---

Try examples (especially ./encode и ./decode which are located in /usr/share/ti/dvsdk-demos)

We see that it works with an external AIC codec and audio is recorded and played back via external inputs/outputs (Line-In, Mic-In, Line-Out, Hp-Out). In general it should work.

 

Go to the next step.

Step 2: Obtaining patches.

 

We need to download 5 patches.

 

Goto Khilman site http://git./?p=linux/kernel/git/khilman/linux-davinci.git;a=summary

Select TAGS.

Select v2.6.35-rc1

Click 'tree'.

 

Goto 'drivers/mfd'

Click 'davinci_voicecodec.c'

Click 'history' at top of page.

Find record.

2010-03-12 Miguel Aguilar MFD: DaVinci Voice Codec blob | commitdiff | diff to current

Click 'commitdiff'. Click 'patch' at top of page.

Save it as 'vc-1.patch'.

 

Go back to root catalog, locate the file '/sound/soc/davinci/davinci-vcif.c'

Click 'history'. Find record.

2010-03-12 Miguel Aguilar ASoC: DaVinci: Voice Codec Interface blob | commitdiff | diff to current

Click 'commitdiff'. Click 'patch' at top of page.

Save it as 'vc-2.patch'.

 

Next.

'/sound/soc/codecs/cq93vc.c'.

In a similar manner.

2010-03-12 Miguel Aguilar ASoC: DaVinci: CQ93VC Voice Codec blob | commitdiff | diff to current

Save patch as 'vc-3.patch'.

 

From root catalog, go to 'arch/arm/mach-davinci/dm365.c'

2010-02-04 Miguel Aguilar DaVinci: DM365: Voice codec support for the DM365 SoC blob | commitdiff | diff to current

Save patch as 'vc-4.patch'

 

'arch/arm/mach-davinci/board-dm365-evm.c'

2010-03-12 Miguel Aguilar DaVinci: DM365: Voice Codec support for the DM365 EVM blob | commitdiff | diff to current

Save patch as 'vc-5.patch'

 

Copy all of these five files into '${DVSDK}/psp/linux-2.6.32-rc2-psp03.01.00.37'

 

In the next steps we will need a GIT.

Install 'git' on your host-computer.

 

Go to the next step.

Step 3: Adding MFD-driver.

 

[linux-devkit]> cd ${DVSDK}/psp/linux-2.6.32-rc2-psp03.01.00.37

[linux-devkit]> git apply --check vc-1.patch

error: patch failed: drivers/mfd/Kconfig:53

error: drivers/mfd/Kconfig: patch does not apply

error: patch failed: drivers/mfd/Makefile:12

error: drivers/mfd/Makefile: patch does not apply

 

[linux-devkit]> git apply -v --check vc-1.patch

Will show the details.

 

We will understand how to manually apply a first patch.

Open the file 'vc-1.patch' and study it. This is a plain text file.

It consists of four sections of the 'diff'. And then pointed out which files need to be modified.

Plus sign shows that it is necessary to add, but minus sign is what you want to remove.

It's simple.

 

We make the change manually!

Open the file 'drivers/mfd/Kconfig' in a text editor.

Find the section "config MFD_DM355EVM_MSP"

Before (!) of this section, using the technique of Ctrl-C (copy) and Ctrl-V (paste), copy some strings from patch to file.

 

+config MFD_DAVINCI_VOICECODEC

+ tristate

+ select MFD_CORE

+

 

Remove the leading pluses (!!!) from each line.

As a result, we must add the following text into 'drivers/mfd/Kconfig'.

 

config MFD_ASIC3

bool "Support for Compaq ASIC3"

depends on GENERIC_HARDIRQS && GPIOLIB && ARM

select MFD_CORE

---help---

This driver supports the ASIC3 multifunction chip found on many

PDAs (mainly iPAQ and HTC based ones)

 

config MFD_DAVINCI_VOICECODEC

tristate

select MFD_CORE

 

config MFD_DM355EVM_MSP

bool "DaVinci DM355 EVM microcontroller"

 

 

Save 'drivers/mfd/Kconfig' file.

 

Now, from the file 'vc-1.patch', we need to erase the lines.

 

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig

index 951fa9b..20e3229 100644

--- a/drivers/mfd/Kconfig

+++ b/drivers/mfd/Kconfig

@@ -53,6 +53,10 @@ config MFD_SH_MOBILE_SDHI

This driver supports the SDHI hardware block found in many

SuperH Mobile SoCs.

+config MFD_DAVINCI_VOICECODEC

+ tristate

+ select MFD_CORE

+

config MFD_DM355EVM_MSP

bool "DaVinci DM355 EVM microcontroller"

depends on I2C && MACH_DAVINCI_DM355_EVM

 

That is to erase the entire first section of the 'diff' from the patch (from first 'diff' to the next, but keep the line with the second 'diff').

After removal of the first section, save the file 'vc-1.patch'.

 

So .. one section we have changed manually (I hope you do it carefully !!!!).

We now verify the patch.

 

[linux-devkit]> git apply --check vc-1.patch

error: patch failed: drivers/mfd/Makefile:12

error: drivers/mfd/Makefile: patch does not apply

 

Better already!

 

Again, open the file 'vc-1.patch' and see the following.

 

obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o

obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o

 

+obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o

obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o

 

obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o

 

Open the file 'drivers/mfd/Makefile' in a text editor.

We are looking for in it the string "obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o".

Before this line (see patch) insert

"obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o"

(do not forget to remove the plus char)

 

As a result, we must see...

 

obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o

 

obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o

obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o

 

obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o

 

Save 'drivers/mfd/Makefile'.

 

Remove from the patch file, the second 'diff' section.

Save 'vc-1.patch'.

 

Check again.

[linux-devkit]> git apply --check vc-1.patch

Hooray! Silence! Means no errors. We apply this patch.

 

[linux-devkit]> git apply -v vc-1.patch

Checking patch drivers/mfd/davinci_voicecodec.c...

Checking patch include/linux/mfd/davinci_voicecodec.h...

Applied patch drivers/mfd/davinci_voicecodec.c cleanly.

Applied patch include/linux/mfd/davinci_voicecodec.h cleanly.

 

GOOD!

Congratulations! Go to the next step.

Step 4: Adds support for the codec interface to ALSA.

 

[linux-devkit]> git apply --check vc-2.patch

Silence! Apply the patch.

[linux-devkit]> git apply -v vc-2.patch

Checking patch sound/soc/davinci/Kconfig...

Checking patch sound/soc/davinci/Makefile...

Checking patch sound/soc/davinci/davinci-vcif.c...

Checking patch sound/soc/davinci/davinci-vcif.h...

Applied patch sound/soc/davinci/Kconfig cleanly.

Applied patch sound/soc/davinci/Makefile cleanly.

Applied patch sound/soc/davinci/davinci-vcif.c cleanly.

Applied patch sound/soc/davinci/davinci-vcif.h cleanly.

 

GOOD!

Congratulations! Go to the next step.

Step 5: Adds codec to ALSA.

 

[linux-devkit]> git apply --check vc-3.patch

error: patch failed: sound/soc/codecs/Kconfig:21

error: sound/soc/codecs/Kconfig: patch does not apply

error: patch failed: sound/soc/codecs/Makefile:8

error: sound/soc/codecs/Makefile: patch does not apply

 

Problems mean a change in file 'sound/soc/codecs/Kconfig' and 'sound/soc/codecs/Makefile'.

Let's make the change manually!

Open the file 'sound/soc/codecs/Kconfig' and open the file 'vc-3.patch' in another window.

In the first file, find the line "select SND_SOC_AK4642 if I2C" and between it and the "select SND_SOC_CS4270 if I2C" insert the line marked by plus sign of a patch file ...

Also find the line "# Cirrus Logic CS4270 Codec" and before it put the second batch of patch.

 

As a result, the final Kconfig should now look like this ...

...

select SND_SOC_AK4642 if I2C

select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC

select SND_SOC_CS4270 if I2C

...

config SND_SOC_AK4642

tristate

 

config SND_SOC_CQ0093VC

tristate

 

# Cirrus Logic CS4270 Codec

config SND_SOC_CS4270

tristate

...

 

Save the file 'sound/soc/codecs/Kconfig'.

Delete the first section of the 'diff' from the patch file and save 'vc-3.patch' file.

 

[linux-devkit]> git apply --check vc-3.patch

error: patch failed: sound/soc/codecs/Makefile:8

error: sound/soc/codecs/Makefile: patch does not apply

 

Better already!

Only a little bit!

 

Open the 'our' patch 'vc-3.patch' in one window and 'sound/soc/codecs/Makefile' in another window.

Find in the Makefile line 'snd-soc-ak4642-objs: = ak4642.o' and after it insert that stated plus sign in the patch.

As a result, in the Makefile should be ...

 

snd-soc-ak4642-objs := ak4642.o

snd-soc-cq93vc-objs := cq93vc.o

snd-soc-cs4270-objs := cs4270.o

 

More ... Find and insert ...

 

obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o

obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o

obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.

 

Save Makefile.

Erase this section of the 'diff' from the patch and save 'vc-3.patch' file.

 

Check.

[linux-devkit]> git apply - check vc-3.patch

Silence! That means the rest is applicable to the patch!

 

Apply the patch.

[linux-devkit]> git apply -v vc-3.patch

Checking patch sound/soc/codecs/cq93vc.c...

Checking patch sound/soc/codecs/cq93vc.h...

Applied patch sound/soc/codecs/cq93vc.c cleanly.

Applied patch sound/soc/codecs/cq93vc.h cleanly.

 

Excellent! We applied all three patches.

We go to the next step.

Step 6: Fix something in the Kconfig-files and check it through 'make menuconfig'.

 

In the first step, we rebuild a new kernel. Please note that there was an message 'configuration saved to .config'.

If unsure, rebuild the kernel again (type 'make linux' from DVSDK home but not from linux kernel catalog).

If you're really not sure, rebuild the kernel again with the cleaning ('make linux_clean' then 'make linux' from DVSDK home).

The previous configuration with the AIC-codec was written in the '.config' file (hidden file).

Go to linux kernel catalog again.

Copy '.config' as 'config_aic'.

 

[linux-devkit]> make menuconfig

 

Device Drivers --->

Multifunction device drivers --->

 

There's no matter what we need with respect to voice codec (((

 

Device Drivers --->

<*> Sound card support --->

<*> Advanced Linux Sound Architecture --->

<*> ALSA for SoC audio support --->

 

And then there is no matter what you need.

 

Correct the problem.
Exit from configure the kernel.

Open for editing 'drivers/mfd/Kconfig'.
Find the section

 

config MFD_DAVINCI_VOICECODEC

tristate

select MFD_CORE

 

And type something in quotes after 'tristate'.

For example.

 

config MFD_DAVINCI_VOICECODEC

tristate "MFD_DAVINCI_VOICECODEC"

select MFD_CORE

 

Save file.

 

Open for editing 'sound/soc/davinci/Kconfig'

 

Search...

 

config SND_DAVINCI_SOC_VCIF

tristate

 

Replace with...

 

config SND_DAVINCI_SOC_VCIF

tristate "SND_DAVINCI_SOC_VCIF"

 

Save file.

 

Open 'sound/soc/codecs/Kconfig'

 

Search...

 

config SND_SOC_CQ0093VC

tristate

 

Replace with...

 

config SND_SOC_CQ0093VC

tristate "SND_SOC_CQ0093VC"

 

Save file.

 

Check it!

[linux-devkit]> make menuconfig

 

Device Drivers --->

Multifunction device drivers --->

< > Support for Silicon Motion SM501

[ ] Support for Compaq ASIC3

< > MFD_DAVINCI_VOICECODEC (NEW)

[ ] HTC EGPIO support

 

Device Drivers --->

<*> Sound card support --->

<*> Advanced Linux Sound Architecture --->

<*> ALSA for SoC audio support --->

--- ALSA for SoC audio support

<*> SoC Audio for the TI DAVINCI chip

< > SND_DAVINCI_SOC_VCIF (NEW)

<*> SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM

< > Build all ASoC CODEC drivers

< > SND_SOC_CQ0093VC (NEW)

 

Good!

While nothing and never save. Go to the next step.

Step 7: Adds voice codec support to dm365.

 

[linux-devkit]> git apply --check vc-4.patch

error: patch failed: arch/arm/mach-davinci/include/mach/dm365.h:32

error: arch/arm/mach-davinci/include/mach/dm365.h: patch does not apply

 

Open 'arch/arm/mach-davinci/include/mach/dm365.h' and 'vc-4.patch'. Copy 'defines' and 'dm365_init_vc' function prototype to 'dm365.h' file and save it. Remove this 'diff' section (which refer to the dm365.h) from patch and save 'vc-4.patch'.

 

[linux-devkit]> git apply --check vc-4.patch

Silence is here!

Apply patch.

 

[linux-devkit]> git apply -v vc-4.patch

Checking patch arch/arm/mach-davinci/dm365.c...

Checking patch arch/arm/mach-davinci/include/mach/mux.h...

Applied patch arch/arm/mach-davinci/dm365.c cleanly.

Applied patch arch/arm/mach-davinci/include/mach/mux.h cleanly.

 

Good! Go to next step.

Step 8: Adds voice codec support for DM365EVM board.

 

[linux-devkit]> git apply -v --check vc-5.patch

Checking patch arch/arm/mach-davinci/board-dm365-evm.c...

Checking patch sound/soc/davinci/Kconfig...

Checking patch sound/soc/davinci/davinci-evm.c...

 

Good! Apply the patch.

 

[linux-devkit]> git apply -v vc-5.patch

Checking patch arch/arm/mach-davinci/board-dm365-evm.c...

Checking patch sound/soc/davinci/Kconfig...

Checking patch sound/soc/davinci/davinci-evm.c...

Applied patch arch/arm/mach-davinci/board-dm365-evm.c cleanly.

Applied patch sound/soc/davinci/Kconfig cleanly.

Applied patch sound/soc/davinci/davinci-evm.c cleanly.

 

There is one thing that I did not like.

 

Open 'sound/soc/davinci/Kconfig'. Look here.

 

config SND_DAVINCI_SOC_EVM

tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"

depends on SND_DAVINCI_SOC

depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM

select SND_DAVINCI_SOC_I2S

select SND_SOC_TLV320AIC3X

 

If you choose the codec "in general", it automatically selects the AIC codec (I2S & AIC)

I personally did not like it. I want to select OR aic-codec OR voice-codec. One of the two.

Still, I think that there is hardly any need to work simultaneously with two sound devices. Usually only one is needed. Also will be less problems. We solve this simple.

Cut these two lines from 'MACH_DAVINCI_DM365_EVM ' section and paste these to 'SND_DM365_AIC3X_CODEC' section.

I noted that you need to cut by a minus sign. What you want to insert, I noticed a plus sign.

 

config SND_DAVINCI_SOC_EVM

tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"

depends on SND_DAVINCI_SOC

depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM

- select SND_DAVINCI_SOC_I2S

- select SND_SOC_TLV320AIC3X

help

Say Y if you want to add support for SoC audio on TI

DaVinci DM6446, DM355 or DM365 EVM platforms.

 

choice

prompt "DM365 codec select"

depends on SND_DAVINCI_SOC_EVM

depends on MACH_DAVINCI_DM365_EVM

default SND_DM365_EXTERNAL_CODEC

 

config SND_DM365_AIC3X_CODEC

bool "Audio Codec - AIC3101"

+ select SND_DAVINCI_SOC_I2S

+ select SND_SOC_TLV320AIC3X

help

Say Y if you want to add support for AIC3101 audio codec

 

config SND_DM365_VOICE_CODEC

bool "Voice Codec - CQ93VC"

select MFD_DAVINCI_VOICECODEC

select SND_DAVINCI_SOC_VCIF

select SND_SOC_CQ0093VC

help

Say Y if you want to add support for SoC On-chip voice codec

endchoice

 

Save Kconfig.

Test it.

 

[linux-devkit]> make menuconfig

 

Select the Voice Codec via 'DM365 codec select'.

 

Device Drivers --->

<*> Sound card support --->

<*> Advanced Linux Sound Architecture --->

<*> ALSA for SoC audio support --->

--- ALSA for SoC audio support

<*> SoC Audio for the TI DAVINCI chip

-*- SND_DAVINCI_SOC_VCIF

<*> SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM

DM365 codec select (Voice Codec - CQ93VC) --->

< > Build all ASoC CODEC drivers

-*- SND_SOC_CQ0093VC

 

Make sure that automatically include options 'SND_DAVINCI_SOC_VCIF' and 'SND_SOC_CQ0093VC'.

 

Device Drivers --->

Multifunction device drivers --->

< > Support for Silicon Motion SM501

[ ] Support for Compaq ASIC3

-*- MFD_DAVINCI_VOICECODEC

[ ] HTC EGPIO support

 

Also, you can see that 'MFD_DAVINCI_VOICECODEC' is enabled.

 

Now, select AIC codec via 'DM365 codec select'.

 

Device Drivers --->

<*> Sound card support --->

<*> Advanced Linux Sound Architecture --->

<*> ALSA for SoC audio support --->

--- ALSA for SoC audio support

<*> SoC Audio for the TI DAVINCI chip

< > SND_DAVINCI_SOC_VCIF (NEW)

<*> SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM

DM365 codec select (Audio Codec - AIC3101) --->

< > Build all ASoC CODEC drivers

< > SND_SOC_CQ0093VC (NEW)

 

You will see that the options 'SND_DAVINCI_SOC_VCIF' and 'SND_SOC_CQ0093VC' are disabled in this section.

And 'MFD_DAVINCI_VOICECODEC' is disabled in 'Device Drivers / Multifunction device drivers' section.

 

Select AIC-codec, goto main menu and Save configuration as alternative filename as 'config_aic'.

 

Select VOICE-codec, goto main menu and Save configuration as alternative filename as 'config_vc'.

 

Remember, we are writing a description after 'tristate' keyword in Kconfig-files?

Now that we have tested, these descriptions can be erased, that these items do not appear in the menu and not paying the confusion. But you can leave everything as is.

 

Exit from configurator.

Compare 'config_aic' and 'config_vc' files using special software (like 'Meld').

 

In 'config_aic':

# CONFIG_MFD_CORE is not set

# CONFIG_MFD_DAVINCI_VOICECODEC is not set

CONFIG_SND_DAVINCI_SOC_I2S=y

# CONFIG_SND_DAVINCI_SOC_VCIF is not set

CONFIG_SND_DM365_AIC3X_CODEC=y

# CONFIG_SND_DM365_VOICE_CODEC is not set

# CONFIG_SND_SOC_CQ0093VC is not set

CONFIG_SND_SOC_TLV320AIC3X=y

 

In 'config_vc':

CONFIG_MFD_CORE=y

CONFIG_MFD_DAVINCI_VOICECODEC=y

CONFIG_SND_DAVINCI_SOC_VCIF=y

# CONFIG_SND_DM365_AIC3X_CODEC is not set

CONFIG_SND_DM365_VOICE_CODEC=y

CONFIG_SND_SOC_CQ0093VC=y

Step 9: First build. Problem with 'no soundcard'.

 

Goto 'arch/arm/configs'.

Rename 'davinci_dm365_defconfig' to 'davinci_dm365_defconfig_ORIGINAL'.

Return back to linux main catalog.

Copy 'config_vc' as 'davinci_dm365_defconfig'.

Move this file to 'arch/arm/configs'.

File 'arch/arm/configs/davinci_dm365_defconfig' must match 'config_vc'. You can also make a symbolic link if you wish.

 

Go to DVSDK home.

[linux-devkit]> cd ${DVSDK}

Build kernel without clean.

[linux-devkit]> make linux

Install

[linux-devkit]> make linux_install

Copy uImage to 'tftpboot'.

Reboot board.

Look at the kernel messages.

 

Advanced Linux Sound Architecture Driver Version 1.0.21.

asoc: CQ93VC <-> davinci-vcif mapping ok

ALSA device list:

No soundcards found.

 

Oops!

And where is our sound card?

 

Let's fix this.

Step 10: 'No souncards found' FIX.

 

Open 'sound/soc/codecs/cq93vc.c' in one window and 'tlv320aic3x.c' in other window.

Find 'cq93vc_probe' and 'aic3x_probe' functions. Compare both.

What do you see?

Right!

'aic3x_probe' has the 'snd_soc_init_card' call, but 'cq93vc_probe' has not.

Copy this 'snd_soc_init_card' call from aic probe to cq93vc probe.

I have put some debug messages.

And yet something, something that I liked in the text of aic probe.

As a result, I have the text of this function looks like this.

 

static int cq93vc_probe(struct platform_device *pdev)

{

printk(KERN_INFO "**********MY MESSAGE********** cq93vc_probe\n");

struct snd_soc_device *socdev = platform_get_drvdata(pdev);

struct device *dev = &pdev->dev;

struct snd_soc_codec *codec;

int ret;

 

socdev->card->codec = cq93vc_codec;

codec = socdev->card->codec;

 

/* Register pcms */

ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);

printk(KERN_INFO "**********MY MESSAGE********** ret = snd_soc_new_pcms = %i\n",ret);

if (ret < 0) {

printk(KERN_INFO "**********MY MESSAGE********** ERROR!! \n");

dev_err(dev, "%s: failed to create pcms\n", pdev->name);

// return ret;

goto pcm_err;

}

 

/* Set controls */

snd_soc_add_controls(codec, cq93vc_snd_controls,

ARRAY_SIZE(cq93vc_snd_controls));

 

/* Off, with power on */

cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

 

ret = snd_soc_init_card(socdev);

printk(KERN_INFO "**********MY MESSAGE********** ret = snd_soc_init_card = %i\n",ret);

if (ret < 0) {

printk(KERN_ERR "cq93vc: failed to register card\n");

goto card_err;

}

 

// return 0;

return ret;

 

card_err:

snd_soc_free_pcms(socdev);

snd_soc_dapm_free(socdev);

 

pcm_err:

kfree(codec->reg_cache);

return ret;

}

 

Save 'cq93vc.c' file.

 

Go to DVSDK home.

[linux-devkit]> cd ${DVSDK}

Build kernel without clean.

[linux-devkit]> make linux

Install

[linux-devkit]> make linux_install

Copy uImage to 'tftpboot'.

Reboot board.

Look at the kernel messages.

 

Advanced Linux Sound Architecture Driver Version 1.0.21.

**********MY MESSAGE********** cq93vc_probe

asoc: CQ93VC <-> davinci-vcif mapping ok

**********MY MESSAGE********** ret = snd_soc_new_pcms = 0

**********MY MESSAGE********** ret = snd_soc_init_card = 0

ALSA device list:

#0: DaVinci DM365 EVM (CQ93VC)

 

Good! The soundcard is detected.

Step 11: A bit of magic with targetfs.

 

Once the kernel initialized, we can see the following message from targetfs.

 

Unknown hardware: "CQ93VC" "" "" "" ""

Hardware is initialized using a guess method

/usr/share/alsa/init/default:53: control element not found

/usr/share/alsa/init/default:53: control element not found

/usr/sbin/alsactl: set_control:1256: failed to obtain info for control #1 (No such file or directory)

..

/usr/sbin/alsactl: set_control:1256: failed to obtain info for control #82 (No such file or directory)

 

If you're very careful, you might notice that there are no such warnings for #10 and #26.

 

This will return a bit later, but for now let's see /dev and /proc.

 

root@dm365-evm:~# ls -p /dev/snd

controlC0 pcmC0D0c pcmC0D0p timer

 

root@dm365-evm:~# mkdir /home/root/viewproc

root@dm365-evm:~# cp -R /proc/asound/* /home/root/viewproc

 

You can see the contents of /proc/asound through NSF going into the directory /home/root/viewproc.

Because you can not look at the /proc directly through the NSF.

Catalog 'EVM' there is a link to the catalog 'card0'.

Examine the contents.

 

Get more info about soundcard.

 

root@dm365-evm:~# amixer -h

root@dm365-evm:~# amixer scontrols

Simple mixer control 'Mono DAC',0

Simple mixer control 'PGA',0

root@dm365-evm:~# amixer scontents

Simple mixer control 'Mono DAC',0

Capabilities: pvolume pvolume-joined penum

Playback channels: Mono

Limits: Playback 0 - 63

Mono: Playback 54 [86%]

Simple mixer control 'PGA',0

Capabilities: cvolume cvolume-joined penum

Capture channels: Mono

Limits: Capture 0 - 3

Mono: Capture 0 [0%]

 

Open and view contents of '/etc/asound.state'.

You see the 82 controls. This is too much for voice codec which has only 2.

Have a look at the control with the numbers 10 and 26. That they are in our codec.

 

Remove 'asound.state '

root@dm365-evm:~# rm /etc/asound.state

 

root@dm365-evm:~# alsactl -h

root@dm365-evm:~# alsactl store EVM

Open and view contents of '/etc/asound.state'.

You can see only 2 controls.

Reboot.

When initializing a targetfs no more warnings about the controls.

 

Try to play audio-file.

root@dm365-evm:~# cd /usr/share/sounds/alsa

root@dm365-evm:/usr/share/sounds/alsa# aplay -t wav Front_Center.wav

Playing WAVE 'Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

Division by zero in kernel.

Backtrace:

[<c00307d0>] (dump_backtrace+0x0/0x114) from [<c0317330>] (dump_stack+0x18/0x1c)

Oops!

 

Look here http://e2e./support/embedded/f/354/p/56231/226155.aspx

Step 12: 'davinci-vcif.c' fix.

 

Open 'sound/soc/davinci/davinci-vcif.c'.

Find 'case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:'.

After 'davinci_vcif_start(substream);'

type 'break;'

 

case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:

davinci_vcif_start(substream);

break;

 

Find 'dma_params[2];'

Swap lines as described in the forum post.

 

struct davinci_vcif_dev {

- struct davinci_vc *davinci_vc;

struct davinci_pcm_dma_params dma_params[2];

+ struct davinci_vc *davinci_vc;

};

 

Now it looks like.

 

struct davinci_vcif_dev {

struct davinci_pcm_dma_params dma_params[2];

struct davinci_vc *davinci_vc;

};

 

Save file. Rebuild kernel. Change uImage. Reboot. Test it.

 

root@dm365-evm:~# aplay -t wav /usr/share/sounds/alsa/Front_Center.wav

Finally! The sound was heard from the speaker. But, the sampling frequency is mismatch.

Step 13: Change volume for SPK1 and pga level for MIC1.

 

Speaker volume is given by the numbers from 0 to 63 or a percentage.

 

root@dm365-evm:~# amixer scontents

Simple mixer control 'Mono DAC',0

Capabilities: pvolume pvolume-joined penum

Playback channels: Mono

Limits: Playback 0 - 63

Mono: Playback 54 [86%]

Simple mixer control 'PGA',0

Capabilities: cvolume cvolume-joined penum

Capture channels: Mono

Limits: Capture 0 - 3

Mono: Capture 0 [0%]

 

root@dm365-evm:~# amixer sset 'Mono DAC' 30

Simple mixer control 'Mono DAC',0

Capabilities: pvolume pvolume-joined penum

Playback channels: Mono

Limits: Playback 0 - 63

Mono: Playback 30 [48%]

 

root@dm365-evm:~# amixer sset 'Mono DAC' 90%

Simple mixer control 'Mono DAC',0

Capabilities: pvolume pvolume-joined penum

Playback channels: Mono

Limits: Playback 0 - 63

Mono: Playback 57 [90%]

 

Capture values is 0,1,2,3. But you can specify in percentage terms.

 

root@dm365-evm:~# amixer sset 'PGA' 100%

Simple mixer control 'PGA',0

Capabilities: cvolume cvolume-joined penum

Capture channels: Mono

Limits: Capture 0 - 3

Mono: Capture 3 [100%]

 

If you want to store audio levels, then try this.

 

root@dm365-evm:~# alsactl store EVM

 

This command is store levels to configuration file, and after reboot alsa boot-script restore this levels.

 

Try to record voice, now.

root@dm365-evm:~# arecord -t wav -r 16000 test16kHz.wav

 

Tilt your head as close as possible to the microphone and speak very loudly into it.

After a few seconds, press the 'Ctrl-C'.

 

Replay your record.

root@dm365-evm:~# aplay -t wav -r 16000 test16kHz.wav

 

It works!

 

Okay. If you want switch between AIC and VOICE codecs, there are some hints.

Overwrite 'davinci_dm365_defconfig' with 'config_aic' or 'config_vc' to build kernel.

Or you can can use ready-made images 'uImage_aic' or 'uImage_vc' (simply, change U-Boot variable to boot right image).

Also you can choose 'targetfs_aic' or 'targetfs_vc', or do something in to use the correct 'asound.state' file.

Step N: Future improvements.

 

Goto Khilman site again.

http://git./?p=linux/kernel/git/khilman/linux-davinci.git;a=summary

Now choose the latest tag (Master). Use 'tree' link-button. Find all of the files that we have changed.

There are 'davinci_voicecodec.c', 'davinci-vcif.c', 'cq93vc.c' and others.

Using 'history' link-button, carefully read the history of each file. There may be significant improvement.

Check it! Test it! Describe your results.

Also, watch for Arago project

http:///git/projects/linux-davinci.git?p=projects/linux-davinci.git;a=summary

There may also be something very important.

 

Step X: test ENCODE and DECODE

 

root@dm365-evm:~# cd /usr/share/ti/dvsdk-demos

root@dm365-evm:/usr/share/ti/dvsdk-demos# ./loadmodules.sh

cmemk: disagrees about version of symbol module_layout

irqk: disagrees about version of symbol module_layout

FATAL: Error inserting cmemk (/lib/modules/2.6.32-rc2-davinci1/kernel/drivers/dsp/cmemk.ko): Invalid module format

 

You need to rebuild modules EDMA,CMEM etc.

[linux-devkit]> make cmem_clean && make cmem && make cmem_install

[linux-devkit]> make irq_clean && make irq && make irq_install

[linux-devkit]> make edma_clean && make edma && make edma_install

[linux-devkit]> make dm365mm_clean && make dm365mm && make dm365mm_install

 

Copy

cmemk.ko, dm365mmap.ko, edmak.ko, irqk.ko

to targetfs '/lib/modules/2.6.32-rc2-davinci1/kernel/drivers/dsp'.

Replace old files with new.

Reboot.

 

You need to rebuild demos.

 

[linux-devkit]>make components

[linux-devkit]>make demos_clean

[linux-devkit]>make demos

[linux-devkit]>make demos_install

Copy files from 'install' to 'targetfs'.

Replace old files with new.

root@dm365-evm:/usr/share/ti/dvsdk-demos# ./loadmodules.sh

root@dm365-evm:/usr/share/ti/dvsdk-demos# ./encode -a test.aac

Encode demo started.

ARM Load: 6% Video fps: 0 fps Video bit rate: 0 kbps Sound bit rate: 12 kbps Time: 00:00:01 Demo: Encode Display: 720P 60Hz Video Codec: N/A Resolution: N/A Sound Codec: AACLC Enc
oder Sampling Freq: 16 KHz samp rate

root@dm365-evm:/usr/share/ti/dvsdk-demos# ./decode -a test.aac

Decode demo started.
ARM Load: 13% Video fps: 0 fps Video bit rate: 0 kbps Sound bit rate: 170 kbps Time: 00:00:01 Demo: Decode Display: 720P 60Hz Video Codec: N/A Resolution: N/A Sound Codec: AAC Sam
pling Freq: 16 KHz samp rate

Demos are work.

GOOD LUCK!

By the way, I just tried one thing.

GStreamer works with the internal microphone and speaker!

Although not all GStreamer examples work, but some still work (see below).

 

root@dm365-evm:/usr/share/ti/dvsdk-demos# cd /usr/share/ti/dvsdk-demos

root@dm365-evm:/usr/share/ti/dvsdk-demos# ./loadmodules.sh


Audiotest - 8kHz

 

root@dm365-evm:/usr/share/ti/dvsdk-demos# gst-launch audiotestsrc num-buffers=1000 ! 'audio/x-raw-int, width=16, depth=16, rate=8000' ! alsasink

 

Sound from the speaker seems as normal.

 

Audiotest — 16kHz

 

root@dm365-evm:/usr/share/ti/dvsdk-demos# gst-launch audiotestsrc num-buffers=1000 ! 'audio/x-raw-int, width=16, depth=16, rate=16000' ! alsasink

 

sound is bad.

 

Audio Loopback (record from mic with playback to speaker)

 

gst-launch -v alsasrc ! 'audio/x-raw-int, width=16, depth=16, rate=8000, channels=1' ! alsasink sync=false

gst-launch -v alsasrc ! 'audio/x-raw-int, width=16, depth=16, rate=16000, channels=1' ! alsasink sync=false

 

These examples are working (although sound is echoing).

 

Store audiotest as AAC-file (12 second)

 

gst-launch -v audiotestsrc num-buffers=200 ! 'audio/x-raw-int, width=16, depth=16, rate=16000, channels=1' ! TIAudenc1 codecName=aaclcenc engineName=codecServer ! filesink location=test.aac

 

Works fine.

 

Note, 8kHz rate does not supported with AAC-encoder (16kHz minimum).

 

Store my voice as AAC-file

 

gst-launch -v alsasrc num-buffers=400 ! 'audio/x-raw-int, width=16, depth=16, rate=16000, channels=1' ! TIAudenc1 codecName=aaclcenc engineName=codecServer ! filesink location=myvoice.aac

 

playback my aac-voice

 

gst-launch -v filesrc location=myvoice.aac ! TIAuddec1 codecName=aacdec engineName=codecServer ! alsasink sync=false

 

Sound is played, but the frequency is clearly not the same.

 

Other examples are not working, mostly due to the caps-incompatibility between the pipes.

(WARNING: erroneous pipeline: could not link filesrc0 to tiauddec10)

Hello!

 

Let me to introduce the patch that adds VoiceCodec into the DVSDK4.2. If you have DM365EVM, please test it. I never knew how to do patches, and doing it the first time in my life.

I used the command 'diff' to create this patch.

 

Here are instructions.

1. Getting the patch

 

Download the file by clicking here <7444.Add-VoiceCodec.patch.zip>

Unpack the archive. You will see a file 'Add-VoiceCodec.patch'.

 

2. Backup

 

Linux sources are located in $DVSDK/psp/linux-2.6.32.17-psp03.01.01.39

 

Make a backup copy of this catalog!

 

For example, copy the contents of the catalog

'linux-2.6.32.17-psp03.01.01.39'

into

'backup_linux-2.6.32.17-psp03.01.01.39'.

 

This patch modifies the contents of some files only within the Linux sources catalog.

 

If something goes wrong, simply delete 'linux-2.6.32.17-psp03.01.01.39', and then rename 'backup_linux-2.6.32.17-psp03.01.01.39' back to 'linux-2.6.32.17-psp03 .01.01.39 ', and you'll bring everything back as it was.

 

WARNING! This patch assumes that you have a new installation of DVSDK4.2 and you did not made any changes to these files: 'dm365.c', 'dm365.h', 'mux.h' and 'board-dm365-evm.c'. Otherwise, this patch may or may not apply.

 

Make a copy of the file '/etc/asound.state' from targetfs (be careful, from targetfs, and not from the host).

 

3. Apply the patch

 

Put the file 'Add-VoiceCodec.patch' in catalog 'linux-2.6.32.17-psp03.01.01.39'.

 

Using the terminal go to that catalog and run:

 

$ patch -p1 -i Add-VoiceCodec.patch

 

In normal output should look as follows:

 

patching file arch/arm/mach-davinci/board-dm365-evm.c

patching file arch/arm/mach-davinci/dm365.c

patching file arch/arm/mach-davinci/include/mach/dm365.h

patching file arch/arm/mach-davinci/include/mach/mux.h

patching file drivers/mfd/davinci_voicecodec.c

patching file drivers/mfd/Kconfig

patching file drivers/mfd/Makefile

patching file include/linux/mfd/davinci_voicecodec.h

patching file sound/soc/codecs/cq93vc.c

patching file sound/soc/codecs/cq93vc.h

patching file sound/soc/codecs/Kconfig

patching file sound/soc/codecs/Makefile

patching file sound/soc/davinci/davinci-evm.c

patching file sound/soc/davinci/davinci-vcif.c

patching file sound/soc/davinci/davinci-vcif.h

patching file sound/soc/davinci/Kconfig

patching file sound/soc/davinci/Makefile

 

If the output looks different and there are errors, sorry. Restore the original catalog 'linux-2.6.32.17-psp03.01.01.39' (see above).

 

4. Switching between the AIC and VoiceCodec using Linux menuconfig

 

Device Drivers --->

...

<*> Sound card support --->

...

<*> Advanced Linux Sound Architecture --->

...

<*> ALSA for SoC audio support --->

 

Would be something like that.

--- ALSA for SoC audio support

<*> SoC Audio for the TI DAVINCI chip

<*> SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM

DM365 codec select (Audio Codec - AIC3101) --->

< > Build all ASoC CODEC drivers

 

In paragraph 'DM365 codec select' you can switch the codec.

 

( ) Audio Codec - AIC3101

(X) Voice Codec — CQ93VC

 

You will return to the previous point and see that there is a new opportunity to choose the type of VoiceCodec as 8kHz or 16kHz.

Put a checkmark in the paragraph 'Show clocks at Linux startup'.

The screen should look like this:

 

--- ALSA for SoC audio support

<*> SoC Audio for the TI DAVINCI chip

<*> SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM

DM365 codec select (Voice Codec - CQ93VC) --->

Voice Codec Sampling Frequency (Fs=16kHz) --->

[*] Show clocks at Linux startup (Debug feature)

< > Build all ASoC CODEC drivers

 

5. Initial setup

At the beginning of the Linux boot messages you see this:

 

*** VOICECODEC CONFIGURATION is 16 kHz

*** Board Clocks:

* PERI_CLKCTL=0x243F027C

* CLOCKOUT0EN is 0 = en

* CLOCKOUT1EN is 0 = en

* CLOCKOUT2EN is 1 = dis

* DIV1 is 15 = 16

* DIV2 is 4 = 5

* DIV3 is 63 = 64

* HDVICPCLKS is 1 = PLLC2SYSCLK2

* DDRCLKS is 0 = PLLC1SYSCLK7

* KEYSCLKS is 0 = RTCXI (MXI)

* ARMCLKS is 1 = PLLC2SYSCLK2

* PRTCCLKS is 0 = RTCXI (OSC)

* CLKIN = 24000000 Hz

* PLL1PreDiv is 7 = 8

* PLL1Mul is 81 = 162

* PLL1PostDiv is 0 = 1 -- en

* PLL1 CLK = 486000000 Hz -- en

* PLL1DIV1 is 0 = 1 -- en

* PLL1DIV2 is 1 = 2 -- en

* PLL1DIV3 is 1 = 2 -- en

* PLL1DIV4 is 3 = 4 -- en

* PLL1DIV5 is 1 = 2 -- en

* PLL1DIV6 is 17 = 18 -- en

* PLL1DIV7 is 0 = 1 -- en

* PLL1DIV8 is 3 = 4 -- en

* PLL1DIV9 is 1 = 2 -- en

* PLL2PreDiv is 7 = 8

* PLL2Mul is 99 = 198

* PLL2PostDiv is 0 = 1 -- en

* PLL2 CLK = 594000000 Hz -- en

* PLL2DIV1 is 0 = 1 -- en

* PLL2DIV2 is 1 = 2 -- en

* PLL2DIV3 is 0 = 1 -- en

* PLL2DIV4 is 28 = 29 -- en

* PLL2DIV5 is 7 = 8 -- en

* ARM CORE CLK = 297000000 Hz

* HDVICP CLK = 297000000 Hz

* DDR CLK supply for PHY = 486000000 Hz ; Real DDR clk = 243000000 Hz

* VoiceCodec CLK = 4096551 Hz ; Sample Freq = 16002 Hz

 

and this

 

asoc: CQ93VC <-> davinci-vcif mapping ok

ALSA device list:

#0: DaVinci DM365 EVM (CQ93VC)

 

Remove the old (AIC) configuration

root@dm365-evm:~# rm /etc/asound.state

 

Set the microphone sensitivity (from 0 to 3)

root@dm365-evm:~# amixer sset 'PGA' 2

 

Set the speaker volume (from 0 to 63 or from 0% to 100%)

root@dm365-evm:~# amixer sset 'Mono DAC' 50%

 

Save the new configuration

root@dm365-evm:~# alsactl store EVM

 

6. Hardware Improvements

 

SPK1 Improvements

Unfortunately, the DM365EVM has a bad speaker (SPK1). You'll hear a very quiet sound from it. I can recommend (for your own risk) you to unsolder and unmount this speaker, and you can mount and solder the 3.5mm headphone jack instead the speaker. See photo.

My headphones have a resistance of 32 Ohms, and I made matching this resistance. Keep in mind that VoiceCodec has one channel, and you have to do a mono headset. Also, I recommend making a LP filter, for example, to cut off all frequencies above 3 kHz. You can carefully solder necessary parts to the back of the board. See photo.

Much easier to hear the sound through headphones!

As a result, I hear a loud sound in the headphones if I set 50% of the volume.

(amixer sset 'Mono DAC' 50%)

 

 

MIC1 Improvements

Much worse is the case with the microphone! I see that the problem apparently is that the impedance of the microphone is not match with the impedance of VoiceCodec. As a result, the microphone has a very weak sensitivity. You will have bent to it, literally screaming right into it.

Again, I can recommend to solder a normal and high quality electret microphone instead that there is. See photo.

You must connect a microphone through the BUFFER! It is necessary to match the output and input impedances.

As a result, I can record a loud sound using a value of 2 (range from 0 to 3) in the settings of the microphone.

(amixer sset 'PGA' 2)

 

7. Tests

arecord, aplay

 

Record WAV-file using a microphone (duration 10s)

root@dm365-evm:~# arecord -t wav -f S16_LE -r 16000 -c 1 -d 10 test16kHz.wav

Recording WAVE 'test16kHz.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

 

WAV-file playback

root@dm365-evm:~# aplay test16kHz.wav

Playing WAVE 'test16kHz.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

 

GStreamer

 

Soundtest

gst-launch -v audiotestsrc \

! 'audio/x-raw-int,width=16,depth =16,rate=16000,channels=1' \

! audioconvert \

! alsasink

 

Loopback

gst-launch -v alsasrc \

! 'audio/x-raw-int,width=16,depth=16,rate=16000,channels=1' \

! alsasink sync=false

 

Record AAC (encoder need 2 channels)

gst-launch -v alsasrc \

! 'audio/x-raw-int,width=16,depth=16,rate=16000,channels=2' \

! TIAudenc1 codecName=aaclcenc engineName=codecServer \

! filesink location=test.aac

 

Playback AAC (input file must be 16kHz, 2channels)

gst-launch -v filesrc location=test.aac \

! TIAuddec1 codecName=aacdec engineName=codecServer \

! alsasink sync=false

 

Important note: AAC-encoder and decoder operates with a sampling rate of 16kHz and above. You can not use 8 kHz mode of VoiceCodec to encode/decode AAC.

 

 

'encode' demo (dvsdk-demos)

 

If you have just installed DVSDK, (you never rebuild it), then when you run 'encode-a test.aac', you can see 'failed to create audio device'.

Try to rebuild dvsdk-demos! ('make demos_clean', 'make demos', 'make demos_install')

 

./encode -a test.aac -p 16000 -t 10

The file has a duration of 5 seconds, and the sound is twice as fast (if you listen the file on the host).

 

Need something to fix in the code.

 

Open 'audio.c' from dvsdk-demos_xxx/dm365/encode.

Look for this one block within the code.

/* Use supplied params if any, otherwise use defaults */

params = envp->params ? envp->params : &defaultParams;

dynParams = envp->dynParams ? envp->dynParams : &defaultDynParams;

params->sampleRate = dynParams->sampleRate = envp->sampleRate;

params->bitRate = dynParams->bitRate = envp->soundBitRate;

 

Just add those two lines after this code.

params->channelMode = IAUDIO_1_0;

dynParams->channelMode = IAUDIO_1_0;

 

This is because the VoiceCodec is a mono-device.

Rebuild encode demo.

Try again.

./encode -a test.aac -p 16000 -t 10

It works!!!

 

 

 

Please test it ALL!

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多