home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.2 / LINUX-1.2 / LINUX-1 / linux / drivers / sound / dev_table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-20  |  10.5 KB  |  346 lines

  1. /*
  2.  *    dev_table.h
  3.  *
  4.  *    Global definitions for device call tables
  5.  * 
  6.  * Copyright by Hannu Savolainen 1993
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in the
  15.  *    documentation and/or other materials provided with the distribution.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  *
  29.  
  30. */
  31.  
  32. #ifndef _DEV_TABLE_H_
  33. #define _DEV_TABLE_H_
  34.  
  35. /*
  36.  *    NOTE!     NOTE!    NOTE!    NOTE!
  37.  *
  38.  *    If you modify this file, please check the dev_table.c also.
  39.  *
  40.  *    NOTE!     NOTE!    NOTE!    NOTE!
  41.  */
  42.  
  43. struct driver_info {
  44.     int card_type;    /*    From soundcard.h    */
  45.     char *name;
  46.     long (*attach) (long mem_start, struct address_info *hw_config);
  47.     int (*probe) (struct address_info *hw_config);
  48. };
  49.  
  50. struct card_info {
  51.     int card_type;    /* Link (search key) to the driver list */
  52.     struct address_info config;
  53.     int enabled;
  54. };
  55.  
  56. /*
  57.  * Device specific parameters (used only by dmabuf.c)
  58.  */
  59. #define MAX_SUB_BUFFERS        (32*MAX_REALTIME_FACTOR)
  60.  
  61. #define DMODE_NONE        0
  62. #define DMODE_OUTPUT        1
  63. #define DMODE_INPUT        2
  64.  
  65. struct dma_buffparms {
  66.     int      dma_mode;    /* DMODE_INPUT, DMODE_OUTPUT or DMODE_NONE */
  67.  
  68.     /*
  69.       * Pointers to raw buffers
  70.       */
  71.  
  72.       char     *raw_buf[DSP_BUFFCOUNT];
  73.         unsigned long   raw_buf_phys[DSP_BUFFCOUNT];
  74.         int             raw_count;
  75.  
  76.          /*
  77.          * Device state tables
  78.          */
  79.  
  80.     unsigned long flags;
  81. #define DMA_BUSY    0x00000001
  82. #define DMA_RESTART    0x00000002
  83. #define DMA_ACTIVE    0x00000004
  84. #define DMA_STARTED    0x00000008
  85. #define DMA_ALLOC_DONE    0x00000020
  86.  
  87.     int      open_mode;
  88.  
  89.     /*
  90.      * Queue parameters.
  91.      */
  92.            int      qlen;
  93.            int      qhead;
  94.            int      qtail;
  95.  
  96.     int      nbufs;
  97.     int      counts[MAX_SUB_BUFFERS];
  98.     int      subdivision;
  99.     char    *buf[MAX_SUB_BUFFERS];
  100.     unsigned long buf_phys[MAX_SUB_BUFFERS];
  101.  
  102.     int      fragment_size;
  103.     int     max_fragments;
  104.  
  105.     int     bytes_in_use;
  106.  
  107.     int     underrun_count;
  108. };
  109.  
  110. struct audio_operations {
  111.         char name[32];
  112.     int flags;
  113. #define NOTHING_SPECIAL     0
  114. #define NEEDS_RESTART        1
  115. #define DMA_AUTOMODE        2
  116.     int  format_mask;    /* Bitmask for supported audio formats */
  117.     void *devc;        /* Driver specific info */
  118.     int (*open) (int dev, int mode);
  119.     void (*close) (int dev);
  120.     void (*output_block) (int dev, unsigned long buf, 
  121.                   int count, int intrflag, int dma_restart);
  122.     void (*start_input) (int dev, unsigned long buf, 
  123.                  int count, int intrflag, int dma_restart);
  124.     int (*ioctl) (int dev, unsigned int cmd, unsigned int arg, int local);
  125.     int (*prepare_for_input) (int dev, int bufsize, int nbufs);
  126.     int (*prepare_for_output) (int dev, int bufsize, int nbufs);
  127.     void (*reset) (int dev);
  128.     void (*halt_xfer) (int dev);
  129.     int (*local_qlen)(int dev);
  130.         void (*copy_from_user)(int dev, char *localbuf, int localoffs,
  131.                                snd_rw_buf *userbuf, int useroffs, int len);
  132.     int buffcount;
  133.     long buffsize;
  134.     int dmachan;
  135.     struct dma_buffparms *dmap;
  136. };
  137.  
  138. struct mixer_operations {
  139.     int (*ioctl) (int dev, unsigned int cmd, unsigned int arg);
  140. };
  141.  
  142. struct synth_operations {
  143.     struct synth_info *info;
  144.     int midi_dev;
  145.     int synth_type;
  146.     int synth_subtype;
  147.  
  148.     int (*open) (int dev, int mode);
  149.     void (*close) (int dev);
  150.     int (*ioctl) (int dev, unsigned int cmd, unsigned int arg);
  151.     int (*kill_note) (int dev, int voice, int note, int velocity);
  152.     int (*start_note) (int dev, int voice, int note, int velocity);
  153.     int (*set_instr) (int dev, int voice, int instr);
  154.     void (*reset) (int dev);
  155.     void (*hw_control) (int dev, unsigned char *event);
  156.     int (*load_patch) (int dev, int format, snd_rw_buf *addr,
  157.          int offs, int count, int pmgr_flag);
  158.     void (*aftertouch) (int dev, int voice, int pressure);
  159.     void (*controller) (int dev, int voice, int ctrl_num, int value);
  160.     void (*panning) (int dev, int voice, int value);
  161.     void (*volume_method) (int dev, int mode);
  162.     int (*pmgr_interface) (int dev, struct patmgr_info *info);
  163.     void (*bender) (int dev, int chn, int value);
  164.     int (*alloc_voice) (int dev, int chn, int note, struct voice_alloc_info *alloc);
  165.  
  166.      struct voice_alloc_info alloc;
  167.      struct channel_info chn_info[16];
  168. };
  169.  
  170. struct midi_operations {
  171.     struct midi_info info;
  172.     struct synth_operations *converter;
  173.     int (*open) (int dev, int mode,
  174.         void (*inputintr)(int dev, unsigned char data),
  175.         void (*outputintr)(int dev)
  176.         );
  177.     void (*close) (int dev);
  178.     int (*ioctl) (int dev, unsigned int cmd, unsigned int arg);
  179.     int (*putc) (int dev, unsigned char data);
  180.     int (*start_read) (int dev);
  181.     int (*end_read) (int dev);
  182.     void (*kick)(int dev);
  183.     int (*command) (int dev, unsigned char *data);
  184.     int (*buffer_status) (int dev);
  185.     int (*prefix_cmd) (int dev, unsigned char status);
  186. };
  187.  
  188. struct sound_timer_operations {
  189.     struct sound_timer_info info;
  190.     int priority;
  191.     int devlink;
  192.     int (*open)(int dev, int mode);
  193.     void (*close)(int dev);
  194.     int (*event)(int dev, unsigned char *ev);
  195.     unsigned long (*get_time)(int dev);
  196.     int (*ioctl) (int dev, unsigned int cmd, unsigned int arg);
  197.     void (*arm_timer)(int dev, long time);
  198. };
  199.  
  200. #ifdef _DEV_TABLE_C_   
  201.     struct audio_operations *audio_devs[MAX_AUDIO_DEV] = {NULL}; int num_audiodevs = 0;
  202.     struct mixer_operations *mixer_devs[MAX_MIXER_DEV] = {NULL}; int num_mixers = 0;
  203.     struct synth_operations *synth_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV] = {NULL}; int num_synths = 0;
  204.     struct midi_operations *midi_devs[MAX_MIDI_DEV] = {NULL}; int num_midis = 0;
  205.  
  206. #ifndef EXCLUDE_SEQUENCER
  207.     extern struct sound_timer_operations default_sound_timer;
  208.     struct sound_timer_operations *sound_timer_devs[MAX_TIMER_DEV] = 
  209.         {&default_sound_timer, NULL}; 
  210.     int num_sound_timers = 1;
  211. #else
  212.     struct sound_timer_operations *sound_timer_devs[MAX_TIMER_DEV] = 
  213.         {NULL}; 
  214.     int num_sound_timers = 0;
  215. #endif
  216.  
  217. /*
  218.  * List of low level drivers compiled into the kernel.
  219.  */
  220.  
  221.     struct driver_info sound_drivers[] = {
  222. #ifndef EXCLUDE_PSS
  223.       {SNDCARD_PSS, "Echo Personal Sound System PSS (ESC614)", attach_pss, probe_pss},
  224. #endif
  225. #ifndef EXCLUDE_YM3812
  226.         {SNDCARD_ADLIB,    "OPL-2/OPL-3 FM",        attach_adlib_card, probe_adlib},
  227. #endif
  228. #ifndef EXCLUDE_PAS
  229.         {SNDCARD_PAS,    "ProAudioSpectrum",    attach_pas_card, probe_pas},
  230. #endif
  231. #if !defined(EXCLUDE_MPU401) && !defined(EXCLUDE_MIDI)
  232.         {SNDCARD_MPU401,"Roland MPU-401",    attach_mpu401, probe_mpu401},
  233. #endif
  234. #if !defined(EXCLUDE_UART6850) && !defined(EXCLUDE_MIDI)
  235.         {SNDCARD_UART6850,"6860 UART Midi",    attach_uart6850, probe_uart6850},
  236. #endif
  237. #ifndef EXCLUDE_SB
  238.         {SNDCARD_SB,    "SoundBlaster",        attach_sb_card, probe_sb},
  239. #endif
  240. #if !defined(EXCLUDE_SB) && !defined(EXCLUDE_SB16)
  241. #ifndef EXCLUDE_AUDIO
  242.         {SNDCARD_SB16,    "SoundBlaster16",    sb16_dsp_init, sb16_dsp_detect},
  243. #endif
  244. #ifndef EXCLUDE_MIDI
  245.         {SNDCARD_SB16MIDI,"SB16 MIDI",    attach_sb16midi, probe_sb16midi},
  246. #endif
  247. #endif
  248. #ifndef EXCLUDE_GUS16
  249.         {SNDCARD_GUS16,    "Ultrasound 16-bit opt.",    attach_gus_db16, probe_gus_db16},
  250. #endif
  251. #ifndef EXCLUDE_MSS
  252.         {SNDCARD_MSS,    "MS Sound System",    attach_ms_sound, probe_ms_sound},
  253. #endif
  254. #ifndef EXCLUDE_GUS
  255.         {SNDCARD_GUS,    "Gravis Ultrasound",    attach_gus_card, probe_gus},
  256. #endif
  257.         {0,            "*?*",            NULL, NULL}
  258.     };
  259.  
  260. /*
  261.  *    List of devices actually configured in the system.
  262.  *
  263.  *    Note! The detection order is significant. Don't change it.
  264.  */
  265.  
  266.     struct card_info snd_installed_cards[] = {
  267. #ifndef EXCLUDE_PSS
  268.          {SNDCARD_PSS, {PSS_BASE, PSS_IRQ, PSS_DMA}, SND_DEFAULT_ENABLE},
  269. #endif
  270. #if !defined(EXCLUDE_MPU401) && !defined(EXCLUDE_MIDI)
  271.         {SNDCARD_MPU401, {MPU_BASE, MPU_IRQ, 0}, SND_DEFAULT_ENABLE},
  272. #ifdef MPU2_BASE
  273.         {SNDCARD_MPU401, {MPU2_BASE, MPU2_IRQ, 0}, SND_DEFAULT_ENABLE},
  274. #endif
  275. #ifdef MPU3_BASE
  276.         {SNDCARD_MPU401, {MPU3_BASE, MPU2_IRQ, 0}, SND_DEFAULT_ENABLE},
  277. #endif
  278. #endif
  279. #ifndef EXCLUDE_MSS
  280.         {SNDCARD_MSS, {MSS_BASE, MSS_IRQ, MSS_DMA}, SND_DEFAULT_ENABLE},
  281. #    ifdef MSS2_BASE
  282.         {SNDCARD_MSS, {MSS2_BASE, MSS2_IRQ, MSS2_DMA}, SND_DEFAULT_ENABLE},
  283. #    endif
  284. #endif
  285.  
  286. #if !defined(EXCLUDE_UART6850) && !defined(EXCLUDE_MIDI)
  287.         {SNDCARD_UART6850, {U6850_BASE, U6850_IRQ, 0}, SND_DEFAULT_ENABLE},
  288. #endif
  289.  
  290. #ifndef EXCLUDE_PAS
  291.         {SNDCARD_PAS, {PAS_BASE, PAS_IRQ, PAS_DMA}, SND_DEFAULT_ENABLE},
  292. #endif
  293.  
  294. #ifndef EXCLUDE_SB
  295.         {SNDCARD_SB, {SBC_BASE, SBC_IRQ, SBC_DMA}, SND_DEFAULT_ENABLE},
  296. #endif
  297.  
  298. #if !defined(EXCLUDE_SB) && !defined(EXCLUDE_SB16)
  299. #ifndef EXCLUDE_AUDIO
  300.         {SNDCARD_SB16, {SBC_BASE, SBC_IRQ, SB16_DMA}, SND_DEFAULT_ENABLE},
  301. #endif
  302. #ifndef EXCLUDE_MIDI
  303.         {SNDCARD_SB16MIDI,{SB16MIDI_BASE, SBC_IRQ, 0}, SND_DEFAULT_ENABLE},
  304. #endif
  305. #endif
  306.  
  307. #ifndef EXCLUDE_GUS
  308. #ifndef EXCLUDE_GUS16
  309.         {SNDCARD_GUS16, {GUS16_BASE, GUS16_IRQ, GUS16_DMA}, SND_DEFAULT_ENABLE},
  310. #endif
  311.         {SNDCARD_GUS, {GUS_BASE, GUS_IRQ, GUS_DMA}, SND_DEFAULT_ENABLE},
  312. #endif
  313.  
  314. #ifndef EXCLUDE_YM3812
  315.         {SNDCARD_ADLIB, {FM_MONO, 0, 0}, SND_DEFAULT_ENABLE},
  316. #endif
  317.         {0, {0}, 0}
  318.     };
  319.  
  320.     int num_sound_drivers =
  321.         sizeof(sound_drivers) / sizeof (struct driver_info);
  322.     int num_sound_cards =
  323.         sizeof(snd_installed_cards) / sizeof (struct card_info);
  324.  
  325.  
  326. #else
  327.     extern struct audio_operations * audio_devs[MAX_AUDIO_DEV]; int num_audiodevs;
  328.     extern struct mixer_operations * mixer_devs[MAX_MIXER_DEV]; extern int num_mixers;
  329.     extern struct synth_operations * synth_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV]; extern int num_synths;
  330.     extern struct midi_operations * midi_devs[MAX_MIDI_DEV]; extern int num_midis;
  331.     extern struct sound_timer_operations * sound_timer_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV]; extern int num_sound_timers;
  332.  
  333.     extern struct driver_info sound_drivers[];
  334.     extern int num_sound_drivers;
  335.     extern struct card_info snd_installed_cards[];
  336.     extern int num_sound_cards;
  337.  
  338. long sndtable_init(long mem_start);
  339. int sndtable_get_cardcount (void);
  340. struct address_info *sound_getconf(int card_type);
  341. void sound_chconf(int card_type, int ioaddr, int irq, int dma);
  342. int snd_find_driver(int type);
  343.  
  344. #endif    /* _DEV_TABLE_C_ */
  345. #endif    /* _DEV_TABLE_H_ */
  346.