MODULE_AUTHOR("Digigram <alsa@digigram.com>");
MODULE_DESCRIPTION("Digigram " CARD_NAME);
MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{Digigram," CARD_NAME "}}");
+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 */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
-static int boot_devs;
-#define chip_t mixart_t
-
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
/*
*/
MODULE_DEVICE_TABLE(pci, snd_mixart_ids);
-static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int start)
+static int mixart_set_pipe_state(struct mixart_mgr *mgr,
+ struct mixart_pipe *pipe, int start)
{
- mixart_group_state_req_t group_state;
- mixart_group_state_resp_t group_state_resp;
- mixart_msg_t request;
+ struct mixart_group_state_req group_state;
+ struct mixart_group_state_resp group_state_resp;
+ struct mixart_msg request;
int err;
u32 system_msg_uid;
/* wait on the last MSG_SYSTEM_SEND_SYNCHRO_CMD command to be really finished */
request.message_id = MSG_SYSTEM_WAIT_SYNCHRO_CMD;
- request.uid = (mixart_uid_t){0,0};
+ request.uid = (struct mixart_uid){0,0};
request.data = &system_msg_uid;
request.size = sizeof(system_msg_uid);
else
request.message_id = MSG_STREAM_STOP_STREAM_GRP_PACKET;
- request.uid = pipe->group_uid; /*(mixart_uid_t){0,0};*/
+ request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/
request.data = &group_state;
request.size = sizeof(group_state);
/* in case of start send a synchro top */
request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD;
- request.uid = (mixart_uid_t){0,0};
+ request.uid = (struct mixart_uid){0,0};
request.data = NULL;
request.size = 0;
}
-static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int rate)
+static int mixart_set_clock(struct mixart_mgr *mgr,
+ struct mixart_pipe *pipe, unsigned int rate)
{
- mixart_msg_t request;
- mixart_clock_properties_t clock_properties;
- mixart_clock_properties_resp_t clock_prop_resp;
+ struct mixart_msg request;
+ struct mixart_clock_properties clock_properties;
+ struct mixart_clock_properties_resp clock_prop_resp;
int err;
switch(pipe->status) {
/*
* Allocate or reference output pipe for analog IOs (pcmp0/1)
*/
-mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring)
+struct mixart_pipe *
+snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
+ int monitoring)
{
int stream_count;
- mixart_pipe_t *pipe;
- mixart_msg_t request;
+ struct mixart_pipe *pipe;
+ struct mixart_msg request;
if(capture) {
if (pcm_number == MIXART_PCM_ANALOG) {
/* pipe is not yet defined */
if( pipe->status == PIPE_UNDEFINED ) {
int err, i;
- mixart_streaming_group_t streaming_group_resp;
- mixart_streaming_group_req_t streaming_group_req;
+ struct {
+ struct mixart_streaming_group_req sgroup_req;
+ struct mixart_streaming_group sgroup_resp;
+ } *buf;
snd_printdd("add_ref_pipe audio chip(%d) pcm(%d)\n", chip->chip_idx, pcm_number);
- request.uid = (mixart_uid_t){0,0}; /* should be StreamManagerUID, but zero is OK if there is only one ! */
- request.data = &streaming_group_req;
- request.size = sizeof(streaming_group_req);
+ buf = kmalloc(sizeof(*buf), GFP_KERNEL);
+ if (!buf)
+ return NULL;
+
+ request.uid = (struct mixart_uid){0,0}; /* should be StreamManagerUID, but zero is OK if there is only one ! */
+ request.data = &buf->sgroup_req;
+ request.size = sizeof(buf->sgroup_req);
- memset(&streaming_group_req, 0, sizeof(streaming_group_req));
+ memset(&buf->sgroup_req, 0, sizeof(buf->sgroup_req));
- streaming_group_req.stream_count = stream_count;
- streaming_group_req.channel_count = 2;
- streaming_group_req.latency = 256;
- streaming_group_req.connector = pipe->uid_left_connector; /* the left connector */
+ 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_bufferinfo *bufferinfo;
/* we don't yet know the format, so config 16 bit pcm audio for instance */
- streaming_group_req.stream_info[i].size_max_byte_frame = 1024;
- streaming_group_req.stream_info[i].size_max_sample_frame = 256;
- streaming_group_req.stream_info[i].nb_bytes_max_per_sample = MIXART_FLOAT_P__4_0_TO_HEX; /* is 4.0f */
+ 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 */
- streaming_group_req.flow_entry[i] = j;
+ buf->sgroup_req.flow_entry[i] = j;
flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area;
- flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(mixart_bufferinfo_t));
+ flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mixart_bufferinfo));
flowinfo[j].bufferinfo_count = 1; /* 1 will set the miXart to ring-buffer mode ! */
bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area;
}
}
- err = snd_mixart_send_msg(chip->mgr, &request, sizeof(streaming_group_resp), &streaming_group_resp);
- if((err < 0) || (streaming_group_resp.status != 0)) {
- snd_printk(KERN_ERR "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n", err, streaming_group_resp.status);
+ err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp);
+ if((err < 0) || (buf->sgroup_resp.status != 0)) {
+ snd_printk(KERN_ERR "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n", err, buf->sgroup_resp.status);
+ kfree(buf);
return NULL;
}
- pipe->group_uid = streaming_group_resp.group; /* id of the pipe, as returned by embedded */
- pipe->stream_count = streaming_group_resp.stream_count;
- /* pipe->stream_uid[i] = streaming_group_resp.stream[i].stream_uid; */
+ 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;
}
-int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring)
+int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
+ struct mixart_pipe *pipe, int monitoring)
{
int err = 0;
if((pipe->references <= 0) && (pipe->monitoring == 0)) {
- mixart_msg_t request;
- mixart_delete_group_resp_t delete_resp;
+ struct mixart_msg request;
+ struct mixart_delete_group_resp delete_resp;
/* release the clock */
err = mixart_set_clock( mgr, pipe, 0);
}
request.message_id = MSG_STREAM_DELETE_GROUP;
- request.uid = (mixart_uid_t){0,0};
+ request.uid = (struct mixart_uid){0,0};
request.data = &pipe->group_uid; /* the streaming group ! */
request.size = sizeof(pipe->group_uid);
snd_printk(KERN_ERR "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n", err, delete_resp.status);
}
- pipe->group_uid = (mixart_uid_t){0,0};
+ pipe->group_uid = (struct mixart_uid){0,0};
pipe->stream_count = 0;
pipe->status = PIPE_UNDEFINED;
}
return err;
}
-static int mixart_set_stream_state(mixart_stream_t *stream, int start)
+static int mixart_set_stream_state(struct mixart_stream *stream, int start)
{
- mixart_t *chip;
- mixart_stream_state_req_t stream_state_req;
- mixart_msg_t request;
+ struct snd_mixart *chip;
+ struct mixart_stream_state_req stream_state_req;
+ struct mixart_msg request;
if(!stream->substream)
return -EINVAL;
else
request.message_id = start ? MSG_STREAM_START_OUTPUT_STAGE_PACKET : MSG_STREAM_STOP_OUTPUT_STAGE_PACKET;
- request.uid = (mixart_uid_t){0,0};
+ request.uid = (struct mixart_uid){0,0};
request.data = &stream_state_req;
request.size = sizeof(stream_state_req);
* Trigger callback
*/
-static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd)
+static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
{
- mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+ struct mixart_stream *stream = subs->runtime->private_data;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
return 0;
}
-static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
+static int mixart_sync_nonblock_events(struct mixart_mgr *mgr)
{
- int timeout = HZ;
+ unsigned long timeout = jiffies + HZ;
while (atomic_read(&mgr->msg_processed) > 0) {
- if (! timeout--) {
+ if (time_after(jiffies, timeout)) {
snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
return -EBUSY;
}
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
+ schedule_timeout_uninterruptible(1);
}
return 0;
}
/*
* prepare callback for all pcms
- *
- * NOTE: this callback is non-atomic (pcm->info_flags |= SNDRV_PCM_INFO_NONATOMIC_OPS)
*/
-static int snd_mixart_prepare(snd_pcm_substream_t *subs)
+static int snd_mixart_prepare(struct snd_pcm_substream *subs)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
- mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+ struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+ struct mixart_stream *stream = subs->runtime->private_data;
/* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
}
-static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format)
+static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t format)
{
int err;
- mixart_t *chip;
- mixart_msg_t request;
- mixart_stream_param_desc_t stream_param;
- mixart_return_uid_t resp;
+ struct snd_mixart *chip;
+ struct mixart_msg request;
+ struct mixart_stream_param_desc stream_param;
+ struct mixart_return_uid resp;
chip = snd_pcm_substream_chip(stream->substream);
stream_param.sample_type = ST_INTEGER_24BE;
stream_param.sample_size = 24;
break;
- case SNDRV_PCM_FMTBIT_FLOAT_LE:
+ case SNDRV_PCM_FORMAT_FLOAT_LE:
stream_param.sample_type = ST_FLOATING_POINT_32LE;
stream_param.sample_size = 32;
break;
- case SNDRV_PCM_FMTBIT_FLOAT_BE:
+ case SNDRV_PCM_FORMAT_FLOAT_BE:
stream_param.sample_type = ST_FLOATING_POINT_32BE;
stream_param.sample_size = 32;
break;
stream_param.stream_desc[0].stream_idx = stream->substream->number;
request.message_id = MSG_STREAM_SET_INPUT_STAGE_PARAM;
- request.uid = (mixart_uid_t){0,0};
+ request.uid = (struct mixart_uid){0,0};
request.data = &stream_param;
request.size = sizeof(stream_param);
/*
* HW_PARAMS callback for all pcms
*/
-static int snd_mixart_hw_params(snd_pcm_substream_t *subs,
- snd_pcm_hw_params_t *hw)
+static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
+ struct snd_pcm_hw_params *hw)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
- mixart_mgr_t *mgr = chip->mgr;
- mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+ struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+ struct mixart_mgr *mgr = chip->mgr;
+ struct mixart_stream *stream = subs->runtime->private_data;
snd_pcm_format_t format;
int err;
int channels;
bufferinfo[i].available_length = subs->runtime->dma_bytes;
/* bufferinfo[i].buffer_id is already defined */
- snd_printdd("snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", i, subs->runtime->dma_addr, subs->runtime->dma_bytes, subs->number);
+ snd_printdd("snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", i,
+ bufferinfo[i].buffer_address,
+ bufferinfo[i].available_length,
+ subs->number);
}
up(&mgr->setup_mutex);
return err;
}
-static int snd_mixart_hw_free(snd_pcm_substream_t *subs)
+static int snd_mixart_hw_free(struct snd_pcm_substream *subs)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
+ struct snd_mixart *chip = snd_pcm_substream_chip(subs);
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
*/
-static snd_pcm_hardware_t snd_mixart_analog_caps =
+static struct snd_pcm_hardware snd_mixart_analog_caps =
{
.info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START |
.periods_max = (32*1024/256),
};
-static snd_pcm_hardware_t snd_mixart_digital_caps =
+static struct snd_pcm_hardware snd_mixart_digital_caps =
{
.info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START |
};
-static int snd_mixart_playback_open(snd_pcm_substream_t *subs)
+static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
- mixart_mgr_t *mgr = chip->mgr;
- snd_pcm_runtime_t *runtime = subs->runtime;
- snd_pcm_t *pcm = subs->pcm;
- mixart_stream_t *stream;
- mixart_pipe_t *pipe;
+ 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;
int err = 0;
int pcm_number;
}
-static int snd_mixart_capture_open(snd_pcm_substream_t *subs)
+static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
- mixart_mgr_t *mgr = chip->mgr;
- snd_pcm_runtime_t *runtime = subs->runtime;
- snd_pcm_t *pcm = subs->pcm;
- mixart_stream_t *stream;
- mixart_pipe_t *pipe;
+ 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;
int err = 0;
int pcm_number;
-static int snd_mixart_close(snd_pcm_substream_t *subs)
+static int snd_mixart_close(struct snd_pcm_substream *subs)
{
- mixart_t *chip = snd_pcm_substream_chip(subs);
- mixart_mgr_t *mgr = chip->mgr;
- mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+ struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+ struct mixart_mgr *mgr = chip->mgr;
+ struct mixart_stream *stream = subs->runtime->private_data;
down(&mgr->setup_mutex);
}
-static snd_pcm_uframes_t snd_mixart_stream_pointer(snd_pcm_substream_t * subs)
+static snd_pcm_uframes_t snd_mixart_stream_pointer(struct snd_pcm_substream *subs)
{
- snd_pcm_runtime_t *runtime = subs->runtime;
- mixart_stream_t *stream = (mixart_stream_t*)runtime->private_data;
+ struct snd_pcm_runtime *runtime = subs->runtime;
+ struct mixart_stream *stream = runtime->private_data;
return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag);
}
-static snd_pcm_ops_t snd_mixart_playback_ops = {
+static struct snd_pcm_ops snd_mixart_playback_ops = {
.open = snd_mixart_playback_open,
.close = snd_mixart_close,
.ioctl = snd_pcm_lib_ioctl,
.pointer = snd_mixart_stream_pointer,
};
-static snd_pcm_ops_t snd_mixart_capture_ops = {
+static struct snd_pcm_ops snd_mixart_capture_ops = {
.open = snd_mixart_capture_open,
.close = snd_mixart_close,
.ioctl = snd_pcm_lib_ioctl,
.pointer = snd_mixart_stream_pointer,
};
-static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm)
+static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm)
{
- snd_pcm_substream_t *subs;
+#if 0
+ struct snd_pcm_substream *subs;
int stream;
for (stream = 0; stream < 2; stream++) {
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);
}
/*
*/
-static int snd_mixart_pcm_analog(mixart_t *chip)
+static int snd_mixart_pcm_analog(struct snd_mixart *chip)
{
int err;
- snd_pcm_t *pcm;
+ struct snd_pcm *pcm;
char name[32];
sprintf(name, "miXart analog %d", chip->chip_idx);
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 = SNDRV_PCM_INFO_NONATOMIC_OPS;
+ pcm->info_flags = 0;
strcpy(pcm->name, name);
preallocate_buffers(chip, pcm);
/*
*/
-static int snd_mixart_pcm_digital(mixart_t *chip)
+static int snd_mixart_pcm_digital(struct snd_mixart *chip)
{
int err;
- snd_pcm_t *pcm;
+ struct snd_pcm *pcm;
char name[32];
sprintf(name, "miXart AES/EBU %d", chip->chip_idx);
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 = SNDRV_PCM_INFO_NONATOMIC_OPS;
+ pcm->info_flags = 0;
strcpy(pcm->name, name);
preallocate_buffers(chip, pcm);
return 0;
}
-static int snd_mixart_chip_free(mixart_t *chip)
+static int snd_mixart_chip_free(struct snd_mixart *chip)
{
- snd_magic_kfree(chip);
+ kfree(chip);
return 0;
}
-static int snd_mixart_chip_dev_free(snd_device_t *device)
+static int snd_mixart_chip_dev_free(struct snd_device *device)
{
- mixart_t *chip = snd_magic_cast(mixart_t, device->device_data, return -ENXIO);
+ struct snd_mixart *chip = device->device_data;
return snd_mixart_chip_free(chip);
}
/*
*/
-static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int idx)
+static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int idx)
{
int err;
- mixart_t *chip;
- static snd_device_ops_t ops = {
+ struct snd_mixart *chip;
+ static struct snd_device_ops ops = {
.dev_free = snd_mixart_chip_dev_free,
};
- mgr->chip[idx] = chip = snd_magic_kcalloc(mixart_t, 0, GFP_KERNEL);
+ mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (! chip) {
snd_printk(KERN_ERR "cannot allocate chip\n");
return -ENOMEM;
return err;
}
- if (idx == 0) {
- /* create a DSP loader only on first cardX*/
- err = snd_mixart_hwdep_new(mgr);
- if (err < 0)
- return err;
- }
-
snd_card_set_dev(card, &mgr->pci->dev);
return 0;
}
-int snd_mixart_create_pcm(mixart_t* chip)
+int snd_mixart_create_pcm(struct snd_mixart* chip)
{
int err;
/*
* release all the cards assigned to a manager instance
*/
-static int snd_mixart_free(mixart_mgr_t *mgr)
+static int snd_mixart_free(struct mixart_mgr *mgr)
{
unsigned int i;
free_irq(mgr->irq, (void *)mgr);
/* reset board if some firmware was loaded */
- if(mgr->hwdep->dsp_loaded) {
+ if(mgr->dsp_loaded) {
snd_mixart_reset_board(mgr);
snd_printdd("reset miXart !\n");
}
/* release the i/o ports */
for (i = 0; i < 2; i++) {
if (mgr->mem[i].virt)
- iounmap((void *)mgr->mem[i].virt);
- if (mgr->mem[i].res) {
- release_resource(mgr->mem[i].res);
- kfree_nocheck(mgr->mem[i].res);
- }
+ iounmap(mgr->mem[i].virt);
}
+ pci_release_regions(mgr->pci);
/* free flowarray */
if(mgr->flowinfo.area) {
- snd_dma_free_pages(&mgr->dma_dev, &mgr->flowinfo);
+ snd_dma_free_pages(&mgr->flowinfo);
mgr->flowinfo.area = NULL;
}
/* free bufferarray */
if(mgr->bufferinfo.area) {
- snd_dma_free_pages(&mgr->dma_dev, &mgr->bufferinfo);
+ snd_dma_free_pages(&mgr->bufferinfo);
mgr->bufferinfo.area = NULL;
}
- snd_magic_kfree(mgr);
+ pci_disable_device(mgr->pci);
+ kfree(mgr);
return 0;
}
/*
* proc interface
*/
-static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry,
+static long long snd_mixart_BA0_llseek(struct snd_info_entry *entry,
void *private_file_data,
struct file *file,
long long offset,
return file->f_pos;
}
-static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry,
+static long long snd_mixart_BA1_llseek(struct snd_info_entry *entry,
void *private_file_data,
struct file *file,
long long offset,
/*
mixart_BA0 proc interface for BAR 0 - read callback
*/
-static long snd_mixart_BA0_read(snd_info_entry_t *entry, void *file_private_data,
- struct file *file, char __user *buf, long count)
+static long snd_mixart_BA0_read(struct snd_info_entry *entry, void *file_private_data,
+ struct file *file, char __user *buf,
+ unsigned long count, unsigned long pos)
{
- mixart_mgr_t *mgr = snd_magic_cast(mixart_mgr_t, entry->private_data, return -ENXIO);
+ struct mixart_mgr *mgr = entry->private_data;
count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
if(count <= 0)
return 0;
- if(file->f_pos + count > MIXART_BA0_SIZE)
- count = (long)(MIXART_BA0_SIZE - file->f_pos);
- if(copy_to_user_fromio(buf, MIXART_MEM( mgr, file->f_pos ), count))
+ if(pos + count > MIXART_BA0_SIZE)
+ count = (long)(MIXART_BA0_SIZE - pos);
+ if(copy_to_user_fromio(buf, MIXART_MEM( mgr, pos ), count))
return -EFAULT;
- file->f_pos += count;
return count;
}
/*
mixart_BA1 proc interface for BAR 1 - read callback
*/
-static long snd_mixart_BA1_read(snd_info_entry_t *entry, void *file_private_data,
- struct file *file, char __user *buf, long count)
+static long snd_mixart_BA1_read(struct snd_info_entry *entry, void *file_private_data,
+ struct file *file, char __user *buf,
+ unsigned long count, unsigned long pos)
{
- mixart_mgr_t *mgr = snd_magic_cast(mixart_mgr_t, entry->private_data, return -ENXIO);
+ struct mixart_mgr *mgr = entry->private_data;
count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
if(count <= 0)
return 0;
- if(file->f_pos + count > MIXART_BA1_SIZE)
- count = (long)(MIXART_BA1_SIZE - file->f_pos);
- if(copy_to_user_fromio(buf, MIXART_REG( mgr, file->f_pos ), count))
+ if(pos + count > MIXART_BA1_SIZE)
+ count = (long)(MIXART_BA1_SIZE - pos);
+ if(copy_to_user_fromio(buf, MIXART_REG( mgr, pos ), count))
return -EFAULT;
- file->f_pos += count;
return count;
}
};
-static void snd_mixart_proc_read(snd_info_entry_t *entry,
- snd_info_buffer_t * buffer)
+static void snd_mixart_proc_read(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
- mixart_t *chip = snd_magic_cast(mixart_t, entry->private_data, return);
+ struct snd_mixart *chip = entry->private_data;
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->hwdep->dsp_loaded & ( 1 << MIXART_MOTHERBOARD_ELF_INDEX)) {
+ 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;
} /* endif elf loaded */
}
-static void __devinit snd_mixart_proc_init(mixart_t *chip)
+static void __devinit snd_mixart_proc_init(struct snd_mixart *chip)
{
- snd_info_entry_t *entry;
+ struct snd_info_entry *entry;
/* text interface to read perf and temp meters */
if (! snd_card_proc_new(chip->card, "board_info", &entry)) {
const struct pci_device_id *pci_id)
{
static int dev;
- mixart_mgr_t *mgr;
+ struct mixart_mgr *mgr;
unsigned int i;
int err;
size_t size;
pci_set_master(pci);
/* check if we can restrict PCI DMA transfers to 32 bits */
- if (!pci_dma_supported(pci, 0xffffffff)) {
+ if (pci_set_dma_mask(pci, 0xffffffff) < 0) {
snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
+ pci_disable_device(pci);
return -ENXIO;
}
- pci_set_dma_mask(pci, 0xffffffff);
/*
*/
- mgr = snd_magic_kcalloc(mixart_mgr_t, 0, GFP_KERNEL);
- if (! mgr)
+ mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
+ 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++) {
- static int memory_sizes[2] = {
- MIXART_BA0_SIZE, /* 16M */
- MIXART_BA1_SIZE /* 4 k */
- };
mgr->mem[i].phys = pci_resource_start(pci, i);
- mgr->mem[i].res = request_mem_region(mgr->mem[i].phys, memory_sizes[i], CARD_NAME);
- if (! mgr->mem[i].res) {
- snd_printk(KERN_ERR "unable to grab memory 0x%lx\n", mgr->mem[i].phys);
- snd_mixart_free(mgr);
- return -EBUSY;
- }
- mgr->mem[i].virt = (unsigned long)ioremap_nocache(mgr->mem[i].phys, memory_sizes[i]);
+ mgr->mem[i].virt = ioremap_nocache(mgr->mem[i].phys,
+ pci_resource_len(pci, i));
}
if (request_irq(pci->irq, snd_mixart_interrupt, SA_INTERRUPT|SA_SHIRQ, CARD_NAME, (void *)mgr)) {
sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, irq %i", mgr->shortname, mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq);
/* ISR spinlock */
- mgr->lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&mgr->lock);
/* init mailbox */
mgr->msg_fifo_readptr = 0;
mgr->msg_fifo_writeptr = 0;
- mgr->msg_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&mgr->msg_lock);
init_MUTEX(&mgr->msg_mutex);
init_waitqueue_head(&mgr->msg_sleep);
atomic_set(&mgr->msg_processed, 0);
init_MUTEX(&mgr->setup_mutex);
/* init message taslket */
- tasklet_init( &mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr);
+ tasklet_init(&mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr);
/* card assignment */
mgr->num_cards = MIXART_MAX_CARDS; /* 4 FIXME: configurable? */
for (i = 0; i < mgr->num_cards; i++) {
- snd_card_t *card;
+ struct snd_card *card;
char tmpid[16];
int idx;
idx = index[dev];
else
idx = index[dev] + i;
- snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev], i);
+ snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
card = snd_card_new(idx, tmpid, THIS_MODULE, 0);
if (! card) {
}
}
- /* init firmware status (mgr->hwdep->dsp_loaded reset in hwdep_new) */
+ /* init firmware status (mgr->dsp_loaded reset in hwdep_new) */
mgr->board_type = MIXART_DAUGHTER_TYPE_NONE;
- memset(&mgr->dma_dev, 0, sizeof(mgr->dma_dev));
- mgr->dma_dev.type = SNDRV_DMA_TYPE_DEV;
- mgr->dma_dev.dev = snd_dma_pci_data(mgr->pci);
-
/* create array of streaminfo */
- size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_flowinfo_t)) );
- if (snd_dma_alloc_pages(&mgr->dma_dev, size, &mgr->flowinfo) < 0) {
+ size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
+ sizeof(struct mixart_flowinfo)) );
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+ size, &mgr->flowinfo) < 0) {
snd_mixart_free(mgr);
return -ENOMEM;
}
memset(mgr->flowinfo.area, 0, size);
/* create array of bufferinfo */
- size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_bufferinfo_t)) );
- if (snd_dma_alloc_pages(&mgr->dma_dev, size, &mgr->bufferinfo) < 0) {
+ size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
+ sizeof(struct mixart_bufferinfo)) );
+ 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;
static int __init alsa_card_mixart_init(void)
{
- return pci_module_init(&driver);
+ return pci_register_driver(&driver);
}
static void __exit alsa_card_mixart_exit(void)