/*1* Driver for Digigram pcxhr soundcards2*3* main header file4*5* Copyright (c) 2004 by Digigram <[email protected]>6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*/2122#ifndef __SOUND_PCXHR_H23#define __SOUND_PCXHR_H2425#include <linux/interrupt.h>26#include <linux/mutex.h>27#include <sound/pcm.h>2829#define PCXHR_DRIVER_VERSION 0x000906 /* 0.9.6 */30#define PCXHR_DRIVER_VERSION_STRING "0.9.6" /* 0.9.6 */313233#define PCXHR_MAX_CARDS 634#define PCXHR_PLAYBACK_STREAMS 43536#define PCXHR_GRANULARITY 96 /* min 96 and multiple of 48 */37/* transfer granularity of pipes and the dsp time (MBOX4) */38#define PCXHR_GRANULARITY_MIN 9639/* TODO : granularity could be 64 or 128 */40#define PCXHR_GRANULARITY_HR22 192 /* granularity for stereo cards */4142struct snd_pcxhr;43struct pcxhr_mgr;4445struct pcxhr_stream;46struct pcxhr_pipe;4748enum pcxhr_clock_type {49PCXHR_CLOCK_TYPE_INTERNAL = 0,50PCXHR_CLOCK_TYPE_WORD_CLOCK,51PCXHR_CLOCK_TYPE_AES_SYNC,52PCXHR_CLOCK_TYPE_AES_1,53PCXHR_CLOCK_TYPE_AES_2,54PCXHR_CLOCK_TYPE_AES_3,55PCXHR_CLOCK_TYPE_AES_4,56PCXHR_CLOCK_TYPE_MAX = PCXHR_CLOCK_TYPE_AES_4,57HR22_CLOCK_TYPE_INTERNAL = PCXHR_CLOCK_TYPE_INTERNAL,58HR22_CLOCK_TYPE_AES_SYNC,59HR22_CLOCK_TYPE_AES_1,60HR22_CLOCK_TYPE_MAX = HR22_CLOCK_TYPE_AES_1,61};6263struct pcxhr_mgr {64unsigned int num_cards;65struct snd_pcxhr *chip[PCXHR_MAX_CARDS];6667struct pci_dev *pci;6869int irq;7071int granularity;7273/* card access with 1 mem bar and 2 io bar's */74unsigned long port[3];7576/* share the name */77char shortname[32]; /* short name of this soundcard */78char longname[96]; /* name of this soundcard */7980/* message tasklet */81struct tasklet_struct msg_taskq;82struct pcxhr_rmh *prmh;83/* trigger tasklet */84struct tasklet_struct trigger_taskq;8586spinlock_t lock; /* interrupt spinlock */87spinlock_t msg_lock; /* message spinlock */8889struct mutex setup_mutex; /* mutex used in hw_params, open and close */90struct mutex mixer_mutex; /* mutex for mixer */9192/* hardware interface */93unsigned int dsp_loaded; /* bit flags of loaded dsp indices */94unsigned int dsp_version; /* read from embedded once firmware is loaded */95int playback_chips;96int capture_chips;97int fw_file_set;98int firmware_num;99unsigned int is_hr_stereo:1;100unsigned int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */101unsigned int board_has_analog:1; /* if 0 the board is digital only */102unsigned int board_has_mic:1; /* if 1 the board has microphone input */103unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */104unsigned int mono_capture:1; /* if 1 the board does mono capture */105106struct snd_dma_buffer hostport;107108enum pcxhr_clock_type use_clock_type; /* clock type selected by mixer */109enum pcxhr_clock_type cur_clock_type; /* current clock type synced */110int sample_rate;111int ref_count_rate;112int timer_toggle; /* timer interrupt toggles between the two values 0x200 and 0x300 */113int dsp_time_last; /* the last dsp time (read by interrupt) */114int dsp_time_err; /* dsp time errors */115unsigned int src_it_dsp; /* dsp interrupt source */116unsigned int io_num_reg_cont; /* backup of IO_NUM_REG_CONT */117unsigned int codec_speed; /* speed mode of the codecs */118unsigned int sample_rate_real; /* current real sample rate */119int last_reg_stat;120int async_err_stream_xrun;121int async_err_pipe_xrun;122int async_err_other_last;123124unsigned char xlx_cfg; /* copy of PCXHR_XLX_CFG register */125unsigned char xlx_selmic; /* copy of PCXHR_XLX_SELMIC register */126unsigned char dsp_reset; /* copy of PCXHR_DSP_RESET register */127};128129130enum pcxhr_stream_status {131PCXHR_STREAM_STATUS_FREE,132PCXHR_STREAM_STATUS_OPEN,133PCXHR_STREAM_STATUS_SCHEDULE_RUN,134PCXHR_STREAM_STATUS_STARTED,135PCXHR_STREAM_STATUS_RUNNING,136PCXHR_STREAM_STATUS_SCHEDULE_STOP,137PCXHR_STREAM_STATUS_STOPPED,138PCXHR_STREAM_STATUS_PAUSED139};140141struct pcxhr_stream {142struct snd_pcm_substream *substream;143snd_pcm_format_t format;144struct pcxhr_pipe *pipe;145146enum pcxhr_stream_status status; /* free, open, running, draining, pause */147148u_int64_t timer_abs_periods; /* timer: samples elapsed since TRIGGER_START (multiple of period_size) */149u_int32_t timer_period_frag; /* timer: samples elapsed since last call to snd_pcm_period_elapsed (0..period_size) */150u_int32_t timer_buf_periods; /* nb of periods in the buffer that have already elapsed */151int timer_is_synced; /* if(0) : timer needs to be resynced with real hardware pointer */152153int channels;154};155156157enum pcxhr_pipe_status {158PCXHR_PIPE_UNDEFINED,159PCXHR_PIPE_DEFINED160};161162struct pcxhr_pipe {163enum pcxhr_pipe_status status;164int is_capture; /* this is a capture pipe */165int first_audio; /* first audio num */166};167168169struct snd_pcxhr {170struct snd_card *card;171struct pcxhr_mgr *mgr;172int chip_idx; /* zero based */173174struct snd_pcm *pcm; /* PCM */175176struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */177struct pcxhr_pipe capture_pipe[2]; /* 1 stereo or 2 mono pipes */178179struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS];180struct pcxhr_stream capture_stream[2]; /* 1 stereo or 2 mono streams */181int nb_streams_play;182int nb_streams_capt;183184int analog_playback_active[2]; /* Mixer : Master Playback !mute */185int analog_playback_volume[2]; /* Mixer : Master Playback Volume */186int analog_capture_volume[2]; /* Mixer : Master Capture Volume */187int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2];188int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2];189int digital_capture_volume[2]; /* Mixer : Digital Capture Volume */190int monitoring_active[2]; /* Mixer : Monitoring Active */191int monitoring_volume[2]; /* Mixer : Monitoring Volume */192int audio_capture_source; /* Mixer : Audio Capture Source */193int mic_volume; /* used by cards with MIC only */194int mic_boost; /* used by cards with MIC only */195int mic_active; /* used by cards with MIC only */196int analog_capture_active; /* used by cards with MIC only */197int phantom_power; /* used by cards with MIC only */198199unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */200};201202struct pcxhr_hostport203{204char purgebuffer[6];205char reserved[2];206};207208/* exported */209int pcxhr_create_pcm(struct snd_pcxhr *chip);210int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate);211int pcxhr_get_external_clock(struct pcxhr_mgr *mgr,212enum pcxhr_clock_type clock_type,213int *sample_rate);214215#endif /* __SOUND_PCXHR_H */216217218