Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Driver for Digigram miXart soundcards
0004  *
0005  * main header file
0006  *
0007  * Copyright (c) 2003 by Digigram <alsa@digigram.com>
0008  */
0009 
0010 #ifndef __SOUND_MIXART_H
0011 #define __SOUND_MIXART_H
0012 
0013 #include <linux/interrupt.h>
0014 #include <linux/mutex.h>
0015 #include <sound/pcm.h>
0016 
0017 #define MIXART_DRIVER_VERSION   0x000100    /* 0.1.0 */
0018 
0019 
0020 /*
0021  */
0022 
0023 struct mixart_uid {
0024     u32 object_id;
0025     u32 desc;
0026 };
0027 
0028 struct mem_area {
0029     unsigned long phys;
0030     void __iomem *virt;
0031     struct resource *res;
0032 };
0033 
0034 
0035 struct mixart_route {
0036     unsigned char connected;
0037     unsigned char phase_inv;
0038     int volume;
0039 };
0040 
0041 
0042 /* firmware status codes  */
0043 #define MIXART_MOTHERBOARD_XLX_INDEX  0
0044 #define MIXART_MOTHERBOARD_ELF_INDEX  1
0045 #define MIXART_AESEBUBOARD_XLX_INDEX  2
0046 #define MIXART_HARDW_FILES_MAX_INDEX  3  /* xilinx, elf, AESEBU xilinx */
0047 
0048 #define MIXART_MAX_CARDS    4
0049 #define MSG_FIFO_SIZE           16
0050 
0051 #define MIXART_MAX_PHYS_CONNECTORS  (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */
0052 
0053 struct mixart_mgr {
0054     unsigned int num_cards;
0055     struct snd_mixart *chip[MIXART_MAX_CARDS];
0056 
0057     struct pci_dev *pci;
0058 
0059     int irq;
0060 
0061     /* memory-maps */
0062     struct mem_area mem[2];
0063 
0064     /* one and only blocking message or notification may be pending  */
0065     u32 pending_event;
0066     wait_queue_head_t msg_sleep;
0067 
0068     /* messages fifo */
0069     u32 msg_fifo[MSG_FIFO_SIZE];
0070     int msg_fifo_readptr;
0071     int msg_fifo_writeptr;
0072     atomic_t msg_processed;       /* number of messages to be processed in irq thread */
0073 
0074     struct mutex lock;              /* interrupt lock */
0075     struct mutex msg_lock;      /* mailbox lock */
0076 
0077     struct mutex setup_mutex; /* mutex used in hw_params, open and close */
0078 
0079     /* hardware interface */
0080     unsigned int dsp_loaded;      /* bit flags of loaded dsp indices */
0081     unsigned int board_type;      /* read from embedded once elf file is loaded, 250 = miXart8, 251 = with AES, 252 = with Cobranet */
0082 
0083     struct snd_dma_buffer flowinfo;
0084     struct snd_dma_buffer bufferinfo;
0085 
0086     struct mixart_uid         uid_console_manager;
0087     int sample_rate;
0088     int ref_count_rate;
0089 
0090     struct mutex mixer_mutex; /* mutex for mixer */
0091 
0092 };
0093 
0094 
0095 #define MIXART_STREAM_STATUS_FREE   0
0096 #define MIXART_STREAM_STATUS_OPEN   1
0097 #define MIXART_STREAM_STATUS_RUNNING    2
0098 #define MIXART_STREAM_STATUS_DRAINING   3
0099 #define MIXART_STREAM_STATUS_PAUSE  4
0100 
0101 #define MIXART_PLAYBACK_STREAMS     4
0102 #define MIXART_CAPTURE_STREAMS      1
0103 
0104 #define MIXART_PCM_ANALOG       0
0105 #define MIXART_PCM_DIGITAL      1
0106 #define MIXART_PCM_TOTAL        2
0107 
0108 #define MIXART_MAX_STREAM_PER_CARD  (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) )
0109 
0110 
0111 #define MIXART_NOTIFY_CARD_MASK     0xF000
0112 #define MIXART_NOTIFY_CARD_OFFSET   12
0113 #define MIXART_NOTIFY_PCM_MASK      0x0F00
0114 #define MIXART_NOTIFY_PCM_OFFSET    8
0115 #define MIXART_NOTIFY_CAPT_MASK     0x0080
0116 #define MIXART_NOTIFY_SUBS_MASK     0x007F
0117 
0118 
0119 struct mixart_stream {
0120     struct snd_pcm_substream *substream;
0121     struct mixart_pipe *pipe;
0122     int pcm_number;
0123 
0124     int status;      /* nothing, running, draining */
0125 
0126     u64  abs_period_elapsed;  /* last absolute stream position where period_elapsed was called (multiple of runtime->period_size) */
0127     u32  buf_periods;         /* periods counter in the buffer (< runtime->periods) */
0128     u32  buf_period_frag;     /* defines with buf_period_pos the exact position in the buffer (< runtime->period_size) */
0129 
0130     int channels;
0131 };
0132 
0133 
0134 enum mixart_pipe_status {
0135     PIPE_UNDEFINED,
0136     PIPE_STOPPED,
0137     PIPE_RUNNING,
0138     PIPE_CLOCK_SET
0139 };
0140 
0141 struct mixart_pipe {
0142     struct mixart_uid group_uid;            /* id of the pipe, as returned by embedded */
0143     int          stream_count;
0144     struct mixart_uid uid_left_connector;   /* UID's for the audio connectors */
0145     struct mixart_uid uid_right_connector;
0146     enum mixart_pipe_status status;
0147     int references;             /* number of subs openned */
0148     int monitoring;             /* pipe used for monitoring issue */
0149 };
0150 
0151 
0152 struct snd_mixart {
0153     struct snd_card *card;
0154     struct mixart_mgr *mgr;
0155     int chip_idx;               /* zero based */
0156     struct snd_hwdep *hwdep;        /* DSP loader, only for the first card */
0157 
0158     struct snd_pcm *pcm;             /* PCM analog i/o */
0159     struct snd_pcm *pcm_dig;         /* PCM digital i/o */
0160 
0161     /* allocate stereo pipe for instance */
0162     struct mixart_pipe pipe_in_ana;
0163     struct mixart_pipe pipe_out_ana;
0164 
0165     /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */
0166     struct mixart_pipe pipe_in_dig;
0167     struct mixart_pipe pipe_out_dig;
0168 
0169     struct mixart_stream playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */
0170     struct mixart_stream capture_stream[MIXART_PCM_TOTAL];                           /* 0 = pcm, 1 = pcm_dig */
0171 
0172     /* UID's for the physical io's */
0173     struct mixart_uid uid_out_analog_physio;
0174     struct mixart_uid uid_in_analog_physio;
0175 
0176     int analog_playback_active[2];      /* Mixer : Master Playback active (!mute) */
0177     int analog_playback_volume[2];      /* Mixer : Master Playback Volume */
0178     int analog_capture_volume[2];       /* Mixer : Master Capture Volume */
0179     int digital_playback_active[2*MIXART_PLAYBACK_STREAMS][2];  /* Mixer : Digital Playback Active [(analog+AES output)*streams][stereo]*/
0180     int digital_playback_volume[2*MIXART_PLAYBACK_STREAMS][2];  /* Mixer : Digital Playback Volume [(analog+AES output)*streams][stereo]*/
0181     int digital_capture_volume[2][2];   /* Mixer : Digital Capture Volume [analog+AES output][stereo] */
0182     int monitoring_active[2];       /* Mixer : Monitoring Active */
0183     int monitoring_volume[2];       /* Mixer : Monitoring Volume */
0184 };
0185 
0186 struct mixart_bufferinfo
0187 {
0188     u32 buffer_address;
0189     u32 reserved[5];
0190     u32 available_length;
0191     u32 buffer_id;
0192 };
0193 
0194 struct mixart_flowinfo
0195 {
0196     u32 bufferinfo_array_phy_address;
0197     u32 reserved[11];
0198     u32 bufferinfo_count;
0199     u32 capture;
0200 };
0201 
0202 /* exported */
0203 int snd_mixart_create_pcm(struct snd_mixart * chip);
0204 struct mixart_pipe *snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture, int monitoring);
0205 int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr, struct mixart_pipe *pipe, int monitoring);
0206 
0207 #endif /* __SOUND_MIXART_H */