0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <linux/pci.h>
0022 #include <linux/module.h>
0023 #include <sound/core.h>
0024 #include <sound/control.h>
0025 #include <sound/initval.h>
0026 #include <sound/pcm.h>
0027 #include "oxygen.h"
0028
0029 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
0030 MODULE_DESCRIPTION("Studio Evolution SE6X driver");
0031 MODULE_LICENSE("GPL v2");
0032
0033 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
0034 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
0035 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
0036
0037 module_param_array(index, int, NULL, 0444);
0038 MODULE_PARM_DESC(index, "card index");
0039 module_param_array(id, charp, NULL, 0444);
0040 MODULE_PARM_DESC(id, "ID string");
0041 module_param_array(enable, bool, NULL, 0444);
0042 MODULE_PARM_DESC(enable, "enable card");
0043
0044 static const struct pci_device_id se6x_ids[] = {
0045 { OXYGEN_PCI_SUBID(0x13f6, 0x8788) },
0046 { }
0047 };
0048 MODULE_DEVICE_TABLE(pci, se6x_ids);
0049
0050 static void se6x_init(struct oxygen *chip)
0051 {
0052 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x005);
0053
0054 snd_component_add(chip->card, "PCM1792A");
0055 snd_component_add(chip->card, "PCM1804");
0056 }
0057
0058 static int se6x_control_filter(struct snd_kcontrol_new *template)
0059 {
0060
0061 if (!strncmp(template->name, "Master Playback ", 16))
0062 return 1;
0063 return 0;
0064 }
0065
0066 static void se6x_cleanup(struct oxygen *chip)
0067 {
0068 }
0069
0070 static void set_pcm1792a_params(struct oxygen *chip,
0071 struct snd_pcm_hw_params *params)
0072 {
0073
0074 }
0075
0076 static void set_pcm1804_params(struct oxygen *chip,
0077 struct snd_pcm_hw_params *params)
0078 {
0079 }
0080
0081 static unsigned int se6x_adjust_dac_routing(struct oxygen *chip,
0082 unsigned int play_routing)
0083 {
0084
0085 return ( play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) |
0086 ((play_routing << 2) & OXYGEN_PLAY_DAC1_SOURCE_MASK);
0087 }
0088
0089 static const struct oxygen_model model_se6x = {
0090 .shortname = "Studio Evolution SE6X",
0091 .longname = "C-Media Oxygen HD Audio",
0092 .chip = "CMI8787",
0093 .init = se6x_init,
0094 .control_filter = se6x_control_filter,
0095 .cleanup = se6x_cleanup,
0096 .set_dac_params = set_pcm1792a_params,
0097 .set_adc_params = set_pcm1804_params,
0098 .adjust_dac_routing = se6x_adjust_dac_routing,
0099 .device_config = PLAYBACK_0_TO_I2S |
0100 CAPTURE_0_FROM_I2S_1 |
0101 CAPTURE_2_FROM_I2S_2 |
0102 CAPTURE_3_FROM_I2S_3,
0103 .dac_channels_pcm = 2,
0104 .function_flags = OXYGEN_FUNCTION_SPI,
0105 .dac_mclks = OXYGEN_MCLKS(256, 128, 128),
0106 .adc_mclks = OXYGEN_MCLKS(256, 256, 128),
0107 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
0108 .adc_i2s_format = OXYGEN_I2S_FORMAT_I2S,
0109 };
0110
0111 static int se6x_get_model(struct oxygen *chip,
0112 const struct pci_device_id *pci_id)
0113 {
0114 chip->model = model_se6x;
0115 return 0;
0116 }
0117
0118 static int se6x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
0119 {
0120 static int dev;
0121 int err;
0122
0123 if (dev >= SNDRV_CARDS)
0124 return -ENODEV;
0125 if (!enable[dev]) {
0126 ++dev;
0127 return -ENOENT;
0128 }
0129 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
0130 se6x_ids, se6x_get_model);
0131 if (err >= 0)
0132 ++dev;
0133 return err;
0134 }
0135
0136 static struct pci_driver se6x_driver = {
0137 .name = KBUILD_MODNAME,
0138 .id_table = se6x_ids,
0139 .probe = se6x_probe,
0140 #ifdef CONFIG_PM_SLEEP
0141 .driver = {
0142 .pm = &oxygen_pci_pm,
0143 },
0144 #endif
0145 .shutdown = oxygen_pci_shutdown,
0146 };
0147
0148 module_pci_driver(se6x_driver);