wm_adsp.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * wm_adsp.h -- Wolfson ADSP support
  3. *
  4. * Copyright 2012 Wolfson Microelectronics plc
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __WM_ADSP_H
  13. #define __WM_ADSP_H
  14. #include <sound/soc.h>
  15. #include <sound/soc-dapm.h>
  16. #include <sound/compress_driver.h>
  17. #include "wmfw.h"
  18. /* Return values for wm_adsp_compr_handle_irq */
  19. #define WM_ADSP_COMPR_OK 0
  20. #define WM_ADSP_COMPR_VOICE_TRIGGER 1
  21. struct wm_adsp_region {
  22. int type;
  23. unsigned int base;
  24. };
  25. struct wm_adsp_alg_region {
  26. struct list_head list;
  27. unsigned int alg;
  28. int type;
  29. unsigned int base;
  30. };
  31. struct wm_adsp_compr;
  32. struct wm_adsp_compr_buf;
  33. struct wm_adsp {
  34. const char *part;
  35. int num;
  36. int type;
  37. struct device *dev;
  38. struct regmap *regmap;
  39. struct snd_soc_card *card;
  40. int base;
  41. int sysclk_reg;
  42. int sysclk_mask;
  43. int sysclk_shift;
  44. struct list_head alg_regions;
  45. unsigned int fw_id;
  46. unsigned int fw_id_version;
  47. const struct wm_adsp_region *mem;
  48. int num_mems;
  49. int fw;
  50. int fw_ver;
  51. bool booted;
  52. bool running;
  53. struct list_head ctl_list;
  54. struct work_struct boot_work;
  55. struct wm_adsp_compr *compr;
  56. struct wm_adsp_compr_buf *buffer;
  57. struct mutex pwr_lock;
  58. #ifdef CONFIG_DEBUG_FS
  59. struct dentry *debugfs_root;
  60. char *wmfw_file_name;
  61. char *bin_file_name;
  62. #endif
  63. };
  64. #define WM_ADSP1(wname, num) \
  65. SND_SOC_DAPM_PGA_E(wname, SND_SOC_NOPM, num, 0, NULL, 0, \
  66. wm_adsp1_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)
  67. #define WM_ADSP2(wname, num, event_fn) \
  68. { .id = snd_soc_dapm_supply, .name = wname " Preloader", \
  69. .reg = SND_SOC_NOPM, .shift = num, .event = event_fn, \
  70. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD, \
  71. .subseq = 100, /* Ensure we run after SYSCLK supply widget */ }, \
  72. { .id = snd_soc_dapm_out_drv, .name = wname, \
  73. .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp2_event, \
  74. .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }
  75. extern const struct snd_kcontrol_new wm_adsp_fw_controls[];
  76. int wm_adsp1_init(struct wm_adsp *dsp);
  77. int wm_adsp2_init(struct wm_adsp *dsp);
  78. void wm_adsp2_remove(struct wm_adsp *dsp);
  79. int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec);
  80. int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec);
  81. int wm_adsp1_event(struct snd_soc_dapm_widget *w,
  82. struct snd_kcontrol *kcontrol, int event);
  83. int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
  84. struct snd_kcontrol *kcontrol, int event,
  85. unsigned int freq);
  86. int wm_adsp2_event(struct snd_soc_dapm_widget *w,
  87. struct snd_kcontrol *kcontrol, int event);
  88. extern int wm_adsp_compr_open(struct wm_adsp *dsp,
  89. struct snd_compr_stream *stream);
  90. extern int wm_adsp_compr_free(struct snd_compr_stream *stream);
  91. extern int wm_adsp_compr_set_params(struct snd_compr_stream *stream,
  92. struct snd_compr_params *params);
  93. extern int wm_adsp_compr_get_caps(struct snd_compr_stream *stream,
  94. struct snd_compr_caps *caps);
  95. extern int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd);
  96. extern int wm_adsp_compr_handle_irq(struct wm_adsp *dsp);
  97. extern int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
  98. struct snd_compr_tstamp *tstamp);
  99. extern int wm_adsp_compr_copy(struct snd_compr_stream *stream,
  100. char __user *buf, size_t count);
  101. #endif