1 #ifndef __SOUND_AK4XXX_ADDA_H
2 #define __SOUND_AK4XXX_ADDA_H
5 * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4381
8 * Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef AK4XXX_MAX_CHIPS
27 #define AK4XXX_MAX_CHIPS 4
32 struct snd_ak4xxx_ops {
33 void (*lock)(struct snd_akm4xxx *ak, int chip);
34 void (*unlock)(struct snd_akm4xxx *ak, int chip);
35 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
37 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
40 #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
42 /* DAC label and channels */
43 struct snd_akm4xxx_dac_channel {
44 char *name; /* mixer volume name */
45 unsigned int num_channels;
48 /* ADC labels and channels */
49 struct snd_akm4xxx_adc_channel {
50 char *name; /* capture gain volume label */
51 char *gain_name; /* IPGA */
52 char *switch_name; /* capture switch */
53 unsigned int num_channels;
57 struct snd_card *card;
58 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
59 unsigned int num_dacs; /* AK4524 or AK4528 DACs */
60 unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
61 unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */
62 unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
63 void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
64 /* template should fill the following fields */
65 unsigned int idx_offset; /* control index offset */
67 SND_AK4524, SND_AK4528, SND_AK4529,
68 SND_AK4355, SND_AK4358, SND_AK4381,
72 /* (array) information of combined codecs */
73 struct snd_akm4xxx_dac_channel *dac_info;
74 struct snd_akm4xxx_adc_channel *adc_info;
76 struct snd_ak4xxx_ops ops;
79 void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
81 void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
82 void snd_akm4xxx_init(struct snd_akm4xxx *ak);
83 int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
85 #define snd_akm4xxx_get(ak,chip,reg) \
86 (ak)->images[(chip) * 16 + (reg)]
87 #define snd_akm4xxx_set(ak,chip,reg,val) \
88 ((ak)->images[(chip) * 16 + (reg)] = (val))
89 #define snd_akm4xxx_get_vol(ak,chip,reg) \
90 (ak)->volumes[(chip) * 16 + (reg)]
91 #define snd_akm4xxx_set_vol(ak,chip,reg,val) \
92 ((ak)->volumes[(chip) * 16 + (reg)] = (val))
94 /* Warning: IPGA is tricky - we assume the addr + 4 is unused
95 * so far, it's OK for all AK codecs with IPGA:
96 * AK4524, AK4528 and EK5365
98 #define snd_akm4xxx_get_ipga(ak,chip,reg) \
99 snd_akm4xxx_get_vol(ak, chip, (reg) + 4)
100 #define snd_akm4xxx_set_ipga(ak,chip,reg,val) \
101 snd_akm4xxx_set_vol(ak, chip, (reg) + 4, val)
103 #endif /* __SOUND_AK4XXX_ADDA_H */