blob: 5555eb4b2400696e640422aba6a231f0a47e43a0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 *
4 * Lowlevel functions for Pontis MS300
5 *
6 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/delay.h>
25#include <linux/interrupt.h>
26#include <linux/init.h>
27#include <linux/slab.h>
Ingo Molnar62932df2006-01-16 16:34:20 +010028#include <linux/mutex.h>
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <sound/core.h>
31#include <sound/info.h>
Takashi Iwaif640c322006-08-30 16:57:37 +020032#include <sound/tlv.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34#include "ice1712.h"
35#include "envy24ht.h"
36#include "pontis.h"
37
38/* I2C addresses */
39#define WM_DEV 0x34
40#define CS_DEV 0x20
41
42/* WM8776 registers */
43#define WM_HP_ATTEN_L 0x00 /* headphone left attenuation */
44#define WM_HP_ATTEN_R 0x01 /* headphone left attenuation */
Vedran Mileticcc67b7f2008-09-07 12:00:02 +020045#define WM_HP_MASTER 0x02 /* headphone master (both channels) */
46 /* override LLR */
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define WM_DAC_ATTEN_L 0x03 /* digital left attenuation */
48#define WM_DAC_ATTEN_R 0x04
49#define WM_DAC_MASTER 0x05
50#define WM_PHASE_SWAP 0x06 /* DAC phase swap */
51#define WM_DAC_CTRL1 0x07
52#define WM_DAC_MUTE 0x08
53#define WM_DAC_CTRL2 0x09
54#define WM_DAC_INT 0x0a
55#define WM_ADC_INT 0x0b
56#define WM_MASTER_CTRL 0x0c
57#define WM_POWERDOWN 0x0d
58#define WM_ADC_ATTEN_L 0x0e
59#define WM_ADC_ATTEN_R 0x0f
60#define WM_ALC_CTRL1 0x10
61#define WM_ALC_CTRL2 0x11
62#define WM_ALC_CTRL3 0x12
63#define WM_NOISE_GATE 0x13
64#define WM_LIMITER 0x14
65#define WM_ADC_MUX 0x15
66#define WM_OUT_MUX 0x16
67#define WM_RESET 0x17
68
69/*
70 * GPIO
71 */
72#define PONTIS_CS_CS (1<<4) /* CS */
73#define PONTIS_CS_CLK (1<<5) /* CLK */
74#define PONTIS_CS_RDATA (1<<6) /* CS8416 -> VT1720 */
75#define PONTIS_CS_WDATA (1<<7) /* VT1720 -> CS8416 */
76
77
78/*
79 * get the current register value of WM codec
80 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +010081static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
83 reg <<= 1;
84 return ((unsigned short)ice->akm[0].images[reg] << 8) |
85 ice->akm[0].images[reg + 1];
86}
87
88/*
89 * set the register value of WM codec and remember it
90 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +010091static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
93 unsigned short cval;
94 cval = (reg << 9) | val;
95 snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff);
96}
97
Takashi Iwaiab0c7d72005-11-17 15:00:18 +010098static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099{
100 wm_put_nocache(ice, reg, val);
101 reg <<= 1;
102 ice->akm[0].images[reg] = val >> 8;
103 ice->akm[0].images[reg + 1] = val;
104}
105
106/*
107 * DAC volume attenuation mixer control (-64dB to 0dB)
108 */
109
110#define DAC_0dB 0xff
111#define DAC_RES 128
112#define DAC_MIN (DAC_0dB - DAC_RES)
113
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100114static int wm_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
116 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
117 uinfo->count = 2;
118 uinfo->value.integer.min = 0; /* mute */
119 uinfo->value.integer.max = DAC_RES; /* 0dB, 0.5dB step */
120 return 0;
121}
122
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100123static int wm_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100125 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 unsigned short val;
127 int i;
128
Ingo Molnar62932df2006-01-16 16:34:20 +0100129 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 for (i = 0; i < 2; i++) {
131 val = wm_get(ice, WM_DAC_ATTEN_L + i) & 0xff;
132 val = val > DAC_MIN ? (val - DAC_MIN) : 0;
133 ucontrol->value.integer.value[i] = val;
134 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100135 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 return 0;
137}
138
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100139static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100141 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 unsigned short oval, nval;
143 int i, idx, change = 0;
144
Ingo Molnar62932df2006-01-16 16:34:20 +0100145 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 for (i = 0; i < 2; i++) {
147 nval = ucontrol->value.integer.value[i];
148 nval = (nval ? (nval + DAC_MIN) : 0) & 0xff;
149 idx = WM_DAC_ATTEN_L + i;
150 oval = wm_get(ice, idx) & 0xff;
151 if (oval != nval) {
152 wm_put(ice, idx, nval);
153 wm_put_nocache(ice, idx, nval | 0x100);
154 change = 1;
155 }
156 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100157 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 return change;
159}
160
161/*
162 * ADC gain mixer control (-64dB to 0dB)
163 */
164
165#define ADC_0dB 0xcf
166#define ADC_RES 128
167#define ADC_MIN (ADC_0dB - ADC_RES)
168
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100169static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
171 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
172 uinfo->count = 2;
173 uinfo->value.integer.min = 0; /* mute (-64dB) */
174 uinfo->value.integer.max = ADC_RES; /* 0dB, 0.5dB step */
175 return 0;
176}
177
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100178static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100180 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 unsigned short val;
182 int i;
183
Ingo Molnar62932df2006-01-16 16:34:20 +0100184 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 for (i = 0; i < 2; i++) {
186 val = wm_get(ice, WM_ADC_ATTEN_L + i) & 0xff;
187 val = val > ADC_MIN ? (val - ADC_MIN) : 0;
188 ucontrol->value.integer.value[i] = val;
189 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100190 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 return 0;
192}
193
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100194static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100196 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 unsigned short ovol, nvol;
198 int i, idx, change = 0;
199
Ingo Molnar62932df2006-01-16 16:34:20 +0100200 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 for (i = 0; i < 2; i++) {
202 nvol = ucontrol->value.integer.value[i];
203 nvol = nvol ? (nvol + ADC_MIN) : 0;
204 idx = WM_ADC_ATTEN_L + i;
205 ovol = wm_get(ice, idx) & 0xff;
206 if (ovol != nvol) {
207 wm_put(ice, idx, nvol);
208 change = 1;
209 }
210 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100211 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 return change;
213}
214
215/*
216 * ADC input mux mixer control
217 */
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200218#define wm_adc_mux_info snd_ctl_boolean_mono_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100220static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100222 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 int bit = kcontrol->private_value;
224
Ingo Molnar62932df2006-01-16 16:34:20 +0100225 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 ucontrol->value.integer.value[0] = (wm_get(ice, WM_ADC_MUX) & (1 << bit)) ? 1 : 0;
Ingo Molnar62932df2006-01-16 16:34:20 +0100227 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 return 0;
229}
230
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100231static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100233 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 int bit = kcontrol->private_value;
235 unsigned short oval, nval;
236 int change;
237
Ingo Molnar62932df2006-01-16 16:34:20 +0100238 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 nval = oval = wm_get(ice, WM_ADC_MUX);
240 if (ucontrol->value.integer.value[0])
241 nval |= (1 << bit);
242 else
243 nval &= ~(1 << bit);
244 change = nval != oval;
245 if (change) {
246 wm_put(ice, WM_ADC_MUX, nval);
247 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100248 mutex_unlock(&ice->gpio_mutex);
Takashi Iwai43337ac2008-03-17 10:16:37 +0100249 return change;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250}
251
252/*
253 * Analog bypass (In -> Out)
254 */
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200255#define wm_bypass_info snd_ctl_boolean_mono_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100257static int wm_bypass_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100259 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Ingo Molnar62932df2006-01-16 16:34:20 +0100261 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0;
Ingo Molnar62932df2006-01-16 16:34:20 +0100263 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 return 0;
265}
266
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100267static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100269 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 unsigned short val, oval;
271 int change = 0;
272
Ingo Molnar62932df2006-01-16 16:34:20 +0100273 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 val = oval = wm_get(ice, WM_OUT_MUX);
275 if (ucontrol->value.integer.value[0])
276 val |= 0x04;
277 else
278 val &= ~0x04;
279 if (val != oval) {
280 wm_put(ice, WM_OUT_MUX, val);
281 change = 1;
282 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100283 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 return change;
285}
286
287/*
288 * Left/Right swap
289 */
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200290#define wm_chswap_info snd_ctl_boolean_mono_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100292static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100294 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Ingo Molnar62932df2006-01-16 16:34:20 +0100296 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90;
Ingo Molnar62932df2006-01-16 16:34:20 +0100298 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 return 0;
300}
301
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100302static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100304 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 unsigned short val, oval;
306 int change = 0;
307
Ingo Molnar62932df2006-01-16 16:34:20 +0100308 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 oval = wm_get(ice, WM_DAC_CTRL1);
310 val = oval & 0x0f;
311 if (ucontrol->value.integer.value[0])
312 val |= 0x60;
313 else
314 val |= 0x90;
315 if (val != oval) {
316 wm_put(ice, WM_DAC_CTRL1, val);
317 wm_put_nocache(ice, WM_DAC_CTRL1, val);
318 change = 1;
319 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100320 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 return change;
322}
323
324/*
325 * write data in the SPI mode
326 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100327static void set_gpio_bit(struct snd_ice1712 *ice, unsigned int bit, int val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
329 unsigned int tmp = snd_ice1712_gpio_read(ice);
330 if (val)
331 tmp |= bit;
332 else
333 tmp &= ~bit;
334 snd_ice1712_gpio_write(ice, tmp);
335}
336
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100337static void spi_send_byte(struct snd_ice1712 *ice, unsigned char data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338{
339 int i;
340 for (i = 0; i < 8; i++) {
341 set_gpio_bit(ice, PONTIS_CS_CLK, 0);
342 udelay(1);
343 set_gpio_bit(ice, PONTIS_CS_WDATA, data & 0x80);
344 udelay(1);
345 set_gpio_bit(ice, PONTIS_CS_CLK, 1);
346 udelay(1);
347 data <<= 1;
348 }
349}
350
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100351static unsigned int spi_read_byte(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352{
353 int i;
354 unsigned int val = 0;
355
356 for (i = 0; i < 8; i++) {
357 val <<= 1;
358 set_gpio_bit(ice, PONTIS_CS_CLK, 0);
359 udelay(1);
360 if (snd_ice1712_gpio_read(ice) & PONTIS_CS_RDATA)
361 val |= 1;
362 udelay(1);
363 set_gpio_bit(ice, PONTIS_CS_CLK, 1);
364 udelay(1);
365 }
366 return val;
367}
368
369
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100370static void spi_write(struct snd_ice1712 *ice, unsigned int dev, unsigned int reg, unsigned int data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
372 snd_ice1712_gpio_set_dir(ice, PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK);
373 snd_ice1712_gpio_set_mask(ice, ~(PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK));
374 set_gpio_bit(ice, PONTIS_CS_CS, 0);
375 spi_send_byte(ice, dev & ~1); /* WRITE */
376 spi_send_byte(ice, reg); /* MAP */
377 spi_send_byte(ice, data); /* DATA */
378 /* trigger */
379 set_gpio_bit(ice, PONTIS_CS_CS, 1);
380 udelay(1);
381 /* restore */
382 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
383 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
384}
385
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100386static unsigned int spi_read(struct snd_ice1712 *ice, unsigned int dev, unsigned int reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
388 unsigned int val;
389 snd_ice1712_gpio_set_dir(ice, PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK);
390 snd_ice1712_gpio_set_mask(ice, ~(PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK));
391 set_gpio_bit(ice, PONTIS_CS_CS, 0);
392 spi_send_byte(ice, dev & ~1); /* WRITE */
393 spi_send_byte(ice, reg); /* MAP */
394 /* trigger */
395 set_gpio_bit(ice, PONTIS_CS_CS, 1);
396 udelay(1);
397 set_gpio_bit(ice, PONTIS_CS_CS, 0);
398 spi_send_byte(ice, dev | 1); /* READ */
399 val = spi_read_byte(ice);
400 /* trigger */
401 set_gpio_bit(ice, PONTIS_CS_CS, 1);
402 udelay(1);
403 /* restore */
404 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
405 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
406 return val;
407}
408
409
410/*
411 * SPDIF input source
412 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100413static int cs_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414{
Takashi Iwai32b47da2007-01-29 15:26:36 +0100415 static const char * const texts[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 "Coax", /* RXP0 */
417 "Optical", /* RXP1 */
418 "CD", /* RXP2 */
419 };
420 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
421 uinfo->count = 1;
422 uinfo->value.enumerated.items = 3;
423 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
424 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
425 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
426 return 0;
427}
428
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100429static int cs_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100431 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Ingo Molnar62932df2006-01-16 16:34:20 +0100433 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 ucontrol->value.enumerated.item[0] = ice->gpio.saved[0];
Ingo Molnar62932df2006-01-16 16:34:20 +0100435 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 return 0;
437}
438
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100439static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100441 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 unsigned char val;
443 int change = 0;
444
Ingo Molnar62932df2006-01-16 16:34:20 +0100445 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 if (ucontrol->value.enumerated.item[0] != ice->gpio.saved[0]) {
447 ice->gpio.saved[0] = ucontrol->value.enumerated.item[0] & 3;
448 val = 0x80 | (ice->gpio.saved[0] << 3);
449 spi_write(ice, CS_DEV, 0x04, val);
450 change = 1;
451 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100452 mutex_unlock(&ice->gpio_mutex);
Takashi Iwai43337ac2008-03-17 10:16:37 +0100453 return change;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
456
457/*
458 * GPIO controls
459 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100460static int pontis_gpio_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
463 uinfo->count = 1;
464 uinfo->value.integer.min = 0;
465 uinfo->value.integer.max = 0xffff; /* 16bit */
466 return 0;
467}
468
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100469static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100471 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Ingo Molnar62932df2006-01-16 16:34:20 +0100472 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 /* 4-7 reserved */
474 ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0;
Ingo Molnar62932df2006-01-16 16:34:20 +0100475 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 return 0;
477}
478
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100479static int pontis_gpio_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100481 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 unsigned int val;
483 int changed;
Ingo Molnar62932df2006-01-16 16:34:20 +0100484 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 /* 4-7 reserved */
486 val = (~ucontrol->value.integer.value[0] & 0xffff) | 0x00f0;
487 changed = val != ice->gpio.write_mask;
488 ice->gpio.write_mask = val;
Ingo Molnar62932df2006-01-16 16:34:20 +0100489 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 return changed;
491}
492
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100493static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100495 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Ingo Molnar62932df2006-01-16 16:34:20 +0100496 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 /* 4-7 reserved */
498 ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f;
Ingo Molnar62932df2006-01-16 16:34:20 +0100499 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 return 0;
501}
502
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100503static int pontis_gpio_dir_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100505 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 unsigned int val;
507 int changed;
Ingo Molnar62932df2006-01-16 16:34:20 +0100508 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 /* 4-7 reserved */
510 val = ucontrol->value.integer.value[0] & 0xff0f;
511 changed = (val != ice->gpio.direction);
512 ice->gpio.direction = val;
Ingo Molnar62932df2006-01-16 16:34:20 +0100513 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 return changed;
515}
516
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100517static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100519 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Ingo Molnar62932df2006-01-16 16:34:20 +0100520 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
522 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
523 ucontrol->value.integer.value[0] = snd_ice1712_gpio_read(ice) & 0xffff;
Ingo Molnar62932df2006-01-16 16:34:20 +0100524 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 return 0;
526}
527
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100528static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100530 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 unsigned int val, nval;
532 int changed = 0;
Ingo Molnar62932df2006-01-16 16:34:20 +0100533 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
535 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask);
536 val = snd_ice1712_gpio_read(ice) & 0xffff;
537 nval = ucontrol->value.integer.value[0] & 0xffff;
538 if (val != nval) {
539 snd_ice1712_gpio_write(ice, nval);
540 changed = 1;
541 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100542 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 return changed;
544}
545
Takashi Iwai0cb29ea2007-01-29 15:33:49 +0100546static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
Takashi Iwaif640c322006-08-30 16:57:37 +0200547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548/*
549 * mixers
550 */
551
Bill Pembertone23e7a12012-12-06 12:35:10 -0500552static struct snd_kcontrol_new pontis_controls[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 {
554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwaif640c322006-08-30 16:57:37 +0200555 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
556 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 .name = "PCM Playback Volume",
558 .info = wm_dac_vol_info,
559 .get = wm_dac_vol_get,
560 .put = wm_dac_vol_put,
Takashi Iwaif640c322006-08-30 16:57:37 +0200561 .tlv = { .p = db_scale_volume },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 },
563 {
564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Takashi Iwaif640c322006-08-30 16:57:37 +0200565 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
566 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .name = "Capture Volume",
568 .info = wm_adc_vol_info,
569 .get = wm_adc_vol_get,
570 .put = wm_adc_vol_put,
Takashi Iwaif640c322006-08-30 16:57:37 +0200571 .tlv = { .p = db_scale_volume },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573 {
574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
575 .name = "CD Capture Switch",
576 .info = wm_adc_mux_info,
577 .get = wm_adc_mux_get,
578 .put = wm_adc_mux_put,
579 .private_value = 0,
580 },
581 {
582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
583 .name = "Line Capture Switch",
584 .info = wm_adc_mux_info,
585 .get = wm_adc_mux_get,
586 .put = wm_adc_mux_put,
587 .private_value = 1,
588 },
589 {
590 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
591 .name = "Analog Bypass Switch",
592 .info = wm_bypass_info,
593 .get = wm_bypass_get,
594 .put = wm_bypass_put,
595 },
596 {
597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
598 .name = "Swap Output Channels",
599 .info = wm_chswap_info,
600 .get = wm_chswap_get,
601 .put = wm_chswap_put,
602 },
603 {
604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
605 .name = "IEC958 Input Source",
606 .info = cs_source_info,
607 .get = cs_source_get,
608 .put = cs_source_put,
609 },
610 /* FIXME: which interface? */
611 {
612 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
613 .name = "GPIO Mask",
614 .info = pontis_gpio_mask_info,
615 .get = pontis_gpio_mask_get,
616 .put = pontis_gpio_mask_put,
617 },
618 {
619 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
620 .name = "GPIO Direction",
621 .info = pontis_gpio_mask_info,
622 .get = pontis_gpio_dir_get,
623 .put = pontis_gpio_dir_put,
624 },
625 {
626 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
627 .name = "GPIO Data",
628 .info = pontis_gpio_mask_info,
629 .get = pontis_gpio_data_get,
630 .put = pontis_gpio_data_put,
631 },
632};
633
634
635/*
636 * WM codec registers
637 */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100638static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639{
Joe Perches9fe856e2010-09-04 18:52:54 -0700640 struct snd_ice1712 *ice = entry->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 char line[64];
642 unsigned int reg, val;
Ingo Molnar62932df2006-01-16 16:34:20 +0100643 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 while (!snd_info_get_line(buffer, line, sizeof(line))) {
645 if (sscanf(line, "%x %x", &reg, &val) != 2)
646 continue;
647 if (reg <= 0x17 && val <= 0xffff)
648 wm_put(ice, reg, val);
649 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100650 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651}
652
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100653static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654{
Joe Perches9fe856e2010-09-04 18:52:54 -0700655 struct snd_ice1712 *ice = entry->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 int reg, val;
657
Ingo Molnar62932df2006-01-16 16:34:20 +0100658 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 for (reg = 0; reg <= 0x17; reg++) {
660 val = wm_get(ice, reg);
661 snd_iprintf(buffer, "%02x = %04x\n", reg, val);
662 }
Ingo Molnar62932df2006-01-16 16:34:20 +0100663 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664}
665
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100666static void wm_proc_init(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100668 struct snd_info_entry *entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 if (! snd_card_proc_new(ice->card, "wm_codec", &entry)) {
Takashi Iwaibf850202006-04-28 15:13:41 +0200670 snd_info_set_text_ops(entry, ice, wm_proc_regs_read);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 entry->mode |= S_IWUSR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 entry->c.text.write = wm_proc_regs_write;
673 }
674}
675
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100676static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677{
Joe Perches9fe856e2010-09-04 18:52:54 -0700678 struct snd_ice1712 *ice = entry->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 int reg, val;
680
Ingo Molnar62932df2006-01-16 16:34:20 +0100681 mutex_lock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 for (reg = 0; reg <= 0x26; reg++) {
683 val = spi_read(ice, CS_DEV, reg);
684 snd_iprintf(buffer, "%02x = %02x\n", reg, val);
685 }
686 val = spi_read(ice, CS_DEV, 0x7f);
687 snd_iprintf(buffer, "%02x = %02x\n", 0x7f, val);
Ingo Molnar62932df2006-01-16 16:34:20 +0100688 mutex_unlock(&ice->gpio_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689}
690
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100691static void cs_proc_init(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692{
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100693 struct snd_info_entry *entry;
Takashi Iwaibf850202006-04-28 15:13:41 +0200694 if (! snd_card_proc_new(ice->card, "cs_codec", &entry))
695 snd_info_set_text_ops(entry, ice, cs_proc_regs_read);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696}
697
698
Bill Pembertone23e7a12012-12-06 12:35:10 -0500699static int pontis_add_controls(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700{
701 unsigned int i;
702 int err;
703
704 for (i = 0; i < ARRAY_SIZE(pontis_controls); i++) {
705 err = snd_ctl_add(ice->card, snd_ctl_new1(&pontis_controls[i], ice));
706 if (err < 0)
707 return err;
708 }
709
710 wm_proc_init(ice);
711 cs_proc_init(ice);
712
713 return 0;
714}
715
716
717/*
718 * initialize the chip
719 */
Bill Pembertone23e7a12012-12-06 12:35:10 -0500720static int pontis_init(struct snd_ice1712 *ice)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721{
Takashi Iwai32b47da2007-01-29 15:26:36 +0100722 static const unsigned short wm_inits[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 /* These come first to reduce init pop noise */
724 WM_ADC_MUX, 0x00c0, /* ADC mute */
725 WM_DAC_MUTE, 0x0001, /* DAC softmute */
726 WM_DAC_CTRL1, 0x0000, /* DAC mute */
727
728 WM_POWERDOWN, 0x0008, /* All power-up except HP */
729 WM_RESET, 0x0000, /* reset */
730 };
Takashi Iwai32b47da2007-01-29 15:26:36 +0100731 static const unsigned short wm_inits2[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 WM_MASTER_CTRL, 0x0022, /* 256fs, slave mode */
733 WM_DAC_INT, 0x0022, /* I2S, normal polarity, 24bit */
734 WM_ADC_INT, 0x0022, /* I2S, normal polarity, 24bit */
735 WM_DAC_CTRL1, 0x0090, /* DAC L/R */
736 WM_OUT_MUX, 0x0001, /* OUT DAC */
737 WM_HP_ATTEN_L, 0x0179, /* HP 0dB */
738 WM_HP_ATTEN_R, 0x0179, /* HP 0dB */
739 WM_DAC_ATTEN_L, 0x0000, /* DAC 0dB */
740 WM_DAC_ATTEN_L, 0x0100, /* DAC 0dB */
741 WM_DAC_ATTEN_R, 0x0000, /* DAC 0dB */
742 WM_DAC_ATTEN_R, 0x0100, /* DAC 0dB */
Vedran Mileticcc67b7f2008-09-07 12:00:02 +0200743 /* WM_DAC_MASTER, 0x0100, */ /* DAC master muted */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 WM_PHASE_SWAP, 0x0000, /* phase normal */
745 WM_DAC_CTRL2, 0x0000, /* no deemphasis, no ZFLG */
746 WM_ADC_ATTEN_L, 0x0000, /* ADC muted */
747 WM_ADC_ATTEN_R, 0x0000, /* ADC muted */
748#if 0
749 WM_ALC_CTRL1, 0x007b, /* */
750 WM_ALC_CTRL2, 0x0000, /* */
751 WM_ALC_CTRL3, 0x0000, /* */
752 WM_NOISE_GATE, 0x0000, /* */
753#endif
754 WM_DAC_MUTE, 0x0000, /* DAC unmute */
755 WM_ADC_MUX, 0x0003, /* ADC unmute, both CD/Line On */
756 };
Takashi Iwai32b47da2007-01-29 15:26:36 +0100757 static const unsigned char cs_inits[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 0x04, 0x80, /* RUN, RXP0 */
759 0x05, 0x05, /* slave, 24bit */
760 0x01, 0x00,
761 0x02, 0x00,
762 0x03, 0x00,
763 };
764 unsigned int i;
765
766 ice->vt1720 = 1;
767 ice->num_total_dacs = 2;
768 ice->num_total_adcs = 2;
769
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300770 /* to remember the register values */
Takashi Iwaiab0c7d72005-11-17 15:00:18 +0100771 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 if (! ice->akm)
773 return -ENOMEM;
774 ice->akm_codecs = 1;
775
776 /* HACK - use this as the SPDIF source.
777 * don't call snd_ice1712_gpio_get/put(), otherwise it's overwritten
778 */
779 ice->gpio.saved[0] = 0;
780
781 /* initialize WM8776 codec */
782 for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
783 wm_put(ice, wm_inits[i], wm_inits[i+1]);
Nishanth Aravamudan8433a502005-10-24 15:02:37 +0200784 schedule_timeout_uninterruptible(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 for (i = 0; i < ARRAY_SIZE(wm_inits2); i += 2)
786 wm_put(ice, wm_inits2[i], wm_inits2[i+1]);
787
788 /* initialize CS8416 codec */
789 /* assert PRST#; MT05 bit 7 */
790 outb(inb(ICEMT1724(ice, AC97_CMD)) | 0x80, ICEMT1724(ice, AC97_CMD));
791 mdelay(5);
792 /* deassert PRST# */
793 outb(inb(ICEMT1724(ice, AC97_CMD)) & ~0x80, ICEMT1724(ice, AC97_CMD));
794
795 for (i = 0; i < ARRAY_SIZE(cs_inits); i += 2)
796 spi_write(ice, CS_DEV, cs_inits[i], cs_inits[i+1]);
797
798 return 0;
799}
800
801
802/*
803 * Pontis boards don't provide the EEPROM data at all.
804 * hence the driver needs to sets up it properly.
805 */
806
Bill Pembertone23e7a12012-12-06 12:35:10 -0500807static unsigned char pontis_eeprom[] = {
Takashi Iwai189bc172007-01-29 15:25:40 +0100808 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */
809 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
810 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
811 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
812 [ICE_EEP2_GPIO_DIR] = 0x07,
813 [ICE_EEP2_GPIO_DIR1] = 0x00,
814 [ICE_EEP2_GPIO_DIR2] = 0x00, /* ignored */
815 [ICE_EEP2_GPIO_MASK] = 0x0f, /* 4-7 reserved for CS8416 */
816 [ICE_EEP2_GPIO_MASK1] = 0xff,
817 [ICE_EEP2_GPIO_MASK2] = 0x00, /* ignored */
818 [ICE_EEP2_GPIO_STATE] = 0x06, /* 0-low, 1-high, 2-high */
819 [ICE_EEP2_GPIO_STATE1] = 0x00,
820 [ICE_EEP2_GPIO_STATE2] = 0x00, /* ignored */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821};
822
823/* entry point */
Bill Pembertone23e7a12012-12-06 12:35:10 -0500824struct snd_ice1712_card_info snd_vt1720_pontis_cards[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 {
826 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300,
827 .name = "Pontis MS300",
828 .model = "ms300",
829 .chip_init = pontis_init,
830 .build_controls = pontis_add_controls,
831 .eeprom_size = sizeof(pontis_eeprom),
832 .eeprom_data = pontis_eeprom,
833 },
834 { } /* terminator */
835};