⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omap2-audio-twl4030.h

📁 omap3 linux 2.6 用nocc去除了冗余代码
💻 H
📖 第 1 页 / 共 4 页
字号:
	.period_bytes_min = 32,	.period_bytes_max = 8 * 1024,	.periods_min = 16,	.periods_max = 255,	.fifo_size = 0,};static struct snd_pcm_hardware twl4030_pcm_hardware_capture = {	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |		 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),	.formats = (SNDRV_PCM_FMTBIT_S16_LE),	.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |		  SNDRV_PCM_RATE_16000 |		  SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |		  SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |		  SNDRV_PCM_RATE_KNOT),	.rate_min = 8000,	.rate_max = 48000,	.channels_min = 1,	.channels_max = 2,	.buffer_bytes_max = 128 * 1024,	.period_bytes_min = 32,	.period_bytes_max = 8 * 1024,	.periods_min = 16,	.periods_max = 255,	.fifo_size = 0,};static int mixer_dev_id;struct twl_local_info {	/* Global volume control */	u16 play_volume; /* Store the play volume */	u16 rec_volume; /* Store the record volume */	/* Device specific volume control */	u16 hset; /* Store the hset volume */	u16 classd; /* Store the classd volume */	u16 ear; /* Store the ear volume */	u16 line; /* Store the line volume */	u16 mic; /* Store the mic volume */	u16 aux; /* Store aux/FM volume */	u16 sidetone; /* Store sidetone volume */	u16 carkit_out; /* Store carkit output gain */	u16 carkit_in; /* Store carkit input gain */	/* Source Management */	int recsrc; /* current active record sources */	int outsrc; /* current active playback sources */	int mod_cnt;/* how many usages */};static struct twl_local_info twl4030_local = {	.play_volume =  WRITE_LR_VOLUME(DEFAULT_OUTPUT_VOLUME),	.rec_volume = WRITE_LR_VOLUME(DEFAULT_INPUT_VOLUME),	.line = WRITE_LR_VOLUME(DEFAULT_INPUT_LINE_VOLUME),	.mic = WRITE_LR_VOLUME(DEFAULT_INPUT_MIC_VOLUME),	.aux = WRITE_LR_VOLUME(DEFAULT_INPUT_LINE_VOLUME),	.hset = WRITE_LR_VOLUME(DEFAULT_OUTPUT_HSET_VOLUME),	.classd = WRITE_LR_VOLUME(DEFAULT_OUTPUT_SPK_VOLUME),	.ear = WRITE_LEFT_VOLUME(DEFAULT_OUTPUT_EAR_VOLUME),	.sidetone = WRITE_LEFT_VOLUME(DEFAULT_SIDETONE_VOLUME),	.carkit_out = WRITE_LR_VOLUME(DEFAULT_OUTPUT_CARKIT_VOLUME),	.carkit_in = WRITE_LEFT_VOLUME(DEFAULT_INPUT_CARKIT_VOLUME),	.recsrc = DEFAULT_INPUT_LNX_DEVICE,	.outsrc = DEFAULT_OUTPUT_LNX_DEVICE,	.mod_cnt = 0,};/* Configured count - * Codec is configured when this reaches 1 * Codec is shutdown when this reaches 0 */static char twl4030_configured = 0;struct mcbsp_config {	u8 mcbsp_clk_src;	/* source it from prcm? */	u8 srg_clk_src;		/* clks/fclk/clkr/clkx */	u8 srg_clk_sync;	/* free_running or just running */	u8 srg_clk_pol;		/* polarity of srg clk */	u8 tx_clk_pol;          /* TX clock polarity */	u8 tx_clk_src;		/* internal/external (master based) */	u8 rx_clk_pol;          /* TX clock polarity */	u8 rx_clk_src;		/* internal/external (master based) */	u8 fs_clk_pol;		/* Frame sync polarity */	u8 tx_polarity;		/* TX polarity */	u8 rx_polarity;		/* RX polarity */	u8 rx_ip_clk;           /* Rx input clock */	u8 tx_ip_clk;           /* Tx input clock */	omap2_mcbsp_transfer_params tx_params; /* Transmit parameters */	omap2_mcbsp_transfer_params rx_params; /* Recieve parameters */};/* Default volume */static int current_input = DEFAULT_INPUT_TWL_DEVICE;static int current_output = DEFAULT_OUTPUT_TWL_DEVICE;/* Switch flags */u8 handsfree_en = 1;u8 hsmic_en     = 1;u8 main_mic_en  = 1;u8 sub_mic_en   = 1;/* To Store the default sample rate */static long audio_samplerate = AUDIO_RATE_DEFAULT;struct sample_rate_info_t {	u16 rate;	u8 apll;};/* Hint - optimization wise move the most used values up the list */static const struct sample_rate_info_t valid_sample_rates[] = {	{.rate = 8000,.apll = AUDIO_MODE_RATE_08_000},	{.rate = 16000,.apll = AUDIO_MODE_RATE_16_000},	{.rate = 44100,.apll = AUDIO_MODE_RATE_44_100},	{.rate = 11025,.apll = AUDIO_MODE_RATE_11_025},	{.rate = 12000,.apll = AUDIO_MODE_RATE_12_000},	{.rate = 22050,.apll = AUDIO_MODE_RATE_22_050},	{.rate = 24000,.apll = AUDIO_MODE_RATE_24_000},	{.rate = 32000,.apll = AUDIO_MODE_RATE_32_000},	{.rate = 48000,.apll = AUDIO_MODE_RATE_48_000},	/* Dont support 96Khz -requires HSCLK >26Mhz	   { .rate = 96000, .apll = AUDIO_MODE_RATE_96_000 }, */};#define NUMBER_OF_RATES_SUPPORTED (sizeof (valid_sample_rates)/\				   sizeof (struct sample_rate_info_t))/* Give time for these to settle down * one frame (worst case is at 8000hz) = 125 uSec * wait two frame duration each - giving dma a chance to push data thru also * =125*4= 500uSec */#define TWL4030_MCBSP2_3430SDP_PRESCALE_TIME 500/* if we would like to listen to mono sound as stereo on stereo devices */#undef MONO_MODE_SOUNDS_STEREO/* How long to wait for stream to remain active?in Jiffies */#define TIMEOUT_WAIT_FOR_ACTIVE       20/* T2 GPIO for External Mute control - required for pop noise */#define T2_AUD_EXT_MUT_GPIO 6#define GPIO_DATA_DIR  0x03#define GPIO_CLR  0x09#define GPIO_SET  0x0Cstatic u8 current_bitspersample = AUDIO_SAMPLE_DATA_WIDTH_16;static u8 current_stereomode = STEREO_MODE;/* To handle transfer errors.. */static int tx_err, rx_err;/******************** MODULES SPECIFIC FUNCTION PROTOTYPES ********************/static inline int audio_twl4030_write(u8 address, u8 data);static inline int audio_twl4030_read(u8 address);static inline int twl4030_codec_on(void);static inline int twl4030_codec_off(void);static int twl4030_enable_output(void);static int twl4030_disable_output(void);static int twl4030_enable_input(void);static int twl4030_disable_input(void);static int twl4030_disable_input(void);static int twl4030_select_source(int flag, int val);static int twl4030_setvolume(int flag, u8 gain_l, u8 gain_r);static int twl4030_codec_conf_data_path(void);static int twl4030_conf_data_interface(void);static int twl4030_set_samplerate(long sample_rate);static int twl4030_stereomode_set(int mode, int dsp);static void twl4030_unconfigure(void);static int twl4030_configure(void);static void twl4030_mcbsp_dma_cb(u16 ch_status, void *arg);static int omap_twl4030_transfer(int mode, void *buffer_phy,u32 size, void *arg);static int omap_twl4030_transfer_stop(int mode);static int omap_twl4030_transfer_posn(int mode);static int omap_twl4030_transfer_init(int mode);static int omap_twl4030_initialize(void);static void omap_twl4030_shutdown(void);static int omap_twl4030_sidle(u32 level);static int omap_twl4030_probe(void);static int omap_twl4030_mixer_init(struct snd_card *card);static int omap_twl4030_mixer_shutdown(struct snd_card *card);/******************** DATA STRUCTURES USING FUNCTION POINTERS *****************//* * The TWL4030 will always use stereo I2S protocol to communicate * * McBSP Configuration Required: * Stereo 16 bit:(default) * ------------- * Single phase, FSYNC=Rising, words=1 DMA->Normal,32bit DXR * * Stereo 24 bit: * ------------- * Single phase, FSYNC=Falling, words=2 DMA->Normal,32bit DXR * * Mono 16 bit: * ------------ * Single phase, FSYNC=Rising, words=1 DMA->Normal,16 bit DXR+2 * OR * Single phase, FSYNC=Falling, words=1 DMA->Normal,32bit DXR * * Mono 24 bit: * ------------ * Single phase, FSYNC=Falling, words=2 DMA-> ei=1,fi=-1,32bit DXR * */static struct mcbsp_config plat_mcbsp_config = {	.mcbsp_clk_src = OMAP2_MCBSP_FCLKSRC_PRCM,	/* Driven by twl4030 */	.srg_clk_src = OMAP2_MCBSP_SRGCLKSRC_CLKX,	.tx_clk_src = OMAP2_MCBSP_TXFSYNC_EXTERNAL,	.rx_clk_src = OMAP2_MCBSP_RXFSYNC_EXTERNAL,	.rx_ip_clk = OMAP2_MCBSP_CLKRXSRC_EXTERNAL,	.tx_ip_clk = OMAP2_MCBSP_CLKTXSRC_EXTERNAL,	.srg_clk_sync = OMAP2_MCBSP_SRG_FREERUNNING,	.tx_polarity = OMAP2_MCBSP_FS_ACTIVE_LOW,	.rx_polarity = OMAP2_MCBSP_FS_ACTIVE_LOW,	.srg_clk_pol = OMAP2_MCBSP_CLKX_POLARITY_FALLING,	.tx_clk_pol = OMAP2_MCBSP_CLKX_POLARITY_RISING,	.rx_clk_pol = OMAP2_MCBSP_CLKR_POLARITY_RISING,	/* we will start with right channel and transmit the MSB of DXR */	.fs_clk_pol = OMAP2_MCBSP_FS_ACTIVE_HIGH,	/* I2S */	.tx_params = {			       .data_type = OMAP2_MCBSP_WORDLEN_NONE,			       .skip_alt = OMAP2_MCBSP_SKIP_NONE,			       .auto_reset = OMAP2_MCBSP_AUTO_XRST,			       .phase = OMAP2_MCBSP_FRAME_DUALPHASE,			       .data_delay = OMAP2_MCBSP_DATADELAY1,	/* 1 bit delay expected */			       .reverse_compand = OMAP2_MCBSP_MSBFIRST,	/* Set msb first */			       .word_length1 = OMAP2_MCBSP_WORDLEN_16,	/* RWDLEN1 */			       .word_length2 = OMAP2_MCBSP_WORDLEN_16,	/* RWDLEN2 -dnt care*/			       .frame_length1 = OMAP2_MCBSP_FRAMELEN_1,	/* RFRLEN1 */			       .frame_length2 = OMAP2_MCBSP_FRAMELEN_1,	/* RFRLEN2 -dnt care*/			       .justification = OMAP2_MCBSP_RJUST_ZEROMSB,	/* RJUST and fill 0s */			       .dxena = 0,			       .dxendly = 0,			       .callback = twl4030_mcbsp_dma_cb,			       },	.rx_params = {			       .data_type = OMAP2_MCBSP_WORDLEN_NONE,			       .skip_alt = OMAP2_MCBSP_SKIP_NONE,			       .auto_reset = OMAP2_MCBSP_AUTO_RRST,			       .phase = OMAP2_MCBSP_FRAME_DUALPHASE,			       .data_delay = OMAP2_MCBSP_DATADELAY1,	/* 1 bit delay expected */			       .reverse_compand = OMAP2_MCBSP_MSBFIRST,	/* Set msb first */			       .word_length1 = OMAP2_MCBSP_WORDLEN_16,	/* RWDLEN1 */			       .word_length2 = OMAP2_MCBSP_WORDLEN_16,	/* RWDLEN2 -dntcare*/			       .frame_length1 = OMAP2_MCBSP_FRAMELEN_1,	/* RFRLEN1 */			       .frame_length2 = OMAP2_MCBSP_FRAMELEN_1,	/* RFRLEN2 */			       .justification = OMAP2_MCBSP_RJUST_ZEROMSB,	/* RJUST and fill 0s */			       .dxena = 0,			       .dxendly = 0,			       .callback = twl4030_mcbsp_dma_cb,			       },};static int twl4030_default_samplerate(void){	return AUDIO_RATE_DEFAULT;}/* To store characteristic info regarding the codec for the audio driver */static struct omap_alsa_codec omap_twl_codec = {	.name = CODEC_NAME,	.pcm_hw_constraint_list = &twl4030_pcm_hw_constraint_list,	.pcm_hardware_playback = &twl4030_pcm_hardware_playback,	.pcm_hardware_capture = &twl4030_pcm_hardware_capture,	.codec_probe = omap_twl4030_probe,	.codec_init = omap_twl4030_initialize,	.codec_shutdown = omap_twl4030_shutdown,	.codec_sidle = omap_twl4030_sidle,	.codec_set_samplerate = twl4030_set_samplerate,	.codec_set_stereomode = twl4030_stereomode_set,	.codec_default_samplerate = twl4030_default_samplerate,	.codec_transfer_init = omap_twl4030_transfer_init,	.codec_transfer_start = omap_twl4030_transfer,	.codec_transfer_stop = omap_twl4030_transfer_stop,	.codec_transfer_posn = omap_twl4030_transfer_posn,	.mixer_init = omap_twl4030_mixer_init,	.mixer_shutdown = omap_twl4030_mixer_shutdown,};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -