ctatc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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/spinlock_types.h>
  21. #include <linux/pci.h>
  22. #include <linux/timer.h>
  23. #include <sound/core.h>
  24. #include "ctvmem.h"
  25. #include "ctresource.h"
  26. enum CTALSADEVS { /* Types of alsa devices */
  27. FRONT,
  28. REAR,
  29. CLFE,
  30. SURROUND,
  31. IEC958,
  32. MIXER,
  33. NUM_CTALSADEVS /* This should always be the last */
  34. };
  35. enum CTCARDS {
  36. CTSB0760,
  37. CTHENDRIX,
  38. CTSB08801,
  39. CTSB08802,
  40. CTSB08803,
  41. NUM_CTCARDS /* This should always be the last */
  42. };
  43. struct ct_atc_chip_sub_details {
  44. u16 subsys;
  45. const char *nm_model;
  46. };
  47. struct ct_atc_chip_details {
  48. u16 vendor;
  49. u16 device;
  50. const struct ct_atc_chip_sub_details *sub_details;
  51. const char *nm_card;
  52. };
  53. struct ct_atc;
  54. /* alsa pcm stream descriptor */
  55. struct ct_atc_pcm {
  56. struct snd_pcm_substream *substream;
  57. void (*interrupt)(struct ct_atc_pcm *apcm);
  58. unsigned int started:1;
  59. unsigned int stop_timer:1;
  60. struct timer_list timer;
  61. spinlock_t timer_lock;
  62. unsigned int position;
  63. /* Only mono and interleaved modes are supported now. */
  64. struct ct_vm_block *vm_block;
  65. void *src; /* SRC for interacting with host memory */
  66. void **srccs; /* SRCs for sample rate conversion */
  67. void **srcimps; /* SRC Input Mappers */
  68. void **amixers; /* AMIXERs for routing converted data */
  69. void *mono; /* A SUM resource for mixing chs to one */
  70. unsigned char n_srcc; /* Number of converting SRCs */
  71. unsigned char n_srcimp; /* Number of SRC Input Mappers */
  72. unsigned char n_amixer; /* Number of AMIXERs */
  73. };
  74. /* Chip resource management object */
  75. struct ct_atc {
  76. struct pci_dev *pci;
  77. struct snd_card *card;
  78. unsigned int rsr; /* reference sample rate in Hz */
  79. unsigned int msr; /* master sample rate in rsr */
  80. unsigned int pll_rate; /* current rate of Phase Lock Loop */
  81. const struct ct_atc_chip_details *chip_details;
  82. enum CTCARDS model;
  83. /* Create all alsa devices */
  84. int (*create_alsa_devs)(struct ct_atc *atc);
  85. struct ct_vm *vm; /* device virtual memory manager for this card */
  86. int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  87. void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  88. unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
  89. spinlock_t atc_lock;
  90. int (*pcm_playback_prepare)(struct ct_atc *atc,
  91. struct ct_atc_pcm *apcm);
  92. int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  93. int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  94. int (*pcm_playback_position)(struct ct_atc *atc,
  95. struct ct_atc_pcm *apcm);
  96. int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
  97. struct ct_atc_pcm *apcm);
  98. int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  99. int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  100. int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
  101. int (*pcm_capture_position)(struct ct_atc *atc,
  102. struct ct_atc_pcm *apcm);
  103. int (*pcm_release_resources)(struct ct_atc *atc,
  104. struct ct_atc_pcm *apcm);
  105. int (*select_line_in)(struct ct_atc *atc);
  106. int (*select_mic_in)(struct ct_atc *atc);
  107. int (*select_digit_io)(struct ct_atc *atc);
  108. int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
  109. int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
  110. int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
  111. int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
  112. int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
  113. int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
  114. int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
  115. int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
  116. int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
  117. int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
  118. int (*have_digit_io_switch)(struct ct_atc *atc);
  119. /* Don't touch! Used for internal object. */
  120. void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
  121. void *mixer; /* internal mixer object */
  122. void *hw; /* chip specific hardware access object */
  123. void **daios; /* digital audio io resources */
  124. void **pcm; /* SUMs for collecting all pcm stream */
  125. void **srcs; /* Sample Rate Converters for input signal */
  126. void **srcimps; /* input mappers for SRCs */
  127. unsigned char n_daio;
  128. unsigned char n_src;
  129. unsigned char n_srcimp;
  130. unsigned char n_pcm;
  131. };
  132. int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
  133. unsigned int rsr, unsigned int msr,
  134. struct ct_atc **ratc);
  135. #endif /* CTATC_H */