📄 miro.c
字号:
return right_old; } if ((getreg_right >= ACI_GET_EQ1) && (getreg_right <= ACI_GET_EQ7)) { /* equalizer elements */ if (left_old > 0x80) left_old = 0x80 - left_old; if (right_old > 0x80) right_old = 0x80 - right_old; if (left >= 0) { if ((error = aci_setvalue(miro, setreg_left, left)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", left, error); return error; } } else { if ((error = aci_setvalue(miro, setreg_left, 0x80 - left)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", 0x80 - left, error); return error; } } if (right >= 0) { if ((error = aci_setvalue(miro, setreg_right, right)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", right, error); return error; } } else { if ((error = aci_setvalue(miro, setreg_right, 0x80 - right)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", 0x80 - right, error); return error; } } } else { /* non-equalizer elements */ left_old = 0x20 - left_old; right_old = 0x20 - right_old; if ((error = aci_setvalue(miro, setreg_left, 0x20 - left)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", 0x20 - left, error); return error; } if ((error = aci_setvalue(miro, setreg_right, 0x20 - right)) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", 0x20 - right, error); return error; } } change = (left != left_old) || (right != right_old); return change;}static struct snd_kcontrol_new snd_miro_controls[] __devinitdata = {MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER),MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC),MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE),MIRO_DOUBLE("CD Playback Volume", 0, ACI_GET_CD, ACI_SET_CD),MIRO_DOUBLE("Synth Playback Volume", 0, ACI_GET_SYNTH, ACI_SET_SYNTH),MIRO_DOUBLE("PCM Playback Volume", 1, ACI_GET_PCM, ACI_SET_PCM),MIRO_DOUBLE("Aux Playback Volume", 2, ACI_GET_LINE2, ACI_SET_LINE2),};/* Equalizer with seven bands (only PCM20) from -12dB up to +12dB on each band */static struct snd_kcontrol_new snd_miro_eq_controls[] __devinitdata = {MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1),MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2),MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3),MIRO_DOUBLE("Tone Control - 1 kHz", 0, ACI_GET_EQ4, ACI_SET_EQ4),MIRO_DOUBLE("Tone Control - 2.5 kHz", 0, ACI_GET_EQ5, ACI_SET_EQ5),MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, ACI_GET_EQ6, ACI_SET_EQ6),MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7),};static struct snd_kcontrol_new snd_miro_radio_control[] __devinitdata = {MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1),};static struct snd_kcontrol_new snd_miro_line_control[] __devinitdata = {MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1),};static struct snd_kcontrol_new snd_miro_preamp_control[] __devinitdata = {{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost", .index = 1, .info = snd_miro_info_preamp, .get = snd_miro_get_preamp, .put = snd_miro_put_preamp,}};static struct snd_kcontrol_new snd_miro_amp_control[] __devinitdata = {{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line Boost", .index = 0, .info = snd_miro_info_amp, .get = snd_miro_get_amp, .put = snd_miro_put_amp,}};static struct snd_kcontrol_new snd_miro_capture_control[] __devinitdata = {{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Capture Switch", .index = 0, .info = snd_miro_info_capture, .get = snd_miro_get_capture, .put = snd_miro_put_capture,}};static unsigned char aci_init_values[][2] __devinitdata = { { ACI_SET_MUTE, 0x00 }, { ACI_SET_POWERAMP, 0x00 }, { ACI_SET_PREAMP, 0x00 }, { ACI_SET_SOLOMODE, 0x00 }, { ACI_SET_MIC + 0, 0x20 }, { ACI_SET_MIC + 8, 0x20 }, { ACI_SET_LINE + 0, 0x20 }, { ACI_SET_LINE + 8, 0x20 }, { ACI_SET_CD + 0, 0x20 }, { ACI_SET_CD + 8, 0x20 }, { ACI_SET_PCM + 0, 0x20 }, { ACI_SET_PCM + 8, 0x20 }, { ACI_SET_LINE1 + 0, 0x20 }, { ACI_SET_LINE1 + 8, 0x20 }, { ACI_SET_LINE2 + 0, 0x20 }, { ACI_SET_LINE2 + 8, 0x20 }, { ACI_SET_SYNTH + 0, 0x20 }, { ACI_SET_SYNTH + 8, 0x20 }, { ACI_SET_MASTER + 0, 0x20 }, { ACI_SET_MASTER + 1, 0x20 },};static int __devinit snd_set_aci_init_values(struct snd_miro *miro){ int idx, error; /* enable WSS on PCM1 */ if ((miro->aci_product == 'A') && wss) { if ((error = aci_setvalue(miro, ACI_SET_WSS, wss)) < 0) { snd_printk(KERN_ERR "enabling WSS mode failed\n"); return error; } } /* enable IDE port */ if (ide) { if ((error = aci_setvalue(miro, ACI_SET_IDE, ide)) < 0) { snd_printk(KERN_ERR "enabling IDE port failed\n"); return error; } } /* set common aci values */ for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) if ((error = aci_setvalue(miro, aci_init_values[idx][0], aci_init_values[idx][1])) < 0) { snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", aci_init_values[idx][0], error); return error; } miro->aci_amp = 0; miro->aci_preamp = 0; miro->aci_solomode = 1; return 0;}static int snd_miro_mixer(struct snd_miro *miro){ struct snd_card *card; unsigned int idx; int err; snd_assert(miro != NULL && miro->card != NULL, return -EINVAL); card = miro->card; switch (miro->hardware) { case OPTi9XX_HW_82C924: strcpy(card->mixername, "ACI & OPTi924"); break; case OPTi9XX_HW_82C929: strcpy(card->mixername, "ACI & OPTi929"); break; default: snd_BUG(); break; } for (idx = 0; idx < ARRAY_SIZE(snd_miro_controls); idx++) { if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_controls[idx], miro))) < 0) return err; } if ((miro->aci_product == 'A') || (miro->aci_product == 'B')) { /* PCM1/PCM12 with power-amp and Line 2 */ if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) return err; if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_amp_control[0], miro))) < 0) return err; } if ((miro->aci_product == 'B') || (miro->aci_product == 'C')) { /* PCM12/PCM20 with mic-preamp */ if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) return err; if (miro->aci_version >= 176) if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) return err; } if (miro->aci_product == 'C') { /* PCM20 with radio and 7 band equalizer */ if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) return err; for (idx = 0; idx < ARRAY_SIZE(snd_miro_eq_controls); idx++) { if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_eq_controls[idx], miro))) < 0) return err; } } return 0;}static long snd_legacy_find_free_ioport(long *port_table, long size){ while (*port_table != -1) { struct resource *res; if ((res = request_region(*port_table, size, "ALSA test")) != NULL) { release_and_free_resource(res); return *port_table; } port_table++; } return -1;}static int __devinit snd_miro_init(struct snd_miro *chip, unsigned short hardware){ static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; chip->hardware = hardware; strcpy(chip->name, snd_opti9xx_names[hardware]); chip->mc_base_size = opti9xx_mc_size[hardware]; spin_lock_init(&chip->lock); chip->wss_base = -1; chip->irq = -1; chip->dma1 = -1; chip->dma2 = -1; chip->fm_port = -1; chip->mpu_port = -1; chip->mpu_irq = -1; switch (hardware) { case OPTi9XX_HW_82C929: chip->mc_base = 0xf8c; chip->password = 0xe3; chip->pwd_reg = 3; break; case OPTi9XX_HW_82C924: chip->mc_base = 0xf8c; chip->password = 0xe5; chip->pwd_reg = 3; break; default: snd_printk(KERN_ERR "sorry, no support for %d\n", hardware); return -ENODEV; } return 0;}static unsigned char snd_miro_read(struct snd_miro *chip, unsigned char reg){ unsigned long flags; unsigned char retval = 0xff; spin_lock_irqsave(&chip->lock, flags); outb(chip->password, chip->mc_base + chip->pwd_reg); switch (chip->hardware) { case OPTi9XX_HW_82C924: if (reg > 7) { outb(reg, chip->mc_base + 8); outb(chip->password, chip->mc_base + chip->pwd_reg); retval = inb(chip->mc_base + 9); break; } case OPTi9XX_HW_82C929: retval = inb(chip->mc_base + reg); break; default: snd_printk(KERN_ERR "sorry, no support for %d\n", chip->hardware); } spin_unlock_irqrestore(&chip->lock, flags); return retval;}static void snd_miro_write(struct snd_miro *chip, unsigned char reg, unsigned char value){ unsigned long flags; spin_lock_irqsave(&chip->lock, flags); outb(chip->password, chip->mc_base + chip->pwd_reg); switch (chip->hardware) { case OPTi9XX_HW_82C924: if (reg > 7) { outb(reg, chip->mc_base + 8); outb(chip->password, chip->mc_base + chip->pwd_reg); outb(value, chip->mc_base + 9); break; } case OPTi9XX_HW_82C929: outb(value, chip->mc_base + reg); break; default: snd_printk(KERN_ERR "sorry, no support for %d\n", chip->hardware); } spin_unlock_irqrestore(&chip->lock, flags);}#define snd_miro_write_mask(chip, reg, value, mask) \ snd_miro_write(chip, reg, \ (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask)))/* * Proc Interface */static void snd_miro_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer){ struct snd_miro *miro = (struct snd_miro *) entry->private_data; char* model = "unknown"; /* miroSOUND PCM1 pro, early PCM12 */ if ((miro->hardware == OPTi9XX_HW_82C929) && (miro->aci_vendor == 'm') && (miro->aci_product == 'A')) { switch(miro->aci_version) { case 3: model = "miroSOUND PCM1 pro"; break; default: model = "miroSOUND PCM1 pro / (early) PCM12"; break; } } /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ if ((miro->hardware == OPTi9XX_HW_82C924) && (miro->aci_vendor == 'm') && (miro->aci_product == 'B')) { switch(miro->aci_version) { case 4: model = "miroSOUND PCM12"; break; case 176: model = "miroSOUND PCM12 (Rev. E)"; break; default: model = "miroSOUND PCM12 / PCM12 pnp"; break; } } /* miroSOUND PCM20 radio */ if ((miro->hardware == OPTi9XX_HW_82C924) && (miro->aci_vendor == 'm') && (miro->aci_product == 'C')) { switch(miro->aci_version) { case 7: model = "miroSOUND PCM20 radio (Rev. E)"; break; default: model = "miroSOUND PCM20 radio"; break; } } snd_iprintf(buffer, "\nGeneral information:\n"); snd_iprintf(buffer, " model : %s\n", model); snd_iprintf(buffer, " opti : %s\n", miro->name); snd_iprintf(buffer, " codec : %s\n", miro->pcm->name); snd_iprintf(buffer, " port : 0x%lx\n", miro->wss_base); snd_iprintf(buffer, " irq : %d\n", miro->irq); snd_iprintf(buffer, " dma : %d,%d\n\n", miro->dma1, miro->dma2); snd_iprintf(buffer, "MPU-401:\n"); snd_iprintf(buffer, " port : 0x%lx\n", miro->mpu_port); snd_iprintf(buffer, " irq : %d\n\n", miro->mpu_irq); snd_iprintf(buffer, "ACI information:\n"); snd_iprintf(buffer, " vendor : "); switch(miro->aci_vendor) { case 'm': snd_iprintf(buffer, "Miro\n"); break; default: snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_vendor); break; } snd_iprintf(buffer, " product : "); switch(miro->aci_product) { case 'A': snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); break; case 'B': snd_iprintf(buffer, "miroSOUND PCM12\n"); break; case 'C': snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); break; default: snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_product); break; } snd_iprintf(buffer, " firmware: %d (0x%x)\n", miro->aci_version, miro->aci_version); snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", miro->aci_port, miro->aci_port+2); snd_iprintf(buffer, " wss : 0x%x\n", wss); snd_iprintf(buffer, " ide : 0x%x\n", ide); snd_iprintf(buffer, " solomode: 0x%x\n", miro->aci_solomode); snd_iprintf(buffer, " amp : 0x%x\n", miro->aci_amp); snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp);}static void __devinit snd_miro_proc_init(struct snd_miro * miro){ struct snd_info_entry *entry; if (! snd_card_proc_new(miro->card, "miro", &entry)) snd_info_set_text_ops(entry, miro, snd_miro_proc_read);}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -