Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,81 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config)
return 0;
}

static int dai_ctrl_set_cmd(struct comp_dev *dev,
struct sof_ipc_ctrl_data *cdata)
{
struct dai_data *dd = comp_get_drvdata(dev);
int ret = 0;
int val;

/* validate */
if (cdata->num_elems != 1) {
trace_dai_error("xs0");
return -EINVAL;
}

switch (cdata->cmd) {
case SOF_CTRL_CMD_SWITCH:
val = cdata->compv[0].uvalue;
trace_dai("dcs");
trace_value(cdata->comp_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will flow easier when using ioctl as the cmd can be passed directly in most cases.

trace_value(val);
dai_set_loopback_mode(dd->dai, val);
break;

default:
trace_dai_error("gs1");
return -EINVAL;
}

return ret;
}

static int dai_ctrl_get_cmd(struct comp_dev *dev,
struct sof_ipc_ctrl_data *cdata)
{
struct dai_data *dd = comp_get_drvdata(dev);
int val;

/* validate */
if (cdata->num_elems != 1) {
trace_dai_error("xg0");
return -EINVAL;
}
switch (cdata->cmd) {
case SOF_CTRL_CMD_SWITCH:
val = dai_get_loopback_mode(dd->dai);
trace_dai("dcg");
trace_value(cdata->comp_id);
trace_value(val);
cdata->compv[0].uvalue = val;
break;

default:
trace_dai_error("xcc");
return -EINVAL;
}

return 0;
}

/* used to pass standard and bespoke commands (with data) to component */
static int dai_cmd(struct comp_dev *dev, int cmd, void *data)
{
struct sof_ipc_ctrl_data *cdata = data;

trace_dai("cmd");

switch (cmd) {
case COMP_CMD_SET_VALUE:
return dai_ctrl_set_cmd(dev, cdata);
case COMP_CMD_GET_VALUE:
return dai_ctrl_get_cmd(dev, cdata);
default:
return -EINVAL;
}
}

static struct comp_driver comp_dai = {
.type = SOF_COMP_DAI,
.ops = {
Expand All @@ -700,6 +775,7 @@ static struct comp_driver comp_dai = {
.reset = dai_reset,
.dai_config = dai_config,
.position = dai_position,
.cmd = dai_cmd,
},
};

Expand Down
22 changes: 19 additions & 3 deletions src/drivers/apl-ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,31 @@ static inline int ssp_set_loopback_mode(struct dai *dai, uint32_t lbm)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);

trace_ssp("loo");
spin_lock(&ssp->lock);
trace_ssp("los");

ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
if (ssp->lbm == lbm)
return 0;

spin_lock(&ssp->lock);
ssp->lbm = lbm;
ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
spin_unlock(&ssp->lock);

return 0;
}

static inline int ssp_get_loopback_mode(struct dai *dai)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);
int ret;

trace_ssp("log");
spin_lock(&ssp->lock);
ret = ssp->lbm;
spin_unlock(&ssp->lock);
return ret;
}

/* start the SSP for either playback or capture */
static void ssp_start(struct dai *dai, int direction)
{
Expand Down Expand Up @@ -757,4 +772,5 @@ const struct dai_ops ssp_ops = {
.pm_context_restore = ssp_context_restore,
.probe = ssp_probe,
.set_loopback_mode = ssp_set_loopback_mode,
.get_loopback_mode = ssp_get_loopback_mode,
};
22 changes: 19 additions & 3 deletions src/drivers/byt-ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,31 @@ static inline int ssp_set_loopback_mode(struct dai *dai, uint32_t lbm)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);

trace_ssp("loo");
spin_lock(&ssp->lock);
trace_ssp("los");

ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
if (ssp->lbm == lbm)
return 0;

spin_lock(&ssp->lock);
ssp->lbm = lbm;
ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
spin_unlock(&ssp->lock);

return 0;
}

static inline int ssp_get_loopback_mode(struct dai *dai)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);
int ret;

