Skip to content

Commit 8ab299b

Browse files
authored
Merge pull request #14 from lgirdwood/topic/sof-dev-cleanup1
Topic/sof dev cleanup1
2 parents 28fc73b + b66e8ef commit 8ab299b

File tree

10 files changed

+367
-237
lines changed

10 files changed

+367
-237
lines changed

sound/soc/sof/Kconfig

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ config SND_SOC_SOF_ACPI
77
config SND_SOC_SOF_PLATFORM
88
tristate
99

10-
1110
config SND_SOC_SOF
1211
tristate "Sound Open Firmware Support"
1312
default m
@@ -29,9 +28,19 @@ config SND_SOC_SOF_NOCODEC
2928
Say Y if you need this nocodec fallback option
3029
If unsure select "N".
3130

31+
config SND_SOC_SOF_DEBUG
32+
bool "SOF debugging features"
33+
depends on SND_SOC_SOF
34+
help
35+
This option can be used to enable or disable individual SOF firmware
36+
and driver debugging options.
37+
Say Y if you are debugging SOF FW or drivers.
38+
If unsure select "N".
39+
3240
config SND_SOC_SOF_FORCE_NOCODEC_MODE
33-
tristate "SOF force nocodec Mode"
41+
bool "SOF force nocodec Mode"
3442
depends on SND_SOC_SOF_NOCODEC
43+
depends on SND_SOC_SOF_DEBUG
3544
help
3645
This forces SOF to use dummy/nocodec as machine driver, even
3746
though there is a codec detected on the real platform. This is
@@ -41,5 +50,14 @@ config SND_SOC_SOF_FORCE_NOCODEC_MODE
4150
Say Y if you need this force nocodec mode option
4251
If unsure select "N".
4352

53+
config SND_SOC_SOF_DEBUG_XRUN_STOP
54+
bool "SOF stop on XRUN"
55+
depends on SND_SOC_SOF_DEBUG
56+
help
57+
This option forces PCMs to stop on any XRUN event. This is useful to
58+
preserve any trace data ond pipeline status prior to the XRUN.
59+
Say Y if you are debugging SOF FW pipeline XRUNs.
60+
If unsure select "N".
61+
4462
source "sound/soc/sof/intel/Kconfig"
4563
source "sound/soc/sof/xtensa/Kconfig"

sound/soc/sof/core.c

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020
#include "sof-priv.h"
2121
#include "ops.h"
2222

23-
#define TIMEOUT_IPC 5
24-
#define TIMEOUT_BOOT 100
23+
/* SOF defaults if not provided by the platform in ms */
24+
#define TIMEOUT_DEFAULT_IPC 5
25+
#define TIMEOUT_DEFAULT_BOOT 100
26+
27+
/*
28+
* Generic object lookup APIs.
29+
*/
2530

2631
struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev,
2732
struct snd_soc_pcm_runtime *rtd)
@@ -123,11 +128,16 @@ static inline unsigned int sof_get_pages(size_t size)
123128
return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
124129
}
125130

131+
/*
132+
* FW Panic/fault handling.
133+
*/
134+
126135
struct sof_panic_msg {
127136
u32 id;
128137
const char *msg;
129138
};
130139

140+
/* standard FW panic types */
131141
static const struct sof_panic_msg panic_msg[] = {
132142
{SOF_IPC_PANIC_MEM, "out of memory"},
133143
{SOF_IPC_PANIC_WORK, "work subsystem init failed"},
@@ -178,6 +188,43 @@ int snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
178188
}
179189
EXPORT_SYMBOL(snd_sof_get_status);
180190

