cs4218.h 5.2 KB

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