diff options
-rw-r--r-- | sound/soc/intel/skylake/skl-debug.c | 156 | ||||
-rw-r--r-- | sound/soc/intel/skylake/skl-topology.c | 3 | ||||
-rw-r--r-- | sound/soc/intel/skylake/skl.h | 10 |
3 files changed, 169 insertions, 0 deletions
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c index 6bc4565773c5..be3238c63200 100644 --- a/sound/soc/intel/skylake/skl-debug.c +++ b/sound/soc/intel/skylake/skl-debug.c | |||
@@ -16,14 +16,159 @@ | |||
16 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
17 | #include <linux/debugfs.h> | 17 | #include <linux/debugfs.h> |
18 | #include "skl.h" | 18 | #include "skl.h" |
19 | #include "skl-tplg-interface.h" | ||
20 | #include "skl-topology.h" | ||
21 | |||
22 | #define MOD_BUF PAGE_SIZE | ||
19 | 23 | ||
20 | struct skl_debug { | 24 | struct skl_debug { |
21 | struct skl *skl; | 25 | struct skl *skl; |
22 | struct device *dev; | 26 | struct device *dev; |
23 | 27 | ||
24 | struct dentry *fs; | 28 | struct dentry *fs; |
29 | struct dentry *modules; | ||
25 | }; | 30 | }; |
26 | 31 | ||
32 | static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf, | ||
33 | int max_pin, ssize_t size, bool direction) | ||
34 | { | ||
35 | int i; | ||
36 | ssize_t ret = 0; | ||
37 | |||
38 | for (i = 0; i < max_pin; i++) | ||
39 | ret += snprintf(buf + size, MOD_BUF - size, | ||
40 | "%s %d\n\tModule %d\n\tInstance %d\n\t" | ||
41 | "In-used %s\n\tType %s\n" | ||
42 | "\tState %d\n\tIndex %d\n", | ||
43 | direction ? "Input Pin:" : "Output Pin:", | ||
44 | i, m_pin[i].id.module_id, | ||
45 | m_pin[i].id.instance_id, | ||
46 | m_pin[i].in_use ? "Used" : "Unused", | ||
47 | m_pin[i].is_dynamic ? "Dynamic" : "Static", | ||
48 | m_pin[i].pin_state, i); | ||
49 | return ret; | ||
50 | } | ||
51 | |||
52 | static ssize_t skl_print_fmt(struct skl_module_fmt *fmt, char *buf, | ||
53 | ssize_t size, bool direction) | ||
54 | { | ||
55 | return snprintf(buf + size, MOD_BUF - size, | ||
56 | "%s\n\tCh %d\n\tFreq %d\n\tBit depth %d\n\t" | ||
57 | "Valid bit depth %d\n\tCh config %#x\n\tInterleaving %d\n\t" | ||
58 | "Sample Type %d\n\tCh Map %#x\n", | ||
59 | direction ? "Input Format:" : "Output Format:", | ||
60 | fmt->channels, fmt->s_freq, fmt->bit_depth, | ||
61 | fmt->valid_bit_depth, fmt->ch_cfg, | ||
62 | fmt->interleaving_style, fmt->sample_type, | ||
63 | fmt->ch_map); | ||
64 | } | ||
65 | |||
66 | static ssize_t module_read(struct file *file, char __user *user_buf, | ||
67 | size_t count, loff_t *ppos) | ||
68 | { | ||
69 | struct skl_module_cfg *mconfig = file->private_data; | ||
70 | char *buf; | ||
71 | ssize_t ret; | ||
72 | |||
73 | buf = kzalloc(MOD_BUF, GFP_KERNEL); | ||
74 | if (!buf) | ||
75 | return -ENOMEM; | ||
76 | |||
77 | ret = snprintf(buf, MOD_BUF, "Module:\n\tUUID %pUL\n\tModule id %d\n" | ||
78 | "\tInstance id %d\n\tPvt_id %d\n", mconfig->guid, | ||
79 | mconfig->id.module_id, mconfig->id.instance_id, | ||
80 | mconfig->id.pvt_id); | ||
81 | |||
82 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
83 | "Resources:\n\tMCPS %#x\n\tIBS %#x\n\tOBS %#x\t\n", | ||
84 | mconfig->mcps, mconfig->ibs, mconfig->obs); | ||
85 | |||
86 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
87 | "Module data:\n\tCore %d\n\tIn queue %d\n\t" | ||
88 | "Out queue %d\n\tType %s\n", | ||
89 | mconfig->core_id, mconfig->max_in_queue, | ||
90 | mconfig->max_out_queue, | ||
91 | mconfig->is_loadable ? "loadable" : "inbuilt"); | ||
92 | |||
93 | ret += skl_print_fmt(mconfig->in_fmt, buf, ret, true); | ||
94 | ret += skl_print_fmt(mconfig->out_fmt, buf, ret, false); | ||
95 | |||
96 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
97 | "Fixup:\n\tParams %#x\n\tConverter %#x\n", | ||
98 | mconfig->params_fixup, mconfig->converter); | ||
99 | |||
100 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
101 | "Module Gateway:\n\tType %#x\n\tVbus %#x\n\tHW conn %#x\n\tSlot %#x\n", | ||
102 | mconfig->dev_type, mconfig->vbus_id, | ||
103 | mconfig->hw_conn_type, mconfig->time_slot); | ||
104 | |||
105 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
106 | "Pipeline:\n\tID %d\n\tPriority %d\n\tConn Type %d\n\t" | ||
107 | "Pages %#x\n", mconfig->pipe->ppl_id, | ||
108 | mconfig->pipe->pipe_priority, mconfig->pipe->conn_type, | ||
109 | mconfig->pipe->memory_pages); | ||
110 | |||
111 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
112 | "\tParams:\n\t\tHost DMA %d\n\t\tLink DMA %d\n", | ||
113 | mconfig->pipe->p_params->host_dma_id, | ||
114 | mconfig->pipe->p_params->link_dma_id); | ||
115 | |||
116 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
117 | "\tPCM params:\n\t\tCh %d\n\t\tFreq %d\n\t\tFormat %d\n", | ||
118 | mconfig->pipe->p_params->ch, | ||
119 | mconfig->pipe->p_params->s_freq, | ||
120 | mconfig->pipe->p_params->s_fmt); | ||
121 | |||
122 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
123 | "\tLink %#x\n\tStream %#x\n", | ||
124 | mconfig->pipe->p_params->linktype, | ||
125 | mconfig->pipe->p_params->stream); | ||
126 | |||
127 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
128 | "\tState %d\n\tPassthru %s\n", | ||
129 | mconfig->pipe->state, | ||
130 | mconfig->pipe->passthru ? "true" : "false"); | ||
131 | |||
132 | ret += skl_print_pins(mconfig->m_in_pin, buf, | ||
133 | mconfig->max_in_queue, ret, true); | ||
134 | ret += skl_print_pins(mconfig->m_out_pin, buf, | ||
135 | mconfig->max_out_queue, ret, false); | ||
136 | |||
137 | ret += snprintf(buf + ret, MOD_BUF - ret, | ||
138 | "Other:\n\tDomain %d\n\tHomogenous Input %s\n\t" | ||
139 | "Homogenous Output %s\n\tIn Queue Mask %d\n\t" | ||
140 | "Out Queue Mask %d\n\tDMA ID %d\n\tMem Pages %d\n\t" | ||
141 | "Module Type %d\n\tModule State %d\n", | ||
142 | mconfig->domain, | ||
143 | mconfig->homogenous_inputs ? "true" : "false", | ||
144 | mconfig->homogenous_outputs ? "true" : "false", | ||
145 | mconfig->in_queue_mask, mconfig->out_queue_mask, | ||
146 | mconfig->dma_id, mconfig->mem_pages, mconfig->m_state, | ||
147 | mconfig->m_type); | ||
148 | |||
149 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); | ||
150 | |||
151 | kfree(buf); | ||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static const struct file_operations mcfg_fops = { | ||
156 | .open = simple_open, | ||
157 | .read = module_read, | ||
158 | .llseek = default_llseek, | ||
159 | }; | ||
160 | |||
161 | |||
162 | void skl_debug_init_module(struct skl_debug *d, | ||
163 | struct snd_soc_dapm_widget *w, | ||
164 | struct skl_module_cfg *mconfig) | ||
165 | { | ||
166 | if (!debugfs_create_file(w->name, 0444, | ||
167 | d->modules, mconfig, | ||
168 | &mcfg_fops)) | ||
169 | dev_err(d->dev, "%s: module debugfs init failed\n", w->name); | ||
170 | } | ||
171 | |||
27 | struct skl_debug *skl_debugfs_init(struct skl *skl) | 172 | struct skl_debug *skl_debugfs_init(struct skl *skl) |
28 | { | 173 | { |
29 | struct skl_debug *d; | 174 | struct skl_debug *d; |
@@ -43,7 +188,18 @@ struct skl_debug *skl_debugfs_init(struct skl *skl) | |||
43 | d->skl = skl; | 188 | d->skl = skl; |
44 | d->dev = &skl->pci->dev; | 189 | d->dev = &skl->pci->dev; |
45 | 190 | ||
191 | /* now create the module dir */ | ||
192 | d->modules = debugfs_create_dir("modules", d->fs); | ||
193 | if (IS_ERR(d->modules) || !d->modules) { | ||
194 | dev_err(&skl->pci->dev, "modules debugfs create failed\n"); | ||
195 | goto err; | ||
196 | } | ||
197 | |||
46 | return d; | 198 | return d; |
199 | |||
200 | err: | ||
201 | debugfs_remove_recursive(d->fs); | ||
202 | return NULL; | ||
47 | } | 203 | } |
48 | 204 | ||
49 | void skl_debugfs_exit(struct skl_debug *d) | 205 | void skl_debugfs_exit(struct skl_debug *d) |
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 9569f118e97e..c02da16fdfd6 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c | |||
@@ -2472,6 +2472,9 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, | |||
2472 | ret = skl_tplg_get_pvt_data(tplg_w, skl, bus->dev, mconfig); | 2472 | ret = skl_tplg_get_pvt_data(tplg_w, skl, bus->dev, mconfig); |
2473 | if (ret < 0) | 2473 | if (ret < 0) |
2474 | return ret; | 2474 | return ret; |
2475 | |||
2476 | skl_debug_init_module(skl->debugfs, w, mconfig); | ||
2477 | |||
2475 | bind_event: | 2478 | bind_event: |
2476 | if (tplg_w->event_type == 0) { | 2479 | if (tplg_w->event_type == 0) { |
2477 | dev_dbg(bus->dev, "ASoC: No event handler required\n"); | 2480 | dev_dbg(bus->dev, "ASoC: No event handler required\n"); |
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index a47779c819d5..14e7778d7f80 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <sound/hda_register.h> | 24 | #include <sound/hda_register.h> |
25 | #include <sound/hdaudio_ext.h> | 25 | #include <sound/hdaudio_ext.h> |
26 | #include <sound/soc.h> | ||
26 | #include "skl-nhlt.h" | 27 | #include "skl-nhlt.h" |
27 | 28 | ||
28 | #define SKL_SUSPEND_DELAY 2000 | 29 | #define SKL_SUSPEND_DELAY 2000 |
@@ -120,9 +121,14 @@ void skl_update_d0i3c(struct device *dev, bool enable); | |||
120 | int skl_nhlt_create_sysfs(struct skl *skl); | 121 | int skl_nhlt_create_sysfs(struct skl *skl); |
121 | void skl_nhlt_remove_sysfs(struct skl *skl); | 122 | void skl_nhlt_remove_sysfs(struct skl *skl); |
122 | 123 | ||
124 | struct skl_module_cfg; | ||
125 | |||
123 | #ifdef CONFIG_DEBUG_FS | 126 | #ifdef CONFIG_DEBUG_FS |
124 | struct skl_debug *skl_debugfs_init(struct skl *skl); | 127 | struct skl_debug *skl_debugfs_init(struct skl *skl); |
125 | void skl_debugfs_exit(struct skl_debug *d); | 128 | void skl_debugfs_exit(struct skl_debug *d); |
129 | void skl_debug_init_module(struct skl_debug *d, | ||
130 | struct snd_soc_dapm_widget *w, | ||
131 | struct skl_module_cfg *mconfig); | ||
126 | #else | 132 | #else |
127 | static inline struct skl_debug *skl_debugfs_init(struct skl *skl) | 133 | static inline struct skl_debug *skl_debugfs_init(struct skl *skl) |
128 | { | 134 | { |
@@ -130,6 +136,10 @@ static inline struct skl_debug *skl_debugfs_init(struct skl *skl) | |||
130 | } | 136 | } |
131 | static inline void skl_debugfs_exit(struct skl_debug *d) | 137 | static inline void skl_debugfs_exit(struct skl_debug *d) |
132 | {} | 138 | {} |
139 | static inline void skl_debug_init_module(struct skl_debug *d, | ||
140 | struct snd_soc_dapm_widget *w, | ||
141 | struct skl_module_cfg *mconfig) | ||
142 | {} | ||
133 | #endif | 143 | #endif |
134 | 144 | ||
135 | #endif /* __SOUND_SOC_SKL_H */ | 145 | #endif /* __SOUND_SOC_SKL_H */ |