|
41 | 41 | #include <zephyr/device.h> |
42 | 42 | #include <zephyr/drivers/dai.h> |
43 | 43 |
|
| 44 | +#include <sof/debug/telemetry/performance_monitor.h> |
| 45 | + |
44 | 46 | /* note: if this macro is not defined |
45 | 47 | * then that means the HOST and the DSP |
46 | 48 | * have the same view of the address space. |
@@ -383,6 +385,10 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, |
383 | 385 | /* update host position (in bytes offset) for drivers */ |
384 | 386 | dd->total_data_processed += bytes; |
385 | 387 | } |
| 388 | +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS |
| 389 | + /* Increment performance counters */ |
| 390 | + io_perf_monitor_update_data(dd->io_perf_bytes_count, bytes); |
| 391 | +#endif |
386 | 392 |
|
387 | 393 | return dma_status; |
388 | 394 | } |
@@ -478,6 +484,48 @@ int dai_common_new(struct dai_data *dd, struct comp_dev *dev, |
478 | 484 | dd->xrun = 0; |
479 | 485 | dd->chan = NULL; |
480 | 486 |
|
| 487 | + /* I/O performance init, keep it last so the function does not reach this in case |
| 488 | + * of return on error, so that we do not waste a slot |
| 489 | + */ |
| 490 | +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS |
| 491 | + enum io_perf_data_item_id perf_type; |
| 492 | + enum io_perf_data_item_dir perf_dir; |
| 493 | + |
| 494 | + switch (dai_cfg->type) { |
| 495 | + case SOF_DAI_INTEL_SSP: |
| 496 | + perf_type = IO_PERF_I2S_ID; |
| 497 | + break; |
| 498 | + case SOF_DAI_INTEL_ALH: |
| 499 | + perf_type = IO_PERF_SOUND_WIRE_ID; |
| 500 | + break; |
| 501 | + case SOF_DAI_INTEL_DMIC: |
| 502 | + perf_type = IO_PERF_DMIC_ID; |
| 503 | + break; |
| 504 | + case SOF_DAI_INTEL_HDA: |
| 505 | + perf_type = IO_PERF_HDA_ID; |
| 506 | + break; |
| 507 | + |
| 508 | + default: |
| 509 | + perf_type = IO_PERF_INVALID_ID; |
| 510 | + comp_warn(dev, "Unsupported DAI type"); |
| 511 | + } |
| 512 | + if (dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK) |
| 513 | + perf_dir = IO_PERF_OUTPUT_DIRECTION; |
| 514 | + else |
| 515 | + perf_dir = IO_PERF_INPUT_DIRECTION; |
| 516 | + |
| 517 | + /* ignore perf meas init on case of other dai types */ |
| 518 | + if (perf_type != IO_PERF_INVALID_ID) { |
| 519 | + struct io_perf_data_item init_data = {perf_type, |
| 520 | + cpu_get_id(), |
| 521 | + perf_dir, |
| 522 | + IO_PERF_POWERED_UP_ENABLED, |
| 523 | + IO_PERF_D0IX_POWER_MODE, |
| 524 | + 0, 0, 0 }; |
| 525 | + io_perf_monitor_init_data(&dd->io_perf_bytes_count, &init_data); |
| 526 | + } |
| 527 | +#endif |
| 528 | + |
481 | 529 | return 0; |
482 | 530 | } |
483 | 531 |
|
@@ -523,6 +571,10 @@ static struct comp_dev *dai_new(const struct comp_driver *drv, |
523 | 571 |
|
524 | 572 | void dai_common_free(struct dai_data *dd) |
525 | 573 | { |
| 574 | +#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS |
| 575 | + io_perf_monitor_release_slot(dd->io_perf_bytes_count); |
| 576 | +#endif |
| 577 | + |
526 | 578 | if (dd->group) |
527 | 579 | dai_group_put(dd->group); |
528 | 580 |
|
|
0 commit comments