[ALSA] Add PCXHR driver

Modules: Documentation,PCI drivers,Digigram PCXHR driver

Add Digigram PCXHR driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Markus Bollinger 2005-12-06 13:55:26 +01:00 committed by Jaroslav Kysela
parent 46a1736d7c
commit e12229b4d2
12 changed files with 4517 additions and 0 deletions

View File

@ -1103,6 +1103,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
This module supports only one card, autoprobe and PnP.
Module snd-pcxhr
----------------
Module for Digigram PCXHR boards
This module supports multiple cards.
Module snd-powermac (on ppc only)
---------------------------------

View File

@ -455,6 +455,17 @@ config SND_NM256
To compile this driver as a module, choose M here: the module
will be called snd-nm256.
config SND_PCXHR
tristate "Digigram PCXHR"
depends on SND
select SND_PCM
select SND_HWDEP
help
Say Y here to include support for Digigram PCXHR boards.
To compile this driver as a module, choose M here: the module
will be called snd-pcxhr.
config SND_RME32
tristate "RME Digi32, 32/8, 32 PRO"
depends on SND

View File

@ -61,6 +61,7 @@ obj-$(CONFIG_SND) += \
korg1212/ \
mixart/ \
nm256/ \
pcxhr/ \
rme9652/ \
trident/ \
ymfpci/ \

2
sound/pci/pcxhr/Makefile Normal file
View File

@ -0,0 +1,2 @@
snd-pcxhr-objs := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o
obj-$(CONFIG_SND_PCXHR) += snd-pcxhr.o

1367
sound/pci/pcxhr/pcxhr.c Normal file

File diff suppressed because it is too large Load Diff

188
sound/pci/pcxhr/pcxhr.h Normal file
View File

