2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Driver for Digigram miXart soundcards
|
|
|
|
*
|
|
|
|
* main file with alsa callbacks
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 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 <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/pci.h>
|
2006-03-22 02:53:19 -07:00
|
|
|
#include <linux/dma-mapping.h>
|
2011-07-15 11:13:37 -06:00
|
|
|
#include <linux/module.h>
|
2006-01-16 08:34:20 -07:00
|
|
|
#include <linux/mutex.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2006-03-28 02:56:48 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <sound/info.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
#include "mixart.h"
|
|
|
|
#include "mixart_hwdep.h"
|
|
|
|
#include "mixart_core.h"
|
|
|
|
#include "mixart_mixer.h"
|
|
|
|
|
|
|
|
#define CARD_NAME "miXart"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Digigram <alsa@digigram.com>");
|
|
|
|
MODULE_DESCRIPTION("Digigram " CARD_NAME);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
|
|
|
|
|
|
|
|
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
|
|
|
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
2011-12-14 20:19:36 -07:00
|
|
|
static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
module_param_array(index, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
|
|
|
|
module_param_array(id, charp, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard.");
|
|
|
|
module_param_array(enable, bool, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2014-08-08 07:56:03 -06:00
|
|
|
static const struct pci_device_id snd_mixart_ids[] = {
|
2009-06-24 23:13:35 -06:00
|
|
|
{ PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */
|
2005-04-16 16:20:36 -06:00
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, snd_mixart_ids);
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int mixart_set_pipe_state(struct mixart_mgr *mgr,
|
|
|
|
struct mixart_pipe *pipe, int start)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_group_state_req group_state;
|
|
|
|
struct mixart_group_state_resp group_state_resp;
|
|
|
|
struct mixart_msg request;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err;
|
|
|
|
u32 system_msg_uid;
|
|
|
|
|
|
|
|
switch(pipe->status) {
|
|
|
|
case PIPE_RUNNING:
|
|
|
|
case PIPE_CLOCK_SET:
|
|
|
|
if(start) return 0; /* already started */
|
|
|
|
break;
|
|
|
|
case PIPE_STOPPED:
|
|
|
|
if(!start) return 0; /* already stopped */
|
|
|
|
break;
|
|
|
|
default:
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error mixart_set_pipe_state called with wrong pipe->status!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL; /* function called with wrong pipe status */
|
|
|
|
}
|
|
|
|
|
|
|
|
system_msg_uid = 0x12345678; /* the event ! (take care: the MSB and two LSB's have to be 0) */
|
|
|
|
|
|
|
|
/* wait on the last MSG_SYSTEM_SEND_SYNCHRO_CMD command to be really finished */
|
|
|
|
|
|
|
|
request.message_id = MSG_SYSTEM_WAIT_SYNCHRO_CMD;
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &system_msg_uid;
|
|
|
|
request.size = sizeof(system_msg_uid);
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg_wait_notif(mgr, &request, system_msg_uid);
|
|
|
|
if(err) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error : MSG_SYSTEM_WAIT_SYNCHRO_CMD was not notified !\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start or stop the pipe (1 pipe) */
|
|
|
|
|
|
|
|
memset(&group_state, 0, sizeof(group_state));
|
|
|
|
group_state.pipe_count = 1;
|
|
|
|
group_state.pipe_uid[0] = pipe->group_uid;
|
|
|
|
|
|
|
|
if(start)
|
|
|
|
request.message_id = MSG_STREAM_START_STREAM_GRP_PACKET;
|
|
|
|
else
|
|
|
|
request.message_id = MSG_STREAM_STOP_STREAM_GRP_PACKET;
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &group_state;
|
|
|
|
request.size = sizeof(group_state);
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
|
|
|
|
if (err < 0 || group_state_resp.txx_status != 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error MSG_STREAM_ST***_STREAM_GRP_PACKET err=%x stat=%x !\n",
|
|
|
|
err, group_state_resp.txx_status);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(start) {
|
2016-03-16 01:42:13 -06:00
|
|
|
u32 stat = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
group_state.pipe_count = 0; /* in case of start same command once again with pipe_count=0 */
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
|
|
|
|
if (err < 0 || group_state_resp.txx_status != 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error MSG_STREAM_START_STREAM_GRP_PACKET err=%x stat=%x !\n",
|
|
|
|
err, group_state_resp.txx_status);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* in case of start send a synchro top */
|
|
|
|
|
|
|
|
request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD;
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = NULL;
|
|
|
|
request.size = 0;
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(mgr, &request, sizeof(stat), &stat);
|
|
|
|
if (err < 0 || stat != 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error MSG_SYSTEM_SEND_SYNCHRO_CMD err=%x stat=%x !\n",
|
|
|
|
err, stat);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipe->status = PIPE_RUNNING;
|
|
|
|
}
|
|
|
|
else /* !start */
|
|
|
|
pipe->status = PIPE_STOPPED;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int mixart_set_clock(struct mixart_mgr *mgr,
|
|
|
|
struct mixart_pipe *pipe, unsigned int rate)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_msg request;
|
|
|
|
struct mixart_clock_properties clock_properties;
|
|
|
|
struct mixart_clock_properties_resp clock_prop_resp;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err;
|
|
|
|
|
|
|
|
switch(pipe->status) {
|
|
|
|
case PIPE_CLOCK_SET:
|
|
|
|
break;
|
|
|
|
case PIPE_RUNNING:
|
|
|
|
if(rate != 0)
|
|
|
|
break;
|
2018-08-04 14:11:03 -06:00
|
|
|
/* fall through */
|
2005-04-16 16:20:36 -06:00
|
|
|
default:
|
|
|
|
if(rate == 0)
|
|
|
|
return 0; /* nothing to do */
|
|
|
|
else {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error mixart_set_clock(%d) called with wrong pipe->status !\n",
|
|
|
|
rate);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&clock_properties, 0, sizeof(clock_properties));
|
|
|
|
clock_properties.clock_generic_type = (rate != 0) ? CGT_INTERNAL_CLOCK : CGT_NO_CLOCK;
|
|
|
|
clock_properties.clock_mode = CM_STANDALONE;
|
|
|
|
clock_properties.frequency = rate;
|
|
|
|
clock_properties.nb_callers = 1; /* only one entry in uid_caller ! */
|
|
|
|
clock_properties.uid_caller[0] = pipe->group_uid;
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(&mgr->pci->dev, "mixart_set_clock to %d kHz\n", rate);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
request.message_id = MSG_CLOCK_SET_PROPERTIES;
|
|
|
|
request.uid = mgr->uid_console_manager;
|
|
|
|
request.data = &clock_properties;
|
|
|
|
request.size = sizeof(clock_properties);
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(mgr, &request, sizeof(clock_prop_resp), &clock_prop_resp);
|
|
|
|
if (err < 0 || clock_prop_resp.status != 0 || clock_prop_resp.clock_mode != CM_STANDALONE) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error MSG_CLOCK_SET_PROPERTIES err=%x stat=%x mod=%x !\n",
|
|
|
|
err, clock_prop_resp.status, clock_prop_resp.clock_mode);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(rate) pipe->status = PIPE_CLOCK_SET;
|
|
|
|
else pipe->status = PIPE_RUNNING;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate or reference output pipe for analog IOs (pcmp0/1)
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_pipe *
|
|
|
|
snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
|
|
|
|
int monitoring)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int stream_count;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_pipe *pipe;
|
|
|
|
struct mixart_msg request;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if(capture) {
|
|
|
|
if (pcm_number == MIXART_PCM_ANALOG) {
|
|
|
|
pipe = &(chip->pipe_in_ana); /* analog inputs */
|
|
|
|
} else {
|
|
|
|
pipe = &(chip->pipe_in_dig); /* digital inputs */
|
|
|
|
}
|
|
|
|
request.message_id = MSG_STREAM_ADD_OUTPUT_GROUP;
|
|
|
|
stream_count = MIXART_CAPTURE_STREAMS;
|
|
|
|
} else {
|
|
|
|
if (pcm_number == MIXART_PCM_ANALOG) {
|
|
|
|
pipe = &(chip->pipe_out_ana); /* analog outputs */
|
|
|
|
} else {
|
|
|
|
pipe = &(chip->pipe_out_dig); /* digital outputs */
|
|
|
|
}
|
|
|
|
request.message_id = MSG_STREAM_ADD_INPUT_GROUP;
|
|
|
|
stream_count = MIXART_PLAYBACK_STREAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* a new stream is opened and there are already all streams in use */
|
|
|
|
if( (monitoring == 0) && (pipe->references >= stream_count) ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pipe is not yet defined */
|
|
|
|
if( pipe->status == PIPE_UNDEFINED ) {
|
|
|
|
int err, i;
|
|
|
|
struct {
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_streaming_group_req sgroup_req;
|
|
|
|
struct mixart_streaming_group sgroup_resp;
|
2005-04-16 16:20:36 -06:00
|
|
|
} *buf;
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev,
|
|
|
|
"add_ref_pipe audio chip(%d) pcm(%d)\n",
|
|
|
|
chip->chip_idx, pcm_number);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
buf = kmalloc(sizeof(*buf), GFP_KERNEL);
|
|
|
|
if (!buf)
|
|
|
|
return NULL;
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0}; /* should be StreamManagerUID, but zero is OK if there is only one ! */
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &buf->sgroup_req;
|
|
|
|
request.size = sizeof(buf->sgroup_req);
|
|
|
|
|
|
|
|
memset(&buf->sgroup_req, 0, sizeof(buf->sgroup_req));
|
|
|
|
|
|
|
|
buf->sgroup_req.stream_count = stream_count;
|
|
|
|
buf->sgroup_req.channel_count = 2;
|
|
|
|
buf->sgroup_req.latency = 256;
|
|
|
|
buf->sgroup_req.connector = pipe->uid_left_connector; /* the left connector */
|
|
|
|
|
|
|
|
for (i=0; i<stream_count; i++) {
|
|
|
|
int j;
|
|
|
|
struct mixart_flowinfo *flowinfo;
|
|
|
|
struct mixart_bufferinfo *bufferinfo;
|
|
|
|
|
|
|
|
/* we don't yet know the format, so config 16 bit pcm audio for instance */
|
|
|
|
buf->sgroup_req.stream_info[i].size_max_byte_frame = 1024;
|
|
|
|
buf->sgroup_req.stream_info[i].size_max_sample_frame = 256;
|
|
|
|
buf->sgroup_req.stream_info[i].nb_bytes_max_per_sample = MIXART_FLOAT_P__4_0_TO_HEX; /* is 4.0f */
|
|
|
|
|
|
|
|
/* find the right bufferinfo_array */
|
|
|
|
j = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (pcm_number * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS)) + i;
|
|
|
|
if(capture) j += MIXART_PLAYBACK_STREAMS; /* in the array capture is behind playback */
|
|
|
|
|
|
|
|
buf->sgroup_req.flow_entry[i] = j;
|
|
|
|
|
|
|
|
flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area;
|
2005-11-17 07:01:08 -07:00
|
|
|
flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mixart_bufferinfo));
|
2005-04-16 16:20:36 -06:00
|
|
|
flowinfo[j].bufferinfo_count = 1; /* 1 will set the miXart to ring-buffer mode ! */
|
|
|
|
|
|
|
|
bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area;
|
|
|
|
bufferinfo[j].buffer_address = 0; /* buffer is not yet allocated */
|
|
|
|
bufferinfo[j].available_length = 0; /* buffer is not yet allocated */
|
|
|
|
|
|
|
|
/* construct the identifier of the stream buffer received in the interrupts ! */
|
|
|
|
bufferinfo[j].buffer_id = (chip->chip_idx << MIXART_NOTIFY_CARD_OFFSET) + (pcm_number << MIXART_NOTIFY_PCM_OFFSET ) + i;
|
|
|
|
if(capture) {
|
|
|
|
bufferinfo[j].buffer_id |= MIXART_NOTIFY_CAPT_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp);
|
|
|
|
if((err < 0) || (buf->sgroup_resp.status != 0)) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n",
|
|
|
|
err, buf->sgroup_resp.status);
|
2005-04-16 16:20:36 -06:00
|
|
|
kfree(buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipe->group_uid = buf->sgroup_resp.group; /* id of the pipe, as returned by embedded */
|
|
|
|
pipe->stream_count = buf->sgroup_resp.stream_count;
|
|
|
|
/* pipe->stream_uid[i] = buf->sgroup_resp.stream[i].stream_uid; */
|
|
|
|
|
|
|
|
pipe->status = PIPE_STOPPED;
|
|
|
|
kfree(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(monitoring) pipe->monitoring = 1;
|
|
|
|
else pipe->references++;
|
|
|
|
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
|
|
|
|
struct mixart_pipe *pipe, int monitoring)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if(pipe->status == PIPE_UNDEFINED)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(monitoring)
|
|
|
|
pipe->monitoring = 0;
|
|
|
|
else
|
|
|
|
pipe->references--;
|
|
|
|
|
|
|
|
if((pipe->references <= 0) && (pipe->monitoring == 0)) {
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_msg request;
|
|
|
|
struct mixart_delete_group_resp delete_resp;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* release the clock */
|
|
|
|
err = mixart_set_clock( mgr, pipe, 0);
|
|
|
|
if( err < 0 ) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"mixart_set_clock(0) return error!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stop the pipe */
|
|
|
|
err = mixart_set_pipe_state(mgr, pipe, 0);
|
|
|
|
if( err < 0 ) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev, "error stopping pipe!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
request.message_id = MSG_STREAM_DELETE_GROUP;
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &pipe->group_uid; /* the streaming group ! */
|
|
|
|
request.size = sizeof(pipe->group_uid);
|
|
|
|
|
|
|
|
/* delete the pipe */
|
|
|
|
err = snd_mixart_send_msg(mgr, &request, sizeof(delete_resp), &delete_resp);
|
|
|
|
if ((err < 0) || (delete_resp.status != 0)) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n",
|
|
|
|
err, delete_resp.status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
pipe->group_uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
pipe->stream_count = 0;
|
|
|
|
pipe->status = PIPE_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int mixart_set_stream_state(struct mixart_stream *stream, int start)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip;
|
|
|
|
struct mixart_stream_state_req stream_state_req;
|
|
|
|
struct mixart_msg request;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if(!stream->substream)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memset(&stream_state_req, 0, sizeof(stream_state_req));
|
|
|
|
stream_state_req.stream_count = 1;
|
|
|
|
stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid;
|
|
|
|
stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number;
|
|
|
|
|
|
|
|
if (stream->substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
request.message_id = start ? MSG_STREAM_START_INPUT_STAGE_PACKET : MSG_STREAM_STOP_INPUT_STAGE_PACKET;
|
|
|
|
else
|
|
|
|
request.message_id = start ? MSG_STREAM_START_OUTPUT_STAGE_PACKET : MSG_STREAM_STOP_OUTPUT_STAGE_PACKET;
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &stream_state_req;
|
|
|
|
request.size = sizeof(stream_state_req);
|
|
|
|
|
|
|
|
stream->abs_period_elapsed = 0; /* reset stream pos */
|
|
|
|
stream->buf_periods = 0;
|
|
|
|
stream->buf_period_frag = 0;
|
|
|
|
|
|
|
|
chip = snd_pcm_substream_chip(stream->substream);
|
|
|
|
|
|
|
|
return snd_mixart_send_msg_nonblock(chip->mgr, &request);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trigger callback
|
|
|
|
*/
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_stream *stream = subs->runtime->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_START\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* START_STREAM */
|
|
|
|
if( mixart_set_stream_state(stream, 1) )
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
stream->status = MIXART_STREAM_STATUS_RUNNING;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
|
|
|
|
|
|
/* STOP_STREAM */
|
|
|
|
if( mixart_set_stream_state(stream, 0) )
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
stream->status = MIXART_STREAM_STATUS_OPEN;
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_STOP\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
|
|
|
/* TODO */
|
|
|
|
stream->status = MIXART_STREAM_STATUS_PAUSE;
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_PUSH\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
|
|
|
/* TODO */
|
|
|
|
stream->status = MIXART_STREAM_STATUS_RUNNING;
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_RELEASE\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int mixart_sync_nonblock_events(struct mixart_mgr *mgr)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
[ALSA] sound/pci: fix-up sleeping paths
ENS1370/1+ driver,ES1968 driver,Intel8x0 driver,VIA82xx driver
VIA82xx-modem driver,AC97 Codec,ALI5451 driver,CS46xx driver
MIXART driver,RME HDSP driver,Trident driver,YMFPCI driver
Description: Fix-up sleeping in sound/pci. These changes fall under the
following two categories:
1) Replace schedule_timeout() with msleep() to guarantee the
task delays as expected. This also involved replacing/removing
custom sleep functions.
2) Do not assume jiffies will only increment by one if you
request a 1 jiffy sleep, i.e. use time_after/time_before in
while loops.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-07-09 02:13:22 -06:00
|
|
|
unsigned long timeout = jiffies + HZ;
|
2005-04-16 16:20:36 -06:00
|
|
|
while (atomic_read(&mgr->msg_processed) > 0) {
|
[ALSA] sound/pci: fix-up sleeping paths
ENS1370/1+ driver,ES1968 driver,Intel8x0 driver,VIA82xx driver
VIA82xx-modem driver,AC97 Codec,ALI5451 driver,CS46xx driver
MIXART driver,RME HDSP driver,Trident driver,YMFPCI driver
Description: Fix-up sleeping in sound/pci. These changes fall under the
following two categories:
1) Replace schedule_timeout() with msleep() to guarantee the
task delays as expected. This also involved replacing/removing
custom sleep functions.
2) Do not assume jiffies will only increment by one if you
request a 1 jiffy sleep, i.e. use time_after/time_before in
while loops.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-07-09 02:13:22 -06:00
|
|
|
if (time_after(jiffies, timeout)) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&mgr->pci->dev,
|
|
|
|
"mixart: cannot process nonblock events!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
2005-10-24 07:02:37 -06:00
|
|
|
schedule_timeout_uninterruptible(1);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prepare callback for all pcms
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_prepare(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
|
|
|
struct mixart_stream *stream = subs->runtime->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-05-09 00:41:36 -06:00
|
|
|
/* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev, "snd_mixart_prepare\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
mixart_sync_nonblock_events(chip->mgr);
|
|
|
|
|
|
|
|
/* only the first stream can choose the sample rate */
|
|
|
|
/* the further opened streams will be limited to its frequency (see open) */
|
|
|
|
if(chip->mgr->ref_count_rate == 1)
|
|
|
|
chip->mgr->sample_rate = subs->runtime->rate;
|
|
|
|
|
|
|
|
/* set the clock only once (first stream) on the same pipe */
|
|
|
|
if(stream->pipe->references == 1) {
|
|
|
|
if( mixart_set_clock(chip->mgr, stream->pipe, subs->runtime->rate) )
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t format)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip;
|
|
|
|
struct mixart_msg request;
|
|
|
|
struct mixart_stream_param_desc stream_param;
|
|
|
|
struct mixart_return_uid resp;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
chip = snd_pcm_substream_chip(stream->substream);
|
|
|
|
|
|
|
|
memset(&stream_param, 0, sizeof(stream_param));
|
|
|
|
|
|
|
|
stream_param.coding_type = CT_LINEAR;
|
|
|
|
stream_param.number_of_channel = stream->channels;
|
|
|
|
|
|
|
|
stream_param.sampling_freq = chip->mgr->sample_rate;
|
|
|
|
if(stream_param.sampling_freq == 0)
|
|
|
|
stream_param.sampling_freq = 44100; /* if frequency not yet defined, use some default */
|
|
|
|
|
|
|
|
switch(format){
|
|
|
|
case SNDRV_PCM_FORMAT_U8:
|
|
|
|
stream_param.sample_type = ST_INTEGER_8;
|
|
|
|
stream_param.sample_size = 8;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_S16_LE:
|
|
|
|
stream_param.sample_type = ST_INTEGER_16LE;
|
|
|
|
stream_param.sample_size = 16;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_S16_BE:
|
|
|
|
stream_param.sample_type = ST_INTEGER_16BE;
|
|
|
|
stream_param.sample_size = 16;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_S24_3LE:
|
|
|
|
stream_param.sample_type = ST_INTEGER_24LE;
|
|
|
|
stream_param.sample_size = 24;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_S24_3BE:
|
|
|
|
stream_param.sample_type = ST_INTEGER_24BE;
|
|
|
|
stream_param.sample_size = 24;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_FLOAT_LE:
|
|
|
|
stream_param.sample_type = ST_FLOATING_POINT_32LE;
|
|
|
|
stream_param.sample_size = 32;
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_FORMAT_FLOAT_BE:
|
|
|
|
stream_param.sample_type = ST_FLOATING_POINT_32BE;
|
|
|
|
stream_param.sample_size = 32;
|
|
|
|
break;
|
|
|
|
default:
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"error mixart_set_format() : unknown format\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev,
|
|
|
|
"set SNDRV_PCM_FORMAT sample_type(%d) sample_size(%d) freq(%d) channels(%d)\n",
|
2005-04-16 16:20:36 -06:00
|
|
|
stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels);
|
|
|
|
|
|
|
|
/* TODO: what else to configure ? */
|
|
|
|
/* stream_param.samples_per_frame = 2; */
|
|
|
|
/* stream_param.bytes_per_frame = 4; */
|
|
|
|
/* stream_param.bytes_per_sample = 2; */
|
|
|
|
|
|
|
|
stream_param.pipe_count = 1; /* set to 1 */
|
|
|
|
stream_param.stream_count = 1; /* set to 1 */
|
|
|
|
stream_param.stream_desc[0].uid_pipe = stream->pipe->group_uid;
|
|
|
|
stream_param.stream_desc[0].stream_idx = stream->substream->number;
|
|
|
|
|
|
|
|
request.message_id = MSG_STREAM_SET_INPUT_STAGE_PARAM;
|
2005-11-17 07:01:08 -07:00
|
|
|
request.uid = (struct mixart_uid){0,0};
|
2005-04-16 16:20:36 -06:00
|
|
|
request.data = &stream_param;
|
|
|
|
request.size = sizeof(stream_param);
|
|
|
|
|
|
|
|
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
|
|
|
|
if((err < 0) || resp.error_code) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"MSG_STREAM_SET_INPUT_STAGE_PARAM err=%x; resp=%x\n",
|
|
|
|
err, resp.error_code);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HW_PARAMS callback for all pcms
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
|
|
|
|
struct snd_pcm_hw_params *hw)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
|
|
|
struct mixart_mgr *mgr = chip->mgr;
|
|
|
|
struct mixart_stream *stream = subs->runtime->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_pcm_format_t format;
|
|
|
|
int err;
|
|
|
|
int channels;
|
|
|
|
|
|
|
|
/* set up channels */
|
|
|
|
channels = params_channels(hw);
|
|
|
|
|
|
|
|
/* set up format for the stream */
|
|
|
|
format = params_format(hw);
|
|
|
|
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_lock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* update the stream levels */
|
|
|
|
if( stream->pcm_number <= MIXART_PCM_DIGITAL ) {
|
|
|
|
int is_aes = stream->pcm_number > MIXART_PCM_ANALOG;
|
|
|
|
if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK )
|
|
|
|
mixart_update_playback_stream_level(chip, is_aes, subs->number);
|
|
|
|
else
|
|
|
|
mixart_update_capture_stream_level( chip, is_aes);
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->channels = channels;
|
|
|
|
|
|
|
|
/* set the format to the board */
|
|
|
|
err = mixart_set_format(stream, format);
|
|
|
|
if(err < 0) {
|
2009-03-11 13:11:41 -06:00
|
|
|
mutex_unlock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate buffer */
|
|
|
|
err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw));
|
|
|
|
|
|
|
|
if (err > 0) {
|
|
|
|
struct mixart_bufferinfo *bufferinfo;
|
|
|
|
int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number;
|
|
|
|
if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) {
|
|
|
|
i += MIXART_PLAYBACK_STREAMS; /* in array capture is behind playback */
|
|
|
|
}
|
|
|
|
|
|
|
|
bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area;
|
|
|
|
bufferinfo[i].buffer_address = subs->runtime->dma_addr;
|
|
|
|
bufferinfo[i].available_length = subs->runtime->dma_bytes;
|
|
|
|
/* bufferinfo[i].buffer_id is already defined */
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev,
|
|
|
|
"snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n",
|
|
|
|
i, bufferinfo[i].buffer_address,
|
2005-04-16 16:20:36 -06:00
|
|
|
bufferinfo[i].available_length,
|
|
|
|
subs->number);
|
|
|
|
}
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_unlock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_hw_free(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_pcm_lib_free_pages(subs);
|
|
|
|
mixart_sync_nonblock_events(chip->mgr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max
|
|
|
|
*/
|
2017-08-12 09:31:21 -06:00
|
|
|
static const struct snd_pcm_hardware snd_mixart_analog_caps =
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
.info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
2007-08-13 09:37:55 -06:00
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
2005-04-16 16:20:36 -06:00
|
|
|
SNDRV_PCM_INFO_PAUSE),
|
|
|
|
.formats = ( SNDRV_PCM_FMTBIT_U8 |
|
|
|
|
SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
|
|
|
|
SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |
|
|
|
|
SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE ),
|
|
|
|
.rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.rate_min = 8000,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (32*1024),
|
|
|
|
.period_bytes_min = 256, /* 256 frames U8 mono*/
|
|
|
|
.period_bytes_max = (16*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = (32*1024/256),
|
|
|
|
};
|
|
|
|
|
2017-08-12 09:31:21 -06:00
|
|
|
static const struct snd_pcm_hardware snd_mixart_digital_caps =
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
.info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
|
2007-08-13 09:37:55 -06:00
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
2005-04-16 16:20:36 -06:00
|
|
|
SNDRV_PCM_INFO_PAUSE),
|
|
|
|
.formats = ( SNDRV_PCM_FMTBIT_U8 |
|
|
|
|
SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
|
|
|
|
SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |
|
|
|
|
SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE ),
|
|
|
|
.rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
|
|
|
|
.rate_min = 32000,
|
|
|
|
.rate_max = 48000,
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = (32*1024),
|
|
|
|
.period_bytes_min = 256, /* 256 frames U8 mono*/
|
|
|
|
.period_bytes_max = (16*1024),
|
|
|
|
.periods_min = 2,
|
|
|
|
.periods_max = (32*1024/256),
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
|
|
|
struct mixart_mgr *mgr = chip->mgr;
|
|
|
|
struct snd_pcm_runtime *runtime = subs->runtime;
|
|
|
|
struct snd_pcm *pcm = subs->pcm;
|
|
|
|
struct mixart_stream *stream;
|
|
|
|
struct mixart_pipe *pipe;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err = 0;
|
|
|
|
int pcm_number;
|
|
|
|
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_lock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if ( pcm == chip->pcm ) {
|
|
|
|
pcm_number = MIXART_PCM_ANALOG;
|
|
|
|
runtime->hw = snd_mixart_analog_caps;
|
|
|
|
} else {
|
2008-08-08 09:12:14 -06:00
|
|
|
snd_BUG_ON(pcm != chip->pcm_dig);
|
2005-04-16 16:20:36 -06:00
|
|
|
pcm_number = MIXART_PCM_DIGITAL;
|
|
|
|
runtime->hw = snd_mixart_digital_caps;
|
|
|
|
}
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev,
|
|
|
|
"snd_mixart_playback_open C%d/P%d/Sub%d\n",
|
|
|
|
chip->chip_idx, pcm_number, subs->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* get stream info */
|
|
|
|
stream = &(chip->playback_stream[pcm_number][subs->number]);
|
|
|
|
|
|
|
|
if (stream->status != MIXART_STREAM_STATUS_FREE){
|
|
|
|
/* streams in use */
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"snd_mixart_playback_open C%d/P%d/Sub%d in use\n",
|
|
|
|
chip->chip_idx, pcm_number, subs->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
err = -EBUSY;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get pipe pointer (out pipe) */
|
|
|
|
pipe = snd_mixart_add_ref_pipe(chip, pcm_number, 0, 0);
|
|
|
|
|
|
|
|
if (pipe == NULL) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start the pipe if necessary */
|
|
|
|
err = mixart_set_pipe_state(chip->mgr, pipe, 1);
|
|
|
|
if( err < 0 ) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev, "error starting pipe!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->pipe = pipe;
|
|
|
|
stream->pcm_number = pcm_number;
|
|
|
|
stream->status = MIXART_STREAM_STATUS_OPEN;
|
|
|
|
stream->substream = subs;
|
|
|
|
stream->channels = 0; /* not configured yet */
|
|
|
|
|
|
|
|
runtime->private_data = stream;
|
|
|
|
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 64);
|
|
|
|
|
|
|
|
/* if a sample rate is already used, another stream cannot change */
|
|
|
|
if(mgr->ref_count_rate++) {
|
|
|
|
if(mgr->sample_rate) {
|
|
|
|
runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_exit_open:
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_unlock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
|
|
|
struct mixart_mgr *mgr = chip->mgr;
|
|
|
|
struct snd_pcm_runtime *runtime = subs->runtime;
|
|
|
|
struct snd_pcm *pcm = subs->pcm;
|
|
|
|
struct mixart_stream *stream;
|
|
|
|
struct mixart_pipe *pipe;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err = 0;
|
|
|
|
int pcm_number;
|
|
|
|
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_lock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if ( pcm == chip->pcm ) {
|
|
|
|
pcm_number = MIXART_PCM_ANALOG;
|
|
|
|
runtime->hw = snd_mixart_analog_caps;
|
|
|
|
} else {
|
2008-08-08 09:12:14 -06:00
|
|
|
snd_BUG_ON(pcm != chip->pcm_dig);
|
2005-04-16 16:20:36 -06:00
|
|
|
pcm_number = MIXART_PCM_DIGITAL;
|
|
|
|
runtime->hw = snd_mixart_digital_caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
runtime->hw.channels_min = 2; /* for instance, no mono */
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev, "snd_mixart_capture_open C%d/P%d/Sub%d\n",
|
|
|
|
chip->chip_idx, pcm_number, subs->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* get stream info */
|
|
|
|
stream = &(chip->capture_stream[pcm_number]);
|
|
|
|
|
|
|
|
if (stream->status != MIXART_STREAM_STATUS_FREE){
|
|
|
|
/* streams in use */
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"snd_mixart_capture_open C%d/P%d/Sub%d in use\n",
|
|
|
|
chip->chip_idx, pcm_number, subs->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
err = -EBUSY;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get pipe pointer (in pipe) */
|
|
|
|
pipe = snd_mixart_add_ref_pipe(chip, pcm_number, 1, 0);
|
|
|
|
|
|
|
|
if (pipe == NULL) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start the pipe if necessary */
|
|
|
|
err = mixart_set_pipe_state(chip->mgr, pipe, 1);
|
|
|
|
if( err < 0 ) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev, "error starting pipe!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto _exit_open;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream->pipe = pipe;
|
|
|
|
stream->pcm_number = pcm_number;
|
|
|
|
stream->status = MIXART_STREAM_STATUS_OPEN;
|
|
|
|
stream->substream = subs;
|
|
|
|
stream->channels = 0; /* not configured yet */
|
|
|
|
|
|
|
|
runtime->private_data = stream;
|
|
|
|
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 64);
|
|
|
|
|
|
|
|
/* if a sample rate is already used, another stream cannot change */
|
|
|
|
if(mgr->ref_count_rate++) {
|
|
|
|
if(mgr->sample_rate) {
|
|
|
|
runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_exit_open:
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_unlock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_close(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = snd_pcm_substream_chip(subs);
|
|
|
|
struct mixart_mgr *mgr = chip->mgr;
|
|
|
|
struct mixart_stream *stream = subs->runtime->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_lock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(chip->card->dev, "snd_mixart_close C%d/P%d/Sub%d\n",
|
|
|
|
chip->chip_idx, stream->pcm_number, subs->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* sample rate released */
|
|
|
|
if(--mgr->ref_count_rate == 0) {
|
|
|
|
mgr->sample_rate = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete pipe */
|
|
|
|
if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) {
|
|
|
|
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"error snd_mixart_kill_ref_pipe C%dP%d\n",
|
|
|
|
chip->chip_idx, stream->pcm_number);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
stream->pipe = NULL;
|
|
|
|
stream->status = MIXART_STREAM_STATUS_FREE;
|
|
|
|
stream->substream = NULL;
|
|
|
|
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_unlock(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static snd_pcm_uframes_t snd_mixart_stream_pointer(struct snd_pcm_substream *subs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_pcm_runtime *runtime = subs->runtime;
|
|
|
|
struct mixart_stream *stream = runtime->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-01 16:13:10 -06:00
|
|
|
static const struct snd_pcm_ops snd_mixart_playback_ops = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.open = snd_mixart_playback_open,
|
|
|
|
.close = snd_mixart_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
|
|
.prepare = snd_mixart_prepare,
|
|
|
|
.hw_params = snd_mixart_hw_params,
|
|
|
|
.hw_free = snd_mixart_hw_free,
|
|
|
|
.trigger = snd_mixart_trigger,
|
|
|
|
.pointer = snd_mixart_stream_pointer,
|
|
|
|
};
|
|
|
|
|
2016-09-01 16:13:10 -06:00
|
|
|
static const struct snd_pcm_ops snd_mixart_capture_ops = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.open = snd_mixart_capture_open,
|
|
|
|
.close = snd_mixart_close,
|
|
|
|
.ioctl = snd_pcm_lib_ioctl,
|
|
|
|
.prepare = snd_mixart_prepare,
|
|
|
|
.hw_params = snd_mixart_hw_params,
|
|
|
|
.hw_free = snd_mixart_hw_free,
|
|
|
|
.trigger = snd_mixart_trigger,
|
|
|
|
.pointer = snd_mixart_stream_pointer,
|
|
|
|
};
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
#if 0
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_pcm_substream *subs;
|
2005-04-16 16:20:36 -06:00
|
|
|
int stream;
|
|
|
|
|
|
|
|
for (stream = 0; stream < 2; stream++) {
|
|
|
|
int idx = 0;
|
|
|
|
for (subs = pcm->streams[stream].substream; subs; subs = subs->next, idx++)
|
|
|
|
/* set up the unique device id with the chip index */
|
|
|
|
subs->dma_device.id = subs->pcm->device << 16 |
|
|
|
|
subs->stream << 8 | (subs->number + 1) |
|
|
|
|
(chip->chip_idx + 1) << 24;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
|
|
|
|
snd_dma_pci_data(chip->mgr->pci), 32*1024, 32*1024);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_pcm_analog(struct snd_mixart *chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-16 16:20:36 -06:00
|
|
|
char name[32];
|
|
|
|
|
|
|
|
sprintf(name, "miXart analog %d", chip->chip_idx);
|
|
|
|
if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG,
|
|
|
|
MIXART_PLAYBACK_STREAMS,
|
|
|
|
MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"cannot create the analog pcm %d\n", chip->chip_idx);
|
2005-04-16 16:20:36 -06:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcm->private_data = chip;
|
|
|
|
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_mixart_playback_ops);
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_mixart_capture_ops);
|
|
|
|
|
|
|
|
pcm->info_flags = 0;
|
2014-09-10 03:48:07 -06:00
|
|
|
pcm->nonatomic = true;
|
2005-04-16 16:20:36 -06:00
|
|
|
strcpy(pcm->name, name);
|
|
|
|
|
|
|
|
preallocate_buffers(chip, pcm);
|
|
|
|
|
|
|
|
chip->pcm = pcm;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_pcm_digital(struct snd_mixart *chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-16 16:20:36 -06:00
|
|
|
char name[32];
|
|
|
|
|
|
|
|
sprintf(name, "miXart AES/EBU %d", chip->chip_idx);
|
|
|
|
if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL,
|
|
|
|
MIXART_PLAYBACK_STREAMS,
|
|
|
|
MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(chip->card->dev,
|
|
|
|
"cannot create the digital pcm %d\n", chip->chip_idx);
|
2005-04-16 16:20:36 -06:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcm->private_data = chip;
|
|
|
|
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_mixart_playback_ops);
|
|
|
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_mixart_capture_ops);
|
|
|
|
|
|
|
|
pcm->info_flags = 0;
|
2014-09-10 03:48:07 -06:00
|
|
|
pcm->nonatomic = true;
|
2005-04-16 16:20:36 -06:00
|
|
|
strcpy(pcm->name, name);
|
|
|
|
|
|
|
|
preallocate_buffers(chip, pcm);
|
|
|
|
|
|
|
|
chip->pcm_dig = pcm;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_chip_free(struct snd_mixart *chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
kfree(chip);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_chip_dev_free(struct snd_device *device)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = device->device_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
return snd_mixart_chip_free(chip);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
2012-12-06 10:35:10 -07:00
|
|
|
static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int idx)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip;
|
|
|
|
static struct snd_device_ops ops = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.dev_free = snd_mixart_chip_dev_free,
|
|
|
|
};
|
|
|
|
|
ALSA: sound/pci/mixart/mixart.c: Add missing snd_card_free
The function snd_mixart_create creates a link between mgr and card that
allows snd_mixart_free to free card as well. But if snd_mixart_create
fails, then the link has not been created and card has to be freed explicitly.
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
statement S,S1;
position p1,p2,p3;
expression E,E1;
type T,T1;
expression *ptr != NULL;
@@
(
if ((x@p1 = snd_card_new(...)) == NULL) S
|
x@p1 = snd_card_new(...);
)
... when != snd_card_free(...,(T)x,...)
when != if (...) { <+... snd_card_free(...,(T)x,...) ...+> }
when != true x == NULL || ...
when != x = E
when != E = (T)x
when any
(
if (x == NULL || ...) S1
|
if@p2 (...) {
... when != snd_card_free(...,(T1)x,...)
when != if (...) { <+... snd_card_free(...,(T1)x,...) ...+> }
when != x = E1
when != E1 = (T1)x
(
return \(0\|<+...x...+>\|ptr\);
|
return@p3 ...;
)
}
)
@ script:python @
p1 << r.p1;
p3 << r.p3;
@@
print "* file: %s snd_card_new: %s return: %s" % (p1[0].file,p1[0].line,p3[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-11-27 07:40:40 -07:00
|
|
|
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
2017-08-12 10:45:42 -06:00
|
|
|
if (!chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
chip->card = card;
|
|
|
|
chip->chip_idx = idx;
|
|
|
|
chip->mgr = mgr;
|
|
|
|
|
|
|
|
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
|
|
|
|
snd_mixart_chip_free(chip);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
ALSA: sound/pci/mixart/mixart.c: Add missing snd_card_free
The function snd_mixart_create creates a link between mgr and card that
allows snd_mixart_free to free card as well. But if snd_mixart_create
fails, then the link has not been created and card has to be freed explicitly.
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
statement S,S1;
position p1,p2,p3;
expression E,E1;
type T,T1;
expression *ptr != NULL;
@@
(
if ((x@p1 = snd_card_new(...)) == NULL) S
|
x@p1 = snd_card_new(...);
)
... when != snd_card_free(...,(T)x,...)
when != if (...) { <+... snd_card_free(...,(T)x,...) ...+> }
when != true x == NULL || ...
when != x = E
when != E = (T)x
when any
(
if (x == NULL || ...) S1
|
if@p2 (...) {
... when != snd_card_free(...,(T1)x,...)
when != if (...) { <+... snd_card_free(...,(T1)x,...) ...+> }
when != x = E1
when != E1 = (T1)x
(
return \(0\|<+...x...+>\|ptr\);
|
return@p3 ...;
)
}
)
@ script:python @
p1 << r.p1;
p3 << r.p3;
@@
print "* file: %s snd_card_new: %s return: %s" % (p1[0].file,p1[0].line,p3[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-11-27 07:40:40 -07:00
|
|
|
mgr->chip[idx] = chip;
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
int snd_mixart_create_pcm(struct snd_mixart* chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_mixart_pcm_analog(chip);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if(chip->mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
|
|
|
|
|
|
|
|
err = snd_mixart_pcm_digital(chip);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* release all the cards assigned to a manager instance
|
|
|
|
*/
|
2005-11-17 07:01:08 -07:00
|
|
|
static int snd_mixart_free(struct mixart_mgr *mgr)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < mgr->num_cards; i++) {
|
|
|
|
if (mgr->chip[i])
|
|
|
|
snd_card_free(mgr->chip[i]->card);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stop mailbox */
|
|
|
|
snd_mixart_exit_mailbox(mgr);
|
|
|
|
|
|
|
|
/* release irq */
|
|
|
|
if (mgr->irq >= 0)
|
2006-11-21 04:14:23 -07:00
|
|
|
free_irq(mgr->irq, mgr);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* reset board if some firmware was loaded */
|
|
|
|
if(mgr->dsp_loaded) {
|
|
|
|
snd_mixart_reset_board(mgr);
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_dbg(&mgr->pci->dev, "reset miXart !\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* release the i/o ports */
|
2015-01-03 14:55:54 -07:00
|
|
|
for (i = 0; i < 2; ++i)
|
|
|
|
iounmap(mgr->mem[i].virt);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
pci_release_regions(mgr->pci);
|
|
|
|
|
|
|
|
/* free flowarray */
|
|
|
|
if(mgr->flowinfo.area) {
|
|
|
|
snd_dma_free_pages(&mgr->flowinfo);
|
|
|
|
mgr->flowinfo.area = NULL;
|
|
|
|
}
|
|
|
|
/* free bufferarray */
|
|
|
|
if(mgr->bufferinfo.area) {
|
|
|
|
snd_dma_free_pages(&mgr->bufferinfo);
|
|
|
|
mgr->bufferinfo.area = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_disable_device(mgr->pci);
|
|
|
|
kfree(mgr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* proc interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
mixart_BA0 proc interface for BAR 0 - read callback
|
|
|
|
*/
|
2010-04-13 03:22:01 -06:00
|
|
|
static ssize_t snd_mixart_BA0_read(struct snd_info_entry *entry,
|
|
|
|
void *file_private_data,
|
|
|
|
struct file *file, char __user *buf,
|
|
|
|
size_t count, loff_t pos)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_mgr *mgr = entry->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2010-04-06 10:31:26 -06:00
|
|
|
count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
|
|
|
|
if (copy_to_user_fromio(buf, MIXART_MEM(mgr, pos), count))
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EFAULT;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
mixart_BA1 proc interface for BAR 1 - read callback
|
|
|
|
*/
|
2010-04-13 03:22:01 -06:00
|
|
|
static ssize_t snd_mixart_BA1_read(struct snd_info_entry *entry,
|
|
|
|
void *file_private_data,
|
|
|
|
struct file *file, char __user *buf,
|
|
|
|
size_t count, loff_t pos)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_mgr *mgr = entry->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2010-04-06 10:31:26 -06:00
|
|
|
count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
|
|
|
|
if (copy_to_user_fromio(buf, MIXART_REG(mgr, pos), count))
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EFAULT;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_info_entry_ops snd_mixart_proc_ops_BA0 = {
|
|
|
|
.read = snd_mixart_BA0_read,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = {
|
|
|
|
.read = snd_mixart_BA1_read,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-17 07:01:08 -07:00
|
|
|
static void snd_mixart_proc_read(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_mixart *chip = entry->private_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
u32 ref;
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "Digigram miXart (alsa card %d)\n\n", chip->chip_idx);
|
|
|
|
|
|
|
|
/* stats available when embedded OS is running */
|
|
|
|
if (chip->mgr->dsp_loaded & ( 1 << MIXART_MOTHERBOARD_ELF_INDEX)) {
|
|
|
|
snd_iprintf(buffer, "- hardware -\n");
|
|
|
|
switch (chip->mgr->board_type ) {
|
|
|
|
case MIXART_DAUGHTER_TYPE_NONE : snd_iprintf(buffer, "\tmiXart8 (no daughter board)\n\n"); break;
|
|
|
|
case MIXART_DAUGHTER_TYPE_AES : snd_iprintf(buffer, "\tmiXart8 AES/EBU\n\n"); break;
|
|
|
|
case MIXART_DAUGHTER_TYPE_COBRANET : snd_iprintf(buffer, "\tmiXart8 Cobranet\n\n"); break;
|
|
|
|
default: snd_iprintf(buffer, "\tUNKNOWN!\n\n"); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "- system load -\n");
|
|
|
|
|
|
|
|
/* get perf reference */
|
|
|
|
|
|
|
|
ref = readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_SYSTEM_LOAD_OFFSET));
|
|
|
|
|
|
|
|
if (ref) {
|
|
|
|
u32 mailbox = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_MAILBX_LOAD_OFFSET)) / ref;
|
|
|
|
u32 streaming = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_STREAM_LOAD_OFFSET)) / ref;
|
|
|
|
u32 interr = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_INTERR_LOAD_OFFSET)) / ref;
|
|
|
|
|
|
|
|
snd_iprintf(buffer, "\tstreaming : %d\n", streaming);
|
|
|
|
snd_iprintf(buffer, "\tmailbox : %d\n", mailbox);
|
2013-03-16 05:53:05 -06:00
|
|
|
snd_iprintf(buffer, "\tinterrupts handling : %d\n\n", interr);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
} /* endif elf loaded */
|
|
|
|
}
|
|
|
|
|
2012-12-06 10:35:10 -07:00
|
|
|
static void snd_mixart_proc_init(struct snd_mixart *chip)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_info_entry *entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* text interface to read perf and temp meters */
|
|
|
|
if (! snd_card_proc_new(chip->card, "board_info", &entry)) {
|
|
|
|
entry->private_data = chip;
|
|
|
|
entry->c.text.read = snd_mixart_proc_read;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) {
|
|
|
|
entry->content = SNDRV_INFO_CONTENT_DATA;
|
|
|
|
entry->private_data = chip->mgr;
|
|
|
|
entry->c.ops = &snd_mixart_proc_ops_BA0;
|
|
|
|
entry->size = MIXART_BA0_SIZE;
|
|
|
|
}
|
|
|
|
if (! snd_card_proc_new(chip->card, "mixart_BA1", &entry)) {
|
|
|
|
entry->content = SNDRV_INFO_CONTENT_DATA;
|
|
|
|
entry->private_data = chip->mgr;
|
|
|
|
entry->c.ops = &snd_mixart_proc_ops_BA1;
|
|
|
|
entry->size = MIXART_BA1_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* end of proc interface */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* probe function - creates the card manager
|
|
|
|
*/
|
2012-12-06 10:35:10 -07:00
|
|
|
static int snd_mixart_probe(struct pci_dev *pci,
|
|
|
|
const struct pci_device_id *pci_id)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
static int dev;
|
2005-11-17 07:01:08 -07:00
|
|
|
struct mixart_mgr *mgr;
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned int i;
|
|
|
|
int err;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
if (dev >= SNDRV_CARDS)
|
|
|
|
return -ENODEV;
|
|
|
|
if (! enable[dev]) {
|
|
|
|
dev++;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable PCI device */
|
|
|
|
if ((err = pci_enable_device(pci)) < 0)
|
|
|
|
return err;
|
|
|
|
pci_set_master(pci);
|
|
|
|
|
|
|
|
/* check if we can restrict PCI DMA transfers to 32 bits */
|
ALSA: remove deprecated use of pci api
Replace occurences of the pci api by appropriate call to the dma api.
A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr)
@deprecated@
idexpression id;
position p;
@@
(
pci_dma_supported@p ( id, ...)
|
pci_alloc_consistent@p ( id, ...)
)
@bad1@
idexpression id;
position deprecated.p;
@@
...when != &id->dev
when != pci_get_drvdata ( id )
when != pci_enable_device ( id )
(
pci_dma_supported@p ( id, ...)
|
pci_alloc_consistent@p ( id, ...)
)
@depends on !bad1@
idexpression id;
expression direction;
position deprecated.p;
@@
(
- pci_dma_supported@p ( id,
+ dma_supported ( &id->dev,
...
+ , GFP_ATOMIC
)
|
- pci_alloc_consistent@p ( id,
+ dma_alloc_coherent ( &id->dev,
...
+ , GFP_ATOMIC
)
)
Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-15 08:10:17 -06:00
|
|
|
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&pci->dev,
|
|
|
|
"architecture does not support 32bit PCI busmaster DMA\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
pci_disable_device(pci);
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
[ALSA] Replace with kzalloc() - pci stuff
AD1889 driver,ATIIXP driver,ATIIXP-modem driver,AZT3328 driver
BT87x driver,CMIPCI driver,CS4281 driver,ENS1370/1+ driver
ES1938 driver,ES1968 driver,FM801 driver,Intel8x0 driver
Intel8x0-modem driver,Maestro3 driver,SonicVibes driver,VIA82xx driver
VIA82xx-modem driver,AC97 Codec,AK4531 codec,au88x0 driver
CA0106 driver,CS46xx driver,EMU10K1/EMU10K2 driver,HDA Codec driver
HDA generic driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,Trident driver,YMFPCI driver
Replace kcalloc(1,..) with kzalloc().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-09 06:21:46 -06:00
|
|
|
mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (! mgr) {
|
|
|
|
pci_disable_device(pci);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr->pci = pci;
|
|
|
|
mgr->irq = -1;
|
|
|
|
|
|
|
|
/* resource assignment */
|
|
|
|
if ((err = pci_request_regions(pci, CARD_NAME)) < 0) {
|
|
|
|
kfree(mgr);
|
|
|
|
pci_disable_device(pci);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
mgr->mem[i].phys = pci_resource_start(pci, i);
|
2008-09-28 17:20:09 -06:00
|
|
|
mgr->mem[i].virt = pci_ioremap_bar(pci, i);
|
2007-08-13 08:16:53 -06:00
|
|
|
if (!mgr->mem[i].virt) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&pci->dev, "unable to remap resource 0x%lx\n",
|
2007-08-13 08:16:53 -06:00
|
|
|
mgr->mem[i].phys);
|
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2014-09-10 03:48:07 -06:00
|
|
|
if (request_threaded_irq(pci->irq, snd_mixart_interrupt,
|
|
|
|
snd_mixart_threaded_irq, IRQF_SHARED,
|
|
|
|
KBUILD_MODNAME, mgr)) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
mgr->irq = pci->irq;
|
|
|
|
|
|
|
|
/* init mailbox */
|
|
|
|
mgr->msg_fifo_readptr = 0;
|
|
|
|
mgr->msg_fifo_writeptr = 0;
|
|
|
|
|
2014-09-10 03:48:07 -06:00
|
|
|
mutex_init(&mgr->lock);
|
|
|
|
mutex_init(&mgr->msg_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
init_waitqueue_head(&mgr->msg_sleep);
|
|
|
|
atomic_set(&mgr->msg_processed, 0);
|
|
|
|
|
|
|
|
/* init setup mutex*/
|
2006-01-16 08:34:20 -07:00
|
|
|
mutex_init(&mgr->setup_mutex);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* card assignment */
|
|
|
|
mgr->num_cards = MIXART_MAX_CARDS; /* 4 FIXME: configurable? */
|
|
|
|
for (i = 0; i < mgr->num_cards; i++) {
|
2005-11-17 07:01:08 -07:00
|
|
|
struct snd_card *card;
|
2005-04-16 16:20:36 -06:00
|
|
|
char tmpid[16];
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (index[dev] < 0)
|
|
|
|
idx = index[dev];
|
|
|
|
else
|
|
|
|
idx = index[dev] + i;
|
|
|
|
snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
|
2014-01-29 06:20:19 -07:00
|
|
|
err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
|
|
|
|
0, &card);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-12-28 08:44:30 -07:00
|
|
|
if (err < 0) {
|
2014-02-25 09:51:46 -07:00
|
|
|
dev_err(&pci->dev, "cannot allocate the card %d\n", i);
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_mixart_free(mgr);
|
2008-12-28 08:44:30 -07:00
|
|
|
return err;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(card->driver, CARD_NAME);
|
ALSA: mixart: fix string overflow warning
Using a temporary string produces warnings about a possible overflow
in sprintf:
sound/pci/mixart/mixart.c: In function 'snd_mixart_probe':
sound/pci/mixart/mixart.c:1353:28: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 32 [-Werror=format-overflow=]
sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i);
^~~~~~~~~~~~~~
sound/pci/mixart/mixart.c:1353:28: note: using the range [-2147483648, 2147483647] for directive argument
sound/pci/mixart/mixart.c:1353:3: note: 'sprintf' output between 10 and 51 bytes into a destination of size 32
sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/mixart/mixart.c:1354:27: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 80 [-Werror=format-overflow=]
sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
^~~~~~~~~~~~~~
sound/pci/mixart/mixart.c:1354:27: note: using the range [-2147483648, 2147483647] for directive argument
sound/pci/mixart/mixart.c:1354:3: note: 'sprintf' output between 10 and 99 bytes into a destination of size 80
Skipping the intermediate, we can get gcc to see that it is in fact
safe here.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-18 05:48:08 -06:00
|
|
|
snprintf(card->shortname, sizeof(card->shortname),
|
|
|
|
"Digigram miXart [PCM #%d]", i);
|
|
|
|
snprintf(card->longname, sizeof(card->longname),
|
|
|
|
"Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]",
|
|
|
|
mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if ((err = snd_mixart_create(mgr, card, i)) < 0) {
|
ALSA: sound/pci/mixart/mixart.c: Add missing snd_card_free
The function snd_mixart_create creates a link between mgr and card that
allows snd_mixart_free to free card as well. But if snd_mixart_create
fails, then the link has not been created and card has to be freed explicitly.
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
statement S,S1;
position p1,p2,p3;
expression E,E1;
type T,T1;
expression *ptr != NULL;
@@
(
if ((x@p1 = snd_card_new(...)) == NULL) S
|
x@p1 = snd_card_new(...);
)
... when != snd_card_free(...,(T)x,...)
when != if (...) { <+... snd_card_free(...,(T)x,...) ...+> }
when != true x == NULL || ...
when != x = E
when != E = (T)x
when any
(
if (x == NULL || ...) S1
|
if@p2 (...) {
... when != snd_card_free(...,(T1)x,...)
when != if (...) { <+... snd_card_free(...,(T1)x,...) ...+> }
when != x = E1
when != E1 = (T1)x
(
return \(0\|<+...x...+>\|ptr\);
|
return@p3 ...;
)
}
)
@ script:python @
p1 << r.p1;
p3 << r.p3;
@@
print "* file: %s snd_card_new: %s return: %s" % (p1[0].file,p1[0].line,p3[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-11-27 07:40:40 -07:00
|
|
|
snd_card_free(card);
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i==0) {
|
|
|
|
/* init proc interface only for chip0 */
|
|
|
|
snd_mixart_proc_init(mgr->chip[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err = snd_card_register(card)) < 0) {
|
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init firmware status (mgr->dsp_loaded reset in hwdep_new) */
|
|
|
|
mgr->board_type = MIXART_DAUGHTER_TYPE_NONE;
|
|
|
|
|
|
|
|
/* create array of streaminfo */
|
2005-11-17 07:01:08 -07:00
|
|
|
size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
|
|
|
|
sizeof(struct mixart_flowinfo)) );
|
2005-04-16 16:20:36 -06:00
|
|
|
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
|
|
|
|
size, &mgr->flowinfo) < 0) {
|
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
/* init streaminfo_array */
|
|
|
|
memset(mgr->flowinfo.area, 0, size);
|
|
|
|
|
|
|
|
/* create array of bufferinfo */
|
2005-11-17 07:01:08 -07:00
|
|
|
size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
|
|
|
|
sizeof(struct mixart_bufferinfo)) );
|
2005-04-16 16:20:36 -06:00
|
|
|
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
|
|
|
|
size, &mgr->bufferinfo) < 0) {
|
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
/* init bufferinfo_array */
|
|
|
|
memset(mgr->bufferinfo.area, 0, size);
|
|
|
|
|
|
|
|
/* set up firmware */
|
|
|
|
err = snd_mixart_setup_firmware(mgr);
|
|
|
|
if (err < 0) {
|
|
|
|
snd_mixart_free(mgr);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_set_drvdata(pci, mgr);
|
|
|
|
dev++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-06 10:35:10 -07:00
|
|
|
static void snd_mixart_remove(struct pci_dev *pci)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
snd_mixart_free(pci_get_drvdata(pci));
|
|
|
|
}
|
|
|
|
|
2012-04-24 04:25:00 -06:00
|
|
|
static struct pci_driver mixart_driver = {
|
2011-06-10 08:20:20 -06:00
|
|
|
.name = KBUILD_MODNAME,
|
2005-04-16 16:20:36 -06:00
|
|
|
.id_table = snd_mixart_ids,
|
|
|
|
.probe = snd_mixart_probe,
|
2012-12-06 10:35:10 -07:00
|
|
|
.remove = snd_mixart_remove,
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2012-04-24 04:25:00 -06:00
|
|
|
module_pci_driver(mixart_driver);
|