Kuninori Morimoto | abd3147 | 2016-05-31 09:00:14 +0000 | [diff] [blame] | 1 | /* |
Kuninori Morimoto | 29a43aa | 2016-12-02 05:27:30 +0000 | [diff] [blame] | 2 | * simple_card_utils.h |
Kuninori Morimoto | abd3147 | 2016-05-31 09:00:14 +0000 | [diff] [blame] | 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 | */ |
Kuninori Morimoto | 29a43aa | 2016-12-02 05:27:30 +0000 | [diff] [blame] | 10 | #ifndef __SIMPLE_CARD_UTILS_H |
| 11 | #define __SIMPLE_CARD_UTILS_H |
Kuninori Morimoto | abd3147 | 2016-05-31 09:00:14 +0000 | [diff] [blame] | 12 | |
| 13 | #include <sound/soc.h> |
| 14 | |
Kuninori Morimoto | cecdef3 | 2016-06-30 06:02:46 +0000 | [diff] [blame] | 15 | struct asoc_simple_dai { |
| 16 | const char *name; |
| 17 | unsigned int sysclk; |
| 18 | int slots; |
| 19 | int slot_width; |
| 20 | unsigned int tx_slot_mask; |
| 21 | unsigned int rx_slot_mask; |
| 22 | struct clk *clk; |
| 23 | }; |
| 24 | |
Kuninori Morimoto | 13bb1cc | 2017-06-15 00:24:09 +0000 | [diff] [blame] | 25 | struct asoc_simple_card_data { |
| 26 | u32 convert_rate; |
| 27 | u32 convert_channels; |
| 28 | }; |
| 29 | |
Kuninori Morimoto | abd3147 | 2016-05-31 09:00:14 +0000 | [diff] [blame] | 30 | int asoc_simple_card_parse_daifmt(struct device *dev, |
| 31 | struct device_node *node, |
| 32 | struct device_node *codec, |
| 33 | char *prefix, |
| 34 | unsigned int *retfmt); |
Nicolas Iooss | e5668ca | 2016-08-23 10:51:22 +0200 | [diff] [blame] | 35 | __printf(3, 4) |
Kuninori Morimoto | 1db3312 | 2016-07-11 23:57:14 +0000 | [diff] [blame] | 36 | int asoc_simple_card_set_dailink_name(struct device *dev, |
| 37 | struct snd_soc_dai_link *dai_link, |
| 38 | const char *fmt, ...); |
Kuninori Morimoto | fc55c9b | 2016-07-11 23:59:16 +0000 | [diff] [blame] | 39 | int asoc_simple_card_parse_card_name(struct snd_soc_card *card, |
| 40 | char *prefix); |
Kuninori Morimoto | abd3147 | 2016-05-31 09:00:14 +0000 | [diff] [blame] | 41 | |
Kuninori Morimoto | e984fd6 | 2017-01-23 07:29:42 +0000 | [diff] [blame] | 42 | #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \ |
Kuninori Morimoto | 8e16638 | 2017-06-05 04:28:45 +0000 | [diff] [blame] | 43 | asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \ |
| 44 | dai_link->cpu_dai_name) |
Kuninori Morimoto | e984fd6 | 2017-01-23 07:29:42 +0000 | [diff] [blame] | 45 | #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \ |
Kuninori Morimoto | 8e16638 | 2017-06-05 04:28:45 +0000 | [diff] [blame] | 46 | asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\ |
| 47 | dai_link->codec_dai_name) |
Kuninori Morimoto | e984fd6 | 2017-01-23 07:29:42 +0000 | [diff] [blame] | 48 | int asoc_simple_card_parse_clk(struct device *dev, |
| 49 | struct device_node *node, |
Kuninori Morimoto | bb6fc62 | 2016-08-08 05:59:56 +0000 | [diff] [blame] | 50 | struct device_node *dai_of_node, |
Kuninori Morimoto | 8e16638 | 2017-06-05 04:28:45 +0000 | [diff] [blame] | 51 | struct asoc_simple_dai *simple_dai, |
| 52 | const char *name); |
Kuninori Morimoto | 891caea | 2017-06-09 00:43:18 +0000 | [diff] [blame] | 53 | int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai); |
| 54 | void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai); |
Kuninori Morimoto | bb6fc62 | 2016-08-08 05:59:56 +0000 | [diff] [blame] | 55 | |
Kuninori Morimoto | ae30a69 | 2016-08-08 06:01:43 +0000 | [diff] [blame] | 56 | #define asoc_simple_card_parse_cpu(node, dai_link, \ |
| 57 | list_name, cells_name, is_single_link) \ |
| 58 | asoc_simple_card_parse_dai(node, &dai_link->cpu_of_node, \ |
| 59 | &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) |
| 60 | #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \ |
| 61 | asoc_simple_card_parse_dai(node, &dai_link->codec_of_node, \ |
| 62 | &dai_link->codec_dai_name, list_name, cells_name, NULL) |
| 63 | #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \ |
| 64 | asoc_simple_card_parse_dai(node, &dai_link->platform_of_node, \ |
| 65 | NULL, list_name, cells_name, NULL) |
| 66 | int asoc_simple_card_parse_dai(struct device_node *node, |
| 67 | struct device_node **endpoint_np, |
| 68 | const char **dai_name, |
| 69 | const char *list_name, |
| 70 | const char *cells_name, |
| 71 | int *is_single_links); |
| 72 | |
Kuninori Morimoto | 1689333 | 2017-04-20 01:35:18 +0000 | [diff] [blame] | 73 | #define asoc_simple_card_parse_graph_cpu(ep, dai_link) \ |
| 74 | asoc_simple_card_parse_graph_dai(ep, &dai_link->cpu_of_node, \ |
| 75 | &dai_link->cpu_dai_name) |
| 76 | #define asoc_simple_card_parse_graph_codec(ep, dai_link) \ |
| 77 | asoc_simple_card_parse_graph_dai(ep, &dai_link->codec_of_node, \ |
| 78 | &dai_link->codec_dai_name) |
| 79 | int asoc_simple_card_parse_graph_dai(struct device_node *ep, |
| 80 | struct device_node **endpoint_np, |
| 81 | const char **dai_name); |
| 82 | |
Kuninori Morimoto | e68ba20 | 2017-06-14 00:34:35 +0000 | [diff] [blame] | 83 | #define asoc_simple_card_of_parse_tdm(np, dai) \ |
| 84 | snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \ |
| 85 | &(dai)->rx_slot_mask, \ |
| 86 | &(dai)->slots, \ |
| 87 | &(dai)->slot_width); |
| 88 | |
Kuninori Morimoto | 21ba62f | 2016-08-09 05:48:30 +0000 | [diff] [blame] | 89 | int asoc_simple_card_init_dai(struct snd_soc_dai *dai, |
| 90 | struct asoc_simple_dai *simple_dai); |
Kuninori Morimoto | c262c9a | 2016-08-09 05:49:41 +0000 | [diff] [blame] | 91 | |
| 92 | int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link); |
Kuninori Morimoto | 983cebd | 2016-08-10 02:20:19 +0000 | [diff] [blame] | 93 | void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link, |
| 94 | int is_single_links); |
Kuninori Morimoto | c262c9a | 2016-08-09 05:49:41 +0000 | [diff] [blame] | 95 | |
Kuninori Morimoto | 0f4e071 | 2016-08-10 02:21:25 +0000 | [diff] [blame] | 96 | int asoc_simple_card_clean_reference(struct snd_soc_card *card); |
| 97 | |
Kuninori Morimoto | 13bb1cc | 2017-06-15 00:24:09 +0000 | [diff] [blame] | 98 | void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data, |
| 99 | struct snd_pcm_hw_params *params); |
| 100 | void asoc_simple_card_parse_convert(struct device *dev, char *prefix, |
| 101 | struct asoc_simple_card_data *data); |
| 102 | |
Kuninori Morimoto | 3296d07 | 2017-06-15 00:25:02 +0000 | [diff] [blame] | 103 | int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, |
| 104 | char *prefix, |
| 105 | int optional); |
| 106 | |
Kuninori Morimoto | 29a43aa | 2016-12-02 05:27:30 +0000 | [diff] [blame] | 107 | #endif /* __SIMPLE_CARD_UTILS_H */ |