@ -0,0 +1,188 @@
/*
* Driver for Digigram pcxhr soundcards
*
* main header file
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_H
#define __SOUND_PCXHR_H
#include <linux/interrupt.h>
#include <sound/pcm.h>
#define PCXHR_DRIVER_VERSION 0x000804 /* 0.8.4 */
#define PCXHR_DRIVER_VERSION_STRING "0.8.4" /* 0.8.4 */
#define PCXHR_MAX_CARDS 6
#define PCXHR_PLAYBACK_STREAMS 4
#define PCXHR_GRANULARITY 96 /* transfer granularity (should be min 96 and multiple of 48) */
#define PCXHR_GRANULARITY_MIN 96 /* transfer granularity of pipes and the dsp time (MBOX4) */
struct snd_pcxhr;
struct pcxhr_mgr;
struct pcxhr_stream;
struct pcxhr_pipe;
enum pcxhr_clock_type {
PCXHR_CLOCK_TYPE_INTERNAL = 0,
PCXHR_CLOCK_TYPE_WORD_CLOCK,
PCXHR_CLOCK_TYPE_AES_SYNC,
PCXHR_CLOCK_TYPE_AES_1,
PCXHR_CLOCK_TYPE_AES_2,
PCXHR_CLOCK_TYPE_AES_3,
PCXHR_CLOCK_TYPE_AES_4,
};
struct pcxhr_mgr {
unsigned int num_cards;
struct snd_pcxhr *chip[PCXHR_MAX_CARDS];
struct pci_dev *pci;
int irq;
/* card access with 1 mem bar and 2 io bar's */
unsigned long port[3];
/* share the name */
char shortname[32]; /* short name of this soundcard */
char longname[96]; /* name of this soundcard */
/* message tasklet */
struct tasklet_struct msg_taskq;
struct pcxhr_rmh *prmh;
/* trigger tasklet */
struct tasklet_struct trigger_taskq;
spinlock_t lock; /* interrupt spinlock */
spinlock_t msg_lock; /* message spinlock */
struct semaphore setup_mutex; /* mutex used in hw_params, open and close */
struct semaphore mixer_mutex; /* mutex for mixer */
/* hardware interface */
unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
unsigned int dsp_version; /* read from embedded once firmware is loaded */
int board_has_analog; /* if 0 the board is digital only */
int mono_capture; /* if 1 the board does mono capture */
int playback_chips; /* 4 or 6 */
int capture_chips; /* 4 or 1 */
int firmware_num; /* 41 or 42 */
struct snd_dma_buffer hostport;
enum pcxhr_clock_type use_clock_type; /* clock type selected by mixer */
enum pcxhr_clock_type cur_clock_type; /* current clock type synced */
int sample_rate;
int ref_count_rate;
int timer_toggle; /* timer interrupt toggles between the two values 0x200 and 0x300 */
int dsp_time_last; /* the last dsp time (read by interrupt) */
int dsp_time_err; /* dsp time errors */
unsigned int src_it_dsp; /* dsp interrupt source */
unsigned int io_num_reg_cont; /* backup of IO_NUM_REG_CONT */
unsigned int codec_speed; /* speed mode of the codecs */
unsigned int sample_rate_real; /* current real sample rate */
int last_reg_stat;
int async_err_stream_xrun;
int async_err_pipe_xrun;
int async_err_other_last;
};
enum pcxhr_stream_status {
PCXHR_STREAM_STATUS_FREE,
PCXHR_STREAM_STATUS_OPEN,
PCXHR_STREAM_STATUS_SCHEDULE_RUN,
PCXHR_STREAM_STATUS_STARTED,
PCXHR_STREAM_STATUS_RUNNING,
PCXHR_STREAM_STATUS_SCHEDULE_STOP,
PCXHR_STREAM_STATUS_STOPPED,
PCXHR_STREAM_STATUS_PAUSED
};
struct pcxhr_stream {
struct snd_pcm_substream *substream;
snd_pcm_format_t format;
struct pcxhr_pipe *pipe;
enum pcxhr_stream_status status; /* free, open, running, draining, pause */
u_int64_t timer_abs_periods; /* timer: samples elapsed since TRIGGER_START (multiple of period_size) */
u_int32_t timer_period_frag; /* timer: samples elapsed since last call to snd_pcm_period_elapsed (0..period_size) */
u_int32_t timer_buf_periods; /* nb of periods in the buffer that have already elapsed */
int timer_is_synced; /* if(0) : timer needs to be resynced with real hardware pointer */
int channels;
};
enum pcxhr_pipe_status {
PCXHR_PIPE_UNDEFINED,
PCXHR_PIPE_DEFINED
};
struct pcxhr_pipe {
enum pcxhr_pipe_status status;
int is_capture; /* this is a capture pipe */
int first_audio; /* first audio num */
};
struct snd_pcxhr {
struct snd_card *card;
struct pcxhr_mgr *mgr;
int chip_idx; /* zero based */
struct snd_pcm *pcm; /* PCM */
struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */
struct pcxhr_pipe capture_pipe[2]; /* 1 stereo pipe or 2 mono pipes */
struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS];
struct pcxhr_stream capture_stream[2]; /* 1 stereo stream or 2 mono streams */
int nb_streams_play;
int nb_streams_capt;
int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */
int analog_playback_volume[2]; /* Mixer : Master Playback Volume */
int analog_capture_volume[2]; /* Mixer : Master Capture Volume */
int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [streams][stereo]*/
int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [streams][stereo]*/
int digital_capture_volume[2]; /* Mixer : Digital Capture Volume [stereo] */
int monitoring_active[2]; /* Mixer : Monitoring Active */
int monitoring_volume[2]; /* Mixer : Monitoring Volume */
int audio_capture_source; /* Mixer : Audio Capture Source */
unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */
};
struct pcxhr_hostport
{
char purgebuffer[6];
char reserved[2];
};
/* exported */
int pcxhr_create_pcm(struct snd_pcxhr *chip);
int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate);
int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, int *sample_rate);
#endif /* __SOUND_PCXHR_H */

