Version


#include "traudef.h" /* Contains public interface to TRAU API */




static CTA_SERVICE_DESC Services[] = /* for ctaOpenServices */
{
{ {"TRAU","ADIMGR"}, { 0 }, { 0 }, { 0 } },
}
ret = ctaOpenServices( loadhd,
Services,
sizeof(Services)/sizeof(CTA_SERVICE_DESC) );
printf( "Waiting for open service on the loader \n" );
while (1)
{
ret = ctaWaitEvent( ctaQue, &event, CTA_WAIT_FOREVER);
if ( CTAEVN_OPEN_SERVICES_DONE == event.id )
break;
}
if (Event.value == CTA_REASON_FINISHED
printf ("Success.");

printf( "Request for first load \n" );
ret =trauLoad (loadhd,ANY_FUSION_BOARD,vocfile,&dspid,ParmPtr,ParmSize );
if( ret != SUCCESS )
{
printf ("Call to trauload failed:|t%x ", ret );
exit( ret );
}

Figure 7. Loading AG TRAU Programs With a Single loadhd
Figure 8. Possible Load Handle Configurations


Figure 9. Attaching AG TRAU Channels

{
ctaCreateContext( ctaQue, 0, "TRAUCHNHD", &trauchnhd[ channel_index ] );
printf( "open service request on channel %d...", channel_index );
ctaOpenServices( trauchnhd[ channel_index ],Services,
sizeof(Services)/sizeof(CTA_SERVICE_DESC) );
static CTA_SERVICE_DESC Services[] = /* for ctaOpenServices */
{
{ {"TRAU","ADIMGR"}, { 0 }, { 0 }, { 0 } },
}; /* Initialize other services as needed. */
while (1)
{
ctaWaitEvent( ctaQue, &event, CTA_WAIT_FOREVER);
if ( CTAEVN_OPEN_SERVICES_DONE == event.id )
{
if ( value == CTA_REASON_FINISHED)
puts("..success!");
printf ("Success.");
break;
}
else
{
ProcessError( loadhd, event.id );
puts("..Unknown event!");
}
}
/* All channel service set up so do the first attach */
ret = trauAttach (trauchnhd[ channel_index ],
loadhd,
type[0],
&attach_data );
if ( ret == SUCCESS )
{
printf( "trauAttach successful for %d \n", channel_index );
printf( "\t dspid = %x\n",attach_data.dspid);
printf( "\t board = %x\n",attach_data.board);
printf( "\t dsp = %x\n",attach_data.dsp);
printf( "\t channel = %x\n",attach_data.channel);
if ( loaddata->pcm_stream_from_dsp != 0 )
{
/* Now print switching information */
printf ("\t Switching info:\n");
printf ("\t PCM from DSP\t= %d:%01d\n",

/* Submit an enable request */
ret = trauEnable ( ctahd );
if( ret != SUCCESS )
{
printf ("Call to trauEnable failed:\t%x ", ret );
exit( ret );
}
while (1)
{
ret = ctaWaitEvent( ctaQue, &event, CTA_WAIT_FOREVER);
if ( TRAUEVN_ENABLE_DONE == event.id )
break;
}
/* process the TRAUEVN_ENABLE_DONE */
if ( event.value == CTA_REASON_FINISHED )
{ /* this enable was successful */
enabled_ctahd = event.ctahd;
printf ("TRAU Enable received, channel ctahd handle= %x\n",
enabled_ctahd );
}
else
printf ("Done event for trauEnable failed:\t%x ", event.value );
exit(event.value);



|
Value
|
Description
|
|---|---|
|
TRAU_CHN_ON_LINE
|
Channel attached and enabled.
|
|
TRAU_CHN_OFF_LINE
|
Channel attached but not enabled.
|
|
TRAU_CHN_DETACHED
|
Channel not attached.
|
======== TRAU INFO ===============
load hdl = 80000001
type = 1f01
channels = 3
detached #= 0
Vocoder type is MVIP based: Specific Data follows
CHANNEL INFO for channel 0
state = b....TRAU_CHN_ON_LINE
ctahd for this channel = 80010002
Switching info:
PCM from DSP = 28:0
PCM to DSP = 29:0
HDLC Data from DSP = 30:0,1,2,3
HDLC Data to DSP = 31:0,1,2,3
CHANNEL INFO for channel 1
state = b....TRAU_CHN_ON_LINE
ctahd for this channel = 80020003
Switching info:
PCM from DSP = 28:1
PCM to DSP = 29:1
HDLC Data from DSP = 30:0,1,2,3
HDLC Data to DSP = 31:0,1,2,3
CHANNEL INFO for channel 2
state = a....TRAU_CHN_OFF_LINE
ctahd for this channel = 80030004
Switching info:
PCM from DSP = 28:2
PCM to DSP = 29:2
HDLC Data from DSP = 30:0,1,2,3
HDLC Data to DSP = 31:0,1,2,3
Note: For more sample code, refer to trauexr.c.
======== TRAU INFO ===============
load hdl = 80000001
type = 4b49
channels = 1
detached #= 0
Vocoder type is host-based: Specific Data follows
frame tic in .25ms increments = 120
frame size in bytes = 32
under run count read = 0
under run count write = 0
CHANNEL INFO for channel 0
state = b....TRAU_CHN_ON_LINE
ctahd for this channel = 80020003

Figure 10. AG TRAU Channel State Diagram

case TRAUEVN_LOAD_DONE:
{
if ( event.value == CTA_REASON_FINISHED )
{
/* The following code provides examples of
how to extract load done buffer speific data with
the use of tthe load_done_data structure. */
/* Make sure a buffer is returned with load_data */
if ( event.size != 0 )
{
loaddata = event.buffer;
type[ total_trau_count ] = loaddata->type; /* vocoder type */
trauhd[total_trau_count] = loaddata->dspid; /* dsp identifier */
board = loaddata->board; /* brd # 0-n */
DSP = loaddata->dsp; /* DSP used */
channels = loaddata->channels;/* # of supported chns */
frame_tic = loaddata->frame_tic;
bufsize = loaddata->max_frame_size;
printf ("TRAU board # \t= %d\n", board );
printf ("TRAU channel count \t= %d\n", channels);
printf ("TRAU dsp used \t= %d\n", DSP );
printf ("TRAU dsp id (hex) \t= %x\n", trauhd[total_trau_count]);
printf ("TRAU vocoder type (hex)\t= %x\n",type[total_trau_count] );
if ( bufsize != 0 )
{
puts ("Detected vocoder transmission type is host-based");
printf (" TRAU frame duration in .25ms tics = %d\n",frame_tic);
printf (" TRAU Buffer size for each frame = %d\n",bufsize);
}
else
puts ("Detected vocoder transmission type is MVIP ");
if ( loaddata->pcm_stream_from_dsp != 0 )
{
/* Now print switching information */
printf ("Switching info:\n");
printf (" PCM from DSP\t\t= %d:",loaddata->pcm_stream_from_dsp);
for (index = 0; index < loaddata->pcm_count; index++)
{
if ( index != 0 )
printf(",");
printf ("%01d",loaddata->pcm_slot[index]);
}
printf ("\n");
printf (" PCM to DSP\t\t= %d:", loaddata->pcm_stream_to_dsp );
for (index = 0; index < loaddata->pcm_count; index++)
{
if ( index != 0 )
printf(",");
printf ("%01d",loaddata->pcm_slot[index]);
}
printf ("\n");
if ( bufsize == 0 ) /* print the output tx side. */
{
printf (" HDLC from DSP\t= %d:",loaddata->tx_stream_from_dsp);
for (index = 0; index < loaddata->tx_count;index++)
{
if ( index != 0 )
printf(",");
printf ("%01d",loaddata->tx_slot[index]);
}
printf ("\n");
printf (" HDLC to DSP\t= %d:",loaddata->tx_stream_to_dsp );
for (index = 0; index < loaddata->tx_count;index++)
{
if ( index != 0 )
printf(",");
printf ("%01d",loaddata->tx_slot[index]);
}
printf ("\n");
}
}
/* We know trauload returns a buffer, so release it. */
trauReleaseBuffer( event.ctahd, event.buffer );
}
else
{
/* Can't exercise from here since we do not have load
data, so abort program with this message */
puts("Size is Zero...probably forgot to release buffers\n");
exit (-1);
}

ctaGetText(event.ctahd, event.id, text, sizeof(text) );
printf ("\t\t EVENT: %s\n",text );
EVENT: TRAUEVN_SNDMSG_DONE_0ANote: Messages are vocoder specific. Refer to the appropriate .h file for more information.
Version