PDK API Guide for J721E
MCASP Driver API

Introduction

MCASP driver interface

Files

file  mcasp_drv.h
 McASP driver interface definition file.
 

Data Structures

struct  Mcasp_errCbStatus
 structure to hold the error condition and the status More...
 
struct  Mcasp_HwSetupDataClk
 Hardware setup data clock structure. More...
 
struct  Mcasp_HwSetupGbl
 Hardware setup global structure. More...
 
struct  Mcasp_HwSetupData
 Hardware setup data structure. More...
 
struct  Mcasp_HwSetup
 Hardware setup structure. More...
 
struct  Mcasp_AudioDevData
 structure to store the audio device related information More...
 
struct  Mcasp_ChanParams
 channel Parameters to initialize channel Object More...
 
struct  Mcasp_ChStatusRam
 DIT channel status register structure. More...
 
struct  Mcasp_UserDataRam
 DIT channel user data register structure. More...
 
struct  Mcasp_PktAddrPayload
 Structure passed through DriverTypes_Packet addr field. More...
 
struct  MCASP_Packet
 McASP frame object params. More...
 
struct  Mcasp_Params
 

Functions

int32_t mcaspBindDev (void **devp, int32_t devId, void *devParams)
 
int32_t mcaspUnBindDev (void *devp)
 
int32_t mcaspCreateChan (void **chanp, void *devp, Mcasp_chanMode_e mode, void *chanParams, MCASP_TiomCallback cbFxn, void *cbArg)
 
int32_t mcaspSubmitChan (void *chanp, MCASP_Packet *ioPacket)
 
int32_t mcaspDeleteChan (void *chanp)
 
int32_t mcaspControlChan (void *chanp, Mcasp_ioctlCmd cmd, void *cmdArgs)
 

Variables

const Mcasp_Params Mcasp_PARAMS
 

Typedefs

typedef void(* Mcasp_GblCallback) (Mcasp_errCbStatus errCbStat)
 Global error callback function protype. More...
 
typedef void(* Mcasp_Isr) (void *arg)
 Mcasp Interrupt service routine. More...
 
typedef QueueP_Elem Mcasp_QueueElem
 McASP queue element. More...
 
typedef void(* MCASP_TiomCallback) (void *arg, MCASP_Packet *packet)
 EDMA TC callback function prototype This function is the call back function provided by the application during the mcaspCreateChannel(). This call back function is called every time a TX or RX transaction is completed. The arguments to this function are defined as below. More...
 

Enumerations

enum  Mcasp_chanMode_e { MCASP_INPUT = 0x0001, MCASP_OUTPUT = 0x0002, MCASP_INOUT = (MCASP_INPUT | MCASP_OUTPUT) }
 enumerated constants for the channel modes supported by Mcasp More...
 
enum  Mcasp_IOcmd_e { MCASP_READ = 0, MCASP_WRITE = 1, MCASP_ABORT = 2, MCASP_FLUSH = 3 }
 enumerated constants for the commands supported by Mcasp More...
 
enum  Mcasp_OpMode { Mcasp_OpMode_TDM = 0, Mcasp_OpMode_DIT = 1 }
 enumerated constants for the Transfer modes supported by Mcasp More...
 
enum  Mcasp_SerializerNum {
  Mcasp_SerializerNum_0 = 0, Mcasp_SerializerNum_1 = 1, Mcasp_SerializerNum_2 = 2, Mcasp_SerializerNum_3 = 3,
  Mcasp_SerializerNum_4 = 4, Mcasp_SerializerNum_5 = 5, Mcasp_SerializerNum_6 = 6, Mcasp_SerializerNum_7 = 7,
  Mcasp_SerializerNum_8 = 8, Mcasp_SerializerNum_9 = 9, Mcasp_SerializerNum_10 = 10, Mcasp_SerializerNum_11 = 11,
  Mcasp_SerializerNum_12 = 12, Mcasp_SerializerNum_13 = 13, Mcasp_SerializerNum_14 = 14, Mcasp_SerializerNum_15 = 15
}
 Enumeration for the MCASP serializer numbers. More...
 
enum  Mcasp_WordLength {
  Mcasp_WordLength_8 = 8u, Mcasp_WordLength_12 = 12u, Mcasp_WordLength_16 = 16u, Mcasp_WordLength_20 = 20u,
  Mcasp_WordLength_24 = 24u, Mcasp_WordLength_32 = 32u
}
 Enumerated constant for wordlength supported by the MCASP device. More...
 
enum  Mcasp_WordBitsSelect { Mcasp_WordBitsSelect_LSB = 0u, Mcasp_WordBitsSelect_MSB = 1u }
 Enumerated constant for selecting MSB/LSB word in the slot bits. More...
 
enum  Mcasp_pllDomain { Mcasp_pllDomain_0 = 0, Mcasp_pllDomain_1 = 1, Mcasp_pllDomain_NONE = 2 }
 PLL domain to be used by the device. More...
 
enum  Mcasp_BufferFormat {
  Mcasp_BufferFormat_1SER_1SLOT, Mcasp_BufferFormat_1SER_MULTISLOT_NON_INTERLEAVED, Mcasp_BufferFormat_1SER_MULTISLOT_INTERLEAVED, Mcasp_BufferFormat_MULTISER_1SLOT_SER_INTERLEAVED,
  Mcasp_BufferFormat_MULTISER_1SLOT_SER_NON_INTERLEAVED, Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_1, Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_2
}
 Enum to specify the supported buffer formats. More...
 
enum  Mcasp_ioctlCmd {
  MCASP_CHAN_RESET = 0, MCASP_CHAN_TIMEDOUT = 1, MCASP_DEVICE_RESET = 2, Mcasp_IOCTL_DEVICE_RESET = 128,
  Mcasp_IOCTL_CNTRL_AMUTE, Mcasp_IOCTL_START_PORT, Mcasp_IOCTL_STOP_PORT, Mcasp_IOCTL_QUERY_MUTE,
  Mcasp_IOCTL_CTRL_MODIFY_LOOPJOB, Mcasp_IOCTL_CTRL_MUTE_ON, Mcasp_IOCTL_CTRL_MUTE_OFF, Mcasp_IOCTL_PAUSE,
  Mcasp_IOCTL_RESUME, Mcasp_IOCTL_SET_DIT_MODE, Mcasp_IOCTL_CHAN_TIMEDOUT, Mcasp_IOCTL_CHAN_RESET,
  Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN, Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN, Mcasp_IOCTL_CNTRL_SET_GBL_REGS, Mcasp_IOCTL_SET_DLB_MODE,
  Mcasp_IOCTL_ABORT, Mcasp_IOCTL_SET_SAMPLE_RATE, Mcasp_IOCTL_GET_DEVINFO, Mcasp_IOCTL_FLUSH_RCV_FIFO,
  Mcasp_IOCTL_SET_TIMEOUT, Mcasp_IOCTL_QUERY_LOOPJOB_MODE, Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS, Mcasp_IOCTL_CHAN_PARAMS_WORD_WIDTH,
  Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN_CLKXDIV, Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN_CLKXDIV
}
 Mcasp Ioctl commands. More...
 

Macros

#define Mcasp_CACHE_LENGTH   (128u)
 
#define Mcasp_NUMSERIALIZERS   (16u)
 
#define Mcasp_GBLCTL_TIMEOUT   (30000U)
 
#define MCASP_EBADIO   (-(1)) /* Generic failure condition */
 
#define MCASP_ETIMEOUT   (-(2)) /* Timeout occurred */
 
#define MCASP_ENOPACKETS   (-(3)) /* No packets available for I/O */
 
#define MCASP_EFREE   (-(4)) /* Unable to free resources */
 
#define MCASP_EALLOC   (-(5)) /* Unable to alloc resource */
 
#define MCASP_EABORT   (-(6)) /* I/O was aborted before completed */
 
#define MCASP_EBADMODE   (-(7)) /* Illegal device mode */
 
#define MCASP_EOF   (-(8)) /* End-of-File was encountered */
 
#define MCASP_ENOTIMPL   (-(9)) /* Operation not implemented or supported */
 
#define MCASP_EBADARGS   (-(10)) /* Illegal arguments specified */
 
#define MCASP_ETIMEOUTUNREC   (-(11)) /* Unrecoverable timeout occurred */
 
#define MCASP_EINUSE   (-(12)) /* Device already in use */
 
#define MCASP_EINVALIDVAL   (-(13)) /* Invalid value encountered (Unexpected) */
 
#define MCASP_COMPLETED   (0) /* I/O completed successfully */
 
#define MCASP_PENDING   (1) /* I/O queued and pending */
 
#define MCASP_FLUSHED   2
 
#define MCASP_ABORTED   3
 

Macro Definition Documentation

◆ Mcasp_CACHE_LENGTH

#define Mcasp_CACHE_LENGTH   (128u)

cache line length

◆ Mcasp_NUMSERIALIZERS

#define Mcasp_NUMSERIALIZERS   (16u)

Number of serializers on mcasp

◆ Mcasp_GBLCTL_TIMEOUT

#define Mcasp_GBLCTL_TIMEOUT   (30000U)

The time to try (in Msec) before the GBLCTL register setting timeouts * if the setting/resetting is done in a context other than a task this will* be used as a retry count rather than the MSec timeout

◆ MCASP_EBADIO

#define MCASP_EBADIO   (-(1)) /* Generic failure condition */

◆ MCASP_ETIMEOUT

#define MCASP_ETIMEOUT   (-(2)) /* Timeout occurred */

◆ MCASP_ENOPACKETS

#define MCASP_ENOPACKETS   (-(3)) /* No packets available for I/O */

◆ MCASP_EFREE

#define MCASP_EFREE   (-(4)) /* Unable to free resources */

◆ MCASP_EALLOC

#define MCASP_EALLOC   (-(5)) /* Unable to alloc resource */

◆ MCASP_EABORT

#define MCASP_EABORT   (-(6)) /* I/O was aborted before completed */

◆ MCASP_EBADMODE

#define MCASP_EBADMODE   (-(7)) /* Illegal device mode */

◆ MCASP_EOF

#define MCASP_EOF   (-(8)) /* End-of-File was encountered */

◆ MCASP_ENOTIMPL

#define MCASP_ENOTIMPL   (-(9)) /* Operation not implemented or supported */

◆ MCASP_EBADARGS

#define MCASP_EBADARGS   (-(10)) /* Illegal arguments specified */

◆ MCASP_ETIMEOUTUNREC

#define MCASP_ETIMEOUTUNREC   (-(11)) /* Unrecoverable timeout occurred */

◆ MCASP_EINUSE

#define MCASP_EINUSE   (-(12)) /* Device already in use */

◆ MCASP_EINVALIDVAL

#define MCASP_EINVALIDVAL   (-(13)) /* Invalid value encountered (Unexpected) */

◆ MCASP_COMPLETED

#define MCASP_COMPLETED   (0) /* I/O completed successfully */

◆ MCASP_PENDING

#define MCASP_PENDING   (1) /* I/O queued and pending */

◆ MCASP_FLUSHED

#define MCASP_FLUSHED   2

◆ MCASP_ABORTED

#define MCASP_ABORTED   3

Typedef Documentation

◆ Mcasp_GblCallback

typedef void(* Mcasp_GblCallback) (Mcasp_errCbStatus errCbStat)

Global error callback function protype.

This is the global error callback function for the McASP driver. This function is called directly called from ISR context in case of error.

◆ Mcasp_Isr

typedef void(* Mcasp_Isr) (void *arg)

Mcasp Interrupt service routine.

This is Function pointer to the McASP ISR. Interrupt registration takes place by hooking the ISR to the interrrupt number.

◆ Mcasp_QueueElem

McASP queue element.

    Doubly linked list for queue elements.
    Required for Mcasp_IOBuf structure.

◆ MCASP_TiomCallback

typedef void(* MCASP_TiomCallback) (void *arg, MCASP_Packet *packet)

EDMA TC callback function prototype This function is the call back function provided by the application during the mcaspCreateChannel(). This call back function is called every time a TX or RX transaction is completed. The arguments to this function are defined as below.

arg - This callback argument is passed to the driver by the application during mcaspCreateChan(). The driver would pass this argument as is to the

call back function when the TX or RX transaction is completed. The application can then use this argument as they chose in their implementation of the call back function. If the application does not want to use this call back argument, it can be set to NULL during mcaspCreateChan().

packet - This argument returns the MCASP_Packet * which was submitted as a part of mcaspSubmitChan(). Once the transaction is completed, the application can use this to find the details of the transaction which just completed such as the buffer address, size, cmd and other fields of MCASP_Packet.

Enumeration Type Documentation

◆ Mcasp_chanMode_e

enumerated constants for the channel modes supported by Mcasp