1214
sound/pci/pcxhr/pcxhr_core.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
/*
* Driver for Digigram pcxhr compatible soundcards
*
* low level interface with interrupt ans message handling
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_CORE_H
#define __SOUND_PCXHR_CORE_H
struct firmware;
struct pcxhr_mgr;
/* init and firmware download commands */
void pcxhr_reset_xilinx_com(struct pcxhr_mgr *mgr);
void pcxhr_reset_dsp(struct pcxhr_mgr *mgr);
void pcxhr_enable_dsp(struct pcxhr_mgr *mgr);
int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilinx, int second);
int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, const struct firmware *eeprom);
int pcxhr_load_boot_binary(struct pcxhr_mgr *mgr, const struct firmware *boot);
int pcxhr_load_dsp_binary(struct pcxhr_mgr *mgr, const struct firmware *dsp);
/* DSP time available on MailBox4 register : 24 bit time samples() */
#define PCXHR_DSP_TIME_MASK 0x00ffffff
#define PCXHR_DSP_TIME_INVALID 0x10000000
#define PCXHR_SIZE_MAX_CMD 8
#define PCXHR_SIZE_MAX_STATUS 16
#define PCXHR_SIZE_MAX_LONG_STATUS 256
struct pcxhr_rmh {
u16 cmd_len; /* length of the command to send (WORDs) */
u16 stat_len; /* length of the status received (WORDs) */
u16 dsp_stat; /* status type, RMP_SSIZE_XXX */
u16 cmd_idx; /* index of the command */
u32 cmd[PCXHR_SIZE_MAX_CMD];
u32 stat[PCXHR_SIZE_MAX_STATUS];
};
enum {
CMD_VERSION, /* cmd_len = 2 stat_len = 1 */
CMD_SUPPORTED, /* cmd_len = 1 stat_len = 4 */
CMD_TEST_IT, /* cmd_len = 1 stat_len = 1 */
CMD_SEND_IRQA, /* cmd_len = 1 stat_len = 0 */
CMD_ACCESS_IO_WRITE, /* cmd_len >= 1 stat_len >= 1 */
CMD_ACCESS_IO_READ, /* cmd_len >= 1 stat_len >= 1 */
CMD_ASYNC, /* cmd_len = 1 stat_len = 1 */
CMD_MODIFY_CLOCK, /* cmd_len = 3 stat_len = 0 */
CMD_RESYNC_AUDIO_INPUTS, /* cmd_len = 1 stat_len = 0 */
CMD_GET_DSP_RESOURCES, /* cmd_len = 1 stat_len = 4 */
CMD_SET_TIMER_INTERRUPT, /* cmd_len = 1 stat_len = 0 */
CMD_RES_PIPE, /* cmd_len = 2 stat_len = 0 */
CMD_FREE_PIPE, /* cmd_len = 1 stat_len = 0 */
CMD_CONF_PIPE, /* cmd_len = 2 stat_len = 0 */
CMD_STOP_PIPE, /* cmd_len = 1 stat_len = 0 */
CMD_PIPE_SAMPLE_COUNT, /* cmd_len = 2 stat_len = 2 */
CMD_CAN_START_PIPE, /* cmd_len >= 1 stat_len = 1 */
CMD_START_STREAM, /* cmd_len = 2 stat_len = 0 */
CMD_STREAM_OUT_LEVEL_ADJUST, /* cmd_len >= 1 stat_len = 0 */
CMD_STOP_STREAM, /* cmd_len = 2 stat_len = 0 */
CMD_UPDATE_R_BUFFERS, /* cmd_len = 4 stat_len = 0 */
CMD_FORMAT_STREAM_OUT, /* cmd_len >= 2 stat_len = 0 */
CMD_FORMAT_STREAM_IN, /* cmd_len >= 4 stat_len = 0 */
CMD_STREAM_SAMPLE_COUNT, /* cmd_len = 2 stat_len = (2 * nb_stream) */
CMD_AUDIO_LEVEL_ADJUST, /* cmd_len = 3 stat_len = 0 */
CMD_LAST_INDEX
};
#define MASK_DSP_WORD 0x00ffffff
#define MASK_ALL_STREAM 0x00ffffff
#define MASK_DSP_WORD_LEVEL 0x000001ff
#define MASK_FIRST_FIELD 0x0000001f
#define FIELD_SIZE 5
/*
init the rmh struct; by default cmd_len is set to 1
*/
void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd);
void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh* rmh, int capture, unsigned int param1,
unsigned int param2, unsigned int param3);
/*
send the rmh
*/
int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh);
/* values used for CMD_ACCESS_IO_WRITE and CMD_ACCESS_IO_READ */
#define IO_NUM_REG_CONT 0
#define IO_NUM_REG_GENCLK 1
#define IO_NUM_REG_MUTE_OUT 2
#define IO_NUM_SPEED_RATIO 4
#define IO_NUM_REG_STATUS 5
#define IO_NUM_REG_CUER 10
#define IO_NUM_UER_CHIP_REG 11
#define IO_NUM_REG_OUT_ANA_LEVEL 20
#define IO_NUM_REG_IN_ANA_LEVEL 21
#define REG_CONT_UNMUTE_INPUTS 0x020000
/* parameters used with register IO_NUM_REG_STATUS */
#define REG_STATUS_OPTIONS 0
#define REG_STATUS_AES_SYNC 8
#define REG_STATUS_AES_1 9
#define REG_STATUS_AES_2 10
#define REG_STATUS_AES_3 11
#define REG_STATUS_AES_4 12
#define REG_STATUS_WORD_CLOCK 13
#define REG_STATUS_INTER_SYNC 14
#define REG_STATUS_CURRENT 0x80
/* results */
#define REG_STATUS_OPT_NO_VIDEO_SIGNAL 0x01
#define REG_STATUS_OPT_DAUGHTER_MASK 0x1c
#define REG_STATUS_OPT_ANALOG_BOARD 0x00
#define REG_STATUS_OPT_NO_DAUGHTER 0x1c
#define REG_STATUS_OPT_COMPANION_MASK 0xe0
#define REG_STATUS_OPT_NO_COMPANION 0xe0
#define REG_STATUS_SYNC_32000 0x00
#define REG_STATUS_SYNC_44100 0x01
#define REG_STATUS_SYNC_48000 0x02
#define REG_STATUS_SYNC_64000 0x03
#define REG_STATUS_SYNC_88200 0x04
#define REG_STATUS_SYNC_96000 0x05
#define REG_STATUS_SYNC_128000 0x06
#define REG_STATUS_SYNC_176400 0x07
#define REG_STATUS_SYNC_192000 0x08
int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_mask, int start);
int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
unsigned int value, int *changed);
/* codec parameters */
#define CS8416_RUN 0x200401
#define CS8416_FORMAT_DETECT 0x200b00
#define CS8416_CSB0 0x201900
#define CS8416_CSB1 0x201a00
#define CS8416_CSB2 0x201b00
#define CS8416_CSB3 0x201c00
#define CS8416_CSB4 0x201d00
#define CS8416_VERSION 0x207f00
#define CS8420_DATA_FLOW_CTL 0x200301
#define CS8420_CLOCK_SRC_CTL 0x200401
#define CS8420_RECEIVER_ERRORS 0x201000
#define CS8420_SRC_RATIO 0x201e00
#define CS8420_CSB0 0x202000
#define CS8420_CSB1 0x202100
#define CS8420_CSB2 0x202200
#define CS8420_CSB3 0x202300
#define CS8420_CSB4 0x202400
#define CS8420_VERSION 0x207f00
#define CS4271_MODE_CTL_1 0x200101
#define CS4271_DAC_CTL 0x200201
#define CS4271_VOLMIX 0x200301
#define CS4271_VOLMUTE_LEFT 0x200401
#define CS4271_VOLMUTE_RIGHT 0x200501
#define CS4271_ADC_CTL 0x200601
#define CS4271_MODE_CTL_2 0x200701
#define CHIP_SIG_AND_MAP_SPI 0xff7f00
/* codec selection */
#define CS4271_01_CS 0x160018
#define CS4271_23_CS 0x160019
#define CS4271_45_CS 0x16001a
#define CS4271_67_CS 0x16001b
#define CS4271_89_CS 0x16001c
#define CS4271_AB_CS 0x16001d
#define CS8420_01_CS 0x080090
#define CS8420_23_CS 0x080092
#define CS8420_45_CS 0x080094
#define CS8420_67_CS 0x080096
#define CS8416_01_CS 0x080098
/* interrupt handling */
irqreturn_t pcxhr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
void pcxhr_msg_tasklet(unsigned long arg);
#endif /* __SOUND_PCXHR_CORE_H */

