2019-05-27 06:55:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Driver for Digigram VX soundcards
|
|
|
|
*
|
|
|
|
* Hardware core part
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/firmware.h>
|
2011-07-15 16:38:28 +00:00
|
|
|
#include <linux/module.h>
|
2015-01-28 15:49:33 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/asoundef.h>
|
|
|
|
#include <sound/info.h>
|
|
|
|
#include <sound/vx_core.h>
|
|
|
|
#include "vx_cmd.h"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
|
|
|
|
MODULE_DESCRIPTION("Common routines for Digigram VX drivers");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_check_reg_bit - wait for the specified bit is set/reset on a register
|
|
|
|
* @reg: register to check
|
|
|
|
* @mask: bit mask
|
|
|
|
* @bit: resultant bit to be checked
|
|
|
|
* @time: time-out of loop in msec
|
|
|
|
*
|
|
|
|
* returns zero if a bit matches, or a negative error code.
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned long end_time = jiffies + (time * HZ + 999) / 1000;
|
2020-01-05 14:47:22 +00:00
|
|
|
static const char * const reg_names[VX_REG_MAX] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
"ICR", "CVR", "ISR", "IVR", "RXH", "RXM", "RXL",
|
|
|
|
"DMA", "CDSP", "RFREQ", "RUER/V2", "DATA", "MEMIRQ",
|
|
|
|
"ACQ", "BIT0", "BIT1", "MIC0", "MIC1", "MIC2",
|
|
|
|
"MIC3", "INTCSR", "CNTRL", "GPIOC",
|
|
|
|
"LOFREQ", "HIFREQ", "CSUER", "RUER"
|
|
|
|
};
|
2013-01-25 09:54:07 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
do {
|
|
|
|
if ((snd_vx_inb(chip, reg) & mask) == bit)
|
|
|
|
return 0;
|
2005-11-17 09:21:19 +00:00
|
|
|
//msleep(10);
|
2005-04-16 22:20:36 +00:00
|
|
|
} while (time_after_eq(end_time, jiffies));
|
|
|
|
snd_printd(KERN_DEBUG "vx_check_reg_bit: timeout, reg=%s, mask=0x%x, val=0x%x\n", reg_names[reg], mask, snd_vx_inb(chip, reg));
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_check_reg_bit);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* vx_send_irq_dsp - set command irq bit
|
|
|
|
* @num: the requested IRQ type, IRQ_XXX
|
|
|
|
*
|
|
|
|
* this triggers the specified IRQ request
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
*
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static int vx_send_irq_dsp(struct vx_core *chip, int num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int nirq;
|
|
|
|
|
|
|
|
/* wait for Hc = 0 */
|
|
|
|
if (snd_vx_check_reg_bit(chip, VX_CVR, CVR_HC, 0, 200) < 0)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
nirq = num;
|
|
|
|
if (vx_has_new_dsp(chip))
|
|
|
|
nirq += VXP_IRQ_OFFSET;
|
|
|
|
vx_outb(chip, CVR, (nirq >> 1) | CVR_HC);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_reset_chk - reset CHK bit on ISR
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static int vx_reset_chk(struct vx_core *chip)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
/* Reset irq CHK */
|
|
|
|
if (vx_send_irq_dsp(chip, IRQ_RESET_CHK) < 0)
|
|
|
|
return -EIO;
|
|
|
|
/* Wait until CHK = 0 */
|
|
|
|
if (vx_check_isr(chip, ISR_CHK, 0, 200) < 0)
|
|
|
|
return -EIO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_transfer_end - terminate message transfer
|
|
|
|
* @cmd: IRQ message to send (IRQ_MESS_XXX_END)
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
* the error code can be VX-specific, retrieved via vx_get_error().
|
2014-09-09 15:17:20 +00:00
|
|
|
* NB: call with mutex held!
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static int vx_transfer_end(struct vx_core *chip, int cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_reset_chk(chip);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* irq MESS_READ/WRITE_END */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_send_irq_dsp(chip, cmd);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Wait CHK = 1 */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_CHK);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* If error, Read RX */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_inb(chip, ISR);
|
|
|
|
if (err & ISR_ERR) {
|
|
|
|
err = vx_wait_for_rx_full(chip);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "transfer_end: error in rx_full\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
err = vx_inb(chip, RXH) << 16;
|
|
|
|
err |= vx_inb(chip, RXM) << 8;
|
|
|
|
err |= vx_inb(chip, RXL);
|
|
|
|
snd_printd(KERN_DEBUG "transfer_end: error = 0x%x\n", err);
|
|
|
|
return -(VX_ERR_MASK | err);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_read_status - return the status rmh
|
|
|
|
* @rmh: rmh record to store the status
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
* the error code can be VX-specific, retrieved via vx_get_error().
|
2014-09-09 15:17:20 +00:00
|
|
|
* NB: call with mutex held!
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i, err, val, size;
|
|
|
|
|
|
|
|
/* no read necessary? */
|
|
|
|
if (rmh->DspStat == RMH_SSIZE_FIXED && rmh->LgStat == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Wait for RX full (with timeout protection)
|
|
|
|
* The first word of status is in RX
|
|
|
|
*/
|
|
|
|
err = vx_wait_for_rx_full(chip);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Read RX */
|
|
|
|
val = vx_inb(chip, RXH) << 16;
|
|
|
|
val |= vx_inb(chip, RXM) << 8;
|
|
|
|
val |= vx_inb(chip, RXL);
|
|
|
|
|
|
|
|
/* If status given by DSP, let's decode its size */
|
|
|
|
switch (rmh->DspStat) {
|
|
|
|
case RMH_SSIZE_ARG:
|
|
|
|
size = val & 0xff;
|
|
|
|
rmh->Stat[0] = val & 0xffff00;
|
|
|
|
rmh->LgStat = size + 1;
|
|
|
|
break;
|
|
|
|
case RMH_SSIZE_MASK:
|
|
|
|
/* Let's count the arg numbers from a mask */
|
|
|
|
rmh->Stat[0] = val;
|
|
|
|
size = 0;
|
|
|
|
while (val) {
|
|
|
|
if (val & 0x01)
|
|
|
|
size++;
|
|
|
|
val >>= 1;
|
|
|
|
}
|
|
|
|
rmh->LgStat = size + 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* else retrieve the status length given by the driver */
|
|
|
|
size = rmh->LgStat;
|
|
|
|
rmh->Stat[0] = val; /* Val is the status 1st word */
|
|
|
|
size--; /* hence adjust remaining length */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < 1)
|
|
|
|
return 0;
|
2013-06-21 12:25:33 +00:00
|
|
|
if (snd_BUG_ON(size >= SIZE_MAX_STATUS))
|
2008-08-08 15:12:47 +00:00
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 1; i <= size; i++) {
|
|
|
|
/* trigger an irq MESS_WRITE_NEXT */
|
|
|
|
err = vx_send_irq_dsp(chip, IRQ_MESS_WRITE_NEXT);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
/* Wait for RX full (with timeout protection) */
|
|
|
|
err = vx_wait_for_rx_full(chip);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
rmh->Stat[i] = vx_inb(chip, RXH) << 16;
|
|
|
|
rmh->Stat[i] |= vx_inb(chip, RXM) << 8;
|
|
|
|
rmh->Stat[i] |= vx_inb(chip, RXL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return vx_transfer_end(chip, IRQ_MESS_WRITE_END);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define MASK_MORE_THAN_1_WORD_COMMAND 0x00008000
|
|
|
|
#define MASK_1_WORD_COMMAND 0x00ff7fff
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_send_msg_nolock - send a DSP message and read back the status
|
|
|
|
* @rmh: the rmh record to send and receive
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
* the error code can be VX-specific, retrieved via vx_get_error().
|
|
|
|
*
|
2014-09-09 15:17:20 +00:00
|
|
|
* this function doesn't call mutex lock at all.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
|
|
|
|
if (chip->chip_status & VX_STAT_IS_STALE)
|
|
|
|
return -EBUSY;
|
|
|
|
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_reset_chk(chip);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: vx_reset_chk error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printk(KERN_DEBUG "rmh: cmd = 0x%06x, length = %d, stype = %d\n",
|
|
|
|
rmh->Cmd[0], rmh->LgCmd, rmh->DspStat);
|
|
|
|
if (rmh->LgCmd > 1) {
|
|
|
|
printk(KERN_DEBUG " ");
|
|
|
|
for (i = 1; i < rmh->LgCmd; i++)
|
2017-08-31 08:56:12 +00:00
|
|
|
printk(KERN_CONT "0x%06x ", rmh->Cmd[i]);
|
|
|
|
printk(KERN_CONT "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* Check bit M is set according to length of the command */
|
|
|
|
if (rmh->LgCmd > 1)
|
|
|
|
rmh->Cmd[0] |= MASK_MORE_THAN_1_WORD_COMMAND;
|
|
|
|
else
|
|
|
|
rmh->Cmd[0] &= MASK_1_WORD_COMMAND;
|
|
|
|
|
|
|
|
/* Wait for TX empty */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: wait tx empty error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write Cmd[0] */
|
|
|
|
vx_outb(chip, TXH, (rmh->Cmd[0] >> 16) & 0xff);
|
|
|
|
vx_outb(chip, TXM, (rmh->Cmd[0] >> 8) & 0xff);
|
|
|
|
vx_outb(chip, TXL, rmh->Cmd[0] & 0xff);
|
|
|
|
|
|
|
|
/* Trigger irq MESSAGE */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_send_irq_dsp(chip, IRQ_MESSAGE);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: send IRQ_MESSAGE error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for CHK = 1 */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_CHK);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* If error, get error value from RX */
|
|
|
|
if (vx_inb(chip, ISR) & ISR_ERR) {
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_for_rx_full(chip);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: rx_full read error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
err = vx_inb(chip, RXH) << 16;
|
|
|
|
err |= vx_inb(chip, RXM) << 8;
|
|
|
|
err |= vx_inb(chip, RXL);
|
|
|
|
snd_printd(KERN_DEBUG "msg got error = 0x%x at cmd[0]\n", err);
|
|
|
|
err = -(VX_ERR_MASK | err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send the other words */
|
|
|
|
if (rmh->LgCmd > 1) {
|
|
|
|
for (i = 1; i < rmh->LgCmd; i++) {
|
|
|
|
/* Wait for TX ready */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_TX_READY);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: tx_ready error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write Cmd[i] */
|
|
|
|
vx_outb(chip, TXH, (rmh->Cmd[i] >> 16) & 0xff);
|
|
|
|
vx_outb(chip, TXM, (rmh->Cmd[i] >> 8) & 0xff);
|
|
|
|
vx_outb(chip, TXL, rmh->Cmd[i] & 0xff);
|
|
|
|
|
|
|
|
/* Trigger irq MESS_READ_NEXT */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: IRQ_READ_NEXT error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Wait for TX empty */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_TX_READY);
|
|
|
|
if (err < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_printd(KERN_DEBUG "vx_send_msg: TX_READY error\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
/* End of transfer */
|
|
|
|
err = vx_transfer_end(chip, IRQ_MESS_READ_END);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vx_read_status(chip, rmh);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-09-09 15:17:20 +00:00
|
|
|
* vx_send_msg - send a DSP message with mutex
|
2005-04-16 22:20:36 +00:00
|
|
|
* @rmh: the rmh record to send and receive
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
* see vx_send_msg_nolock().
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_lock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
err = vx_send_msg_nolock(chip, rmh);
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_unlock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vx_send_rih_nolock - send an RIH to xilinx
|
|
|
|
* @cmd: the command to send
|
|
|
|
*
|
|
|
|
* returns 0 if successful, or a negative error code.
|
|
|
|
* the error code can be VX-specific, retrieved via vx_get_error().
|
|
|
|
*
|
2014-09-09 15:17:20 +00:00
|
|
|
* this function doesn't call mutex at all.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* unlike RMH, no command is sent to DSP.
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int vx_send_rih_nolock(struct vx_core *chip, int cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (chip->chip_status & VX_STAT_IS_STALE)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printk(KERN_DEBUG "send_rih: cmd = 0x%x\n", cmd);
|
|
|
|
#endif
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_reset_chk(chip);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
/* send the IRQ */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_send_irq_dsp(chip, cmd);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
/* Wait CHK = 1 */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_CHK);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
/* If error, read RX */
|
|
|
|
if (vx_inb(chip, ISR) & ISR_ERR) {
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_for_rx_full(chip);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
err = vx_inb(chip, RXH) << 16;
|
|
|
|
err |= vx_inb(chip, RXM) << 8;
|
|
|
|
err |= vx_inb(chip, RXL);
|
|
|
|
return -(VX_ERR_MASK | err);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-09-09 15:17:20 +00:00
|
|
|
* vx_send_rih - send an RIH with mutex
|
2005-04-16 22:20:36 +00:00
|
|
|
* @cmd: the command to send
|
|
|
|
*
|
|
|
|
* see vx_send_rih_nolock().
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int vx_send_rih(struct vx_core *chip, int cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_lock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
err = vx_send_rih_nolock(chip, cmd);
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_unlock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define END_OF_RESET_WAIT_TIME 500 /* us */
|
|
|
|
|
|
|
|
/**
|
2021-03-02 21:54:28 +00:00
|
|
|
* snd_vx_load_boot_image - boot up the xilinx interface
|
2014-11-10 15:46:35 +00:00
|
|
|
* @chip: VX core instance
|
2005-04-16 22:20:36 +00:00
|
|
|
* @boot: the boot record to load
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int no_fillup = vx_has_new_dsp(chip);
|
|
|
|
|
|
|
|
/* check the length of boot image */
|
2008-08-08 15:12:47 +00:00
|
|
|
if (boot->size <= 0)
|
|
|
|
return -EINVAL;
|
|
|
|
if (boot->size % 3)
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
/* more strict check */
|
|
|
|
unsigned int c = ((u32)boot->data[0] << 16) | ((u32)boot->data[1] << 8) | boot->data[2];
|
2008-08-08 15:12:47 +00:00
|
|
|
if (boot->size != (c + 2) * 3)
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* reset dsp */
|
|
|
|
vx_reset_dsp(chip);
|
|
|
|
|
|
|
|
udelay(END_OF_RESET_WAIT_TIME); /* another wait? */
|
|
|
|
|
|
|
|
/* download boot strap */
|
|
|
|
for (i = 0; i < 0x600; i += 3) {
|
|
|
|
if (i >= boot->size) {
|
|
|
|
if (no_fillup)
|
|
|
|
break;
|
|
|
|
if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) {
|
|
|
|
snd_printk(KERN_ERR "dsp boot failed at %d\n", i);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
vx_outb(chip, TXH, 0);
|
|
|
|
vx_outb(chip, TXM, 0);
|
|
|
|
vx_outb(chip, TXL, 0);
|
|
|
|
} else {
|
2008-05-23 23:02:49 +00:00
|
|
|
const unsigned char *image = boot->data + i;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) {
|
|
|
|
snd_printk(KERN_ERR "dsp boot failed at %d\n", i);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
vx_outb(chip, TXH, image[0]);
|
|
|
|
vx_outb(chip, TXM, image[1]);
|
|
|
|
vx_outb(chip, TXL, image[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_load_boot_image);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* vx_test_irq_src - query the source of interrupts
|
|
|
|
*
|
|
|
|
* called from irq handler only
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static int vx_test_irq_src(struct vx_core *chip, unsigned int *ret)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
vx_init_rmh(&chip->irq_rmh, CMD_TEST_IT);
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_lock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
err = vx_send_msg_nolock(chip, &chip->irq_rmh);
|
|
|
|
if (err < 0)
|
|
|
|
*ret = 0;
|
|
|
|
else
|
|
|
|
*ret = chip->irq_rmh.Stat[0];
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_unlock(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-09-09 15:17:20 +00:00
|
|
|
* snd_vx_threaded_irq_handler - threaded irq handler
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2014-09-09 15:17:20 +00:00
|
|
|
irqreturn_t snd_vx_threaded_irq_handler(int irq, void *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2014-09-09 15:17:20 +00:00
|
|
|
struct vx_core *chip = dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int events;
|
|
|
|
|
|
|
|
if (chip->chip_status & VX_STAT_IS_STALE)
|
2014-09-09 15:17:20 +00:00
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (vx_test_irq_src(chip, &events) < 0)
|
2014-09-09 15:17:20 +00:00
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (events & 0x000800)
|
|
|
|
printk(KERN_ERR "DSP Stream underrun ! IRQ events = 0x%x\n", events);
|
|
|
|
#endif
|
|
|
|
// printk(KERN_DEBUG "IRQ events = 0x%x\n", events);
|
|
|
|
|
|
|
|
/* We must prevent any application using this DSP
|
|
|
|
* and block any further request until the application
|
|
|
|
* either unregisters or reloads the DSP
|
|
|
|
*/
|
|
|
|
if (events & FATAL_DSP_ERROR) {
|
|
|
|
snd_printk(KERN_ERR "vx_core: fatal DSP error!!\n");
|
2014-09-09 15:17:20 +00:00
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The start on time code conditions are filled (ie the time code
|
|
|
|
* received by the board is equal to one of those given to it).
|
|
|
|
*/
|
2020-07-02 19:36:03 +00:00
|
|
|
if (events & TIME_CODE_EVENT_PENDING) {
|
2005-04-16 22:20:36 +00:00
|
|
|
; /* so far, nothing to do yet */
|
2020-07-02 19:36:03 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* The frequency has changed on the board (UER mode). */
|
|
|
|
if (events & FREQUENCY_CHANGE_EVENT_PENDING)
|
|
|
|
vx_change_frequency(chip);
|
|
|
|
|
|
|
|
/* update the pcm streams */
|
|
|
|
vx_pcm_update_intr(chip, events);
|
2014-09-09 15:17:20 +00:00
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2014-09-09 15:17:20 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_threaded_irq_handler);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_vx_irq_handler - interrupt handler
|
2014-11-10 15:46:35 +00:00
|
|
|
* @irq: irq number
|
|
|
|
* @dev: VX core instance
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
irqreturn_t snd_vx_irq_handler(int irq, void *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-17 13:46:59 +00:00
|
|
|
struct vx_core *chip = dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (! (chip->chip_status & VX_STAT_CHIP_INIT) ||
|
|
|
|
(chip->chip_status & VX_STAT_IS_STALE))
|
|
|
|
return IRQ_NONE;
|
|
|
|
if (! vx_test_and_ack(chip))
|
2014-09-09 15:17:20 +00:00
|
|
|
return IRQ_WAKE_THREAD;
|
|
|
|
return IRQ_NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_irq_handler);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
static void vx_reset_board(struct vx_core *chip, int cold_reset)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-08-08 15:12:47 +00:00
|
|
|
if (snd_BUG_ON(!chip->ops->reset_board))
|
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* current source, later sync'ed with target */
|
|
|
|
chip->audio_source = VX_AUDIO_SRC_LINE;
|
|
|
|
if (cold_reset) {
|
|
|
|
chip->audio_source_target = chip->audio_source;
|
|
|
|
chip->clock_source = INTERNAL_QUARTZ;
|
|
|
|
chip->clock_mode = VX_CLOCK_MODE_AUTO;
|
|
|
|
chip->freq = 48000;
|
|
|
|
chip->uer_detected = VX_UER_MODE_NOT_PRESENT;
|
|
|
|
chip->uer_bits = SNDRV_PCM_DEFAULT_CON_SPDIF;
|
|
|
|
}
|
|
|
|
|
|
|
|
chip->ops->reset_board(chip, cold_reset);
|
|
|
|
|
|
|
|
vx_reset_codec(chip, cold_reset);
|
|
|
|
|
|
|
|
vx_set_internal_clock(chip, chip->freq);
|
|
|
|
|
|
|
|
/* Reset the DSP */
|
|
|
|
vx_reset_dsp(chip);
|
|
|
|
|
|
|
|
if (vx_is_pcmcia(chip)) {
|
|
|
|
/* Acknowledge any pending IRQ and reset the MEMIRQ flag. */
|
|
|
|
vx_test_and_ack(chip);
|
|
|
|
vx_validate_irq(chip, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init CBits */
|
|
|
|
vx_set_iec958_status(chip, chip->uer_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* proc interface
|
|
|
|
*/
|
|
|
|
|
2005-11-17 13:46:59 +00:00
|
|
|
static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-17 13:46:59 +00:00
|
|
|
struct vx_core *chip = entry->private_data;
|
2020-01-05 14:47:22 +00:00
|
|
|
static const char * const audio_src_vxp[] = { "Line", "Mic", "Digital" };
|
|
|
|
static const char * const audio_src_vx2[] = { "Analog", "Analog", "Digital" };
|
|
|
|
static const char * const clock_mode[] = { "Auto", "Internal", "External" };
|
|
|
|
static const char * const clock_src[] = { "Internal", "External" };
|
|
|
|
static const char * const uer_type[] = { "Consumer", "Professional", "Not Present" };
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
snd_iprintf(buffer, "%s\n", chip->card->longname);
|
|
|
|
snd_iprintf(buffer, "Xilinx Firmware: %s\n",
|
2020-09-02 21:21:31 +00:00
|
|
|
(chip->chip_status & VX_STAT_XILINX_LOADED) ? "Loaded" : "No");
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_iprintf(buffer, "Device Initialized: %s\n",
|
2020-09-02 21:21:31 +00:00
|
|
|
(chip->chip_status & VX_STAT_DEVICE_INIT) ? "Yes" : "No");
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_iprintf(buffer, "DSP audio info:");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_REAL_TIME)
|
|
|
|
snd_iprintf(buffer, " realtime");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_OFFLINE)
|
|
|
|
snd_iprintf(buffer, " offline");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_MPEG1)
|
|
|
|
snd_iprintf(buffer, " mpeg1");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_MPEG2)
|
|
|
|
snd_iprintf(buffer, " mpeg2");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_LINEAR_8)
|
|
|
|
snd_iprintf(buffer, " linear8");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_LINEAR_16)
|
|
|
|
snd_iprintf(buffer, " linear16");
|
|
|
|
if (chip->audio_info & VX_AUDIO_INFO_LINEAR_24)
|
|
|
|
snd_iprintf(buffer, " linear24");
|
|
|
|
snd_iprintf(buffer, "\n");
|
|
|
|
snd_iprintf(buffer, "Input Source: %s\n", vx_is_pcmcia(chip) ?
|
|
|
|
audio_src_vxp[chip->audio_source] :
|
|
|
|
audio_src_vx2[chip->audio_source]);
|
|
|
|
snd_iprintf(buffer, "Clock Mode: %s\n", clock_mode[chip->clock_mode]);
|
|
|
|
snd_iprintf(buffer, "Clock Source: %s\n", clock_src[chip->clock_source]);
|
|
|
|
snd_iprintf(buffer, "Frequency: %d\n", chip->freq);
|
|
|
|
snd_iprintf(buffer, "Detected Frequency: %d\n", chip->freq_detected);
|
|
|
|
snd_iprintf(buffer, "Detected UER type: %s\n", uer_type[chip->uer_detected]);
|
|
|
|
snd_iprintf(buffer, "Min/Max/Cur IBL: %d/%d/%d (granularity=%d)\n",
|
|
|
|
chip->ibl.min_size, chip->ibl.max_size, chip->ibl.size,
|
|
|
|
chip->ibl.granularity);
|
|
|
|
}
|
|
|
|
|
2005-11-17 13:46:59 +00:00
|
|
|
static void vx_proc_init(struct vx_core *chip)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2019-02-04 14:58:33 +00:00
|
|
|
snd_card_ro_proc_new(chip->card, "vx-status", chip, vx_proc_read);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_vx_dsp_boot - load the DSP boot
|
2014-11-10 15:46:35 +00:00
|
|
|
* @chip: VX core instance
|
|
|
|
* @boot: firmware data
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
int cold_reset = !(chip->chip_status & VX_STAT_DEVICE_INIT);
|
|
|
|
|
|
|
|
vx_reset_board(chip, cold_reset);
|
|
|
|
vx_validate_irq(chip, 0);
|
|
|
|
|
2021-06-08 14:05:34 +00:00
|
|
|
err = snd_vx_load_boot_image(chip, boot);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
2005-11-17 09:21:19 +00:00
|
|
|
msleep(10);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_dsp_boot);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* snd_vx_dsp_load - load the DSP image
|
2014-11-10 15:46:35 +00:00
|
|
|
* @chip: VX core instance
|
|
|
|
* @dsp: firmware data
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-11-17 13:46:59 +00:00
|
|
|
int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int err;
|
|
|
|
unsigned int csum = 0;
|
2008-05-23 23:02:49 +00:00
|
|
|
const unsigned char *image, *cptr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-08-08 15:12:47 +00:00
|
|
|
if (dsp->size % 3)
|
|
|
|
return -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
vx_toggle_dac_mute(chip, 1);
|
|
|
|
|
|
|
|
/* Transfert data buffer from PC to DSP */
|
|
|
|
for (i = 0; i < dsp->size; i += 3) {
|
|
|
|
image = dsp->data + i;
|
|
|
|
/* Wait DSP ready for a new read */
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
|
|
|
|
if (err < 0) {
|
2009-02-05 14:51:50 +00:00
|
|
|
printk(KERN_ERR
|
|
|
|
"dsp loading error at position %d\n", i);
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
cptr = image;
|
|
|
|
csum ^= *cptr;
|
|
|
|
csum = (csum >> 24) | (csum << 8);
|
|
|
|
vx_outb(chip, TXH, *cptr++);
|
|
|
|
csum ^= *cptr;
|
|
|
|
csum = (csum >> 24) | (csum << 8);
|
|
|
|
vx_outb(chip, TXM, *cptr++);
|
|
|
|
csum ^= *cptr;
|
|
|
|
csum = (csum >> 24) | (csum << 8);
|
|
|
|
vx_outb(chip, TXL, *cptr++);
|
|
|
|
}
|
|
|
|
snd_printdd(KERN_DEBUG "checksum = 0x%08x\n", csum);
|
|
|
|
|
2005-11-17 09:21:19 +00:00
|
|
|
msleep(200);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2021-06-08 14:05:34 +00:00
|
|
|
err = vx_wait_isr_bit(chip, ISR_CHK);
|
|
|
|
if (err < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
vx_toggle_dac_mute(chip, 0);
|
|
|
|
|
|
|
|
vx_test_and_ack(chip);
|
|
|
|
vx_validate_irq(chip, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_dsp_load);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
/*
|
|
|
|
* suspend
|
|
|
|
*/
|
2012-07-02 13:20:37 +00:00
|
|
|
int snd_vx_suspend(struct vx_core *chip)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-17 15:06:05 +00:00
|
|
|
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
|
2005-04-16 22:20:36 +00:00
|
|
|
chip->chip_status |= VX_STAT_IN_SUSPEND;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_suspend);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* resume
|
|
|
|
*/
|
2005-11-17 15:06:05 +00:00
|
|
|
int snd_vx_resume(struct vx_core *chip)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
|
|
|
|
chip->chip_status &= ~VX_STAT_CHIP_INIT;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (! chip->firmware[i])
|
|
|
|
continue;
|
|
|
|
err = chip->ops->load_dsp(chip, i, chip->firmware[i]);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_printk(KERN_ERR "vx: firmware resume error at DSP %d\n", i);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
chip->chip_status |= VX_STAT_CHIP_INIT;
|
|
|
|
chip->chip_status &= ~VX_STAT_IN_SUSPEND;
|
|
|
|
|
2005-11-17 15:06:05 +00:00
|
|
|
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_resume);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2021-07-15 07:59:11 +00:00
|
|
|
static void snd_vx_release(struct device *dev, void *data)
|
|
|
|
{
|
|
|
|
snd_vx_free_firmware(data);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
2005-11-17 13:46:59 +00:00
|
|
|
* snd_vx_create - constructor for struct vx_core
|
2014-11-10 15:46:35 +00:00
|
|
|
* @card: card instance
|
2005-04-16 22:20:36 +00:00
|
|
|
* @hw: hardware specific record
|
2014-11-10 15:46:35 +00:00
|
|
|
* @ops: VX ops pointer
|
|
|
|
* @extra_size: extra byte size to allocate appending to chip
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* this function allocates the instance and prepare for the hardware
|
|
|
|
* initialization.
|
|
|
|
*
|
2021-07-15 07:59:11 +00:00
|
|
|
* The object is managed via devres, and will be automatically released.
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* return the instance pointer if successful, NULL in error.
|
|
|
|
*/
|
2020-01-03 08:16:46 +00:00
|
|
|
struct vx_core *snd_vx_create(struct snd_card *card,
|
|
|
|
const struct snd_vx_hardware *hw,
|
|
|
|
const struct snd_vx_ops *ops,
|
2005-11-17 13:46:59 +00:00
|
|
|
int extra_size)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-17 13:46:59 +00:00
|
|
|
struct vx_core *chip;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-08-08 15:12:47 +00:00
|
|
|
if (snd_BUG_ON(!card || !hw || !ops))
|
|
|
|
return NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2021-07-15 07:59:11 +00:00
|
|
|
chip = devres_alloc(snd_vx_release, sizeof(*chip) + extra_size,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!chip)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
2014-09-09 15:17:20 +00:00
|
|
|
mutex_init(&chip->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
chip->irq = -1;
|
|
|
|
chip->hw = hw;
|
|
|
|
chip->type = hw->type;
|
|
|
|
chip->ops = ops;
|
2006-01-16 15:31:42 +00:00
|
|
|
mutex_init(&chip->mixer_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
chip->card = card;
|
|
|
|
card->private_data = chip;
|
|
|
|
strcpy(card->driver, hw->name);
|
|
|
|
sprintf(card->shortname, "Digigram %s", hw->name);
|
|
|
|
|
|
|
|
vx_proc_init(chip);
|
|
|
|
|
|
|
|
return chip;
|
|
|
|
}
|
|
|
|
|
2006-04-28 13:13:40 +00:00
|
|
|
EXPORT_SYMBOL(snd_vx_create);
|