• Home
  • Raw
  • Download

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>
37 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
68 switch(pipe->status) { in mixart_set_pipe_state()
77 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
78 "error mixart_set_pipe_state called with wrong pipe->status!\n"); in mixart_set_pipe_state()
79 return -EINVAL; /* function called with wrong pipe status */ in mixart_set_pipe_state()
93 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
102 group_state.pipe_uid[0] = pipe->group_uid; in mixart_set_pipe_state()
109 request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/ in mixart_set_pipe_state()
115 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
118 return -EINVAL; in mixart_set_pipe_state()
128 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
131 return -EINVAL; in mixart_set_pipe_state()
143 dev_err(&mgr->pci->dev, in mixart_set_pipe_state()
146 return -EINVAL; in mixart_set_pipe_state()
149 pipe->status = PIPE_RUNNING; in mixart_set_pipe_state()
152 pipe->status = PIPE_STOPPED; in mixart_set_pipe_state()
159 struct mixart_pipe *pipe, unsigned int rate) in mixart_set_clock() argument
166 switch(pipe->status) { in mixart_set_clock()
170 if(rate != 0) in mixart_set_clock()
174 if(rate == 0) in mixart_set_clock()
177 dev_err(&mgr->pci->dev, in mixart_set_clock()
178 "error mixart_set_clock(%d) called with wrong pipe->status !\n", in mixart_set_clock()
179 rate); in mixart_set_clock()
180 return -EINVAL; in mixart_set_clock()
185 clock_properties.clock_generic_type = (rate != 0) ? CGT_INTERNAL_CLOCK : CGT_NO_CLOCK; in mixart_set_clock()
187 clock_properties.frequency = rate; in mixart_set_clock()
189 clock_properties.uid_caller[0] = pipe->group_uid; in mixart_set_clock()
191 dev_dbg(&mgr->pci->dev, "mixart_set_clock to %d kHz\n", rate); in mixart_set_clock()
194 request.uid = mgr->uid_console_manager; in mixart_set_clock()
200 dev_err(&mgr->pci->dev, in mixart_set_clock()
203 return -EINVAL; in mixart_set_clock()
206 if(rate) pipe->status = PIPE_CLOCK_SET; in mixart_set_clock()
207 else pipe->status = PIPE_RUNNING; in mixart_set_clock()
226 pipe = &(chip->pipe_in_ana); /* analog inputs */ in snd_mixart_add_ref_pipe()
228 pipe = &(chip->pipe_in_dig); /* digital inputs */ in snd_mixart_add_ref_pipe()
234 pipe = &(chip->pipe_out_ana); /* analog outputs */ in snd_mixart_add_ref_pipe()
236 pipe = &(chip->pipe_out_dig); /* digital outputs */ in snd_mixart_add_ref_pipe()
243 if( (monitoring == 0) && (pipe->references >= stream_count) ) { in snd_mixart_add_ref_pipe()
248 if( pipe->status == PIPE_UNDEFINED ) { in snd_mixart_add_ref_pipe()
255 dev_dbg(chip->card->dev, in snd_mixart_add_ref_pipe()
256 "add_ref_pipe audio chip(%d) pcm(%d)\n", in snd_mixart_add_ref_pipe()
257 chip->chip_idx, pcm_number); in snd_mixart_add_ref_pipe()
264 request.data = &buf->sgroup_req; in snd_mixart_add_ref_pipe()
265 request.size = sizeof(buf->sgroup_req); in snd_mixart_add_ref_pipe()
267 memset(&buf->sgroup_req, 0, sizeof(buf->sgroup_req)); in snd_mixart_add_ref_pipe()
269 buf->sgroup_req.stream_count = stream_count; in snd_mixart_add_ref_pipe()
270 buf->sgroup_req.channel_count = 2; in snd_mixart_add_ref_pipe()
271 buf->sgroup_req.latency = 256; in snd_mixart_add_ref_pipe()
272 buf->sgroup_req.connector = pipe->uid_left_connector; /* the left connector */ in snd_mixart_add_ref_pipe()
279 /* we don't yet know the format, so config 16 bit pcm audio for instance */ in snd_mixart_add_ref_pipe()
280 buf->sgroup_req.stream_info[i].size_max_byte_frame = 1024; in snd_mixart_add_ref_pipe()
281 buf->sgroup_req.stream_info[i].size_max_sample_frame = 256; in snd_mixart_add_ref_pipe()
282 … 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()
285 …j = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (pcm_number * (MIXART_PLAYBACK_STREAMS + MIXAR… in snd_mixart_add_ref_pipe()
288 buf->sgroup_req.flow_entry[i] = j; in snd_mixart_add_ref_pipe()
290 flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area; in snd_mixart_add_ref_pipe()
291 …flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mi… in snd_mixart_add_ref_pipe()
292 flowinfo[j].bufferinfo_count = 1; /* 1 will set the miXart to ring-buffer mode ! */ in snd_mixart_add_ref_pipe()
294 bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area; in snd_mixart_add_ref_pipe()
299 …bufferinfo[j].buffer_id = (chip->chip_idx << MIXART_NOTIFY_CARD_OFFSET) + (pcm_number << MIXART_NO… in snd_mixart_add_ref_pipe()
305 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp); in snd_mixart_add_ref_pipe()
306 if((err < 0) || (buf->sgroup_resp.status != 0)) { in snd_mixart_add_ref_pipe()
307 dev_err(chip->card->dev, in snd_mixart_add_ref_pipe()
309 err, buf->sgroup_resp.status); in snd_mixart_add_ref_pipe()
314 pipe->group_uid = buf->sgroup_resp.group; /* id of the pipe, as returned by embedded */ in snd_mixart_add_ref_pipe()
315 pipe->stream_count = buf->sgroup_resp.stream_count; in snd_mixart_add_ref_pipe()
316 /* pipe->stream_uid[i] = buf->sgroup_resp.stream[i].stream_uid; */ in snd_mixart_add_ref_pipe()
318 pipe->status = PIPE_STOPPED; in snd_mixart_add_ref_pipe()
322 if(monitoring) pipe->monitoring = 1; in snd_mixart_add_ref_pipe()
323 else pipe->references++; in snd_mixart_add_ref_pipe()
334 if(pipe->status == PIPE_UNDEFINED) in snd_mixart_kill_ref_pipe()
338 pipe->monitoring = 0; in snd_mixart_kill_ref_pipe()
340 pipe->references--; in snd_mixart_kill_ref_pipe()
342 if((pipe->references <= 0) && (pipe->monitoring == 0)) { in snd_mixart_kill_ref_pipe()
350 dev_err(&mgr->pci->dev, in snd_mixart_kill_ref_pipe()
357 dev_err(&mgr->pci->dev, "error stopping pipe!\n"); in snd_mixart_kill_ref_pipe()
362 request.data = &pipe->group_uid; /* the streaming group ! */ in snd_mixart_kill_ref_pipe()
363 request.size = sizeof(pipe->group_uid); in snd_mixart_kill_ref_pipe()
368 dev_err(&mgr->pci->dev, in snd_mixart_kill_ref_pipe()
373 pipe->group_uid = (struct mixart_uid){0,0}; in snd_mixart_kill_ref_pipe()
374 pipe->stream_count = 0; in snd_mixart_kill_ref_pipe()
375 pipe->status = PIPE_UNDEFINED; in snd_mixart_kill_ref_pipe()
387 if(!stream->substream) in mixart_set_stream_state()
388 return -EINVAL; in mixart_set_stream_state()
392 stream_state_req.stream_info.stream_desc.uid_pipe = stream->pipe->group_uid; in mixart_set_stream_state()
393 stream_state_req.stream_info.stream_desc.stream_idx = stream->substream->number; in mixart_set_stream_state()
395 if (stream->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mixart_set_stream_state()
404 stream->abs_period_elapsed = 0; /* reset stream pos */ in mixart_set_stream_state()
405 stream->buf_periods = 0; in mixart_set_stream_state()
406 stream->buf_period_frag = 0; in mixart_set_stream_state()
408 chip = snd_pcm_substream_chip(stream->substream); in mixart_set_stream_state()
410 return snd_mixart_send_msg_nonblock(chip->mgr, &request); in mixart_set_stream_state()
419 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_trigger()
424 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_START\n"); in snd_mixart_trigger()
428 return -EINVAL; in snd_mixart_trigger()
430 stream->status = MIXART_STREAM_STATUS_RUNNING; in snd_mixart_trigger()
437 return -EINVAL; in snd_mixart_trigger()
439 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_trigger()
441 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_STOP\n"); in snd_mixart_trigger()
447 stream->status = MIXART_STREAM_STATUS_PAUSE; in snd_mixart_trigger()
448 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_PUSH\n"); in snd_mixart_trigger()
452 stream->status = MIXART_STREAM_STATUS_RUNNING; in snd_mixart_trigger()
453 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_RELEASE\n"); in snd_mixart_trigger()
456 return -EINVAL; in snd_mixart_trigger()
464 while (atomic_read(&mgr->msg_processed) > 0) { in mixart_sync_nonblock_events()
466 dev_err(&mgr->pci->dev, in mixart_sync_nonblock_events()
468 return -EBUSY; in mixart_sync_nonblock_events()
481 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_prepare()
483 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ in snd_mixart_prepare()
485 dev_dbg(chip->card->dev, "snd_mixart_prepare\n"); in snd_mixart_prepare()
487 mixart_sync_nonblock_events(chip->mgr); in snd_mixart_prepare()
489 /* only the first stream can choose the sample rate */ in snd_mixart_prepare()
491 if(chip->mgr->ref_count_rate == 1) in snd_mixart_prepare()
492 chip->mgr->sample_rate = subs->runtime->rate; in snd_mixart_prepare()
495 if(stream->pipe->references == 1) { in snd_mixart_prepare()
496 if( mixart_set_clock(chip->mgr, stream->pipe, subs->runtime->rate) ) in snd_mixart_prepare()
497 return -EINVAL; in snd_mixart_prepare()
512 chip = snd_pcm_substream_chip(stream->substream); in mixart_set_format()
517 stream_param.number_of_channel = stream->channels; in mixart_set_format()
519 stream_param.sampling_freq = chip->mgr->sample_rate; in mixart_set_format()
553 dev_err(chip->card->dev, in mixart_set_format()
555 return -EINVAL; in mixart_set_format()
558 dev_dbg(chip->card->dev, in mixart_set_format()
560 … stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels); in mixart_set_format()
569 stream_param.stream_desc[0].uid_pipe = stream->pipe->group_uid; in mixart_set_format()
570 stream_param.stream_desc[0].stream_idx = stream->substream->number; in mixart_set_format()
577 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp); in mixart_set_format()
579 dev_err(chip->card->dev, in mixart_set_format()
582 return -EINVAL; in mixart_set_format()
595 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_hw_params()
596 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_hw_params()
607 mutex_lock(&mgr->setup_mutex); in snd_mixart_hw_params()
610 if( stream->pcm_number <= MIXART_PCM_DIGITAL ) { in snd_mixart_hw_params()
611 int is_aes = stream->pcm_number > MIXART_PCM_ANALOG; in snd_mixart_hw_params()
612 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) in snd_mixart_hw_params()
613 mixart_update_playback_stream_level(chip, is_aes, subs->number); in snd_mixart_hw_params()
618 stream->channels = channels; in snd_mixart_hw_params()
623 mutex_unlock(&mgr->setup_mutex); in snd_mixart_hw_params()
627 if (subs->runtime->buffer_changed) { in snd_mixart_hw_params()
629 …int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STR… in snd_mixart_hw_params()
630 if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) { in snd_mixart_hw_params()
634 bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area; in snd_mixart_hw_params()
635 bufferinfo[i].buffer_address = subs->runtime->dma_addr; in snd_mixart_hw_params()
636 bufferinfo[i].available_length = subs->runtime->dma_bytes; in snd_mixart_hw_params()
639 dev_dbg(chip->card->dev, in snd_mixart_hw_params()
640 "snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", in snd_mixart_hw_params()
643 subs->number); in snd_mixart_hw_params()
645 mutex_unlock(&mgr->setup_mutex); in snd_mixart_hw_params()
653 mixart_sync_nonblock_events(chip->mgr); in snd_mixart_hw_free()
660 * TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max
708 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_playback_open()
709 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_playback_open()
710 struct snd_pcm *pcm = subs->pcm; in snd_mixart_playback_open() local
716 mutex_lock(&mgr->setup_mutex); in snd_mixart_playback_open()
718 if ( pcm == chip->pcm ) { in snd_mixart_playback_open()
720 runtime->hw = snd_mixart_analog_caps; in snd_mixart_playback_open()
722 snd_BUG_ON(pcm != chip->pcm_dig); in snd_mixart_playback_open()
724 runtime->hw = snd_mixart_digital_caps; in snd_mixart_playback_open()
726 dev_dbg(chip->card->dev, in snd_mixart_playback_open()
728 chip->chip_idx, pcm_number, subs->number); in snd_mixart_playback_open()
731 stream = &(chip->playback_stream[pcm_number][subs->number]); in snd_mixart_playback_open()
733 if (stream->status != MIXART_STREAM_STATUS_FREE){ in snd_mixart_playback_open()
735 dev_err(chip->card->dev, in snd_mixart_playback_open()
737 chip->chip_idx, pcm_number, subs->number); in snd_mixart_playback_open()
738 err = -EBUSY; in snd_mixart_playback_open()
746 err = -EINVAL; in snd_mixart_playback_open()
751 err = mixart_set_pipe_state(chip->mgr, pipe, 1); in snd_mixart_playback_open()
753 dev_err(chip->card->dev, "error starting pipe!\n"); in snd_mixart_playback_open()
754 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); in snd_mixart_playback_open()
755 err = -EINVAL; in snd_mixart_playback_open()
759 stream->pipe = pipe; in snd_mixart_playback_open()
760 stream->pcm_number = pcm_number; in snd_mixart_playback_open()
761 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_playback_open()
762 stream->substream = subs; in snd_mixart_playback_open()
763 stream->channels = 0; /* not configured yet */ in snd_mixart_playback_open()
765 runtime->private_data = stream; in snd_mixart_playback_open()
770 /* if a sample rate is already used, another stream cannot change */ in snd_mixart_playback_open()
771 if(mgr->ref_count_rate++) { in snd_mixart_playback_open()
772 if(mgr->sample_rate) { in snd_mixart_playback_open()
773 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in snd_mixart_playback_open()
778 mutex_unlock(&mgr->setup_mutex); in snd_mixart_playback_open()
787 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_capture_open()
788 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_capture_open()
789 struct snd_pcm *pcm = subs->pcm; in snd_mixart_capture_open() local
795 mutex_lock(&mgr->setup_mutex); in snd_mixart_capture_open()
797 if ( pcm == chip->pcm ) { in snd_mixart_capture_open()
799 runtime->hw = snd_mixart_analog_caps; in snd_mixart_capture_open()
801 snd_BUG_ON(pcm != chip->pcm_dig); in snd_mixart_capture_open()
803 runtime->hw = snd_mixart_digital_caps; in snd_mixart_capture_open()
806 runtime->hw.channels_min = 2; /* for instance, no mono */ in snd_mixart_capture_open()
808 dev_dbg(chip->card->dev, "snd_mixart_capture_open C%d/P%d/Sub%d\n", in snd_mixart_capture_open()
809 chip->chip_idx, pcm_number, subs->number); in snd_mixart_capture_open()
812 stream = &(chip->capture_stream[pcm_number]); in snd_mixart_capture_open()
814 if (stream->status != MIXART_STREAM_STATUS_FREE){ in snd_mixart_capture_open()
816 dev_err(chip->card->dev, in snd_mixart_capture_open()
818 chip->chip_idx, pcm_number, subs->number); in snd_mixart_capture_open()
819 err = -EBUSY; in snd_mixart_capture_open()
827 err = -EINVAL; in snd_mixart_capture_open()
832 err = mixart_set_pipe_state(chip->mgr, pipe, 1); in snd_mixart_capture_open()
834 dev_err(chip->card->dev, "error starting pipe!\n"); in snd_mixart_capture_open()
835 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); in snd_mixart_capture_open()
836 err = -EINVAL; in snd_mixart_capture_open()
840 stream->pipe = pipe; in snd_mixart_capture_open()
841 stream->pcm_number = pcm_number; in snd_mixart_capture_open()
842 stream->status = MIXART_STREAM_STATUS_OPEN; in snd_mixart_capture_open()
843 stream->substream = subs; in snd_mixart_capture_open()
844 stream->channels = 0; /* not configured yet */ in snd_mixart_capture_open()
846 runtime->private_data = stream; in snd_mixart_capture_open()
851 /* if a sample rate is already used, another stream cannot change */ in snd_mixart_capture_open()
852 if(mgr->ref_count_rate++) { in snd_mixart_capture_open()
853 if(mgr->sample_rate) { in snd_mixart_capture_open()
854 runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; in snd_mixart_capture_open()
859 mutex_unlock(&mgr->setup_mutex); in snd_mixart_capture_open()
869 struct mixart_mgr *mgr = chip->mgr; in snd_mixart_close()
870 struct mixart_stream *stream = subs->runtime->private_data; in snd_mixart_close()
872 mutex_lock(&mgr->setup_mutex); in snd_mixart_close()
874 dev_dbg(chip->card->dev, "snd_mixart_close C%d/P%d/Sub%d\n", in snd_mixart_close()
875 chip->chip_idx, stream->pcm_number, subs->number); in snd_mixart_close()
877 /* sample rate released */ in snd_mixart_close()
878 if(--mgr->ref_count_rate == 0) { in snd_mixart_close()
879 mgr->sample_rate = 0; in snd_mixart_close()
883 if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) { in snd_mixart_close()
885 dev_err(chip->card->dev, in snd_mixart_close()
887 chip->chip_idx, stream->pcm_number); in snd_mixart_close()
890 stream->pipe = NULL; in snd_mixart_close()
891 stream->status = MIXART_STREAM_STATUS_FREE; in snd_mixart_close()
892 stream->substream = NULL; in snd_mixart_close()
894 mutex_unlock(&mgr->setup_mutex); in snd_mixart_close()
901 struct snd_pcm_runtime *runtime = subs->runtime; in snd_mixart_stream_pointer()
902 struct mixart_stream *stream = runtime->private_data; in snd_mixart_stream_pointer()
904 return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag); in snd_mixart_stream_pointer()
929 static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm) in preallocate_buffers() argument
937 for (subs = pcm->streams[stream].substream; subs; subs = subs->next, idx++) in preallocate_buffers()
939 subs->dma_device.id = subs->pcm->device << 16 | in preallocate_buffers()
940 subs->stream << 8 | (subs->number + 1) | in preallocate_buffers()
941 (chip->chip_idx + 1) << 24; in preallocate_buffers()
944 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, in preallocate_buffers()
945 &chip->mgr->pci->dev, in preallocate_buffers()
954 struct snd_pcm *pcm; in snd_mixart_pcm_analog() local
957 sprintf(name, "miXart analog %d", chip->chip_idx); in snd_mixart_pcm_analog()
958 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG, in snd_mixart_pcm_analog()
960 MIXART_CAPTURE_STREAMS, &pcm)) < 0) { 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 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL, in snd_mixart_pcm_digital()
993 MIXART_CAPTURE_STREAMS, &pcm)) < 0) { in snd_mixart_pcm_digital()
994 dev_err(chip->card->dev, in snd_mixart_pcm_digital()
995 "cannot create the digital pcm %d\n", chip->chip_idx); in snd_mixart_pcm_digital()
999 pcm->private_data = chip; in snd_mixart_pcm_digital()
1001 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_mixart_playback_ops); in snd_mixart_pcm_digital()
1002 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_mixart_capture_ops); in snd_mixart_pcm_digital()
1004 pcm->info_flags = 0; in snd_mixart_pcm_digital()
1005 pcm->nonatomic = true; in snd_mixart_pcm_digital()
1006 strcpy(pcm->name, name); in snd_mixart_pcm_digital()
1008 preallocate_buffers(chip, pcm); in snd_mixart_pcm_digital()
1010 chip->pcm_dig = pcm; in snd_mixart_pcm_digital()
1022 struct snd_mixart *chip = device->device_data; in snd_mixart_chip_dev_free()
1039 return -ENOMEM; in snd_mixart_create()
1041 chip->card = card; in snd_mixart_create()
1042 chip->chip_idx = idx; in snd_mixart_create()
1043 chip->mgr = mgr; in snd_mixart_create()
1044 card->sync_irq = mgr->irq; in snd_mixart_create()
1051 mgr->chip[idx] = chip; in snd_mixart_create()
1063 if(chip->mgr->board_type == MIXART_DAUGHTER_TYPE_AES) { in snd_mixart_create_pcm()
1080 for (i = 0; i < mgr->num_cards; i++) { in snd_mixart_free()
1081 if (mgr->chip[i]) in snd_mixart_free()
1082 snd_card_free(mgr->chip[i]->card); in snd_mixart_free()
1089 if (mgr->irq >= 0) in snd_mixart_free()
1090 free_irq(mgr->irq, mgr); in snd_mixart_free()
1093 if(mgr->dsp_loaded) { in snd_mixart_free()
1095 dev_dbg(&mgr->pci->dev, "reset miXart !\n"); in snd_mixart_free()
1100 iounmap(mgr->mem[i].virt); in snd_mixart_free()
1102 pci_release_regions(mgr->pci); in snd_mixart_free()
1105 if(mgr->flowinfo.area) { in snd_mixart_free()
1106 snd_dma_free_pages(&mgr->flowinfo); in snd_mixart_free()
1107 mgr->flowinfo.area = NULL; in snd_mixart_free()
1110 if(mgr->bufferinfo.area) { in snd_mixart_free()
1111 snd_dma_free_pages(&mgr->bufferinfo); in snd_mixart_free()
1112 mgr->bufferinfo.area = NULL; in snd_mixart_free()
1115 pci_disable_device(mgr->pci); in snd_mixart_free()
1121 * proc interface
1125 mixart_BA0 proc interface for BAR 0 - read callback
1132 struct mixart_mgr *mgr = entry->private_data; in snd_mixart_BA0_read()
1136 return -EFAULT; in snd_mixart_BA0_read()
1141 mixart_BA1 proc interface for BAR 1 - read callback
1148 struct mixart_mgr *mgr = entry->private_data; in snd_mixart_BA1_read()
1152 return -EFAULT; in snd_mixart_BA1_read()
1168 struct snd_mixart *chip = entry->private_data; in snd_mixart_proc_read()
1171 snd_iprintf(buffer, "Digigram miXart (alsa card %d)\n\n", chip->chip_idx); in snd_mixart_proc_read()
1174 if (chip->mgr->dsp_loaded & ( 1 << MIXART_MOTHERBOARD_ELF_INDEX)) { in snd_mixart_proc_read()
1175 snd_iprintf(buffer, "- hardware -\n"); in snd_mixart_proc_read()
1176 switch (chip->mgr->board_type ) { in snd_mixart_proc_read()
1183 snd_iprintf(buffer, "- system load -\n"); in snd_mixart_proc_read()
1187 ref = readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_SYSTEM_LOAD_OFFSET)); in snd_mixart_proc_read()
1190 …u32 mailbox = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_MAILBX_LOAD_OFFSET)) … in snd_mixart_proc_read()
1191 …u32 streaming = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_STREAM_LOAD_OFFSET)) … in snd_mixart_proc_read()
1192 …u32 interr = 100 * readl_be( MIXART_MEM( chip->mgr, MIXART_PSEUDOREG_PERF_INTERR_LOAD_OFFSET)) … in snd_mixart_proc_read()
1205 /* text interface to read perf and temp meters */ in snd_mixart_proc_init()
1206 snd_card_ro_proc_new(chip->card, "board_info", chip, in snd_mixart_proc_init()
1209 if (! snd_card_proc_new(chip->card, "mixart_BA0", &entry)) { in snd_mixart_proc_init()
1210 entry->content = SNDRV_INFO_CONTENT_DATA; in snd_mixart_proc_init()
1211 entry->private_data = chip->mgr; in snd_mixart_proc_init()
1212 entry->c.ops = &snd_mixart_proc_ops_BA0; in snd_mixart_proc_init()
1213 entry->size = MIXART_BA0_SIZE; in snd_mixart_proc_init()
1215 if (! snd_card_proc_new(chip->card, "mixart_BA1", &entry)) { in snd_mixart_proc_init()
1216 entry->content = SNDRV_INFO_CONTENT_DATA; in snd_mixart_proc_init()
1217 entry->private_data = chip->mgr; in snd_mixart_proc_init()
1218 entry->c.ops = &snd_mixart_proc_ops_BA1; in snd_mixart_proc_init()
1219 entry->size = MIXART_BA1_SIZE; in snd_mixart_proc_init()
1222 /* end of proc interface */
1226 * probe function - creates the card manager
1240 return -ENODEV; in snd_mixart_probe()
1243 return -ENOENT; in snd_mixart_probe()
1252 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) { in snd_mixart_probe()
1253 dev_err(&pci->dev, in snd_mixart_probe()
1256 return -ENXIO; in snd_mixart_probe()
1264 return -ENOMEM; in snd_mixart_probe()
1267 mgr->pci = pci; in snd_mixart_probe()
1268 mgr->irq = -1; in snd_mixart_probe()
1277 mgr->mem[i].phys = pci_resource_start(pci, i); in snd_mixart_probe()
1278 mgr->mem[i].virt = pci_ioremap_bar(pci, i); in snd_mixart_probe()
1279 if (!mgr->mem[i].virt) { in snd_mixart_probe()
1280 dev_err(&pci->dev, "unable to remap resource 0x%lx\n", in snd_mixart_probe()
1281 mgr->mem[i].phys); in snd_mixart_probe()
1283 return -EBUSY; in snd_mixart_probe()
1287 if (request_threaded_irq(pci->irq, snd_mixart_interrupt, in snd_mixart_probe()
1290 dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq); in snd_mixart_probe()
1292 return -EBUSY; in snd_mixart_probe()
1294 mgr->irq = pci->irq; in snd_mixart_probe()
1297 mgr->msg_fifo_readptr = 0; in snd_mixart_probe()
1298 mgr->msg_fifo_writeptr = 0; in snd_mixart_probe()
1300 mutex_init(&mgr->lock); in snd_mixart_probe()
1301 mutex_init(&mgr->msg_lock); in snd_mixart_probe()
1302 init_waitqueue_head(&mgr->msg_sleep); in snd_mixart_probe()
1303 atomic_set(&mgr->msg_processed, 0); in snd_mixart_probe()
1306 mutex_init(&mgr->setup_mutex); in snd_mixart_probe()
1309 mgr->num_cards = MIXART_MAX_CARDS; /* 4 FIXME: configurable? */ in snd_mixart_probe()
1310 for (i = 0; i < mgr->num_cards; i++) { in snd_mixart_probe()
1319 snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); in snd_mixart_probe()
1320 err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE, in snd_mixart_probe()
1324 dev_err(&pci->dev, "cannot allocate the card %d\n", i); in snd_mixart_probe()
1329 strcpy(card->driver, CARD_NAME); in snd_mixart_probe()
1330 snprintf(card->shortname, sizeof(card->shortname), in snd_mixart_probe()
1331 "Digigram miXart [PCM #%d]", i); in snd_mixart_probe()
1332 snprintf(card->longname, sizeof(card->longname), in snd_mixart_probe()
1333 "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", in snd_mixart_probe()
1334 mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); in snd_mixart_probe()
1343 /* init proc interface only for chip0 */ in snd_mixart_probe()
1344 snd_mixart_proc_init(mgr->chip[i]); in snd_mixart_probe()
1353 /* init firmware status (mgr->dsp_loaded reset in hwdep_new) */ in snd_mixart_probe()
1354 mgr->board_type = MIXART_DAUGHTER_TYPE_NONE; in snd_mixart_probe()
1359 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, in snd_mixart_probe()
1360 size, &mgr->flowinfo) < 0) { in snd_mixart_probe()
1362 return -ENOMEM; in snd_mixart_probe()
1365 memset(mgr->flowinfo.area, 0, size); in snd_mixart_probe()
1370 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, in snd_mixart_probe()
1371 size, &mgr->bufferinfo) < 0) { in snd_mixart_probe()
1373 return -ENOMEM; in snd_mixart_probe()
1376 memset(mgr->bufferinfo.area, 0, size); in snd_mixart_probe()