aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 04:27:08 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:16:44 -0500
commitf739aeccedc7681a249bdae435e9af3e5476ad1d (patch)
treef0a2e33a755039a6cb3286895d8c43187c1de613
parent0948e3c8bb187b3dea38be1e1ffd1797866014f1 (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>
-rw-r--r--include/sound/cs4231.h39
-rw-r--r--sound/isa/cs423x/cs4231_lib.c82
2 files changed, 2 insertions, 119 deletions
diff --git a/include/sound/cs4231.h b/include/sound/cs4231.h
index d7f90823778a..d956de947e70 100644
--- a/include/sound/cs4231.h
+++ b/include/sound/cs4231.h
@@ -26,21 +26,6 @@
26#include "pcm.h" 26#include "pcm.h"
27#include "timer.h" 27#include "timer.h"
28 28
29#ifdef CONFIG_SBUS
30#define SBUS_SUPPORT
31#include <asm/sbus.h>
32#endif
33
34#if defined(CONFIG_PCI) && defined(CONFIG_SPARC64)
35#define EBUS_SUPPORT
36#include <linux/pci.h>
37#include <asm/ebus.h>
38#endif
39
40#if !defined(SBUS_SUPPORT) && !defined(EBUS_SUPPORT)
41#define LEGACY_SUPPORT
42#endif
43
44/* IO ports */ 29/* IO ports */
45 30
46#define CS4231P(x) (c_d_c_CS4231##x) 31#define CS4231P(x) (c_d_c_CS4231##x)
@@ -236,14 +221,12 @@ typedef struct _snd_cs4231 cs4231_t;
236 221
237struct _snd_cs4231 { 222struct _snd_cs4231 {
238 unsigned long port; /* base i/o port */ 223 unsigned long port; /* base i/o port */
239#ifdef LEGACY_SUPPORT
240 struct resource *res_port; 224 struct resource *res_port;
241 unsigned long cport; /* control base i/o port (CS4236) */ 225 unsigned long cport; /* control base i/o port (CS4236) */
242 struct resource *res_cport; 226 struct resource *res_cport;
243 int irq; /* IRQ line */ 227 int irq; /* IRQ line */
244 int dma1; /* playback DMA */ 228 int dma1; /* playback DMA */
245 int dma2; /* record DMA */ 229 int dma2; /* record DMA */
246#endif
247 unsigned short version; /* version of CODEC chip */ 230 unsigned short version; /* version of CODEC chip */
248 unsigned short mode; /* see to CS4231_MODE_XXXX */ 231 unsigned short mode; /* see to CS4231_MODE_XXXX */
249 unsigned short hardware; /* see to CS4231_HW_XXXX */ 232 unsigned short hardware; /* see to CS4231_HW_XXXX */
@@ -251,24 +234,6 @@ struct _snd_cs4231 {
251 unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */ 234 unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */
252 ebus_flag:1; /* SPARC: EBUS present */ 235 ebus_flag:1; /* SPARC: EBUS present */
253 236
254#ifdef EBUS_SUPPORT
255 struct ebus_dma_info eb2c;
256 struct ebus_dma_info eb2p;
257#endif
258
259#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
260 union {
261#ifdef SBUS_SUPPORT
262 struct sbus_dev *sdev;
263#endif
264#ifdef EBUS_SUPPORT
265 struct pci_dev *pdev;
266#endif
267 } dev_u;
268 unsigned int p_periods_sent;
269 unsigned int c_periods_sent;
270#endif
271
272 snd_card_t *card; 237 snd_card_t *card;
273 snd_pcm_t *pcm; 238 snd_pcm_t *pcm;
274 snd_pcm_substream_t *playback_substream; 239 snd_pcm_substream_t *playback_substream;
@@ -281,10 +246,8 @@ struct _snd_cs4231 {
281 int mce_bit; 246 int mce_bit;
282 int calibrate_mute; 247 int calibrate_mute;
283 int sw_3d_bit; 248 int sw_3d_bit;
284#ifdef LEGACY_SUPPORT
285 unsigned int p_dma_size; 249 unsigned int p_dma_size;
286 unsigned int c_dma_size; 250 unsigned int c_dma_size;
287#endif
288 251
289 spinlock_t reg_lock; 252 spinlock_t reg_lock;
290 struct semaphore mce_mutex; 253 struct semaphore mce_mutex;
@@ -299,10 +262,8 @@ struct _snd_cs4231 {
299 void (*resume) (cs4231_t *chip); 262 void (*resume) (cs4231_t *chip);
300#endif 263#endif
301 void *dma_private_data; 264 void *dma_private_data;
302#ifdef LEGACY_SUPPORT
303 int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma); 265 int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma);
304 int (*release_dma) (cs4231_t *chip, void *dma_private_data, int dma); 266 int (*release_dma) (cs4231_t *chip, void *dma_private_data, int dma);
305#endif
306}; 267};
307 268
308/* exported functions */ 269/* exported functions */
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) 127static 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
133static __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
151static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset) 132static 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
169static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, 137static 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
878static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) 845static 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
901static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, 867static 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
922static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) 887static 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
947static void snd_cs4231_overrange(cs4231_t *chip) 911static 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
1002static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) 965static 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
1418static int snd_cs4231_free(cs4231_t *chip) 1364static 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
1449const char *snd_cs4231_chip_id(cs4231_t *chip) 1393const 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
1498int snd_cs4231_create(snd_card_t * card, 1440int 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
1586static snd_pcm_ops_t snd_cs4231_playback_ops = { 1526static 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)