Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] [DO NOT MERGE] Integration of Soundwire and SOF #1130

Conversation

plbossart
Copy link
Member

The integration of SoundWire support is quite hacky (the spell checker suggests wacky which isn't far from the truth). @RanderWang suggested that this isn't quite right as well so let's try and use GitHub to collect feedback.

We will need bandwidth from the usual suspects @ranj063 @kv2019i @lyakh @juimonen to help us make progress.

The goal is not to merge this in topic/sof-dev for now, this is to be applied on top of all the queued SoundWire patches (kept in an integration branch for reference).

For SoundWire/ALH, we have BE-specific inits to run, so don't return
and give a chance to the hardware driver to run.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The helper calls the SoundWire initializations and sets the resource
structure defined as an interface with the platform driver. The
resource deals with PCI base address, interrupts and the callback for
the stream configuration.

The interrupts are gated/ungated at the top-level with the
ADSPIPC2.SNDW field

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The Core0 needs to be powered before the SoundWire IP is initialized.

The storage of the SoundWire information the snd_sof_dev structure
will have to be revisited.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Once we get the ALH stream ID, we need to send an IPC to configure the
firmware.

Open: how do we get the DAI index from the dai?

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Implement all required back-end operations for SoundWire

FIXMEs:

1. the use of indices to detect SoundWire is a bad design to be
revisited

2. this patch was squashed for simplicity but may have to be better
split to simplify reviews.
3.we will have to rework all the stream handling since we have 4
structures called 'blah_stream'

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Somehow the core0 needs to be on to set-up the interrupts and power-up
the SoundWire IP.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
@RanderWang
Copy link

RanderWang commented Aug 14, 2019

@plbossart & all, how about my solution for sdw in SOF based on this PR? plbossart#3

we don't need to make such strange code.

	if (rtd->cpu_dai->id < SDW_DAI_ID_RANGE_START ||
	    rtd->cpu_dai->id > SDW_DAI_ID_RANGE_END)
		return 0;

	hda_stream = container_of(hstream,
				  struct sof_intel_hda_stream,
				  hda_stream.hstream);

And some functions, such as prepare, trigger, free, should be done in BE sdw dai link driver, just like hda dai link driver. In this PR, the sdw setting is recourse to FE stream, do it like the following code

        static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) {
	/* skip front-end specific inits for BE */
	if (rtd->dai_link->no_pcm) {
		snd_sof_pcm_platform_trigger(sdev, substream, cmd);
        }
       ...
 }

And found it will affect HDMI, although we can add more code to check whether it is HDMI or not.

@plbossart
Copy link
Member Author

@plbossart & all, how about my solution for sdw in SOF based on this PR? plbossart#3

Your solution was posted after this PR, so please give people time to review. I provided comments already.
Also your solution only impacts the PCM parts but the other 4 patches in this PR need to be reviewed as well.

And some functions, such as prepare, trigger, free, should be done in BE sdw dai link driver, just like hda dai link driver. In this PR, the sdw setting is recourse to FE stream, do it like the following code

        static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) {
	/* skip front-end specific inits for BE */
	if (rtd->dai_link->no_pcm) {
		snd_sof_pcm_platform_trigger(sdev, substream, cmd);
        }
       ...
 }

And found it will affect HDMI, although we can add more code to check whether it is HDMI or not.

I cannot figure out what you were trying to say here. Just boiler-plate answer is that I don't want any ties between SoundWire and front-ends, nor any warts related to HDMI.

@ranj063
Copy link
Collaborator

ranj063 commented Aug 14, 2019

@plbossart & all, how about my solution for sdw in SOF based on this PR? plbossart#3

@plbossart I do like the direction in Rander's PR.

  1. With the move to add the trigger and prepare() callbacks to the dai_ops, the SOF code looks much cleaner but...
  2. Should sdw_stream_setup() be in intel_startup() instead of intel_hw_params()? That would be in line with what you have in this PR
  3. I dont understand why the sdw_stream_add_slave() was moved from the rt700's hw_params to prepare(). It seems incorrect to me
  4. And there are some other simple fixes needed that I have commented on.

Copy link
Collaborator

@bardliao bardliao left a comment

Choose a reason for hiding this comment

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

Thanks @plbossart for posting it. Some minor comments from my side.

int sdw_pcm_prepare(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
{
//struct snd_pcm_runtime *runtime = substream->runtime;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove it :)

}

int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
{
struct hdac_stream *hstream = substream->runtime->private_data;
struct hdac_stream *hstream = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

move below hstream = runtime->private_data; here?

ret = hda_dsp_stream_put(sdev, direction, hstream->stream_tag);

if (ret) {
dev_dbg(sdev->dev, "stream %s not opened!\n", substream->name);
return -ENODEV;
}

goto free;

be:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably check if it is soundwire here. e.g.

if (rtd->cpu_dai->id < SDW_DAI_ID_RANGE_START ||
	    rtd->cpu_dai->id > SDW_DAI_ID_RANGE_END)
		return 0;

@@ -500,6 +512,35 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
spin_unlock_irq(&bus->reg_lock);

return 0;
be:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably check if it is soundwire here, too

if (rtd->dai_link->no_pcm)
/* skip front-end specific inits for BE */
if (rtd->dai_link->no_pcm) {
snd_sof_pcm_platform_prepare(sdev, substream);
Copy link
Collaborator

Choose a reason for hiding this comment

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

return snd_sof_pcm_platform_prepare(sdev, substream);?

if (rtd->dai_link->no_pcm)
/* skip front-end specific inits for BE */
if (rtd->dai_link->no_pcm) {
snd_sof_pcm_platform_trigger(sdev, substream, cmd);
Copy link
Collaborator

Choose a reason for hiding this comment

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

return snd_sof_pcm_platform_trigger(sdev, substream, cmd);?

return ret;
}

hda_sdw_int_enable(sdev, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary? SdW interrupt should work in suspended, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

no. If the IP is power gated then it can't generate interrupts.
This is different from the bus wake, which is something that we need to handle with the clock-stop mode, but that's for future work.

@RanderWang
Copy link

@plbossart & all, how about my solution for sdw in SOF based on this PR? plbossart#3

@plbossart I do like the direction in Rander's PR.

  1. With the move to add the trigger and prepare() callbacks to the dai_ops, the SOF code looks much cleaner but...
  2. Should sdw_stream_setup() be in intel_startup() instead of intel_hw_params()? That would be in line with what you have in this PR

yes, I also want to do it.

  1. I dont understand why the sdw_stream_add_slave() was moved from the rt700's hw_params to prepare(). It seems incorrect to me

because hw_params in codecs is invoke before dai hw_params, so if sdw data is set in dai hw_params,
it can't be gotten in codec hw_param. But with your advice to set sdw data in startup(), this prepare is no need.

  1. And there are some other simple fixes needed that I have commented on.

@plbossart
Copy link
Member Author

closed and replaced by #1139

@plbossart plbossart closed this Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants