/******************************************************************************
*
*  System Name : ARM USB Autdio Class Library
*  File Name   : usb_haudio_rza1.h
*  Contents    : Definitions for USB Mass Storage Class Driver
*  Version     : 0.00.01
*  Device      : ARM
*  Tool-Chain  :
*  OS          :
*
*  Note        :
*
*  Copyright (C) 2014 Renesas Electronics Corporation and
*  Renesas Solutions Corp. All rights reserved.
*
*  History     : Feb.12,2014 Ver.0.00.01
******************************************************************************/
#ifndef __USB_HAUDIO_RZA1_H__
#define __USB_HAUDIO_RZA1_H__


/*******************************************************************************
Includes   <System Includes> , "Project Includes"
*******************************************************************************/
#include "usb_hdrv_rza1.h"


/*******************************************************************************
Macro definitions
*******************************************************************************/

#define    USB_HAUDIO_LINK_COUNT                  10

#define    USB_HAUDIO_LINK_CHANGE                 16

#define    USB_HAUDIO_YES2                        2
#define    USB_HAUDIO_YES                         1
#define    USB_HAUDIO_NO                          0

#define    USB_HAUDIO_SAMPLE_44_1KHZ              (44100)
#define    USB_HAUDIO_SAMPLE_48_0KHZ              (48000)
#define    USB_HAUDIO_SAMPLE_32_0KHZ              (32000)
#define    USB_HAUDIO_SAMPLE_96_0KHZ              (96000)
#define    USB_HAUDIO_MAX_SAMPLE                  USB_HAUDIO_SAMPLE_96_0KHZ

#define    USB_HAUDIO_SUCCESS2                    1
#define    USB_HAUDIO_SUCCESS                     USB_SUCCESS
#define    USB_HAUDIO_ERROR                       USB_ERROR
#define    USB_HAUDIO_STALL                       USB_STALL
#define    USB_HAUDIO_TIMEOUT                     USB_TIMEOUT
#define    USB_HAUDIO_NAK_TIMEOUT                 USB_NAK_TIMEOUT
#define    USB_HAUDIO_DETACH                      USB_DETACH_ERR
#define    USB_HAUDIO_SETUP_ERR                   USB_SETUP_ERR
#define    USB_HAUDIO_CTRL_COM_ERR                USB_CTRL_COM_ERR
#define    USB_HAUDIO_COM_ERR                     USB_COM_ERR
#define    USB_HAUDIO_TYPE_ERROR                  -200

#define    USB_HAUDIO_MAX_DEVADDRESS              10
#define    USB_HAUDIO_MAX_INTERFACE               8
#define    USB_HAUDIO_MAX_SAMPLE_NUM              4

#define    USB_HAUDIO_IF_SUB_CLS_AUDIO_CONTROL    0x01
#define    USB_HAUDIO_IF_SUB_CLS_AUDIO_STREAM     0x02
#define    USB_HAUDIO_IF_SUB_CLS_AUDIO_MIDI       0x03
#define    USB_HAUDIO_IF_CS_INTERFACE             0x24
#define    USB_HAUDIO_IF_CS_AS_GENERAL            0x01
#define    USB_HAUDIO_IF_CS_FORMAT_TYPE           0x02

#define    USB_HAUDIO_IF_HEADER                   0x01
#define    USB_HAUDIO_IF_OUTPUT_TERMINAL          0x03

#define    USB_HAUDIO_INVALID                     0xFFFF

#define    USB_HAUDIO_FIFO_BIG_ENDIAN             0
#define    USB_HAUDIO_FIFO_LITTLE_ENDIAN          1

#define    USB_HAUDIO_CONTROL                     0
#define    USB_HAUDIO_STREAM_WO_EP                1
#define    USB_HAUDIO_STREAM_WI_EP                2

#define    USB_HAUDIO_DEV_DET                     0
#define    USB_HAUDIO_DEV_FULL_ATT                1
#define    USB_HAUDIO_DEV_HIGH_ATT                2

#define    USB_HAUDIO_INTERFACE_NUM_0             0x0000u
#define    USB_HAUDIO_INTERFACE_NUM_1             0x0001u
#define    USB_HAUDIO_INTERFACE_NUM_2             0x0002u
#define    USB_HAUDIO_INTERFACE_NUM_3             0x0003u

#define    USB_HAUDIO_ENDPOINT_NUM_0              0x0000u
#define    USB_HAUDIO_ENDPOINT_NUM_1              0x0001u
#define    USB_HAUDIO_ENDPOINT_NUM_2              0x0002u
#define    USB_HAUDIO_ENDPOINT_NUM_3              0x0003u

#define    USB_HAUDIO_ENTITY_0                    0x0000u
#define    USB_HAUDIO_ENTITY_1                    0x0100u
#define    USB_HAUDIO_ENTITY_2                    0x0200u
#define    USB_HAUDIO_ENTITY_3                    0x0300u
#define    USB_HAUDIO_ENTITY_4                    0x0400u
#define    USB_HAUDIO_ENTITY_5                    0x0500u
#define    USB_HAUDIO_ENTITY_6                    0x0600u
#define    USB_HAUDIO_ENTITY_7                    0x0700u
#define    USB_HAUDIO_ENTITY_8                    0x0800u
#define    USB_HAUDIO_ENTITY_9                    0x0900u
#define    USB_HAUDIO_ENTITY_10                   0x0A00u
#define    USB_HAUDIO_ENTITY_11                   0x0B00u
#define    USB_HAUDIO_ENTITY_12                   0x0C00u
#define    USB_HAUDIO_ENTITY_13                   0x0D00u
#define    USB_HAUDIO_ENTITY_14                   0x0E00u
#define    USB_HAUDIO_ENTITY_15                   0x0F00u

