Commit | Line | Data |
---|---|---|
d613a7f4 KM |
1 | /* SPDX-License-Identifier: GPL-2.0 |
2 | * | |
29a43aa9 | 3 | * simple_card_utils.h |
abd3147e KM |
4 | * |
5 | * Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | |
abd3147e | 6 | */ |
d613a7f4 | 7 | |
29a43aa9 KM |
8 | #ifndef __SIMPLE_CARD_UTILS_H |
9 | #define __SIMPLE_CARD_UTILS_H | |
abd3147e KM |
10 | |
11 | #include <sound/soc.h> | |
12 | ||
62c2c9fc KS |
13 | #define asoc_simple_card_init_hp(card, sjack, prefix) \ |
14 | asoc_simple_card_init_jack(card, sjack, 1, prefix) | |
15 | #define asoc_simple_card_init_mic(card, sjack, prefix) \ | |
16 | asoc_simple_card_init_jack(card, sjack, 0, prefix) | |
17 | ||
cecdef36 KM |
18 | struct asoc_simple_dai { |
19 | const char *name; | |
20 | unsigned int sysclk; | |
a728f560 | 21 | int clk_direction; |
cecdef36 KM |
22 | int slots; |
23 | int slot_width; | |
24 | unsigned int tx_slot_mask; | |
25 | unsigned int rx_slot_mask; | |
26 | struct clk *clk; | |
27 | }; | |
28 | ||
13bb1cc0 KM |
29 | struct asoc_simple_card_data { |
30 | u32 convert_rate; | |
31 | u32 convert_channels; | |
32 | }; | |
33 | ||
62c2c9fc KS |
34 | struct asoc_simple_jack { |
35 | struct snd_soc_jack jack; | |
36 | struct snd_soc_jack_pin pin; | |
37 | struct snd_soc_jack_gpio gpio; | |
38 | }; | |
39 | ||
abd3147e KM |
40 | int asoc_simple_card_parse_daifmt(struct device *dev, |
41 | struct device_node *node, | |
42 | struct device_node *codec, | |
43 | char *prefix, | |
44 | unsigned int *retfmt); | |
e5668cae | 45 | __printf(3, 4) |
1db3312e KM |
46 | int asoc_simple_card_set_dailink_name(struct device *dev, |
47 | struct snd_soc_dai_link *dai_link, | |
48 | const char *fmt, ...); | |
fc55c9b5 KM |
49 | int asoc_simple_card_parse_card_name(struct snd_soc_card *card, |
50 | char *prefix); | |
abd3147e | 51 | |
e984fd61 | 52 | #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \ |
8e166382 | 53 | asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ |
e664de68 | 54 | dai_link->cpu_dai_name, NULL) |
e984fd61 | 55 | #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \ |
8e166382 | 56 | asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ |
e664de68 | 57 | dai_link->codec_dai_name, dai_link->codecs) |
e984fd61 KM |
58 | int asoc_simple_card_parse_clk(struct device *dev, |
59 | struct device_node *node, | |
bb6fc620 | 60 | struct device_node *dai_of_node, |
8e166382 | 61 | struct asoc_simple_dai *simple_dai, |
e664de68 KM |
62 | const char *dai_name, |
63 | struct snd_soc_dai_link_component *dlc); | |
891caea4 KM |
64 | int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); |
65 | void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); | |
bb6fc620 | 66 | |
ae30a694 KM |
67 | #define asoc_simple_card_parse_cpu(node, dai_link, \ |
68 | list_name, cells_name, is_single_link) \ | |
e664de68 KM |
69 | asoc_simple_card_parse_dai(node, NULL, \ |
70 | &dai_link->cpu_of_node, \ | |
ae30a694 KM |
71 | &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) |
72 | #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ | |
e664de68 KM |
73 | asoc_simple_card_parse_dai(node, dai_link->codecs, \ |
74 | &dai_link->codec_of_node, \ | |
75 | &dai_link->codec_dai_name, \ | |
76 | list_name, cells_name, NULL) | |
ae30a694 | 77 | #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ |
910fdcab | 78 | asoc_simple_card_parse_dai(node, dai_link->platforms, \ |
e664de68 | 79 | &dai_link->platform_of_node, \ |
ae30a694 KM |
80 | NULL, list_name, cells_name, NULL) |
81 | int asoc_simple_card_parse_dai(struct device_node *node, | |
e664de68 | 82 | struct snd_soc_dai_link_component *dlc, |
ae30a694 KM |
83 | struct device_node **endpoint_np, |
84 | const char **dai_name, | |
85 | const char *list_name, | |
86 | const char *cells_name, | |
87 | int *is_single_links); | |
88 | ||
1689333f | 89 | #define asoc_simple_card_parse_graph_cpu(ep, dai_link) \ |
e664de68 KM |
90 | asoc_simple_card_parse_graph_dai(ep, NULL, \ |
91 | &dai_link->cpu_of_node, \ | |
1689333f KM |
92 | &dai_link->cpu_dai_name) |
93 | #define asoc_simple_card_parse_graph_codec(ep, dai_link) \ | |
e664de68 KM |
94 | asoc_simple_card_parse_graph_dai(ep, dai_link->codecs, \ |
95 | &dai_link->codec_of_node, \ | |
1689333f KM |
96 | &dai_link->codec_dai_name) |
97 | int asoc_simple_card_parse_graph_dai(struct device_node *ep, | |
e664de68 | 98 | struct snd_soc_dai_link_component *dlc, |
1689333f KM |
99 | struct device_node **endpoint_np, |
100 | const char **dai_name); | |
101 | ||
e68ba207 KM |
102 | #define asoc_simple_card_of_parse_tdm(np, dai) \ |
103 | snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ | |
104 | &(dai)->rx_slot_mask, \ | |
105 | &(dai)->slots, \ | |
106 | &(dai)->slot_width); | |
107 | ||
21ba62f8 KM |
108 | int asoc_simple_card_init_dai(struct snd_soc_dai *dai, |
109 | struct asoc_simple_dai *simple_dai); | |
c262c9ab | 110 | |
fe7ed4de | 111 | void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link); |
983cebd6 KM |
112 | void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, |
113 | int is_single_links); | |
c262c9ab | 114 | |
0f4e0711 KM |
115 | int asoc_simple_card_clean_reference(struct snd_soc_card *card); |
116 | ||
13bb1cc0 KM |
117 | void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, |
118 | struct snd_pcm_hw_params *params); | |
a48bf02b KM |
119 | void asoc_simple_card_parse_convert(struct device *dev, |
120 | struct device_node *np, char *prefix, | |
13bb1cc0 KM |
121 | struct asoc_simple_card_data *data); |
122 | ||
3296d078 | 123 | int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, |
33404f3f | 124 | char *prefix); |
b31f11d0 KM |
125 | int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, |
126 | char *prefix); | |
3296d078 | 127 | |
62c2c9fc KS |
128 | int asoc_simple_card_init_jack(struct snd_soc_card *card, |
129 | struct asoc_simple_jack *sjack, | |
130 | int is_hp, char *prefix); | |
131 | ||
29a43aa9 | 132 | #endif /* __SIMPLE_CARD_UTILS_H */ |