cs4218.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef _cs4218_h_
  2. /*
  3. * Hacked version of linux/drivers/sound/dmasound/dmasound.h
  4. *
  5. *
  6. * Minor numbers for the sound driver.
  7. *
  8. * Unfortunately Creative called the codec chip of SB as a DSP. For this
  9. * reason the /dev/dsp is reserved for digitized audio use. There is a
  10. * device for true DSP processors but it will be called something else.
  11. * In v3.0 it's /dev/sndproc but this could be a temporary solution.
  12. */
  13. #define _cs4218_h_
  14. #include <linux/types.h>
  15. #include <linux/config.h>
  16. #define SND_NDEVS 256 /* Number of supported devices */
  17. #define SND_DEV_CTL 0 /* Control port /dev/mixer */
  18. #define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
  19. synthesizer and MIDI output) */
  20. #define SND_DEV_MIDIN 2 /* Raw midi access */
  21. #define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
  22. #define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
  23. #define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
  24. #define SND_DEV_STATUS 6 /* /dev/sndstat */
  25. /* #7 not in use now. Was in 2.4. Free for use after v3.0. */
  26. #define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
  27. #define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
  28. #define SND_DEV_PSS SND_DEV_SNDPROC
  29. /* switch on various prinks */
  30. #define DEBUG_DMASOUND 1
  31. #define MAX_AUDIO_DEV 5
  32. #define MAX_MIXER_DEV 4
  33. #define MAX_SYNTH_DEV 3
  34. #define MAX_MIDI_DEV 6
  35. #define MAX_TIMER_DEV 3
  36. #define MAX_CATCH_RADIUS 10
  37. #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
  38. #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
  39. #define IOCTL_IN(arg, ret) \
  40. do { int error = get_user(ret, (int *)(arg)); \
  41. if (error) return error; \
  42. } while (0)
  43. #define IOCTL_OUT(arg, ret) ioctl_return((int *)(arg), ret)
  44. static inline int ioctl_return(int *addr, int value)
  45. {
  46. return value < 0 ? value : put_user(value, addr);
  47. }
  48. #define HAS_RECORD
  49. /*
  50. * Initialization
  51. */
  52. /* description of the set-up applies to either hard or soft settings */
  53. typedef struct {
  54. int format; /* AFMT_* */
  55. int stereo; /* 0 = mono, 1 = stereo */
  56. int size; /* 8/16 bit*/
  57. int speed; /* speed */
  58. } SETTINGS;
  59. /*
  60. * Machine definitions
  61. */
  62. typedef struct {
  63. const char *name;
  64. const char *name2;
  65. void (*open)(void);
  66. void (*release)(void);
  67. void *(*dma_alloc)(unsigned int, int);
  68. void (*dma_free)(void *, unsigned int);
  69. int (*irqinit)(void);
  70. #ifdef MODULE
  71. void (*irqcleanup)(void);
  72. #endif
  73. void (*init)(void);
  74. void (*silence)(void);
  75. int (*setFormat)(int);
  76. int (*setVolume)(int);
  77. int (*setBass)(int);
  78. int (*setTreble)(int);
  79. int (*setGain)(int);
  80. void (*play)(void);
  81. void (*record)(void); /* optional */
  82. void (*mixer_init)(void); /* optional */
  83. int (*mixer_ioctl)(u_int, u_long); /* optional */
  84. int (*write_sq_setup)(void); /* optional */
  85. int (*read_sq_setup)(void); /* optional */
  86. int (*sq_open)(mode_t); /* optional */
  87. int (*state_info)(char *, size_t); /* optional */
  88. void (*abort_read)(void); /* optional */
  89. int min_dsp_speed;
  90. int max_dsp_speed;
  91. int version ;
  92. int hardware_afmts ; /* OSS says we only return h'ware info */
  93. /* when queried via SNDCTL_DSP_GETFMTS */
  94. int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
  95. SETTINGS default_hard ; /* open() or init() should set something valid */
  96. SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
  97. } MACHINE;
  98. /*
  99. * Low level stuff
  100. */
  101. typedef struct {
  102. ssize_t (*ct_ulaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  103. ssize_t (*ct_alaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  104. ssize_t (*ct_s8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  105. ssize_t (*ct_u8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  106. ssize_t (*ct_s16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  107. ssize_t (*ct_u16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  108. ssize_t (*ct_s16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  109. ssize_t (*ct_u16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
  110. } TRANS;
  111. /*
  112. * Sound queue stuff, the heart of the driver
  113. */
  114. struct sound_queue {
  115. /* buffers allocated for this queue */
  116. int numBufs; /* real limits on what the user can have */
  117. int bufSize; /* in bytes */
  118. char **buffers;
  119. /* current parameters */
  120. int locked ; /* params cannot be modified when != 0 */
  121. int user_frags ; /* user requests this many */
  122. int user_frag_size ; /* of this size */
  123. int max_count; /* actual # fragments <= numBufs */
  124. int block_size; /* internal block size in bytes */
  125. int max_active; /* in-use fragments <= max_count */
  126. /* it shouldn't be necessary to declare any of these volatile */
  127. int front, rear, count;
  128. int rear_size;
  129. /*
  130. * The use of the playing field depends on the hardware
  131. *
  132. * Atari, PMac: The number of frames that are loaded/playing
  133. *
  134. * Amiga: Bit 0 is set: a frame is loaded
  135. * Bit 1 is set: a frame is playing
  136. */
  137. int active;
  138. wait_queue_head_t action_queue, open_queue, sync_queue;
  139. int open_mode;
  140. int busy, syncing, xruns, died;
  141. };
  142. #define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ)
  143. #define WAKE_UP(queue) (wake_up_interruptible(&queue))
  144. #endif /* _cs4218_h_ */