diff options
Diffstat (limited to 'sound/isa/cs423x/cs4231_lib.c')
-rw-r--r-- | sound/isa/cs423x/cs4231_lib.c | 334 |
1 files changed, 116 insertions, 218 deletions
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 4af769030beb..eab7eb59b5f7 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c | |||
@@ -73,13 +73,13 @@ static unsigned int rates[14] = { | |||
73 | 27042, 32000, 33075, 37800, 44100, 48000 | 73 | 27042, 32000, 33075, 37800, 44100, 48000 |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static snd_pcm_hw_constraint_list_t hw_constraints_rates = { | 76 | static struct snd_pcm_hw_constraint_list hw_constraints_rates = { |
77 | .count = 14, | 77 | .count = 14, |
78 | .list = rates, | 78 | .list = rates, |
79 | .mask = 0, | 79 | .mask = 0, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static int snd_cs4231_xrate(snd_pcm_runtime_t *runtime) | 82 | static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime) |
83 | { | 83 | { |
84 | return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); | 84 | return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); |
85 | } | 85 | } |
@@ -124,49 +124,17 @@ 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(struct snd_cs4231 *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(struct snd_cs4231 *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(struct snd_cs4231 *chip, unsigned char reg, |
170 | unsigned char mask, unsigned char value) | 138 | unsigned char mask, unsigned char value) |
171 | { | 139 | { |
172 | int timeout; | 140 | int timeout; |
@@ -193,7 +161,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, | |||
193 | } | 161 | } |
194 | } | 162 | } |
195 | 163 | ||
196 | static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char value) | 164 | static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) |
197 | { | 165 | { |
198 | int timeout; | 166 | int timeout; |
199 | 167 | ||
@@ -206,7 +174,7 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val | |||
206 | mb(); | 174 | mb(); |
207 | } | 175 | } |
208 | 176 | ||
209 | void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) | 177 | void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) |
210 | { | 178 | { |
211 | int timeout; | 179 | int timeout; |
212 | 180 | ||
@@ -227,7 +195,7 @@ void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) | |||
227 | #endif | 195 | #endif |
228 | } | 196 | } |
229 | 197 | ||
230 | unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) | 198 | unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) |
231 | { | 199 | { |
232 | int timeout; | 200 | int timeout; |
233 | 201 | ||
@@ -244,7 +212,7 @@ unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) | |||
244 | return cs4231_inb(chip, CS4231P(REG)); | 212 | return cs4231_inb(chip, CS4231P(REG)); |
245 | } | 213 | } |
246 | 214 | ||
247 | void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) | 215 | void snd_cs4236_ext_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val) |
248 | { | 216 | { |
249 | cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); | 217 | cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); |
250 | cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); | 218 | cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); |
@@ -255,7 +223,7 @@ void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) | |||
255 | #endif | 223 | #endif |
256 | } | 224 | } |
257 | 225 | ||
258 | unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) | 226 | unsigned char snd_cs4236_ext_in(struct snd_cs4231 *chip, unsigned char reg) |
259 | { | 227 | { |
260 | cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); | 228 | cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); |
261 | cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); | 229 | cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); |
@@ -273,7 +241,7 @@ unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) | |||
273 | 241 | ||
274 | #if 0 | 242 | #if 0 |
275 | 243 | ||
276 | static void snd_cs4231_debug(cs4231_t *chip) | 244 | static void snd_cs4231_debug(struct snd_cs4231 *chip) |
277 | { | 245 | { |
278 | printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL))); | 246 | printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL))); |
279 | printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS))); | 247 | printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS))); |
@@ -317,7 +285,7 @@ static void snd_cs4231_debug(cs4231_t *chip) | |||
317 | * CS4231 detection / MCE routines | 285 | * CS4231 detection / MCE routines |
318 | */ | 286 | */ |
319 | 287 | ||
320 | static void snd_cs4231_busy_wait(cs4231_t *chip) | 288 | static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) |
321 | { | 289 | { |
322 | int timeout; | 290 | int timeout; |
323 | 291 | ||
@@ -331,7 +299,7 @@ static void snd_cs4231_busy_wait(cs4231_t *chip) | |||
331 | udelay(10); | 299 | udelay(10); |
332 | } | 300 | } |
333 | 301 | ||
334 | void snd_cs4231_mce_up(cs4231_t *chip) | 302 | void snd_cs4231_mce_up(struct snd_cs4231 *chip) |
335 | { | 303 | { |
336 | unsigned long flags; | 304 | unsigned long flags; |
337 | int timeout; | 305 | int timeout; |
@@ -352,7 +320,7 @@ void snd_cs4231_mce_up(cs4231_t *chip) | |||
352 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 320 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
353 | } | 321 | } |
354 | 322 | ||
355 | void snd_cs4231_mce_down(cs4231_t *chip) | 323 | void snd_cs4231_mce_down(struct snd_cs4231 *chip) |
356 | { | 324 | { |
357 | unsigned long flags; | 325 | unsigned long flags; |
358 | int timeout; | 326 | int timeout; |
@@ -431,14 +399,14 @@ static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size | |||
431 | return size; | 399 | return size; |
432 | } | 400 | } |
433 | 401 | ||
434 | static int snd_cs4231_trigger(snd_pcm_substream_t *substream, | 402 | static int snd_cs4231_trigger(struct snd_pcm_substream *substream, |
435 | int cmd) | 403 | int cmd) |
436 | { | 404 | { |
437 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 405 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
438 | int result = 0; | 406 | int result = 0; |
439 | unsigned int what; | 407 | unsigned int what; |
440 | struct list_head *pos; | 408 | struct list_head *pos; |
441 | snd_pcm_substream_t *s; | 409 | struct snd_pcm_substream *s; |
442 | int do_start; | 410 | int do_start; |
443 | 411 | ||
444 | #if 0 | 412 | #if 0 |
@@ -500,7 +468,7 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) | |||
500 | return freq_bits[13]; | 468 | return freq_bits[13]; |
501 | } | 469 | } |
502 | 470 | ||
503 | static unsigned char snd_cs4231_get_format(cs4231_t *chip, | 471 | static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, |
504 | int format, | 472 | int format, |
505 | int channels) | 473 | int channels) |
506 | { | 474 | { |
@@ -522,7 +490,7 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip, | |||
522 | return rformat; | 490 | return rformat; |
523 | } | 491 | } |
524 | 492 | ||
525 | static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) | 493 | static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) |
526 | { | 494 | { |
527 | unsigned long flags; | 495 | unsigned long flags; |
528 | 496 | ||
@@ -556,8 +524,8 @@ static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) | |||
556 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 524 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
557 | } | 525 | } |
558 | 526 | ||
559 | static void snd_cs4231_playback_format(cs4231_t *chip, | 527 | static void snd_cs4231_playback_format(struct snd_cs4231 *chip, |
560 | snd_pcm_hw_params_t *params, | 528 | struct snd_pcm_hw_params *params, |
561 | unsigned char pdfr) | 529 | unsigned char pdfr) |
562 | { | 530 | { |
563 | unsigned long flags; | 531 | unsigned long flags; |
@@ -595,8 +563,8 @@ static void snd_cs4231_playback_format(cs4231_t *chip, | |||
595 | up(&chip->mce_mutex); | 563 | up(&chip->mce_mutex); |
596 | } | 564 | } |
597 | 565 | ||
598 | static void snd_cs4231_capture_format(cs4231_t *chip, | 566 | static void snd_cs4231_capture_format(struct snd_cs4231 *chip, |
599 | snd_pcm_hw_params_t *params, | 567 | struct snd_pcm_hw_params *params, |
600 | unsigned char cdfr) | 568 | unsigned char cdfr) |
601 | { | 569 | { |
602 | unsigned long flags; | 570 | unsigned long flags; |
@@ -642,20 +610,20 @@ static void snd_cs4231_capture_format(cs4231_t *chip, | |||
642 | * Timer interface | 610 | * Timer interface |
643 | */ | 611 | */ |
644 | 612 | ||
645 | static unsigned long snd_cs4231_timer_resolution(snd_timer_t * timer) | 613 | static unsigned long snd_cs4231_timer_resolution(struct snd_timer * timer) |
646 | { | 614 | { |
647 | cs4231_t *chip = snd_timer_chip(timer); | 615 | struct snd_cs4231 *chip = snd_timer_chip(timer); |
648 | if (chip->hardware & CS4231_HW_CS4236B_MASK) | 616 | if (chip->hardware & CS4231_HW_CS4236B_MASK) |
649 | return 14467; | 617 | return 14467; |
650 | else | 618 | else |
651 | return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; | 619 | return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; |
652 | } | 620 | } |
653 | 621 | ||
654 | static int snd_cs4231_timer_start(snd_timer_t * timer) | 622 | static int snd_cs4231_timer_start(struct snd_timer * timer) |
655 | { | 623 | { |
656 | unsigned long flags; | 624 | unsigned long flags; |
657 | unsigned int ticks; | 625 | unsigned int ticks; |
658 | cs4231_t *chip = snd_timer_chip(timer); | 626 | struct snd_cs4231 *chip = snd_timer_chip(timer); |
659 | spin_lock_irqsave(&chip->reg_lock, flags); | 627 | spin_lock_irqsave(&chip->reg_lock, flags); |
660 | ticks = timer->sticks; | 628 | ticks = timer->sticks; |
661 | if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || | 629 | if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || |
@@ -669,17 +637,17 @@ static int snd_cs4231_timer_start(snd_timer_t * timer) | |||
669 | return 0; | 637 | return 0; |
670 | } | 638 | } |
671 | 639 | ||
672 | static int snd_cs4231_timer_stop(snd_timer_t * timer) | 640 | static int snd_cs4231_timer_stop(struct snd_timer * timer) |
673 | { | 641 | { |
674 | unsigned long flags; | 642 | unsigned long flags; |
675 | cs4231_t *chip = snd_timer_chip(timer); | 643 | struct snd_cs4231 *chip = snd_timer_chip(timer); |
676 | spin_lock_irqsave(&chip->reg_lock, flags); | 644 | spin_lock_irqsave(&chip->reg_lock, flags); |
677 | snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); | 645 | snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); |
678 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 646 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
679 | return 0; | 647 | return 0; |
680 | } | 648 | } |
681 | 649 | ||
682 | static void snd_cs4231_init(cs4231_t *chip) | 650 | static void snd_cs4231_init(struct snd_cs4231 *chip) |
683 | { | 651 | { |
684 | unsigned long flags; | 652 | unsigned long flags; |
685 | 653 | ||
@@ -737,7 +705,7 @@ static void snd_cs4231_init(cs4231_t *chip) | |||
737 | #endif | 705 | #endif |
738 | } | 706 | } |
739 | 707 | ||
740 | static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) | 708 | static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) |
741 | { | 709 | { |
742 | unsigned long flags; | 710 | unsigned long flags; |
743 | 711 | ||
@@ -773,7 +741,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) | |||
773 | return 0; | 741 | return 0; |
774 | } | 742 | } |
775 | 743 | ||
776 | static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) | 744 | static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) |
777 | { | 745 | { |
778 | unsigned long flags; | 746 | unsigned long flags; |
779 | 747 | ||
@@ -824,21 +792,21 @@ static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) | |||
824 | * timer open/close | 792 | * timer open/close |
825 | */ | 793 | */ |
826 | 794 | ||
827 | static int snd_cs4231_timer_open(snd_timer_t * timer) | 795 | static int snd_cs4231_timer_open(struct snd_timer * timer) |
828 | { | 796 | { |
829 | cs4231_t *chip = snd_timer_chip(timer); | 797 | struct snd_cs4231 *chip = snd_timer_chip(timer); |
830 | snd_cs4231_open(chip, CS4231_MODE_TIMER); | 798 | snd_cs4231_open(chip, CS4231_MODE_TIMER); |
831 | return 0; | 799 | return 0; |
832 | } | 800 | } |
833 | 801 | ||
834 | static int snd_cs4231_timer_close(snd_timer_t * timer) | 802 | static int snd_cs4231_timer_close(struct snd_timer * timer) |
835 | { | 803 | { |
836 | cs4231_t *chip = snd_timer_chip(timer); | 804 | struct snd_cs4231 *chip = snd_timer_chip(timer); |
837 | snd_cs4231_close(chip, CS4231_MODE_TIMER); | 805 | snd_cs4231_close(chip, CS4231_MODE_TIMER); |
838 | return 0; | 806 | return 0; |
839 | } | 807 | } |
840 | 808 | ||
841 | static struct _snd_timer_hardware snd_cs4231_timer_table = | 809 | static struct snd_timer_hardware snd_cs4231_timer_table = |
842 | { | 810 | { |
843 | .flags = SNDRV_TIMER_HW_AUTO, | 811 | .flags = SNDRV_TIMER_HW_AUTO, |
844 | .resolution = 9945, | 812 | .resolution = 9945, |
@@ -854,10 +822,10 @@ static struct _snd_timer_hardware snd_cs4231_timer_table = | |||
854 | * ok.. exported functions.. | 822 | * ok.. exported functions.. |
855 | */ | 823 | */ |
856 | 824 | ||
857 | static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, | 825 | static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, |
858 | snd_pcm_hw_params_t * hw_params) | 826 | struct snd_pcm_hw_params *hw_params) |
859 | { | 827 | { |
860 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 828 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
861 | unsigned char new_pdfr; | 829 | unsigned char new_pdfr; |
862 | int err; | 830 | int err; |
863 | 831 | ||
@@ -869,16 +837,15 @@ static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, | |||
869 | return 0; | 837 | return 0; |
870 | } | 838 | } |
871 | 839 | ||
872 | static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) | 840 | static int snd_cs4231_playback_hw_free(struct snd_pcm_substream *substream) |
873 | { | 841 | { |
874 | return snd_pcm_lib_free_pages(substream); | 842 | return snd_pcm_lib_free_pages(substream); |
875 | } | 843 | } |
876 | 844 | ||
877 | #ifdef LEGACY_SUPPORT | 845 | static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) |
878 | static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) | ||
879 | { | 846 | { |
880 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 847 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
881 | snd_pcm_runtime_t *runtime = substream->runtime; | 848 | struct snd_pcm_runtime *runtime = substream->runtime; |
882 | unsigned long flags; | 849 | unsigned long flags; |
883 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 850 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
884 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 851 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
@@ -896,12 +863,11 @@ 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(struct snd_pcm_substream *substream, |
902 | snd_pcm_hw_params_t * hw_params) | 868 | struct snd_pcm_hw_params *hw_params) |
903 | { | 869 | { |
904 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 870 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
905 | unsigned char new_cdfr; | 871 | unsigned char new_cdfr; |
906 | int err; | 872 | int err; |
907 | 873 | ||
@@ -913,16 +879,15 @@ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, | |||
913 | return 0; | 879 | return 0; |
914 | } | 880 | } |
915 | 881 | ||
916 | static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) | 882 | static int snd_cs4231_capture_hw_free(struct snd_pcm_substream *substream) |
917 | { | 883 | { |
918 | return snd_pcm_lib_free_pages(substream); | 884 | return snd_pcm_lib_free_pages(substream); |
919 | } | 885 | } |
920 | 886 | ||
921 | #ifdef LEGACY_SUPPORT | 887 | static int snd_cs4231_capture_prepare(struct snd_pcm_substream *substream) |
922 | static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) | ||
923 | { | 888 | { |
924 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 889 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
925 | snd_pcm_runtime_t *runtime = substream->runtime; | 890 | struct snd_pcm_runtime *runtime = substream->runtime; |
926 | unsigned long flags; | 891 | unsigned long flags; |
927 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 892 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
928 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 893 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
@@ -942,9 +907,8 @@ 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(struct snd_cs4231 *chip) |
948 | { | 912 | { |
949 | unsigned long flags; | 913 | unsigned long flags; |
950 | unsigned char res; | 914 | unsigned char res; |
@@ -958,7 +922,7 @@ static void snd_cs4231_overrange(cs4231_t *chip) | |||
958 | 922 | ||
959 | irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 923 | irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
960 | { | 924 | { |
961 | cs4231_t *chip = dev_id; | 925 | struct snd_cs4231 *chip = dev_id; |
962 | unsigned char status; | 926 | unsigned char status; |
963 | 927 | ||
964 | status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); | 928 | status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); |
@@ -998,10 +962,9 @@ 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 | 965 | static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) |
1002 | 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 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1005 | size_t ptr; | 968 | size_t ptr; |
1006 | 969 | ||
1007 | if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) | 970 | if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) |
@@ -1010,9 +973,9 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * subst | |||
1010 | return bytes_to_frames(substream->runtime, ptr); | 973 | return bytes_to_frames(substream->runtime, ptr); |
1011 | } | 974 | } |
1012 | 975 | ||
1013 | static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substream) | 976 | static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) |
1014 | { | 977 | { |
1015 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 978 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1016 | size_t ptr; | 979 | size_t ptr; |
1017 | 980 | ||
1018 | if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) | 981 | if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) |
@@ -1020,13 +983,12 @@ 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 | ||
1027 | */ | 989 | */ |
1028 | 990 | ||
1029 | static int snd_cs4231_probe(cs4231_t *chip) | 991 | static int snd_cs4231_probe(struct snd_cs4231 *chip) |
1030 | { | 992 | { |
1031 | unsigned long flags; | 993 | unsigned long flags; |
1032 | int i, id, rev; | 994 | int i, id, rev; |
@@ -1190,7 +1152,7 @@ static int snd_cs4231_probe(cs4231_t *chip) | |||
1190 | 1152 | ||
1191 | */ | 1153 | */ |
1192 | 1154 | ||
1193 | static snd_pcm_hardware_t snd_cs4231_playback = | 1155 | static struct snd_pcm_hardware snd_cs4231_playback = |
1194 | { | 1156 | { |
1195 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 1157 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
1196 | SNDRV_PCM_INFO_MMAP_VALID | | 1158 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -1211,7 +1173,7 @@ static snd_pcm_hardware_t snd_cs4231_playback = | |||
1211 | .fifo_size = 0, | 1173 | .fifo_size = 0, |
1212 | }; | 1174 | }; |
1213 | 1175 | ||
1214 | static snd_pcm_hardware_t snd_cs4231_capture = | 1176 | static struct snd_pcm_hardware snd_cs4231_capture = |
1215 | { | 1177 | { |
1216 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 1178 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
1217 | SNDRV_PCM_INFO_MMAP_VALID | | 1179 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -1236,10 +1198,10 @@ static snd_pcm_hardware_t snd_cs4231_capture = | |||
1236 | 1198 | ||
1237 | */ | 1199 | */ |
1238 | 1200 | ||
1239 | static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) | 1201 | static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) |
1240 | { | 1202 | { |
1241 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 1203 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1242 | snd_pcm_runtime_t *runtime = substream->runtime; | 1204 | struct snd_pcm_runtime *runtime = substream->runtime; |
1243 | int err; | 1205 | int err; |
1244 | 1206 | ||
1245 | runtime->hw = snd_cs4231_playback; | 1207 | runtime->hw = snd_cs4231_playback; |
@@ -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,29 +1222,23 @@ 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; |
1281 | } | 1236 | } |
1282 | 1237 | ||
1283 | static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) | 1238 | static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) |
1284 | { | 1239 | { |
1285 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 1240 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1286 | snd_pcm_runtime_t *runtime = substream->runtime; | 1241 | struct snd_pcm_runtime *runtime = substream->runtime; |
1287 | int err; | 1242 | int err; |
1288 | 1243 | ||
1289 | runtime->hw = snd_cs4231_capture; | 1244 | runtime->hw = snd_cs4231_capture; |
@@ -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,37 +1255,31 @@ 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; |
1321 | } | 1269 | } |
1322 | 1270 | ||
1323 | static int snd_cs4231_playback_close(snd_pcm_substream_t * substream) | 1271 | static int snd_cs4231_playback_close(struct snd_pcm_substream *substream) |
1324 | { | 1272 | { |
1325 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 1273 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1326 | 1274 | ||
1327 | chip->playback_substream = NULL; | 1275 | chip->playback_substream = NULL; |
1328 | snd_cs4231_close(chip, CS4231_MODE_PLAY); | 1276 | snd_cs4231_close(chip, CS4231_MODE_PLAY); |
1329 | return 0; | 1277 | return 0; |
1330 | } | 1278 | } |
1331 | 1279 | ||
1332 | static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) | 1280 | static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) |
1333 | { | 1281 | { |
1334 | cs4231_t *chip = snd_pcm_substream_chip(substream); | 1282 | struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); |
1335 | 1283 | ||
1336 | chip->capture_substream = NULL; | 1284 | chip->capture_substream = NULL; |
1337 | snd_cs4231_close(chip, CS4231_MODE_RECORD); | 1285 | snd_cs4231_close(chip, CS4231_MODE_RECORD); |
@@ -1341,13 +1289,12 @@ static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) | |||
1341 | #ifdef CONFIG_PM | 1289 | #ifdef CONFIG_PM |
1342 | 1290 | ||
1343 | /* lowlevel suspend callback for CS4231 */ | 1291 | /* lowlevel suspend callback for CS4231 */ |
1344 | static void snd_cs4231_suspend(cs4231_t *chip) | 1292 | static void snd_cs4231_suspend(struct snd_cs4231 *chip) |
1345 | { | 1293 | { |
1346 | int reg; | 1294 | int reg; |
1347 | unsigned long flags; | 1295 | unsigned long flags; |
1348 | 1296 | ||
1349 | if (chip->pcm) | 1297 | snd_pcm_suspend_all(chip->pcm); |
1350 | snd_pcm_suspend_all(chip->pcm); | ||
1351 | spin_lock_irqsave(&chip->reg_lock, flags); | 1298 | spin_lock_irqsave(&chip->reg_lock, flags); |
1352 | for (reg = 0; reg < 32; reg++) | 1299 | for (reg = 0; reg < 32; reg++) |
1353 | chip->image[reg] = snd_cs4231_in(chip, reg); | 1300 | chip->image[reg] = snd_cs4231_in(chip, reg); |
@@ -1355,11 +1302,11 @@ static void snd_cs4231_suspend(cs4231_t *chip) | |||
1355 | } | 1302 | } |
1356 | 1303 | ||
1357 | /* lowlevel resume callback for CS4231 */ | 1304 | /* lowlevel resume callback for CS4231 */ |
1358 | static void snd_cs4231_resume(cs4231_t *chip) | 1305 | static void snd_cs4231_resume(struct snd_cs4231 *chip) |
1359 | { | 1306 | { |
1360 | int reg; | 1307 | int reg; |
1361 | unsigned long flags; | 1308 | unsigned long flags; |
1362 | int timeout; | 1309 | /* int timeout; */ |
1363 | 1310 | ||
1364 | snd_cs4231_mce_up(chip); | 1311 | snd_cs4231_mce_up(chip); |
1365 | spin_lock_irqsave(&chip->reg_lock, flags); | 1312 | spin_lock_irqsave(&chip->reg_lock, flags); |
@@ -1373,7 +1320,7 @@ static void snd_cs4231_resume(cs4231_t *chip) | |||
1373 | } | 1320 | } |
1374 | } | 1321 | } |
1375 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1322 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1376 | #if 0 | 1323 | #if 1 |
1377 | snd_cs4231_mce_down(chip); | 1324 | snd_cs4231_mce_down(chip); |
1378 | #else | 1325 | #else |
1379 | /* The following is a workaround to avoid freeze after resume on TP600E. | 1326 | /* The following is a workaround to avoid freeze after resume on TP600E. |
@@ -1395,27 +1342,9 @@ static void snd_cs4231_resume(cs4231_t *chip) | |||
1395 | snd_cs4231_busy_wait(chip); | 1342 | snd_cs4231_busy_wait(chip); |
1396 | #endif | 1343 | #endif |
1397 | } | 1344 | } |
1398 | |||
1399 | static int snd_cs4231_pm_suspend(snd_card_t *card, pm_message_t state) | ||
1400 | { | ||
1401 | cs4231_t *chip = card->pm_private_data; | ||
1402 | if (chip->suspend) | ||
1403 | chip->suspend(chip); | ||
1404 | return 0; | ||
1405 | } | ||
1406 | |||
1407 | static int snd_cs4231_pm_resume(snd_card_t *card) | ||
1408 | { | ||
1409 | cs4231_t *chip = card->pm_private_data; | ||
1410 | if (chip->resume) | ||
1411 | chip->resume(chip); | ||
1412 | return 0; | ||
1413 | } | ||
1414 | #endif /* CONFIG_PM */ | 1345 | #endif /* CONFIG_PM */ |
1415 | 1346 | ||
1416 | #ifdef LEGACY_SUPPORT | 1347 | static int snd_cs4231_free(struct snd_cs4231 *chip) |
1417 | |||
1418 | static int snd_cs4231_free(cs4231_t *chip) | ||
1419 | { | 1348 | { |
1420 | release_and_free_resource(chip->res_port); | 1349 | release_and_free_resource(chip->res_port); |
1421 | release_and_free_resource(chip->res_cport); | 1350 | release_and_free_resource(chip->res_cport); |
@@ -1438,15 +1367,13 @@ static int snd_cs4231_free(cs4231_t *chip) | |||
1438 | return 0; | 1367 | return 0; |
1439 | } | 1368 | } |
1440 | 1369 | ||
1441 | static int snd_cs4231_dev_free(snd_device_t *device) | 1370 | static int snd_cs4231_dev_free(struct snd_device *device) |
1442 | { | 1371 | { |
1443 | cs4231_t *chip = device->device_data; | 1372 | struct snd_cs4231 *chip = device->device_data; |
1444 | return snd_cs4231_free(chip); | 1373 | return snd_cs4231_free(chip); |
1445 | } | 1374 | } |
1446 | 1375 | ||
1447 | #endif /* LEGACY_SUPPORT */ | 1376 | const char *snd_cs4231_chip_id(struct snd_cs4231 *chip) |
1448 | |||
1449 | const char *snd_cs4231_chip_id(cs4231_t *chip) | ||
1450 | { | 1377 | { |
1451 | switch (chip->hardware) { | 1378 | switch (chip->hardware) { |
1452 | case CS4231_HW_CS4231: return "CS4231"; | 1379 | case CS4231_HW_CS4231: return "CS4231"; |
@@ -1466,12 +1393,12 @@ const char *snd_cs4231_chip_id(cs4231_t *chip) | |||
1466 | } | 1393 | } |
1467 | } | 1394 | } |
1468 | 1395 | ||
1469 | static int snd_cs4231_new(snd_card_t * card, | 1396 | static int snd_cs4231_new(struct snd_card *card, |
1470 | unsigned short hardware, | 1397 | unsigned short hardware, |
1471 | unsigned short hwshare, | 1398 | unsigned short hwshare, |
1472 | cs4231_t ** rchip) | 1399 | struct snd_cs4231 ** rchip) |
1473 | { | 1400 | { |
1474 | cs4231_t *chip; | 1401 | struct snd_cs4231 *chip; |
1475 | 1402 | ||
1476 | *rchip = NULL; | 1403 | *rchip = NULL; |
1477 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1404 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
@@ -1493,20 +1420,18 @@ static int snd_cs4231_new(snd_card_t * card, | |||
1493 | return 0; | 1420 | return 0; |
1494 | } | 1421 | } |
1495 | 1422 | ||
1496 | #ifdef LEGACY_SUPPORT | 1423 | int snd_cs4231_create(struct snd_card *card, |
1497 | |||
1498 | int snd_cs4231_create(snd_card_t * card, | ||
1499 | unsigned long port, | 1424 | unsigned long port, |
1500 | unsigned long cport, | 1425 | unsigned long cport, |
1501 | int irq, int dma1, int dma2, | 1426 | int irq, int dma1, int dma2, |
1502 | unsigned short hardware, | 1427 | unsigned short hardware, |
1503 | unsigned short hwshare, | 1428 | unsigned short hwshare, |
1504 | cs4231_t ** rchip) | 1429 | struct snd_cs4231 ** rchip) |
1505 | { | 1430 | { |
1506 | static snd_device_ops_t ops = { | 1431 | static struct snd_device_ops ops = { |
1507 | .dev_free = snd_cs4231_dev_free, | 1432 | .dev_free = snd_cs4231_dev_free, |
1508 | }; | 1433 | }; |
1509 | cs4231_t *chip; | 1434 | struct snd_cs4231 *chip; |
1510 | int err; | 1435 | int err; |
1511 | 1436 | ||
1512 | err = snd_cs4231_new(card, hardware, hwshare, &chip); | 1437 | err = snd_cs4231_new(card, hardware, hwshare, &chip); |
@@ -1559,10 +1484,12 @@ int snd_cs4231_create(snd_card_t * card, | |||
1559 | } | 1484 | } |
1560 | snd_cs4231_init(chip); | 1485 | snd_cs4231_init(chip); |
1561 | 1486 | ||
1487 | #if 0 | ||
1562 | if (chip->hardware & CS4231_HW_CS4232_MASK) { | 1488 | if (chip->hardware & CS4231_HW_CS4232_MASK) { |
1563 | if (chip->res_cport == NULL) | 1489 | if (chip->res_cport == NULL) |
1564 | snd_printk("CS4232 control port features are not accessible\n"); | 1490 | snd_printk("CS4232 control port features are not accessible\n"); |
1565 | } | 1491 | } |
1492 | #endif | ||
1566 | 1493 | ||
1567 | /* Register device */ | 1494 | /* Register device */ |
1568 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1495 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
@@ -1574,16 +1501,13 @@ int snd_cs4231_create(snd_card_t * card, | |||
1574 | /* Power Management */ | 1501 | /* Power Management */ |
1575 | chip->suspend = snd_cs4231_suspend; | 1502 | chip->suspend = snd_cs4231_suspend; |
1576 | chip->resume = snd_cs4231_resume; | 1503 | chip->resume = snd_cs4231_resume; |
1577 | snd_card_set_isa_pm_callback(card, snd_cs4231_pm_suspend, snd_cs4231_pm_resume, chip); | ||
1578 | #endif | 1504 | #endif |
1579 | 1505 | ||
1580 | *rchip = chip; | 1506 | *rchip = chip; |
1581 | return 0; | 1507 | return 0; |
1582 | } | 1508 | } |
1583 | 1509 | ||
1584 | #endif /* LEGACY_SUPPORT */ | 1510 | static struct snd_pcm_ops snd_cs4231_playback_ops = { |
1585 | |||
1586 | static snd_pcm_ops_t snd_cs4231_playback_ops = { | ||
1587 | .open = snd_cs4231_playback_open, | 1511 | .open = snd_cs4231_playback_open, |
1588 | .close = snd_cs4231_playback_close, | 1512 | .close = snd_cs4231_playback_close, |
1589 | .ioctl = snd_pcm_lib_ioctl, | 1513 | .ioctl = snd_pcm_lib_ioctl, |
@@ -1594,7 +1518,7 @@ static snd_pcm_ops_t snd_cs4231_playback_ops = { | |||
1594 | .pointer = snd_cs4231_playback_pointer, | 1518 | .pointer = snd_cs4231_playback_pointer, |
1595 | }; | 1519 | }; |
1596 | 1520 | ||
1597 | static snd_pcm_ops_t snd_cs4231_capture_ops = { | 1521 | static struct snd_pcm_ops snd_cs4231_capture_ops = { |
1598 | .open = snd_cs4231_capture_open, | 1522 | .open = snd_cs4231_capture_open, |
1599 | .close = snd_cs4231_capture_close, | 1523 | .close = snd_cs4231_capture_close, |
1600 | .ioctl = snd_pcm_lib_ioctl, | 1524 | .ioctl = snd_pcm_lib_ioctl, |
@@ -1605,16 +1529,9 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { | |||
1605 | .pointer = snd_cs4231_capture_pointer, | 1529 | .pointer = snd_cs4231_capture_pointer, |
1606 | }; | 1530 | }; |
1607 | 1531 | ||
1608 | static void snd_cs4231_pcm_free(snd_pcm_t *pcm) | 1532 | int snd_cs4231_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm) |
1609 | { | 1533 | { |
1610 | cs4231_t *chip = pcm->private_data; | 1534 | struct snd_pcm *pcm; |
1611 | chip->pcm = NULL; | ||
1612 | snd_pcm_lib_preallocate_free_for_all(pcm); | ||
1613 | } | ||
1614 | |||
1615 | int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) | ||
1616 | { | ||
1617 | snd_pcm_t *pcm; | ||
1618 | int err; | 1535 | int err; |
1619 | 1536 | ||
1620 | if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0) | 1537 | if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0) |
@@ -1629,7 +1546,6 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) | |||
1629 | 1546 | ||
1630 | /* global setup */ | 1547 | /* global setup */ |
1631 | pcm->private_data = chip; | 1548 | pcm->private_data = chip; |
1632 | pcm->private_free = snd_cs4231_pcm_free; | ||
1633 | pcm->info_flags = 0; | 1549 | pcm->info_flags = 0; |
1634 | if (chip->single_dma) | 1550 | if (chip->single_dma) |
1635 | pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; | 1551 | pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; |
@@ -1637,27 +1553,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) | |||
1637 | pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; | 1553 | pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; |
1638 | strcpy(pcm->name, snd_cs4231_chip_id(chip)); | 1554 | strcpy(pcm->name, snd_cs4231_chip_id(chip)); |
1639 | 1555 | ||
1640 | #ifdef LEGACY_SUPPORT | ||
1641 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 1556 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1642 | snd_dma_isa_data(), | 1557 | snd_dma_isa_data(), |
1643 | 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); | 1558 | 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
1644 | #else | ||
1645 | # ifdef EBUS_SUPPORT | ||
1646 | if (chip->ebus_flag) { | ||
1647 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
1648 | chip->dev_u.pdev, | ||
1649 | 64*1024, 128*1024); | ||
1650 | } else { | ||
1651 | # endif | ||
1652 | # ifdef SBUS_SUPPORT | ||
1653 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS, | ||
1654 | chip->dev_u.sdev, | ||
1655 | 64*1024, 128*1024); | ||
1656 | # endif | ||
1657 | # ifdef EBUS_SUPPORT | ||
1658 | } | ||
1659 | # endif | ||
1660 | #endif | ||
1661 | 1559 | ||
1662 | chip->pcm = pcm; | 1560 | chip->pcm = pcm; |
1663 | if (rpcm) | 1561 | if (rpcm) |
@@ -1665,16 +1563,16 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) | |||
1665 | return 0; | 1563 | return 0; |
1666 | } | 1564 | } |
1667 | 1565 | ||
1668 | static void snd_cs4231_timer_free(snd_timer_t *timer) | 1566 | static void snd_cs4231_timer_free(struct snd_timer *timer) |
1669 | { | 1567 | { |
1670 | cs4231_t *chip = timer->private_data; | 1568 | struct snd_cs4231 *chip = timer->private_data; |
1671 | chip->timer = NULL; | 1569 | chip->timer = NULL; |
1672 | } | 1570 | } |
1673 | 1571 | ||
1674 | int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) | 1572 | int snd_cs4231_timer(struct snd_cs4231 *chip, int device, struct snd_timer **rtimer) |
1675 | { | 1573 | { |
1676 | snd_timer_t *timer; | 1574 | struct snd_timer *timer; |
1677 | snd_timer_id_t tid; | 1575 | struct snd_timer_id tid; |
1678 | int err; | 1576 | int err; |
1679 | 1577 | ||
1680 | /* Timer initialization */ | 1578 | /* Timer initialization */ |
@@ -1699,7 +1597,7 @@ int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) | |||
1699 | * MIXER part | 1597 | * MIXER part |
1700 | */ | 1598 | */ |
1701 | 1599 | ||
1702 | static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1600 | static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1703 | { | 1601 | { |
1704 | static char *texts[4] = { | 1602 | static char *texts[4] = { |
1705 | "Line", "Aux", "Mic", "Mix" | 1603 | "Line", "Aux", "Mic", "Mix" |
@@ -1711,7 +1609,7 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u | |||
1711 | "Line", "Synth", "Mic", "Mix" | 1609 | "Line", "Synth", "Mic", "Mix" |
1712 | }; | 1610 | }; |
1713 | char **ptexts = texts; | 1611 | char **ptexts = texts; |
1714 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1612 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1715 | 1613 | ||
1716 | snd_assert(chip->card != NULL, return -EINVAL); | 1614 | snd_assert(chip->card != NULL, return -EINVAL); |
1717 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 1615 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
@@ -1729,9 +1627,9 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u | |||
1729 | return 0; | 1627 | return 0; |
1730 | } | 1628 | } |
1731 | 1629 | ||
1732 | static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1630 | static int snd_cs4231_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1733 | { | 1631 | { |
1734 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1632 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1735 | unsigned long flags; | 1633 | unsigned long flags; |
1736 | 1634 | ||
1737 | spin_lock_irqsave(&chip->reg_lock, flags); | 1635 | spin_lock_irqsave(&chip->reg_lock, flags); |
@@ -1741,9 +1639,9 @@ static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * | |||
1741 | return 0; | 1639 | return 0; |
1742 | } | 1640 | } |
1743 | 1641 | ||
1744 | static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1642 | static int snd_cs4231_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1745 | { | 1643 | { |
1746 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1644 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1747 | unsigned long flags; | 1645 | unsigned long flags; |
1748 | unsigned short left, right; | 1646 | unsigned short left, right; |
1749 | int change; | 1647 | int change; |
@@ -1764,7 +1662,7 @@ static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * | |||
1764 | return change; | 1662 | return change; |
1765 | } | 1663 | } |
1766 | 1664 | ||
1767 | int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1665 | int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1768 | { | 1666 | { |
1769 | int mask = (kcontrol->private_value >> 16) & 0xff; | 1667 | int mask = (kcontrol->private_value >> 16) & 0xff; |
1770 | 1668 | ||
@@ -1775,9 +1673,9 @@ int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo | |||
1775 | return 0; | 1673 | return 0; |
1776 | } | 1674 | } |
1777 | 1675 | ||
1778 | int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1676 | int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1779 | { | 1677 | { |
1780 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1678 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1781 | unsigned long flags; | 1679 | unsigned long flags; |
1782 | int reg = kcontrol->private_value & 0xff; | 1680 | int reg = kcontrol->private_value & 0xff; |
1783 | int shift = (kcontrol->private_value >> 8) & 0xff; | 1681 | int shift = (kcontrol->private_value >> 8) & 0xff; |
@@ -1792,9 +1690,9 @@ int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon | |||
1792 | return 0; | 1690 | return 0; |
1793 | } | 1691 | } |
1794 | 1692 | ||
1795 | int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1693 | int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1796 | { | 1694 | { |
1797 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1695 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1798 | unsigned long flags; | 1696 | unsigned long flags; |
1799 | int reg = kcontrol->private_value & 0xff; | 1697 | int reg = kcontrol->private_value & 0xff; |
1800 | int shift = (kcontrol->private_value >> 8) & 0xff; | 1698 | int shift = (kcontrol->private_value >> 8) & 0xff; |
@@ -1815,7 +1713,7 @@ int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon | |||
1815 | return change; | 1713 | return change; |
1816 | } | 1714 | } |
1817 | 1715 | ||
1818 | int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1716 | int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1819 | { | 1717 | { |
1820 | int mask = (kcontrol->private_value >> 24) & 0xff; | 1718 | int mask = (kcontrol->private_value >> 24) & 0xff; |
1821 | 1719 | ||
@@ -1826,9 +1724,9 @@ int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo | |||
1826 | return 0; | 1724 | return 0; |
1827 | } | 1725 | } |
1828 | 1726 | ||
1829 | int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1727 | int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1830 | { | 1728 | { |
1831 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1729 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1832 | unsigned long flags; | 1730 | unsigned long flags; |
1833 | int left_reg = kcontrol->private_value & 0xff; | 1731 | int left_reg = kcontrol->private_value & 0xff; |
1834 | int right_reg = (kcontrol->private_value >> 8) & 0xff; | 1732 | int right_reg = (kcontrol->private_value >> 8) & 0xff; |
@@ -1848,9 +1746,9 @@ int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon | |||
1848 | return 0; | 1746 | return 0; |
1849 | } | 1747 | } |
1850 | 1748 | ||
1851 | int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1749 | int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1852 | { | 1750 | { |
1853 | cs4231_t *chip = snd_kcontrol_chip(kcontrol); | 1751 | struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); |
1854 | unsigned long flags; | 1752 | unsigned long flags; |
1855 | int left_reg = kcontrol->private_value & 0xff; | 1753 | int left_reg = kcontrol->private_value & 0xff; |
1856 | int right_reg = (kcontrol->private_value >> 8) & 0xff; | 1754 | int right_reg = (kcontrol->private_value >> 8) & 0xff; |
@@ -1879,7 +1777,7 @@ int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon | |||
1879 | return change; | 1777 | return change; |
1880 | } | 1778 | } |
1881 | 1779 | ||
1882 | static snd_kcontrol_new_t snd_cs4231_controls[] = { | 1780 | static struct snd_kcontrol_new snd_cs4231_controls[] = { |
1883 | CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 1781 | CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
1884 | CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 1782 | CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), |
1885 | CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 1783 | CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
@@ -1905,9 +1803,9 @@ CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | |||
1905 | CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1) | 1803 | CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1) |
1906 | }; | 1804 | }; |
1907 | 1805 | ||
1908 | int snd_cs4231_mixer(cs4231_t *chip) | 1806 | int snd_cs4231_mixer(struct snd_cs4231 *chip) |
1909 | { | 1807 | { |
1910 | snd_card_t *card; | 1808 | struct snd_card *card; |
1911 | unsigned int idx; | 1809 | unsigned int idx; |
1912 | int err; | 1810 | int err; |
1913 | 1811 | ||