Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *   ALSA driver for ICEnsemble VT1724 (Envy24HT)
0004  *
0005  *   Lowlevel functions for Advanced Micro Peripherals Ltd AUDIO2000
0006  *
0007  *  Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
0008  */      
0009 
0010 #include <linux/delay.h>
0011 #include <linux/interrupt.h>
0012 #include <linux/init.h>
0013 #include <sound/core.h>
0014 
0015 #include "ice1712.h"
0016 #include "envy24ht.h"
0017 #include "amp.h"
0018 
0019 static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
0020 {
0021     unsigned short cval;
0022     cval = (reg << 9) | val;
0023     snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff);
0024 }
0025 
0026 static int snd_vt1724_amp_init(struct snd_ice1712 *ice)
0027 {
0028     static const unsigned short wm_inits[] = {
0029         WM_ATTEN_L, 0x0000, /* 0 db */
0030         WM_ATTEN_R, 0x0000, /* 0 db */
0031         WM_DAC_CTRL,    0x0008, /* 24bit I2S */
0032         WM_INT_CTRL,    0x0001, /* 24bit I2S */ 
0033     };
0034 
0035     unsigned int i;
0036 
0037     /* only use basic functionality for now */
0038 
0039     /* VT1616 6ch codec connected to PSDOUT0 using packed mode */
0040     ice->num_total_dacs = 6;
0041     ice->num_total_adcs = 2;
0042 
0043     /* Chaintech AV-710 has another WM8728 codec connected to PSDOUT4
0044        (shared with the SPDIF output). Mixer control for this codec
0045        is not yet supported. */
0046     if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) {
0047         for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
0048             wm_put(ice, wm_inits[i], wm_inits[i+1]);
0049     }
0050 
0051     return 0;
0052 }
0053 
0054 static int snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
0055 {
0056     if (ice->ac97)
0057         /* we use pins 39 and 41 of the VT1616 for left and right
0058         read outputs */
0059         snd_ac97_write_cache(ice->ac97, 0x5a,
0060             snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
0061     return 0;
0062 }
0063 
0064 
0065 /* entry point */
0066 struct snd_ice1712_card_info snd_vt1724_amp_cards[] = {
0067     {
0068         .subvendor = VT1724_SUBDEVICE_AV710,
0069         .name = "Chaintech AV-710",
0070         .model = "av710",
0071         .chip_init = snd_vt1724_amp_init,
0072         .build_controls = snd_vt1724_amp_add_controls,
0073     },
0074     {
0075         .subvendor = VT1724_SUBDEVICE_AUDIO2000,
0076         .name = "AMP Ltd AUDIO2000",
0077         .model = "amp2000",
0078         .chip_init = snd_vt1724_amp_init,
0079         .build_controls = snd_vt1724_amp_add_controls,
0080     },
0081     { } /* terminator */
0082 };
0083