simple_card_utils.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * simple_card_utils.h
  4. *
  5. * Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. */
  7. #ifndef __SIMPLE_CARD_UTILS_H
  8. #define __SIMPLE_CARD_UTILS_H
  9. #include <sound/soc.h>
  10. #define asoc_simple_card_init_hp(card, sjack, prefix) \
  11. asoc_simple_card_init_jack(card, sjack, 1, prefix)
  12. #define asoc_simple_card_init_mic(card, sjack, prefix) \
  13. asoc_simple_card_init_jack(card, sjack, 0, prefix)
  14. struct asoc_simple_dai {
  15. const char *name;
  16. unsigned int sysclk;
  17. int clk_direction;
  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. struct asoc_simple_card_data {
  25. u32 convert_rate;
  26. u32 convert_channels;
  27. };
  28. struct asoc_simple_jack {
  29. struct snd_soc_jack jack;
  30. struct snd_soc_jack_pin pin;
  31. struct snd_soc_jack_gpio gpio;
  32. };
  33. int asoc_simple_card_parse_daifmt(struct device *dev,
  34. struct device_node *node,
  35. struct device_node *codec,
  36. char *prefix,
  37. unsigned int *retfmt);
  38. __printf(3, 4)
  39. int asoc_simple_card_set_dailink_name(struct device *dev,
  40. struct snd_soc_dai_link *dai_link,
  41. const char *fmt, ...);
  42. int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
  43. char *prefix);
  44. #define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai) \
  45. asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \
  46. dai_link->cpu_dai_name)
  47. #define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai) \
  48. asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\
  49. dai_link->codec_dai_name)
  50. int asoc_simple_card_parse_clk(struct device *dev,
  51. struct device_node *node,
  52. struct device_node *dai_of_node,
  53. struct asoc_simple_dai *simple_dai,
  54. const char *name);
  55. int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai);
  56. void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
  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. #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. #define asoc_simple_card_of_parse_tdm(np, dai) \
  83. snd_soc_of_parse_tdm_slot(np, &(dai)->tx_slot_mask, \
  84. &(dai)->rx_slot_mask, \
  85. &(dai)->slots, \
  86. &(dai)->slot_width);
  87. int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
  88. struct asoc_simple_dai *simple_dai);
  89. int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link);
  90. void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
  91. int is_single_links);
  92. int asoc_simple_card_clean_reference(struct snd_soc_card *card);
  93. void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data,
  94. struct snd_pcm_hw_params *params);
  95. void asoc_simple_card_parse_convert(struct device *dev, char *prefix,
  96. struct asoc_simple_card_data *data);
  97. int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
  98. char *prefix,
  99. int optional);
  100. int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
  101. char *prefix);
  102. int asoc_simple_card_init_jack(struct snd_soc_card *card,
  103. struct asoc_simple_jack *sjack,
  104. int is_hp, char *prefix);
  105. #endif /* __SIMPLE_CARD_UTILS_H */