drivers: audio: move to new logger
Move to new logger subsystem. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
9a8567fa4a
commit
31a089412f
2 changed files with 27 additions and 36 deletions
|
@ -28,18 +28,9 @@ config AUDIO_CODEC_INIT_PRIORITY
|
|||
help
|
||||
Audio codec device driver initialization priority.
|
||||
|
||||
config SYS_LOG_AUDIO_CODEC_LEVEL
|
||||
int "Audio codec driver log level"
|
||||
depends on SYS_LOG
|
||||
default 0
|
||||
help
|
||||
Sets log level for Audio codec drivers.
|
||||
Levels are:
|
||||
- 0 OFF, do not write
|
||||
- 1 ERROR, only write SYS_LOG_ERR
|
||||
- 2 WARNING, write SYS_LOG_WRN in addition to previous level
|
||||
- 3 INFO, write SYS_LOG_INF in addition to previous levels
|
||||
- 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
|
||||
module = AUDIO_CODEC
|
||||
module-str = audio codec
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
source "drivers/audio/Kconfig.tlv320dac"
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#define SYS_LOG_DOMAIN "dev/codec"
|
||||
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_AUDIO_CODEC_LEVEL
|
||||
#include <logging/sys_log.h>
|
||||
|
||||
#include <misc/util.h>
|
||||
|
||||
#include <device.h>
|
||||
|
@ -18,6 +14,10 @@
|
|||
#include <audio/codec.h>
|
||||
#include "tlv320dac310x.h"
|
||||
|
||||
#define LOG_LEVEL CONFIG_AUDIO_CODEC_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(tlv320dac310x);
|
||||
|
||||
#define CODEC_OUTPUT_VOLUME_MAX 0
|
||||
#define CODEC_OUTPUT_VOLUME_MIN (-78 * 2)
|
||||
|
||||
|
@ -55,7 +55,7 @@ static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg);
|
|||
static void codec_configure_output(struct device *dev);
|
||||
static int codec_set_output_volume(struct device *dev, int vol);
|
||||
|
||||
#if (SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG)
|
||||
#if (LOG_LEVEL >= LOG_LEVEL_DEBUG)
|
||||
static void codec_read_all_regs(struct device *dev);
|
||||
#define CODEC_DUMP_REGS(dev) codec_read_all_regs((dev))
|
||||
#else
|
||||
|
@ -70,7 +70,7 @@ static int codec_initialize(struct device *dev)
|
|||
dev_cfg->i2c_device = device_get_binding(dev_cfg->i2c_dev_name);
|
||||
|
||||
if (dev_cfg->i2c_device == NULL) {
|
||||
SYS_LOG_ERR("I2C device binding error");
|
||||
LOG_ERR("I2C device binding error");
|
||||
return -ENXIO;
|
||||
}
|
||||
return 0;
|
||||
|
@ -82,7 +82,7 @@ static int codec_configure(struct device *dev,
|
|||
int ret;
|
||||
|
||||
if (cfg->dai_type != AUDIO_DAI_TYPE_I2S) {
|
||||
SYS_LOG_ERR("dai_type must be AUDIO_DAI_TYPE_I2S");
|
||||
LOG_ERR("dai_type must be AUDIO_DAI_TYPE_I2S");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ static int codec_set_property(struct device *dev,
|
|||
{
|
||||
/* individual channel control not currently supported */
|
||||
if (channel != AUDIO_CHANNEL_ALL) {
|
||||
SYS_LOG_ERR("channel %u invalid. must be AUDIO_CHANNEL_ALL");
|
||||
LOG_ERR("channel %u invalid. must be AUDIO_CHANNEL_ALL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ static void codec_write_reg(struct device *dev, struct reg_addr reg, u8_t val)
|
|||
|
||||
i2c_reg_write_byte(dev_cfg->i2c_device,
|
||||
DAC_I2C_DEV_ADDR, reg.reg_addr, val);
|
||||
SYS_LOG_DBG("WR PG:%u REG:%02u VAL:0x%02x",
|
||||
LOG_DBG("WR PG:%u REG:%02u VAL:0x%02x",
|
||||
reg.page, reg.reg_addr, val);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ static void codec_read_reg(struct device *dev, struct reg_addr reg, u8_t *val)
|
|||
|
||||
i2c_reg_read_byte(dev_cfg->i2c_device,
|
||||
DAC_I2C_DEV_ADDR, reg.reg_addr, val);
|
||||
SYS_LOG_DBG("RD PG:%u REG:%02u VAL:0x%02x",
|
||||
LOG_DBG("RD PG:%u REG:%02u VAL:0x%02x",
|
||||
reg.page, reg.reg_addr, *val);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg)
|
|||
val |= IF_CTRL_WLEN(IF_CTRL_WLEN_32);
|
||||
break;
|
||||
default:
|
||||
SYS_LOG_ERR("Unsupported PCM sample bit width %u",
|
||||
LOG_ERR("Unsupported PCM sample bit width %u",
|
||||
cfg->i2s.word_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ static int codec_configure_clocks(struct device *dev,
|
|||
int mdac, ndac, bclk_div, mclk_div;
|
||||
|
||||
i2s = &cfg->dai_cfg.i2s;
|
||||
SYS_LOG_DBG("MCLK %u Hz PCM Rate: %u Hz", cfg->mclk_freq,
|
||||
LOG_DBG("MCLK %u Hz PCM Rate: %u Hz", cfg->mclk_freq,
|
||||
i2s->frame_clk_freq);
|
||||
|
||||
if (cfg->mclk_freq <= DAC_PROC_CLK_FREQ_MAX) {
|
||||
|
@ -301,23 +301,23 @@ static int codec_configure_clocks(struct device *dev,
|
|||
|
||||
/* check if suitable value was found */
|
||||
if (osr < osr_min) {
|
||||
SYS_LOG_ERR("Unable to find suitable mdac and osr values");
|
||||
LOG_ERR("Unable to find suitable mdac and osr values");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
SYS_LOG_DBG("Processing freq: %u Hz Modulator freq: %u Hz",
|
||||
LOG_DBG("Processing freq: %u Hz Modulator freq: %u Hz",
|
||||
dac_clk, mod_clk);
|
||||
SYS_LOG_DBG("NDAC: %u MDAC: %u OSR: %u", ndac, mdac, osr);
|
||||
LOG_DBG("NDAC: %u MDAC: %u OSR: %u", ndac, mdac, osr);
|
||||
|
||||
if (i2s->options & I2S_OPT_BIT_CLK_MASTER) {
|
||||
bclk_div = osr * mdac / (i2s->word_size * 2); /* stereo */
|
||||
if ((bclk_div * i2s->word_size * 2) != (osr * mdac)) {
|
||||
SYS_LOG_ERR("Unable to generate BCLK %u from MCLK %u",
|
||||
LOG_ERR("Unable to generate BCLK %u from MCLK %u",
|
||||
i2s->frame_clk_freq * i2s->word_size * 2,
|
||||
cfg->mclk_freq);
|
||||
return -EINVAL;
|
||||
}
|
||||
SYS_LOG_DBG("I2S Master BCLKDIV: %u", bclk_div);
|
||||
LOG_DBG("I2S Master BCLKDIV: %u", bclk_div);
|
||||
codec_write_reg(dev, BCLK_DIV_ADDR,
|
||||
BCLK_DIV_POWER_UP | BCLK_DIV(bclk_div));
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ static int codec_configure_clocks(struct device *dev,
|
|||
/* setup timer clock to be MCLK divided */
|
||||
codec_write_reg(dev, TIMER_MCLK_DIV_ADDR,
|
||||
TIMER_MCLK_DIV_EN_EXT | TIMER_MCLK_DIV_VAL(mclk_div));
|
||||
SYS_LOG_DBG("Timer MCLK Divider: %u", mclk_div);
|
||||
LOG_DBG("Timer MCLK Divider: %u", mclk_div);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -352,15 +352,15 @@ static int codec_configure_filters(struct device *dev, audio_dai_cfg_t *cfg)
|
|||
/* determine decimation filter type */
|
||||
if (cfg->i2s.frame_clk_freq >= AUDIO_PCM_RATE_192K) {
|
||||
proc_blk = PRB_P18_DECIMATION_C;
|
||||
SYS_LOG_INF("PCM Rate: %u Filter C PRB P18 selected",
|
||||
LOG_INF("PCM Rate: %u Filter C PRB P18 selected",
|
||||
cfg->i2s.frame_clk_freq);
|
||||
} else if (cfg->i2s.frame_clk_freq >= AUDIO_PCM_RATE_96K) {
|
||||
proc_blk = PRB_P10_DECIMATION_B;
|
||||
SYS_LOG_INF("PCM Rate: %u Filter B PRB P10 selected",
|
||||
LOG_INF("PCM Rate: %u Filter B PRB P10 selected",
|
||||
cfg->i2s.frame_clk_freq);
|
||||
} else {
|
||||
proc_blk = PRB_P25_DECIMATION_A;
|
||||
SYS_LOG_INF("PCM Rate: %u Filter A PRB P25 selected",
|
||||
LOG_INF("PCM Rate: %u Filter A PRB P25 selected",
|
||||
cfg->i2s.frame_clk_freq);
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg)
|
|||
osr = OSR_MULTIPLE_8;
|
||||
}
|
||||
|
||||
SYS_LOG_INF("PCM Rate: %u OSR Multiple: %u", cfg->i2s.frame_clk_freq,
|
||||
LOG_INF("PCM Rate: %u OSR Multiple: %u", cfg->i2s.frame_clk_freq,
|
||||
osr);
|
||||
return osr;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ static int codec_set_output_volume(struct device *dev, int vol)
|
|||
|
||||
if ((vol > CODEC_OUTPUT_VOLUME_MAX) ||
|
||||
(vol < CODEC_OUTPUT_VOLUME_MIN)) {
|
||||
SYS_LOG_ERR("Invalid volume %d.%d dB",
|
||||
LOG_ERR("Invalid volume %d.%d dB",
|
||||
vol >> 1, ((u32_t)vol & 1) ? 5 : 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ static int codec_set_output_volume(struct device *dev, int vol)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if (SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG)
|
||||
#if (LOG_LEVEL >= LOG_LEVEL_DEBUG)
|
||||
static void codec_read_all_regs(struct device *dev)
|
||||
{
|
||||
u8_t val;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue