Skip to content

Commit

Permalink
Audio: use struct dai_ts_data replace timestamp_data
Browse files Browse the repository at this point in the history
Use struct dai_ts_data replace timestamp_data if
CONFIG_ZEPHYR_NATIVE_DRIVERS is enabled.

Signed-off-by: Andrula Song <[email protected]>
  • Loading branch information
andrula-song committed Sep 14, 2023
1 parent f6cf396 commit 46899d5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 57 deletions.
11 changes: 9 additions & 2 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,11 @@ static int asrc_dai_stop_timestamp(struct comp_data *cd)
return -EINVAL;
}

static int asrc_dai_get_timestamp(struct comp_data *cd,
struct timestamp_data *tsd)
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
static int asrc_dai_get_timestamp(struct comp_data *cd, struct dai_ts_data *tsd)
#else
static int asrc_dai_get_timestamp(struct comp_data *cd, struct timestamp_data *tsd)
#endif
{
if (!cd->dai_dev)
return -EINVAL;
Expand Down Expand Up @@ -909,7 +912,11 @@ static int asrc_prepare(struct comp_dev *dev)

static int asrc_control_loop(struct comp_dev *dev, struct comp_data *cd)
{
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
struct dai_ts_data tsd;
#else
struct timestamp_data tsd;
#endif
int64_t tmp;
int32_t delta_sample;
int32_t delta_ts;
Expand Down
4 changes: 4 additions & 0 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,11 @@ static int copier_dai_ts_start_op(struct comp_dev *dev)
return dai_common_ts_start(dd, dev);
}

#if CONFIG_ZEPHYR_NATIVE_DRIVERS
static int copier_dai_ts_get_op(struct comp_dev *dev, struct dai_ts_data *tsd)
#else
static int copier_dai_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd)
#endif
{
struct processing_module *mod = comp_get_drvdata(dev);
struct copier_data *cd = module_get_private_data(mod);
Expand Down
7 changes: 3 additions & 4 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,15 +1721,14 @@ static int dai_ts_start_op(struct comp_dev *dev)
return dai_common_ts_start(dd, dev);
}

int dai_common_ts_get(struct dai_data *dd, struct comp_dev *dev, struct timestamp_data *tsd)
int dai_common_ts_get(struct dai_data *dd, struct comp_dev *dev, struct dai_ts_data *tsd)
{
struct dai_ts_data *tsdata = (struct dai_ts_data *)tsd;
struct dai_ts_cfg *cfg = (struct dai_ts_cfg *)&dd->ts_config;

return dai_ts_get(dd->dai->dev, cfg, tsdata);
return dai_ts_get(dd->dai->dev, cfg, tsd);
}

static int dai_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd)
static int dai_ts_get_op(struct comp_dev *dev, struct dai_ts_data *tsd)
{
struct dai_data *dd = comp_get_drvdata(dev);

Expand Down
4 changes: 4 additions & 0 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,11 @@ int module_adapter_ts_stop_op(struct comp_dev *dev)
* 0 - success
* value < 0 - failure.
*/
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
int module_adapter_ts_get_op(struct comp_dev *dev, struct dai_ts_data *tsd)
#else
int module_adapter_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd)
#endif
{
struct processing_module *mod = comp_get_drvdata(dev);
struct module_data *md = &mod->priv;
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct comp_dev;
struct sof_ipc_stream_posn;
struct dai_hw_params;
struct timestamp_data;
struct dai_ts_data;

/** \addtogroup component_api Component API
* @{
Expand Down Expand Up @@ -455,8 +456,12 @@ struct comp_ops {
*
* Mandatory for components that allocate DAI.
*/
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
int (*dai_ts_get)(struct comp_dev *dev, struct dai_ts_data *tsd);
#else
int (*dai_ts_get)(struct comp_dev *dev,
struct timestamp_data *tsd);
#endif

/**
* Bind, atomic - used to notify component of bind event.
Expand Down
4 changes: 4 additions & 0 deletions src/include/sof/audio/dai_copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ int dai_common_ts_start(struct dai_data *dd, struct comp_dev *dev);

int dai_common_ts_stop(struct dai_data *dd, struct comp_dev *dev);

#if CONFIG_ZEPHYR_NATIVE_DRIVERS
int dai_common_ts_get(struct dai_data *dd, struct comp_dev *dev, struct dai_ts_data *tsd);
#else
int dai_common_ts_get(struct dai_data *dd, struct comp_dev *dev, struct timestamp_data *tsd);
#endif

int dai_common_get_hw_params(struct dai_data *dd, struct comp_dev *dev,
struct sof_ipc_stream_params *params, int dir);
Expand Down
4 changes: 4 additions & 0 deletions src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ int module_adapter_position(struct comp_dev *dev, struct sof_ipc_stream_posn *po
int module_adapter_ts_config_op(struct comp_dev *dev);
int module_adapter_ts_start_op(struct comp_dev *dev);
int module_adapter_ts_stop_op(struct comp_dev *dev);
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
int module_adapter_ts_get_op(struct comp_dev *dev, struct dai_ts_data *tsd);
#else
int module_adapter_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd);
#endif

static inline void module_update_buffer_position(struct input_stream_buffer *input_buffers,
struct output_stream_buffer *output_buffers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct output_stream_buffer {

struct comp_dev;
struct timestamp_data;
struct dai_ts_data;
/**
* \struct module_endpoint_ops
* \brief Ops relevant only for the endpoint devices such as the host copier or DAI copier.
Expand Down Expand Up @@ -120,7 +121,11 @@ struct module_endpoint_ops {
*
* Mandatory for components that allocate DAI.
*/
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
int (*dai_ts_get)(struct comp_dev *dev, struct dai_ts_data *tsd);
#else
int (*dai_ts_get)(struct comp_dev *dev, struct timestamp_data *tsd);
#endif

/**
* Fetches hardware stream parameters.
Expand Down
36 changes: 0 additions & 36 deletions src/include/sof/drivers/timestamp.h

This file was deleted.

16 changes: 1 addition & 15 deletions src/include/sof/lib/dai-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <stddef.h>
#include <stdint.h>
#include <zephyr/device.h>
#include <zephyr/drivers/dai.h>

/** \addtogroup sof_dai_drivers DAI Drivers
* DAI Drivers API specification.
Expand Down Expand Up @@ -61,21 +62,6 @@ struct timestamp_cfg {
int dma_chan_index; /* Used GPDMA channel */
int dma_chan_count; /* Channels in single GPDMA */
};

struct timestamp_data {
uint64_t walclk; /* Wall clock */
uint64_t sample; /* Sample count */
uint32_t walclk_rate; /* Rate in Hz, e.g. 19200000 */
};

struct timestamp_ops {
int (*ts_config)(struct dai *dai, struct timestamp_cfg *cfg);
int (*ts_start)(struct dai *dai, struct timestamp_cfg *cfg);
int (*ts_stop)(struct dai *dai, struct timestamp_cfg *cfg);
int (*ts_get)(struct dai *dai, struct timestamp_cfg *cfg,
struct timestamp_data *tsd);
};

union hdalink_cfg {
uint16_t full;
struct {
Expand Down

0 comments on commit 46899d5

Please sign in to comment.