Skip to content

Commit

Permalink
sof: replace log calls with zephyr logging api
Browse files Browse the repository at this point in the history
The log context in zephyr is per file or module.

To use zephyr logging api, LOG_MODULE_REGISTER is used
to register a log context, LOG_MODULE_DECLARE is used
to refer to the registered context.

For function in header file, LOG_MODULE_DECLARE should
be used within that function to avoid context collapse,
a condition one source file have multiple context
registered or declared.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
  • Loading branch information
Chao Song committed Mar 29, 2022
1 parent 441e3b6 commit 3220cac
Show file tree
Hide file tree
Showing 100 changed files with 352 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Kconfig.sof
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ if !ZEPHYR_SOF_MODULE
rsource "Kconfig.xtos-build"
endif

if ZEPHYR_SOF_MODULE
rsource "Kconfig.zephyr-log"
endif

menu "Debug"

config DEBUG
Expand Down
52 changes: 52 additions & 0 deletions Kconfig.zephyr-log
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-License-Identifier: Apache-2.0

menu "Logging"

config LOG
bool "Enable logging"
default y
help
Select for log support

choice "SOF_LOG_LEVEL_CHOICE"
prompt "Max compiled-in log level for SOF"
default SOF_LOG_LEVEL_INF
depends on LOG

config SOF_LOG_LEVEL_OFF
bool "Off"
help
Set log level to off

config SOF_LOG_LEVEL_ERR
bool "Error"
help
Set log level to error

config SOF_LOG_LEVEL_WRN
bool "Warning"
help
Set log level to warning

config SOF_LOG_LEVEL_INF
bool "Info"
help
Set log level to info

config SOF_LOG_LEVEL_DBG
bool "Debug"
help
Set log level to debug

endchoice

config SOF_LOG_LEVEL
int
depends on LOG
default 0 if SOF_LOG_LEVEL_OFF
default 1 if SOF_LOG_LEVEL_ERR
default 2 if SOF_LOG_LEVEL_WRN
default 3 if SOF_LOG_LEVEL_INF
default 4 if SOF_LOG_LEVEL_DBG

endmenu
2 changes: 2 additions & 0 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ typedef void (*asrc_proc_func)(struct comp_dev *dev,

static const struct comp_driver comp_asrc;

LOG_MODULE_REGISTER(asrc, CONFIG_SOF_LOG_LEVEL);

#ifndef CONFIG_IPC_MAJOR_4
/* c8ec72f6-8526-4faf-9d39-a23d0b541de2 */
DECLARE_SOF_RT_UUID("asrc", asrc_uuid, 0xc8ec72f6, 0x8526, 0x4faf,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/asrc/asrc_farrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <sof/audio/asrc/asrc_config.h>
#include <sof/audio/asrc/asrc_farrow.h>

LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL);

#define CONVERT_COEFF(x) ((int32_t)(x))

/* Rate skew in Q2.30 format can be 0.5 - 2.0 x rate */
Expand Down
2 changes: 2 additions & 0 deletions src/audio/asrc/asrc_farrow_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <sof/audio/asrc/asrc_farrow.h>
#include <sof/audio/format.h>

LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL);

void asrc_fir_filter16(struct asrc_farrow *src_obj, int16_t **output_buffers,
int index_output_frame)
{
Expand Down
2 changes: 2 additions & 0 deletions src/audio/asrc/asrc_farrow_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <xtensa/tie/xt_hifi3.h>

LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL);

void asrc_fir_filter16(struct asrc_farrow *src_obj, int16_t **output_buffers,
int index_output_frame)
{
Expand Down
2 changes: 2 additions & 0 deletions src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <ipc4/pipeline.h>
#include <sof_versions.h>

LOG_MODULE_REGISTER(basefw, CONFIG_SOF_LOG_LEVEL);

/* 0e398c32-5ade-ba4b-93b1-c50432280ee4 */
DECLARE_SOF_RT_UUID("basefw", basefw_comp_uuid, 0xe398c32, 0x5ade, 0xba4b,
0x93, 0xb1, 0xc5, 0x04, 0x32, 0x28, 0x0e, 0xe4);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_REGISTER(buffer, CONFIG_SOF_LOG_LEVEL);

/* 42544c92-8e92-4e41-b679-34519f1c1d28 */
DECLARE_SOF_RT_UUID("buffer", buffer_uuid, 0x42544c92, 0x8e92, 0x4e41,
0xb6, 0x79, 0x34, 0x51, 0x9f, 0x1c, 0x1d, 0x28);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/channel_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <stdint.h>
#include <stdlib.h>

LOG_MODULE_REGISTER(channel_map, CONFIG_SOF_LOG_LEVEL);

/* ec290e95-4a20-47eb-bbff-d9c888431831 */
DECLARE_SOF_UUID("channel-map", chmap_uuid, 0xec290e95, 0x4a20, 0x47eb,
0xbb, 0xff, 0xd9, 0xc8, 0x88, 0x43, 0x18, 0x31);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_REGISTER(component, CONFIG_SOF_LOG_LEVEL);

static SHARED_DATA struct comp_driver_list cd;

/* 7c42ce8b-0108-43d0-9137-56d660478c5f */
Expand Down
2 changes: 2 additions & 0 deletions src/audio/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

static const struct comp_driver comp_copier;

LOG_MODULE_REGISTER(copier, CONFIG_SOF_LOG_LEVEL);

/* this id aligns windows driver requirement to support windows driver */
/* 9ba00c83-ca12-4a83-943c-1fa2e82f9dda */
DECLARE_SOF_RT_UUID("copier", copier_comp_uuid, 0x9ba00c83, 0xca12, 0x4a83,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

static const struct comp_driver comp_dai;

LOG_MODULE_REGISTER(comp_dai, CONFIG_SOF_LOG_LEVEL);

/* c2b00d27-ffbc-4150-a51a-245c79c5e54b */
DECLARE_SOF_RT_UUID("dai", dai_comp_uuid, 0xc2b00d27, 0xffbc, 0x4150,
0xa5, 0x1a, 0x24, 0x5c, 0x79, 0xc5, 0xe5, 0x4b);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

static const struct comp_driver comp_dcblock;

LOG_MODULE_REGISTER(dcblock, CONFIG_SOF_LOG_LEVEL);

/* b809efaf-5681-42b1-9ed6-04bb012dd384 */
DECLARE_SOF_RT_UUID("dcblock", dcblock_uuid, 0xb809efaf, 0x5681, 0x42b1,
0x9e, 0xd6, 0x04, 0xbb, 0x01, 0x2d, 0xd3, 0x84);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/dcblock/dcblock_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <sof/audio/format.h>
#include <sof/audio/dcblock/dcblock.h>

LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL);

/**
*
* Genereric processing function. Input is 32 bits.
Expand Down
2 changes: 2 additions & 0 deletions src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

static const struct comp_driver comp_eq_fir;

LOG_MODULE_REGISTER(eq_fir, CONFIG_SOF_LOG_LEVEL);

/* 43a90ce7-f3a5-41df-ac06-ba98651ae6a3 */
DECLARE_SOF_RT_UUID("eq-fir", eq_fir_uuid, 0x43a90ce7, 0xf3a5, 0x41df,
0xac, 0x06, 0xba, 0x98, 0x65, 0x1a, 0xe6, 0xa3);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/eq_fir/eq_fir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(eq_fir, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_FORMAT_S16LE
void eq_fir_s16(struct fir_state_32x16 fir[], const struct audio_stream *source,
struct audio_stream *sink, int frames, int nch)
Expand Down
2 changes: 2 additions & 0 deletions src/audio/eq_fir/eq_fir_hifi2ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(eq_fir, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_FORMAT_S32LE
/* For even frame lengths use FIR filter that processes two sequential
* sample per call.
Expand Down
2 changes: 2 additions & 0 deletions src/audio/eq_fir/eq_fir_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(eq_fir, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_FORMAT_S32LE
/* For even frame lengths use FIR filter that processes two sequential
* sample per call.
Expand Down
2 changes: 2 additions & 0 deletions src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

static const struct comp_driver comp_eq_iir;

LOG_MODULE_REGISTER(eq_iir, CONFIG_SOF_LOG_LEVEL);

/* 5150c0e6-27f9-4ec8-8351-c705b642d12f */
DECLARE_SOF_RT_UUID("eq-iir", eq_iir_uuid, 0x5150c0e6, 0x27f9, 0x4ec8,
0x83, 0x51, 0xc7, 0x05, 0xb6, 0x42, 0xd1, 0x2f);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/google_hotword_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

static const struct comp_driver ghd_driver;

LOG_MODULE_REGISTER(google_hotword_detect, CONFIG_SOF_LOG_LEVEL);

/* c3c74249-058e-414f-8240-4da5f3fc2389 */
DECLARE_SOF_RT_UUID("google-hotword-detect", ghd_uuid,
0xc3c74249, 0x058e, 0x414f,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#define GOOGLE_RTC_AUDIO_PROCESSING_SAMPLERATE 48000

LOG_MODULE_REGISTER(google_rtc_audio_processing, CONFIG_SOF_LOG_LEVEL);

/* b780a0a6-269f-466f-b477-23dfa05af758 */
DECLARE_SOF_RT_UUID("google-rtc-audio-processing", google_rtc_audio_processing_uuid,
0xb780a0a6, 0x269f, 0x466f, 0xb4, 0x77, 0x23, 0xdf, 0xa0,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

static const struct comp_driver comp_host;

LOG_MODULE_REGISTER(host, CONFIG_SOF_LOG_LEVEL);

/* 8b9d100c-6d78-418f-90a3-e0e805d0852b */
DECLARE_SOF_RT_UUID("host", host_uuid, 0x8b9d100c, 0x6d78, 0x418f,
0x90, 0xa3, 0xe0, 0xe8, 0x05, 0xd0, 0x85, 0x2b);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

static const struct comp_driver comp_kpb;

LOG_MODULE_REGISTER(kpb, CONFIG_SOF_LOG_LEVEL);

/* d8218443-5ff3-4a4c-b388-6cfe07b9562e */
DECLARE_SOF_RT_UUID("kpb", kpb_uuid, 0xd8218443, 0x5ff3, 0x4a4c,
0xb3, 0x88, 0x6c, 0xfe, 0x07, 0xb9, 0x56, 0x2e);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

static const struct comp_driver comp_mixer;

LOG_MODULE_REGISTER(mixer, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_IPC_MAJOR_3
/* bc06c037-12aa-417c-9a97-89282e321a76 */
DECLARE_SOF_RT_UUID("mixer", mixer_uuid, 0xbc06c037, 0x12aa, 0x417c,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

static const struct comp_driver comp_mux;

LOG_MODULE_REGISTER(mux_demux, CONFIG_SOF_LOG_LEVEL);

/* c607ff4d-9cb6-49dc-b678-7da3c63ea557 */
DECLARE_SOF_RT_UUID("mux", mux_uuid, 0xc607ff4d, 0x9cb6, 0x49dc,
0xb6, 0x78, 0x7d, 0xa3, 0xc6, 0x3e, 0xa5, 0x57);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/mux/mux_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(mux_demux, CONFIG_SOF_LOG_LEVEL);

static void mux_check_for_wrap(struct audio_stream *sink,
const struct audio_stream **sources,
struct mux_look_up *lookup)
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_REGISTER(pipe, CONFIG_SOF_LOG_LEVEL);

/* 4e934adb-b0ec-4d33-a086-c1022f921321 */
DECLARE_SOF_RT_UUID("pipe", pipe_uuid, 0x4e934adb, 0xb0ec, 0x4d33,
0xa0, 0x86, 0xc1, 0x02, 0x2f, 0x92, 0x13, 0x21);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL);

static int pipeline_comp_params_neg(struct comp_dev *current,
struct comp_buffer *calling_buf,
struct pipeline_walk_context *ctx,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL);

/* f11818eb-e92e-4082-82a3-dc54c604ebb3 */
DECLARE_SOF_UUID("pipe-task", pipe_task_uuid, 0xf11818eb, 0xe92e, 0x4082,
0x82, 0xa3, 0xdc, 0x54, 0xc6, 0x04, 0xeb, 0xb3);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL);

/*
* Check whether pipeline is incapable of acquiring data for capture.
*
Expand Down
2 changes: 2 additions & 0 deletions src/audio/pipeline/pipeline-xrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL);

/*
* This flag disables firmware-side xrun recovery.
* It should remain enabled in the situation when the
Expand Down
2 changes: 2 additions & 0 deletions src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

static const struct comp_driver comp_selector;

LOG_MODULE_REGISTER(selector, CONFIG_SOF_LOG_LEVEL);

/* 55a88ed5-3d18-46ca-88f1-0ee6eae9930f */
DECLARE_SOF_RT_UUID("selector", selector_uuid, 0x55a88ed5, 0x3d18, 0x46ca,
0x88, 0xf1, 0x0e, 0xe6, 0xea, 0xe9, 0x93, 0x0f);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/selector/selector_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(selector, CONFIG_SOF_LOG_LEVEL);

#define BYTES_TO_S16_SAMPLES 1
#define BYTES_TO_S32_SAMPLES 2

Expand Down
3 changes: 3 additions & 0 deletions src/audio/src/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#define MAX_OUT_DELAY_SIZE_XNCH (PLATFORM_MAX_CHANNELS * MAX_OUT_DELAY_SIZE)

static const struct comp_driver comp_src;

LOG_MODULE_REGISTER(src, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_IPC_MAJOR_4
/* e61bb28d-149a-4c1f-b709-46823ef5f5a3 */
DECLARE_SOF_RT_UUID("src", src_uuid, 0xe61bb28d, 0x149a, 0x4c1f,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/src/src_hifi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(src, CONFIG_SOF_LOG_LEVEL);

/* HiFi4 has
* 16x 64 bit registers in register file AE_DR
*/
Expand Down
2 changes: 2 additions & 0 deletions src/audio/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

static const struct comp_driver comp_switch;

LOG_MODULE_REGISTER(switch, CONFIG_SOF_LOG_LEVEL);

/* 385cc44b-f34e-4b9b-8be0-535c5f43a825 */
DECLARE_SOF_RT_UUID("switch", switch_uuid, 0x385cc44b, 0xf34e, 0x4b9b,
0x8b, 0xe0, 0x53, 0x5c, 0x5f, 0x43, 0xa8, 0x25);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/tone.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

static const struct comp_driver comp_tone;

LOG_MODULE_REGISTER(tone, CONFIG_SOF_LOG_LEVEL);

/* 04e3f894-2c5c-4f2e-8dc1-694eeaab53fa */
DECLARE_SOF_RT_UUID("tone", tone_uuid, 0x04e3f894, 0x2c5c, 0x4f2e,
0x8d, 0xc1, 0x69, 0x4e, 0xea, 0xab, 0x53, 0xfa);
Expand Down
2 changes: 2 additions & 0 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

static const struct comp_driver comp_volume;

LOG_MODULE_REGISTER(volume, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_IPC_MAJOR_3
/* b77e677e-5ff4-4188-af14-fba8bdbf8682 */
DECLARE_SOF_RT_UUID("pga", volume_uuid, 0xb77e677e, 0x5ff4, 0x4188,
Expand Down
2 changes: 2 additions & 0 deletions src/audio/volume/volume_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <stddef.h>
#include <stdint.h>

LOG_MODULE_DECLARE(volume, CONFIG_SOF_LOG_LEVEL);

#if CONFIG_FORMAT_S24LE
/**
* \brief Volume s24 to s24 multiply function
Expand Down
Loading

0 comments on commit 3220cac

Please sign in to comment.