piSmasher Configuration Libraries
piSmasher peripheral device configuration libraries
tlv320aic3104.h File Reference

TLV320AIC3104 Audio Codec FreeBSD. More...

#include <stdio.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  aic3x_asd_if_cfg
 
struct  aic3x_gain
 
struct  aic3x_cfg
 
struct  aic3x_dev
 

Macros

#define AIC3X_ADDR   (0x18U)
 
#define PAGE_REG_ADDR(__PAGE__, __ADDR__)   ((((uint16_t)(__PAGE__)) << 8) | ((uint16_t)(__ADDR__) & 0x00FFU))
 
#define AIC3X_SOFT_RESET   (0x80U)
 
#define DATAPATH_FREF_MASK   (1 << 7)
 
#define DATAPATH_ADC_DUAL_RATE   (1 << 6)
 
#define DATAPATH_DAC_DUAL_RATE   (1 << 5)
 
#define DATAPATH_RDAC_SHIFT   (1)
 
#define DATAPATH_LDAC_SHIFT   (3)
 
#define DATAPATH_CTRL_MASK   (0x03U)
 
#define ASD_IFA_MODE_SHIFT   (6)
 
#define ASD_IFA_BCLK_MASTER   (1 << 7)
 
#define ASD_IFA_WCLK_MASTER   (1 << 6)
 
#define ASD_IFA_DOUT_HIZ   (1 << 5)
 
#define ASD_IFB_MODE_SHIFT   (6)
 
#define ASD_IFB_MODE_MASK   (0x03U << ASD_IFB_MODE_SHIFT)
 
#define ASD_IFB_LEN_SHIFT   (4)
 
#define ASD_IFB_LEN_MASK   (0x03U << ASD_IFB_LEN_SHIFT)
 
#define AIC3X_MICBIAS_LEVEL_SHIFT   (6)
 
#define AIC3X_MICBIAS_LEVEL_MASK   (0x03U << AIC3X_MICBIAS_LEVEL_SHIFT)
 
#define INVERT_VOL(val)   (0x7FU - val)
 
#define AIC3X_DEFAULT_VOL   INVERT_VOL(0x50)
 
#define AIC3X_DEFAULT_GAIN   (0x20U)
 
#define AIC3X_ROUTE_ON   (1 << 7)
 
#define AIC3X_UNMUTE   (1 << 3)
 
#define AIC3X_MUTE_ON   (1 << 7)
 
#define AIC3X_POWER_ON   (1 << 0)
 
#define MIC2LINE2_RADC_CTRL_MASK   (0x0FU)
 
#define CLKGEN_CTRL_SOURCE_MASK   (0x03U)
 

Enumerations

enum  aic3x_fref { DATAPATH_FREF_48kHz = 0x00, DATAPATH_FREF_44_1kHz = 0x01 }
 
enum  aic3x_datapath_dac { DATAPATH_RDAC = 0x01, DATAPATH_LDAC = 0x03 }
 
enum  aic3x_datapath_ctrl { DATAPATH_MUTED = 0x00, DATAPATH_STRAIGHT = 0x01, DATAPATH_SWAPPED = 0x02, DATAPATH_MONO_MIX = 0x03 }
 
enum  aic3x_asd_ifa_ctrl { ASD_IFA_SLAVE = 0x00, ASD_IFA_MASTER = 0x03 }
 
enum  aic3x_asd_ifb_mode { ASD_IFB_MODE_I2S = 0x00, ASD_IFB_MODE_DSP = 0x01, ASD_IFB_MODE_RJUST = 0x02, ASD_IFB_MODE_LJUST = 0x03 }
 
enum  aic3x_asd_ifb_len { ASD_IFB_LEN_16BIT = 0x00, ASD_IFB_LEN_20BIT = 0x01, ASD_IFB_LEN_24BIT = 0x02, ASD_IFB_LEN_32BIT = 0x03 }
 
enum  aic3x_mic2line2_radc_ctrl { MIC2LINE2_RIGHT_RADC = 0x00, MIC2LINE2_LEFT_RADC = 0x04 }
 
enum  aic3x_dac_pwr_dac { DAC_PWR_RDAC = 0x06, DAC_PWR_LDAC = 0x07 }
 
enum  aic3x_input_ctrl_gain {
  INPUT_CTRL_GAIN_0dB = 0x00, INPUT_CTRL_GAIN_1_5dB = 0x01, INPUT_CTRL_GAIN_3dB = 0x02, INPUT_CTRL_GAIN_4_5dB = 0x03,
  INPUT_CTRL_GAIN_6dB = 0x04, INPUT_CTRL_GAIN_7_5dB = 0x05, INPUT_CTRL_GAIN_9dB = 0x06, INPUT_CTRL_GAIN_10_5dB = 0x07,
  INPUT_CTRL_GAIN_12dB = 0x08, INPUT_CTRL_ADC_DISCONNECT = 0x0F
}
 
enum  aic3x_rate_div {
  AIC3X_DIV_FS_1 = 0x00, AIC3X_DIV_FS_1_5 = 0x01, AIC3X_DIV_FS_2 = 0x02, AIC3X_DIV_FS_2_5 = 0x03,
  AIC3X_DIV_FS_3 = 0x04, AIC3X_DIV_FS_3_5 = 0x05, AIC3X_DIV_FS_4 = 0x06, AIC3X_DIV_FS_4_5 = 0x07,
  AIC3X_DIV_FS_5 = 0x08, AIC3X_DIV_FS_5_5 = 0x09, AIC3X_DIV_FS_6 = 0x0A
}
 
enum  aic3x_micbias { AIC3X_MICBIAS_OFF = 0x00, AIC3X_MICBIAS_2V = 0x01, AIC3X_MICBIAS_2V5 = 0x02, AIC3X_MICBIAS_AVDD = 0x03 }
 
enum  aic3x_clkgen_ctrl { CLKGEN_CTRL_PLLCLK_IN = 0x04, CLKGEN_CTRL_CLKDIV_IN = 0x06 }
 
enum  aic3x_clkgen_ctrl_source { CLKGEN_SOURCE_MCLK = 0x00, CLKGEN_SOURCE_GPIO2 = 0x01, CLKGEN_SOURCE_BCLK = 0x02 }
 
enum  aic3x_outroute { AIC3X_LINE_OUT_STEREO, AIC3X_HP_OUT_STEREO }
 
enum  aic3x_inroute { AIC3X_LINE_IN_STEREO, AIC3X_MIC_IN_MONO }
 

Functions

int aic3x_init (struct aic3x_dev *codec, struct aic3x_cfg *cfg)
 Initialize AIC3x Codec.
 
int aic3x_reset (struct aic3x_dev *codec)
 
int aic3x_configure_fref (struct aic3x_dev *codec, enum aic3x_fref fref)
 
int aic3x_configure_datapath (struct aic3x_dev *codec, enum aic3x_datapath_dac dac, enum aic3x_datapath_ctrl path)
 
int aic3x_set_sample_rate (struct aic3x_dev *codec, enum aic3x_rate_div adc_div, enum aic3x_rate_div dac_div)
 
int aic3x_enable_dac_pwr (struct aic3x_dev *codec, enum aic3x_dac_pwr_dac dac, unsigned char en)
 

Detailed Description

TLV320AIC3104 Audio Codec FreeBSD.

Author
R. Bush bush@.nosp@m.krtk.nosp@m.l.com
Version
v1.0
Date
2017 September 28 Copyright (c) 2017, krtkl inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.

Macro Definition Documentation

◆ AIC3X_ADDR

#define AIC3X_ADDR   (0x18U)

Fixed I2C slave address

Enumeration Type Documentation

◆ aic3x_datapath_ctrl

Enumerator
DATAPATH_MUTED 

ADC data path is off (muted)

DATAPATH_STRAIGHT 

LADC plays left channel, RADC plays right channel

DATAPATH_SWAPPED 

LADC plays right channel, RADC plays left channel

DATAPATH_MONO_MIX 

ADC plays mono mix of both channels

79  {
80  DATAPATH_MUTED = 0x00,
81  DATAPATH_STRAIGHT = 0x01,
82  DATAPATH_SWAPPED = 0x02,
83  DATAPATH_MONO_MIX = 0x03,
84 };
Definition: tlv320aic3104.h:81
Definition: tlv320aic3104.h:82
Definition: tlv320aic3104.h:80
Definition: tlv320aic3104.h:83

◆ aic3x_mic2line2_radc_ctrl

Enumerator
MIC2LINE2_RIGHT_RADC 

Offset of MIC2R/LINE2R to RADC bits

MIC2LINE2_LEFT_RADC 

Offset of MIC2L/LINE2L to RADC bits

149  {
150  MIC2LINE2_RIGHT_RADC = 0x00,
151  MIC2LINE2_LEFT_RADC = 0x04
152 };
Definition: tlv320aic3104.h:151
Definition: tlv320aic3104.h:150