diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-21 02:54:06 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:30:08 -0500 |
commit | c57cccc0382fedd95373ffdb192f45d278210686 (patch) | |
tree | 92c525221ff7471df52d61fe8506cccd6b0fa606 | |
parent | 7f0b89465bb94eb3273ea5af5e009332351a54c9 (diff) |
[ALSA] oxygen: optimize snd_pcm_hardware structures
Add one more indirection to the lookup of the snd_pcm_hardware
structures so that we can save the space of the duplicate ones.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | sound/pci/oxygen/oxygen_pcm.c | 229 |
1 files changed, 79 insertions, 150 deletions
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 200290099cbc..272ef08f0a28 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -24,155 +24,84 @@ | |||
24 | #include <sound/pcm_params.h> | 24 | #include <sound/pcm_params.h> |
25 | #include "oxygen.h" | 25 | #include "oxygen.h" |
26 | 26 | ||
27 | static struct snd_pcm_hardware oxygen_hardware[PCM_COUNT] = { | 27 | static const struct snd_pcm_hardware oxygen_stereo_hardware = { |
28 | [PCM_A] = { | 28 | .info = SNDRV_PCM_INFO_MMAP | |
29 | .info = SNDRV_PCM_INFO_MMAP | | 29 | SNDRV_PCM_INFO_MMAP_VALID | |
30 | SNDRV_PCM_INFO_MMAP_VALID | | 30 | SNDRV_PCM_INFO_INTERLEAVED | |
31 | SNDRV_PCM_INFO_INTERLEAVED | | 31 | SNDRV_PCM_INFO_PAUSE | |
32 | SNDRV_PCM_INFO_PAUSE | | 32 | SNDRV_PCM_INFO_SYNC_START, |
33 | SNDRV_PCM_INFO_SYNC_START, | 33 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
34 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 34 | SNDRV_PCM_FMTBIT_S32_LE, |
35 | SNDRV_PCM_FMTBIT_S32_LE, | 35 | .rates = SNDRV_PCM_RATE_32000 | |
36 | .rates = SNDRV_PCM_RATE_32000 | | 36 | SNDRV_PCM_RATE_44100 | |
37 | SNDRV_PCM_RATE_44100 | | 37 | SNDRV_PCM_RATE_48000 | |
38 | SNDRV_PCM_RATE_48000 | | 38 | SNDRV_PCM_RATE_64000 | |
39 | SNDRV_PCM_RATE_64000 | | 39 | SNDRV_PCM_RATE_88200 | |
40 | SNDRV_PCM_RATE_88200 | | 40 | SNDRV_PCM_RATE_96000 | |
41 | SNDRV_PCM_RATE_96000 | | 41 | SNDRV_PCM_RATE_176400 | |
42 | SNDRV_PCM_RATE_176400 | | 42 | SNDRV_PCM_RATE_192000, |
43 | SNDRV_PCM_RATE_192000, | 43 | .rate_min = 32000, |
44 | .rate_min = 32000, | 44 | .rate_max = 192000, |
45 | .rate_max = 192000, | 45 | .channels_min = 2, |
46 | .channels_min = 2, | 46 | .channels_max = 2, |
47 | .channels_max = 2, | 47 | .buffer_bytes_max = 256 * 1024, |
48 | .buffer_bytes_max = 256 * 1024, | 48 | .period_bytes_min = 128, |
49 | .period_bytes_min = 128, | 49 | .period_bytes_max = 128 * 1024, |
50 | .period_bytes_max = 128 * 1024, | 50 | .periods_min = 2, |
51 | .periods_min = 2, | 51 | .periods_max = 2048, |
52 | .periods_max = 2048, | 52 | }; |
53 | }, | 53 | static const struct snd_pcm_hardware oxygen_multichannel_hardware = { |
54 | [PCM_B] = { | 54 | .info = SNDRV_PCM_INFO_MMAP | |
55 | .info = SNDRV_PCM_INFO_MMAP | | 55 | SNDRV_PCM_INFO_MMAP_VALID | |
56 | SNDRV_PCM_INFO_MMAP_VALID | | 56 | SNDRV_PCM_INFO_INTERLEAVED | |
57 | SNDRV_PCM_INFO_INTERLEAVED | | 57 | SNDRV_PCM_INFO_PAUSE | |
58 | SNDRV_PCM_INFO_PAUSE | | 58 | SNDRV_PCM_INFO_SYNC_START, |
59 | SNDRV_PCM_INFO_SYNC_START, | 59 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
60 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 60 | SNDRV_PCM_FMTBIT_S32_LE, |
61 | SNDRV_PCM_FMTBIT_S32_LE, | 61 | .rates = SNDRV_PCM_RATE_32000 | |
62 | .rates = SNDRV_PCM_RATE_32000 | | 62 | SNDRV_PCM_RATE_44100 | |
63 | SNDRV_PCM_RATE_44100 | | 63 | SNDRV_PCM_RATE_48000 | |
64 | SNDRV_PCM_RATE_48000 | | 64 | SNDRV_PCM_RATE_64000 | |
65 | SNDRV_PCM_RATE_64000 | | 65 | SNDRV_PCM_RATE_88200 | |
66 | SNDRV_PCM_RATE_88200 | | 66 | SNDRV_PCM_RATE_96000 | |
67 | SNDRV_PCM_RATE_96000 | | 67 | SNDRV_PCM_RATE_176400 | |
68 | SNDRV_PCM_RATE_176400 | | 68 | SNDRV_PCM_RATE_192000, |
69 | SNDRV_PCM_RATE_192000, | 69 | .rate_min = 32000, |
70 | .rate_min = 32000, | 70 | .rate_max = 192000, |
71 | .rate_max = 192000, | 71 | .channels_min = 2, |
72 | .channels_min = 2, | 72 | .channels_max = 8, |
73 | .channels_max = 2, | 73 | .buffer_bytes_max = 2048 * 1024, |
74 | .buffer_bytes_max = 256 * 1024, | 74 | .period_bytes_min = 128, |
75 | .period_bytes_min = 128, | 75 | .period_bytes_max = 256 * 1024, |
76 | .period_bytes_max = 128 * 1024, | 76 | .periods_min = 2, |
77 | .periods_min = 2, | 77 | .periods_max = 16384, |
78 | .periods_max = 2048, | 78 | }; |
79 | }, | 79 | static const struct snd_pcm_hardware oxygen_ac97_hardware = { |
80 | [PCM_C] = { | 80 | .info = SNDRV_PCM_INFO_MMAP | |
81 | .info = SNDRV_PCM_INFO_MMAP | | 81 | SNDRV_PCM_INFO_MMAP_VALID | |
82 | SNDRV_PCM_INFO_MMAP_VALID | | 82 | SNDRV_PCM_INFO_INTERLEAVED | |
83 | SNDRV_PCM_INFO_INTERLEAVED | | 83 | SNDRV_PCM_INFO_PAUSE | |
84 | SNDRV_PCM_INFO_PAUSE | | 84 | SNDRV_PCM_INFO_SYNC_START, |
85 | SNDRV_PCM_INFO_SYNC_START, | 85 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
86 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 86 | .rates = SNDRV_PCM_RATE_48000, |
87 | SNDRV_PCM_FMTBIT_S32_LE, | 87 | .rate_min = 48000, |
88 | .rates = SNDRV_PCM_RATE_32000 | | 88 | .rate_max = 48000, |
89 | SNDRV_PCM_RATE_44100 | | 89 | .channels_min = 2, |
90 | SNDRV_PCM_RATE_48000 | | 90 | .channels_max = 2, |
91 | SNDRV_PCM_RATE_64000 | | 91 | .buffer_bytes_max = 256 * 1024, |
92 | SNDRV_PCM_RATE_88200 | | 92 | .period_bytes_min = 128, |
93 | SNDRV_PCM_RATE_96000 | | 93 | .period_bytes_max = 128 * 1024, |
94 | SNDRV_PCM_RATE_176400 | | 94 | .periods_min = 2, |
95 | SNDRV_PCM_RATE_192000, | 95 | .periods_max = 2048, |
96 | .rate_min = 32000, | 96 | }; |
97 | .rate_max = 192000, | 97 | |
98 | .channels_min = 2, | 98 | static const struct snd_pcm_hardware *const oxygen_hardware[PCM_COUNT] = { |
99 | .channels_max = 2, | 99 | [PCM_A] = &oxygen_stereo_hardware, |
100 | .buffer_bytes_max = 256 * 1024, | 100 | [PCM_B] = &oxygen_stereo_hardware, |
101 | .period_bytes_min = 128, | 101 | [PCM_C] = &oxygen_stereo_hardware, |
102 | .period_bytes_max = 128 * 1024, | 102 | [PCM_SPDIF] = &oxygen_stereo_hardware, |
103 | .periods_min = 2, | 103 | [PCM_MULTICH] = &oxygen_multichannel_hardware, |
104 | .periods_max = 2048, | 104 | [PCM_AC97] = &oxygen_ac97_hardware, |
105 | }, | ||
106 | [PCM_SPDIF] = { | ||
107 | .info = SNDRV_PCM_INFO_MMAP | | ||
108 | SNDRV_PCM_INFO_MMAP_VALID | | ||
109 | SNDRV_PCM_INFO_INTERLEAVED | | ||
110 | SNDRV_PCM_INFO_PAUSE | | ||
111 | SNDRV_PCM_INFO_SYNC_START, | ||
112 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
113 | SNDRV_PCM_FMTBIT_S32_LE, | ||
114 | .rates = SNDRV_PCM_RATE_32000 | | ||
115 | SNDRV_PCM_RATE_44100 | | ||
116 | SNDRV_PCM_RATE_48000 | | ||
117 | SNDRV_PCM_RATE_64000 | | ||
118 | SNDRV_PCM_RATE_88200 | | ||
119 | SNDRV_PCM_RATE_96000 | | ||
120 | SNDRV_PCM_RATE_176400 | | ||
121 | SNDRV_PCM_RATE_192000, | ||
122 | .rate_min = 32000, | ||
123 | .rate_max = 192000, | ||
124 | .channels_min = 2, | ||
125 | .channels_max = 2, | ||
126 | .buffer_bytes_max = 256 * 1024, | ||
127 | .period_bytes_min = 128, | ||
128 | .period_bytes_max = 128 * 1024, | ||
129 | .periods_min = 2, | ||
130 | .periods_max = 2048, | ||
131 | }, | ||
132 | [PCM_MULTICH] = { | ||
133 | .info = SNDRV_PCM_INFO_MMAP | | ||
134 | SNDRV_PCM_INFO_MMAP_VALID | | ||
135 | SNDRV_PCM_INFO_INTERLEAVED | | ||
136 | SNDRV_PCM_INFO_PAUSE | | ||
137 | SNDRV_PCM_INFO_SYNC_START, | ||
138 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
139 | SNDRV_PCM_FMTBIT_S32_LE, | ||
140 | .rates = SNDRV_PCM_RATE_32000 | | ||
141 | SNDRV_PCM_RATE_44100 | | ||
142 | SNDRV_PCM_RATE_48000 | | ||
143 | SNDRV_PCM_RATE_64000 | | ||
144 | SNDRV_PCM_RATE_88200 | | ||
145 | SNDRV_PCM_RATE_96000 | | ||
146 | SNDRV_PCM_RATE_176400 | | ||
147 | SNDRV_PCM_RATE_192000, | ||
148 | .rate_min = 32000, | ||
149 | .rate_max = 192000, | ||
150 | .channels_min = 2, | ||
151 | .channels_max = 8, | ||
152 | .buffer_bytes_max = 2048 * 1024, | ||
153 | .period_bytes_min = 128, | ||
154 | .period_bytes_max = 256 * 1024, | ||
155 | .periods_min = 2, | ||
156 | .periods_max = 16384, | ||
157 | }, | ||
158 | [PCM_AC97] = { | ||
159 | .info = SNDRV_PCM_INFO_MMAP | | ||
160 | SNDRV_PCM_INFO_MMAP_VALID | | ||
161 | SNDRV_PCM_INFO_INTERLEAVED | | ||
162 | SNDRV_PCM_INFO_PAUSE | | ||
163 | SNDRV_PCM_INFO_SYNC_START, | ||
164 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
165 | .rates = SNDRV_PCM_RATE_48000, | ||
166 | .rate_min = 48000, | ||
167 | .rate_max = 48000, | ||
168 | .channels_min = 2, | ||
169 | .channels_max = 2, | ||
170 | .buffer_bytes_max = 256 * 1024, | ||
171 | .period_bytes_min = 128, | ||
172 | .period_bytes_max = 128 * 1024, | ||
173 | .periods_min = 2, | ||
174 | .periods_max = 2048, | ||
175 | }, | ||
176 | }; | 105 | }; |
177 | 106 | ||
178 | static inline unsigned int | 107 | static inline unsigned int |
@@ -189,7 +118,7 @@ static int oxygen_open(struct snd_pcm_substream *substream, | |||
189 | int err; | 118 | int err; |
190 | 119 | ||
191 | runtime->private_data = (void *)(uintptr_t)channel; | 120 | runtime->private_data = (void *)(uintptr_t)channel; |
192 | runtime->hw = oxygen_hardware[channel]; | 121 | runtime->hw = *oxygen_hardware[channel]; |
193 | if (chip->model->pcm_hardware_filter) | 122 | if (chip->model->pcm_hardware_filter) |
194 | chip->model->pcm_hardware_filter(channel, &runtime->hw); | 123 | chip->model->pcm_hardware_filter(channel, &runtime->hw); |
195 | err = snd_pcm_hw_constraint_step(runtime, 0, | 124 | err = snd_pcm_hw_constraint_step(runtime, 0, |