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

multiple SSPs/BEs support for SOF--Kernel Part #4

Merged
merged 10 commits into from
Jul 2, 2018
8 changes: 5 additions & 3 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static int sof_probe(struct platform_device *pdev)
spin_lock_init(&sdev->ipc_lock);
spin_lock_init(&sdev->hw_lock);

/* set up platform and component drivers */
/* set up platform component driver */
snd_sof_new_platform_drv(sdev);
snd_sof_new_dai_drv(sdev);

Expand Down Expand Up @@ -271,14 +271,16 @@ static int sof_probe(struct platform_device *pdev)
goto fw_run_err;
}

ret = snd_soc_register_component(&pdev->dev, sdev->cmpnt_drv,
&sdev->dai_drv, sdev->num_dai);
ret = snd_soc_register_component(&pdev->dev, sdev->cmpnt_drv,
sdev->ops->dai_drv->drv,
sdev->ops->dai_drv->num_drv);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to register DSP DAI driver %d\n", ret);
goto comp_err;
}

/* init DMA trace */
ret = snd_sof_init_trace(sdev);
if (ret < 0) {
dev_warn(sdev->dev,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/intel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ snd-sof-intel-byt-objs := byt.o
snd-sof-intel-hsw-objs := hsw.o
snd-sof-intel-bdw-objs := bdw.o
snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o hda-dai.o\
skl.o apl.o cnl.o

obj-$(CONFIG_SND_SOC_SOF_BAYTRAIL) += snd-sof-intel-byt.o
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,8 @@ struct snd_sof_dsp_ops sof_apl_ops = {
.trace_init = hda_dsp_trace_init,
.trace_release = hda_dsp_trace_release,
.trace_trigger = hda_dsp_trace_trigger,

/* DAI drivers */
.dai_drv = &hda_dai_drv,
};
EXPORT_SYMBOL(sof_apl_ops);
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,8 @@ struct snd_sof_dsp_ops sof_cnl_ops = {
.trace_init = hda_dsp_trace_init,
.trace_release = hda_dsp_trace_release,
.trace_trigger = hda_dsp_trace_trigger,

/* DAI drivers */
.dai_drv = &hda_dai_drv,
};
EXPORT_SYMBOL(sof_cnl_ops);
118 changes: 118 additions & 0 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* Copyright(c) 2018 Intel Corporation. All rights reserved.
*
* Authors: Keyon Jie <yang.jie@linux.intel.com>
*/

#include <sound/pcm_params.h>
#include "../sof-priv.h"

#define SKL_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE)

/*
* common dai driver for skl+ platforms.
* some products who use this DAI array only physically have a subset of
* the DAIs, but no harm is done here by adding the whole set.
*/
static struct snd_soc_dai_driver skl_dai[] = {
{
.name = "SSP0 Pin",
.playback = SOF_DAI_STREAM("ssp0 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp0 Rx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "SSP1 Pin",
.playback = SOF_DAI_STREAM("ssp1 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp1 Rx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "SSP2 Pin",
.playback = SOF_DAI_STREAM("ssp2 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp2 Rx", 1, 16,
Copy link
Member

Choose a reason for hiding this comment

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

8

Copy link
Author

Choose a reason for hiding this comment

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

oops, let me send incremental fix soon.

SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "SSP3 Pin",
.playback = SOF_DAI_STREAM("ssp3 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp3 Rx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "SSP4 Pin",
.playback = SOF_DAI_STREAM("ssp4 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp4 Rx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "SSP5 Pin",
.playback = SOF_DAI_STREAM("ssp5 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("ssp5 Rx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "DMIC01 Pin",
.capture = SOF_DAI_STREAM("DMIC01 Rx", 1, 4,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "DMIC16k Pin",
.capture = SOF_DAI_STREAM("DMIC16k Rx", 1, 4,
SNDRV_PCM_RATE_16000, SKL_FORMATS),
},
{
.name = "iDisp1 Pin",
.playback = SOF_DAI_STREAM("iDisp1 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "iDisp2 Pin",
.playback = SOF_DAI_STREAM("iDisp2 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "iDisp3 Pin",
.playback = SOF_DAI_STREAM("iDisp3 Tx", 1, 8,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "Analog Codec DAI",
.playback = SOF_DAI_STREAM("Analog Codec Playback", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("Analog Codec Capture", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "Digital Codec DAI",
.playback = SOF_DAI_STREAM("Digital Codec Playback", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("Digital Codec Capture", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
{
.name = "Alt Analog Codec DAI",
.playback = SOF_DAI_STREAM("Alt Analog Codec Playback", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
.capture = SOF_DAI_STREAM("Alt Analog Codec Capture", 1, 16,
SNDRV_PCM_RATE_8000_192000, SKL_FORMATS),
},
};

struct snd_sof_dai_drv hda_dai_drv = {
.drv = skl_dai,
.num_drv = ARRAY_SIZE(skl_dai)
};
EXPORT_SYMBOL(hda_dai_drv);

3 changes: 3 additions & 0 deletions sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
int hda_dsp_trace_release(struct snd_sof_dev *sdev);
int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);

/* common dai driver */
extern struct snd_sof_dai_drv hda_dai_drv;

/*
* Platform Specific HW abstraction Ops.
*/
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/skl.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@ struct snd_sof_dsp_ops sof_skl_ops = {
.trace_init = hda_dsp_trace_init,
.trace_release = hda_dsp_trace_release,
.trace_trigger = hda_dsp_trace_trigger,

/* DAI drivers */
.dai_drv = &hda_dai_drv,
};
EXPORT_SYMBOL(sof_skl_ops);
2 changes: 1 addition & 1 deletion sound/soc/sof/nocodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static struct snd_soc_dai_link sof_nocodec_dais[] = {
.name = "NoCodec",
.id = 0,
.init = nocodec_rtd_init,
.cpu_dai_name = "sof-audio",
.cpu_dai_name = "sof-nocodec-dai",
.platform_name = "sof-audio",
.no_pcm = 1,
.codec_dai_name = "snd-soc-dummy-dai",
Expand Down
22 changes: 2 additions & 20 deletions sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,30 +625,12 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
pd->topology_name_prefix = "sof";
}

static const struct snd_soc_dai_ops sof_dai_ops = {
};

static const struct snd_soc_component_driver sof_dai_component = {
.name = "sof-dai",
.name = "sof-dai",
};

#define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)

void snd_sof_new_dai_drv(struct snd_sof_dev *sdev)
{
struct snd_soc_dai_driver *dd = &sdev->dai_drv;
//struct snd_sof_pdata *plat_data = sdev->pdata;

sdev->cmpnt_drv = &sof_dai_component;
dd->playback.channels_min = 1;
dd->playback.channels_max = 16;
dd->playback.rates = SNDRV_PCM_RATE_8000_192000;
dd->playback.formats = SOF_FORMATS;
dd->capture.channels_min = 1;
dd->capture.channels_max = 16;
dd->capture.rates = SNDRV_PCM_RATE_8000_192000;
dd->capture.formats = SOF_FORMATS;
dd->ops = &sof_dai_ops;
sdev->num_dai = 1;
}

18 changes: 16 additions & 2 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
/* max number of FE PCMs before BEs */
#define SOF_BE_PCM_BASE 16

/* convenience constructor for DAI driver streams */
#define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
{.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
.rates = srates, .formats = sfmt}

#define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)

struct snd_sof_dev;
struct snd_sof_ipc_msg;
struct snd_sof_ipc;
Expand All @@ -52,6 +60,11 @@ struct snd_soc_component;
struct sof_intel_hda_dev;
struct snd_sof_pdata;

struct snd_sof_dai_drv {
struct snd_soc_dai_driver *drv;
int num_drv;
};

/*
* SOF DSP HW abstraction operations.
* Used to abstract DSP HW architecture and any IO busses between host CPU
Expand Down Expand Up @@ -139,6 +152,9 @@ struct snd_sof_dsp_ops {
int (*trace_init)(struct snd_sof_dev *sdev, u32 *stream_tag);
int (*trace_release)(struct snd_sof_dev *sdev);
int (*trace_trigger)(struct snd_sof_dev *sdev, int cmd);

/* DAI ops */
struct snd_sof_dai_drv *dai_drv;
};

/* DSP architecture specific callbacks for oops and stack dumps */
Expand Down Expand Up @@ -263,8 +279,6 @@ struct snd_sof_dev {
/* ASoC components */
struct snd_soc_platform_driver plat_drv;
const struct snd_soc_component_driver *cmpnt_drv;
struct snd_soc_dai_driver dai_drv;
int num_dai;

/* DSP firmware boot */
wait_queue_head_t boot_wait;
Expand Down