diff options
-rw-r--r-- | sound/pci/asihpi/asihpi.c | 143 | ||||
-rw-r--r-- | sound/pci/asihpi/hpi6000.c | 59 | ||||
-rw-r--r-- | sound/pci/asihpi/hpi6205.c | 8 | ||||
-rw-r--r-- | sound/pci/asihpi/hpicmn.c | 20 | ||||
-rw-r--r-- | sound/pci/asihpi/hpicmn.h | 11 | ||||
-rw-r--r-- | sound/pci/asihpi/hpioctl.c | 62 | ||||
-rw-r--r-- | sound/pci/asihpi/hpios.h | 14 |
7 files changed, 147 insertions, 170 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index f56a1b8358b1..2402801388c9 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "hpi_internal.h" | 25 | #include "hpi_internal.h" |
26 | #include "hpimsginit.h" | 26 | #include "hpimsginit.h" |
27 | #include "hpioctl.h" | 27 | #include "hpioctl.h" |
28 | #include "hpicmn.h" | ||
29 | |||
28 | 30 | ||
29 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
30 | #include <linux/init.h> | 32 | #include <linux/init.h> |
@@ -119,12 +121,7 @@ struct clk_cache { | |||
119 | struct snd_card_asihpi { | 121 | struct snd_card_asihpi { |
120 | struct snd_card *card; | 122 | struct snd_card *card; |
121 | struct pci_dev *pci; | 123 | struct pci_dev *pci; |
122 | u16 adapter_index; | 124 | struct hpi_adapter *hpi; |
123 | u32 serial_number; | ||
124 | u16 type; | ||
125 | u16 version; | ||
126 | u16 num_outstreams; | ||
127 | u16 num_instreams; | ||
128 | 125 | ||
129 | u32 h_mixer; | 126 | u32 h_mixer; |
130 | struct clk_cache cc; | 127 | struct clk_cache cc; |
@@ -497,6 +494,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
497 | 494 | ||
498 | snd_printdd("stream_host_buffer_attach status 0x%x\n", | 495 | snd_printdd("stream_host_buffer_attach status 0x%x\n", |
499 | dpcm->hpi_buffer_attached); | 496 | dpcm->hpi_buffer_attached); |
497 | |||
500 | } | 498 | } |
501 | bytes_per_sec = params_rate(params) * params_channels(params); | 499 | bytes_per_sec = params_rate(params) * params_channels(params); |
502 | width = snd_pcm_format_width(params_format(params)); | 500 | width = snd_pcm_format_width(params_format(params)); |
@@ -993,7 +991,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) | |||
993 | return -ENOMEM; | 991 | return -ENOMEM; |
994 | 992 | ||
995 | err = | 993 | err = |
996 | hpi_outstream_open(card->adapter_index, | 994 | hpi_outstream_open(card->hpi->adapter->index, |
997 | substream->number, &dpcm->h_stream); | 995 | substream->number, &dpcm->h_stream); |
998 | hpi_handle_error(err); | 996 | hpi_handle_error(err); |
999 | if (err) | 997 | if (err) |
@@ -1174,10 +1172,10 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) | |||
1174 | return -ENOMEM; | 1172 | return -ENOMEM; |
1175 | 1173 | ||
1176 | snd_printdd("capture open adapter %d stream %d\n", | 1174 | snd_printdd("capture open adapter %d stream %d\n", |
1177 | card->adapter_index, substream->number); | 1175 | card->hpi->adapter->index, substream->number); |
1178 | 1176 | ||
1179 | err = hpi_handle_error( | 1177 | err = hpi_handle_error( |
1180 | hpi_instream_open(card->adapter_index, | 1178 | hpi_instream_open(card->hpi->adapter->index, |
1181 | substream->number, &dpcm->h_stream)); | 1179 | substream->number, &dpcm->h_stream)); |
1182 | if (err) | 1180 | if (err) |
1183 | kfree(dpcm); | 1181 | kfree(dpcm); |
@@ -1186,7 +1184,6 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) | |||
1186 | if (err) | 1184 | if (err) |
1187 | return -EIO; | 1185 | return -EIO; |
1188 | 1186 | ||
1189 | |||
1190 | init_timer(&dpcm->timer); | 1187 | init_timer(&dpcm->timer); |
1191 | dpcm->timer.data = (unsigned long) dpcm; | 1188 | dpcm->timer.data = (unsigned long) dpcm; |
1192 | dpcm->timer.function = snd_card_asihpi_timer_function; | 1189 | dpcm->timer.function = snd_card_asihpi_timer_function; |
@@ -1243,15 +1240,20 @@ static struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = { | |||
1243 | .pointer = snd_card_asihpi_capture_pointer, | 1240 | .pointer = snd_card_asihpi_capture_pointer, |
1244 | }; | 1241 | }; |
1245 | 1242 | ||
1246 | static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, | 1243 | static int __devinit snd_card_asihpi_pcm_new( |
1247 | int device, int substreams) | 1244 | struct snd_card_asihpi *asihpi, int device) |
1248 | { | 1245 | { |
1249 | struct snd_pcm *pcm; | 1246 | struct snd_pcm *pcm; |
1250 | int err; | 1247 | int err; |
1248 | u16 num_instreams, num_outstreams, x16; | ||
1249 | u32 x32; | ||
1250 | |||
1251 | err = hpi_adapter_get_info(asihpi->hpi->adapter->index, | ||
1252 | &num_outstreams, &num_instreams, | ||
1253 | &x16, &x32, &x16); | ||
1251 | 1254 | ||
1252 | err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, | 1255 | err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, |
1253 | asihpi->num_outstreams, asihpi->num_instreams, | 1256 | num_outstreams, num_instreams, &pcm); |
1254 | &pcm); | ||
1255 | if (err < 0) | 1257 | if (err < 0) |
1256 | return err; | 1258 | return err; |
1257 | /* pointer to ops struct is stored, dont change ops afterwards! */ | 1259 | /* pointer to ops struct is stored, dont change ops afterwards! */ |
@@ -2561,7 +2563,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) | |||
2561 | strcpy(card->mixername, "Asihpi Mixer"); | 2563 | strcpy(card->mixername, "Asihpi Mixer"); |
2562 | 2564 | ||
2563 | err = | 2565 | err = |
2564 | hpi_mixer_open(asihpi->adapter_index, | 2566 | hpi_mixer_open(asihpi->hpi->adapter->index, |
2565 | &asihpi->h_mixer); | 2567 | &asihpi->h_mixer); |
2566 | hpi_handle_error(err); | 2568 | hpi_handle_error(err); |
2567 | if (err) | 2569 | if (err) |
@@ -2679,24 +2681,33 @@ snd_asihpi_proc_read(struct snd_info_entry *entry, | |||
2679 | struct snd_info_buffer *buffer) | 2681 | struct snd_info_buffer *buffer) |
2680 | { | 2682 | { |
2681 | struct snd_card_asihpi *asihpi = entry->private_data; | 2683 | struct snd_card_asihpi *asihpi = entry->private_data; |
2682 | u16 version; | ||
2683 | u32 h_control; | 2684 | u32 h_control; |
2684 | u32 rate = 0; | 2685 | u32 rate = 0; |
2685 | u16 source = 0; | 2686 | u16 source = 0; |
2687 | |||
2688 | u16 num_outstreams; | ||
2689 | u16 num_instreams; | ||
2690 | u16 version; | ||
2691 | u32 serial_number; | ||
2692 | u16 type; | ||
2693 | |||
2686 | int err; | 2694 | int err; |
2687 | 2695 | ||
2688 | snd_iprintf(buffer, "ASIHPI driver proc file\n"); | 2696 | snd_iprintf(buffer, "ASIHPI driver proc file\n"); |
2697 | |||
2698 | hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index, | ||
2699 | &num_outstreams, &num_instreams, | ||
2700 | &version, &serial_number, &type)); | ||
2701 | |||
2689 | snd_iprintf(buffer, | 2702 | snd_iprintf(buffer, |
2690 | "adapter ID=%4X\n_index=%d\n" | 2703 | "Adapter type ASI%4X\nHardware Index %d\n" |
2691 | "num_outstreams=%d\n_num_instreams=%d\n", | 2704 | "%d outstreams\n%d instreams\n", |
2692 | asihpi->type, asihpi->adapter_index, | 2705 | type, asihpi->hpi->adapter->index, |
2693 | asihpi->num_outstreams, asihpi->num_instreams); | 2706 | num_outstreams, num_instreams); |
2694 | 2707 | ||
2695 | version = asihpi->version; | ||
2696 | snd_iprintf(buffer, | 2708 | snd_iprintf(buffer, |
2697 | "serial#=%d\n_hw version %c%d\nDSP code version %03d\n", | 2709 | "Serial#%d\nHardware version %c%d\nDSP code version %03d\n", |
2698 | asihpi->serial_number, ((version >> 3) & 0xf) + 'A', | 2710 | serial_number, ((version >> 3) & 0xf) + 'A', version & 0x7, |
2699 | version & 0x7, | ||
2700 | ((version >> 13) * 100) + ((version >> 7) & 0x3f)); | 2711 | ((version >> 13) * 100) + ((version >> 7) & 0x3f)); |
2701 | 2712 | ||
2702 | err = hpi_mixer_get_control(asihpi->h_mixer, | 2713 | err = hpi_mixer_get_control(asihpi->h_mixer, |
@@ -2704,18 +2715,15 @@ snd_asihpi_proc_read(struct snd_info_entry *entry, | |||
2704 | HPI_CONTROL_SAMPLECLOCK, &h_control); | 2715 | HPI_CONTROL_SAMPLECLOCK, &h_control); |
2705 | 2716 | ||
2706 | if (!err) { | 2717 | if (!err) { |
2707 | err = hpi_sample_clock_get_sample_rate( | 2718 | err = hpi_sample_clock_get_sample_rate(h_control, &rate); |
2708 | h_control, &rate); | ||
2709 | err += hpi_sample_clock_get_source(h_control, &source); | 2719 | err += hpi_sample_clock_get_source(h_control, &source); |
2710 | 2720 | ||
2711 | if (!err) | 2721 | if (!err) |
2712 | snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n", | 2722 | snd_iprintf(buffer, "Sample Clock %dHz, source %s\n", |
2713 | rate, sampleclock_sources[source]); | 2723 | rate, sampleclock_sources[source]); |
2714 | } | 2724 | } |
2715 | |||
2716 | } | 2725 | } |
2717 | 2726 | ||
2718 | |||
2719 | static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi) | 2727 | static void __devinit snd_asihpi_proc_init(struct snd_card_asihpi *asihpi) |
2720 | { | 2728 | { |
2721 | struct snd_info_entry *entry; | 2729 | struct snd_info_entry *entry; |
@@ -2787,35 +2795,34 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2787 | const struct pci_device_id *pci_id) | 2795 | const struct pci_device_id *pci_id) |
2788 | { | 2796 | { |
2789 | int err; | 2797 | int err; |
2790 | 2798 | struct hpi_adapter *hpi; | |
2791 | u16 version; | ||
2792 | int pcm_substreams; | ||
2793 | |||
2794 | struct hpi_adapter *hpi_card; | ||
2795 | struct snd_card *card; | 2799 | struct snd_card *card; |
2796 | struct snd_card_asihpi *asihpi; | 2800 | struct snd_card_asihpi *asihpi; |
2797 | 2801 | ||
2798 | u32 h_control; | 2802 | u32 h_control; |
2799 | u32 h_stream; | 2803 | u32 h_stream; |
2804 | u32 adapter_index; | ||
2800 | 2805 | ||
2801 | static int dev; | 2806 | static int dev; |
2802 | if (dev >= SNDRV_CARDS) | 2807 | if (dev >= SNDRV_CARDS) |
2803 | return -ENODEV; | 2808 | return -ENODEV; |
2804 | 2809 | ||
2805 | /* Should this be enable[hpi_card->index] ? */ | 2810 | /* Should this be enable[hpi->index] ? */ |
2806 | if (!enable[dev]) { | 2811 | if (!enable[dev]) { |
2807 | dev++; | 2812 | dev++; |
2808 | return -ENOENT; | 2813 | return -ENOENT; |
2809 | } | 2814 | } |
2810 | 2815 | ||
2816 | /* Initialise low-level HPI driver */ | ||
2811 | err = asihpi_adapter_probe(pci_dev, pci_id); | 2817 | err = asihpi_adapter_probe(pci_dev, pci_id); |
2812 | if (err < 0) | 2818 | if (err < 0) |
2813 | return err; | 2819 | return err; |
2814 | 2820 | ||
2815 | hpi_card = pci_get_drvdata(pci_dev); | 2821 | hpi = pci_get_drvdata(pci_dev); |
2822 | adapter_index = hpi->adapter->index; | ||
2816 | /* first try to give the card the same index as its hardware index */ | 2823 | /* first try to give the card the same index as its hardware index */ |
2817 | err = snd_card_create(hpi_card->index, | 2824 | err = snd_card_create(adapter_index, |
2818 | id[hpi_card->index], THIS_MODULE, | 2825 | id[adapter_index], THIS_MODULE, |
2819 | sizeof(struct snd_card_asihpi), | 2826 | sizeof(struct snd_card_asihpi), |
2820 | &card); | 2827 | &card); |
2821 | if (err < 0) { | 2828 | if (err < 0) { |
@@ -2829,50 +2836,32 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2829 | return err; | 2836 | return err; |
2830 | snd_printk(KERN_WARNING | 2837 | snd_printk(KERN_WARNING |
2831 | "**** WARNING **** Adapter index %d->ALSA index %d\n", | 2838 | "**** WARNING **** Adapter index %d->ALSA index %d\n", |
2832 | hpi_card->index, card->number); | 2839 | adapter_index, card->number); |
2833 | } | 2840 | } |
2834 | 2841 | ||
2835 | snd_card_set_dev(card, &pci_dev->dev); | 2842 | snd_card_set_dev(card, &pci_dev->dev); |
2836 | 2843 | ||
2837 | asihpi = (struct snd_card_asihpi *) card->private_data; | 2844 | asihpi = card->private_data; |
2838 | asihpi->card = card; | 2845 | asihpi->card = card; |
2839 | asihpi->pci = pci_dev; | 2846 | asihpi->pci = pci_dev; |
2840 | asihpi->adapter_index = hpi_card->index; | 2847 | asihpi->hpi = hpi; |
2841 | hpi_handle_error(hpi_adapter_get_info( | 2848 | |
2842 | asihpi->adapter_index, | 2849 | snd_printk(KERN_INFO "adapter ID=%4X index=%d\n", |
2843 | &asihpi->num_outstreams, | 2850 | asihpi->hpi->adapter->type, adapter_index); |
2844 | &asihpi->num_instreams, | 2851 | |
2845 | &asihpi->version, | 2852 | err = hpi_adapter_get_property(adapter_index, |
2846 | &asihpi->serial_number, &asihpi->type)); | ||
2847 | |||
2848 | version = asihpi->version; | ||
2849 | snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d " | ||
2850 | "num_instreams=%d S/N=%d\n" | ||
2851 | "Hw Version %c%d DSP code version %03d\n", | ||
2852 | asihpi->type, asihpi->adapter_index, | ||
2853 | asihpi->num_outstreams, | ||
2854 | asihpi->num_instreams, asihpi->serial_number, | ||
2855 | ((version >> 3) & 0xf) + 'A', | ||
2856 | version & 0x7, | ||
2857 | ((version >> 13) * 100) + ((version >> 7) & 0x3f)); | ||
2858 | |||
2859 | pcm_substreams = asihpi->num_outstreams; | ||
2860 | if (pcm_substreams < asihpi->num_instreams) | ||
2861 | pcm_substreams = asihpi->num_instreams; | ||
2862 | |||
2863 | err = hpi_adapter_get_property(asihpi->adapter_index, | ||
2864 | HPI_ADAPTER_PROPERTY_CAPS1, | 2853 | HPI_ADAPTER_PROPERTY_CAPS1, |
2865 | NULL, &asihpi->support_grouping); | 2854 | NULL, &asihpi->support_grouping); |
2866 | if (err) | 2855 | if (err) |
2867 | asihpi->support_grouping = 0; | 2856 | asihpi->support_grouping = 0; |
2868 | 2857 | ||
2869 | err = hpi_adapter_get_property(asihpi->adapter_index, | 2858 | err = hpi_adapter_get_property(adapter_index, |
2870 | HPI_ADAPTER_PROPERTY_CAPS2, | 2859 | HPI_ADAPTER_PROPERTY_CAPS2, |
2871 | &asihpi->support_mrx, NULL); | 2860 | &asihpi->support_mrx, NULL); |
2872 | if (err) | 2861 | if (err) |
2873 | asihpi->support_mrx = 0; | 2862 | asihpi->support_mrx = 0; |
2874 | 2863 | ||
2875 | err = hpi_adapter_get_property(asihpi->adapter_index, | 2864 | err = hpi_adapter_get_property(adapter_index, |
2876 | HPI_ADAPTER_PROPERTY_INTERVAL, | 2865 | HPI_ADAPTER_PROPERTY_INTERVAL, |
2877 | NULL, &asihpi->update_interval_frames); | 2866 | NULL, &asihpi->update_interval_frames); |
2878 | if (err) | 2867 | if (err) |
@@ -2881,7 +2870,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2881 | if (!asihpi->can_dma) | 2870 | if (!asihpi->can_dma) |
2882 | asihpi->update_interval_frames *= 2; | 2871 | asihpi->update_interval_frames *= 2; |
2883 | 2872 | ||
2884 | hpi_handle_error(hpi_instream_open(asihpi->adapter_index, | 2873 | hpi_handle_error(hpi_instream_open(adapter_index, |
2885 | 0, &h_stream)); | 2874 | 0, &h_stream)); |
2886 | 2875 | ||
2887 | err = hpi_instream_host_buffer_free(h_stream); | 2876 | err = hpi_instream_host_buffer_free(h_stream); |
@@ -2889,7 +2878,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2889 | 2878 | ||
2890 | hpi_handle_error(hpi_instream_close(h_stream)); | 2879 | hpi_handle_error(hpi_instream_close(h_stream)); |
2891 | 2880 | ||
2892 | err = hpi_adapter_get_property(asihpi->adapter_index, | 2881 | err = hpi_adapter_get_property(adapter_index, |
2893 | HPI_ADAPTER_PROPERTY_CURCHANNELS, | 2882 | HPI_ADAPTER_PROPERTY_CURCHANNELS, |
2894 | &asihpi->in_max_chans, &asihpi->out_max_chans); | 2883 | &asihpi->in_max_chans, &asihpi->out_max_chans); |
2895 | if (err) { | 2884 | if (err) { |
@@ -2906,13 +2895,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2906 | asihpi->in_min_chans = 1; | 2895 | asihpi->in_min_chans = 1; |
2907 | } | 2896 | } |
2908 | 2897 | ||
2909 | snd_printk(KERN_INFO "has dma:%d, grouping:%d, mrx:%d\n", | 2898 | snd_printk(KERN_INFO "Has dma:%d, grouping:%d, mrx:%d\n", |
2910 | asihpi->can_dma, | 2899 | asihpi->can_dma, |
2911 | asihpi->support_grouping, | 2900 | asihpi->support_grouping, |
2912 | asihpi->support_mrx | 2901 | asihpi->support_mrx |
2913 | ); | 2902 | ); |
2914 | 2903 | ||
2915 | err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); | 2904 | err = snd_card_asihpi_pcm_new(asihpi, 0); |
2916 | if (err < 0) { | 2905 | if (err < 0) { |
2917 | snd_printk(KERN_ERR "pcm_new failed\n"); | 2906 | snd_printk(KERN_ERR "pcm_new failed\n"); |
2918 | goto __nodev; | 2907 | goto __nodev; |
@@ -2939,13 +2928,14 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
2939 | 2928 | ||
2940 | strcpy(card->driver, "ASIHPI"); | 2929 | strcpy(card->driver, "ASIHPI"); |
2941 | 2930 | ||
2942 | sprintf(card->shortname, "AudioScience ASI%4X", asihpi->type); | 2931 | sprintf(card->shortname, "AudioScience ASI%4X", |
2932 | asihpi->hpi->adapter->type); | ||
2943 | sprintf(card->longname, "%s %i", | 2933 | sprintf(card->longname, "%s %i", |
2944 | card->shortname, asihpi->adapter_index); | 2934 | card->shortname, adapter_index); |
2945 | err = snd_card_register(card); | 2935 | err = snd_card_register(card); |
2946 | 2936 | ||
2947 | if (!err) { | 2937 | if (!err) { |
2948 | hpi_card->snd_card_asihpi = card; | 2938 | hpi->snd_card = card; |
2949 | dev++; | 2939 | dev++; |
2950 | return 0; | 2940 | return 0; |
2951 | } | 2941 | } |
@@ -2958,10 +2948,9 @@ __nodev: | |||
2958 | 2948 | ||
2959 | static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev) | 2949 | static void __devexit snd_asihpi_remove(struct pci_dev *pci_dev) |
2960 | { | 2950 | { |
2961 | struct hpi_adapter *hpi_card = pci_get_drvdata(pci_dev); | 2951 | struct hpi_adapter *hpi = pci_get_drvdata(pci_dev); |
2962 | 2952 | snd_card_free(hpi->snd_card); | |
2963 | snd_card_free(hpi_card->snd_card_asihpi); | 2953 | hpi->snd_card = NULL; |
2964 | hpi_card->snd_card_asihpi = NULL; | ||
2965 | asihpi_adapter_remove(pci_dev); | 2954 | asihpi_adapter_remove(pci_dev); |
2966 | } | 2955 | } |
2967 | 2956 | ||
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c index 278bec82b6d5..2414d7a2239d 100644 --- a/sound/pci/asihpi/hpi6000.c +++ b/sound/pci/asihpi/hpi6000.c | |||
@@ -231,6 +231,8 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) | |||
231 | static void control_message(struct hpi_adapter_obj *pao, | 231 | static void control_message(struct hpi_adapter_obj *pao, |
232 | struct hpi_message *phm, struct hpi_response *phr) | 232 | struct hpi_message *phm, struct hpi_response *phr) |
233 | { | 233 | { |
234 | struct hpi_hw_obj *phw = pao->priv; | ||
235 | |||
234 | switch (phm->function) { | 236 | switch (phm->function) { |
235 | case HPI_CONTROL_GET_STATE: | 237 | case HPI_CONTROL_GET_STATE: |
236 | if (pao->has_control_cache) { | 238 | if (pao->has_control_cache) { |
@@ -248,17 +250,14 @@ static void control_message(struct hpi_adapter_obj *pao, | |||
248 | break; | 250 | break; |
249 | } | 251 | } |
250 | 252 | ||
251 | if (hpi_check_control_cache(((struct hpi_hw_obj *) | 253 | if (hpi_check_control_cache(phw->p_cache, phm, phr)) |
252 | pao->priv)->p_cache, phm, | ||
253 | phr)) | ||
254 | break; | 254 | break; |
255 | } | 255 | } |
256 | hw_message(pao, phm, phr); | 256 | hw_message(pao, phm, phr); |
257 | break; | 257 | break; |
258 | case HPI_CONTROL_SET_STATE: | 258 | case HPI_CONTROL_SET_STATE: |
259 | hw_message(pao, phm, phr); | 259 | hw_message(pao, phm, phr); |
260 | hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao-> | 260 | hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, phr); |
261 | priv)->p_cache, phm, phr); | ||
262 | break; | 261 | break; |
263 | 262 | ||
264 | case HPI_CONTROL_GET_INFO: | 263 | case HPI_CONTROL_GET_INFO: |
@@ -451,11 +450,11 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
451 | } | 450 | } |
452 | 451 | ||
453 | for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { | 452 | for (dsp_index = 0; dsp_index < MAX_DSPS; dsp_index++) { |
454 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 453 | struct hpi_hw_obj *phw = pao->priv; |
455 | phw->ado[dsp_index].pa_parent_adapter = pao; | 454 | phw->ado[dsp_index].pa_parent_adapter = pao; |
456 | } | 455 | } |
457 | 456 | ||
458 | phr->u.s.adapter_type = ao.adapter_type; | 457 | phr->u.s.adapter_type = ao.type; |
459 | phr->u.s.adapter_index = ao.index; | 458 | phr->u.s.adapter_index = ao.index; |
460 | phr->error = 0; | 459 | phr->error = 0; |
461 | } | 460 | } |
@@ -476,7 +475,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, | |||
476 | u32 dsp_index = 0; | 475 | u32 dsp_index = 0; |
477 | u32 control_cache_size = 0; | 476 | u32 control_cache_size = 0; |
478 | u32 control_cache_count = 0; | 477 | u32 control_cache_count = 0; |
479 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 478 | struct hpi_hw_obj *phw = pao->priv; |
480 | 479 | ||
481 | /* The PCI2040 has the following address map */ | 480 | /* The PCI2040 has the following address map */ |
482 | /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ | 481 | /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */ |
@@ -559,7 +558,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, | |||
559 | if (error) | 558 | if (error) |
560 | return error; | 559 | return error; |
561 | } | 560 | } |
562 | pao->adapter_type = hr0.u.ax.info.adapter_type; | 561 | pao->type = hr0.u.ax.info.adapter_type; |
563 | pao->index = hr0.u.ax.info.adapter_index; | 562 | pao->index = hr0.u.ax.info.adapter_index; |
564 | } | 563 | } |
565 | 564 | ||
@@ -584,9 +583,8 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, | |||
584 | pao->has_control_cache = 1; | 583 | pao->has_control_cache = 1; |
585 | } | 584 | } |
586 | 585 | ||
587 | HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", | 586 | HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n", pao->type, |
588 | pao->adapter_type, pao->index); | 587 | pao->index); |
589 | pao->open = 0; /* upon creation the adapter is closed */ | ||
590 | 588 | ||
591 | if (phw->p_cache) | 589 | if (phw->p_cache) |
592 | phw->p_cache->adap_idx = pao->index; | 590 | phw->p_cache->adap_idx = pao->index; |
@@ -596,7 +594,7 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, | |||
596 | 594 | ||
597 | static void delete_adapter_obj(struct hpi_adapter_obj *pao) | 595 | static void delete_adapter_obj(struct hpi_adapter_obj *pao) |
598 | { | 596 | { |
599 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 597 | struct hpi_hw_obj *phw = pao->priv; |
600 | 598 | ||
601 | if (pao->has_control_cache) | 599 | if (pao->has_control_cache) |
602 | hpi_free_control_cache(phw->p_cache); | 600 | hpi_free_control_cache(phw->p_cache); |
@@ -639,7 +637,7 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao, | |||
639 | static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, | 637 | static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, |
640 | u32 *pos_error_code) | 638 | u32 *pos_error_code) |
641 | { | 639 | { |
642 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 640 | struct hpi_hw_obj *phw = pao->priv; |
643 | short error; | 641 | short error; |
644 | u32 timeout; | 642 | u32 timeout; |
645 | u32 read = 0; | 643 | u32 read = 0; |
@@ -1220,8 +1218,8 @@ static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata, | |||
1220 | static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, | 1218 | static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, |
1221 | u16 dsp_index, u32 hpi_address, u32 *source, u32 count) | 1219 | u16 dsp_index, u32 hpi_address, u32 *source, u32 count) |
1222 | { | 1220 | { |
1223 | struct dsp_obj *pdo = | 1221 | struct hpi_hw_obj *phw = pao->priv; |
1224 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1222 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1225 | u32 time_out = PCI_TIMEOUT; | 1223 | u32 time_out = PCI_TIMEOUT; |
1226 | int c6711_burst_size = 128; | 1224 | int c6711_burst_size = 128; |
1227 | u32 local_hpi_address = hpi_address; | 1225 | u32 local_hpi_address = hpi_address; |
@@ -1258,8 +1256,8 @@ static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao, | |||
1258 | static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, | 1256 | static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, |
1259 | u16 dsp_index, u32 hpi_address, u32 *dest, u32 count) | 1257 | u16 dsp_index, u32 hpi_address, u32 *dest, u32 count) |
1260 | { | 1258 | { |
1261 | struct dsp_obj *pdo = | 1259 | struct hpi_hw_obj *phw = pao->priv; |
1262 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1260 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1263 | u32 time_out = PCI_TIMEOUT; | 1261 | u32 time_out = PCI_TIMEOUT; |
1264 | int c6711_burst_size = 16; | 1262 | int c6711_burst_size = 16; |
1265 | u32 local_hpi_address = hpi_address; | 1263 | u32 local_hpi_address = hpi_address; |
@@ -1298,7 +1296,7 @@ static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao, | |||
1298 | static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, | 1296 | static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, |
1299 | u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr) | 1297 | u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr) |
1300 | { | 1298 | { |
1301 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 1299 | struct hpi_hw_obj *phw = pao->priv; |
1302 | struct dsp_obj *pdo = &phw->ado[dsp_index]; | 1300 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1303 | u32 timeout; | 1301 | u32 timeout; |
1304 | u16 ack; | 1302 | u16 ack; |
@@ -1414,8 +1412,8 @@ static short hpi6000_send_data_check_adr(u32 address, u32 length_in_dwords) | |||
1414 | static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, | 1412 | static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, |
1415 | struct hpi_message *phm, struct hpi_response *phr) | 1413 | struct hpi_message *phm, struct hpi_response *phr) |
1416 | { | 1414 | { |
1417 | struct dsp_obj *pdo = | 1415 | struct hpi_hw_obj *phw = pao->priv; |
1418 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1416 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1419 | u32 data_sent = 0; | 1417 | u32 data_sent = 0; |
1420 | u16 ack; | 1418 | u16 ack; |
1421 | u32 length, address; | 1419 | u32 length, address; |
@@ -1487,8 +1485,8 @@ static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index, | |||
1487 | static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, | 1485 | static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index, |
1488 | struct hpi_message *phm, struct hpi_response *phr) | 1486 | struct hpi_message *phm, struct hpi_response *phr) |
1489 | { | 1487 | { |
1490 | struct dsp_obj *pdo = | 1488 | struct hpi_hw_obj *phw = pao->priv; |
1491 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1489 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1492 | u32 data_got = 0; | 1490 | u32 data_got = 0; |
1493 | u16 ack; | 1491 | u16 ack; |
1494 | u32 length, address; | 1492 | u32 length, address; |
@@ -1551,8 +1549,8 @@ static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo) | |||
1551 | static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, | 1549 | static short hpi6000_send_host_command(struct hpi_adapter_obj *pao, |
1552 | u16 dsp_index, u32 host_cmd) | 1550 | u16 dsp_index, u32 host_cmd) |
1553 | { | 1551 | { |
1554 | struct dsp_obj *pdo = | 1552 | struct hpi_hw_obj *phw = pao->priv; |
1555 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1553 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1556 | u32 timeout = TIMEOUT; | 1554 | u32 timeout = TIMEOUT; |
1557 | 1555 | ||
1558 | /* set command */ | 1556 | /* set command */ |
@@ -1577,7 +1575,7 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao, | |||
1577 | { | 1575 | { |
1578 | u32 hPI_error; | 1576 | u32 hPI_error; |
1579 | 1577 | ||
1580 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 1578 | struct hpi_hw_obj *phw = pao->priv; |
1581 | 1579 | ||
1582 | /* read the error bits from the PCI2040 */ | 1580 | /* read the error bits from the PCI2040 */ |
1583 | hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); | 1581 | hPI_error = ioread32(phw->dw2040_HPICSR + HPI_ERROR_REPORT); |
@@ -1597,8 +1595,8 @@ static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao, | |||
1597 | static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, | 1595 | static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index, |
1598 | u32 ack_value) | 1596 | u32 ack_value) |
1599 | { | 1597 | { |
1600 | struct dsp_obj *pdo = | 1598 | struct hpi_hw_obj *phw = pao->priv; |
1601 | &(*(struct hpi_hw_obj *)pao->priv).ado[dsp_index]; | 1599 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1602 | u32 ack = 0L; | 1600 | u32 ack = 0L; |
1603 | u32 timeout; | 1601 | u32 timeout; |
1604 | u32 hPIC = 0L; | 1602 | u32 hPIC = 0L; |
@@ -1640,7 +1638,7 @@ static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao, | |||
1640 | struct hpi_message *phm) | 1638 | struct hpi_message *phm) |
1641 | { | 1639 | { |
1642 | const u16 dsp_index = 0; | 1640 | const u16 dsp_index = 0; |
1643 | struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv; | 1641 | struct hpi_hw_obj *phw = pao->priv; |
1644 | struct dsp_obj *pdo = &phw->ado[dsp_index]; | 1642 | struct dsp_obj *pdo = &phw->ado[dsp_index]; |
1645 | u32 timeout; | 1643 | u32 timeout; |
1646 | u32 cache_dirty_flag; | 1644 | u32 cache_dirty_flag; |
@@ -1740,7 +1738,8 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, | |||
1740 | { | 1738 | { |
1741 | u16 error = 0; | 1739 | u16 error = 0; |
1742 | u16 dsp_index = 0; | 1740 | u16 dsp_index = 0; |
1743 | u16 num_dsp = ((struct hpi_hw_obj *)pao->priv)->num_dsp; | 1741 | struct hpi_hw_obj *phw = pao->priv; |
1742 | u16 num_dsp = phw->num_dsp; | ||
1744 | 1743 | ||
1745 | if (num_dsp < 2) | 1744 | if (num_dsp < 2) |
1746 | dsp_index = 0; | 1745 | dsp_index = 0; |
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index 95d1cd5804c0..e3d0f55ad6c4 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c | |||
@@ -488,7 +488,7 @@ static void subsys_create_adapter(struct hpi_message *phm, | |||
488 | return; | 488 | return; |
489 | } | 489 | } |
490 | 490 | ||
491 | phr->u.s.adapter_type = ao.adapter_type; | 491 | phr->u.s.adapter_type = ao.type; |
492 | phr->u.s.adapter_index = ao.index; | 492 | phr->u.s.adapter_index = ao.index; |
493 | phr->error = 0; | 493 | phr->error = 0; |
494 | } | 494 | } |
@@ -503,7 +503,7 @@ static void adapter_delete(struct hpi_adapter_obj *pao, | |||
503 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; | 503 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | phw = (struct hpi_hw_obj *)pao->priv; | 506 | phw = pao->priv; |
507 | /* reset adapter h/w */ | 507 | /* reset adapter h/w */ |
508 | /* Reset C6713 #1 */ | 508 | /* Reset C6713 #1 */ |
509 | boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); | 509 | boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); |
@@ -652,7 +652,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, | |||
652 | if (hr.error) | 652 | if (hr.error) |
653 | return hr.error; | 653 | return hr.error; |
654 | 654 | ||
655 | pao->adapter_type = hr.u.ax.info.adapter_type; | 655 | pao->type = hr.u.ax.info.adapter_type; |
656 | pao->index = hr.u.ax.info.adapter_index; | 656 | pao->index = hr.u.ax.info.adapter_index; |
657 | 657 | ||
658 | max_streams = | 658 | max_streams = |
@@ -665,8 +665,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, | |||
665 | hr.u.ax.info.serial_number); | 665 | hr.u.ax.info.serial_number); |
666 | } | 666 | } |
667 | 667 | ||
668 | pao->open = 0; /* upon creation the adapter is closed */ | ||
669 | |||
670 | if (phw->p_cache) | 668 | if (phw->p_cache) |
671 | phw->p_cache->adap_idx = pao->index; | 669 | phw->p_cache->adap_idx = pao->index; |
672 | 670 | ||
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c index 358853a047c2..c54a49f0e6d1 100644 --- a/sound/pci/asihpi/hpicmn.c +++ b/sound/pci/asihpi/hpicmn.c | |||
@@ -68,7 +68,7 @@ u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr) | |||
68 | u16 hpi_add_adapter(struct hpi_adapter_obj *pao) | 68 | u16 hpi_add_adapter(struct hpi_adapter_obj *pao) |
69 | { | 69 | { |
70 | u16 retval = 0; | 70 | u16 retval = 0; |
71 | /*HPI_ASSERT(pao->wAdapterType); */ | 71 | /*HPI_ASSERT(pao->type); */ |
72 | 72 | ||
73 | hpios_alistlock_lock(&adapters); | 73 | hpios_alistlock_lock(&adapters); |
74 | 74 | ||
@@ -77,13 +77,13 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao) | |||
77 | goto unlock; | 77 | goto unlock; |
78 | } | 78 | } |
79 | 79 | ||
80 | if (adapters.adapter[pao->index].adapter_type) { | 80 | if (adapters.adapter[pao->index].type) { |
81 | int a; | 81 | int a; |
82 | for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { | 82 | for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { |
83 | if (!adapters.adapter[a].adapter_type) { | 83 | if (!adapters.adapter[a].type) { |
84 | HPI_DEBUG_LOG(WARNING, | 84 | HPI_DEBUG_LOG(WARNING, |
85 | "ASI%X duplicate index %d moved to %d\n", | 85 | "ASI%X duplicate index %d moved to %d\n", |
86 | pao->adapter_type, pao->index, a); | 86 | pao->type, pao->index, a); |
87 | pao->index = a; | 87 | pao->index = a; |
88 | break; | 88 | break; |
89 | } | 89 | } |
@@ -104,13 +104,13 @@ unlock: | |||
104 | 104 | ||
105 | void hpi_delete_adapter(struct hpi_adapter_obj *pao) | 105 | void hpi_delete_adapter(struct hpi_adapter_obj *pao) |
106 | { | 106 | { |
107 | if (!pao->adapter_type) { | 107 | if (!pao->type) { |
108 | HPI_DEBUG_LOG(ERROR, "removing null adapter?\n"); | 108 | HPI_DEBUG_LOG(ERROR, "removing null adapter?\n"); |
109 | return; | 109 | return; |
110 | } | 110 | } |
111 | 111 | ||
112 | hpios_alistlock_lock(&adapters); | 112 | hpios_alistlock_lock(&adapters); |
113 | if (adapters.adapter[pao->index].adapter_type) | 113 | if (adapters.adapter[pao->index].type) |
114 | adapters.gw_num_adapters--; | 114 | adapters.gw_num_adapters--; |
115 | memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0])); | 115 | memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0])); |
116 | hpios_alistlock_unlock(&adapters); | 116 | hpios_alistlock_unlock(&adapters); |
@@ -132,7 +132,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | pao = &adapters.adapter[adapter_index]; | 134 | pao = &adapters.adapter[adapter_index]; |
135 | if (pao->adapter_type != 0) { | 135 | if (pao->type != 0) { |
136 | /* | 136 | /* |
137 | HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", | 137 | HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", |
138 | wAdapterIndex); | 138 | wAdapterIndex); |
@@ -165,7 +165,7 @@ static void subsys_get_adapter(struct hpi_message *phm, | |||
165 | 165 | ||
166 | /* find the nCount'th nonzero adapter in array */ | 166 | /* find the nCount'th nonzero adapter in array */ |
167 | for (index = 0; index < HPI_MAX_ADAPTERS; index++) { | 167 | for (index = 0; index < HPI_MAX_ADAPTERS; index++) { |
168 | if (adapters.adapter[index].adapter_type) { | 168 | if (adapters.adapter[index].type) { |
169 | if (!count) | 169 | if (!count) |
170 | break; | 170 | break; |
171 | count--; | 171 | count--; |
@@ -174,11 +174,11 @@ static void subsys_get_adapter(struct hpi_message *phm, | |||
174 | 174 | ||
175 | if (index < HPI_MAX_ADAPTERS) { | 175 | if (index < HPI_MAX_ADAPTERS) { |
176 | phr->u.s.adapter_index = adapters.adapter[index].index; | 176 | phr->u.s.adapter_index = adapters.adapter[index].index; |
177 | phr->u.s.adapter_type = adapters.adapter[index].adapter_type; | 177 | phr->u.s.adapter_type = adapters.adapter[index].type; |
178 | } else { | 178 | } else { |
179 | phr->u.s.adapter_index = 0; | 179 | phr->u.s.adapter_index = 0; |
180 | phr->u.s.adapter_type = 0; | 180 | phr->u.s.adapter_type = 0; |
181 | phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER; | 181 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
diff --git a/sound/pci/asihpi/hpicmn.h b/sound/pci/asihpi/hpicmn.h index 67cc1b0bd05f..e44121283047 100644 --- a/sound/pci/asihpi/hpicmn.h +++ b/sound/pci/asihpi/hpicmn.h | |||
@@ -18,12 +18,15 @@ | |||
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | struct hpi_adapter_obj; | ||
22 | |||
23 | /* a function that takes an adapter obj and returns an int */ | ||
24 | typedef int adapter_int_func(struct hpi_adapter_obj *pao); | ||
25 | |||
21 | struct hpi_adapter_obj { | 26 | struct hpi_adapter_obj { |
22 | struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */ | 27 | struct hpi_pci pci; /* PCI info - bus#,dev#,address etc */ |
23 | u16 adapter_type; /* ASI6701 etc */ | 28 | u16 type; /* 0x6644 == ASI6644 etc */ |
24 | u16 index; /* */ | 29 | u16 index; |
25 | u16 open; /* =1 when adapter open */ | ||
26 | u16 mixer_open; | ||
27 | 30 | ||
28 | struct hpios_spinlock dsp_lock; | 31 | struct hpios_spinlock dsp_lock; |
29 | 32 | ||
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 75f7a2d11a3e..609156205562 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c | |||
@@ -66,9 +66,7 @@ static struct hpi_adapter adapters[HPI_MAX_ADAPTERS]; | |||
66 | static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr, | 66 | static void hpi_send_recv_f(struct hpi_message *phm, struct hpi_response *phr, |
67 | struct file *file) | 67 | struct file *file) |
68 | { | 68 | { |
69 | int adapter = phm->adapter_index; | 69 | if ((phm->adapter_index >= HPI_MAX_ADAPTERS) |
70 | |||
71 | if ((adapter >= HPI_MAX_ADAPTERS || adapter < 0) | ||
72 | && (phm->object != HPI_OBJ_SUBSYSTEM)) | 70 | && (phm->object != HPI_OBJ_SUBSYSTEM)) |
73 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; | 71 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
74 | else | 72 | else |
@@ -179,19 +177,14 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
179 | } else { | 177 | } else { |
180 | u16 __user *ptr = NULL; | 178 | u16 __user *ptr = NULL; |
181 | u32 size = 0; | 179 | u32 size = 0; |
182 | u32 adapter_present; | ||
183 | /* -1=no data 0=read from user mem, 1=write to user mem */ | 180 | /* -1=no data 0=read from user mem, 1=write to user mem */ |
184 | int wrflag = -1; | 181 | int wrflag = -1; |
185 | struct hpi_adapter *pa; | 182 | struct hpi_adapter *pa = NULL; |
186 | 183 | ||
187 | if (hm->h.adapter_index < HPI_MAX_ADAPTERS) { | 184 | if (hm->h.adapter_index < ARRAY_SIZE(adapters)) |
188 | pa = &adapters[hm->h.adapter_index]; | 185 | pa = &adapters[hm->h.adapter_index]; |
189 | adapter_present = pa->type; | ||
190 | } else { | ||
191 | adapter_present = 0; | ||
192 | } | ||
193 | 186 | ||
194 | if (!adapter_present) { | 187 | if (!pa || !pa->adapter || !pa->adapter->type) { |
195 | hpi_init_response(&hr->r0, hm->h.object, | 188 | hpi_init_response(&hr->r0, hm->h.object, |
196 | hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER); | 189 | hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER); |
197 | 190 | ||
@@ -318,6 +311,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
318 | const struct pci_device_id *pci_id) | 311 | const struct pci_device_id *pci_id) |
319 | { | 312 | { |
320 | int idx, nm; | 313 | int idx, nm; |
314 | int adapter_index; | ||
321 | unsigned int memlen; | 315 | unsigned int memlen; |
322 | struct hpi_message hm; | 316 | struct hpi_message hm; |
323 | struct hpi_response hr; | 317 | struct hpi_response hr; |
@@ -346,8 +340,6 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
346 | 340 | ||
347 | hm.adapter_index = HPI_ADAPTER_INDEX_INVALID; | 341 | hm.adapter_index = HPI_ADAPTER_INDEX_INVALID; |
348 | 342 | ||
349 | adapter.pci = pci_dev; | ||
350 | |||
351 | nm = HPI_MAX_ADAPTER_MEM_SPACES; | 343 | nm = HPI_MAX_ADAPTER_MEM_SPACES; |
352 | 344 | ||
353 | for (idx = 0; idx < nm; idx++) { | 345 | for (idx = 0; idx < nm; idx++) { |
@@ -356,18 +348,16 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
356 | 348 | ||
357 | if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { | 349 | if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { |
358 | memlen = pci_resource_len(pci_dev, idx); | 350 | memlen = pci_resource_len(pci_dev, idx); |
359 | adapter.ap_remapped_mem_base[idx] = | 351 | pci.ap_mem_base[idx] = |
360 | ioremap(pci_resource_start(pci_dev, idx), | 352 | ioremap(pci_resource_start(pci_dev, idx), |
361 | memlen); | 353 | memlen); |
362 | if (!adapter.ap_remapped_mem_base[idx]) { | 354 | if (!pci.ap_mem_base[idx]) { |
363 | HPI_DEBUG_LOG(ERROR, | 355 | HPI_DEBUG_LOG(ERROR, |
364 | "ioremap failed, aborting\n"); | 356 | "ioremap failed, aborting\n"); |
365 | /* unmap previously mapped pci mem space */ | 357 | /* unmap previously mapped pci mem space */ |
366 | goto err; | 358 | goto err; |
367 | } | 359 | } |
368 | } | 360 | } |
369 | |||
370 | pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx]; | ||
371 | } | 361 | } |
372 | 362 | ||
373 | pci.pci_dev = pci_dev; | 363 | pci.pci_dev = pci_dev; |
@@ -379,6 +369,9 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
379 | if (hr.error) | 369 | if (hr.error) |
380 | goto err; | 370 | goto err; |
381 | 371 | ||
372 | adapter_index = hr.u.s.adapter_index; | ||
373 | adapter.adapter = hpi_find_adapter(adapter_index); | ||
374 | |||
382 | if (prealloc_stream_buf) { | 375 | if (prealloc_stream_buf) { |
383 | adapter.p_buffer = vmalloc(prealloc_stream_buf); | 376 | adapter.p_buffer = vmalloc(prealloc_stream_buf); |
384 | if (!adapter.p_buffer) { | 377 | if (!adapter.p_buffer) { |
@@ -390,36 +383,32 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, | |||
390 | } | 383 | } |
391 | } | 384 | } |
392 | 385 | ||
393 | adapter.index = hr.u.s.adapter_index; | ||
394 | adapter.type = hr.u.s.adapter_type; | ||
395 | |||
396 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, | 386 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, |
397 | HPI_ADAPTER_OPEN); | 387 | HPI_ADAPTER_OPEN); |
398 | hm.adapter_index = adapter.index; | 388 | hm.adapter_index = adapter.adapter->index; |
399 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); | 389 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); |
400 | 390 | ||
401 | if (hr.error) | 391 | if (hr.error) |
402 | goto err; | 392 | goto err; |
403 | 393 | ||
404 | adapter.snd_card_asihpi = NULL; | ||
405 | /* WARNING can't init mutex in 'adapter' | 394 | /* WARNING can't init mutex in 'adapter' |
406 | * and then copy it to adapters[] ?!?! | 395 | * and then copy it to adapters[] ?!?! |
407 | */ | 396 | */ |
408 | adapters[adapter.index] = adapter; | 397 | adapters[adapter_index] = adapter; |
409 | mutex_init(&adapters[adapter.index].mutex); | 398 | mutex_init(&adapters[adapter_index].mutex); |
410 | pci_set_drvdata(pci_dev, &adapters[adapter.index]); | 399 | pci_set_drvdata(pci_dev, &adapters[adapter_index]); |
411 | 400 | ||
412 | dev_printk(KERN_INFO, &pci_dev->dev, | 401 | dev_printk(KERN_INFO, &pci_dev->dev, |
413 | "probe succeeded for ASI%04X HPI index %d\n", adapter.type, | 402 | "probe succeeded for ASI%04X HPI index %d\n", |
414 | adapter.index); | 403 | adapter.adapter->type, adapter_index); |
415 | 404 | ||
416 | return 0; | 405 | return 0; |
417 | 406 | ||
418 | err: | 407 | err: |
419 | for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { | 408 | for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { |
420 | if (adapter.ap_remapped_mem_base[idx]) { | 409 | if (pci.ap_mem_base[idx]) { |
421 | iounmap(adapter.ap_remapped_mem_base[idx]); | 410 | iounmap(pci.ap_mem_base[idx]); |
422 | adapter.ap_remapped_mem_base[idx] = NULL; | 411 | pci.ap_mem_base[idx] = NULL; |
423 | } | 412 | } |
424 | } | 413 | } |
425 | 414 | ||
@@ -438,19 +427,20 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) | |||
438 | struct hpi_message hm; | 427 | struct hpi_message hm; |
439 | struct hpi_response hr; | 428 | struct hpi_response hr; |
440 | struct hpi_adapter *pa; | 429 | struct hpi_adapter *pa; |
430 | struct hpi_pci pci; | ||
431 | |||
441 | pa = pci_get_drvdata(pci_dev); | 432 | pa = pci_get_drvdata(pci_dev); |
433 | pci = pa->adapter->pci; | ||
442 | 434 | ||
443 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, | 435 | hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, |
444 | HPI_ADAPTER_DELETE); | 436 | HPI_ADAPTER_DELETE); |
445 | hm.adapter_index = pa->index; | 437 | hm.adapter_index = pa->adapter->index; |
446 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); | 438 | hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); |
447 | 439 | ||
448 | /* unmap PCI memory space, mapped during device init. */ | 440 | /* unmap PCI memory space, mapped during device init. */ |
449 | for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { | 441 | for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { |
450 | if (pa->ap_remapped_mem_base[idx]) { | 442 | if (pci.ap_mem_base[idx]) |
451 | iounmap(pa->ap_remapped_mem_base[idx]); | 443 | iounmap(pci.ap_mem_base[idx]); |
452 | pa->ap_remapped_mem_base[idx] = NULL; | ||
453 | } | ||
454 | } | 444 | } |
455 | 445 | ||
456 | if (pa->p_buffer) | 446 | if (pa->p_buffer) |
@@ -462,7 +452,7 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) | |||
462 | "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n", | 452 | "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n", |
463 | pci_dev->vendor, pci_dev->device, | 453 | pci_dev->vendor, pci_dev->device, |
464 | pci_dev->subsystem_vendor, pci_dev->subsystem_device, | 454 | pci_dev->subsystem_vendor, pci_dev->subsystem_device, |
465 | pci_dev->devfn, pa->index); | 455 | pci_dev->devfn, pa->adapter->index); |
466 | 456 | ||
467 | memset(pa, 0, sizeof(*pa)); | 457 | memset(pa, 0, sizeof(*pa)); |
468 | } | 458 | } |
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h index d59a05944537..c5cef113c209 100644 --- a/sound/pci/asihpi/hpios.h +++ b/sound/pci/asihpi/hpios.h | |||
@@ -149,20 +149,18 @@ static inline void cond_unlock(struct hpios_spinlock *l) | |||
149 | #define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) | 149 | #define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) |
150 | #define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock)) | 150 | #define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock)) |
151 | 151 | ||
152 | struct snd_card; | ||
153 | |||
154 | /** pci drvdata points to an instance of this struct */ | ||
152 | struct hpi_adapter { | 155 | struct hpi_adapter { |
156 | struct hpi_adapter_obj *adapter; | ||
157 | struct snd_card *snd_card; | ||
158 | |||
153 | /* mutex prevents contention for one card | 159 | /* mutex prevents contention for one card |
154 | between multiple user programs (via ioctl) */ | 160 | between multiple user programs (via ioctl) */ |
155 | struct mutex mutex; | 161 | struct mutex mutex; |
156 | u16 index; | ||
157 | u16 type; | ||
158 | |||
159 | /* ALSA card structure */ | ||
160 | void *snd_card_asihpi; | ||
161 | |||
162 | char *p_buffer; | 162 | char *p_buffer; |
163 | size_t buffer_size; | 163 | size_t buffer_size; |
164 | struct pci_dev *pci; | ||
165 | void __iomem *ap_remapped_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; | ||
166 | }; | 164 | }; |
167 | 165 | ||
168 | #endif | 166 | #endif |