#define    USB_HAUDIO_HOST_TO_DEVICE              0x0000u
#define    USB_HAUDIO_DEVICE_TO_HOST              0x0080u
#define    USB_HAUDIO_REQ_CLASS                   0x0020u
#define    USB_HAUDIO_DEVICE                      0x0000u
#define    USB_HAUDIO_INTERFACE                   0x0001u
#define    USB_HAUDIO_ENDPOINT                    0x0002u

#define    USB_HAUDIO_GET_CUR                     0x8100u
#define    USB_HAUDIO_GET_MIN                     0x8200u
#define    USB_HAUDIO_GET_MAX                     0x8300u
#define    USB_HAUDIO_GET_RES                     0x8400u
#define    USB_HAUDIO_GET_MEM                     0x8500u
#define    USB_HAUDIO_SET_CUR                     0x0100u
#define    USB_HAUDIO_SET_MIN                     0x0200u
#define    USB_HAUDIO_SET_MAX                     0x0300u
#define    USB_HAUDIO_SET_RES                     0x0400u
#define    USB_HAUDIO_SET_MEM                     0x0500u

#define    USB_HAUDIO_MUTE                        0x0100u
#define    USB_HAUDIO_VOLUME                      0x0200u
#define    USB_HAUDIO_BASS                        0x0300u
#define    USB_HAUDIO_MID                         0x0400u
#define    USB_HAUDIO_TREBLE                      0x0500u
#define    USB_HAUDIO_GRAPHIC                     0x0600u
#define    USB_HAUDIO_GAIN                        0x0700u
#define    USB_HAUDIO_DEALY                       0x0800u
#define    USB_HAUDIO_BASS_BOOST                  0x0900u
#define    USB_HAUDIO_LOUDNESS                    0x0A00u

#define    USB_HAUDIO_SAMPLING                    0x0100u
#define    USB_HAUDIO_PITCH                       0x0200u

#define    USB_HAUDIO_MAXPFIELD                   (0x007Fu)
#define    USB_HAUDIO_PIPE_MAXPFIELD              (0x07FFu)

#define    USB_HAUDIO_IITV                        0x0007u
#define    USB_HAUDIO_PCM                         0x0001

#define    USB_HAUDIO_16BPS                       0x02UL    /* bit per sample */
#define    USB_HAUDIO_24BPS                       0x03UL    /* bit per sample */
#define    USB_HAUDIO_24BPS_WITH_PAD              0x04UL    /* bit per sample */


/*******************************************************************************
Typedef definitions
*******************************************************************************/
typedef struct {
    USB_HOST_CFG_PIPETBL_t    *pipe_table;
    uint32_t                  time_out;
} USB_HAUDIO_REGIST_t;

typedef struct {
    uint16_t    Interface;
    uint16_t    EndPointAddress;
    uint16_t    FifoPort;
    uint16_t    OffAltNum;
    uint16_t    OnAltNum;
    uint16_t    PipeNum;
    uint16_t    MaxPacketSize;
    uint16_t    pipe_enable;
    uint32_t    TransSize;
    uint32_t    CurrentSize;
    uint32_t    CurrentCount;
    uint8_t     *CurrentBuff;
    uint32_t    ReloadTransSize;
    uint32_t    ReloadSize;
    uint32_t    ReloadCount;
    uint8_t     *ReloadBuff;
    uint8_t     BitResolution;
    uint8_t     SubframeSize;
    uint8_t     Sample_Num;
    uint32_t    Sample_Rate[USB_HAUDIO_MAX_SAMPLE_NUM];
} USB_HAUDIO_INFO_t;

typedef struct {
    uint16_t    Type;
    uint16_t    Interface;
    uint16_t    AltNum;
} USB_HAUDIO_TYPE_t;

typedef struct {
    uint8_t     SrcId;
    uint8_t     ClockSrcId;
} USB_HAUDIO_CTRL_t;

typedef struct{
    int32_t                audio_dev_status;
    uint16_t               InterfaceNum;
    USB_HAUDIO_TYPE_t      InterfaceType[ USB_HAUDIO_MAX_INTERFACE ];
    USB_HAUDIO_INFO_t      Control;
    USB_HAUDIO_INFO_t      StreamIn;
    USB_HAUDIO_INFO_t      StreamOut;
    USB_HAUDIO_CTRL_t      AudioSrc;
    USB_HAUDIO_REGIST_t    *audio_regist;
} USB_HAUDIO_t;


/*******************************************************************************
Variable Externs
*******************************************************************************/


/*******************************************************************************
Functions Prototypes
*******************************************************************************/


#include "usb0_haudio_rza1.h"


#endif /* __USB_HAUDIO_RZA1_H__ */

/* End of file */