View File

@ -0,0 +1,438 @@
/*
* Driver for Digigram pcxhr compatible soundcards
*
* hwdep device manager
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sound/driver.h>
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
#include <linux/firmware.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <sound/core.h>
#include <sound/hwdep.h>
#include "pcxhr.h"
#include "pcxhr_mixer.h"
#include "pcxhr_hwdep.h"
#include "pcxhr_core.h"
#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
#if !defined(CONFIG_USE_PCXHRLOADER) && !defined(CONFIG_SND_PCXHR) /* built-in kernel */
#define SND_PCXHR_FW_LOADER /* use the standard firmware loader */
#endif
#endif
/*
* get basic information and init pcxhr card
*/
static int pcxhr_init_board(struct pcxhr_mgr *mgr)
{
int err;
struct pcxhr_rmh rmh;
int card_streams;
/* calc the number of all streams used */
if (mgr->mono_capture)
card_streams = mgr->capture_chips * 2;
else
card_streams = mgr->capture_chips;
card_streams += mgr->playback_chips * PCXHR_PLAYBACK_STREAMS;
/* enable interrupts */
pcxhr_enable_dsp(mgr);
pcxhr_init_rmh(&rmh, CMD_SUPPORTED);
err = pcxhr_send_msg(mgr, &rmh);
if (err)
return err;
/* test 8 or 12 phys out */
snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2,
return -EINVAL);
/* test 8 or 2 phys in */
snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) ==
mgr->capture_chips * 2, return -EINVAL);
/* test max nb substream per board */
snd_assert((rmh.stat[1] & 0x5F) >= card_streams, return -EINVAL);
/* test max nb substream per pipe */
snd_assert(((rmh.stat[1]>>7)&0x5F) >= PCXHR_PLAYBACK_STREAMS, return -EINVAL);
pcxhr_init_rmh(&rmh, CMD_VERSION);
/* firmware num for DSP */
rmh.cmd[0] |= mgr->firmware_num;
/* transfer granularity in samples (should be multiple of 48) */
rmh.cmd[1] = (1<<23) + PCXHR_GRANULARITY;
rmh.cmd_len = 2;
err = pcxhr_send_msg(mgr, &rmh);
if (err)
return err;
snd_printdd("PCXHR DSP version is %d.%d.%d\n",
(rmh.stat[0]>>16)&0xff, (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff);
mgr->dsp_version = rmh.stat[0];
/* get options */
pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ);
rmh.cmd[0] |= IO_NUM_REG_STATUS;
rmh.cmd[1] = REG_STATUS_OPTIONS;
rmh.cmd_len = 2;
err = pcxhr_send_msg(mgr, &rmh);
if (err)
return err;
if ((rmh.stat[1] & REG_STATUS_OPT_DAUGHTER_MASK) == REG_STATUS_OPT_ANALOG_BOARD)
mgr->board_has_analog = 1; /* analog addon board available */
else
/* analog addon board not available -> no support for instance */
return -EINVAL;
/* unmute inputs */
err = pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS,
REG_CONT_UNMUTE_INPUTS, NULL);
if (err)
return err;
/* unmute outputs */
pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* a write to IO_NUM_REG_MUTE_OUT mutes! */
rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT;
err = pcxhr_send_msg(mgr, &rmh);
return err;
}
void pcxhr_reset_board(struct pcxhr_mgr *mgr)
{
struct pcxhr_rmh rmh;
if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) {
/* mute outputs */
/* a read to IO_NUM_REG_MUTE_OUT register unmutes! */
pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE);
rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT;
pcxhr_send_msg(mgr, &rmh);
/* mute inputs */
pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, 0, NULL);
}
/* reset pcxhr dsp */
if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_DSP_EPRM_INDEX))
pcxhr_reset_dsp(mgr);
/* reset second xilinx */
if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_XLX_COM_INDEX))
pcxhr_reset_xilinx_com(mgr);
return;
}
/*
* allocate a playback/capture pipe (pcmp0/pcmc0)
*/
static int pcxhr_dsp_allocate_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe,
int is_capture, int pin)
{
int stream_count, audio_count;
int err;
struct pcxhr_rmh rmh;
if (is_capture) {
stream_count = 1;
if (mgr->mono_capture)
audio_count = 1;
else
audio_count = 2;
} else {
stream_count = PCXHR_PLAYBACK_STREAMS;
audio_count = 2; /* always stereo */
}
snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n", pin, is_capture ? 'c' : 'p');
pipe->is_capture = is_capture;
pipe->first_audio = pin;
/* define pipe (P_PCM_ONLY_MASK (0x020000) is not necessary) */
pcxhr_init_rmh(&rmh, CMD_RES_PIPE);
pcxhr_set_pipe_cmd_params(&rmh, is_capture, pin, audio_count, stream_count);
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0) {
snd_printk(KERN_ERR "error pipe allocation (CMD_RES_PIPE) err=%x!\n", err );
return err;
}
pipe->status = PCXHR_PIPE_DEFINED;
return 0;
}
/*
* free playback/capture pipe (pcmp0/pcmc0)
*/
#if 0
static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe)
{
struct pcxhr_rmh rmh;
int capture_mask = 0;
int playback_mask = 0;
int err = 0;
if (pipe->is_capture)
capture_mask = (1 << pipe->first_audio);
else
playback_mask = (1 << pipe->first_audio);
/* stop one pipe */
err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
if (err < 0)
snd_printk(KERN_ERR "error stopping pipe!\n");
/* release the pipe */
pcxhr_init_rmh(&rmh, CMD_FREE_PIPE);
pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio, 0, 0);
err = pcxhr_send_msg(mgr, &rmh);
if (err < 0)
snd_printk(KERN_ERR "error pipe release (CMD_FREE_PIPE) err(%x)\n", err);
pipe->status = PCXHR_PIPE_UNDEFINED;
return err;
}
#endif
static int pcxhr_config_pipes(struct pcxhr_mgr *mgr)
{
int err, i, j;
struct snd_pcxhr *chip;
struct pcxhr_pipe *pipe;
/* allocate the pipes on the dsp */
for (i = 0; i < mgr->num_cards; i++) {
chip = mgr->chip[i];
if (chip->nb_streams_play) {
pipe = &chip->playback_pipe;
err = pcxhr_dsp_allocate_pipe( mgr, pipe, 0, i*2);
if (err)
return err;
for(j = 0; j < chip->nb_streams_play; j++)
chip->playback_stream[j].pipe = pipe;
}
for (j = 0; j < chip->nb_streams_capt; j++) {
pipe = &chip->capture_pipe[j];
err = pcxhr_dsp_allocate_pipe(mgr, pipe, 1, i*2 + j);
if (err)
return err;
chip->capture_stream[j].pipe = pipe;
}
}
return 0;
}
static int pcxhr_start_pipes(struct pcxhr_mgr *mgr)
{
int i, j;
struct snd_pcxhr *chip;
int playback_mask = 0;
int capture_mask = 0;
/* start all the pipes on the dsp */
for (i = 0; i < mgr->num_cards; i++) {
chip = mgr->chip[i];
if (chip->nb_streams_play)
playback_mask |= (1 << chip->playback_pipe.first_audio);
for (j = 0; j < chip->nb_streams_capt; j++)
capture_mask |= (1 << chip->capture_pipe[j].first_audio);
}
return pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
}
static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, const struct firmware *dsp)
{
int err, card_index;
snd_printdd("loading dsp [%d] size = %Zd\n", index, dsp->size);
switch (index) {
case PCXHR_FIRMWARE_XLX_INT_INDEX:
pcxhr_reset_xilinx_com(mgr);
return pcxhr_load_xilinx_binary(mgr, dsp, 0);
case PCXHR_FIRMWARE_XLX_COM_INDEX:
pcxhr_reset_xilinx_com(mgr);
return pcxhr_load_xilinx_binary(mgr, dsp, 1);
case PCXHR_FIRMWARE_DSP_EPRM_INDEX:
pcxhr_reset_dsp(mgr);
return pcxhr_load_eeprom_binary(mgr, dsp);
case PCXHR_FIRMWARE_DSP_BOOT_INDEX:
return pcxhr_load_boot_binary(mgr, dsp);
case PCXHR_FIRMWARE_DSP_MAIN_INDEX:
err = pcxhr_load_dsp_binary(mgr, dsp);
if (err)
return err;
break; /* continue with first init */
default:
snd_printk(KERN_ERR "wrong file index\n");
return -EFAULT;
} /* end of switch file index*/
/* first communication with embedded */
err = pcxhr_init_board(mgr);
if (err < 0) {
snd_printk(KERN_ERR "pcxhr could not be set up\n");
return err;
}
err = pcxhr_config_pipes(mgr);
if (err < 0) {
snd_printk(KERN_ERR "pcxhr pipes could not be set up\n");
return err;
}
/* create devices and mixer in accordance with HW options*/
for (card_index = 0; card_index < mgr->num_cards; card_index++) {
struct snd_pcxhr *chip = mgr->chip[card_index];
if ((err = pcxhr_create_pcm(chip)) < 0)
return err;
if (card_index == 0) {
if ((err = pcxhr_create_mixer(chip->mgr)) < 0)
return err;
}
if ((err = snd_card_register(chip->card)) < 0)
return err;
}
err = pcxhr_start_pipes(mgr);
if (err < 0) {
snd_printk(KERN_ERR "pcxhr pipes could not be started\n");
return err;
}
snd_printdd("pcxhr firmware downloaded and successfully set up\n");
return 0;
}
/*
* fw loader entry
*/
#ifdef SND_PCXHR_FW_LOADER
int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
{
static char *fw_files[5] = {
"xi_1_882.dat",
"xc_1_882.dat",
"e321_512.e56",
"b321_512.b56",
"d321_512.d56"
};
char path[32];
const struct firmware *fw_entry;
int i, err;
for (i = 0; i < ARRAY_SIZE(fw_files); i++) {
sprintf(path, "pcxhr/%s", fw_files[i]);
if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", path);
return -ENOENT;
}
/* fake hwdep dsp record */
err = pcxhr_dsp_load(mgr, i, fw_entry);
release_firmware(fw_entry);
if (err < 0)
return err;
mgr->dsp_loaded |= 1 << i;
}
return 0;
}
#else /* old style firmware loading */
/* pcxhr hwdep interface id string */
#define PCXHR_HWDEP_ID "pcxhr loader"
static int pcxhr_hwdep_dsp_status(struct snd_hwdep *hw,
struct snd_hwdep_dsp_status *info)
{
strcpy(info->id, "pcxhr");
info->num_dsps = PCXHR_FIRMWARE_FILES_MAX_INDEX;
if (hw->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))
info->chip_ready = 1;
info->version = PCXHR_DRIVER_VERSION;
return 0;
}
static int pcxhr_hwdep_dsp_load(struct snd_hwdep *hw,
struct snd_hwdep_dsp_image *dsp)
{
struct pcxhr_mgr *mgr = hw->private_data;
int err;
struct firmware fw;
fw.size = dsp->length;
fw.data = vmalloc(fw.size);
if (! fw.data) {
snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image (%d bytes)\n",
fw.size);
return -ENOMEM;
}
if (copy_from_user(fw.data, dsp->image, dsp->length)) {
vfree(fw.data);
return -EFAULT;
}
err = pcxhr_dsp_load(mgr, dsp->index, &fw);
vfree(fw.data);
if (err < 0)
return err;
mgr->dsp_loaded |= 1 << dsp->index;
return 0;
}
static int pcxhr_hwdep_open(struct snd_hwdep *hw, struct file *file)
{
return 0;
}
static int pcxhr_hwdep_release(struct snd_hwdep *hw, struct file *file)
{
return 0;
}
int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
{
int err;
struct snd_hwdep *hw;
/* only create hwdep interface for first cardX (see "index" module parameter)*/
if ((err = snd_hwdep_new(mgr->chip[0]->card, PCXHR_HWDEP_ID, 0, &hw)) < 0)
return err;
hw->iface = SNDRV_HWDEP_IFACE_PCXHR;
hw->private_data = mgr;
hw->ops.open = pcxhr_hwdep_open;
hw->ops.release = pcxhr_hwdep_release;
hw->ops.dsp_status = pcxhr_hwdep_dsp_status;
hw->ops.dsp_load = pcxhr_hwdep_dsp_load;
hw->exclusive = 1;
mgr->dsp_loaded = 0;
sprintf(hw->name, PCXHR_HWDEP_ID);
if ((err = snd_card_register(mgr->chip[0]->card)) < 0)
return err;
return 0;
}
#endif /* SND_PCXHR_FW_LOADER */

