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

Topic/sof dev cleanup1 #14

Merged
22 changes: 20 additions & 2 deletions sound/soc/sof/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ config SND_SOC_SOF_ACPI
config SND_SOC_SOF_PLATFORM
tristate


config SND_SOC_SOF
tristate "Sound Open Firmware Support"
default m
Expand All @@ -29,9 +28,19 @@ config SND_SOC_SOF_NOCODEC
Say Y if you need this nocodec fallback option
If unsure select "N".

config SND_SOC_SOF_DEBUG
bool "SOF debugging features"
depends on SND_SOC_SOF
help
This option can be used to enable or disable individual SOF firmware
and driver debugging options.
Say Y if you are debugging SOF FW or drivers.
If unsure select "N".

config SND_SOC_SOF_FORCE_NOCODEC_MODE
tristate "SOF force nocodec Mode"
bool "SOF force nocodec Mode"
depends on SND_SOC_SOF_NOCODEC
depends on SND_SOC_SOF_DEBUG
help
This forces SOF to use dummy/nocodec as machine driver, even
though there is a codec detected on the real platform. This is
Expand All @@ -41,5 +50,14 @@ config SND_SOC_SOF_FORCE_NOCODEC_MODE
Say Y if you need this force nocodec mode option
If unsure select "N".

config SND_SOC_SOF_DEBUG_XRUN_STOP
bool "SOF stop on XRUN"
depends on SND_SOC_SOF_DEBUG
help
This option forces PCMs to stop on any XRUN event. This is useful to
preserve any trace data ond pipeline status prior to the XRUN.
Say Y if you are debugging SOF FW pipeline XRUNs.
If unsure select "N".

source "sound/soc/sof/intel/Kconfig"
source "sound/soc/sof/xtensa/Kconfig"
87 changes: 54 additions & 33 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
#include "sof-priv.h"
#include "ops.h"

#define TIMEOUT_IPC 5
#define TIMEOUT_BOOT 100
/* SOF defaults if not provided by the platform in ms */
#define TIMEOUT_DEFAULT_IPC 5
#define TIMEOUT_DEFAULT_BOOT 100

/*
* Generic object lookup APIs.
*/

struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev,
struct snd_soc_pcm_runtime *rtd)
Expand Down Expand Up @@ -122,11 +127,16 @@ static inline unsigned int sof_get_pages(size_t size)
return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
}

/*
* FW Panic/fault handling.
*/

struct sof_panic_msg {
u32 id;
const char *msg;
};

/* standard FW panic types */
static const struct sof_panic_msg panic_msg[] = {
{SOF_IPC_PANIC_MEM, "out of memory"},
{SOF_IPC_PANIC_WORK, "work subsystem init failed"},
Expand Down Expand Up @@ -177,6 +187,43 @@ int snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
}
EXPORT_SYMBOL(snd_sof_get_status);

/*
* Generic buffer page table creation.
*/

int snd_sof_create_page_table(struct snd_sof_dev *sdev,
struct snd_dma_buffer *dmab,
unsigned char *page_table, size_t size)
{
int i, pages;

pages = snd_sgbuf_aligned_pages(size);

dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
dmab->area, size, pages);

for (i = 0; i < pages; i++) {
u32 idx = (((i << 2) + i)) >> 1;
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
u32 *pg_table;

dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);

pg_table = (u32 *)(page_table + idx);

if (i & 1)
*pg_table |= (pfn << 4);
else
*pg_table |= pfn;
}

return pages;
}

/*
* SOF Driver enumeration.
*/

static int sof_probe(struct platform_device *pdev)
{
struct snd_sof_pdata *plat_data = dev_get_platdata(&pdev->dev);
Expand Down Expand Up @@ -210,17 +257,17 @@ 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);

/* set default timeouts if none provided */
if (plat_data->desc->ipc_timeout == 0)
sdev->ipc_timeout = TIMEOUT_IPC;
sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC;
else
sdev->ipc_timeout = plat_data->desc->ipc_timeout;
if (plat_data->desc->boot_timeout == 0)
sdev->boot_timeout = TIMEOUT_BOOT;
sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT;
else
sdev->boot_timeout = plat_data->desc->boot_timeout;

Expand Down Expand Up @@ -279,8 +326,10 @@ static int sof_probe(struct platform_device *pdev)
goto comp_err;
}

/* init DMA trace */
ret = snd_sof_init_trace(sdev);
if (ret < 0) {
/* non fatal */
dev_warn(sdev->dev,
"warning: failed to initialize trace %d\n", ret);
}
Expand Down Expand Up @@ -321,34 +370,6 @@ void snd_sof_shutdown(struct device *dev)
}
EXPORT_SYMBOL(snd_sof_shutdown);

int snd_sof_create_page_table(struct snd_sof_dev *sdev,
struct snd_dma_buffer *dmab,
unsigned char *page_table, size_t size)
{
int i, pages;

pages = sof_get_pages(size);

dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
dmab->area, size, pages);

for (i = 0; i < pages; i++) {
u32 idx = (((i << 2) + i)) >> 1;
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
u32 *pg_table;

dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);

pg_table = (u32 *)(page_table + idx);

if (i & 1)
*pg_table |= (pfn << 4);
else
*pg_table |= pfn;
}

return pages;
}

static struct platform_driver sof_driver = {
.driver = {
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ struct snd_sof_dsp_ops sof_apl_ops = {
.dbg_dump = hda_dsp_dump,

/* stream callbacks */
.host_stream_open = hda_dsp_pcm_open,
.host_stream_close = hda_dsp_pcm_close,
.host_stream_hw_params = hda_dsp_pcm_hw_params,
.host_stream_trigger = hda_dsp_pcm_trigger,
.pcm_open = hda_dsp_pcm_open,
.pcm_close = hda_dsp_pcm_close,
.pcm_hw_params = hda_dsp_pcm_hw_params,
.pcm_trigger = hda_dsp_pcm_trigger,

/* firmware loading */
.load_firmware = hda_dsp_cl_load_fw,
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ struct snd_sof_dsp_ops sof_cnl_ops = {
.dbg_dump = hda_dsp_dump,

/* stream callbacks */
.host_stream_open = hda_dsp_pcm_open,
.host_stream_close = hda_dsp_pcm_close,
.host_stream_hw_params = hda_dsp_pcm_hw_params,
.host_stream_trigger = hda_dsp_pcm_trigger,
.pcm_open = hda_dsp_pcm_open,
.pcm_close = hda_dsp_pcm_close,
.pcm_hw_params = hda_dsp_pcm_hw_params,
.pcm_trigger = hda_dsp_pcm_trigger,

/* firmware loading */
.load_firmware = hda_dsp_cl_load_fw,
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/intel/skl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ struct snd_sof_dsp_ops sof_skl_ops = {
.dbg_dump = hda_dsp_dump,

/* stream callbacks */
.host_stream_open = hda_dsp_pcm_open,
.host_stream_close = hda_dsp_pcm_close,
.host_stream_hw_params = hda_dsp_pcm_hw_params,
.host_stream_trigger = hda_dsp_pcm_trigger,
.pcm_open = hda_dsp_pcm_open,
.pcm_close = hda_dsp_pcm_close,
.pcm_hw_params = hda_dsp_pcm_hw_params,
.pcm_trigger = hda_dsp_pcm_trigger,

/* firmware loading */
.load_firmware = hda_dsp_cl_load_fw,
Expand Down
Loading