| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
|---|
| 3 | 4 | * Routines for Sound Blaster mixer control |
|---|
| 4 | | - * |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | | - * |
|---|
| 20 | 5 | */ |
|---|
| 21 | 6 | |
|---|
| 22 | 7 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 453 | 438 | */ |
|---|
| 454 | 439 | int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value) |
|---|
| 455 | 440 | { |
|---|
| 456 | | - static struct snd_kcontrol_new newctls[] = { |
|---|
| 441 | + static const struct snd_kcontrol_new newctls[] = { |
|---|
| 457 | 442 | [SB_MIX_SINGLE] = { |
|---|
| 458 | 443 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
|---|
| 459 | 444 | .info = snd_sbmixer_info_single, |
|---|
| .. | .. |
|---|
| 509 | 494 | * SB 2.0 specific mixer elements |
|---|
| 510 | 495 | */ |
|---|
| 511 | 496 | |
|---|
| 512 | | -static struct sbmix_elem snd_sb20_controls[] = { |
|---|
| 497 | +static const struct sbmix_elem snd_sb20_controls[] = { |
|---|
| 513 | 498 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), |
|---|
| 514 | 499 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), |
|---|
| 515 | 500 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), |
|---|
| 516 | 501 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) |
|---|
| 517 | 502 | }; |
|---|
| 518 | 503 | |
|---|
| 519 | | -static unsigned char snd_sb20_init_values[][2] = { |
|---|
| 504 | +static const unsigned char snd_sb20_init_values[][2] = { |
|---|
| 520 | 505 | { SB_DSP20_MASTER_DEV, 0 }, |
|---|
| 521 | 506 | { SB_DSP20_FM_DEV, 0 }, |
|---|
| 522 | 507 | }; |
|---|
| .. | .. |
|---|
| 524 | 509 | /* |
|---|
| 525 | 510 | * SB Pro specific mixer elements |
|---|
| 526 | 511 | */ |
|---|
| 527 | | -static struct sbmix_elem snd_sbpro_controls[] = { |
|---|
| 512 | +static const struct sbmix_elem snd_sbpro_controls[] = { |
|---|
| 528 | 513 | SB_DOUBLE("Master Playback Volume", |
|---|
| 529 | 514 | SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), |
|---|
| 530 | 515 | SB_DOUBLE("PCM Playback Volume", |
|---|
| .. | .. |
|---|
| 544 | 529 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1) |
|---|
| 545 | 530 | }; |
|---|
| 546 | 531 | |
|---|
| 547 | | -static unsigned char snd_sbpro_init_values[][2] = { |
|---|
| 532 | +static const unsigned char snd_sbpro_init_values[][2] = { |
|---|
| 548 | 533 | { SB_DSP_MASTER_DEV, 0 }, |
|---|
| 549 | 534 | { SB_DSP_PCM_DEV, 0 }, |
|---|
| 550 | 535 | { SB_DSP_FM_DEV, 0 }, |
|---|
| .. | .. |
|---|
| 553 | 538 | /* |
|---|
| 554 | 539 | * SB16 specific mixer elements |
|---|
| 555 | 540 | */ |
|---|
| 556 | | -static struct sbmix_elem snd_sb16_controls[] = { |
|---|
| 541 | +static const struct sbmix_elem snd_sb16_controls[] = { |
|---|
| 557 | 542 | SB_DOUBLE("Master Playback Volume", |
|---|
| 558 | 543 | SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), |
|---|
| 559 | 544 | SB_DOUBLE("PCM Playback Volume", |
|---|
| .. | .. |
|---|
| 591 | 576 | SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) |
|---|
| 592 | 577 | }; |
|---|
| 593 | 578 | |
|---|
| 594 | | -static unsigned char snd_sb16_init_values[][2] = { |
|---|
| 579 | +static const unsigned char snd_sb16_init_values[][2] = { |
|---|
| 595 | 580 | { SB_DSP4_MASTER_DEV + 0, 0 }, |
|---|
| 596 | 581 | { SB_DSP4_MASTER_DEV + 1, 0 }, |
|---|
| 597 | 582 | { SB_DSP4_PCM_DEV + 0, 0 }, |
|---|
| .. | .. |
|---|
| 607 | 592 | /* |
|---|
| 608 | 593 | * DT019x specific mixer elements |
|---|
| 609 | 594 | */ |
|---|
| 610 | | -static struct sbmix_elem snd_dt019x_controls[] = { |
|---|
| 595 | +static const struct sbmix_elem snd_dt019x_controls[] = { |
|---|
| 611 | 596 | /* ALS4000 below has some parts which we might be lacking, |
|---|
| 612 | 597 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ |
|---|
| 613 | 598 | SB_DOUBLE("Master Playback Volume", |
|---|
| .. | .. |
|---|
| 637 | 622 | } |
|---|
| 638 | 623 | }; |
|---|
| 639 | 624 | |
|---|
| 640 | | -static unsigned char snd_dt019x_init_values[][2] = { |
|---|
| 625 | +static const unsigned char snd_dt019x_init_values[][2] = { |
|---|
| 641 | 626 | { SB_DT019X_MASTER_DEV, 0 }, |
|---|
| 642 | 627 | { SB_DT019X_PCM_DEV, 0 }, |
|---|
| 643 | 628 | { SB_DT019X_SYNTH_DEV, 0 }, |
|---|
| .. | .. |
|---|
| 652 | 637 | /* |
|---|
| 653 | 638 | * ALS4000 specific mixer elements |
|---|
| 654 | 639 | */ |
|---|
| 655 | | -static struct sbmix_elem snd_als4000_controls[] = { |
|---|
| 640 | +static const struct sbmix_elem snd_als4000_controls[] = { |
|---|
| 656 | 641 | SB_DOUBLE("PCM Playback Switch", |
|---|
| 657 | 642 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
|---|
| 658 | 643 | SB_DOUBLE("Synth Playback Switch", |
|---|
| .. | .. |
|---|
| 686 | 671 | #endif |
|---|
| 687 | 672 | }; |
|---|
| 688 | 673 | |
|---|
| 689 | | -static unsigned char snd_als4000_init_values[][2] = { |
|---|
| 674 | +static const unsigned char snd_als4000_init_values[][2] = { |
|---|
| 690 | 675 | { SB_DSP4_MASTER_DEV + 0, 0 }, |
|---|
| 691 | 676 | { SB_DSP4_MASTER_DEV + 1, 0 }, |
|---|
| 692 | 677 | { SB_DSP4_PCM_DEV + 0, 0 }, |
|---|
| .. | .. |
|---|
| 704 | 689 | /* |
|---|
| 705 | 690 | */ |
|---|
| 706 | 691 | static int snd_sbmixer_init(struct snd_sb *chip, |
|---|
| 707 | | - struct sbmix_elem *controls, |
|---|
| 692 | + const struct sbmix_elem *controls, |
|---|
| 708 | 693 | int controls_count, |
|---|
| 709 | | - unsigned char map[][2], |
|---|
| 694 | + const unsigned char map[][2], |
|---|
| 710 | 695 | int map_count, |
|---|
| 711 | 696 | char *name) |
|---|
| 712 | 697 | { |
|---|
| .. | .. |
|---|
| 815 | 800 | } |
|---|
| 816 | 801 | |
|---|
| 817 | 802 | #ifdef CONFIG_PM |
|---|
| 818 | | -static unsigned char sb20_saved_regs[] = { |
|---|
| 803 | +static const unsigned char sb20_saved_regs[] = { |
|---|
| 819 | 804 | SB_DSP20_MASTER_DEV, |
|---|
| 820 | 805 | SB_DSP20_PCM_DEV, |
|---|
| 821 | 806 | SB_DSP20_FM_DEV, |
|---|
| 822 | 807 | SB_DSP20_CD_DEV, |
|---|
| 823 | 808 | }; |
|---|
| 824 | 809 | |
|---|
| 825 | | -static unsigned char sbpro_saved_regs[] = { |
|---|
| 810 | +static const unsigned char sbpro_saved_regs[] = { |
|---|
| 826 | 811 | SB_DSP_MASTER_DEV, |
|---|
| 827 | 812 | SB_DSP_PCM_DEV, |
|---|
| 828 | 813 | SB_DSP_PLAYBACK_FILT, |
|---|
| .. | .. |
|---|
| 834 | 819 | SB_DSP_CAPTURE_FILT, |
|---|
| 835 | 820 | }; |
|---|
| 836 | 821 | |
|---|
| 837 | | -static unsigned char sb16_saved_regs[] = { |
|---|
| 822 | +static const unsigned char sb16_saved_regs[] = { |
|---|
| 838 | 823 | SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, |
|---|
| 839 | 824 | SB_DSP4_3DSE, |
|---|
| 840 | 825 | SB_DSP4_BASS_DEV, SB_DSP4_BASS_DEV + 1, |
|---|
| .. | .. |
|---|
| 852 | 837 | SB_DSP4_MIC_AGC |
|---|
| 853 | 838 | }; |
|---|
| 854 | 839 | |
|---|
| 855 | | -static unsigned char dt019x_saved_regs[] = { |
|---|
| 840 | +static const unsigned char dt019x_saved_regs[] = { |
|---|
| 856 | 841 | SB_DT019X_MASTER_DEV, |
|---|
| 857 | 842 | SB_DT019X_PCM_DEV, |
|---|
| 858 | 843 | SB_DT019X_SYNTH_DEV, |
|---|
| .. | .. |
|---|
| 865 | 850 | SB_DT019X_CAPTURE_SW, |
|---|
| 866 | 851 | }; |
|---|
| 867 | 852 | |
|---|
| 868 | | -static unsigned char als4000_saved_regs[] = { |
|---|
| 853 | +static const unsigned char als4000_saved_regs[] = { |
|---|
| 869 | 854 | /* please verify in dsheet whether regs to be added |
|---|
| 870 | 855 | are actually real H/W or just dummy */ |
|---|
| 871 | 856 | SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, |
|---|
| .. | .. |
|---|
| 887 | 872 | SB_ALS4000_CR3_CONFIGURATION, |
|---|
| 888 | 873 | }; |
|---|
| 889 | 874 | |
|---|
| 890 | | -static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) |
|---|
| 875 | +static void save_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs) |
|---|
| 891 | 876 | { |
|---|
| 892 | 877 | unsigned char *val = chip->saved_regs; |
|---|
| 893 | 878 | if (snd_BUG_ON(num_regs > ARRAY_SIZE(chip->saved_regs))) |
|---|
| .. | .. |
|---|
| 896 | 881 | *val++ = snd_sbmixer_read(chip, *regs++); |
|---|
| 897 | 882 | } |
|---|
| 898 | 883 | |
|---|
| 899 | | -static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) |
|---|
| 884 | +static void restore_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs) |
|---|
| 900 | 885 | { |
|---|
| 901 | 886 | unsigned char *val = chip->saved_regs; |
|---|
| 902 | 887 | if (snd_BUG_ON(num_regs > ARRAY_SIZE(chip->saved_regs))) |
|---|