18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ALSA driver for ICEnsemble VT1724 (Envy24HT) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Lowlevel functions for Advanced Micro Peripherals Ltd AUDIO2000 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/delay.h> 118c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 128c2ecf20Sopenharmony_ci#include <linux/init.h> 138c2ecf20Sopenharmony_ci#include <sound/core.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "ice1712.h" 168c2ecf20Sopenharmony_ci#include "envy24ht.h" 178c2ecf20Sopenharmony_ci#include "amp.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci unsigned short cval; 228c2ecf20Sopenharmony_ci cval = (reg << 9) | val; 238c2ecf20Sopenharmony_ci snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); 248c2ecf20Sopenharmony_ci} 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic int snd_vt1724_amp_init(struct snd_ice1712 *ice) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci static const unsigned short wm_inits[] = { 298c2ecf20Sopenharmony_ci WM_ATTEN_L, 0x0000, /* 0 db */ 308c2ecf20Sopenharmony_ci WM_ATTEN_R, 0x0000, /* 0 db */ 318c2ecf20Sopenharmony_ci WM_DAC_CTRL, 0x0008, /* 24bit I2S */ 328c2ecf20Sopenharmony_ci WM_INT_CTRL, 0x0001, /* 24bit I2S */ 338c2ecf20Sopenharmony_ci }; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci unsigned int i; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci /* only use basic functionality for now */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* VT1616 6ch codec connected to PSDOUT0 using packed mode */ 408c2ecf20Sopenharmony_ci ice->num_total_dacs = 6; 418c2ecf20Sopenharmony_ci ice->num_total_adcs = 2; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* Chaintech AV-710 has another WM8728 codec connected to PSDOUT4 448c2ecf20Sopenharmony_ci (shared with the SPDIF output). Mixer control for this codec 458c2ecf20Sopenharmony_ci is not yet supported. */ 468c2ecf20Sopenharmony_ci if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) { 478c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) 488c2ecf20Sopenharmony_ci wm_put(ice, wm_inits[i], wm_inits[i+1]); 498c2ecf20Sopenharmony_ci } 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci return 0; 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic int snd_vt1724_amp_add_controls(struct snd_ice1712 *ice) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci if (ice->ac97) 578c2ecf20Sopenharmony_ci /* we use pins 39 and 41 of the VT1616 for left and right 588c2ecf20Sopenharmony_ci read outputs */ 598c2ecf20Sopenharmony_ci snd_ac97_write_cache(ice->ac97, 0x5a, 608c2ecf20Sopenharmony_ci snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); 618c2ecf20Sopenharmony_ci return 0; 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* entry point */ 668c2ecf20Sopenharmony_cistruct snd_ice1712_card_info snd_vt1724_amp_cards[] = { 678c2ecf20Sopenharmony_ci { 688c2ecf20Sopenharmony_ci .subvendor = VT1724_SUBDEVICE_AV710, 698c2ecf20Sopenharmony_ci .name = "Chaintech AV-710", 708c2ecf20Sopenharmony_ci .model = "av710", 718c2ecf20Sopenharmony_ci .chip_init = snd_vt1724_amp_init, 728c2ecf20Sopenharmony_ci .build_controls = snd_vt1724_amp_add_controls, 738c2ecf20Sopenharmony_ci }, 748c2ecf20Sopenharmony_ci { 758c2ecf20Sopenharmony_ci .subvendor = VT1724_SUBDEVICE_AUDIO2000, 768c2ecf20Sopenharmony_ci .name = "AMP Ltd AUDIO2000", 778c2ecf20Sopenharmony_ci .model = "amp2000", 788c2ecf20Sopenharmony_ci .chip_init = snd_vt1724_amp_init, 798c2ecf20Sopenharmony_ci .build_controls = snd_vt1724_amp_add_controls, 808c2ecf20Sopenharmony_ci }, 818c2ecf20Sopenharmony_ci { } /* terminator */ 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 84