]>
Commit | Line | Data |
---|---|---|
abd3147e | 1 | /* |
29a43aa9 | 2 | * simple_card_utils.h |
abd3147e KM |
3 | * |
4 | * Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | */ | |
29a43aa9 KM |
10 | #ifndef __SIMPLE_CARD_UTILS_H |
11 | #define __SIMPLE_CARD_UTILS_H | |
abd3147e KM |
12 | |
13 | #include <sound/soc.h> | |
14 | ||
cecdef36 KM |
15 | struct asoc_simple_dai { |
16 | const char *name; | |
17 | unsigned int sysclk; | |
a728f560 | 18 | int clk_direction; |
cecdef36 KM |
19 | int slots; |
20 | int slot_width; | |
21 | unsigned int tx_slot_mask; | |
22 | unsigned int rx_slot_mask; | |
23 | struct clk *clk; | |
24 | }; | |
25 | ||
13bb1cc0 KM |
26 | struct asoc_simple_card_data { |
27 | u32 convert_rate; | |
28 | u32 convert_channels; | |
29 | }; | |
30 | ||
abd3147e KM |
31 | int asoc_simple_card_parse_daifmt(struct device *dev, |
32 | struct device_node *node, | |
33 | struct device_node *codec, | |
34 | char *prefix, | |
35 | unsigned int *retfmt); | |
e5668cae | 36 | __printf(3, 4) |
1db3312e KM |
37 | int asoc_simple_card_set_dailink_name(struct device *dev, |
38 | struct snd_soc_dai_link *dai_link, | |
39 | const char *fmt, ...); | |
fc55c9b5 KM |
40 | int asoc_simple_card_parse_card_name(struct snd_soc_card *card, |
41 | char *prefix); | |
abd3147e | 42 | |
e984fd61 | 43 | #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \ |
8e166382 KM |
44 | asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ |
45 | dai_link->cpu_dai_name) | |
e984fd61 | 46 | #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \ |
8e166382 KM |
47 | asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ |
48 | dai_link->codec_dai_name) | |
e984fd61 KM |
49 | int asoc_simple_card_parse_clk(struct device *dev, |
50 | struct device_node *node, | |
bb6fc620 | 51 | struct device_node *dai_of_node, |
8e166382 KM |
52 | struct asoc_simple_dai *simple_dai, |
53 | const char *name); | |
891caea4 KM |
54 | int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); |
55 | void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); | |
bb6fc620 | 56 | |
ae30a694 KM |
57 | #define asoc_simple_card_parse_cpu(node, dai_link, \ |
58 | list_name, cells_name, is_single_link) \ | |
59 | asoc_simple_card_parse_dai(node, &dai_link->cpu_of_node, \ | |
60 | &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) | |
61 | #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ | |
62 | asoc_simple_card_parse_dai(node, &dai_link->codec_of_node, \ | |
63 | &dai_link->codec_dai_name, list_name, cells_name, NULL) | |
64 | #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ | |
65 | asoc_simple_card_parse_dai(node, &dai_link->platform_of_node, \ | |
66 | NULL, list_name, cells_name, NULL) | |
67 | int asoc_simple_card_parse_dai(struct device_node *node, | |
68 | struct device_node **endpoint_np, | |
69 | const char **dai_name, | |
70 | const char *list_name, | |
71 | const char *cells_name, | |
72 | int *is_single_links); | |
73 | ||
1689333f KM |
74 | #define asoc_simple_card_parse_graph_cpu(ep, dai_link) \ |
75 | asoc_simple_card_parse_graph_dai(ep, &dai_link->cpu_of_node, \ | |
76 | &dai_link->cpu_dai_name) | |
77 | #define asoc_simple_card_parse_graph_codec(ep, dai_link) \ | |
78 | asoc_simple_card_parse_graph_dai(ep, &dai_link->codec_of_node, \ | |
79 | &dai_link->codec_dai_name) | |
80 | int asoc_simple_card_parse_graph_dai(struct device_node *ep, | |
81 | struct device_node **endpoint_np, | |
82 | const char **dai_name); | |
83 | ||
e68ba207 KM |
84 | #define asoc_simple_card_of_parse_tdm(np, dai) \ |
85 | snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ | |
86 | &(dai)->rx_slot_mask, \ | |
87 | &(dai)->slots, \ | |
88 | &(dai)->slot_width); | |
89 | ||
21ba62f8 KM |
90 | int asoc_simple_card_init_dai(struct snd_soc_dai *dai, |
91 | struct asoc_simple_dai *simple_dai); | |
c262c9ab KM |
92 | |
93 | int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link); | |
983cebd6 KM |
94 | void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, |
95 | int is_single_links); | |
c262c9ab | 96 | |
0f4e0711 KM |
97 | int asoc_simple_card_clean_reference(struct snd_soc_card *card); |
98 | ||
13bb1cc0 KM |
99 | void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, |
100 | struct snd_pcm_hw_params *params); | |
101 | void asoc_simple_card_parse_convert(struct device *dev, char *prefix, | |
102 | struct asoc_simple_card_data *data); | |
103 | ||
3296d078 KM |
104 | int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, |
105 | char *prefix, | |
106 | int optional); | |
b31f11d0 KM |
107 | int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, |
108 | char *prefix); | |
3296d078 | 109 | |
29a43aa9 | 110 | #endif /* __SIMPLE_CARD_UTILS_H */ |