trace_ssp("log");
spin_lock(&ssp->lock);
ret = ssp->lbm;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this variable to track state ? cant we just use the SSP LBM bit for this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will use the register value directly,

spin_unlock(&ssp->lock);
return ret;
}

/* start the SSP for either playback or capture */
static void ssp_start(struct dai *dai, int direction)
{
Expand Down Expand Up @@ -608,4 +623,5 @@ const struct dai_ops ssp_ops = {
.pm_context_restore = ssp_context_restore,
.probe = ssp_probe,
.set_loopback_mode = ssp_set_loopback_mode,
.get_loopback_mode = ssp_get_loopback_mode,
};
6 changes: 6 additions & 0 deletions src/drivers/dmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,13 +1454,19 @@ static inline int dmic_set_loopback_mode(struct dai *dai, uint32_t lbm)
return -EINVAL;
}

static inline int dmic_get_loopback_mode(struct dai *dai)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed with ioctl change.

{
return -EINVAL;
}

const struct dai_ops dmic_ops = {
.trigger = dmic_trigger,
.set_config = dmic_set_config,
.pm_context_store = dmic_context_store,
.pm_context_restore = dmic_context_restore,
.probe = dmic_probe,
.set_loopback_mode = dmic_set_loopback_mode,
.get_loopback_mode = dmic_get_loopback_mode,
};

#endif
22 changes: 19 additions & 3 deletions src/drivers/hsw-ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,31 @@ static inline int ssp_set_loopback_mode(struct dai *dai, uint32_t lbm)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);

trace_ssp("loo");
spin_lock(&ssp->lock);
trace_ssp("los");

ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
if (ssp->lbm == lbm)
return 0;

spin_lock(&ssp->lock);
ssp->lbm = lbm;
ssp_update_bits(dai, SSCR1, SSCR1_LBM, lbm ? SSCR1_LBM : 0);
spin_unlock(&ssp->lock);

return 0;
}

static inline int ssp_get_loopback_mode(struct dai *dai)
{
struct ssp_pdata *ssp = dai_get_drvdata(dai);
int ret;

trace_ssp("log");
spin_lock(&ssp->lock);
ret = ssp->lbm;
spin_unlock(&ssp->lock);
return ret;
}

/* start the SSP for either playback or capture */
static void ssp_start(struct dai *dai, int direction)
{
Expand Down Expand Up @@ -525,4 +540,5 @@ const struct dai_ops ssp_ops = {
.pm_context_restore = ssp_context_restore,
.probe = ssp_probe,
.set_loopback_mode = ssp_set_loopback_mode,
.get_loopback_mode = ssp_get_loopback_mode,
};
6 changes: 6 additions & 0 deletions src/include/sof/dai.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct dai_ops {
int (*pm_context_store)(struct dai *dai);
int (*probe)(struct dai *dai);
int (*set_loopback_mode)(struct dai *dai, uint32_t lbm);
int (*get_loopback_mode)(struct dai *dai);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove set_loopback_mode and use an int (*ioctl)(*dai, int cmd, void *data) callback for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will refine DAI.

};

/* DAI slot map to audio channel */
Expand Down Expand Up @@ -129,6 +130,11 @@ static inline int dai_set_loopback_mode(struct dai *dai, uint32_t lbm)
return dai->ops->set_loopback_mode(dai, lbm);
}

static inline int dai_get_loopback_mode(struct dai *dai)
{
return dai->ops->get_loopback_mode(dai);
}

/* Digital Audio interface trigger */
static inline int dai_trigger(struct dai *dai, int cmd, int direction)
{
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/ssp.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct ssp_pdata {
uint32_t psp;
spinlock_t lock;
uint32_t state[2]; /* SSP_STATE_ for each direction */
uint32_t lbm;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is platform data, so it cant hold any "status". It can however store a flag that can be used to do a one time configure of the SSP hardware. Please also use a more descriptive name for this, what does it do ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use register value.

completion_t drain_complete;
struct sof_ipc_dai_config config;
struct sof_ipc_dai_ssp_params params;
Expand Down