18
18
struct simple_card_data {
19
19
struct snd_soc_card snd_card ;
20
20
struct simple_dai_props {
21
- struct asoc_simple_dai cpu_dai ;
22
- struct asoc_simple_dai codec_dai ;
21
+ struct asoc_simple_dai * cpu_dai ;
22
+ struct asoc_simple_dai * codec_dai ;
23
23
struct snd_soc_dai_link_component codecs ; /* single codec */
24
24
struct snd_soc_dai_link_component platform ;
25
25
unsigned int mclk_fs ;
@@ -28,6 +28,7 @@ struct simple_card_data {
28
28
struct asoc_simple_jack hp_jack ;
29
29
struct asoc_simple_jack mic_jack ;
30
30
struct snd_soc_dai_link * dai_link ;
31
+ struct asoc_simple_dai * dais ;
31
32
};
32
33
33
34
#define simple_priv_to_card (priv ) (&(priv)->snd_card)
@@ -47,13 +48,13 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
47
48
simple_priv_to_props (priv , rtd -> num );
48
49
int ret ;
49
50
50
- ret = asoc_simple_card_clk_enable (& dai_props -> cpu_dai );
51
+ ret = asoc_simple_card_clk_enable (dai_props -> cpu_dai );
51
52
if (ret )
52
53
return ret ;
53
54
54
- ret = asoc_simple_card_clk_enable (& dai_props -> codec_dai );
55
+ ret = asoc_simple_card_clk_enable (dai_props -> codec_dai );
55
56
if (ret )
56
- asoc_simple_card_clk_disable (& dai_props -> cpu_dai );
57
+ asoc_simple_card_clk_disable (dai_props -> cpu_dai );
57
58
58
59
return ret ;
59
60
}
@@ -65,9 +66,9 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
65
66
struct simple_dai_props * dai_props =
66
67
simple_priv_to_props (priv , rtd -> num );
67
68
68
- asoc_simple_card_clk_disable (& dai_props -> cpu_dai );
69
+ asoc_simple_card_clk_disable (dai_props -> cpu_dai );
69
70
70
- asoc_simple_card_clk_disable (& dai_props -> codec_dai );
71
+ asoc_simple_card_clk_disable (dai_props -> codec_dai );
71
72
}
72
73
73
74
static int asoc_simple_set_clk_rate (struct asoc_simple_dai * simple_dai ,
@@ -102,11 +103,11 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
102
103
if (mclk_fs ) {
103
104
mclk = params_rate (params ) * mclk_fs ;
104
105
105
- ret = asoc_simple_set_clk_rate (& dai_props -> codec_dai , mclk );
106
+ ret = asoc_simple_set_clk_rate (dai_props -> codec_dai , mclk );
106
107
if (ret < 0 )
107
108
return ret ;
108
109
109
- ret = asoc_simple_set_clk_rate (& dai_props -> cpu_dai , mclk );
110
+ ret = asoc_simple_set_clk_rate (dai_props -> cpu_dai , mclk );
110
111
if (ret < 0 )
111
112
return ret ;
112
113
@@ -134,17 +135,16 @@ static const struct snd_soc_ops asoc_simple_card_ops = {
134
135
static int asoc_simple_card_dai_init (struct snd_soc_pcm_runtime * rtd )
135
136
{
136
137
struct simple_card_data * priv = snd_soc_card_get_drvdata (rtd -> card );
137
- struct snd_soc_dai * codec = rtd -> codec_dai ;
138
- struct snd_soc_dai * cpu = rtd -> cpu_dai ;
139
- struct simple_dai_props * dai_props =
140
- simple_priv_to_props (priv , rtd -> num );
138
+ struct simple_dai_props * dai_props = simple_priv_to_props (priv , rtd -> num );
141
139
int ret ;
142
140
143
- ret = asoc_simple_card_init_dai (codec , & dai_props -> codec_dai );
141
+ ret = asoc_simple_card_init_dai (rtd -> codec_dai ,
142
+ dai_props -> codec_dai );
144
143
if (ret < 0 )
145
144
return ret ;
146
145
147
- ret = asoc_simple_card_init_dai (cpu , & dai_props -> cpu_dai );
146
+ ret = asoc_simple_card_init_dai (rtd -> cpu_dai ,
147
+ dai_props -> cpu_dai );
148
148
if (ret < 0 )
149
149
return ret ;
150
150
@@ -153,14 +153,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
153
153
154
154
static int asoc_simple_card_dai_link_of (struct device_node * node ,
155
155
struct simple_card_data * priv ,
156
- int idx ,
156
+ int * dai_idx , int link_idx ,
157
157
bool is_top_level_node )
158
158
{
159
159
struct device * dev = simple_priv_to_dev (priv );
160
- struct snd_soc_dai_link * dai_link = simple_priv_to_link (priv , idx );
161
- struct simple_dai_props * dai_props = simple_priv_to_props (priv , idx );
162
- struct asoc_simple_dai * cpu_dai = & dai_props -> cpu_dai ;
163
- struct asoc_simple_dai * codec_dai = & dai_props -> codec_dai ;
160
+ struct snd_soc_dai_link * dai_link = simple_priv_to_link (priv , link_idx );
161
+ struct simple_dai_props * dai_props = simple_priv_to_props (priv , link_idx );
162
+ struct asoc_simple_dai * cpu_dai ;
163
+ struct asoc_simple_dai * codec_dai ;
164
164
struct device_node * cpu = NULL ;
165
165
struct device_node * plat = NULL ;
166
166
struct device_node * codec = NULL ;
@@ -193,6 +193,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
193
193
goto dai_link_of_err ;
194
194
}
195
195
196
+ cpu_dai =
197
+ dai_props -> cpu_dai = & priv -> dais [(* dai_idx )++ ];
198
+ codec_dai =
199
+ dai_props -> codec_dai = & priv -> dais [(* dai_idx )++ ];
200
+
196
201
ret = asoc_simple_card_parse_daifmt (dev , node , codec ,
197
202
prefix , & dai_link -> dai_fmt );
198
203
if (ret < 0 )
@@ -290,6 +295,7 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv)
290
295
struct device_node * dai_link ;
291
296
struct device_node * node = dev -> of_node ;
292
297
int ret ;
298
+ int link_idx , dai_idx ;
293
299
294
300
if (!node )
295
301
return - EINVAL ;
@@ -308,23 +314,24 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv)
308
314
of_property_read_u32 (node , PREFIX "mclk-fs" , & priv -> mclk_fs );
309
315
310
316
/* Single/Muti DAI link(s) & New style of DT node */
317
+ link_idx = 0 ;
318
+ dai_idx = 0 ;
311
319
if (dai_link ) {
312
320
struct device_node * np = NULL ;
313
- int i = 0 ;
314
321
315
322
for_each_child_of_node (node , np ) {
316
- dev_dbg (dev , "\tlink %d:\n" , i );
323
+ dev_dbg (dev , "\tlink %d:\n" , link_idx );
317
324
ret = asoc_simple_card_dai_link_of (np , priv ,
318
- i , false);
325
+ & dai_idx , link_idx ++ , false);
319
326
if (ret < 0 ) {
320
327
of_node_put (np );
321
328
goto card_parse_end ;
322
329
}
323
- i ++ ;
324
330
}
325
331
} else {
326
332
/* For single DAI link & old style of DT node */
327
- ret = asoc_simple_card_dai_link_of (node , priv , 0 , true);
333
+ ret = asoc_simple_card_dai_link_of (node , priv ,
334
+ & dai_idx , link_idx ++ , true);
328
335
if (ret < 0 )
329
336
goto card_parse_end ;
330
337
}
@@ -362,6 +369,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
362
369
struct simple_card_data * priv ;
363
370
struct snd_soc_dai_link * dai_link ;
364
371
struct simple_dai_props * dai_props ;
372
+ struct asoc_simple_dai * dais ;
365
373
struct device * dev = & pdev -> dev ;
366
374
struct device_node * np = dev -> of_node ;
367
375
struct snd_soc_card * card ;
@@ -380,7 +388,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
380
388
381
389
dai_props = devm_kcalloc (dev , num , sizeof (* dai_props ), GFP_KERNEL );
382
390
dai_link = devm_kcalloc (dev , num , sizeof (* dai_link ), GFP_KERNEL );
383
- if (!dai_props || !dai_link )
391
+ dais = devm_kcalloc (dev , num * 2 , sizeof (* dais ), GFP_KERNEL );
392
+ if (!dai_props || !dai_link || !dais )
384
393
return - ENOMEM ;
385
394
386
395
/*
@@ -397,6 +406,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
397
406
398
407
priv -> dai_props = dai_props ;
399
408
priv -> dai_link = dai_link ;
409
+ priv -> dais = dais ;
400
410
401
411
/* Init snd_soc_card */
402
412
card = simple_priv_to_card (priv );
0 commit comments