25 #include <linux/module.h>
27 #include <linux/pci.h>
29 #include <linux/slab.h>
54 static const char card_name[] =
"LX6464ES";
57 #define PCI_DEVICE_ID_PLX_LX6464ES PCI_DEVICE_ID_PLX_9056
76 #define CHIPSC_RESET_XILINX (1L<<16)
105 static int lx_hardware_open(
struct lx6464es *chip,
115 snd_printd(
LXP "allocating pipe for %d channels\n", channels);
122 err = lx_set_granularity(chip, period_size);
132 static int lx_hardware_start(
struct lx6464es *chip,
164 static int lx_hardware_stop(
struct lx6464es *chip,
195 static int lx_hardware_close(
struct lx6464es *chip,
223 runtime->
hw = lx_caps;
238 board_rate, board_rate);
252 "could not constrain period size\n");
292 spin_unlock_irqrestore(&chip->
lock, flags);
309 err = lx_hardware_stop(chip, substream);
312 "Error code %d\n", err);
316 err = lx_hardware_close(chip, substream);
319 "Error code %d\n", err);
325 err = lx_hardware_open(chip, substream);
328 "Error code %d\n", err);
332 err = lx_hardware_start(chip, substream);
335 "Error code %d\n", err);
377 return lx_pcm_hw_params(substream, hw_params, 0);
383 return lx_pcm_hw_params(substream, hw_params, 1);
396 err = lx_hardware_stop(chip, substream);
399 "Error code %d\n", err);
403 err = lx_hardware_close(chip, substream);
406 "Error code %d\n", err);
428 const unsigned int is_capture = lx_stream->
is_capture;
434 const u32 period_size = substream->
runtime->period_size;
435 const u32 periods = substream->
runtime->periods;
444 for (i = 0; i != periods; ++
i) {
445 u32 buffer_index = 0;
457 buffer_index, (
void *)buf, period_bytes);
461 err =
lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
462 snd_printdd(
LXP "starting: needed %d, freed %d\n", needed, freed);
465 err = lx_stream_start(chip, 0, is_capture);
474 static void lx_trigger_stop(
struct lx6464es *chip,
struct lx_stream *lx_stream)
476 const unsigned int is_capture = lx_stream->
is_capture;
480 err = lx_stream_stop(chip, 0, is_capture);
488 static void lx_trigger_tasklet_dispatch_stream(
struct lx6464es *chip,
489 struct lx_stream *lx_stream)
491 switch (lx_stream->
status) {
493 lx_trigger_start(chip, lx_stream);
497 lx_trigger_stop(chip, lx_stream);
505 static void lx_trigger_tasklet(
unsigned long data)
515 spin_unlock_irqrestore(&chip->
lock, flags);
518 static int lx_pcm_trigger_dispatch(
struct lx6464es *chip,
519 struct lx_stream *lx_stream,
int cmd)
552 return lx_pcm_trigger_dispatch(chip, stream, cmd);
555 static int snd_lx6464es_free(
struct lx6464es *chip)
601 for (i = 0; i != 100; ++
i) {
647 snd_printd(
LXP "Xilinx/MicroBlaze access test successful\n");
676 for (i = 0; i != 1000; ++
i) {
680 goto ethersound_initialized;
685 "ethersound could not be initialized after %dms\n", i);
688 ethersound_initialized:
707 (dsp_version>>16) & 0xff, (dsp_version>>8) & 0xff,
730 static int lx_set_granularity(
struct lx6464es *chip,
u32 gran)
738 while ((snapped_gran < gran) &&
752 if (snapped_gran != gran)
770 err = lx_init_xilinx_reset(chip);
775 err = lx_init_xilinx_test(chip);
780 err = lx_init_ethersound_config(chip);
788 for (i = 0; i != 1000; ++
i) {
801 snd_printk(
LXP "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n",
805 err = lx_init_get_version_features(chip);
818 .close = lx_pcm_close,
820 .prepare = lx_pcm_prepare,
821 .hw_params = lx_pcm_hw_params_playback,
822 .hw_free = lx_pcm_hw_free,
823 .trigger = lx_pcm_trigger,
824 .pointer = lx_pcm_stream_pointer,
829 .close = lx_pcm_close,
831 .prepare = lx_pcm_prepare,
832 .hw_params = lx_pcm_hw_params_capture,
833 .hw_free = lx_pcm_hw_free,
834 .trigger = lx_pcm_trigger,
835 .pointer = lx_pcm_stream_pointer,
877 static int lx_control_playback_info(
struct snd_kcontrol *kcontrol,
887 static int lx_control_playback_get(
struct snd_kcontrol *kcontrol,
895 static int lx_control_playback_put(
struct snd_kcontrol *kcontrol,
902 if (current_value != ucontrol->
value.integer.value[0]) {
912 .name =
"PCM Playback Switch",
916 .info = lx_control_playback_info,
917 .get = lx_control_playback_get,
918 .put = lx_control_playback_put
931 snd_iprintf(buffer,
"capture levels:\n");
936 for (i = 0; i != 8; ++
i) {
937 for (j = 0; j != 8; ++
j)
938 snd_iprintf(buffer,
"%08x ", levels[i*8+j]);
939 snd_iprintf(buffer,
"\n");
942 snd_iprintf(buffer,
"\nplayback levels:\n");
948 for (i = 0; i != 8; ++
i) {
949 for (j = 0; j != 8; ++
j)
950 snd_iprintf(buffer,
"%08x ", levels[i*8+j]);
951 snd_iprintf(buffer,
"\n");
954 snd_iprintf(buffer,
"\n");
960 int err = snd_card_proc_new(card,
"levels", &entry);
964 snd_info_set_text_ops(entry, chip, lx_proc_levels_read);
995 "32bit PCI busmaster DMA\n");
1015 (
unsigned long)chip);
1017 (
unsigned long)chip);
1019 (
unsigned long)chip);
1024 goto request_regions_failed;
1028 chip->port_plx_remapped =
ioport_map(chip->port_plx,
1035 KBUILD_MODNAME, chip);
1038 goto request_irq_failed;
1040 chip->irq = pci->
irq;
1044 goto device_new_failed;
1046 err = lx_init_dsp(chip);
1052 err = lx_pcm_create(chip);
1056 err = lx_proc_create(card, chip);
1076 request_regions_failed:
1106 err = snd_lx6464es_create(card, pci, &chip);
1113 sprintf(card->
id,
"LX6464ES_%02X%02X%02X",
1129 pci_set_drvdata(pci, card);
1142 pci_set_drvdata(pci,
NULL);
1147 .
name = KBUILD_MODNAME,
1148 .id_table = snd_lx6464es_ids,
1149 .probe = snd_lx6464es_probe,