-
Notifications
You must be signed in to change notification settings - Fork 140
Mt8186 pcm #3733
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
Mt8186 pcm #3733
Conversation
Add dsp ops callback to register AFE DL1/DL2/UL1/UL2 SOF dai's with ALSA Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
Use generic IPC stream and mailbox ops for mt8186 Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
Use generic sof_ipc_msg_data instead of specific implementation as they do the same things Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
include/sound/sof.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbaluta out of curiosity how do you handle for the IMX platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063, in our internal tree we read this info from device tree but in a very non standard way.
https://www.spinics.net/lists/devicetree/msg433908.html
We got lots of advice from community on how to handle this, but after several iterations i got busy with other stuff. I think @chunxu-li is the way to go. Will update with similar patches for i.MX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dbaluta this is what I wanted to know i fthis will be used in other platforms as well.
include/sound/sof.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dbaluta this is what I wanted to know i fthis will be used in other platforms as well.
sound/soc/sof/pcm.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should somehow the pd->ignore_machine initialized to something not NULL for non ACPI platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ujfalusi , current patch can resolve this pull request as well.
The 'ignore_machine' field is currently used to ignore all FE dailinks statically added by the machine drivers, as well as override the fixups for the BE dailinks. The motivation for this field was primarily to reuse the same machine driver on Intel devices, both with legacy and SOF-based platform drivers.
The other platforms, where the same card may uses SOF-based dailinks to deal with DSP-managed streams, as well as 'regular' dailinks. The 'ignore_machine' field set by the core SOF platform driver is too strong, with dailinks not managed by SOF being modified.
update as
if (plat_data->machine)
drv_name = plat_data->machine->drv_name;
else if (plat_data->of_machine)
drv_name = plat_data->of_machine->drv_name;
else
drv_name = NULL;
From current design in sof_machine_check, the SOF can only support ACPI based machine, We introduce snd_sof_of_machine_select to give a chance for the machine which do not based on ACPI, this callback is optional, each machine that do not based on ACPI can implement their own specific routine. Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
As the mt8186 do not use ACPI based machine, the of_machine_select is used to distinguish different machines in sof_machine_check. Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
| snd_sof_of_machine_select(struct snd_sof_dev *sdev) | ||
| { | ||
| if (sof_ops(sdev) && sof_ops(sdev)->of_machine_select) | ||
| return sof_ops(sdev)->of_machine_select(sdev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the definitions at all. In the DT world, the machine is already described with a device, which will be matched with a driver already. What does 'of_machine_select' mean in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean 'a machine is already described with a device using device tree, right?'. Device tree describes the hardware, while we need information like machine driver name, tplg name, firmware name which according to Mark cannot be placed inside a DT node.
| /* machine */ | ||
| struct platform_device *pdev_mach; | ||
| const struct snd_soc_acpi_mach *machine; | ||
| const struct snd_sof_of_mach *of_machine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar in commit message
a chance for the machines which are not based on ACPI, this callback
is optional, each machine that is not based on ACPI can implement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart do you think it makes better sense to make the machine field const void * in snd_sof_pdata and resolve it to either snd_soc_acpi_mach or and_sof_of_mach in the platform dependent code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly, but it's not clear to me by the DT/OF machines need something in the kernel when everything is already described in platform firmware. That's the big difference between DT/OF and ACPI, in ACPI we do not have a device entry for the machine driver, so we do all this machine driver selection. It's not needed for DT/OF, so it's really questionable why we would build on something that was a work-around ACPI limitations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart @ranj063 , Sorry for confusion.
If we do not implement the machine_select callback the sof_machine_check will return -ENODEV. what we actually want is do not return error since we don't need machine_select with DT/OF machines. What's more the sof_machine_select not just checking ACPI machine, but also assign sof_tplg_filename at the same time. Do you have any ideal how to handle this?
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* return ACPI machine, this will return NULL with DT/OF machines */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart that is indeed a valid question. We need to find the ACPI machine and register it in sof_machine_register(). Without the need to explicitly register the machine driver, I cant explain what the need for change for OF devices would be for. @dbaluta any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ranj063 @plbossart @dbaluta The 'ACPI machine' should be selected before register by sof_machine_register, then it looks like the machine_select and machine_register should use at the same time when using ACPI machine.
How about
- we add a condition before
machine_select?
or - add a flag to check whether the current machine is ACPI or not?
1.check whether the machine_register is implement or not, if the machine_register is implemented then the machine must be checked before register.
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* acpi machine should implement machine register */
if (sof_ops(dev) && sof_ops(dev)->machine_register) {
/* return ACPI machine */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
} else {
/* of machine device return directly */
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
- add a flag in sof_dev_desc to check whether the current machine is ACPI or not?
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
const struct sof_dev_desc *desc = sof_pdata->desc;
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* acpi machine should select machine before register */
if (desc->is_acpi_machine) {
/* return ACPI machine */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
} else {
/* of machine device return directly */
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart,
From devicetree people comment, it's not ok we put fw/tplg filenames in DT. I think ACPI and DT are different specifications and it's not a work-around.
We need find a way for sof_machine_check func.
Please let me know if you have any comments. thanks.
sound/soc/sof/sof-of-dev.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dbaluta I checked this link https://www.spinics.net/lists/devicetree/msg433908.html
the following members should meet your requirement, do you have any other advice?
drv_name
tplg_filename
fw_filename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chunxu-li what I don't understand from your patch is where do we get for example drv_name.
Mark, here https://www.spinics.net/lists/devicetree/msg433913.html advised that this should be taken from something like sof_dev_desc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dbaluta :
this should be taken from something like sof_dev_desc.
Yes, We add this mach info into sof_of_mt8186_desc.of_machines field, and assign drv_name in function snd_sof_new_platform_drv at sof/pcm.c
code example
static struct snd_sof_of_mach sof_mt8186_machs[] = {
{
.board = "google,kingler",
.sof_tplg_filename = "sof-mt8186-mt6366-da7219-max98357.tplg",
.drv_name = "mt8186-mt6366-da7219-max98357"
},
{
.board = "google,krabby",
.sof_tplg_filename = "sof-mt8186-mt6366-rt1019-rt5682s.tplg",
.drv_name = "mt8186-mt6366-rt1019-rt5682s"
},
{}
};
static const struct sof_dev_desc sof_of_mt8186_desc = {
.of_machines = sof_mt8186_machs,
// sof/pcm.c
// void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
if (plat_data->machine)
drv_name = plat_data->machine->drv_name;
else if (plat_data->of_machine)
drv_name = plat_data->of_machine->drv_name;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. This works for me.
| /* machine */ | ||
| struct platform_device *pdev_mach; | ||
| const struct snd_soc_acpi_mach *machine; | ||
| const struct snd_sof_of_mach *of_machine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart @ranj063 , Sorry for confusion.
If we do not implement the machine_select callback the sof_machine_check will return -ENODEV. what we actually want is do not return error since we don't need machine_select with DT/OF machines. What's more the sof_machine_select not just checking ACPI machine, but also assign sof_tplg_filename at the same time. Do you have any ideal how to handle this?
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* return ACPI machine, this will return NULL with DT/OF machines */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
| /* machine */ | ||
| struct platform_device *pdev_mach; | ||
| const struct snd_soc_acpi_mach *machine; | ||
| const struct snd_sof_of_mach *of_machine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ranj063 @plbossart @dbaluta The 'ACPI machine' should be selected before register by sof_machine_register, then it looks like the machine_select and machine_register should use at the same time when using ACPI machine.
How about
- we add a condition before
machine_select?
or - add a flag to check whether the current machine is ACPI or not?
1.check whether the machine_register is implement or not, if the machine_register is implemented then the machine must be checked before register.
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* acpi machine should implement machine register */
if (sof_ops(dev) && sof_ops(dev)->machine_register) {
/* return ACPI machine */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
} else {
/* of machine device return directly */
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
- add a flag in sof_dev_desc to check whether the current machine is ACPI or not?
int sof_machine_check(struct snd_sof_dev *sdev)
{
//...
const struct sof_dev_desc *desc = sof_pdata->desc;
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
/* acpi machine should select machine before register */
if (desc->is_acpi_machine) {
/* return ACPI machine */
mach = snd_sof_machine_select(sdev);
if (mach) {
sof_pdata->machine = mach;
snd_sof_set_mach_params(mach, sdev);
return 0;
}
} else {
/* of machine device return directly */
return 0;
}
/* this will lead to machine check fail. */
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) {
dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n");
return -ENODEV;
}
// ...
}
|
Ping. We think we addressed all comments, is there anything else that needs to change? |
Hi ,
This series introduce the support of MT8186 SOF audio driver.