ctatc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  4. *
  5. * @File ctatc.h
  6. *
  7. * @Brief
  8. * This file contains the definition of the device resource management object.
  9. *
  10. * @Author Liu Chun
  11. * @Date Mar 28 2008
  12. */
  13. #ifndef CTATC_H
  14. #define CTATC_H
  15. #include <linux/types.h>
  16. #include <linux/mutex.h>
  17. #include <linux/pci.h>
  18. #include <linux/timer.h>
  19. #include <sound/core.h>
  20. #include "ctvmem.h"
  21. #include "cthardware.h"
  22. #include "ctresource.h"
  23. enum CTALSADEVS { /* Types of alsa devices */
  24. FRONT,
  25. SURROUND,
  26. CLFE,
  27. SIDE,
  28. IEC958,
  29. MIXER,
  30. NUM_CTALSADEVS /* This should always be the last */
  31. };
  32. struct ct_atc_chip_sub_details {
  33. u16 subsys;
  34. const char *nm_model;
  35. };
  36. struct ct_atc_chip_details {
  37. u16 vendor;
  38. u16 device;
  39. const struct ct_atc_chip_sub_details *sub_details;
  40. const char *nm_card;
  41. };
  42. struct ct_atc;
  43. struct ct_timer;
  44. struct ct_timer_instance;
  45. /* alsa pcm stream descriptor */
  46. struct ct_atc_pcm {
  47. struct snd_pcm_substream *substream;
  48. void (*interrupt)(struct ct_atc_pcm *apcm);
  49. struct ct_timer_instance *timer;
  50. unsigned int started:1;
  51. /* Only mono and interleaved modes are supported now. */
  52. struct ct_vm_block *vm_block;
  53. void *src; /* SRC for interacting with host memory */
  54. void **srccs; /* SRCs for sample rate conversion */
  55. void **srcimps; /* SRC Input Mappers */
  56. void **amixers; /* AMIXERs for routing converted data */
  57. void *mono; /* A SUM resource for mixing chs to one */
  58. unsigned char n_srcc; /* Number of converting SRCs */
  59. unsigned char n_srcimp; /* Number of SRC Input Mappers */
  60. unsigned char n_amixer; /* Number of AMIXERs */
  61. };
  62. /* Chip resource management object */
  63. struct ct_atc {
  64. struct pci_dev *pci;
  65. struct snd_card *card;
  66. unsigned int rsr; /* reference sample rate in Hz */
  67. unsigned int msr; /* master sample rate in rsr */
  68. unsigned int pll_rate; /* current rate of Phase Lock Loop */
  69. int chip_type;
  70. int model;
  71. const char *chip_name;
  72. const char *model_name;
  73. struct ct_vm *vm; /* device virtual memory manager for this card */
  74. int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  75. void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  76. unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
  77. struct mutex atc_mutex;
  78. int (*pcm_playback_prepare)(struct ct_atc *atc,
  79. struct ct_atc_pcm *apcm);
  80. int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  81. int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  82. int (*pcm_playback_position)(struct ct_atc *atc,
  83. struct ct_atc_pcm *apcm);
  84. int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
  85. struct ct_atc_pcm *apcm);
  86. int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  87. int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  88. int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  89. int (*pcm_capture_position)(struct ct_atc *atc,
  90. struct ct_atc_pcm *apcm);
  91. int (*pcm_release_resources)(struct ct_atc *atc,
  92. struct ct_atc_pcm *apcm);
  93. int (*select_line_in)(struct ct_atc *atc);
  94. int (*select_mic_in)(struct ct_atc *atc);
  95. int (*select_digit_io)(struct ct_atc *atc);
  96. int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
  97. int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
  98. int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
  99. int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
  100. int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
  101. int (*mic_unmute)(struct ct_atc *atc, unsigned char state);
  102. int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
  103. int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
  104. int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
  105. int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
  106. int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
  107. struct capabilities (*capabilities)(struct ct_atc *atc);
  108. int (*output_switch_get)(struct ct_atc *atc);
  109. int (*output_switch_put)(struct ct_atc *atc, int position);
  110. int (*mic_source_switch_get)(struct ct_atc *atc);
  111. int (*mic_source_switch_put)(struct ct_atc *atc, int position);
  112. /* Don't touch! Used for internal object. */
  113. void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
  114. void *mixer; /* internal mixer object */
  115. struct hw *hw; /* chip specific hardware access object */
  116. void **daios; /* digital audio io resources */
  117. void **pcm; /* SUMs for collecting all pcm stream */
  118. void **srcs; /* Sample Rate Converters for input signal */
  119. void **srcimps; /* input mappers for SRCs */
  120. unsigned char n_daio;
  121. unsigned char n_src;
  122. unsigned char n_srcimp;
  123. unsigned char n_pcm;
  124. struct ct_timer *timer;
  125. #ifdef CONFIG_PM_SLEEP
  126. int (*suspend)(struct ct_atc *atc);
  127. int (*resume)(struct ct_atc *atc);
  128. #define NUM_PCMS (NUM_CTALSADEVS - 1)
  129. struct snd_pcm *pcms[NUM_PCMS];
  130. #endif
  131. };
  132. int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
  133. unsigned int rsr, unsigned int msr, int chip_type,
  134. unsigned int subsysid, struct ct_atc **ratc);
  135. int ct_atc_create_alsa_devs(struct ct_atc *atc);
  136. #endif /* CTATC_H */