diff options
Diffstat (limited to 'sound/pci/pcxhr/pcxhr_hwdep.c')
-rw-r--r-- | sound/pci/pcxhr/pcxhr_hwdep.c | 158 |
1 files changed, 45 insertions, 113 deletions
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index 592743a298b0..96640d9c227d 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -31,7 +31,6 @@ #include "pcxhr_mixer.h" #include "pcxhr_hwdep.h" #include "pcxhr_core.h" -#include "pcxhr_mix22.h" #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) @@ -41,10 +40,10 @@ #endif -static int pcxhr_sub_init(struct pcxhr_mgr *mgr); /* * get basic information and init pcxhr card */ + static int pcxhr_init_board(struct pcxhr_mgr *mgr) { int err; @@ -69,7 +68,7 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) return -EINVAL; /* test 8 or 2 phys in */ - if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) < + if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) != mgr->capture_chips * 2) return -EINVAL; /* test max nb substream per board */ @@ -78,34 +77,20 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) /* test max nb substream per pipe */ if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS) return -EINVAL; - snd_printdd("supported formats : playback=%x capture=%x\n", - rmh.stat[2], rmh.stat[3]); 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) + mgr->granularity; + 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); + 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]; - if (mgr->is_hr_stereo) - err = hr222_sub_init(mgr); - else - err = pcxhr_sub_init(mgr); - return err; -} - -static int pcxhr_sub_init(struct pcxhr_mgr *mgr) -{ - int err; - struct pcxhr_rmh rmh; - /* get options */ pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); rmh.cmd[0] |= IO_NUM_REG_STATUS; @@ -115,22 +100,20 @@ static int pcxhr_sub_init(struct pcxhr_mgr *mgr) 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 found */ + 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 (a write to IO_NUM_REG_MUTE_OUT mutes!) */ - pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); + /* 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; - if (DSP_EXT_CMD_SET(mgr)) { - rmh.cmd[1] = 1; /* unmute digital plugs */ - rmh.cmd_len = 2; - } err = pcxhr_send_msg(mgr, &rmh); return err; } @@ -141,25 +124,19 @@ void pcxhr_reset_board(struct pcxhr_mgr *mgr) if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { /* mute outputs */ - if (!mgr->is_hr_stereo) { /* 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); - } - /* stereo cards mute with reset of dsp */ + 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)) + 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)) { + if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_XLX_COM_INDEX)) pcxhr_reset_xilinx_com(mgr); - mgr->dsp_loaded = 1; - } return; } @@ -167,9 +144,8 @@ void pcxhr_reset_board(struct pcxhr_mgr *mgr) /* * 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) +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; @@ -185,23 +161,15 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr, 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'); + 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); - rmh.cmd[1] |= 0x020000; /* add P_PCM_ONLY_MASK */ - if (DSP_EXT_CMD_SET(mgr)) { - /* add channel mask to command */ - rmh.cmd[rmh.cmd_len++] = (audio_count == 1) ? 0x01 : 0x03; - } + 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); + snd_printk(KERN_ERR "error pipe allocation (CMD_RES_PIPE) err=%x!\n", err ); return err; } pipe->status = PCXHR_PIPE_DEFINED; @@ -231,12 +199,10 @@ static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe) 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); + 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); + snd_printk(KERN_ERR "error pipe release (CMD_FREE_PIPE) err(%x)\n", err); pipe->status = PCXHR_PIPE_UNDEFINED; return err; } @@ -282,16 +248,15 @@ static int pcxhr_start_pipes(struct pcxhr_mgr *mgr) 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; + 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; + 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) +static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, const struct firmware *dsp) { int err, card_index; @@ -365,33 +330,22 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) { - static char *fw_files[][5] = { - [0] = { "xlxint.dat", "xlxc882hr.dat", - "dspe882.e56", "dspb882hr.b56", "dspd882.d56" }, - [1] = { "xlxint.dat", "xlxc882e.dat", - "dspe882.e56", "dspb882e.b56", "dspd882.d56" }, - [2] = { "xlxint.dat", "xlxc1222hr.dat", - "dspe882.e56", "dspb1222hr.b56", "dspd1222.d56" }, - [3] = { "xlxint.dat", "xlxc1222e.dat", - "dspe882.e56", "dspb1222e.b56", "dspd1222.d56" }, - [4] = { NULL, "xlxc222.dat", - "dspe924.e56", "dspb924.b56", "dspd222.d56" }, - [5] = { NULL, "xlxc924.dat", - "dspe924.e56", "dspb924.b56", "dspd222.d56" }, + 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; - int fw_set = mgr->fw_file_set; - for (i = 0; i < 5; i++) { - if (!fw_files[fw_set][i]) - continue; - sprintf(path, "pcxhr/%s", fw_files[fw_set][i]); + 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); + snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", path); return -ENOENT; } /* fake hwdep dsp record */ @@ -404,26 +358,11 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) return 0; } -MODULE_FIRMWARE("pcxhr/xlxint.dat"); -MODULE_FIRMWARE("pcxhr/xlxc882hr.dat"); -MODULE_FIRMWARE("pcxhr/xlxc882e.dat"); -MODULE_FIRMWARE("pcxhr/dspe882.e56"); -MODULE_FIRMWARE("pcxhr/dspb882hr.b56"); -MODULE_FIRMWARE("pcxhr/dspb882e.b56"); -MODULE_FIRMWARE("pcxhr/dspd882.d56"); - -MODULE_FIRMWARE("pcxhr/xlxc1222hr.dat"); -MODULE_FIRMWARE("pcxhr/xlxc1222e.dat"); -MODULE_FIRMWARE("pcxhr/dspb1222hr.b56"); -MODULE_FIRMWARE("pcxhr/dspb1222e.b56"); -MODULE_FIRMWARE("pcxhr/dspd1222.d56"); - -MODULE_FIRMWARE("pcxhr/xlxc222.dat"); -MODULE_FIRMWARE("pcxhr/xlxc924.dat"); -MODULE_FIRMWARE("pcxhr/dspe924.e56"); -MODULE_FIRMWARE("pcxhr/dspb924.b56"); -MODULE_FIRMWARE("pcxhr/dspd222.d56"); - +MODULE_FIRMWARE("pcxhr/xi_1_882.dat"); +MODULE_FIRMWARE("pcxhr/xc_1_882.dat"); +MODULE_FIRMWARE("pcxhr/e321_512.e56"); +MODULE_FIRMWARE("pcxhr/b321_512.b56"); +MODULE_FIRMWARE("pcxhr/d321_512.d56"); #else /* old style firmware loading */ @@ -434,8 +373,7 @@ MODULE_FIRMWARE("pcxhr/dspd222.d56"); static int pcxhr_hwdep_dsp_status(struct snd_hwdep *hw, struct snd_hwdep_dsp_status *info) { - struct pcxhr_mgr *mgr = hw->private_data; - sprintf(info->id, "pcxhr%d", mgr->fw_file_set); + strcpy(info->id, "pcxhr"); info->num_dsps = PCXHR_FIRMWARE_FILES_MAX_INDEX; if (hw->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) @@ -455,8 +393,8 @@ static int pcxhr_hwdep_dsp_load(struct snd_hwdep *hw, fw.size = dsp->length; fw.data = vmalloc(fw.size); if (! fw.data) { - snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image " - "(%lu bytes)\n", (unsigned long)fw.size); + snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image (%lu bytes)\n", + (unsigned long)fw.size); return -ENOMEM; } if (copy_from_user((void *)fw.data, dsp->image, dsp->length)) { @@ -486,11 +424,8 @@ 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) - */ - err = snd_hwdep_new(mgr->chip[0]->card, PCXHR_HWDEP_ID, 0, &hw); - if (err < 0) + /* 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; @@ -500,13 +435,10 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) hw->ops.dsp_status = pcxhr_hwdep_dsp_status; hw->ops.dsp_load = pcxhr_hwdep_dsp_load; hw->exclusive = 1; - /* stereo cards don't need fw_file_0 -> dsp_loaded = 1 */ - hw->dsp_loaded = mgr->is_hr_stereo ? 1 : 0; mgr->dsp_loaded = 0; sprintf(hw->name, PCXHR_HWDEP_ID); - err = snd_card_register(mgr->chip[0]->card); - if (err < 0) + if ((err = snd_card_register(mgr->chip[0]->card)) < 0) return err; return 0; } |