11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * ALSA driver for ICEnsemble VT1724 (Envy24HT) 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Lowlevel functions for Advanced Micro Peripherals Ltd AUDIO2000 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz> 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 91da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 101da177e4SLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 111da177e4SLinus Torvalds * (at your option) any later version. 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, 141da177e4SLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 151da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 161da177e4SLinus Torvalds * GNU General Public License for more details. 171da177e4SLinus Torvalds * 181da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 191da177e4SLinus Torvalds * along with this program; if not, write to the Free Software 201da177e4SLinus Torvalds * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 211da177e4SLinus Torvalds * 221da177e4SLinus Torvalds */ 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds #include <sound/driver.h> 251da177e4SLinus Torvalds #include <asm/io.h> 261da177e4SLinus Torvalds #include <linux/delay.h> 271da177e4SLinus Torvalds #include <linux/interrupt.h> 281da177e4SLinus Torvalds #include <linux/init.h> 291da177e4SLinus Torvalds #include <linux/slab.h> 301da177e4SLinus Torvalds #include <sound/core.h> 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds #include "ice1712.h" 33*8cfbbac6STakashi Iwai #include "envy24ht.h" 341da177e4SLinus Torvalds #include "amp.h" 351da177e4SLinus Torvalds 36*8cfbbac6STakashi Iwai static void wm_put(ice1712_t *ice, int reg, unsigned short val) 37*8cfbbac6STakashi Iwai { 38*8cfbbac6STakashi Iwai unsigned short cval; 39*8cfbbac6STakashi Iwai cval = (reg << 9) | val; 40*8cfbbac6STakashi Iwai snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); 41*8cfbbac6STakashi Iwai } 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds static int __devinit snd_vt1724_amp_init(ice1712_t *ice) 441da177e4SLinus Torvalds { 45*8cfbbac6STakashi Iwai static unsigned short wm_inits[] = { 46*8cfbbac6STakashi Iwai WM_ATTEN_L, 0x0000, /* 0 db */ 47*8cfbbac6STakashi Iwai WM_ATTEN_R, 0x0000, /* 0 db */ 48*8cfbbac6STakashi Iwai WM_DAC_CTRL, 0x0008, /* 24bit I2S */ 49*8cfbbac6STakashi Iwai WM_INT_CTRL, 0x0001, /* 24bit I2S */ 50*8cfbbac6STakashi Iwai }; 51*8cfbbac6STakashi Iwai 52*8cfbbac6STakashi Iwai unsigned int i; 53*8cfbbac6STakashi Iwai 541da177e4SLinus Torvalds /* only use basic functionality for now */ 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds ice->num_total_dacs = 2; /* only PSDOUT0 is connected */ 571da177e4SLinus Torvalds ice->num_total_adcs = 2; 581da177e4SLinus Torvalds 59*8cfbbac6STakashi Iwai /* Chaintech AV-710 has another codecs, which need initialization */ 60*8cfbbac6STakashi Iwai /* initialize WM8728 codec */ 61*8cfbbac6STakashi Iwai if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) { 62*8cfbbac6STakashi Iwai for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) 63*8cfbbac6STakashi Iwai wm_put(ice, wm_inits[i], wm_inits[i+1]); 64*8cfbbac6STakashi Iwai } 65*8cfbbac6STakashi Iwai 661da177e4SLinus Torvalds return 0; 671da177e4SLinus Torvalds } 681da177e4SLinus Torvalds 691da177e4SLinus Torvalds static int __devinit snd_vt1724_amp_add_controls(ice1712_t *ice) 701da177e4SLinus Torvalds { 711da177e4SLinus Torvalds /* we use pins 39 and 41 of the VT1616 for left and right read outputs */ 721da177e4SLinus Torvalds snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); 731da177e4SLinus Torvalds return 0; 741da177e4SLinus Torvalds } 751da177e4SLinus Torvalds 761da177e4SLinus Torvalds 771da177e4SLinus Torvalds /* entry point */ 781da177e4SLinus Torvalds struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { 791da177e4SLinus Torvalds { 80*8cfbbac6STakashi Iwai .subvendor = VT1724_SUBDEVICE_AV710, 81*8cfbbac6STakashi Iwai .name = "Chaintech AV-710", 82*8cfbbac6STakashi Iwai .model = "av710", 83*8cfbbac6STakashi Iwai .chip_init = snd_vt1724_amp_init, 84*8cfbbac6STakashi Iwai .build_controls = snd_vt1724_amp_add_controls, 85*8cfbbac6STakashi Iwai }, 86*8cfbbac6STakashi Iwai { 871da177e4SLinus Torvalds .subvendor = VT1724_SUBDEVICE_AUDIO2000, 881da177e4SLinus Torvalds .name = "AMP Ltd AUDIO2000", 891da177e4SLinus Torvalds .model = "amp2000", 901da177e4SLinus Torvalds .chip_init = snd_vt1724_amp_init, 911da177e4SLinus Torvalds .build_controls = snd_vt1724_amp_add_controls, 921da177e4SLinus Torvalds }, 931da177e4SLinus Torvalds { } /* terminator */ 941da177e4SLinus Torvalds }; 951da177e4SLinus Torvalds 96