diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-06-08 12:10:32 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-08 12:10:32 -0400 |
commit | 9470195a9cd13e6d90221b8b5d897e9232da8d28 (patch) | |
tree | 12f57a49fe94310396f7108c267560c74189c0e0 /sound/pci/ctxfi/cthw20k1.c | |
parent | d362af62ed98f58c64a2b3dd58c79d25ad181b0b (diff) |
ALSA: ctxfi - Clean up probe routines
Clean up probe routines and model detection routines so that the driver
won't call and check the PCI subsystem id at each time.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ctxfi/cthw20k1.c')
-rw-r--r-- | sound/pci/ctxfi/cthw20k1.c | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 38b87b6ee6d4..5d58650beb73 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c | |||
@@ -1432,11 +1432,9 @@ static int hw_dac_init(struct hw *hw, const struct dac_conf *info) | |||
1432 | { | 1432 | { |
1433 | u32 data; | 1433 | u32 data; |
1434 | u16 gpioorg; | 1434 | u16 gpioorg; |
1435 | u16 subsys_id; | ||
1436 | unsigned int ret; | 1435 | unsigned int ret; |
1437 | 1436 | ||
1438 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | 1437 | if (hw->model == CTSB055X) { |
1439 | if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { | ||
1440 | /* SB055x, unmute outputs */ | 1438 | /* SB055x, unmute outputs */ |
1441 | gpioorg = (u16)hw_read_20kx(hw, GPIO); | 1439 | gpioorg = (u16)hw_read_20kx(hw, GPIO); |
1442 | gpioorg &= 0xffbf; /* set GPIO6 to low */ | 1440 | gpioorg &= 0xffbf; /* set GPIO6 to low */ |
@@ -1538,19 +1536,14 @@ static int is_adc_input_selected_hendrix(struct hw *hw, enum ADCSRC type) | |||
1538 | 1536 | ||
1539 | static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) | 1537 | static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) |
1540 | { | 1538 | { |
1541 | u16 subsys_id; | 1539 | switch (hw->model) { |
1542 | 1540 | case CTSB055X: | |
1543 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | ||
1544 | if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { | ||
1545 | /* SB055x cards */ | ||
1546 | return is_adc_input_selected_SB055x(hw, type); | 1541 | return is_adc_input_selected_SB055x(hw, type); |
1547 | } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { | 1542 | case CTSB073X: |
1548 | /* SB073x cards */ | ||
1549 | return is_adc_input_selected_hendrix(hw, type); | 1543 | return is_adc_input_selected_hendrix(hw, type); |
1550 | } else if ((subsys_id & 0xf000) == 0x6000) { | 1544 | case CTHENDRIX: |
1551 | /* Vista compatible cards */ | ||
1552 | return is_adc_input_selected_hendrix(hw, type); | 1545 | return is_adc_input_selected_hendrix(hw, type); |
1553 | } else { | 1546 | default: |
1554 | return is_adc_input_selected_SBx(hw, type); | 1547 | return is_adc_input_selected_SBx(hw, type); |
1555 | } | 1548 | } |
1556 | } | 1549 | } |
@@ -1692,20 +1685,17 @@ adc_input_select_hendrix(struct hw *hw, enum ADCSRC type, unsigned char boost) | |||
1692 | 1685 | ||
1693 | static int hw_adc_input_select(struct hw *hw, enum ADCSRC type) | 1686 | static int hw_adc_input_select(struct hw *hw, enum ADCSRC type) |
1694 | { | 1687 | { |
1695 | u16 subsys_id; | 1688 | int state = type == ADC_MICIN; |
1696 | 1689 | ||
1697 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | 1690 | switch (hw->model) { |
1698 | if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { | 1691 | case CTSB055X: |
1699 | /* SB055x cards */ | 1692 | return adc_input_select_SB055x(hw, type, state); |
1700 | return adc_input_select_SB055x(hw, type, (ADC_MICIN == type)); | 1693 | case CTSB073X: |
1701 | } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { | 1694 | return adc_input_select_hendrix(hw, type, state); |
1702 | /* SB073x cards */ | 1695 | case CTHENDRIX: |
1703 | return adc_input_select_hendrix(hw, type, (ADC_MICIN == type)); | 1696 | return adc_input_select_hendrix(hw, type, state); |
1704 | } else if ((subsys_id & 0xf000) == 0x6000) { | 1697 | default: |
1705 | /* Vista compatible cards */ | 1698 | return adc_input_select_SBx(hw, type, state); |
1706 | return adc_input_select_hendrix(hw, type, (ADC_MICIN == type)); | ||
1707 | } else { | ||
1708 | return adc_input_select_SBx(hw, type, (ADC_MICIN == type)); | ||
1709 | } | 1699 | } |
1710 | } | 1700 | } |
1711 | 1701 | ||
@@ -1781,28 +1771,16 @@ static int adc_init_SBx(struct hw *hw, int input, int mic20db) | |||
1781 | 1771 | ||
1782 | static int hw_adc_init(struct hw *hw, const struct adc_conf *info) | 1772 | static int hw_adc_init(struct hw *hw, const struct adc_conf *info) |
1783 | { | 1773 | { |
1784 | int err; | 1774 | if (hw->model == CTSB055X) |
1785 | u16 subsys_id; | 1775 | return adc_init_SB055x(hw, info->input, info->mic20db); |
1786 | 1776 | else | |
1787 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | 1777 | return adc_init_SBx(hw, info->input, info->mic20db); |
1788 | if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { | ||
1789 | /* Sb055x card */ | ||
1790 | err = adc_init_SB055x(hw, info->input, info->mic20db); | ||
1791 | } else { | ||
1792 | err = adc_init_SBx(hw, info->input, info->mic20db); | ||
1793 | } | ||
1794 | |||
1795 | return err; | ||
1796 | } | 1778 | } |
1797 | 1779 | ||
1798 | static int hw_have_digit_io_switch(struct hw *hw) | 1780 | static int hw_have_digit_io_switch(struct hw *hw) |
1799 | { | 1781 | { |
1800 | u16 subsys_id; | ||
1801 | |||
1802 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | ||
1803 | /* SB073x and Vista compatible cards have no digit IO switch */ | 1782 | /* SB073x and Vista compatible cards have no digit IO switch */ |
1804 | return !((subsys_id == 0x0029) || (subsys_id == 0x0031) | 1783 | return !(hw->model == CTSB073X || hw->model == CTHENDRIX); |
1805 | || ((subsys_id & 0xf000) == 0x6000)); | ||
1806 | } | 1784 | } |
1807 | 1785 | ||
1808 | #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) | 1786 | #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) |
@@ -1918,7 +1896,6 @@ static int hw_card_start(struct hw *hw) | |||
1918 | { | 1896 | { |
1919 | int err; | 1897 | int err; |
1920 | struct pci_dev *pci = hw->pci; | 1898 | struct pci_dev *pci = hw->pci; |
1921 | u16 subsys_id; | ||
1922 | 1899 | ||
1923 | err = pci_enable_device(pci); | 1900 | err = pci_enable_device(pci); |
1924 | if (err < 0) | 1901 | if (err < 0) |
@@ -1939,8 +1916,7 @@ static int hw_card_start(struct hw *hw) | |||
1939 | goto error1; | 1916 | goto error1; |
1940 | 1917 | ||
1941 | /* Switch to X-Fi mode from UAA mode if neeeded */ | 1918 | /* Switch to X-Fi mode from UAA mode if neeeded */ |
1942 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsys_id); | 1919 | if (hw->model == CTHENDRIX) { |
1943 | if ((0x5 == pci->device) && (0x6000 == (subsys_id & 0x6000))) { | ||
1944 | err = uaa_to_xfi(pci); | 1920 | err = uaa_to_xfi(pci); |
1945 | if (err) | 1921 | if (err) |
1946 | goto error2; | 1922 | goto error2; |
@@ -2004,7 +1980,6 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
2004 | { | 1980 | { |
2005 | int err; | 1981 | int err; |
2006 | unsigned int gctl; | 1982 | unsigned int gctl; |
2007 | u16 subsys_id; | ||
2008 | u32 data; | 1983 | u32 data; |
2009 | struct dac_conf dac_info = {0}; | 1984 | struct dac_conf dac_info = {0}; |
2010 | struct adc_conf adc_info = {0}; | 1985 | struct adc_conf adc_info = {0}; |
@@ -2044,19 +2019,20 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
2044 | hw_write_20kx(hw, SRCIP, 0); | 2019 | hw_write_20kx(hw, SRCIP, 0); |
2045 | mdelay(30); | 2020 | mdelay(30); |
2046 | 2021 | ||
2047 | pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); | ||
2048 | /* Detect the card ID and configure GPIO accordingly. */ | 2022 | /* Detect the card ID and configure GPIO accordingly. */ |
2049 | if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { | 2023 | switch (hw->model) { |
2050 | /* SB055x cards */ | 2024 | case CTSB055X: |
2051 | hw_write_20kx(hw, GPIOCTL, 0x13fe); | 2025 | hw_write_20kx(hw, GPIOCTL, 0x13fe); |
2052 | } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { | 2026 | break; |
2053 | /* SB073x cards */ | 2027 | case CTSB073X: |
2054 | hw_write_20kx(hw, GPIOCTL, 0x00e6); | 2028 | hw_write_20kx(hw, GPIOCTL, 0x00e6); |
2055 | } else if ((subsys_id & 0xf000) == 0x6000) { | 2029 | break; |
2056 | /* Vista compatible cards */ | 2030 | case CTHENDRIX: /* Vista compatible cards */ |
2057 | hw_write_20kx(hw, GPIOCTL, 0x00c2); | 2031 | hw_write_20kx(hw, GPIOCTL, 0x00c2); |
2058 | } else { | 2032 | break; |
2033 | default: | ||
2059 | hw_write_20kx(hw, GPIOCTL, 0x01e6); | 2034 | hw_write_20kx(hw, GPIOCTL, 0x01e6); |
2035 | break; | ||
2060 | } | 2036 | } |
2061 | 2037 | ||
2062 | trn_info.vm_pgt_phys = info->vm_pgt_phys; | 2038 | trn_info.vm_pgt_phys = info->vm_pgt_phys; |