1 /* SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 #ifndef __SIMPLE_CARD_UTILS_H
9 #define __SIMPLE_CARD_UTILS_H
11 #include <sound/soc.h>
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)
18 struct asoc_simple_dai
{
24 unsigned int tx_slot_mask
;
25 unsigned int rx_slot_mask
;
29 struct asoc_simple_card_data
{
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
;
40 int asoc_simple_card_parse_daifmt(struct device
*dev
,
41 struct device_node
*node
,
42 struct device_node
*codec
,
44 unsigned int *retfmt
);
46 int asoc_simple_card_set_dailink_name(struct device
*dev
,
47 struct snd_soc_dai_link
*dai_link
,
48 const char *fmt
, ...);
49 int asoc_simple_card_parse_card_name(struct snd_soc_card
*card
,
52 #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \
53 asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \
54 dai_link->cpu_dai_name, NULL)
55 #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \
56 asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\
57 dai_link->codec_dai_name, dai_link->codecs)
58 int asoc_simple_card_parse_clk(struct device
*dev
,
59 struct device_node
*node
,
60 struct device_node
*dai_of_node
,
61 struct asoc_simple_dai
*simple_dai
,
63 struct snd_soc_dai_link_component
*dlc
);
64 int asoc_simple_card_clk_enable(struct asoc_simple_dai
*dai
);
65 void asoc_simple_card_clk_disable(struct asoc_simple_dai
*dai
);
67 #define asoc_simple_card_parse_cpu(node, dai_link, \
68 list_name, cells_name, is_single_link) \
69 asoc_simple_card_parse_dai(node, NULL, \
70 &dai_link->cpu_of_node, \
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) \
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)
77 #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \
78 asoc_simple_card_parse_dai(node, dai_link->platform, \
79 &dai_link->platform_of_node, \
80 NULL, list_name, cells_name, NULL)
81 int asoc_simple_card_parse_dai(struct device_node
*node
,
82 struct snd_soc_dai_link_component
*dlc
,
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
);
89 #define asoc_simple_card_parse_graph_cpu(ep, dai_link) \
90 asoc_simple_card_parse_graph_dai(ep, NULL, \
91 &dai_link->cpu_of_node, \
92 &dai_link->cpu_dai_name)
93 #define asoc_simple_card_parse_graph_codec(ep, dai_link) \
94 asoc_simple_card_parse_graph_dai(ep, dai_link->codecs, \
95 &dai_link->codec_of_node, \
96 &dai_link->codec_dai_name)
97 int asoc_simple_card_parse_graph_dai(struct device_node
*ep
,
98 struct snd_soc_dai_link_component
*dlc
,
99 struct device_node
**endpoint_np
,
100 const char **dai_name
);
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, \
108 int asoc_simple_card_init_dai(struct snd_soc_dai
*dai
,
109 struct asoc_simple_dai
*simple_dai
);
111 int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link
*dai_link
);
112 void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link
*dai_link
,
113 int is_single_links
);
115 int asoc_simple_card_clean_reference(struct snd_soc_card
*card
);
117 void asoc_simple_card_convert_fixup(struct asoc_simple_card_data
*data
,
118 struct snd_pcm_hw_params
*params
);
119 void asoc_simple_card_parse_convert(struct device
*dev
,
120 struct device_node
*np
, char *prefix
,
121 struct asoc_simple_card_data
*data
);
123 int asoc_simple_card_of_parse_routing(struct snd_soc_card
*card
,
125 int asoc_simple_card_of_parse_widgets(struct snd_soc_card
*card
,
128 int asoc_simple_card_init_jack(struct snd_soc_card
*card
,
129 struct asoc_simple_jack
*sjack
,
130 int is_hp
, char *prefix
);
132 #endif /* __SIMPLE_CARD_UTILS_H */