Enumerator
MCASP_INPUT 

McASP channel receives data

MCASP_OUTPUT 

McASP channel transmits data

MCASP_INOUT 

McASP channel transmits & recieves data

◆ Mcasp_IOcmd_e

enumerated constants for the commands supported by Mcasp

Enumerator
MCASP_READ 

Command to perform Read data

MCASP_WRITE 

Command to perform Write data

MCASP_ABORT 

Command to abort local transactions

MCASP_FLUSH 

Command to flush transactions

◆ Mcasp_OpMode

enumerated constants for the Transfer modes supported by Mcasp

Enumerator
Mcasp_OpMode_TDM 

TDM Mode for channel operation

Mcasp_OpMode_DIT 

DIT Mode for channel operation

◆ Mcasp_SerializerNum

Enumeration for the MCASP serializer numbers.

Enumerator
Mcasp_SerializerNum_0 

Serializer 0

Mcasp_SerializerNum_1 

Serializer 1

Mcasp_SerializerNum_2 

Serializer 2

Mcasp_SerializerNum_3 

Serializer 3

Mcasp_SerializerNum_4 

Serializer 4

Mcasp_SerializerNum_5 

Serializer 5

Mcasp_SerializerNum_6 

Serializer 6

Mcasp_SerializerNum_7 

Serializer 7

Mcasp_SerializerNum_8 

Serializer 8

Mcasp_SerializerNum_9 

Serializer 9

Mcasp_SerializerNum_10 

Serializer 10

Mcasp_SerializerNum_11 

Serializer 11

Mcasp_SerializerNum_12 

Serializer 12

Mcasp_SerializerNum_13 

Serializer 13

Mcasp_SerializerNum_14 

Serializer 14

Mcasp_SerializerNum_15 

Serializer 15

◆ Mcasp_WordLength

Enumerated constant for wordlength supported by the MCASP device.

Enumerator
Mcasp_WordLength_8 

Word length of 8 bits

Mcasp_WordLength_12 

Word length of 12 bits

Mcasp_WordLength_16 

Word length of 16 bits

Mcasp_WordLength_20 

Word length of 20 bits

Mcasp_WordLength_24 

Word length of 24 bits

Mcasp_WordLength_32 

Word length of 32 bits

◆ Mcasp_WordBitsSelect

Enumerated constant for selecting MSB/LSB word in the slot bits.

Enumerator
Mcasp_WordBitsSelect_LSB 

Select the Least significant 'word' sized bits in the slot bits

Mcasp_WordBitsSelect_MSB 

Select the Most significant 'word' sized bits in the slot

◆ Mcasp_pllDomain

PLL domain to be used by the device.

Enumerator
Mcasp_pllDomain_0 

PLL domain 0

Mcasp_pllDomain_1 

PLL domain 1

Mcasp_pllDomain_NONE 

Not in any pll domain

◆ Mcasp_BufferFormat

Enum to specify the supported buffer formats.

Interleaved and non-interleaved is standard format, this enumeration captures the standard and custom data formats.

Enumerator
Mcasp_BufferFormat_1SER_1SLOT 
Mcasp_BufferFormat_1SER_MULTISLOT_NON_INTERLEAVED 
Mcasp_BufferFormat_1SER_MULTISLOT_INTERLEAVED 
Mcasp_BufferFormat_MULTISER_1SLOT_SER_INTERLEAVED 
Mcasp_BufferFormat_MULTISER_1SLOT_SER_NON_INTERLEAVED 
Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_1 
Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_2 

◆ Mcasp_ioctlCmd

Mcasp Ioctl commands.

Mcaspp Ioctl commands

Enumerator
MCASP_CHAN_RESET 

Reset Device, cmdArg = NONE Channel timeout, cmdArg = NONE

MCASP_CHAN_TIMEDOUT 

Channel reset, cmdArg = NONE

MCASP_DEVICE_RESET 

Reset Device, cmdArg = NONE

Mcasp_IOCTL_DEVICE_RESET 

Enable/Disable mute, cmdArg = (uint32_t *) value for AMUTE register

Mcasp_IOCTL_CNTRL_AMUTE 

Start Mcasp port, cmdArg = NONE

Mcasp_IOCTL_START_PORT 

Stop Mcasp port, cmdArg = NONE

Mcasp_IOCTL_STOP_PORT 

