Lines Matching +full:pcm +full:- +full:interface +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0-or-later
14 #include <linux/dma-mapping.h>
23 #include <sound/pcm.h>
36 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
67 switch(pipe->status) { in mixart_set_pipe_state()
76 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
77 "error mixart_set_pipe_state called with wrong pipe->status!\n"); in mixart_set_pipe_state()
78 return -EINVAL; /* function called with wrong pipe status */ in mixart_set_pipe_state()
92 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
101 group_state.pipe_uid = pipe->group_uid; in mixart_set_pipe_state()
108 request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/ in mixart_set_pipe_state()
114 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
117 return -EINVAL; in mixart_set_pipe_state()
127 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
130 return -EINVAL; in mixart_set_pipe_state()
142 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
145 return -EINVAL; in mixart_set_pipe_state()
148 pipe->status = PIPE_RUNNING; in mixart_set_pipe_state()
151 pipe->status = PIPE_STOPPED; in mixart_set_pipe_state()
158 struct mixart_pipe *pipe, unsigned int rate) in mixart_set_clock() argument
165 switch(pipe->status) { in mixart_set_clock()
169 if(rate != 0) in mixart_set_clock()
173 if(rate == 0) in mixart_set_clock()
176 dev_err(&mgr->pci->dev, in mixart_set_clock()
177 "error mixart_set_clock(%d) called with wrong pipe->status !\n", in mixart_set_clock()
178 rate); in mixart_set_clock()
179 return -EINVAL; in mixart_set_clock()
184 clock_properties.clock_generic_type = (rate != 0) ? CGT_INTERNAL_CLOCK : CGT_NO_CLOCK; in mixart_set_clock()
186 clock_properties.frequency = rate; in mixart_set_clock()
188 clock_properties.uid_caller = pipe->group_uid; in mixart_set_clock()
190 dev_dbg(&mgr->pci->dev, "mixart_set_clock to %d kHz\n", rate); in mixart_set_clock()
193 request.uid = mgr->uid_console_manager; in mixart_set_clock()
199 dev_err(&mgr->pci->dev, in mixart_set_clock()
202 return -EINVAL; in mixart_set_clock()
205 if(rate) pipe->status = PIPE_CLOCK_SET; in mixart_set_clock()
206 else pipe->status = PIPE_RUNNING; in mixart_set_clock()
225 pipe = &(chip->pipe_in_ana); /* analog inputs */ in snd_mixart_add_ref_pipe()
227 pipe = &(chip->pipe_in_dig); /* digital inputs */ in snd_mixart_add_ref_pipe()
233 pipe = &(chip->pipe_out_ana); /* analog outputs */ in snd_mixart_add_ref_pipe()
235 pipe = &(chip->pipe_out_dig); /* digital outputs */ in snd_mixart_add_ref_pipe()
242 if( (monitoring == 0) && (pipe->references >= stream_count) ) { in snd_mixart_add_ref_pipe()
247 if( pipe->status == PIPE_UNDEFINED ) { in snd_mixart_add_ref_pipe()
254 dev_dbg(chip->card->dev, in snd_mixart_add_ref_pipe()
255 "add_ref_pipe audio chip(%d) pcm(%d)\n", in snd_mixart_add_ref_pipe()
256 chip->chip_idx, pcm_number); in snd_mixart_add_ref_pipe()
263 request.data = &buf->sgroup_req; in snd_mixart_add_ref_pipe()
264 request.size = sizeof(buf->sgroup_req); in snd_mixart_add_ref_pipe()
266 memset(&buf->sgroup_req, 0, sizeof(buf->sgroup_req)); in snd_mixart_add_ref_pipe()
268 buf->sgroup_req.stream_count = stream_count; in snd_mixart_add_ref_pipe()
269 buf->sgroup_req.channel_count = 2; in snd_mixart_add_ref_pipe()
270 buf->sgroup_req.latency = 256; in snd_mixart_add_ref_pipe()
271 buf->sgroup_req.connector = pipe->uid_left_connector; /* the left connector */ in snd_mixart_add_ref_pipe()
278 /* we don't yet know the format, so config 16 bit pcm audio for instance */ in snd_mixart_add_ref_pipe()
279 buf->sgroup_req.stream_info[i].size_max_byte_frame = 1024; in snd_mixart_add_ref_pipe()
280 buf->sgroup_req.stream_info[i].size_max_sample_frame = 256; in snd_mixart_add_ref_pipe()
281 … buf->sgroup_req.stream_info[i].nb_bytes_max_per_sample = MIXART_FLOAT_P__4_0_TO_HEX; /* is 4.0f */ in snd_mixart_add_ref_pipe()
284 …j = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (pcm_number * (MIXART_PLAYBACK_STREAMS + MIXAR… in snd_mixart_add_ref_pipe()
287 buf->sgroup_req.flow_entry[i] = j; in snd_mixart_add_ref_pipe()
289 flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area; in snd_mixart_add_ref_pipe()
290 …flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mi… in snd_mixart_add_ref_pipe()
291 flowinfo[j].bufferinfo_count = 1; /* 1 will set the miXart to ring-buffer mode ! */ in snd_mixart_add_ref_pipe()
293 bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area; in snd_mixart_add_ref_pipe()
298 …bufferinfo[j].buffer_id = (chip->chip_idx << MIXART_NOTIFY_CARD_OFFSET) + (pcm_number << MIXART_NO… in snd_mixart_add_ref_pipe()
304 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp); in snd_mixart_add_ref_pipe()
305 if((err < 0) || (buf->sgroup_resp.status != 0)) { in snd_mixart_add_ref_pipe()
306 dev_err(chip->card->dev, in snd_mixart_add_ref_pipe()
308 err, buf->sgroup_resp.status); in snd_mixart_add_ref_pipe()
313 pipe->group_uid = buf->sgroup_resp.group; /* id of the pipe, as returned by embedded */ in snd_mixart_add_ref_pipe()
314 pipe->stream_count = buf->sgroup_resp.stream_count; in snd_mixart_add_ref_pipe()
315 /* pipe->stream_uid[i] = buf->sgroup_resp.stream[i].stream_uid; */ in snd_mixart_add_ref_pipe()
317 pipe->status = PIPE_STOPPED; in snd_mixart_add_ref_pipe()
321 if(monitoring) pipe->monitoring = 1; in snd_mixart_add_ref_pipe()
322 else pipe->references++; in snd_mixart_add_ref_pipe()
333 if(pipe->status == PIPE_UNDEFINED) in snd_mixart_kill_ref_pipe()
337 pipe->monitoring = 0; in snd_mixart_kill_ref_pipe()
339 pipe->references--; in snd_mixart_kill_ref_pipe()
341 if((pipe->references <= 0) && (pipe->monitoring == 0)) { in snd_mixart_kill_ref_pipe()
349 dev_err(&mgr->pci->dev, in snd_mixart_kill_ref_pipe()
356 dev_err(&mgr->pci->dev, "error stopping pipe!\n"); in snd_mixart_kill_ref_pipe()
361 request.data = &pipe->group_uid; /* the streaming group ! */ in snd_mixart_kill_ref_pipe()
362 request.size = sizeof(pipe->group_uid); in snd_mixart_kill_ref_pipe()
367 dev_err(&mgr->pci->dev, in snd_mixart_kill_ref_pipe()
372 pipe->group_uid = (struct mixart_uid){0,0}; in snd_mixart_kill_ref_pipe()
373 pipe->stream_count = 0; in snd_mixart_kill_ref_pipe()
374 pipe->status = PIPE_UNDEFINED; in snd_mixart_kill_ref_pipe()
386 if(!stream->substream) in mixart_set_stream_state()
387 return -EINVAL; in mixart_set_stream_state()
391 stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid; in mixart_set_stream_state()
392 stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number; in mixart_set_stream_state()
394 if (stream->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mixart_set_stream_state()
403 stream->abs_period_elapsed = 0; /* reset stream pos */ in mixart_set_stream_state()
404 stream->buf_periods = 0; in mixart_set_stream_state()
405 stream->buf_period_frag = 0; in mixart_set_stream_state()
407 chip = snd_pcm_substream_chip(stream->substream); in mixart_set_stream_state()
409 return snd_mixart_send_msg_nonblock(chip->mgr, &request); in mixart_set_stream_state()
418 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_trigger()
423 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_START\n"); in snd_mixart_trigger()
427 return -EINVAL; in snd_mixart_trigger()
429 stream->status = MIXART_STREAM_STATUS_RUNNING; in snd_mixart_trigger()
436 return -EINVAL; in snd_mixart_trigger()
438 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_trigger()
440 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_STOP\n"); in snd_mixart_trigger()
446 stream->status = MIXART_STREAM_STATUS_PAUSE; in snd_mixart_trigger()
447 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_PUSH\n"); in snd_mixart_trigger()
451 stream->status = MIXART_STREAM_STATUS_RUNNING; in snd_mixart_trigger()
452 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_RELEASE\n"); in snd_mixart_trigger()
455 return -EINVAL; in snd_mixart_trigger()
463 while (atomic_read(&mgr->msg_processed) > 0) { in mixart_sync_nonblock_events()
465 dev_err(&mgr->pci->dev, in mixart_sync_nonblock_events()
467 return -EBUSY; in mixart_sync_nonblock_events()
480 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_prepare()
482 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ in snd_mixart_prepare()
484 dev_dbg(chip->card->dev, "snd_mixart_prepare\n"); in snd_mixart_prepare()
486 mixart_sync_nonblock_events(chip->mgr); in snd_mixart_prepare()
488 /* only the first stream can choose the sample rate */ in snd_mixart_prepare()
490 if(chip->mgr->ref_count_rate == 1) in snd_mixart_prepare()
491 chip->mgr->sample_rate = subs->runtime->rate; in snd_mixart_prepare()
494 if(stream->pipe->references == 1) { in snd_mixart_prepare()
495 if( mixart_set_clock(chip->mgr, stream->pipe, subs->runtime->rate) ) in snd_mixart_prepare()
496 return -EINVAL; in snd_mixart_prepare()
511 chip = snd_pcm_substream_chip(stream->substream); in mixart_set_format()
516 stream_param.number_of_channel = stream->channels; in mixart_set_format()
518 stream_param.sampling_freq = chip->mgr->sample_rate; in mixart_set_format()
552 dev_err(chip->card->dev, in mixart_set_format()
554 return -EINVAL; in mixart_set_format()
557 dev_dbg(chip->card->dev, in mixart_set_format()
559 … stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels); in mixart_set_format()
568 stream_param.stream_desc.uid_pipe = stream->pipe->group_uid; in mixart_set_format()
569 stream_param.stream_desc.stream_idx = stream->substream->number; in mixart_set_format()
576 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp); in mixart_set_format()
578 dev_err(chip->card->dev, in mixart_set_format()
581 return -EINVAL; in mixart_set_format()
594 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_hw_params()
595 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_hw_params()
606 mutex_lock(&mgr->setup_mutex); in snd_mixart_hw_params()
609 if( stream->pcm_number <= MIXART_PCM_DIGITAL ) { in snd_mixart_hw_params()
610 int is_aes = stream->pcm_number > MIXART_PCM_ANALOG; in snd_mixart_hw_params()
611 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) in snd_mixart_hw_params()
612 mixart_update_playback_stream_level(chip, is_aes, subs->number); in snd_mixart_hw_params()
617 stream->channels = channels; in snd_mixart_hw_params()
622 mutex_unlock(&mgr->setup_mutex); in snd_mixart_hw_params()
626 if (subs->runtime->buffer_changed) { in snd_mixart_hw_params()
628 …int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STR… in snd_mixart_hw_params()
629 if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) { in snd_mixart_hw_params()
633 bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area; in snd_mixart_hw_params()
634 bufferinfo[i].buffer_address = subs->runtime->dma_addr; in snd_mixart_hw_params()
635 bufferinfo[i].available_length = subs->runtime->dma_bytes; in snd_mixart_hw_params()
638 dev_dbg(chip->card->dev, in snd_mixart_hw_params()
639 "snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", in snd_mixart_hw_params()
642 subs->number); in snd_mixart_hw_params()
644 mutex_unlock(&mgr->setup_mutex); in snd_mixart_hw_params()
652 mixart_sync_nonblock_events(chip->mgr); in snd_mixart_hw_free()
659 * TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max
707 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_playback_open()
708 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_playback_open()
709 struct snd_pcm *pcm = subs->pcm; in snd_mixart_playback_open() local
715 mutex_lock(&mgr->setup_mutex); in snd_mixart_playback_open()
717 if ( pcm == chip->pcm ) { in snd_mixart_playback_open()
719 runtime->hw = snd_mixart_analog_caps; in snd_mixart_playback_open()
721 snd_BUG_ON(pcm != chip->pcm_dig); in snd_mixart_playback_open()
723 runtime->hw = snd_mixart_digital_caps; in snd_mixart_playback_open()
725 dev_dbg(chip->card->dev, in snd_mixart_playback_open()
727 chip->chip_idx, pcm_number, subs->number); in snd_mixart_playback_open()
730 stream = &(chip->playback_stream[pcm_number][subs->number]); in snd_mixart_playback_open()
732 if (stream->status != MIXART_STREAM_STATUS_FREE){ in snd_mixart_playback_open()
734 dev_err(chip->card->dev, in snd_mixart_playback_open()
736 chip->chip_idx, pcm_number, subs->number); in snd_mixart_playback_open()
737 err = -EBUSY; in snd_mixart_playback_open()
745 err = -EINVAL; in snd_mixart_playback_open()
750 err = mixart_set_pipe_state(chip->mgr, pipe, 1); in snd_mixart_playback_open()
752 dev_err(chip->card->dev, "error starting pipe!\n"); in snd_mixart_playback_open()
753 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); in snd_mixart_playback_open()
754 err = -EINVAL; in snd_mixart_playback_open()
758 stream->pipe = pipe; in snd_mixart_playback_open()
759 stream->pcm_number = pcm_number; in snd_mixart_playback_open()
760 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_playback_open()
761 stream->substream = subs; in snd_mixart_playback_open()
762 stream->channels = 0; /* not configured yet */ in snd_mixart_playback_open()
764 runtime->private_data = stream; in snd_mixart_playback_open()
769 /* if a sample rate is already used, another stream cannot change */ in snd_mixart_playback_open()
770 if(mgr->ref_count_rate++) { in snd_mixart_playback_open()
771 if(mgr->sample_rate) { in snd_mixart_playback_open()
772 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in snd_mixart_playback_open()
777 mutex_unlock(&mgr->setup_mutex); in snd_mixart_playback_open()
786 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_capture_open()
787 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_capture_open()
788 struct snd_pcm *pcm = subs->pcm; in snd_mixart_capture_open() local
794 mutex_lock(&mgr->setup_mutex); in snd_mixart_capture_open()
796 if ( pcm == chip->pcm ) { in snd_mixart_capture_open()
798 runtime->hw = snd_mixart_analog_caps; in snd_mixart_capture_open()
800 snd_BUG_ON(pcm != chip->pcm_dig); in snd_mixart_capture_open()
802 runtime->hw = snd_mixart_digital_caps; in snd_mixart_capture_open()
805 runtime->hw.channels_min = 2; /* for instance, no mono */ in snd_mixart_capture_open()
807 dev_dbg(chip->card->dev, "snd_mixart_capture_open C%d/P%d/Sub%d\n", in snd_mixart_capture_open()
808 chip->chip_idx, pcm_number, subs->number); in snd_mixart_capture_open()
811 stream = &(chip->capture_stream[pcm_number]); in snd_mixart_capture_open()
813 if (stream->status != MIXART_STREAM_STATUS_FREE){ in snd_mixart_capture_open()
815 dev_err(chip->card->dev, in snd_mixart_capture_open()
817 chip->chip_idx, pcm_number, subs->number); in snd_mixart_capture_open()
818 err = -EBUSY; in snd_mixart_capture_open()
826 err = -EINVAL; in snd_mixart_capture_open()
831 err = mixart_set_pipe_state(chip->mgr, pipe, 1); in snd_mixart_capture_open()
833 dev_err(chip->card->dev, "error starting pipe!\n"); in snd_mixart_capture_open()
834 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); in snd_mixart_capture_open()
835 err = -EINVAL; in snd_mixart_capture_open()
839 stream->pipe = pipe; in snd_mixart_capture_open()
840 stream->pcm_number = pcm_number; in snd_mixart_capture_open()
841 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_capture_open()
842 stream->substream = subs; in snd_mixart_capture_open()
843 stream->channels = 0; /* not configured yet */ in snd_mixart_capture_open()
845 runtime->private_data = stream; in snd_mixart_capture_open()
850 /* if a sample rate is already used, another stream cannot change */ in snd_mixart_capture_open()
851 if(mgr->ref_count_rate++) { in snd_mixart_capture_open()
852 if(mgr->sample_rate) { in snd_mixart_capture_open()
853 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in snd_mixart_capture_open()
858 mutex_unlock(&mgr->setup_mutex); in snd_mixart_capture_open()
868 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_close()
869 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_close()
871 mutex_lock(&mgr->setup_mutex); in snd_mixart_close()
873 dev_dbg(chip->card->dev, "snd_mixart_close C%d/P%d/Sub%d\n", in snd_mixart_close()
874 chip->chip_idx, stream->pcm_number, subs->number); in snd_mixart_close()
876 /* sample rate released */ in snd_mixart_close()
877 if(--mgr->ref_count_rate == 0) { in snd_mixart_close()
878 mgr->sample_rate = 0; in snd_mixart_close()
882 if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) { in snd_mixart_close()
884 dev_err(chip->card->dev, in snd_mixart_close()
886 chip->chip_idx, stream->pcm_number); in snd_mixart_close()
889 stream->pipe = NULL; in snd_mixart_close()
890 stream->status = MIXART_STREAM_STATUS_FREE; in snd_mixart_close()
891 stream->substream = NULL; in snd_mixart_close()
893 mutex_unlock(&mgr->setup_mutex); in snd_mixart_close()
900 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_stream_pointer()
901 struct mixart_stream *stream = runtime->private_data; in snd_mixart_stream_pointer()
903 return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag); in snd_mixart_stream_pointer()
928 static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm) in preallocate_buffers() argument
936 for (subs = pcm->streams[stream].substream; subs; subs = subs->next, idx++) in preallocate_buffers()
938 subs->dma_device.id = subs->pcm->device << 16 | in preallocate_buffers()
939 subs->stream << 8 | (subs->number + 1) | in preallocate_buffers()
940 (chip->chip_idx + 1) << 24; in preallocate_buffers()
943 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, in preallocate_buffers()
944 &chip->mgr->pci->dev, in preallocate_buffers()
953 struct snd_pcm *pcm; in snd_mixart_pcm_analog() local
956 sprintf(name, "miXart analog %d", chip->chip_idx); in snd_mixart_pcm_analog()
957 err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG, in snd_mixart_pcm_analog()
959 MIXART_CAPTURE_STREAMS, &pcm); in snd_mixart_pcm_analog()
961 dev_err(chip->card->dev, in snd_mixart_pcm_analog()
962 "cannot create the analog pcm %d\n", chip->chip_idx); in snd_mixart_pcm_analog()
966 pcm->private_data = chip; in snd_mixart_pcm_analog()
968 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_mixart_playback_ops); in snd_mixart_pcm_analog()
969 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_mixart_capture_ops); in snd_mixart_pcm_analog()
971 pcm->info_flags = 0; in snd_mixart_pcm_analog()
972 pcm->nonatomic = true; in snd_mixart_pcm_analog()
973 strcpy(pcm->name, name); in snd_mixart_pcm_analog()
975 preallocate_buffers(chip, pcm); in snd_mixart_pcm_analog()
977 chip->pcm = pcm; in snd_mixart_pcm_analog()
987 struct snd_pcm *pcm; in snd_mixart_pcm_digital() local
990 sprintf(name, "miXart AES/EBU %d", chip->chip_idx); in snd_mixart_pcm_digital()
991 err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL, in snd_mixart_pcm_digital()
993 MIXART_CAPTURE_STREAMS, &pcm); in snd_mixart_pcm_digital()
995 dev_err(chip->card->dev, in snd_mixart_pcm_digital()
996 "cannot create the digital pcm %d\n", chip->chip_idx); in snd_mixart_pcm_digital()
1000 pcm->private_data = chip; in snd_mixart_pcm_digital()
1002 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_mixart_playback_ops); in snd_mixart_pcm_digital()
1003 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_mixart_capture_ops); in snd_mixart_pcm_digital()
1005 pcm->info_flags = 0; in snd_mixart_pcm_digital()
1006 pcm->nonatomic = true; in snd_mixart_pcm_digital()
1007 strcpy(pcm->name, name); in snd_mixart_pcm_digital()
1009 preallocate_buffers(chip, pcm); in snd_mixart_pcm_digital()
1011 chip->pcm_dig = pcm; in snd_mixart_pcm_digital()
1023 struct snd_mixart *chip = device->device_data; in snd_mixart_chip_dev_free()
1040 return -ENOMEM; in snd_mixart_create()
1042 chip->card = card; in snd_mixart_create()
1043 chip->chip_idx = idx; in snd_mixart_create()
1044 chip->mgr = mgr; in snd_mixart_create()
1045 card->sync_irq = mgr->irq; in snd_mixart_create()
1053 mgr->chip[idx] = chip; in snd_mixart_create()
1065 if(chip->mgr->board_type == MIXART_DAUGHTER_TYPE_AES) { in snd_mixart_create_pcm()
1082 for (i = 0; i < mgr->num_cards; i++) { in snd_mixart_free()
1083 if (mgr->chip[i]) in snd_mixart_free()
1084 snd_card_free(mgr->chip[i]->card); in snd_mixart_free()
1091 if (mgr->irq >= 0) in snd_mixart_free()
1092 free_irq(mgr->irq, mgr); in snd_mixart_free()
1095 if(mgr->dsp_loaded) { in snd_mixart_free()
1097 dev_dbg(&mgr->pci->dev, "reset miXart !\n"); in snd_mixart_free()
1102 iounmap(mgr->mem[i].virt); in snd_mixart_free()
1104 pci_release_regions(mgr->pci); in snd_mixart_free()
1107 if(mgr->flowinfo.area) { in snd_mixart_free()
1108 snd_dma_free_pages(&mgr->flowinfo); in snd_mixart_free()
1109 mgr->flowinfo.area = NULL; in snd_mixart_free()
1112 if(mgr->bufferinfo.area) { in snd_mixart_free()
1113 snd_dma_free_pages(&mgr->bufferinfo); in snd_mixart_free()
1114 mgr->bufferinfo.area = NULL; in snd_mixart_free()
1117 pci_disable_device(mgr->pci); in snd_mixart_free()
1123 * proc interface
1127 mixart_BA0 proc interface for BAR 0 - read callback
1134 struct mixart_mgr *mgr = entry->private_data; in snd_mixart_BA0_read()
1138 return -EFAULT; in snd_mixart_BA0_read()
1143 mixart_BA1 proc interface for BAR 1 - read callback
1150 struct mixart_mgr *mgr = entry->private_data; in snd_mixart_BA1_read()
1154 return -EFAULT; in snd_mixart_BA1_read()
1170 struct snd_mixart *chip = entry->private_data; in snd_mixart_proc_read()
1173 snd_iprintf(buffer, "Digigram miXart (alsa card %d)\n\n", chip->chip_idx); in snd_mixart_proc_read()
1176 if (chip->mgr->dsp_loaded & ( 1 << MIXART_MOTHERBOARD_ELF_INDEX)) { in snd_mixart_proc_read()
1177 snd_iprintf(buffer, "- hardware -\n"); in snd_mixart_proc_read()
1178 switch (chip->mgr->board_type ) { in snd_mixart_proc_read()
1185 snd_iprintf(buffer, "- system load -\n"); in snd_mixart_proc_read()
1189 ref = readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_SYSTEM_LOAD_OFFSET)); in snd_mixart_proc_read()
1192 …u32 mailbox = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_MAILBX_LOAD_OFFSET)) … in snd_mixart_proc_read()
1193 …u32 streaming = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_STREAM_LOAD_OFFSET)) … in snd_mixart_proc_read()
1194 …u32 interr = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_INTERR_LOAD_OFFSET)) … in snd_mixart_proc_read()
1207 /* text interface to read perf and temp meters */ in snd_mixart_proc_init()
1208 snd_card_ro_proc_new(chip->card, "board_info", chip, in snd_mixart_proc_init()
1211 if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) { in snd_mixart_proc_init()
1212 entry->content = SNDRV_INFO_CONTENT_DATA; in snd_mixart_proc_init()
1213 entry->private_data = chip->mgr; in snd_mixart_proc_init()
1214 entry->c.ops = &snd_mixart_proc_ops_BA0; in snd_mixart_proc_init()
1215 entry->size = MIXART_BA0_SIZE; in snd_mixart_proc_init()
1217 if (! snd_card_proc_new(chip->card, "mixart_BA1", &entry)) { in snd_mixart_proc_init()
1218 entry->content = SNDRV_INFO_CONTENT_DATA; in snd_mixart_proc_init()
1219 entry->private_data = chip->mgr; in snd_mixart_proc_init()
1220 entry->c.ops = &snd_mixart_proc_ops_BA1; in snd_mixart_proc_init()
1221 entry->size = MIXART_BA1_SIZE; in snd_mixart_proc_init()
1224 /* end of proc interface */
1228 * probe function - creates the card manager
1242 return -ENODEV; in snd_mixart_probe()
1245 return -ENOENT; in snd_mixart_probe()
1255 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) { in snd_mixart_probe()
1256 dev_err(&pci->dev, in snd_mixart_probe()
1259 return -ENXIO; in snd_mixart_probe()
1267 return -ENOMEM; in snd_mixart_probe()
1270 mgr->pci = pci; in snd_mixart_probe()
1271 mgr->irq = -1; in snd_mixart_probe()
1281 mgr->mem[i].phys = pci_resource_start(pci, i); in snd_mixart_probe()
1282 mgr->mem[i].virt = pci_ioremap_bar(pci, i); in snd_mixart_probe()
1283 if (!mgr->mem[i].virt) { in snd_mixart_probe()
1284 dev_err(&pci->dev, "unable to remap resource 0x%lx\n", in snd_mixart_probe()
1285 mgr->mem[i].phys); in snd_mixart_probe()
1287 return -EBUSY; in snd_mixart_probe()
1291 if (request_threaded_irq(pci->irq, snd_mixart_interrupt, in snd_mixart_probe()
1294 dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq); in snd_mixart_probe()
1296 return -EBUSY; in snd_mixart_probe()
1298 mgr->irq = pci->irq; in snd_mixart_probe()
1301 mgr->msg_fifo_readptr = 0; in snd_mixart_probe()
1302 mgr->msg_fifo_writeptr = 0; in snd_mixart_probe()
1304 mutex_init(&mgr->lock); in snd_mixart_probe()
1305 mutex_init(&mgr->msg_lock); in snd_mixart_probe()
1306 init_waitqueue_head(&mgr->msg_sleep); in snd_mixart_probe()
1307 atomic_set(&mgr->msg_processed, 0); in snd_mixart_probe()
1310 mutex_init(&mgr->setup_mutex); in snd_mixart_probe()
1313 mgr->num_cards = MIXART_MAX_CARDS; /* 4 FIXME: configurable? */ in snd_mixart_probe()
1314 for (i = 0; i < mgr->num_cards; i++) { in snd_mixart_probe()
1323 snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); in snd_mixart_probe()
1324 err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE, in snd_mixart_probe()
1328 dev_err(&pci->dev, "cannot allocate the card %d\n", i); in snd_mixart_probe()
1333 strcpy(card->driver, CARD_NAME); in snd_mixart_probe()
1334 snprintf(card->shortname, sizeof(card->shortname), in snd_mixart_probe()
1335 "Digigram miXart [PCM #%d]", i); in snd_mixart_probe()
1336 snprintf(card->longname, sizeof(card->longname), in snd_mixart_probe()
1337 "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", in snd_mixart_probe()
1338 mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); in snd_mixart_probe()
1348 /* init proc interface only for chip0 */ in snd_mixart_probe()
1349 snd_mixart_proc_init(mgr->chip[i]); in snd_mixart_probe()
1359 /* init firmware status (mgr->dsp_loaded reset in hwdep_new) */ in snd_mixart_probe()
1360 mgr->board_type = MIXART_DAUGHTER_TYPE_NONE; in snd_mixart_probe()
1365 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, in snd_mixart_probe()
1366 size, &mgr->flowinfo) < 0) { in snd_mixart_probe()
1368 return -ENOMEM; in snd_mixart_probe()
1371 memset(mgr->flowinfo.area, 0, size); in snd_mixart_probe()
1376 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, in snd_mixart_probe()
1377 size, &mgr->bufferinfo) < 0) { in snd_mixart_probe()
1379 return -ENOMEM; in snd_mixart_probe()
1382 memset(mgr->bufferinfo.area, 0, size); in snd_mixart_probe()