1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for Digigram Lola PCI-e boards
5 * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
8 #include <linux/kernel.h>
9 #include <linux/init.h>
11 #include <sound/core.h>
12 #include <sound/info.h>
13 #include <sound/pcm.h>
16 static void print_audio_widget(struct snd_info_buffer
*buffer
,
17 struct lola
*chip
, int nid
, const char *name
)
21 lola_read_param(chip
, nid
, LOLA_PAR_AUDIO_WIDGET_CAP
, &val
);
22 snd_iprintf(buffer
, "Node 0x%02x %s wcaps 0x%x\n", nid
, name
, val
);
23 lola_read_param(chip
, nid
, LOLA_PAR_STREAM_FORMATS
, &val
);
24 snd_iprintf(buffer
, " Formats: 0x%x\n", val
);
27 static void print_pin_widget(struct snd_info_buffer
*buffer
,
28 struct lola
*chip
, int nid
, unsigned int ampcap
,
33 lola_read_param(chip
, nid
, LOLA_PAR_AUDIO_WIDGET_CAP
, &val
);
34 snd_iprintf(buffer
, "Node 0x%02x %s wcaps 0x%x\n", nid
, name
, val
);
35 if (val
== 0x00400200)
37 lola_read_param(chip
, nid
, ampcap
, &val
);
38 snd_iprintf(buffer
, " Amp-Caps: 0x%x\n", val
);
39 snd_iprintf(buffer
, " mute=%d, step-size=%d, steps=%d, ofs=%d\n",
40 LOLA_AMP_MUTE_CAPABLE(val
),
41 LOLA_AMP_STEP_SIZE(val
),
42 LOLA_AMP_NUM_STEPS(val
),
43 LOLA_AMP_OFFSET(val
));
44 lola_codec_read(chip
, nid
, LOLA_VERB_GET_MAX_LEVEL
, 0, 0, &val
, NULL
);
45 snd_iprintf(buffer
, " Max-level: 0x%x\n", val
);
48 static void print_clock_widget(struct snd_info_buffer
*buffer
,
49 struct lola
*chip
, int nid
)
54 lola_read_param(chip
, nid
, LOLA_PAR_AUDIO_WIDGET_CAP
, &val
);
55 snd_iprintf(buffer
, "Node 0x%02x [Clock] wcaps 0x%x\n", nid
, val
);
56 num_clocks
= val
& 0xff;
57 for (i
= 0; i
< num_clocks
; i
+= 4) {
59 unsigned short items
[4];
62 lola_codec_read(chip
, nid
, LOLA_VERB_GET_CLOCK_LIST
,
64 items
[0] = val
& 0xfff;
65 items
[1] = (val
>> 16) & 0xfff;
66 items
[2] = res_ex
& 0xfff;
67 items
[3] = (res_ex
>> 16) & 0xfff;
68 for (j
= 0; j
< 4; j
++) {
69 unsigned char type
= items
[j
] >> 8;
70 unsigned int freq
= items
[j
] & 0xff;
71 if (i
+ j
>= num_clocks
)
73 if (type
== LOLA_CLOCK_TYPE_INTERNAL
) {
75 freq
= lola_sample_rate_convert(freq
);
76 } else if (type
== LOLA_CLOCK_TYPE_VIDEO
) {
78 freq
= lola_sample_rate_convert(freq
);
82 snd_iprintf(buffer
, " Clock %d: Type %d:%s, freq=%d\n",
83 i
+ j
, type
, name
, freq
);
88 static void print_mixer_widget(struct snd_info_buffer
*buffer
,
89 struct lola
*chip
, int nid
)
93 lola_read_param(chip
, nid
, LOLA_PAR_AUDIO_WIDGET_CAP
, &val
);
94 snd_iprintf(buffer
, "Node 0x%02x [Mixer] wcaps 0x%x\n", nid
, val
);
97 static void lola_proc_codec_read(struct snd_info_entry
*entry
,
98 struct snd_info_buffer
*buffer
)
100 struct lola
*chip
= entry
->private_data
;
104 lola_read_param(chip
, 0, LOLA_PAR_VENDOR_ID
, &val
);
105 snd_iprintf(buffer
, "Vendor: 0x%08x\n", val
);
106 lola_read_param(chip
, 1, LOLA_PAR_FUNCTION_TYPE
, &val
);
107 snd_iprintf(buffer
, "Function Type: %d\n", val
);
108 lola_read_param(chip
, 1, LOLA_PAR_SPECIFIC_CAPS
, &val
);
109 snd_iprintf(buffer
, "Specific-Caps: 0x%08x\n", val
);
110 snd_iprintf(buffer
, " Pins-In %d, Pins-Out %d\n",
111 chip
->pin
[CAPT
].num_pins
, chip
->pin
[PLAY
].num_pins
);
113 for (i
= 0; i
< chip
->pcm
[CAPT
].num_streams
; i
++, nid
++)
114 print_audio_widget(buffer
, chip
, nid
, "[Audio-In]");
115 for (i
= 0; i
< chip
->pcm
[PLAY
].num_streams
; i
++, nid
++)
116 print_audio_widget(buffer
, chip
, nid
, "[Audio-Out]");
117 for (i
= 0; i
< chip
->pin
[CAPT
].num_pins
; i
++, nid
++)
118 print_pin_widget(buffer
, chip
, nid
, LOLA_PAR_AMP_IN_CAP
,
120 for (i
= 0; i
< chip
->pin
[PLAY
].num_pins
; i
++, nid
++)
121 print_pin_widget(buffer
, chip
, nid
, LOLA_PAR_AMP_OUT_CAP
,
123 if (LOLA_AFG_CLOCK_WIDGET_PRESENT(chip
->lola_caps
)) {
124 print_clock_widget(buffer
, chip
, nid
);
127 if (LOLA_AFG_MIXER_WIDGET_PRESENT(chip
->lola_caps
)) {
128 print_mixer_widget(buffer
, chip
, nid
);
133 /* direct codec access for debugging */
134 static void lola_proc_codec_rw_write(struct snd_info_entry
*entry
,
135 struct snd_info_buffer
*buffer
)
137 struct lola
*chip
= entry
->private_data
;
139 unsigned int id
, verb
, data
, extdata
;
140 while (!snd_info_get_line(buffer
, line
, sizeof(line
))) {
141 if (sscanf(line
, "%u %u %u %u", &id
, &verb
, &data
, &extdata
) != 4)
143 lola_codec_read(chip
, id
, verb
, data
, extdata
,
145 &chip
->debug_res_ex
);
149 static void lola_proc_codec_rw_read(struct snd_info_entry
*entry
,
150 struct snd_info_buffer
*buffer
)
152 struct lola
*chip
= entry
->private_data
;
153 snd_iprintf(buffer
, "0x%x 0x%x\n", chip
->debug_res
, chip
->debug_res_ex
);
157 * dump some registers
159 static void lola_proc_regs_read(struct snd_info_entry
*entry
,
160 struct snd_info_buffer
*buffer
)
162 struct lola
*chip
= entry
->private_data
;
165 for (i
= 0; i
< 0x40; i
+= 4) {
166 snd_iprintf(buffer
, "BAR0 %02x: %08x\n", i
,
167 readl(chip
->bar
[BAR0
].remap_addr
+ i
));
169 snd_iprintf(buffer
, "\n");
170 for (i
= 0; i
< 0x30; i
+= 4) {
171 snd_iprintf(buffer
, "BAR1 %02x: %08x\n", i
,
172 readl(chip
->bar
[BAR1
].remap_addr
+ i
));
174 snd_iprintf(buffer
, "\n");
175 for (i
= 0x80; i
< 0xa0; i
+= 4) {
176 snd_iprintf(buffer
, "BAR1 %02x: %08x\n", i
,
177 readl(chip
->bar
[BAR1
].remap_addr
+ i
));
179 snd_iprintf(buffer
, "\n");
180 for (i
= 0; i
< 32; i
++) {
181 snd_iprintf(buffer
, "DSD %02x STS %08x\n", i
,
182 lola_dsd_read(chip
, i
, STS
));
183 snd_iprintf(buffer
, "DSD %02x LPIB %08x\n", i
,
184 lola_dsd_read(chip
, i
, LPIB
));
185 snd_iprintf(buffer
, "DSD %02x CTL %08x\n", i
,
186 lola_dsd_read(chip
, i
, CTL
));
187 snd_iprintf(buffer
, "DSD %02x LVIL %08x\n", i
,
188 lola_dsd_read(chip
, i
, LVI
));
189 snd_iprintf(buffer
, "DSD %02x BDPL %08x\n", i
,
190 lola_dsd_read(chip
, i
, BDPL
));
191 snd_iprintf(buffer
, "DSD %02x BDPU %08x\n", i
,
192 lola_dsd_read(chip
, i
, BDPU
));
196 void lola_proc_debug_new(struct lola
*chip
)
198 snd_card_ro_proc_new(chip
->card
, "codec", chip
, lola_proc_codec_read
);
199 snd_card_rw_proc_new(chip
->card
, "codec_rw", chip
,
200 lola_proc_codec_rw_read
,
201 lola_proc_codec_rw_write
);
202 snd_card_ro_proc_new(chip
->card
, "regs", chip
, lola_proc_regs_read
);