18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/********************************************************************* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * msnd.h 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Turtle Beach MultiSound Sound Card Driver for Linux 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Some parts of this header file were derived from the Turtle Beach 98c2ecf20Sopenharmony_ci * MultiSound Driver Development Kit. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Copyright (C) 1998 Andrew Veliath 128c2ecf20Sopenharmony_ci * Copyright (C) 1993 Turtle Beach Systems, Inc. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci ********************************************************************/ 158c2ecf20Sopenharmony_ci#ifndef __MSND_H 168c2ecf20Sopenharmony_ci#define __MSND_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define DEFSAMPLERATE 44100 198c2ecf20Sopenharmony_ci#define DEFSAMPLESIZE SNDRV_PCM_FORMAT_S16 208c2ecf20Sopenharmony_ci#define DEFCHANNELS 1 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define SRAM_BANK_SIZE 0x8000 238c2ecf20Sopenharmony_ci#define SRAM_CNTL_START 0x7F00 248c2ecf20Sopenharmony_ci#define SMA_STRUCT_START 0x7F40 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define DSP_BASE_ADDR 0x4000 278c2ecf20Sopenharmony_ci#define DSP_BANK_BASE 0x4000 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define AGND 0x01 308c2ecf20Sopenharmony_ci#define SIGNAL 0x02 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define EXT_DSP_BIT_DCAL 0x0001 338c2ecf20Sopenharmony_ci#define EXT_DSP_BIT_MIDI_CON 0x0002 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define BUFFSIZE 0x8000 368c2ecf20Sopenharmony_ci#define HOSTQ_SIZE 0x40 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define DAP_BUFF_SIZE 0x2400 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define DAPQ_STRUCT_SIZE 0x10 418c2ecf20Sopenharmony_ci#define DARQ_STRUCT_SIZE 0x10 428c2ecf20Sopenharmony_ci#define DAPQ_BUFF_SIZE (3 * 0x10) 438c2ecf20Sopenharmony_ci#define DARQ_BUFF_SIZE (3 * 0x10) 448c2ecf20Sopenharmony_ci#define MODQ_BUFF_SIZE 0x400 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define DAPQ_DATA_BUFF 0x6C00 478c2ecf20Sopenharmony_ci#define DARQ_DATA_BUFF 0x6C30 488c2ecf20Sopenharmony_ci#define MODQ_DATA_BUFF 0x6C60 498c2ecf20Sopenharmony_ci#define MIDQ_DATA_BUFF 0x7060 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define DAPQ_OFFSET SRAM_CNTL_START 528c2ecf20Sopenharmony_ci#define DARQ_OFFSET (SRAM_CNTL_START + 0x08) 538c2ecf20Sopenharmony_ci#define MODQ_OFFSET (SRAM_CNTL_START + 0x10) 548c2ecf20Sopenharmony_ci#define MIDQ_OFFSET (SRAM_CNTL_START + 0x18) 558c2ecf20Sopenharmony_ci#define DSPQ_OFFSET (SRAM_CNTL_START + 0x20) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define HP_ICR 0x00 588c2ecf20Sopenharmony_ci#define HP_CVR 0x01 598c2ecf20Sopenharmony_ci#define HP_ISR 0x02 608c2ecf20Sopenharmony_ci#define HP_IVR 0x03 618c2ecf20Sopenharmony_ci#define HP_NU 0x04 628c2ecf20Sopenharmony_ci#define HP_INFO 0x04 638c2ecf20Sopenharmony_ci#define HP_TXH 0x05 648c2ecf20Sopenharmony_ci#define HP_RXH 0x05 658c2ecf20Sopenharmony_ci#define HP_TXM 0x06 668c2ecf20Sopenharmony_ci#define HP_RXM 0x06 678c2ecf20Sopenharmony_ci#define HP_TXL 0x07 688c2ecf20Sopenharmony_ci#define HP_RXL 0x07 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define HP_ICR_DEF 0x00 718c2ecf20Sopenharmony_ci#define HP_CVR_DEF 0x12 728c2ecf20Sopenharmony_ci#define HP_ISR_DEF 0x06 738c2ecf20Sopenharmony_ci#define HP_IVR_DEF 0x0f 748c2ecf20Sopenharmony_ci#define HP_NU_DEF 0x00 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define HP_IRQM 0x09 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define HPR_BLRC 0x08 798c2ecf20Sopenharmony_ci#define HPR_SPR1 0x09 808c2ecf20Sopenharmony_ci#define HPR_SPR2 0x0A 818c2ecf20Sopenharmony_ci#define HPR_TCL0 0x0B 828c2ecf20Sopenharmony_ci#define HPR_TCL1 0x0C 838c2ecf20Sopenharmony_ci#define HPR_TCL2 0x0D 848c2ecf20Sopenharmony_ci#define HPR_TCL3 0x0E 858c2ecf20Sopenharmony_ci#define HPR_TCL4 0x0F 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define HPICR_INIT 0x80 888c2ecf20Sopenharmony_ci#define HPICR_HM1 0x40 898c2ecf20Sopenharmony_ci#define HPICR_HM0 0x20 908c2ecf20Sopenharmony_ci#define HPICR_HF1 0x10 918c2ecf20Sopenharmony_ci#define HPICR_HF0 0x08 928c2ecf20Sopenharmony_ci#define HPICR_TREQ 0x02 938c2ecf20Sopenharmony_ci#define HPICR_RREQ 0x01 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define HPCVR_HC 0x80 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define HPISR_HREQ 0x80 988c2ecf20Sopenharmony_ci#define HPISR_DMA 0x40 998c2ecf20Sopenharmony_ci#define HPISR_HF3 0x10 1008c2ecf20Sopenharmony_ci#define HPISR_HF2 0x08 1018c2ecf20Sopenharmony_ci#define HPISR_TRDY 0x04 1028c2ecf20Sopenharmony_ci#define HPISR_TXDE 0x02 1038c2ecf20Sopenharmony_ci#define HPISR_RXDF 0x01 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#define HPIO_290 0 1068c2ecf20Sopenharmony_ci#define HPIO_260 1 1078c2ecf20Sopenharmony_ci#define HPIO_250 2 1088c2ecf20Sopenharmony_ci#define HPIO_240 3 1098c2ecf20Sopenharmony_ci#define HPIO_230 4 1108c2ecf20Sopenharmony_ci#define HPIO_220 5 1118c2ecf20Sopenharmony_ci#define HPIO_210 6 1128c2ecf20Sopenharmony_ci#define HPIO_3E0 7 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define HPMEM_NONE 0 1158c2ecf20Sopenharmony_ci#define HPMEM_B000 1 1168c2ecf20Sopenharmony_ci#define HPMEM_C800 2 1178c2ecf20Sopenharmony_ci#define HPMEM_D000 3 1188c2ecf20Sopenharmony_ci#define HPMEM_D400 4 1198c2ecf20Sopenharmony_ci#define HPMEM_D800 5 1208c2ecf20Sopenharmony_ci#define HPMEM_E000 6 1218c2ecf20Sopenharmony_ci#define HPMEM_E800 7 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#define HPIRQ_NONE 0 1248c2ecf20Sopenharmony_ci#define HPIRQ_5 1 1258c2ecf20Sopenharmony_ci#define HPIRQ_7 2 1268c2ecf20Sopenharmony_ci#define HPIRQ_9 3 1278c2ecf20Sopenharmony_ci#define HPIRQ_10 4 1288c2ecf20Sopenharmony_ci#define HPIRQ_11 5 1298c2ecf20Sopenharmony_ci#define HPIRQ_12 6 1308c2ecf20Sopenharmony_ci#define HPIRQ_15 7 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define HIMT_PLAY_DONE 0x00 1338c2ecf20Sopenharmony_ci#define HIMT_RECORD_DONE 0x01 1348c2ecf20Sopenharmony_ci#define HIMT_MIDI_EOS 0x02 1358c2ecf20Sopenharmony_ci#define HIMT_MIDI_OUT 0x03 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define HIMT_MIDI_IN_UCHAR 0x0E 1388c2ecf20Sopenharmony_ci#define HIMT_DSP 0x0F 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define HDEX_BASE 0x92 1418c2ecf20Sopenharmony_ci#define HDEX_PLAY_START (0 + HDEX_BASE) 1428c2ecf20Sopenharmony_ci#define HDEX_PLAY_STOP (1 + HDEX_BASE) 1438c2ecf20Sopenharmony_ci#define HDEX_PLAY_PAUSE (2 + HDEX_BASE) 1448c2ecf20Sopenharmony_ci#define HDEX_PLAY_RESUME (3 + HDEX_BASE) 1458c2ecf20Sopenharmony_ci#define HDEX_RECORD_START (4 + HDEX_BASE) 1468c2ecf20Sopenharmony_ci#define HDEX_RECORD_STOP (5 + HDEX_BASE) 1478c2ecf20Sopenharmony_ci#define HDEX_MIDI_IN_START (6 + HDEX_BASE) 1488c2ecf20Sopenharmony_ci#define HDEX_MIDI_IN_STOP (7 + HDEX_BASE) 1498c2ecf20Sopenharmony_ci#define HDEX_MIDI_OUT_START (8 + HDEX_BASE) 1508c2ecf20Sopenharmony_ci#define HDEX_MIDI_OUT_STOP (9 + HDEX_BASE) 1518c2ecf20Sopenharmony_ci#define HDEX_AUX_REQ (10 + HDEX_BASE) 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci#define HDEXAR_CLEAR_PEAKS 1 1548c2ecf20Sopenharmony_ci#define HDEXAR_IN_SET_POTS 2 1558c2ecf20Sopenharmony_ci#define HDEXAR_AUX_SET_POTS 3 1568c2ecf20Sopenharmony_ci#define HDEXAR_CAL_A_TO_D 4 1578c2ecf20Sopenharmony_ci#define HDEXAR_RD_EXT_DSP_BITS 5 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/* Pinnacle only HDEXAR defs */ 1608c2ecf20Sopenharmony_ci#define HDEXAR_SET_ANA_IN 0 1618c2ecf20Sopenharmony_ci#define HDEXAR_SET_SYNTH_IN 4 1628c2ecf20Sopenharmony_ci#define HDEXAR_READ_DAT_IN 5 1638c2ecf20Sopenharmony_ci#define HDEXAR_MIC_SET_POTS 6 1648c2ecf20Sopenharmony_ci#define HDEXAR_SET_DAT_IN 7 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci#define HDEXAR_SET_SYNTH_48 8 1678c2ecf20Sopenharmony_ci#define HDEXAR_SET_SYNTH_44 9 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define HIWORD(l) ((u16)((((u32)(l)) >> 16) & 0xFFFF)) 1708c2ecf20Sopenharmony_ci#define LOWORD(l) ((u16)(u32)(l)) 1718c2ecf20Sopenharmony_ci#define HIBYTE(w) ((u8)(((u16)(w) >> 8) & 0xFF)) 1728c2ecf20Sopenharmony_ci#define LOBYTE(w) ((u8)(w)) 1738c2ecf20Sopenharmony_ci#define MAKELONG(low, hi) ((long)(((u16)(low))|(((u32)((u16)(hi)))<<16))) 1748c2ecf20Sopenharmony_ci#define MAKEWORD(low, hi) ((u16)(((u8)(low))|(((u16)((u8)(hi)))<<8))) 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#define PCTODSP_OFFSET(w) (u16)((w)/2) 1778c2ecf20Sopenharmony_ci#define PCTODSP_BASED(w) (u16)(((w)/2) + DSP_BASE_ADDR) 1788c2ecf20Sopenharmony_ci#define DSPTOPC_BASED(w) (((w) - DSP_BASE_ADDR) * 2) 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#ifdef SLOWIO 1818c2ecf20Sopenharmony_ci# undef outb 1828c2ecf20Sopenharmony_ci# undef inb 1838c2ecf20Sopenharmony_ci# define outb outb_p 1848c2ecf20Sopenharmony_ci# define inb inb_p 1858c2ecf20Sopenharmony_ci#endif 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* JobQueueStruct */ 1888c2ecf20Sopenharmony_ci#define JQS_wStart 0x00 1898c2ecf20Sopenharmony_ci#define JQS_wSize 0x02 1908c2ecf20Sopenharmony_ci#define JQS_wHead 0x04 1918c2ecf20Sopenharmony_ci#define JQS_wTail 0x06 1928c2ecf20Sopenharmony_ci#define JQS__size 0x08 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci/* DAQueueDataStruct */ 1958c2ecf20Sopenharmony_ci#define DAQDS_wStart 0x00 1968c2ecf20Sopenharmony_ci#define DAQDS_wSize 0x02 1978c2ecf20Sopenharmony_ci#define DAQDS_wFormat 0x04 1988c2ecf20Sopenharmony_ci#define DAQDS_wSampleSize 0x06 1998c2ecf20Sopenharmony_ci#define DAQDS_wChannels 0x08 2008c2ecf20Sopenharmony_ci#define DAQDS_wSampleRate 0x0A 2018c2ecf20Sopenharmony_ci#define DAQDS_wIntMsg 0x0C 2028c2ecf20Sopenharmony_ci#define DAQDS_wFlags 0x0E 2038c2ecf20Sopenharmony_ci#define DAQDS__size 0x10 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci#include <sound/pcm.h> 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_cistruct snd_msnd { 2088c2ecf20Sopenharmony_ci void __iomem *mappedbase; 2098c2ecf20Sopenharmony_ci int play_period_bytes; 2108c2ecf20Sopenharmony_ci int playLimit; 2118c2ecf20Sopenharmony_ci int playPeriods; 2128c2ecf20Sopenharmony_ci int playDMAPos; 2138c2ecf20Sopenharmony_ci int banksPlayed; 2148c2ecf20Sopenharmony_ci int captureDMAPos; 2158c2ecf20Sopenharmony_ci int capturePeriodBytes; 2168c2ecf20Sopenharmony_ci int captureLimit; 2178c2ecf20Sopenharmony_ci int capturePeriods; 2188c2ecf20Sopenharmony_ci struct snd_card *card; 2198c2ecf20Sopenharmony_ci void *msndmidi_mpu; 2208c2ecf20Sopenharmony_ci struct snd_rawmidi *rmidi; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci /* Hardware resources */ 2238c2ecf20Sopenharmony_ci long io; 2248c2ecf20Sopenharmony_ci int memid, irqid; 2258c2ecf20Sopenharmony_ci int irq, irq_ref; 2268c2ecf20Sopenharmony_ci unsigned long base; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci /* Motorola 56k DSP SMA */ 2298c2ecf20Sopenharmony_ci void __iomem *SMA; 2308c2ecf20Sopenharmony_ci void __iomem *DAPQ; 2318c2ecf20Sopenharmony_ci void __iomem *DARQ; 2328c2ecf20Sopenharmony_ci void __iomem *MODQ; 2338c2ecf20Sopenharmony_ci void __iomem *MIDQ; 2348c2ecf20Sopenharmony_ci void __iomem *DSPQ; 2358c2ecf20Sopenharmony_ci int dspq_data_buff, dspq_buff_size; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci /* State variables */ 2388c2ecf20Sopenharmony_ci enum { msndClassic, msndPinnacle } type; 2398c2ecf20Sopenharmony_ci fmode_t mode; 2408c2ecf20Sopenharmony_ci unsigned long flags; 2418c2ecf20Sopenharmony_ci#define F_RESETTING 0 2428c2ecf20Sopenharmony_ci#define F_HAVEDIGITAL 1 2438c2ecf20Sopenharmony_ci#define F_AUDIO_WRITE_INUSE 2 2448c2ecf20Sopenharmony_ci#define F_WRITING 3 2458c2ecf20Sopenharmony_ci#define F_WRITEBLOCK 4 2468c2ecf20Sopenharmony_ci#define F_WRITEFLUSH 5 2478c2ecf20Sopenharmony_ci#define F_AUDIO_READ_INUSE 6 2488c2ecf20Sopenharmony_ci#define F_READING 7 2498c2ecf20Sopenharmony_ci#define F_READBLOCK 8 2508c2ecf20Sopenharmony_ci#define F_EXT_MIDI_INUSE 9 2518c2ecf20Sopenharmony_ci#define F_HDR_MIDI_INUSE 10 2528c2ecf20Sopenharmony_ci#define F_DISABLE_WRITE_NDELAY 11 2538c2ecf20Sopenharmony_ci spinlock_t lock; 2548c2ecf20Sopenharmony_ci spinlock_t mixer_lock; 2558c2ecf20Sopenharmony_ci int nresets; 2568c2ecf20Sopenharmony_ci unsigned recsrc; 2578c2ecf20Sopenharmony_ci#define LEVEL_ENTRIES 32 2588c2ecf20Sopenharmony_ci int left_levels[LEVEL_ENTRIES]; 2598c2ecf20Sopenharmony_ci int right_levels[LEVEL_ENTRIES]; 2608c2ecf20Sopenharmony_ci int calibrate_signal; 2618c2ecf20Sopenharmony_ci int play_sample_size, play_sample_rate, play_channels; 2628c2ecf20Sopenharmony_ci int play_ndelay; 2638c2ecf20Sopenharmony_ci int capture_sample_size, capture_sample_rate, capture_channels; 2648c2ecf20Sopenharmony_ci int capture_ndelay; 2658c2ecf20Sopenharmony_ci u8 bCurrentMidiPatch; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci int last_playbank, last_recbank; 2688c2ecf20Sopenharmony_ci struct snd_pcm_substream *playback_substream; 2698c2ecf20Sopenharmony_ci struct snd_pcm_substream *capture_substream; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_civoid snd_msnd_init_queue(void __iomem *base, int start, int size); 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ciint snd_msnd_send_dsp_cmd(struct snd_msnd *chip, u8 cmd); 2768c2ecf20Sopenharmony_ciint snd_msnd_send_word(struct snd_msnd *chip, 2778c2ecf20Sopenharmony_ci unsigned char high, 2788c2ecf20Sopenharmony_ci unsigned char mid, 2798c2ecf20Sopenharmony_ci unsigned char low); 2808c2ecf20Sopenharmony_ciint snd_msnd_upload_host(struct snd_msnd *chip, 2818c2ecf20Sopenharmony_ci const u8 *bin, int len); 2828c2ecf20Sopenharmony_ciint snd_msnd_enable_irq(struct snd_msnd *chip); 2838c2ecf20Sopenharmony_ciint snd_msnd_disable_irq(struct snd_msnd *chip); 2848c2ecf20Sopenharmony_civoid snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file); 2858c2ecf20Sopenharmony_ciint snd_msnd_DAPQ(struct snd_msnd *chip, int start); 2868c2ecf20Sopenharmony_ciint snd_msnd_DARQ(struct snd_msnd *chip, int start); 2878c2ecf20Sopenharmony_ciint snd_msnd_pcm(struct snd_card *card, int device); 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ciint snd_msndmidi_new(struct snd_card *card, int device); 2908c2ecf20Sopenharmony_civoid snd_msndmidi_input_read(void *mpu); 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_civoid snd_msndmix_setup(struct snd_msnd *chip); 2938c2ecf20Sopenharmony_ciint snd_msndmix_new(struct snd_card *card); 2948c2ecf20Sopenharmony_ciint snd_msndmix_force_recsrc(struct snd_msnd *chip, int recsrc); 2958c2ecf20Sopenharmony_ci#endif /* __MSND_H */ 296