diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 04:27:08 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:16:44 -0500 |
commit | f739aeccedc7681a249bdae435e9af3e5476ad1d (patch) | |
tree | f0a2e33a755039a6cb3286895d8c43187c1de613 /sound/isa | |
parent | 0948e3c8bb187b3dea38be1e1ffd1797866014f1 (diff) |
[ALSA] Clean up ISA cs4231 code
Modules: CS4231 driver
Clean up ISA cs4231 code, removing experimental EBUS/SBUS merge,
to improve readability.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/cs423x/cs4231_lib.c | 82 |
1 files changed, 2 insertions, 80 deletions
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 4c9fb168636b..94e07a7c8b33 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c | |||
@@ -124,46 +124,14 @@ static unsigned char snd_cs4231_original_image[32] = | |||
124 | * Basic I/O functions | 124 | * Basic I/O functions |
125 | */ | 125 | */ |
126 | 126 | ||
127 | #if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT) | 127 | static inline void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) |
128 | #define __CS4231_INLINE__ inline | ||
129 | #else | ||
130 | #define __CS4231_INLINE__ /* nothing */ | ||
131 | #endif | ||
132 | |||
133 | static __CS4231_INLINE__ void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) | ||
134 | { | 128 | { |
135 | #ifdef EBUS_SUPPORT | ||
136 | if (chip->ebus->flag) { | ||
137 | writeb(val, chip->port + (offset << 2)); | ||
138 | } else { | ||
139 | #endif | ||
140 | #ifdef SBUS_SUPPORT | ||
141 | sbus_writeb(val, chip->port + (offset << 2)); | ||
142 | #endif | ||
143 | #ifdef EBUS_SUPPORT | ||
144 | } | ||
145 | #endif | ||
146 | #ifdef LEGACY_SUPPORT | ||
147 | outb(val, chip->port + offset); | 129 | outb(val, chip->port + offset); |
148 | #endif | ||
149 | } | 130 | } |
150 | 131 | ||
151 | static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset) | 132 | static inline u8 cs4231_inb(cs4231_t *chip, u8 offset) |
152 | { | 133 | { |
153 | #ifdef EBUS_SUPPORT | ||
154 | if (chip->ebus_flag) { | ||
155 | return readb(chip->port + (offset << 2)); | ||
156 | } else { | ||
157 | #endif | ||
158 | #ifdef SBUS_SUPPORT | ||
159 | return sbus_readb(chip->port + (offset << 2)); | ||
160 | #endif | ||
161 | #ifdef EBUS_SUPPORT | ||
162 | } | ||
163 | #endif | ||
164 | #ifdef LEGACY_SUPPORT | ||
165 | return inb(chip->port + offset); | 134 | return inb(chip->port + offset); |
166 | #endif | ||
167 | } | 135 | } |
168 | 136 | ||
169 | static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, | 137 | static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, |
@@ -874,7 +842,6 @@ static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) | |||
874 | return snd_pcm_lib_free_pages(substream); | 842 | return snd_pcm_lib_free_pages(substream); |
875 | } | 843 | } |
876 | 844 | ||
877 | #ifdef LEGACY_SUPPORT | ||
878 | static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) | 845 | static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) |
879 | { | 846 | { |
880 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 847 | cs4231_t *chip = snd_pcm_substream_chip(substream); |
@@ -896,7 +863,6 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) | |||
896 | #endif | 863 | #endif |
897 | return 0; | 864 | return 0; |
898 | } | 865 | } |
899 | #endif /* LEGACY_SUPPORT */ | ||
900 | 866 | ||
901 | static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, | 867 | static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, |
902 | snd_pcm_hw_params_t * hw_params) | 868 | snd_pcm_hw_params_t * hw_params) |
@@ -918,7 +884,6 @@ static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) | |||
918 | return snd_pcm_lib_free_pages(substream); | 884 | return snd_pcm_lib_free_pages(substream); |
919 | } | 885 | } |
920 | 886 | ||
921 | #ifdef LEGACY_SUPPORT | ||
922 | static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) | 887 | static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) |
923 | { | 888 | { |
924 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 889 | cs4231_t *chip = snd_pcm_substream_chip(substream); |
@@ -942,7 +907,6 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) | |||
942 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 907 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
943 | return 0; | 908 | return 0; |
944 | } | 909 | } |
945 | #endif | ||
946 | 910 | ||
947 | static void snd_cs4231_overrange(cs4231_t *chip) | 911 | static void snd_cs4231_overrange(cs4231_t *chip) |
948 | { | 912 | { |
@@ -998,7 +962,6 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
998 | return IRQ_HANDLED; | 962 | return IRQ_HANDLED; |
999 | } | 963 | } |
1000 | 964 | ||
1001 | #ifdef LEGACY_SUPPORT | ||
1002 | static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) | 965 | static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) |
1003 | { | 966 | { |
1004 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 967 | cs4231_t *chip = snd_pcm_substream_chip(substream); |
@@ -1020,7 +983,6 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr | |||
1020 | ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); | 983 | ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); |
1021 | return bytes_to_frames(substream->runtime, ptr); | 984 | return bytes_to_frames(substream->runtime, ptr); |
1022 | } | 985 | } |
1023 | #endif /* LEGACY_SUPPORT */ | ||
1024 | 986 | ||
1025 | /* | 987 | /* |
1026 | 988 | ||
@@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) | |||
1253 | chip->hardware == CS4231_HW_CS4239) | 1215 | chip->hardware == CS4231_HW_CS4239) |
1254 | runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; | 1216 | runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; |
1255 | 1217 | ||
1256 | #ifdef LEGACY_SUPPORT | ||
1257 | snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); | 1218 | snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); |
1258 | snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); | 1219 | snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); |
1259 | 1220 | ||
@@ -1261,20 +1222,14 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) | |||
1261 | if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) | 1222 | if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) |
1262 | return err; | 1223 | return err; |
1263 | } | 1224 | } |
1264 | #endif | ||
1265 | 1225 | ||
1266 | if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { | 1226 | if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { |
1267 | #ifdef LEGACY_SUPPORT | ||
1268 | if (chip->release_dma) | 1227 | if (chip->release_dma) |
1269 | chip->release_dma(chip, chip->dma_private_data, chip->dma1); | 1228 | chip->release_dma(chip, chip->dma_private_data, chip->dma1); |
1270 | #endif | ||
1271 | snd_free_pages(runtime->dma_area, runtime->dma_bytes); | 1229 | snd_free_pages(runtime->dma_area, runtime->dma_bytes); |
1272 | return err; | 1230 | return err; |
1273 | } | 1231 | } |
1274 | chip->playback_substream = substream; | 1232 | chip->playback_substream = substream; |
1275 | #if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) | ||
1276 | chip->p_periods_sent = 0; | ||
1277 | #endif | ||
1278 | snd_pcm_set_sync(substream); | 1233 | snd_pcm_set_sync(substream); |
1279 | chip->rate_constraint(runtime); | 1234 | chip->rate_constraint(runtime); |
1280 | return 0; | 1235 | return 0; |
@@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) | |||
1293 | chip->hardware == CS4231_HW_CS4239) | 1248 | chip->hardware == CS4231_HW_CS4239) |
1294 | runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; | 1249 | runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; |
1295 | 1250 | ||
1296 | #ifdef LEGACY_SUPPORT | ||
1297 | snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); | 1251 | snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); |
1298 | snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); | 1252 | snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); |
1299 | 1253 | ||
@@ -1301,20 +1255,14 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) | |||
1301 | if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) | 1255 | if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) |
1302 | return err; | 1256 | return err; |
1303 | } | 1257 | } |
1304 | #endif | ||
1305 | 1258 | ||
1306 | if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { | 1259 | if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { |
1307 | #ifdef LEGACY_SUPPORT | ||
1308 | if (chip->release_dma) | 1260 | if (chip->release_dma) |
1309 | chip->release_dma(chip, chip->dma_private_data, chip->dma2); | 1261 | chip->release_dma(chip, chip->dma_private_data, chip->dma2); |
1310 | #endif | ||
1311 | snd_free_pages(runtime->dma_area, runtime->dma_bytes); | 1262 | snd_free_pages(runtime->dma_area, runtime->dma_bytes); |
1312 | return err; | 1263 | return err; |
1313 | } | 1264 | } |
1314 | chip->capture_substream = substream; | 1265 | chip->capture_substream = substream; |
1315 | #if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) | ||
1316 | chip->c_periods_sent = 0; | ||
1317 | #endif | ||
1318 | snd_pcm_set_sync(substream); | 1266 | snd_pcm_set_sync(substream); |
1319 | chip->rate_constraint(runtime); | 1267 | chip->rate_constraint(runtime); |
1320 | return 0; | 1268 | return 0; |
@@ -1413,8 +1361,6 @@ static int snd_cs4231_pm_resume(snd_card_t *card) | |||
1413 | } | 1361 | } |
1414 | #endif /* CONFIG_PM */ | 1362 | #endif /* CONFIG_PM */ |
1415 | 1363 | ||
1416 | #ifdef LEGACY_SUPPORT | ||
1417 | |||
1418 | static int snd_cs4231_free(cs4231_t *chip) | 1364 | static int snd_cs4231_free(cs4231_t *chip) |
1419 | { | 1365 | { |
1420 | release_and_free_resource(chip->res_port); | 1366 | release_and_free_resource(chip->res_port); |
@@ -1444,8 +1390,6 @@ static int snd_cs4231_dev_free(snd_device_t *device) | |||
1444 | return snd_cs4231_free(chip); | 1390 | return snd_cs4231_free(chip); |
1445 | } | 1391 | } |
1446 | 1392 | ||
1447 | #endif /* LEGACY_SUPPORT */ | ||
1448 | |||
1449 | const char *snd_cs4231_chip_id(cs4231_t *chip) | 1393 | const char *snd_cs4231_chip_id(cs4231_t *chip) |
1450 | { | 1394 | { |
1451 | switch (chip->hardware) { | 1395 | switch (chip->hardware) { |
@@ -1493,8 +1437,6 @@ static int snd_cs4231_new(snd_card_t * card, | |||
1493 | return 0; | 1437 | return 0; |
1494 | } | 1438 | } |
1495 | 1439 | ||
1496 | #ifdef LEGACY_SUPPORT | ||
1497 | |||
1498 | int snd_cs4231_create(snd_card_t * card, | 1440 | int snd_cs4231_create(snd_card_t * card, |
1499 | unsigned long port, | 1441 | unsigned long port, |
1500 | unsigned long cport, | 1442 | unsigned long cport, |
@@ -1581,8 +1523,6 @@ int snd_cs4231_create(snd_card_t * card, | |||
1581 | return 0; | 1523 | return 0; |
1582 | } | 1524 | } |
1583 | 1525 | ||
1584 | #endif /* LEGACY_SUPPORT */ | ||
1585 | |||
1586 | static snd_pcm_ops_t snd_cs4231_playback_ops = { | 1526 | static snd_pcm_ops_t snd_cs4231_playback_ops = { |
1587 | .open = snd_cs4231_playback_open, | 1527 | .open = snd_cs4231_playback_open, |
1588 | .close = snd_cs4231_playback_close, | 1528 | .close = snd_cs4231_playback_close, |
@@ -1629,27 +1569,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) | |||
1629 | pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; | 1569 | pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; |
1630 | strcpy(pcm->name, snd_cs4231_chip_id(chip)); | 1570 | strcpy(pcm->name, snd_cs4231_chip_id(chip)); |
1631 | 1571 | ||
1632 | #ifdef LEGACY_SUPPORT | ||
1633 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 1572 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1634 | snd_dma_isa_data(), | 1573 | snd_dma_isa_data(), |
1635 | 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); | 1574 | 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
1636 | #else | ||
1637 | # ifdef EBUS_SUPPORT | ||
1638 | if (chip->ebus_flag) { | ||
1639 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
1640 | chip->dev_u.pdev, | ||
1641 | 64*1024, 128*1024); | ||
1642 | } else { | ||
1643 | # endif | ||
1644 | # ifdef SBUS_SUPPORT | ||
1645 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS, | ||
1646 | chip->dev_u.sdev, | ||
1647 | 64*1024, 128*1024); | ||
1648 | # endif | ||
1649 | # ifdef EBUS_SUPPORT | ||
1650 | } | ||
1651 | # endif | ||
1652 | #endif | ||
1653 | 1575 | ||
1654 | chip->pcm = pcm; | 1576 | chip->pcm = pcm; |
1655 | if (rpcm) | 1577 | if (rpcm) |