- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

csl_audioClass.h
Go to the documentation of this file.

    00001 /*  ============================================================================
    00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
    00003  *
    00004  *   Use of this software is controlled by the terms and conditions found in the
    00005  *   license agreement under which this software has been supplied.
    00006  *  ============================================================================
    00007  */
    00008
    00016 /* ============================================================================
    00017  * Revision History
    00018  * ================
    00019  * 10-Dec-2008 Created
    00020  * 21-Jan-2009 Modified for code review comments
    00021  * ============================================================================
    00022  */
    00023
    00040 #ifndef _CSL_AUDIOCLASS_H_
    00041 #define _CSL_AUDIOCLASS_H_
    00042
    00043 #ifdef __cplusplus
    00044 extern "C" {
    00045 #endif
    00046
    00047 #include <cslr.h>
    00048 #include <csl_error.h>
    00049 #include <csl_types.h>
    00050 #include <cslr_usb.h>
    00051 #include <csl_usb.h>
    00052 #include <soc.h>
    00053 #include <csl_general.h>
    00054
    00055
    00074 /*****************************************************************************\
    00075           USB AC global macro declarations                                    *
    00076 \*****************************************************************************/
    00083 #define CSL_AC_DEVICE_DESCRIPTOR_TYPE                         (0x01)
    00084
    00085 #define CSL_AC_CONFIGURATION_DESCRIPTOR_TYPE                  (0x02)
    00086
    00087 #define CSL_AC_STRING_DESCRIPTOR_TYPE                         (0x03)
    00088
    00089 #define CSL_AC_INTERFACE_DESCRIPTOR_TYPE                      (0x04)
    00090
    00091 #define CSL_AC_ENDPOINT_DESCRIPTOR_TYPE                       (0x05)
    00092
    00093 #define CSL_AC_POWER_DESCRIPTOR_TYPE                          (0x06)
    00094
    00095 #define CSL_AC_HID_DESCRIPTOR_TYPE                            (0x21)
    00096
    00099 #define CSL_AC_FEATURE_ENDPOINT_STALL                         (0x0000)
    00100
    00101 #define CSL_AC_FEATURE_REMOTE_WAKEUP                          (0x0001)
    00102
    00104 #define CSL_AC_DEVICE_DESCR_MAX_LEN                           (20)
    00105
    00106 #define CSL_AC_DEV_QUAL_DESCR_MAX_LEN                         (12)
    00107
    00108 #define CSL_AC_CONFIG_DESCR_MAX_LEN                           (124)
    00109
    00110 #define CSL_AC_INTER_DESCR_MAX_LEN                            (12)
    00111
    00112 #define CSL_AC_STRING_DESCR_LANGID_MAX_LEN                    (12)
    00113
    00114 #define CSL_AC_AUDIO_TYPE_MONO                                (0x01)
    00115
    00116 #define CSL_AC_AUDIO_TYPE_STEREO                              (0x02)
    00117
    00120 #define CSL_AC_VERIFY_PASSED                                  (0x0)
    00121
    00122 #define CSL_AC_VERIFY_FAILED                                  (0x1)
    00123
    00124 #define CSL_AC_UNIT_REMOVEABLE                                (0x1)
    00125
    00126 #define CSL_AC_CURRDEV_STAT                                   (0x01)
    00127
    00128 #define CSL_AC_CURRINTRF_STAT                                 (0x00)
    00129
    00130 #define CSL_AC_NO_ENDPTOBJECT                                 (5)
    00131
    00132 #define CSL_AC_DEVDESC_LEN                                    (10)
    00133
    00134 #define CSL_AC_CONFDESC_LEN                                   (6)
    00135
    00136 #define CSL_AC_MS_INTDESC_LEN                                 (6)
    00137
    00138 #define CSL_AC_MS_ISOOUT_ENDPTDESC_LEN                        (5)
    00139
    00140 #define CSL_AC_MS_ISOIN_ENDPTDESC_LEN                         (5)
    00141
    00142 #define CSL_AC_STRDESC_LANGID_LEN                             (4)
    00143
    00144 #define CSL_AC_SCSI_INQUIRY_LEN                               (50)
    00145
    00146 #define CSL_AC_SENSEDATA_LEN                                  (15)
    00147
    00148 #define CSL_AC_LUN_MAX                                        (4)
    00149
    00150 #define CSL_AC_CBWSIZE                                        (17)
    00151
    00152 #define CSL_AC_CSWSIZE                                        (8)
    00153
    00154 #define CSL_AC_READCAP                                        (6)
    00155
    00156 #define CSL_AC_CTRLBUFF_LEN                                   (5)
    00157
    00158 #define CSL_AC_SCSI_INQUIRY_CONF_LEN                          (24)
    00159
    00160 #define CSL_AC_DEVICE_CLASS_STORAGE                           (0x08)
    00161
    00162 #define CSL_AC_SCSI_DATA_PROTECT                              (0x0007)
    00163
    00164 #define CSL_AC_REQUEST_AUDIO_CLASS                            (0x20)
    00165
    00166 #define CSL_AC_GET_BUF_LEN                                    (0x04)
    00167
    00170 #define CSL_AC_REQUEST_GET_STATUS                             (0x8000)
    00171
    00172 #define CSL_AC_REQUEST_CLEAR_FEATURE                          (0x0001)
    00173
    00174 #define CSL_AC_REQUEST_SET_CUR                                (0x2001)
    00175
    00176 #define CSL_AC_REQUEST_GET_CUR                                (0xA081)
    00177
    00178 #define CSL_AC_REQUEST_SET_MIN                                (0x2002)
    00179
    00180 #define CSL_AC_REQUEST_GET_MIN                                (0xA082)
    00181
    00182 #define CSL_AC_REQUEST_SET_MAX                                (0x2003)
    00183
    00184 #define CSL_AC_REQUEST_GET_MAX                                (0xA083)
    00185
    00186 #define CSL_AC_REQUEST_SET_RES                                (0x2004)
    00187
    00188 #define CSL_AC_REQUEST_GET_RES                                (0xA084)
    00189
    00190 #define CSL_AC_VOLUME_CTRL_BUF_LEN                            (6)
    00191
    00192 #define USB_AC_FEATURE_UNIT_MUTE_CTRL                         (0x01)
    00193
    00194 #define USB_AC_FEATURE_UNIT_VOLUME_CTRL                       (0x02)
    00195
    00196 #define USB_AC_FEATURE_UNIT_LEFT_RIGHT_VOLUME                 (0x00)
    00197
    00198 #define USB_AC_FEATURE_UNIT_LEFT_VOLUME                       (0x01)
    00199
    00200 #define USB_AC_FEATURE_UNIT_RIGHT_VOLUME                      (0x02)
    00201
    00203 #define CSL_AC_REQUEST_SET_FEATURE                            (0x0003)
    00204
    00205 #define CSL_AC_REQUEST_SET_ADDRESS                            (0x0005)
    00206
    00207 #define CSL_AC_REQUEST_GET_DESCRIPTOR                         (0x8006)
    00208
    00209 #define CSL_AC_REQUEST_SET_DESCRIPTOR                         (0x0007)
    00210
    00211 #define CSL_AC_REQUEST_GET_CONFIGURATION                      (0x8008)
    00212
    00213 #define CSL_AC_REQUEST_SET_CONFIGURATION                      (0x0009)
    00214
    00215 #define CSL_AC_REQUEST_GET_INTERFACE                          (0x800A)
    00216
    00217 #define CSL_AC_REQUEST_SET_INTERFACE                          (0x000B)
    00218
    00219 #define CSL_AC_REQUEST_SYNC_FRAME                             (0x800C)
    00220
    00221 #define CSL_AC_REQUEST_ISO_ONLY_RESET                         (0x20FF)
    00222
    00223 #define CSL_AC_REQUEST_GET_MAX_LUN                            (0xA0FE)
    00224
    00225 #define CSL_AC_REQUEST_TYPE_BASE                              (0x80)
    00226
    00227 #define CSL_AC_REQUEST_TYPE_DEVICE_STATUS                     (0x0)
    00228
    00229 #define CSL_AC_REQUEST_TYPE_INTERFACE_STATUS                  (0x1)
    00230
    00231 #define CSL_AC_REQUEST_TYPE_EP_STATUS                         (0x2)
    00232
    00235 #define CSL_AC_DEVICE_SUSPENDED                               (0x01)
    00236
    00237 #define CSL_AC_DEVICE_NOT_SUSPENDED                           (0x0)
    00238
    00239 #define CSL_AC_LUN_LOCKED                                     (0x01)
    00240
    00241 #define CSL_AC_LUN_NOT_LOCKED                                 (0x0)
    00242
    00243 #define CSL_AC_ACTIVITY_PRESENT                               (0x01)
    00244
    00245 #define CSL_AC_ACTIVITY_NOT_PRESENT                           (0x0)
    00246
    00248 #define CSL_AC_16BIT_MASK                                     (0xFFFF)
    00249
    00250 #define CSL_AC_16BIT_SHIFT                                    (16)
    00251
    00253 #define CSL_AC_24BIT_SHIFT                                    (24)
    00254
    00256 #define CSL_AC_8BIT_MASK                                      (0xFF)
    00257
    00258 #define CSL_AC_8BIT_HIGH_MASK                                 (0xFF00)
    00259
    00260 #define CSL_AC_8BIT_SHIFT                                     (8)
    00261
    00262 #define CSL_AC_UNICODE_SIZE                                   (66)
    00263
    00265 #define CSL_AC_SENSE_DATA0_DEFVAL                             (26)
    00266
    00267 #define CSL_AC_SENSE_DATA1_DEFVAL                             (0)
    00268
    00269 #define CSL_AC_SENSE_DATA2_DEFVAL                             (0x0070)
    00270
    00271 #define CSL_AC_SENSE_DATA3_DEFVAL                             (0x0000)
    00272
    00273 #define CSL_AC_SENSE_DATA4_DEFVAL                             (0x0000)
    00274
    00275 #define CSL_AC_SENSE_DATA5_DEFVAL                             ((11<<8) | 0)
    00276
    00278 #define CSL_AC_READ_CAPACITY0_DEFVAL                          (8)
    00279
    00281 #define CSL_AC_CSW0_DEFVAL                                    (0)
    00282
    00283 #define CSL_AC_CSW1_DEFVAL                                    (0x5355)
    00284
    00285 #define CSL_AC_CSW2_DEFVAL                                    (0x5342)
    00286
    00288 #define CSL_AC_ERROR_BASE                             (CSL_EUSB_FIRST)
    00289
    00290 #define CSL_AC_INVALID_REQUEST_HANDLER                (CSL_AC_ERROR_BASE - 1)
    00291
    00293 #define CSL_AC_REQUEST_ARGS     CSL_UsbDevNum         devNum,           \
    00294                                 CSL_UsbSetupStruct    *usbSetup,        \
    00295                                 pUsbEpHandle          hInEp,            \
    00296                                 pUsbEpHandle          hOutEp,           \
    00297                                 void                  *pAcObj
    00298
    00303 /**************************************************************************\
    00304 * USB AC global typedef declarations                                       *
    00305 \**************************************************************************/
    00306
    00313 typedef enum {
    00314     /* Don't call request again until new SETUP                              */
    00315     CSL_AC_REQUEST_DONE = 0,
    00316     /* STALL the control endpoint                                            */
    00317     CSL_AC_REQUEST_STALL,
    00318     /* Send a 0 length IN packet                                             */
    00319     CSL_AC_REQUEST_SEND_ACK,
    00320     /* Prepare to receive 0 length OUT packet                                */
    00321     CSL_AC_REQUEST_GET_ACK,
    00322     /* Notify handler when IN data has been transmitted                      */
    00323     CSL_AC_REQUEST_DATA_IN,
    00324     /* Notify handler when OUT data has been received                        */
    00325     CSL_AC_REQUEST_DATA_OUT
    00326 } CSL_AcRequestRet;
    00327
    00331 typedef enum {
    00333     CSL_AC_MEDIACCESS_OVERFLOW,
    00335     CSL_AC_MEDIACCESS_SUCCESS,
    00337     CSL_AC_MEDIACCESS_NOTPRESENT,
    00339     CSL_AC_MEDIACCESS_WRITEPROTECT,
    00341     CSL_AC_MEDIACCESS_BADMEDIA
    00342 } CSL_AcMediaStatus;
    00343
    00347 typedef enum {
    00349     CSL_AC_UNLOCK = 0,
    00351     CSL_AC_LOCK
    00352 } CSL_AcMediaLockStatus;
    00353
    00357 typedef enum {
    00359     CSL_AC_DEVICE_DESCR = 0,
    00361     CSL_AC_DEVICE_QUAL_DESCR,
    00363     CSL_AC_CONFIG_DESCR,
    00365     CSL_AC_INTERFACE_DESCR,
    00367     CSL_AC_STRING_LANGID_DESC
    00368 } CSL_AcDescrId;
    00369
    00373 /**************************************************************************\
    00374 * USB AC global data structure declarations                                *
    00375 \**************************************************************************/
    00376
    00387 typedef struct CSL_AcRequestStruct {
    00389     WORD                request;
    00391     CSL_AcRequestRet    (*fpRequestHandler)(CSL_AC_REQUEST_ARGS);
    00392 } CSL_AcRequestStruct;
    00393
    00400 typedef struct CSL_AcInitStructApp {
    00402     void                   *pAcObj;
    00404     Uint16                 pId;
    00406     Uint16                 vId;
    00408     Uint16                 numLun;
    00410     Uint16                 txPktSize;
    00412     Uint16                 rxPktSize;
    00414     char                   **strDescrApp;
    00417     Uint16                 *lbaBufferApp;
    00419     CSL_AcRequestStruct    *acReqTableApp;
    00422     void                   (*isoHandler)();
    00425     void                   (*ctrlHandler)();
    00427     CSL_AcMediaStatus      (*playAudioApp)(Uint16 , Uint16* , Uint16*, void*);
    00429     CSL_AcMediaStatus      (*stopAudioApp)(Uint16 , void* );
    00431     CSL_AcMediaStatus      (*recordAudioApp)(Uint16 , Uint16* , Uint16*, void*);
    00433     CSL_AcMediaStatus      (*mediaGetPresentStateApp)(Uint16);
    00435     CSL_AcMediaStatus      (*mediaInitApp)(Uint16);
    00437     CSL_AcMediaStatus      (*mediaEjectApp)(Uint16);
    00439     CSL_AcMediaStatus      (*mediaLockUnitApp)(Uint16,CSL_AcMediaLockStatus);
    00441     Uint32                 (*getMediaSizeApp)(Uint16);
    00442 } CSL_AcInitStructApp;
    00443
    00445 typedef CSL_AcInitStructApp  *pAcAppClassHandle;
    00446
    00453 typedef struct CSL_AcLunAttribApp {
    00455     Uint32    lbaSizeApp;
    00457     Uint32    mediaSizeApp;
    00459     Uint16    removeableApp;
    00461     Uint16    scsiInquiryConfData [CSL_AC_SCSI_INQUIRY_CONF_LEN];
    00463     Uint16    mediaStateApp;
    00465     Uint16    readwriteApp;
    00466 } CSL_AcLunAttribApp;
    00467
    00469 typedef CSL_AcLunAttribApp   *pAcAppLunAttribHandle;
    00470
    00472 typedef  CSL_AcRequestRet (*fpAC_REQ_HANDLER)(CSL_AC_REQUEST_ARGS);
    00473
    00481 typedef struct CSL_AcLogicalUnit {
    00483     Uint16    scsiInquiryData[CSL_AC_SCSI_INQUIRY_LEN];
    00486     Uint32    mediaSize;
    00488     Uint32    currLba;
    00490     Uint32    lbaSize;
    00492     Uint16    removeable;
    00494     Uint16    mediaState;
    00496     Uint16    readwrite;
    00498     Uint16    lbaCnt;
    00500     Uint16    verifyFlag;
    00501 } CSL_AcLogicalUnit;
    00502
    00508 typedef struct CSL_AcObject {
    00510     CSL_AcMediaStatus    (*recordAudio)(Uint16 , Uint16* , Uint16*, void*);
    00512     CSL_AcMediaStatus    (*playAudio)(Uint16 , Uint16* , Uint16*, void*);
    00514     CSL_AcMediaStatus    (*stopAudio)(Uint16 , void*);
    00516     CSL_AcMediaStatus    (*mediaGetPresentState)(Uint16 );
    00518     CSL_AcMediaStatus    (*mediaInit)(Uint16 );
    00520     CSL_AcMediaStatus    (*mediaEject)(Uint16 );
    00522     CSL_AcMediaStatus    (*mediaLockUnit)(Uint16,CSL_AcMediaLockStatus);
    00524     Uint32               (*getMediaSize)(Uint16 );
    00526     Uint16               *lbaBuffer;
    00528     Uint32                cbwDataTransferLength;
    00530     CSL_AcLogicalUnit    lun[CSL_AC_LUN_MAX];
    00532     Uint16               senseData[CSL_AC_SENSEDATA_LEN];
    00534     Uint16               activityPresentFlag;
    00536     Uint16               csw[CSL_AC_CSWSIZE];
    00538     Uint16               readCapacity[CSL_AC_READCAP];
    00540     Uint16               cbw[CSL_AC_CBWSIZE];
    00542     CSL_UsbEpObj         isoInEpObj;
    00544     CSL_UsbEpObj         isoOutEpObj;
    00546     Uint16               noOfLun;
    00548     Uint16               mediaState;
    00550     Uint16               playBackActive;
    00552     Uint16               mediaInitDone;
    00554     Uint16               tempBuffer[4];
    00555 } CSL_AcObject;
    00556
    00562 typedef struct CSL_AcCtrlObject {
    00564     CSL_UsbEpObj           ctrlInEpObj;
    00566     CSL_UsbDevNum          devNum;
    00568     CSL_UsbEpObj           ctrlOutEpObj;
    00570     Uint16                 suspendFlag;
    00572     pUsbEpHandle           hEpObjArray[CSL_AC_NO_ENDPTOBJECT];
    00574     CSL_UsbSetupStruct     usbSetup;
    00576     Uint16                 leftVolBuf[CSL_AC_VOLUME_CTRL_BUF_LEN];
    00578     Uint16                 rightVolBuf[CSL_AC_VOLUME_CTRL_BUF_LEN];
    00580     Uint16                 leftRightVolBuf[2*CSL_AC_VOLUME_CTRL_BUF_LEN];
    00582     Uint16                 muteCtrlBuf[CSL_AC_VOLUME_CTRL_BUF_LEN];
    00584     Uint16                 getMinBuffer[CSL_AC_GET_BUF_LEN];
    00586     Uint16                 getMaxBuffer[CSL_AC_GET_BUF_LEN];
    00588     Uint16                 getResBuffer[CSL_AC_GET_BUF_LEN];
    00590     Uint16                 dummydesc[63];
    00592     Uint16                 deviceQualifierDescr[CSL_AC_DEV_QUAL_DESCR_MAX_LEN];
    00594     Uint16                 deviceDescr[CSL_AC_DEVICE_DESCR_MAX_LEN];
    00596     Uint16                 confDescr[CSL_AC_CONFIG_DESCR_MAX_LEN];
    00598     Uint16                 audioClassIntDescr[CSL_AC_INTER_DESCR_MAX_LEN];
    00600     Uint16 audioClassIsoOutEndptDescr[CSL_AC_MS_ISOOUT_ENDPTDESC_LEN];
    00602     CSL_UsbDataStruct      audioClassInterfcLnk;
    00604     Uint16 audioClassIsoInEndptDescr[CSL_AC_MS_ISOIN_ENDPTDESC_LEN];
    00606     CSL_UsbDataStruct      audioClassIsoOutEndptLnk;
    00608     Uint16                 stringDescrLangid[CSL_AC_STRING_DESCR_LANGID_MAX_LEN];
    00610     Uint16                 curConfigStat;
    00612     CSL_UsbDataStruct      audioClassIsoInEndptLnk;
    00614     Uint16                 ctrlBuffer[CSL_AC_CTRLBUFF_LEN];
    00616     CSL_UsbDataStruct      configDescrLnk;
    00618     char                   **strDescr;
    00620     CSL_AcRequestStruct    *acReqTable;
    00622     CSL_AcRequestRet        (*fpRequestHandler)(CSL_AC_REQUEST_ARGS);
    00623 } CSL_AcCtrlObject;
    00624
    00630 typedef struct CSL_AcClassStruct {
    00632     CSL_AcCtrlObject    ctrlHandle;
    00634     CSL_AcObject        acHandle;
    00635 } CSL_AcClassStruct;
    00636
    00638 typedef CSL_AcClassStruct  *pAcClassHandle;
    00639
    00643 /**************************************************************************\
    00644 * USB AC function declarations                                            *
    00645 \**************************************************************************/
    00646
    00694 CSL_Status AC_Open(pAcAppClassHandle    pAppClassHandle);
    00695
    00740 CSL_Status AC_Close(pAcAppClassHandle    pAppClassHandle);
    00741
    00789 CSL_Status AC_Ctrl(void    *pAcObj);
    00790
    00838 CSL_Status AC_Iso(void    *pAcObj);
    00839
    00885 Uint16 AC_GetactivityFlagStatus(void    *pAcObj);
    00886
    00932 Uint16 AC_GetsuspendFlagStatus(void    *pAcObj);
    00933
    00979 CSL_Status AC_initDescriptors(void             *pAcObj,
    00980                               Uint16           *descBuf,
    00981                               CSL_AcDescrId    descrId,
    00982                               Uint16           descrLen);
    00983
    01018 static CSL_Status AC_initAcVal(CSL_AcObject    *pAcHandle);
    01019
    01070 CSL_AcRequestRet AC_reqGetDescriptor(CSL_UsbDevNum         devNum,
    01071                                      CSL_UsbSetupStruct    *usbSetup,
    01072                                      pUsbEpHandle          hInEp,
    01073                                      pUsbEpHandle          hOutEp,
    01074                                      void                  *pAcObj);
    01075
    01130 CSL_AcRequestRet AC_reqSetCurrent(CSL_UsbDevNum           devNum,
    01131                                     CSL_UsbSetupStruct    *usbSetup,
    01132                                     pUsbEpHandle          hInEp,
    01133                                     pUsbEpHandle          hOutEp,
    01134                                     void                  *pAcObj);
    01135
    01190 CSL_AcRequestRet AC_reqGetCurrent(CSL_UsbDevNum         devNum,
    01191                                   CSL_UsbSetupStruct    *usbSetup,
    01192                                   pUsbEpHandle          hInEp,
    01193                                   pUsbEpHandle          hOutEp,
    01194                                   void                  *pAcObj);
    01195
    01250 CSL_AcRequestRet AC_reqGetMinimum(CSL_UsbDevNum         devNum,
    01251                                   CSL_UsbSetupStruct    *usbSetup,
    01252                                   pUsbEpHandle          hInEp,
    01253                                   pUsbEpHandle          hOutEp,
    01254                                   void                  *pAcObj);
    01255
    01310 CSL_AcRequestRet AC_reqGetMaximum(CSL_UsbDevNum         devNum,
    01311                                   CSL_UsbSetupStruct    *usbSetup,
    01312                                   pUsbEpHandle          hInEp,
    01313                                   pUsbEpHandle          hOutEp,
    01314                                   void                  *pAcObj);
    01315
    01370 CSL_AcRequestRet AC_reqGetResolution(CSL_UsbDevNum         devNum,
    01371                                      CSL_UsbSetupStruct    *usbSetup,
    01372                                      pUsbEpHandle          hInEp,
    01373                                      pUsbEpHandle          hOutEp,
    01374                                      void                  *pAcObj);
    01375
    01431 CSL_AcRequestRet AC_reqSetInterface(CSL_UsbDevNum         devNum,
    01432                                     CSL_UsbSetupStruct    *usbSetup,
    01433                                     pUsbEpHandle          hInEp,
    01434                                     pUsbEpHandle          hOutEp,
    01435                                     void                  *pAcObj);
    01436
    01442 #ifdef __cplusplus
    01443 }
    01444 #endif
    01445
    01446 #endif    // _CSL_AUDIOCLASS_H_
    01447