diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 2dee890d9653..d7c2aa20011b 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -41,6 +41,8 @@ #include #include +#include + /* note: if this macro is not defined * then that means the HOST and the DSP * have the same view of the address space. @@ -342,6 +344,10 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, /* update host position (in bytes offset) for drivers */ dd->total_data_processed += bytes; } +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* Increment performance counters */ + io_perf_monitor_update_data(dd->io_perf_bytes_count, bytes); +#endif return dma_status; } @@ -434,6 +440,47 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev, dd->xrun = 0; dd->chan = NULL; + /* I/O performance init, keep it last so the function does not reach this in case + * of return on error, so that we do not waste a slot + */ +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + enum io_perf_data_item_id perf_type; + enum io_perf_data_item_dir perf_dir; + + switch (dai_cfg->type) { + case SOF_DAI_INTEL_SSP: + perf_type = I2S_ID; + break; + case SOF_DAI_INTEL_ALH: + perf_type = SOUND_WIRE_ID; + break; + case SOF_DAI_INTEL_DMIC: + perf_type = DMIC_ID; + break; + case SOF_DAI_INTEL_HDA: + perf_type = HDA_ID; + break; + + default: + perf_type = INVALID_ID; + } + if (dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK) + perf_dir = INPUT_DIRECTION; + else + perf_dir = OUTPUT_DIRECTION; + + /* ignore perf meas init on case of other dai types */ + if (perf_type != INVALID_ID) { + struct io_perf_data_item init_data = {perf_type, + cpu_get_id(), + perf_dir, + POWERED_UP_ENABLED, + D0IX_POWER_MODE, + 0, 0, 0 }; + io_perf_monitor_init_data(&dd->io_perf_bytes_count, &init_data); + } +#endif + return 0; } @@ -491,6 +538,10 @@ void dai_common_free(struct dai_data *dd) dai_put(dd->dai); +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + io_perf_monitor_release_slot(dd->io_perf_bytes_count); +#endif + rfree(dd->dai_spec_config); } diff --git a/src/include/sof/lib/dai-zephyr.h b/src/include/sof/lib/dai-zephyr.h index 98e174a43c8d..749e4583d5e1 100644 --- a/src/include/sof/lib/dai-zephyr.h +++ b/src/include/sof/lib/dai-zephyr.h @@ -35,6 +35,8 @@ #include #include +#include + /** \addtogroup sof_dai_drivers DAI Drivers * DAI Drivers API specification. * @{ @@ -149,6 +151,10 @@ struct dai_data { uint32_t sampling; /* fast mode, use one byte memory to save repreated cycles */ bool fast_mode; +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS + /* io performance measurement */ + struct io_perf_data_item *io_perf_bytes_count; +#endif }; /* these 3 are here to satisfy clk.c and ssp.h interconnection, will be removed leter */