View File

@ -0,0 +1,40 @@
/*
* Driver for Digigram pcxhr compatible soundcards
*
* definitions and makros for basic card access
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_HWDEP_H
#define __SOUND_PCXHR_HWDEP_H
/* firmware status codes */
#define PCXHR_FIRMWARE_XLX_INT_INDEX 0
#define PCXHR_FIRMWARE_XLX_COM_INDEX 1
#define PCXHR_FIRMWARE_DSP_EPRM_INDEX 2
#define PCXHR_FIRMWARE_DSP_BOOT_INDEX 3
#define PCXHR_FIRMWARE_DSP_MAIN_INDEX 4
#define PCXHR_FIRMWARE_FILES_MAX_INDEX 5
/* exported */
int pcxhr_setup_firmware(struct pcxhr_mgr *mgr);
void pcxhr_reset_board(struct pcxhr_mgr *mgr);
#endif /* __SOUND_PCXHR_HWDEP_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
/*
* Driver for Digigram pcxhr compatible soundcards
*
* include file for mixer
*
* Copyright (c) 2004 by Digigram <alsa@digigram.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SOUND_PCXHR_MIXER_H
#define __SOUND_PCXHR_MIXER_H
/* exported */
int pcxhr_create_mixer(struct pcxhr_mgr *mgr);
#endif /* __SOUND_PCXHR_MIXER_H */