diff options
Diffstat (limited to 'sound/pci/ctxfi/cthw20k2.c')
-rw-r--r-- | sound/pci/ctxfi/cthw20k2.c | 73 |
1 files changed, 58 insertions, 15 deletions
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index dec46d04b041..b6b11bfe7574 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c | |||
@@ -166,7 +166,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) | |||
166 | 166 | ||
167 | *rblk = NULL; | 167 | *rblk = NULL; |
168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
169 | if (NULL == blk) | 169 | if (!blk) |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | 171 | ||
172 | *rblk = blk; | 172 | *rblk = blk; |
@@ -492,7 +492,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) | |||
492 | 492 | ||
493 | *rblk = NULL; | 493 | *rblk = NULL; |
494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
495 | if (NULL == blk) | 495 | if (!blk) |
496 | return -ENOMEM; | 496 | return -ENOMEM; |
497 | 497 | ||
498 | *rblk = blk; | 498 | *rblk = blk; |
@@ -513,7 +513,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) | |||
513 | 513 | ||
514 | *rblk = NULL; | 514 | *rblk = NULL; |
515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
516 | if (NULL == blk) | 516 | if (!blk) |
517 | return -ENOMEM; | 517 | return -ENOMEM; |
518 | 518 | ||
519 | *rblk = blk; | 519 | *rblk = blk; |
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) | |||
702 | 702 | ||
703 | *rblk = NULL; | 703 | *rblk = NULL; |
704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
705 | if (NULL == blk) | 705 | if (!blk) |
706 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | 707 | ||
708 | *rblk = blk; | 708 | *rblk = blk; |
@@ -891,7 +891,7 @@ static int dai_get_ctrl_blk(void **rblk) | |||
891 | 891 | ||
892 | *rblk = NULL; | 892 | *rblk = NULL; |
893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
894 | if (NULL == blk) | 894 | if (!blk) |
895 | return -ENOMEM; | 895 | return -ENOMEM; |
896 | 896 | ||
897 | *rblk = blk; | 897 | *rblk = blk; |
@@ -941,7 +941,7 @@ static int dao_get_ctrl_blk(void **rblk) | |||
941 | 941 | ||
942 | *rblk = NULL; | 942 | *rblk = NULL; |
943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
944 | if (NULL == blk) | 944 | if (!blk) |
945 | return -ENOMEM; | 945 | return -ENOMEM; |
946 | 946 | ||
947 | *rblk = blk; | 947 | *rblk = blk; |
@@ -1092,7 +1092,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) | |||
1092 | 1092 | ||
1093 | *rblk = NULL; | 1093 | *rblk = NULL; |
1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
1095 | if (NULL == blk) | 1095 | if (!blk) |
1096 | return -ENOMEM; | 1096 | return -ENOMEM; |
1097 | 1097 | ||
1098 | for (i = 0; i < 8; i++) { | 1098 | for (i = 0; i < 8; i++) { |
@@ -1112,6 +1112,26 @@ static int daio_mgr_put_ctrl_blk(void *blk) | |||
1112 | return 0; | 1112 | return 0; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | /* Timer interrupt */ | ||
1116 | static int set_timer_irq(struct hw *hw, int enable) | ||
1117 | { | ||
1118 | hw_write_20kx(hw, GIE, enable ? IT_INT : 0); | ||
1119 | return 0; | ||
1120 | } | ||
1121 | |||
1122 | static int set_timer_tick(struct hw *hw, unsigned int ticks) | ||
1123 | { | ||
1124 | if (ticks) | ||
1125 | ticks |= TIMR_IE | TIMR_IP; | ||
1126 | hw_write_20kx(hw, TIMR, ticks); | ||
1127 | return 0; | ||
1128 | } | ||
1129 | |||
1130 | static unsigned int get_wc(struct hw *hw) | ||
1131 | { | ||
1132 | return hw_read_20kx(hw, WC); | ||
1133 | } | ||
1134 | |||
1115 | /* Card hardware initialization block */ | 1135 | /* Card hardware initialization block */ |
1116 | struct dac_conf { | 1136 | struct dac_conf { |
1117 | unsigned int msr; /* master sample rate in rsrs */ | 1137 | unsigned int msr; /* master sample rate in rsrs */ |
@@ -1841,6 +1861,22 @@ static int hw_have_digit_io_switch(struct hw *hw) | |||
1841 | return 0; | 1861 | return 0; |
1842 | } | 1862 | } |
1843 | 1863 | ||
1864 | static irqreturn_t ct_20k2_interrupt(int irq, void *dev_id) | ||
1865 | { | ||
1866 | struct hw *hw = dev_id; | ||
1867 | unsigned int status; | ||
1868 | |||
1869 | status = hw_read_20kx(hw, GIP); | ||
1870 | if (!status) | ||
1871 | return IRQ_NONE; | ||
1872 | |||
1873 | if (hw->irq_callback) | ||
1874 | hw->irq_callback(hw->irq_callback_data, status); | ||
1875 | |||
1876 | hw_write_20kx(hw, GIP, status); | ||
1877 | return IRQ_HANDLED; | ||
1878 | } | ||
1879 | |||
1844 | static int hw_card_start(struct hw *hw) | 1880 | static int hw_card_start(struct hw *hw) |
1845 | { | 1881 | { |
1846 | int err = 0; | 1882 | int err = 0; |
@@ -1868,7 +1904,7 @@ static int hw_card_start(struct hw *hw) | |||
1868 | hw->io_base = pci_resource_start(hw->pci, 2); | 1904 | hw->io_base = pci_resource_start(hw->pci, 2); |
1869 | hw->mem_base = (unsigned long)ioremap(hw->io_base, | 1905 | hw->mem_base = (unsigned long)ioremap(hw->io_base, |
1870 | pci_resource_len(hw->pci, 2)); | 1906 | pci_resource_len(hw->pci, 2)); |
1871 | if (NULL == (void *)hw->mem_base) { | 1907 | if (!hw->mem_base) { |
1872 | err = -ENOENT; | 1908 | err = -ENOENT; |
1873 | goto error2; | 1909 | goto error2; |
1874 | } | 1910 | } |
@@ -1879,12 +1915,15 @@ static int hw_card_start(struct hw *hw) | |||
1879 | set_field(&gctl, GCTL_UAA, 0); | 1915 | set_field(&gctl, GCTL_UAA, 0); |
1880 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 1916 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1881 | 1917 | ||
1882 | /*if ((err = request_irq(pci->irq, ct_atc_interrupt, IRQF_SHARED, | 1918 | if (hw->irq < 0) { |
1883 | atc->chip_details->nm_card, hw))) { | 1919 | err = request_irq(pci->irq, ct_20k2_interrupt, IRQF_SHARED, |
1884 | goto error3; | 1920 | "ctxfi", hw); |
1921 | if (err < 0) { | ||
1922 | printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq); | ||
1923 | goto error2; | ||
1924 | } | ||
1925 | hw->irq = pci->irq; | ||
1885 | } | 1926 | } |
1886 | hw->irq = pci->irq; | ||
1887 | */ | ||
1888 | 1927 | ||
1889 | pci_set_master(pci); | 1928 | pci_set_master(pci); |
1890 | 1929 | ||
@@ -1923,7 +1962,7 @@ static int hw_card_shutdown(struct hw *hw) | |||
1923 | 1962 | ||
1924 | hw->irq = -1; | 1963 | hw->irq = -1; |
1925 | 1964 | ||
1926 | if (NULL != ((void *)hw->mem_base)) | 1965 | if (hw->mem_base) |
1927 | iounmap((void *)hw->mem_base); | 1966 | iounmap((void *)hw->mem_base); |
1928 | 1967 | ||
1929 | hw->mem_base = (unsigned long)NULL; | 1968 | hw->mem_base = (unsigned long)NULL; |
@@ -1972,7 +2011,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
1972 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 2011 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1973 | 2012 | ||
1974 | /* Reset all global pending interrupts */ | 2013 | /* Reset all global pending interrupts */ |
1975 | hw_write_20kx(hw, INTERRUPT_GIE, 0); | 2014 | hw_write_20kx(hw, GIE, 0); |
1976 | /* Reset all SRC pending interrupts */ | 2015 | /* Reset all SRC pending interrupts */ |
1977 | hw_write_20kx(hw, SRC_IP, 0); | 2016 | hw_write_20kx(hw, SRC_IP, 0); |
1978 | 2017 | ||
@@ -2149,6 +2188,10 @@ static struct hw ct20k2_preset __devinitdata = { | |||
2149 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, | 2188 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, |
2150 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, | 2189 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, |
2151 | .daio_mgr_commit_write = daio_mgr_commit_write, | 2190 | .daio_mgr_commit_write = daio_mgr_commit_write, |
2191 | |||
2192 | .set_timer_irq = set_timer_irq, | ||
2193 | .set_timer_tick = set_timer_tick, | ||
2194 | .get_wc = get_wc, | ||
2152 | }; | 2195 | }; |
2153 | 2196 | ||
2154 | int __devinit create_20k2_hw_obj(struct hw **rhw) | 2197 | int __devinit create_20k2_hw_obj(struct hw **rhw) |