This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OMAP4 ABE changes for Bluetooth PCM routing for HF role

Other Parts Discussed in Thread: 4460

Hi TI

          I'm working on a custom board based on TI OMAP4430 Blaze running  TI 4AJ2.5.P1_OMAP4_Jelly_Bean . , kernel version 3.4

I'm implementing Bluetooth HandsFree profile (HF role). The Bt stack here is bluedroid and it supports only SCO over PCM.

Now as the HandsFree use-case is reversed (instead of AG role, it is HF role), I have the following queries on how to go about implementing the BT SCO PCM data read/write in the existing OMAP4 ABE/ HAL architecture for the following

1) Capture from device MIC and send to BT_VX_DL. Another condition here is I need to get the mic data into the HAL side for doing preprocessing effects like AGC, NC etc and  direct routing of MIC data to BT_VX_DL port is not an option

2) Read from BT_VX_UL and playback on device speaker.

Our custom board does not support modem and hence voice UL/DL should not get the BT DL/UL data by default.

a) What changes need to be done in the OMAP4 ABE such that

b) The PCM interfaces for BT_VX_UL and BT_VX_DL are not created ( no_pcm=1) . If PCM inteface this is created, can I use tinycap and tinyplay on the BT ports  simultaneously along with MIC record and playback on speaker ?

Please point out  what other changes may be required in the audio_hw.c (primary audio HAL) to accomplish the above use-case

Please HElp !! I'm stuck in this for long time and need more clarity on understanding OMAP4 ABE (audio engine)

Regards