Query AMUTE register, cmdArg = (uint32_t *) variable to store value

Mcasp_IOCTL_QUERY_MUTE 

Loop job modification, cmdArg = (Mcasp_ChanParams *)

Mcasp_IOCTL_CTRL_MODIFY_LOOPJOB 

Mute on, cmdArg = NONE

Mcasp_IOCTL_CTRL_MUTE_ON 

Mute off, cmdArg = NONE

Mcasp_IOCTL_CTRL_MUTE_OFF 

Pause data transfer, cmdArg = NONE

Mcasp_IOCTL_PAUSE 

Resume data transfer, cmdArg = NONE

Mcasp_IOCTL_RESUME 

Set DIT mode, cmdArg = (uint32_t *) value for DITCTL register

Mcasp_IOCTL_SET_DIT_MODE 

Channel timeout, cmdArg = NONE

Mcasp_IOCTL_CHAN_TIMEDOUT 

Channel reset, cmdArg = NONE

Mcasp_IOCTL_CHAN_RESET 

Set channel format, cmdArg = (Mcasp_HwSetupData *)

Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN 

Get format channel info, cmdArg = (Mcasp_HwSetupdata *)

Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN 

Set GBL register values, cmdArg = (Mcasp_HwSetup *)

Mcasp_IOCTL_CNTRL_SET_GBL_REGS 

Set digital loop back mode, cmdArg = (bool *)

Mcasp_IOCTL_SET_DLB_MODE 

Abort all queued requests, cmdArg = NONE

Mcasp_IOCTL_ABORT 

IOCTL to Set the sample rate cmdArg = (uint32_t *)

Mcasp_IOCTL_SET_SAMPLE_RATE 

Ioctl to query the Mcasp specific information. cmdArg = (Mcasp_AudioDevData *)

Mcasp_IOCTL_GET_DEVINFO 

Ioctl to flush the receive FIFO

Mcasp_IOCTL_FLUSH_RCV_FIFO 

Ioctl command to modify the timeout used by the driver for certain wait operations. cmdArg = (uint32_t *)

Mcasp_IOCTL_SET_TIMEOUT 

Ioctl command to check if the driver is compiled in loop job mode or Not. cmdArg = (uint16_t *) TRUE = loop job mode,FALSE = loop job disabled

Mcasp_IOCTL_QUERY_LOOPJOB_MODE 

Ioctl command to collect error stats cmdArg = (Mcasp_errCbStatus *)

Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS 

Ioctl command to reconfigure word width of the channel parameters: Mcasp_ChanParams.wordWidth. cmdArg = (Mcasp_ChanParams *).

Remarks
Only wordWidth of the channel parameters in Mcasp_ChanParams provided via cmdArg is used and all other parameters are ignored.
Mcasp_IOCTL_CHAN_PARAMS_WORD_WIDTH 

Ioctl command to read Tx channel bit clock divide ratio. cmdArg = (uint32_t *) value read from ACLKXCTL:CLKXDIV register.

Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN_CLKXDIV 

Ioctl command to write Tx channel bit clock divide ratio. cmdArg = (uint32_t *) value to write to ACLKXCTL:CLKXDIV register.

Remarks
This command should only be used on a Tx channel with no pending or active transfers. Using the command on a Tx channel with pending or active will produce unexpected results.
Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN_CLKXDIV 

Function Documentation

◆ mcaspBindDev()

int32_t mcaspBindDev ( void **  devp,
int32_t  devId,
void *  devParams 
)

◆ mcaspUnBindDev()

int32_t mcaspUnBindDev ( void *  devp)

◆ mcaspCreateChan()

int32_t mcaspCreateChan ( void **  chanp,
void *  devp,
Mcasp_chanMode_e  mode,
void *  chanParams,
MCASP_TiomCallback  cbFxn,
void *  cbArg 
)

◆ mcaspSubmitChan()

int32_t mcaspSubmitChan ( void *  chanp,
MCASP_Packet ioPacket 
)

◆ mcaspDeleteChan()

int32_t mcaspDeleteChan ( void *  chanp)

◆ mcaspControlChan()

int32_t mcaspControlChan ( void *  chanp,
Mcasp_ioctlCmd  cmd,
void *  cmdArgs 
)

Variable Documentation

◆ Mcasp_PARAMS

const Mcasp_Params Mcasp_PARAMS