Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * ALSA driver for ICEnsemble VT1724 (Envy24HT) |
| 4 | * |
| 5 | * Lowlevel functions for Advanced Micro Peripherals Ltd AUDIO2000 |
| 6 | * |
Jaroslav Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 7 | * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/delay.h> |
| 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <sound/core.h> |
| 14 | |
| 15 | #include "ice1712.h" |
Takashi Iwai | 8cfbbac | 2005-05-27 12:10:40 +0200 | [diff] [blame] | 16 | #include "envy24ht.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include "amp.h" |
| 18 | |
Takashi Iwai | ab0c7d7 | 2005-11-17 15:00:18 +0100 | [diff] [blame] | 19 | static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) |
Takashi Iwai | 8cfbbac | 2005-05-27 12:10:40 +0200 | [diff] [blame] | 20 | { |
| 21 | unsigned short cval; |
| 22 | cval = (reg << 9) | val; |
| 23 | snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); |
| 24 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 26 | static int snd_vt1724_amp_init(struct snd_ice1712 *ice) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Takashi Iwai | 32b47da | 2007-01-29 15:26:36 +0100 | [diff] [blame] | 28 | static const unsigned short wm_inits[] = { |
Takashi Iwai | 8cfbbac | 2005-05-27 12:10:40 +0200 | [diff] [blame] | 29 | WM_ATTEN_L, 0x0000, /* 0 db */ |
| 30 | WM_ATTEN_R, 0x0000, /* 0 db */ |
| 31 | WM_DAC_CTRL, 0x0008, /* 24bit I2S */ |
| 32 | WM_INT_CTRL, 0x0001, /* 24bit I2S */ |
| 33 | }; |
| 34 | |
| 35 | unsigned int i; |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* only use basic functionality for now */ |
| 38 | |
Robert Hancock | 43189a3 | 2009-10-09 22:08:58 -0600 | [diff] [blame] | 39 | /* VT1616 6ch codec connected to PSDOUT0 using packed mode */ |
| 40 | ice->num_total_dacs = 6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | ice->num_total_adcs = 2; |
| 42 | |
Robert Hancock | 43189a3 | 2009-10-09 22:08:58 -0600 | [diff] [blame] | 43 | /* Chaintech AV-710 has another WM8728 codec connected to PSDOUT4 |
| 44 | (shared with the SPDIF output). Mixer control for this codec |
| 45 | is not yet supported. */ |
Takashi Iwai | 8cfbbac | 2005-05-27 12:10:40 +0200 | [diff] [blame] | 46 | if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) { |
| 47 | for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) |
| 48 | wm_put(ice, wm_inits[i], wm_inits[i+1]); |
| 49 | } |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 54 | static int snd_vt1724_amp_add_controls(struct snd_ice1712 *ice) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
Pavel Hofman | e784816 | 2012-01-05 23:05:18 +0100 | [diff] [blame] | 56 | if (ice->ac97) |
| 57 | /* we use pins 39 and 41 of the VT1616 for left and right |
| 58 | read outputs */ |
| 59 | snd_ac97_write_cache(ice->ac97, 0x5a, |
| 60 | snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | /* entry point */ |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 66 | struct snd_ice1712_card_info snd_vt1724_amp_cards[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
Takashi Iwai | 8cfbbac | 2005-05-27 12:10:40 +0200 | [diff] [blame] | 68 | .subvendor = VT1724_SUBDEVICE_AV710, |
| 69 | .name = "Chaintech AV-710", |
| 70 | .model = "av710", |
| 71 | .chip_init = snd_vt1724_amp_init, |
| 72 | .build_controls = snd_vt1724_amp_add_controls, |
| 73 | }, |
| 74 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | .subvendor = VT1724_SUBDEVICE_AUDIO2000, |
| 76 | .name = "AMP Ltd AUDIO2000", |
| 77 | .model = "amp2000", |
| 78 | .chip_init = snd_vt1724_amp_init, |
| 79 | .build_controls = snd_vt1724_amp_add_controls, |
| 80 | }, |
| 81 | { } /* terminator */ |
| 82 | }; |
| 83 | |