191+
/*
192+
* Generic buffer page table creation.
193+
*/
194+
195+
int snd_sof_create_page_table(struct snd_sof_dev *sdev,
196+
struct snd_dma_buffer *dmab,
197+
unsigned char *page_table, size_t size)
198+
{
199+
int i, pages;
200+
201+
pages = snd_sgbuf_aligned_pages(size);
202+
203+
dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
204+
dmab->area, size, pages);
205+
206+
for (i = 0; i < pages; i++) {
207+
u32 idx = (((i << 2) + i)) >> 1;
208+
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
209+
u32 *pg_table;
210+
211+
dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
212+
213+
pg_table = (u32 *)(page_table + idx);
214+
215+
if (i & 1)
216+
*pg_table |= (pfn << 4);
217+
else
218+
*pg_table |= pfn;
219+
}
220+
221+
return pages;
222+
}
223+
224+
/*
225+
* SOF Driver enumeration.
226+
*/
227+
181228
static int sof_probe(struct platform_device *pdev)
182229
{
183230
struct snd_sof_pdata *plat_data = dev_get_platdata(&pdev->dev);
@@ -217,11 +264,11 @@ static int sof_probe(struct platform_device *pdev)
217264

218265
/* set default timeouts if none provided */
219266
if (plat_data->desc->ipc_timeout == 0)
220-
sdev->ipc_timeout = TIMEOUT_IPC;
267+
sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC;
221268
else
222269
sdev->ipc_timeout = plat_data->desc->ipc_timeout;
223270
if (plat_data->desc->boot_timeout == 0)
224-
sdev->boot_timeout = TIMEOUT_BOOT;
271+
sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT;
225272
else
226273
sdev->boot_timeout = plat_data->desc->boot_timeout;
227274

@@ -284,6 +331,7 @@ static int sof_probe(struct platform_device *pdev)
284331
/* init DMA trace */
285332
ret = snd_sof_init_trace(sdev);
286333
if (ret < 0) {
334+
/* non fatal */
287335
dev_warn(sdev->dev,
288336
"warning: failed to initialize trace %d\n", ret);
289337
}
@@ -324,34 +372,6 @@ void snd_sof_shutdown(struct device *dev)
324372
}
325373
EXPORT_SYMBOL(snd_sof_shutdown);
326374

327-
int snd_sof_create_page_table(struct snd_sof_dev *sdev,
328-
struct snd_dma_buffer *dmab,
329-
unsigned char *page_table, size_t size)
330-
{
331-
int i, pages;
332-
333-
pages = sof_get_pages(size);
334-
335-
dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
336-
dmab->area, size, pages);
337-
338-
for (i = 0; i < pages; i++) {
339-
u32 idx = (((i << 2) + i)) >> 1;
340-
u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
341-
u32 *pg_table;
342-
343-
dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
344-
345-
pg_table = (u32 *)(page_table + idx);
346-
347-
if (i & 1)
348-
*pg_table |= (pfn << 4);
349-
else
350-
*pg_table |= pfn;
351-
}
352-
353-
return pages;
354-
}
355375

356376
static struct platform_driver sof_driver = {
357377
.driver = {

sound/soc/sof/intel/apl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ struct snd_sof_dsp_ops sof_apl_ops = {
7777
.dbg_dump = hda_dsp_dump,
7878

7979
/* stream callbacks */
80-
.host_stream_open = hda_dsp_pcm_open,
81-
.host_stream_close = hda_dsp_pcm_close,
82-
.host_stream_hw_params = hda_dsp_pcm_hw_params,
83-
.host_stream_trigger = hda_dsp_pcm_trigger,
80+
.pcm_open = hda_dsp_pcm_open,
81+
.pcm_close = hda_dsp_pcm_close,
82+
.pcm_hw_params = hda_dsp_pcm_hw_params,
83+
.pcm_trigger = hda_dsp_pcm_trigger,
8484

8585
/* firmware loading */
8686
.load_firmware = hda_dsp_cl_load_fw,

sound/soc/sof/intel/cnl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ struct snd_sof_dsp_ops sof_cnl_ops = {
205205
.dbg_dump = hda_dsp_dump,
206206

207207
/* stream callbacks */
208-
.host_stream_open = hda_dsp_pcm_open,
209-
.host_stream_close = hda_dsp_pcm_close,
210-
.host_stream_hw_params = hda_dsp_pcm_hw_params,
211-
.host_stream_trigger = hda_dsp_pcm_trigger,
208+
.pcm_open = hda_dsp_pcm_open,
209+
.pcm_close = hda_dsp_pcm_close,
210+
.pcm_hw_params = hda_dsp_pcm_hw_params,
211+
.pcm_trigger = hda_dsp_pcm_trigger,
212212

213213
/* firmware loading */
214214
.load_firmware = hda_dsp_cl_load_fw,

sound/soc/sof/intel/skl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ struct snd_sof_dsp_ops sof_skl_ops = {
7777
.dbg_dump = hda_dsp_dump,
7878

7979
/* stream callbacks */
80-
.host_stream_open = hda_dsp_pcm_open,
81-
.host_stream_close = hda_dsp_pcm_close,
82-
.host_stream_hw_params = hda_dsp_pcm_hw_params,
83-
.host_stream_trigger = hda_dsp_pcm_trigger,
80+
.pcm_open = hda_dsp_pcm_open,
81+
.pcm_close = hda_dsp_pcm_close,
82+
.pcm_hw_params = hda_dsp_pcm_hw_params,
83+
.pcm_trigger = hda_dsp_pcm_trigger,
8484

8585
/* firmware loading */
8686
.load_firmware = hda_dsp_cl_load_fw,

0 commit comments

Comments
 (0)