14
14
#include <sound/pcm_params.h>
15
15
#include <sound/soc.h>
16
16
#include <sound/hdaudio_ext.h>
17
+ #include <sound/hda_i915.h>
17
18
#include <sound/hda_codec.h>
18
19
#include <sound/hda_register.h>
19
- #include "hdac_hda.h"
20
20
21
- #define HDAC_ANALOG_DAI_ID 0
22
- #define HDAC_DIGITAL_DAI_ID 1
23
- #define HDAC_ALT_ANALOG_DAI_ID 2
21
+ #include "hdac_hda.h"
24
22
25
23
#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
26
24
SNDRV_PCM_FMTBIT_U8 | \
32
30
SNDRV_PCM_FMTBIT_U32_LE | \
33
31
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
34
32
33
+ #define STUB_HDMI_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
34
+ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
35
+ SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\
36
+ SNDRV_PCM_RATE_192000)
37
+
35
38
static int hdac_hda_dai_open (struct snd_pcm_substream * substream ,
36
39
struct snd_soc_dai * dai );
37
40
static void hdac_hda_dai_close (struct snd_pcm_substream * substream ,
@@ -121,7 +124,46 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = {
121
124
.formats = STUB_FORMATS ,
122
125
.sig_bits = 24 ,
123
126
},
124
- }
127
+ },
128
+ {
129
+ .id = HDAC_HDMI_0_DAI_ID ,
130
+ .name = "intel-hdmi-hifi1" ,
131
+ .ops = & hdac_hda_dai_ops ,
132
+ .playback = {
133
+ .stream_name = "hifi1" ,
134
+ .channels_min = 1 ,
135
+ .channels_max = 32 ,
136
+ .rates = STUB_HDMI_RATES ,
137
+ .formats = STUB_FORMATS ,
138
+ .sig_bits = 24 ,
139
+ },
140
+ },
141
+ {
142
+ .id = HDAC_HDMI_1_DAI_ID ,
143
+ .name = "intel-hdmi-hifi2" ,
144
+ .ops = & hdac_hda_dai_ops ,
145
+ .playback = {
146
+ .stream_name = "hifi2" ,
147
+ .channels_min = 1 ,
148
+ .channels_max = 32 ,
149
+ .rates = STUB_HDMI_RATES ,
150
+ .formats = STUB_FORMATS ,
151
+ .sig_bits = 24 ,
152
+ },
153
+ },
154
+ {
155
+ .id = HDAC_HDMI_2_DAI_ID ,
156
+ .name = "intel-hdmi-hifi3" ,
157
+ .ops = & hdac_hda_dai_ops ,
158
+ .playback = {
159
+ .stream_name = "hifi3" ,
160
+ .channels_min = 1 ,
161
+ .channels_max = 32 ,
162
+ .rates = STUB_HDMI_RATES ,
163
+ .formats = STUB_FORMATS ,
164
+ .sig_bits = 24 ,
165
+ },
166
+ },
125
167
126
168
};
127
169
@@ -135,10 +177,11 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
135
177
136
178
hda_pvt = snd_soc_component_get_drvdata (component );
137
179
pcm = & hda_pvt -> pcm [dai -> id ];
180
+
138
181
if (tx_mask )
139
- pcm [ dai -> id ]. stream_tag [SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask ;
182
+ pcm -> stream_tag [SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask ;
140
183
else
141
- pcm [ dai -> id ]. stream_tag [SNDRV_PCM_STREAM_CAPTURE ] = rx_mask ;
184
+ pcm -> stream_tag [SNDRV_PCM_STREAM_CAPTURE ] = rx_mask ;
142
185
143
186
return 0 ;
144
187
}
@@ -278,6 +321,12 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
278
321
struct hda_pcm * cpcm ;
279
322
const char * pcm_name ;
280
323
324
+ /*
325
+ * map DAI ID to the closest matching PCM name, using the naming
326
+ * scheme used by hda-codec snd_hda_gen_build_pcms() and for
327
+ * HDMI in hda_codec patch_hdmi.c)
328
+ */
329
+
281
330
switch (dai -> id ) {
282
331
case HDAC_ANALOG_DAI_ID :
283
332
pcm_name = "Analog" ;
@@ -288,20 +337,41 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
288
337
case HDAC_ALT_ANALOG_DAI_ID :
289
338
pcm_name = "Alt Analog" ;
290
339
break ;
340
+ case HDAC_HDMI_0_DAI_ID :
341
+ pcm_name = "HDMI 0" ;
342
+ break ;
343
+ case HDAC_HDMI_1_DAI_ID :
344
+ pcm_name = "HDMI 1" ;
345
+ break ;
346
+ case HDAC_HDMI_2_DAI_ID :
347
+ pcm_name = "HDMI 2" ;
348
+ break ;
291
349
default :
292
350
dev_err (& hcodec -> core .dev , "invalid dai id %d\n" , dai -> id );
293
351
return NULL ;
294
352
}
295
353
296
354
list_for_each_entry (cpcm , & hcodec -> pcm_list_head , list ) {
297
- if (strpbrk (cpcm -> name , pcm_name ))
355
+ if (strstr (cpcm -> name , pcm_name ))
298
356
return cpcm ;
299
357
}
300
358
301
359
dev_err (& hcodec -> core .dev , "didn't find PCM for DAI %s\n" , dai -> name );
302
360
return NULL ;
303
361
}
304
362
363
+ static bool is_hdmi_codec (struct hda_codec * hcodec )
364
+ {
365
+ struct hda_pcm * cpcm ;
366
+
367
+ list_for_each_entry (cpcm , & hcodec -> pcm_list_head , list ) {
368
+ if (cpcm -> pcm_type == HDA_PCM_TYPE_HDMI )
369
+ return true;
370
+ }
371
+
372
+ return false;
373
+ }
374
+
305
375
static int hdac_hda_codec_probe (struct snd_soc_component * component )
306
376
{
307
377
struct hdac_hda_priv * hda_pvt =
@@ -322,6 +392,15 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
322
392
323
393
snd_hdac_ext_bus_link_get (hdev -> bus , hlink );
324
394
395
+ /*
396
+ * Ensure any HDA display is powered at codec probe.
397
+ * After snd_hda_codec_device_new(), display power is
398
+ * managed by runtime PM.
399
+ */
400
+ if (hda_pvt -> need_display_power )
401
+ snd_hdac_display_power (hdev -> bus ,
402
+ HDA_CODEC_IDX_CONTROLLER , true);
403
+
325
404
ret = snd_hda_codec_device_new (hcodec -> bus , component -> card -> snd_card ,
326
405
hdev -> addr , hcodec );
327
406
if (ret < 0 ) {
@@ -366,20 +445,31 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)
366
445
dev_dbg (& hdev -> dev , "no patch file found\n" );
367
446
}
368
447
448
+ /* configure codec for 1:1 PCM:DAI mapping */
449
+ hcodec -> mst_no_extra_pcms = 1 ;
450
+
369
451
ret = snd_hda_codec_parse_pcms (hcodec );
370
452
if (ret < 0 ) {
371
453
dev_err (& hdev -> dev , "unable to map pcms to dai %d\n" , ret );
372
454
goto error ;
373
455
}
374
456
375
- ret = snd_hda_codec_build_controls (hcodec );
376
- if (ret < 0 ) {
377
- dev_err (& hdev -> dev , "unable to create controls %d\n" , ret );
378
- goto error ;
457
+ /* HDMI controls need to be created in machine drivers */
458
+ if (!is_hdmi_codec (hcodec )) {
459
+ ret = snd_hda_codec_build_controls (hcodec );
460
+ if (ret < 0 ) {
461
+ dev_err (& hdev -> dev , "unable to create controls %d\n" ,
462
+ ret );
463
+ goto error ;
464
+ }
379
465
}
380
466
381
467
hcodec -> core .lazy_cache = true;
382
468
469
+ if (hda_pvt -> need_display_power )
470
+ snd_hdac_display_power (hdev -> bus ,
471
+ HDA_CODEC_IDX_CONTROLLER , false);
472
+
383
473
/*
384
474
* hdac_device core already sets the state to active and calls
385
475
* get_noresume. So enable runtime and set the device to suspend.
0 commit comments