ctatc.h 5.2 KB

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