Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

DM368 IPNC I2S ( McBSP ) audio AV Capture(Server) Error...

I am testing av-server using ITE 6604 HDMI receiver.
Video Data input is well works...
But I have problem to use audio through I2S form HDMI receiver 
I want to send Audio/Video data using AV-server ( RTSP Server )
But I think av-server only receive form VOICE PCM data ( 8000 or 16000 ),
And Our HDMI output is I2S and Sampling Rate is 44.1kHz..
origin:
MIC  -------> Internel Voice Codec(CQ93VC) --->PCM  to AV Capture --> Stream Server  --> Streaming
Our System
HDMI out -------> I2S Codec( Dummy HDMI Codec ) ---> Av Capture --> Stream Server  ---> Streaming
What shall  I do for I2S PCM Data to AV-Capture??
Please let me know...
Follow is Our log...
Kernel Log:

[ 2.973335] Registered DAI 'DUMMY-DAI-CODEC'
[ 2.986833] Registered DAI 'davinci-mcbsp'
[ 3.042707] asoc: DUMMY-DAI-CODEC <-> davinci-mcbsp mapping ok
[ 3.066614] ALSA device list:
[ 3.069593] #0: DaVinci DM365 EVM
[ 3.074464] TCP cubic registered

======================================================

Av-Capure Log

FR : 0 users registered from exsiting face album

IPNC_DM365_4.1.0 (ycyi@ubuntu) (gcc version 4.3.3 (GCC) ) #19 PREEMPT Sun Mar
IPNC AUTO_IRIS = 1
AUDIO: Recevied CMD = 0x0300
AUDIO: Create...

