1 #ifndef _SDR_H 2 #define _SDR_H 3 /* ======= General Parameter ======= */ 4 /* Global configure */ 5 #define DMA_LENGTH_BY_FRAME 6 #define MIXER_SB16 7 8 #include <minix/audio_fw.h> 9 #include <sys/types.h> 10 #include <sys/ioc_sound.h> 11 #include <minix/sound.h> 12 #include <machine/pci.h> 13 #include <sys/mman.h> 14 #include "io.h" 15 16 /* Subdevice type */ 17 #define DAC 0 18 #define ADC 1 19 #define MIX 2 20 21 /* PCI number and driver name */ 22 #define VENDOR_ID 0x13f6 23 #define DEVICE_ID 0x0111 24 #define DRIVER_NAME "CMI8738" 25 26 /* Volume option */ 27 #define GET_VOL 0 28 #define SET_VOL 1 29 30 /* Interrupt control */ 31 #define INTR_ENABLE 1 32 #define INTR_DISABLE 0 33 34 /* Interrupt status */ 35 #define INTR_STS_DAC 0x00000001 36 #define INTR_STS_ADC 0x00000002 37 38 /* ======= Self-defined Parameter ======= */ 39 #define REG_FUNC_CTRL 0x00 40 #define REG_FUNC_CTRL1 0x04 41 #define REG_FORMAT 0x08 42 #define REG_MISC_CTRL 0x18 43 #define REG_SB_DATA 0x22 44 #define REG_SB_ADDR 0x23 45 #define REG_MIX_INPUT 0x25 46 #define REG_EXT_MISC 0x90 47 #define REG_DAC_SAMPLE_COUNT 0x86 48 #define REG_ADC_SAMPLE_COUNT 0x8e 49 #define REG_DAC_DMA_ADDR 0x80 50 #define REG_DAC_DMA_LEN 0x84 51 #define REG_DAC_CUR_ADDR 0x80 52 #define REG_ADC_DMA_ADDR 0x88 53 #define REG_ADC_DMA_LEN 0x8c 54 #define REG_ADC_CUR_ADDR 0x88 55 #define REG_EXT_INDEX 0xf0 56 #define REG_INTR_CTRL 0x0c 57 #define REG_INTR_STS 0x10 58 59 #define FMT_BIT16 0x02 60 #define FMT_STEREO 0x01 61 62 #define MIXER_ADCL 0x3d 63 #define MIXER_ADCR 0x3e 64 #define MIXER_OUT_MUTE 0x3c 65 66 #define CMD_POWER_DOWN 0x80000000 67 #define CMD_RESET 0x40000000 68 #define CMD_ADC_C0 0x00000001 69 #define CMD_ADC_C1 0x00000002 70 #define CMD_N4SPK3D 0x04000000 71 #define CMD_SPDIF_ENA 0x00000200 72 #define CMD_SPDIF_LOOP 0x00000080 73 #define CMD_ENA_C0 0x00010000 74 #define CMD_ENA_C1 0x00020000 75 #define CMD_INTR_C0 0x00010000 76 #define CMD_INTR_C1 0x00020000 77 #define CMD_RESET_C0 0x00040000 78 #define CMD_RESET_C1 0x00080000 79 #define CMD_PAUSE_C0 0x00000004 80 #define CMD_PAUSE_C1 0x00000008 81 82 #define CMD_INTR_ENABLE 0x00030000 83 84 static u32_t g_sample_rate[] = { 85 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 86 }; 87 88 /* Driver Data Structure */ 89 typedef struct aud_sub_dev_conf_t { 90 u32_t stereo; 91 u16_t sample_rate; 92 u32_t nr_of_bits; 93 u32_t sign; 94 u32_t busy; 95 u32_t fragment_size; 96 u8_t format; 97 } aud_sub_dev_conf_t; 98 99 typedef struct DEV_STRUCT { 100 char *name; 101 u16_t vid; 102 u16_t did; 103 u32_t devind; 104 u32_t base[6]; 105 char irq; 106 char revision; 107 u32_t intr_status; 108 } DEV_STRUCT; 109 110 void dev_mixer_write(u32_t *base, u32_t reg, u32_t val); 111 u32_t dev_mixer_read(u32_t *base, u32_t reg); 112 113 #endif 114