Subhadra

  • Can anybody else give me pointers on how this can be achieved ? Please Help..  

    - Subhadra

  • Adding to  above details , as per our custom board  schematics , the BT chip is on McBSP2 interface  (not on McBSP1 and we don't have modem / FM radio ) .

    I also understand that by default the McBSP ports are owned by ABE driver (ie backend DAIs) and hence they are not visible to user as PCM interface .

    But I prefer to expose the BT McBSP2 as PCM interface ie .Front-end DAI so that it is visible in user space and i can use alsa utilities to read/write pcm samples .

    Please let me know what changes need to be done in the kernel omap4 sound soc to register the BT McBSP2 as front-end DAI (ie  ALSA PCM ) and also how to avoid ABE controlling the BT_VX_DL/BT_VX_UL links .

    The idea is to have simultaneous access to audio record (MIC) & playback(speaker) and still read/write  to BT PCM interface ..

    Kindly let me know..

  • Hello Subhadra,

    I suggest to look in section McBSP Basic Programming Model in OMAP4430 TRM.

    This section presents information about how must configure McBSP module in desired mode.

    It is needed to check the follow registers for proper McBSP configuration:

    Set the transmitter pins to operate as MCBSP pins. MCBSPLP_PCR_REG[13] XIOEN
    Enable/disable DLB mode - MCBSPLP_XCCR_REG[5] DLB
    Enable/disable ALB mode - MCBSPLP_SPCR1_REG[5] ALB

    Enable/disable the transmit multichannel selection mode - MCBSPLP_MCR1_REG[0] RMCM

    After that, see Data Configuration registers - MCBSPLP_RCR2_REG

                                                                                    MCBSPLP_XCR1_REG MCBSPLP_XCR2_REG

                                                                                    MCBSPLP_THRSH2_REG

    The McBSP driver in Android is in /arch/arm/mach-omap2/mcbsp.c. Refer to this file to see which configurations are possible to use.

    Best regards,

    Yanko

  • Hi Yanko

                             Thanks very much for  your response. I'm currently going through the McBSp section in OMAPP4430 TRM as you suggested. However what I still what to know is that , assuming the required McBSP register configurations are in place , is that all required for my use-case (or )

    should I be making any other changes in OMAP ABE driver such that it does not own the McBSP2 BT ports and create PCM interface  for Bluetooth uplink and downlink so that at user-space I can use ALSA utils to directly read and write to BT PCM ports.  

    Basically I want to achieve simultaneous access to audio in (MIC) and audio out (speaker) and perform read/write to bluetooth PCM  device.

    Please guide me....

    Thanks

    Subhadra

  • Hello Subhadra,

    I looked in OMAP4430 TRM, section 23.5.2.3.2.3 McBSP Function 3: Voice Data. There is showed an example of the McBSP module connected to voice device through the PCM interface. See the figure below:

    You can find ALSA PCM interface for the OMAP SoC in /sound/soc/omap - omap-pcm.c file, there are functions handled OMAP PCM hardware. Other file which is used for McBSP PCM configuration is /sound/soc/omap - omap-mcbsp.c

    Best regards,

    Yanko

  • Hello Subhadra,

    About PCM interface for Bluetooth uplink and downlink, refer to functions in /sound/soc/omap/ - omap-abe-pcm.c.

    The function - static int omap_abe_dl1_enabled(struct omap_abe *abe) - handles DL1 path common for BT_VX_DL.

    The function - static int be_connect_serial_port(struct snd_soc_pcm_runtime *be, struct snd_soc_dai *dai, int stream) is used to connect BE to serial port (McBSP).

    For ABE Uplink and Downlink gains refer to file /sound/soc/omap/ - omap-abe-core.c

    The logical port IDs - OMAP_ABE_BE/FE_PORT_BT_VX_DL, OMAP_ABE_BE/FE_PORT_BT_VX_UL are defined in /sound/soc/omap/abe - abe.h.

     MAIN PORT SELECTION - you can find in /sound/soc/omap/abe - abe_dat.c.

    Function (/sound/soc/omap/abe/ abe_port.c)- int omap_aess_connect_serial_port(struct omap_aess *abe, u32 id, struct omap_aess_data_format *f, u32 mcbsp_id)  - enables the data echanges between a McBSP and an ATC buffer in DMEM. This API is used connect 48kHz McBSP streams to MM_DL and 8/16kHz voice streams to VX_UL, VX_DL, BT_VX_UL, BT_VX_DL. It abstracts the abe_write_port API.

    I think that by modifying of these functions and files you will achieve simultaneous access to perform read and write to bluetooth PCM device for your case.
    For your information you can observe the following topic in e2e forum "OMAP 4460 Bluetooth Audio PCM Interface" - http://e2e.ti.com/support/omap/f/849/t/226568.aspx

    Best regards,
    Yanko

  • Hi Subhandra,

    For your information refer to this topic BT PCM porting issues?  http://e2e.ti.com/support/omap/f/849/t/235960.aspx

    It discusses similar problem as - PCM interface for Bluetooth.


    Best regards,

    Yanko

    BT PCM porting issues?

  • Hi Yanko 

                            Yes I 've been following the post you mentioned and couple of others.  Basically on our custom board we have some issues concerning the MCBSP2 configuration which causes system to freeze for sometime when BT sco is connected and resumes when SCO is disconnected . (Please refer to post by my colleague :  http://e2e.ti.com/support/omap/f/849/t/296649.aspx )

    Until then , I have been trying  following changes  on Blaze HS device running 4AJ.2.5 P1 . For HF role use-case on Blaze , I could not get both the AMIC capture and BT_VX_UL capture happening at same time using ABE which I belive is due to mixer design constraints  .

    So I commented  Bluetooth related BE route setting in aess code and created front-end DAI for Bluetooth

     I have made changes in the following files in kernel 3.4 version to create pcm interface for Bluetooth Capture & playback  . The Bluetooth PCM interface got created with DAI name set to 'omap.mcbsp.1' . 
    Console logs :
    shell@android:/ # cat /proc/asound/card0/pcm11c/*                              
    card: 0
    device: 11
    subdevice: 0
    stream: CAPTURE
    id: Bluetooth (*)
    name: 
    subname: subdevice #0
    class: 0
    subclass: 0
    subdevices_count: 1
    subdevices_avail: 1
    sh: cat: /proc/asound/card0/pcm11c/sub0: Is a directory

    However after BT SCO is connected , if I try to do tinycap or tinyplay on that pcm device id (11), I get the following error (for capture as well as for playback) :
    1|shell@android:/ # tinycap /sdcard/bt_pcm1.wav -d 11 -c 1 -r 8000             
    [  599.888824]  Bluetooth McBSP: asoc: Bluetooth McBSP no valid capture route from source to sink
    Unable to open PCM device (cannot open device '/dev/snd/pcmC0D11c': Invalid argument)
    Captured 0 frames
    I realized that this happens because of DAI was set as 'dynamic' =1. Next I commented out  dynamic =1 setting and  this time the pcm device node entry  /dev/snd/pcmC0D11x  is not created. However from logs I can make out that the pcm device for Bluetooth is registered.  Not clear what is going wrong..
    Files modified :
    1) sound/soc/omap/omap-abe-mixer.c  - Commented out BT_VX related route settings in struct 'snd_soc_dapm_route'
    2) sound/soc/omap/omap-abe-twl6040.c
    In this file, under omap_abe_dai_link[] and omap_abe_no_dmic_dai[] array, added entry by name "Bluetooth McBSP".  Here the cpu_dai_name is set to omap.mcbsp.1  and its platform_name is set to "omap-pcm-audio"
    Please let me know if  how can I accomplish simultaneous BT capture /playback directly without involving the OMAP ABE . I intend to use OMAP ABE to capture AMIC data and similarly do HandsFree audio playback . 
    Can somebody confirm if my changes are right for implementing seperate bluetooth pcm device ? Please help!
  • Hello Subhandra,

    I looked your post. It seems, there is a problem with ALSA driver configuration. This causes the problem with DAI.

    Could you try to execute the tinymix commands described in Testing Audio Driver from http://www.omappedia.com/wiki/Audio_Drive_Arch

    You can use some ALSA tools in order to test the driver in the most basic way without intervention of other applicacion to find if your driver, hardware or codec is working properly. Most of the times the tools are included in the filesystem.

    For more information about ALSA refer to https://bbs.archlinux.org/viewtopic.php?id=104602

    Best regards,

    Yanko

  • Hi Subhandra,

    I found that in SCO routing is disabled, it is possible your problem to be caused from this.

    Check in /mydroid/system/bluetooth/data/ audio.conf file and enable #SCORouting=PCM . Test again.

    Best regards,

    Yanko