[ 31.888360] asoc: interface davinci-mcbsp hw params failed
ERROR (drv_audio.c|DRV_audioOpen|101): unable to set hw parameters: Invalid argument
ERROR (audioThr.c|AUDIO_audioTskMain|663): AUDIO_audio[ 31.905489] davinci_mmc davinci_mmc.0: powerup timeout
TskCreate()
ERROR (avServerMainThr.c|AVSERVER_tskStart|177):
AVSERVER MAIN: Delete audioTsk ...
AUDIO: Recevied CMD = 0x0301
queue id:0

  • Park,

    Did you add driver for your HDMI audio capture device in the kernel? If its there, you can enable that device as your capture device and avserver will take audio from that. 

  • Yes, I already add codec driver.

    root@20:/sys/bus/platform/drivers/dummy-dummy-codec# cd dummy-dummy-codec/
    root@20:/sys/devices/platform/dummy-dummy-codec# ls -al
    drwxr-xr-x 2 root root 0 Jan 1 08:00 .
    drwxr-xr-x 27 root root 0 Jan 1 08:00 ..
    lrwxrwxrwx 1 root root 0 Jan 1 08:02 driver -> ../../../bus/platform/drivers/dummy-dummy-codec
    -r--r--r-- 1 root root 4096 Jan 1 08:02 modalias
    lrwxrwxrwx 1 root root 0 Jan 1 08:02 subsystem -> ../../../bus/platform
    -rw-r--r-- 1 root root 4096 Jan 1 08:02 uevent

    Belows are source code.

    ============================================

    Our Source Code : davinci-evm.c

    static struct snd_soc_dai_link dm365_evm_dai = {
    .name = "DUMMY_SOC_LINK",
    .stream_name = "dummy",
    .cpu_dai_name = "davinci-mcbsp",
    .codec_dai_name = "DUMMY-DAI-CODEC",
    .init = evm_aic3x_init,
    .codec_name = "dummy-dummy-codec",
    .ops = &evm_ops,
    .platform_name = "davinci-pcm-audio",
    };

    ==========================================

    I don't understand that AV server  only can receive 8000~16000 sampling rate..but, our pcm sampling rate is 441000.

    Do I change sampling rate parameter ?

    I use below command,

    av_server.out DM368 AUDIO 8000 AAC 32000 720P H264 1000000 VBR AUTO SVC RTSP

    I want chage to below command.

    av_server.out DM368 AUDIO 441000 AAC 32000 720P H264 1000000 VBR AUTO SVC RTSP

  • Park,

    Have you implemented the codec driver properly? Is it just for name sake? Because your codec driver has to configure the MCBSP properly according to the sampling rates etc. 

    If you have implemented an ALSA driver properly for your codec, it should work fine.

  • Yes, Our Codec is just dummy codec.

    Because HDMI output is I2S format. I don't control anything for audio output 

    I Just control video interface with i2c bus. and always audio is out through I2S bus . So I made a fake dummy codec.

    And I do mapping davinci-i2.c source.

    This is dummy codec full source.

    ==============================================================

    /* Dummy dai driver for HDMI */
    static struct snd_soc_dai_driver it6604_dai = {
    .name = "DUMMY-DAI-CODEC",
    .playback = {
    .stream_name = "Playback",
    .channels_min = 2,
    .channels_max = 2,
    .rates = SNDRV_PCM_RATE_8000_96000,
    .formats =SNDRV_PCM_FMTBIT_S16_LE ,
    },
    .capture = {
    .stream_name = "Capture",
    .channels_min = 2,
    .channels_max = 2,
    .rates = SNDRV_PCM_RATE_8000_96000,
    .formats =SNDRV_PCM_FMTBIT_S16_LE,
    },
    .symmetric_rates = 1,

    };

    static int hdmi_codec_probe(struct platform_device *pdev)
    {
    int ret;

    ret = snd_soc_register_codec(&pdev->dev, &soc_codec_hdmi, &it6604_dai, 1);
    if (ret < 0)
    printk(KERN_INFO " HDMI Codec Register Failed\n");

    return ret;
    }

    static int hdmi_codec_remove(struct platform_device *pdev)
    {
    snd_soc_unregister_codec(&pdev->dev);
    return 0;
    }

    static struct platform_driver hdmi_codec_driver = {
    .driver = {
    .name = "dummy-dummy-codec",
    .owner = THIS_MODULE,
    },
    .probe = hdmi_codec_probe,
    .remove = hdmi_codec_remove,
    };

    static int __init hdmi_modinit(void)
    {
    int ret = 0;

    ret = platform_driver_probe(&hdmi_codec_driver,hdmi_codec_probe);

    printk("return ret=================%d\n",ret);

    return ret;
    }

    module_init(hdmi_modinit);

    static void __exit hdmi_exit(void)
    {
    platform_driver_unregister(&hdmi_codec_driver);
    }
    module_exit(hdmi_exit);

    MODULE_DESCRIPTION("ASoC IT6604 HDMI Audio driver");
    MODULE_AUTHOR("YcYi");
    MODULE_LICENSE("GPL");
    MODULE_ALIAS("platform:hdmi-dummy-codec");

    ==============================================================

  • Park,

    Can you try with arecord first. I guess you'll have to implement couple of more APIs which is specific start/stop etc.. Just refer to a standard driver and implement stub APIs and ensure that they return success. 

  • Thank you for your respose,

    I 'v tested using arecord...and fixed some errors.

    Then I record sound with "arecord" and put the PC . and Sound is very well..

    But still streaming is not working..there some error on encoding parts.

    This is error log.

    ===========================================================

    Enter Choice : ...done initializing
    ...done initializing
    ...done initializing
    ...done initializing
    ...done initializing
    ERROR (alg_audEnc.c|ALG_audEncRun|252): AUDENC1_process() failed with error (-1 ext: 0x0)
    ERROR (audioThr.c|AUDIO_audioTskRun|482): Audio encode error !!
    ERROR (audioThr.c|AUDIO_audioTskMain|710): AUDIO_audioTskRun()
    AUDIO: Delete...
    AUDIO: Delete...DONE

    Play this stream using the URL:
    rtsp://169.254.7.197:8556/PSIA/Streaming/channels/2?videoCodecType=H.264

    (We use port Play this stream using the URL:
    rtsp://169.254.7.197:8554/PSIA/Streaming/channels/1?videoCodecType=MPEG4
    Play this stream using the URL:
    rtsp://169.254.7.197:8553/PSIA/Streaming/channels/1?videoCodecType=MPEG4
    Play this stream using the URL:
    rtsp://169.254.7.197:8555/PSIA/Streaming/channels/0?videoCodecType=MJPEG

    (We use port 8302 for optional RTSP-over-HTTP tunneling.)
    8303 for optional RTSP-over-HTTP tunneling.)
    Play this stream using the URL:
    rtsp://169.254.7.197:8557/PSIA/Streaming/channels/2?videoCodecType=H.264

    (We use port 8304 for optional RTSP-over-HTTP tunneling.)

    (We use port 8300 for optional RTSP-over-HTTP tunneling.)

    (We use port 8301 for optional RTSP-over-HTTP tunneling.)
    amixer: Unable to find simple control 'PGA',0

    amixer: Unable to find simple control 'Mono DAC',0

    sycOnvif Profile 1
    SystemInit success

    =============================================================

    Our Sound source have two channel stereo, 44.1Khz Sampling rate, and using S32_LE Format.

    Thanks you. 

  • Park,

    This looks more like an issue with the audio encoder. I'm not sure, but can you check the arguments to the audio encoder? See whether it supports the sampling rate etc with your new codec. Also you can try different sampling rates as well. Also which is the codec used for encode? 

  • Yes, I think this is an issue with audio encoder. 

    I've check argument for audio encoder. and I tried to change encoding parameter many times. but result is same.

    Follows are I checked parameter value..

    And I used AAC Encoder..

    =======================================

    Encoding Parameter for AAC.

    #define NUM_CHANNELS (2)

    #define NUMSAMPLES (1024)
    #define RAWBUFSIZE (NUMSAMPLES * 2)
    #define INPUTBUFSIZE (RAWBUFSIZE)
    /* The max amount of bytes of speech data to process at once */
    #define OUPUTBUFSIZE (RAWBUFSIZE)

    audEncPrm.codec = gAVSERVER_config.audioConfig.codecType;   <<=== AAC
    audEncPrm.encMode = (gAVSERVER_config.audioConfig.codecType==ALG_AUD_CODEC_G711)?PCM_ULAW:MPEG4_AUDIO;
    audEncPrm.numSamples = NUMSAMPLES;  <<============= 1024 ~ 16384 :
    audEncPrm.sampRate = gAVSERVER_config.audioConfig.samplingRate;  <<=== 44100
    audEncPrm.bitRate = gAVSERVER_config.audioConfig.bitRate;  <<==== 32000


    but results is

    Enter Choice : ERROR (alg_audEnc.c|ALG_audEncRun|287): AUDENC1_process() failed with error (-1 ext: 0x0)
    AUDIO ENCODER STATUS MESSAGE: In data used (2048) Bytes Generated(0)
    ERROR (audioThr.c|AUDIO_audioTskRun|518): Audio encode error !!
    ERROR (audioThr.c|AUDIO_audioTskMain|754): AUDIO_audioTskRun()

    Perhaps, which parts occurs above error?  I'm already check parameter all of them...


    Please help me..

     

  • Park,

    I am not an audio expert, but still I think G711 doesn't support 44.1KHz sampling rate. G711 is meant for voice generally. You can try to reduce the sampling rate 8 or 16KHz and see whether it works or not.

  • I know G.711 does't supoort 44.1Khz Sampling rate. So I used AAC Encoder.

    And , I should supoort 44.1Khz or 48Khz sampling rate.

    I really want to know which case AAC Encoder produce error return. I think that sampling rate, etc, doesn't matter.

    I don't know exactly which parts of encoding routine occurs a problem.

  • Park,

    Sorry, I didn't read the log care fully. I'm not an expert in codecs, I'll check this with our audio encoder expert and get back to you by Monday.

  • Hi Park, 

    Where are you feeding the number of channels to the encoder create parameter?

    Since the number of channels is 2 and number of samples per channel is 1024 - you should be feeding 2048 samples, i.e, 4096 bytes. 

    guess the process call is returning error due to insufficient input samples, I'll confirm if this is the cause for error on Monday. 

    Feel free to reach me on vinay DOT mangalore AT pathpartnertech DOT com - if I forget to answer you early next week. 

    regards

    Vinay

  • To aid for understanding, Let It appears both variables and value parameter what we set.

    We command like this,

    av_server.out DM368 AUDIO 44100 AAC 128000 720P H264 1000000 VBR AUTO SVC RTSP

    Our Sound Source input  : 44.1K sampling rate , format : S32_LE,  2channel

    ===============================================================

    in audioThr.c

    ------------------

    #define NUM_CHANNELS (2)
    #define NUMSAMPLES (2048)
    #define RAWBUFSIZE (NUMSAMPLES * 2)
    #define INPUTBUFSIZE (RAWBUFSIZE)
    #define OUPUTBUFSIZE (RAWBUFSIZE)

    in alg_audEnc.c
    --------------------
    void *ALG_audEncCreate(ALG_AudEncPrm *prm)

    case ALG_AUD_CODEC_AAC:
    pObj->audParams.aud_params.size = sizeof(AUDENC1_Params);
    pObj->audParams.aud_params.sampleRate = prm->sampRate;
    pObj->audParams.aud_params.bitRate = prm->bitRate;
    pObj->audParams.aud_params.channelMode = IAUDIO_2_0;

    pObj->audParams.aud_params.dataEndianness = XDM_LE_16;

    pObj->audParams.aud_params.encMode = IAUDIO_CBR;

    pObj->audParams.aud_params.inputFormat = IAUDIO_INTERLEAVED;

    pObj->audParams.aud_params.inputBitsPerSample = 32;
    pObj->audParams.aud_params.maxBitRate = 256000;

    pObj->audParams.aud_params.dualMonoMode = IAUDIO_DUALMONO_LR;
    pObj->audParams.aud_params.crcFlag = XDAS_FALSE;

    pObj->audParams.aud_params.ancFlag = XDAS_FALSE;
    pObj->audParams.aud_params.lfeFlag = XDAS_FALSE;

    int ALG_audDynparams(void *hndl, ALG_AudEncPrm *prm)

    pObj->audParams.aud_dynParams.size = sizeof(AUDENC1_DynamicParams);
    pObj->audParams.aud_dynParams.sampleRate = prm->sampRate;
    pObj->audParams.aud_dynParams.bitRate = prm->bitRate;

    pObj->audParams.aud_dynParams.channelMode = IAUDIO_2_0;
    pObj->audParams.aud_dynParams.lfeFlag = XDAS_FALSE;

    pObj->audParams.aud_dynParams.dualMonoMode = IAUDIO_DUALMONO_LR;

    pObj->audParams.aud_dynParams.inputBitsPerSample = 32;

    =================================================================

    Log is :

    root@20:/usr/bin# ./av_server.out DM368 AUDIO 44100 AAC 128000 720P H264 1000000
    VBR AUTO SVC RTSP

    DM365MM Init Successful
    AVSERVER UI: Initializing.
    AVSERVER API: Creating TSKs.
    DRV_SyncRst: module = 47, domain = 0, state = 3

    CLK Hz,
    ARM Hz = 432000000
    DDR Hz = 340000000
    VPSS Hz = 340000000
    IMCOP Hz = 340000000

    DM365MM Init Successful AVSERVER API: Creating TSKs...DONE

    SYSTEM.MSTPRI0 value changed to 00440011

    CONFIGURING AVSERVER FOR DM368 .....
    queue id:65538
    AVSERVER UI: Starting Streaming Server...
    sh: ./wis-streamer: not found
    AVSERVER UI: Starting Streaming Server...DONE
    AVSERVER API: Sending START.
    AVSERVER MAIN: Recevied CMD = 0x0400, state = 0x0000
    AVSERVER MAIN: AVSERVER_tskConnectInit() ...
    AVSERVER MAIN: Create captureTsk ...
    SENSOR FPS VALUE = 30
    AVSERVER MAIN: Create encodeTsk ...
    AVSERVER MAIN: Create streamTsk ...
    queue id:131076
    AVSERVER MAIN: Create fdTsk ...

    FR : 0 users registered from exsiting face album
    AVSERVER MAIN: Create displayTsk ...
    AVSERVER MAIN: Create aewbTsk ...
    IPNC_DM365_4.1.0 (ycyi@ubuntu) (gcc version 4.3.3 (GCC) ) #1 PREEMPT Fri Mar 2
    IPNC AUTO_IRIS = 1
    AVSERVER MAIN: Create audioTsk ...
    AUDIO: Recevied CMD = 0x0300
    AUDIO: Create...
    Sample channel 2
    Sample buff 2048
    Sample rate 44100
    Driver for Capture Open
    [ 30.624861] asoc: DUMMY-DAI-CODEC <-> davinci-mcbsp info:
    [ 30.630403] asoc: rate mask 0x7fe
    [ 30.633734] asoc: min ch 2 max ch 2
    [ 30.637250] asoc: min rate 8000 max rate 96000
    Sample rate 44100
    Frame 2048
    AUDIO : period size = 1024 frames, dir = 1
    AUDIO : period time = 23219 us, dir = 1
    AUDIO : num of channel = 2
    AUDIO : Sample rate = 44100
    Encoder Task Create ==========================
    Codec Type 1
    Encode mode 3
    Bit rate 128000
    param size = 52
    param sampleRate = 44100
    param bitrate = 128000
    AUDIO: Create...DONE
    AVSERVER MAIN: Create audioPlayTsk ...
    AUDIOPLAY: Recevied CMD = 0x030[ 30.733026] asoc: DUMMY-DAI-CODEC <-> davinci-mcbsp info:
    0
    AUDIOPLAY: C[ 30.738959] asoc: rate mask 0x7fe
    reate...
    [ 30.743720] asoc: min ch 2 max ch 2
    [ 30.747938] asoc: min rate 8000 max rate 96000
    AUDIOPLAY: Create...DONE
    Initializing...
    Initializing...
    Initializing...
    Initializing...
    Initializing...
    queue id:0
    queue id:32769
    ...done initializing
    ...done initializing
    ...done initializing
    ...done initializing
    ...done initializing
    AVSERVER MAIN: Start audioTsk ...
    AUDIO: Start...
    AUDIO: Start...DONE
    AVSERVER MAIN: Start audioPlayTsk ...
    AUDIOPLAY: Start...
    AUDIOPLAY: Start...DONE
    ==========================================================================
    ======================== Audio Task Run Start ============================
    ==========================================================================
    AVSERVER MAIN: Start DONE
    AVSERVER API: Sending START...DONE

    Host-name / IP address : 20.20.20.10

    Read from Audio Codec Num Byte = 4096

    Read from Audio Codec time 30986
    [ALG_audEncRun] : InBuffer Addr : 40473000
    [ALG_audEncRun] : InBuffer Size : 4096
    [ALG_audEncRun] : OutBuffer Addr : 406a0000
    [ALG_audEncRun] : OutBuffer Size : 4096
    [ALG_audEncRun] : Num In Samples : 2048
    ERROR (alg_audEnc.c|ALG_audEncRun|300): AUDENC1_process() failed with error (-1 ext: 0x0)
    AUDIO ENCODER STATUS MESSAGE: In data used (4096) Bytes Generated(0)
    ERROR (audioThr.c|AUDIO_audioTskRun|523): Audio encode error !!
    ERROR (audioThr.c|AUDIO_audioTskMain|759): AUDIO_audioTskRun()
    AUDIO: Delete...
    AUDIO: Delete...DONE