X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fmixart%2Fmixart.c;h=09cc0786495a00dd5456f3994affdaab5ecfa516;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=a7041d850501458db5dad055d771a0c688cf7869;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index a7041d850..09cc07864 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -25,8 +25,11 @@ #include #include #include +#include +#include +#include + #include -#define SNDRV_GET_ID #include #include #include @@ -42,29 +45,23 @@ MODULE_AUTHOR("Digigram "); 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 */ -#define chip_t mixart_t - -MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +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_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s"); +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_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard."); -MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); /* */ -static struct pci_device_id snd_mixart_ids[] = { +static struct pci_device_id snd_mixart_ids[] __devinitdata = { { 0x1057, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* MC8240 */ { 0, } }; @@ -72,11 +69,12 @@ static struct pci_device_id snd_mixart_ids[] = { 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; @@ -98,7 +96,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta /* 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); @@ -119,7 +117,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta 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); @@ -143,7 +141,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta /* 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; @@ -162,11 +160,12 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta } -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) { @@ -214,11 +213,13 @@ static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int /* * 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) { @@ -246,21 +247,27 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt /* 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; - memset(&streaming_group_req, 0, sizeof(streaming_group_req)); + 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); - 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 */ + 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; isgroup_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; @@ -293,17 +300,19 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt } } - 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; @@ -313,7 +322,8 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt } -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; @@ -327,8 +337,8 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito 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); @@ -343,7 +353,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito } 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); @@ -353,7 +363,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito 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; } @@ -361,11 +371,11 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito 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; @@ -380,7 +390,7 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start) 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); @@ -397,9 +407,9 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start) * 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: @@ -441,29 +451,26 @@ static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd) 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) */ @@ -486,13 +493,13 @@ static int snd_mixart_prepare(snd_pcm_substream_t *subs) } -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); @@ -526,11 +533,11 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) 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; @@ -553,7 +560,7 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) 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); @@ -569,12 +576,12 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) /* * 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; @@ -585,7 +592,7 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs, /* set up format for the stream */ format = params_format(hw); - down(&mgr->setup_mutex); + mutex_lock(&mgr->setup_mutex); /* update the stream levels */ if( stream->pcm_number <= MIXART_PCM_DIGITAL ) { @@ -619,16 +626,19 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs, 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); + mutex_unlock(&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; @@ -639,7 +649,7 @@ static int snd_mixart_hw_free(snd_pcm_substream_t *subs) /* * 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 | @@ -660,7 +670,7 @@ static snd_pcm_hardware_t snd_mixart_analog_caps = .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 | @@ -682,18 +692,18 @@ static snd_pcm_hardware_t snd_mixart_digital_caps = }; -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; - down(&mgr->setup_mutex); + mutex_lock(&mgr->setup_mutex); if ( pcm == chip->pcm ) { pcm_number = MIXART_PCM_ANALOG; @@ -751,24 +761,24 @@ static int snd_mixart_playback_open(snd_pcm_substream_t *subs) } _exit_open: - up(&mgr->setup_mutex); + mutex_unlock(&mgr->setup_mutex); return err; } -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; - down(&mgr->setup_mutex); + mutex_lock(&mgr->setup_mutex); if ( pcm == chip->pcm ) { pcm_number = MIXART_PCM_ANALOG; @@ -829,20 +839,20 @@ static int snd_mixart_capture_open(snd_pcm_substream_t *subs) } _exit_open: - up(&mgr->setup_mutex); + mutex_unlock(&mgr->setup_mutex); return err; } -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); + mutex_lock(&mgr->setup_mutex); snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number); @@ -861,22 +871,22 @@ static int snd_mixart_close(snd_pcm_substream_t *subs) stream->status = MIXART_STREAM_STATUS_FREE; stream->substream = NULL; - up(&mgr->setup_mutex); + mutex_unlock(&mgr->setup_mutex); return 0; } -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, @@ -887,7 +897,7 @@ static snd_pcm_ops_t snd_mixart_playback_ops = { .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, @@ -898,9 +908,10 @@ static snd_pcm_ops_t snd_mixart_capture_ops = { .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++) { @@ -911,16 +922,17 @@ static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm) 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); @@ -936,7 +948,7 @@ static int snd_mixart_pcm_analog(mixart_t *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 = SNDRV_PCM_INFO_NONATOMIC_OPS; + pcm->info_flags = 0; strcpy(pcm->name, name); preallocate_buffers(chip, pcm); @@ -948,10 +960,10 @@ static int snd_mixart_pcm_analog(mixart_t *chip) /* */ -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); @@ -967,7 +979,7 @@ static int snd_mixart_pcm_digital(mixart_t *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 = SNDRV_PCM_INFO_NONATOMIC_OPS; + pcm->info_flags = 0; strcpy(pcm->name, name); preallocate_buffers(chip, pcm); @@ -976,30 +988,30 @@ static int snd_mixart_pcm_digital(mixart_t *chip) 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; @@ -1014,19 +1026,12 @@ static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int 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; @@ -1047,7 +1052,7 @@ int snd_mixart_create_pcm(mixart_t* chip) /* * 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; @@ -1064,7 +1069,7 @@ static int snd_mixart_free(mixart_mgr_t *mgr) 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"); } @@ -1072,32 +1077,30 @@ static int snd_mixart_free(mixart_mgr_t *mgr) /* 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, @@ -1123,7 +1126,7 @@ static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry, 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, @@ -1152,38 +1155,38 @@ static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry, /* 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 *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 *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; } @@ -1198,16 +1201,16 @@ static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { }; -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; @@ -1234,9 +1237,9 @@ static void snd_mixart_proc_read(snd_info_entry_t *entry, } /* 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)) { @@ -1268,7 +1271,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, 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; @@ -1288,35 +1291,33 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, 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, DMA_32BIT_MASK) < 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)) { @@ -1330,27 +1331,27 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, 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; - init_MUTEX(&mgr->msg_mutex); + spin_lock_init(&mgr->msg_lock); + mutex_init(&mgr->msg_mutex); init_waitqueue_head(&mgr->msg_sleep); atomic_set(&mgr->msg_processed, 0); /* init setup mutex*/ - init_MUTEX(&mgr->setup_mutex); + mutex_init(&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; @@ -1358,7 +1359,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, 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) { @@ -1387,16 +1388,14 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, } } - /* 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; } @@ -1404,14 +1403,23 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, 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; @@ -1432,15 +1440,7 @@ static struct pci_driver driver = { static int __init alsa_card_mixart_init(void) { - int err; - - if ((err = pci_module_init(&driver)) < 0) { -#ifdef MODULE - snd_printk(KERN_ERR "Digigram miXart soundcard not found or device busy\n"); -#endif - return err; - } - return 0; + return pci_register_driver(&driver); } static void __exit alsa_card_mixart_exit(void) @@ -1450,24 +1450,3 @@ static void __exit alsa_card_mixart_exit(void) module_init(alsa_card_mixart_init) module_exit(alsa_card_mixart_exit) - -#ifndef MODULE - -/* format is: snd-mixart=enable,index,id */ - -static int __init alsa_card_mixart_setup(char *str) -{ - static unsigned __initdata nr_dev = 0; - - if (nr_dev >= SNDRV_CARDS) - return 0; - (void)(get_option(&str,&enable[nr_dev]) == 2 && - get_option(&str,&index[nr_dev]) == 2 && - get_id(&str,&id[nr_dev]) == 2); - nr_dev++; - return 1; -} - -__setup("snd-mixart=", alsa_card_mixart_setup); - -#endif /* ifndef MODULE */