simple_card_utils.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * simple_card_core.h
  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. */
  10. #ifndef __SIMPLE_CARD_CORE_H
  11. #define __SIMPLE_CARD_CORE_H
  12. #include <sound/soc.h>
  13. struct asoc_simple_dai {
  14. const char *name;
  15. unsigned int sysclk;
  16. int slots;
  17. int slot_width;
  18. unsigned int tx_slot_mask;
  19. unsigned int rx_slot_mask;
  20. struct clk *clk;
  21. };
  22. int asoc_simple_card_parse_daifmt(struct device *dev,
  23. struct device_node *node,
  24. struct device_node *codec,
  25. char *prefix,
  26. unsigned int *retfmt);
  27. __printf(3, 4)
  28. int asoc_simple_card_set_dailink_name(struct device *dev,
  29. struct snd_soc_dai_link *dai_link,
  30. const char *fmt, ...);
  31. int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
  32. char *prefix);
  33. #define asoc_simple_card_parse_clk_cpu(node, dai_link, simple_dai) \
  34. asoc_simple_card_parse_clk(node, dai_link->cpu_of_node, simple_dai)
  35. #define asoc_simple_card_parse_clk_codec(node, dai_link, simple_dai) \
  36. asoc_simple_card_parse_clk(node, dai_link->codec_of_node, simple_dai)
  37. int asoc_simple_card_parse_clk(struct device_node *node,
  38. struct device_node *dai_of_node,
  39. struct asoc_simple_dai *simple_dai);
  40. #define asoc_simple_card_parse_cpu(node, dai_link, \
  41. list_name, cells_name, is_single_link) \
  42. asoc_simple_card_parse_dai(node, &dai_link->cpu_of_node, \
  43. &dai_link->cpu_dai_name, list_name, cells_name, is_single_link)
  44. #define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name) \
  45. asoc_simple_card_parse_dai(node, &dai_link->codec_of_node, \
  46. &dai_link->codec_dai_name, list_name, cells_name, NULL)
  47. #define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name) \
  48. asoc_simple_card_parse_dai(node, &dai_link->platform_of_node, \
  49. NULL, list_name, cells_name, NULL)
  50. int asoc_simple_card_parse_dai(struct device_node *node,
  51. struct device_node **endpoint_np,
  52. const char **dai_name,
  53. const char *list_name,
  54. const char *cells_name,
  55. int *is_single_links);
  56. int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
  57. struct asoc_simple_dai *simple_dai);
  58. int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link);
  59. void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
  60. int is_single_links);
  61. int asoc_simple_card_clean_reference(struct snd_soc_card *card);
  62. #endif /* __SIMPLE_CARD_CORE_H */