aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/maestro3.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /sound/pci/maestro3.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'sound/pci/maestro3.c')
-rw-r--r--sound/pci/maestro3.c151
1 files changed, 112 insertions, 39 deletions
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 9387533f70d..0378126e627 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -39,7 +39,7 @@
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
42#include <linux/module.h> 42#include <linux/moduleparam.h>
43#include <linux/firmware.h> 43#include <linux/firmware.h>
44#include <linux/input.h> 44#include <linux/input.h>
45#include <sound/core.h> 45#include <sound/core.h>
@@ -64,8 +64,8 @@ MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
64 64
65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 65static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 66static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
67static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */ 67static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* all enabled */
68static bool external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 68static int external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; 69static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
70 70
71module_param_array(index, int, NULL, 0444); 71module_param_array(index, int, NULL, 0444);
@@ -361,6 +361,74 @@ MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)");
361#define DSP2HOST_REQ_I2SRATE 0x02 361#define DSP2HOST_REQ_I2SRATE 0x02
362#define DSP2HOST_REQ_TIMER 0x04 362#define DSP2HOST_REQ_TIMER 0x04
363 363
364/* AC97 registers */
365/* XXX fix this crap up */
366/*#define AC97_RESET 0x00*/
367
368#define AC97_VOL_MUTE_B 0x8000
369#define AC97_VOL_M 0x1F
370#define AC97_LEFT_VOL_S 8
371
372#define AC97_MASTER_VOL 0x02
373#define AC97_LINE_LEVEL_VOL 0x04
374#define AC97_MASTER_MONO_VOL 0x06
375#define AC97_PC_BEEP_VOL 0x0A
376#define AC97_PC_BEEP_VOL_M 0x0F
377#define AC97_SROUND_MASTER_VOL 0x38
378#define AC97_PC_BEEP_VOL_S 1
379
380/*#define AC97_PHONE_VOL 0x0C
381#define AC97_MIC_VOL 0x0E*/
382#define AC97_MIC_20DB_ENABLE 0x40
383
384/*#define AC97_LINEIN_VOL 0x10
385#define AC97_CD_VOL 0x12
386#define AC97_VIDEO_VOL 0x14
387#define AC97_AUX_VOL 0x16*/
388#define AC97_PCM_OUT_VOL 0x18
389/*#define AC97_RECORD_SELECT 0x1A*/
390#define AC97_RECORD_MIC 0x00
391#define AC97_RECORD_CD 0x01
392#define AC97_RECORD_VIDEO 0x02
393#define AC97_RECORD_AUX 0x03
394#define AC97_RECORD_MONO_MUX 0x02
395#define AC97_RECORD_DIGITAL 0x03
396#define AC97_RECORD_LINE 0x04
397#define AC97_RECORD_STEREO 0x05
398#define AC97_RECORD_MONO 0x06
399#define AC97_RECORD_PHONE 0x07
400
401/*#define AC97_RECORD_GAIN 0x1C*/
402#define AC97_RECORD_VOL_M 0x0F
403
404/*#define AC97_GENERAL_PURPOSE 0x20*/
405#define AC97_POWER_DOWN_CTRL 0x26
406#define AC97_ADC_READY 0x0001
407#define AC97_DAC_READY 0x0002
408#define AC97_ANALOG_READY 0x0004
409#define AC97_VREF_ON 0x0008
410#define AC97_PR0 0x0100
411#define AC97_PR1 0x0200
412#define AC97_PR2 0x0400
413#define AC97_PR3 0x0800
414#define AC97_PR4 0x1000
415
416#define AC97_RESERVED1 0x28
417
418#define AC97_VENDOR_TEST 0x5A
419
420#define AC97_CLOCK_DELAY 0x5C
421#define AC97_LINEOUT_MUX_SEL 0x0001
422#define AC97_MONO_MUX_SEL 0x0002
423#define AC97_CLOCK_DELAY_SEL 0x1F
424#define AC97_DAC_CDS_SHIFT 6
425#define AC97_ADC_CDS_SHIFT 11
426
427#define AC97_MULTI_CHANNEL_SEL 0x74
428
429/*#define AC97_VENDOR_ID1 0x7C
430#define AC97_VENDOR_ID2 0x7E*/
431
364/* 432/*
365 * ASSP control regs 433 * ASSP control regs
366 */ 434 */
@@ -789,7 +857,7 @@ struct snd_m3 {
789 857
790 unsigned int in_suspend; 858 unsigned int in_suspend;
791 859
792#ifdef CONFIG_PM_SLEEP 860#ifdef CONFIG_PM
793 u16 *suspend_mem; 861 u16 *suspend_mem;
794#endif 862#endif
795 863
@@ -822,7 +890,7 @@ static DEFINE_PCI_DEVICE_TABLE(snd_m3_ids) = {
822 890
823MODULE_DEVICE_TABLE(pci, snd_m3_ids); 891MODULE_DEVICE_TABLE(pci, snd_m3_ids);
824 892
825static struct snd_pci_quirk m3_amp_quirk_list[] = { 893static struct snd_pci_quirk m3_amp_quirk_list[] __devinitdata = {
826 SND_PCI_QUIRK(0x0E11, 0x0094, "Compaq Evo N600c", 0x0c), 894 SND_PCI_QUIRK(0x0E11, 0x0094, "Compaq Evo N600c", 0x0c),
827 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d), 895 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d),
828 SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d), 896 SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d),
@@ -831,7 +899,7 @@ static struct snd_pci_quirk m3_amp_quirk_list[] = {
831 { } /* END */ 899 { } /* END */
832}; 900};
833 901
834static struct snd_pci_quirk m3_irda_quirk_list[] = { 902static struct snd_pci_quirk m3_irda_quirk_list[] __devinitdata = {
835 SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1), 903 SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1),
836 SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1), 904 SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1),
837 SND_PCI_QUIRK(0x1028, 0x00e6, "Dell Inspiron 8100", 1), 905 SND_PCI_QUIRK(0x1028, 0x00e6, "Dell Inspiron 8100", 1),
@@ -839,7 +907,7 @@ static struct snd_pci_quirk m3_irda_quirk_list[] = {
839}; 907};
840 908
841/* hardware volume quirks */ 909/* hardware volume quirks */
842static struct snd_pci_quirk m3_hv_quirk_list[] = { 910static struct snd_pci_quirk m3_hv_quirk_list[] __devinitdata = {
843 /* Allegro chips */ 911 /* Allegro chips */
844 SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), 912 SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
845 SND_PCI_QUIRK(0x0E11, 0x0094, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), 913 SND_PCI_QUIRK(0x0E11, 0x0094, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD),
@@ -917,7 +985,7 @@ static struct snd_pci_quirk m3_hv_quirk_list[] = {
917}; 985};
918 986
919/* HP Omnibook quirks */ 987/* HP Omnibook quirks */
920static struct snd_pci_quirk m3_omnibook_quirk_list[] = { 988static struct snd_pci_quirk m3_omnibook_quirk_list[] __devinitdata = {
921 SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */ 989 SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */
922 SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */ 990 SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */
923 { } /* END */ 991 { } /* END */
@@ -1856,7 +1924,7 @@ static struct snd_pcm_ops snd_m3_capture_ops = {
1856 .pointer = snd_m3_pcm_pointer, 1924 .pointer = snd_m3_pcm_pointer,
1857}; 1925};
1858 1926
1859static int 1927static int __devinit
1860snd_m3_pcm(struct snd_m3 * chip, int device) 1928snd_m3_pcm(struct snd_m3 * chip, int device)
1861{ 1929{
1862 struct snd_pcm *pcm; 1930 struct snd_pcm *pcm;
@@ -2031,7 +2099,7 @@ static void snd_m3_ac97_reset(struct snd_m3 *chip)
2031#endif 2099#endif
2032} 2100}
2033 2101
2034static int snd_m3_mixer(struct snd_m3 *chip) 2102static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2035{ 2103{
2036 struct snd_ac97_bus *pbus; 2104 struct snd_ac97_bus *pbus;
2037 struct snd_ac97_template ac97; 2105 struct snd_ac97_template ac97;
@@ -2173,7 +2241,7 @@ static void snd_m3_assp_init(struct snd_m3 *chip)
2173} 2241}
2174 2242
2175 2243
2176static int snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int index) 2244static int __devinit snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int index)
2177{ 2245{
2178 int data_bytes = 2 * ( MINISRC_TMP_BUFFER_SIZE / 2 + 2246 int data_bytes = 2 * ( MINISRC_TMP_BUFFER_SIZE / 2 +
2179 MINISRC_IN_BUFFER_SIZE / 2 + 2247 MINISRC_IN_BUFFER_SIZE / 2 +
@@ -2368,7 +2436,7 @@ static int snd_m3_free(struct snd_m3 *chip)
2368 outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ 2436 outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */
2369 } 2437 }
2370 2438
2371#ifdef CONFIG_PM_SLEEP 2439#ifdef CONFIG_PM
2372 vfree(chip->suspend_mem); 2440 vfree(chip->suspend_mem);
2373#endif 2441#endif
2374 2442
@@ -2390,11 +2458,10 @@ static int snd_m3_free(struct snd_m3 *chip)
2390/* 2458/*
2391 * APM support 2459 * APM support
2392 */ 2460 */
2393#ifdef CONFIG_PM_SLEEP 2461#ifdef CONFIG_PM
2394static int m3_suspend(struct device *dev) 2462static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2395{ 2463{
2396 struct pci_dev *pci = to_pci_dev(dev); 2464 struct snd_card *card = pci_get_drvdata(pci);
2397 struct snd_card *card = dev_get_drvdata(dev);
2398 struct snd_m3 *chip = card->private_data; 2465 struct snd_m3 *chip = card->private_data;
2399 int i, dsp_index; 2466 int i, dsp_index;
2400 2467
@@ -2422,14 +2489,13 @@ static int m3_suspend(struct device *dev)
2422 2489
2423 pci_disable_device(pci); 2490 pci_disable_device(pci);
2424 pci_save_state(pci); 2491 pci_save_state(pci);
2425 pci_set_power_state(pci, PCI_D3hot); 2492 pci_set_power_state(pci, pci_choose_state(pci, state));
2426 return 0; 2493 return 0;
2427} 2494}
2428 2495
2429static int m3_resume(struct device *dev) 2496static int m3_resume(struct pci_dev *pci)
2430{ 2497{
2431 struct pci_dev *pci = to_pci_dev(dev); 2498 struct snd_card *card = pci_get_drvdata(pci);
2432 struct snd_card *card = dev_get_drvdata(dev);
2433 struct snd_m3 *chip = card->private_data; 2499 struct snd_m3 *chip = card->private_data;
2434 int i, dsp_index; 2500 int i, dsp_index;
2435 2501
@@ -2480,15 +2546,10 @@ static int m3_resume(struct device *dev)
2480 chip->in_suspend = 0; 2546 chip->in_suspend = 0;
2481 return 0; 2547 return 0;
2482} 2548}
2483 2549#endif /* CONFIG_PM */
2484static SIMPLE_DEV_PM_OPS(m3_pm, m3_suspend, m3_resume);
2485#define M3_PM_OPS &m3_pm
2486#else
2487#define M3_PM_OPS NULL
2488#endif /* CONFIG_PM_SLEEP */
2489 2550
2490#ifdef CONFIG_SND_MAESTRO3_INPUT 2551#ifdef CONFIG_SND_MAESTRO3_INPUT
2491static int snd_m3_input_register(struct snd_m3 *chip) 2552static int __devinit snd_m3_input_register(struct snd_m3 *chip)
2492{ 2553{
2493 struct input_dev *input_dev; 2554 struct input_dev *input_dev;
2494 int err; 2555 int err;
@@ -2532,7 +2593,7 @@ static int snd_m3_dev_free(struct snd_device *device)
2532 return snd_m3_free(chip); 2593 return snd_m3_free(chip);
2533} 2594}
2534 2595
2535static int 2596static int __devinit
2536snd_m3_create(struct snd_card *card, struct pci_dev *pci, 2597snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2537 int enable_amp, 2598 int enable_amp,
2538 int amp_gpio, 2599 int amp_gpio,
@@ -2656,7 +2717,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2656 } 2717 }
2657 chip->irq = pci->irq; 2718 chip->irq = pci->irq;
2658 2719
2659#ifdef CONFIG_PM_SLEEP 2720#ifdef CONFIG_PM
2660 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); 2721 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
2661 if (chip->suspend_mem == NULL) 2722 if (chip->suspend_mem == NULL)
2662 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2723 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
@@ -2700,7 +2761,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2700 2761
2701/* 2762/*
2702 */ 2763 */
2703static int 2764static int __devinit
2704snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 2765snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2705{ 2766{
2706 static int dev; 2767 static int dev;
@@ -2759,8 +2820,8 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2759 /* TODO enable MIDI IRQ and I/O */ 2820 /* TODO enable MIDI IRQ and I/O */
2760 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, 2821 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401,
2761 chip->iobase + MPU401_DATA_PORT, 2822 chip->iobase + MPU401_DATA_PORT,
2762 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, 2823 MPU401_INFO_INTEGRATED,
2763 -1, &chip->rmidi); 2824 chip->irq, 0, &chip->rmidi);
2764 if (err < 0) 2825 if (err < 0)
2765 printk(KERN_WARNING "maestro3: no MIDI support.\n"); 2826 printk(KERN_WARNING "maestro3: no MIDI support.\n");
2766#endif 2827#endif
@@ -2770,20 +2831,32 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2770 return 0; 2831 return 0;
2771} 2832}
2772 2833
2773static void snd_m3_remove(struct pci_dev *pci) 2834static void __devexit snd_m3_remove(struct pci_dev *pci)
2774{ 2835{
2775 snd_card_free(pci_get_drvdata(pci)); 2836 snd_card_free(pci_get_drvdata(pci));
2776 pci_set_drvdata(pci, NULL); 2837 pci_set_drvdata(pci, NULL);
2777} 2838}
2778 2839
2779static struct pci_driver m3_driver = { 2840static struct pci_driver driver = {
2780 .name = KBUILD_MODNAME, 2841 .name = KBUILD_MODNAME,
2781 .id_table = snd_m3_ids, 2842 .id_table = snd_m3_ids,
2782 .probe = snd_m3_probe, 2843 .probe = snd_m3_probe,
2783 .remove = snd_m3_remove, 2844 .remove = __devexit_p(snd_m3_remove),
2784 .driver = { 2845#ifdef CONFIG_PM
2785 .pm = M3_PM_OPS, 2846 .suspend = m3_suspend,
2786 }, 2847 .resume = m3_resume,
2848#endif
2787}; 2849};
2788 2850
2789module_pci_driver(m3_driver); 2851static int __init alsa_card_m3_init(void)
2852{
2853 return pci_register_driver(&driver);
2854}
2855
2856static void __exit alsa_card_m3_exit(void)
2857{
2858 pci_unregister_driver(&driver);
2859}
2860
2861module_init(alsa_card_m3_init)
2862module_exit(alsa_card_m3_exit)