blob: 891cf1aea8b139db918705149a9e7ffb25760fd5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_AK4XXX_ADDA_H
2#define __SOUND_AK4XXX_ADDA_H
3
4/*
5 * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4381
6 * AD and DA converters
7 *
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02008 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 *
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.
14 *
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.
19 *
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
23 *
24 */
25
26#ifndef AK4XXX_MAX_CHIPS
27#define AK4XXX_MAX_CHIPS 4
28#endif
29
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010030struct snd_akm4xxx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32struct snd_ak4xxx_ops {
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010033 void (*lock)(struct snd_akm4xxx *ak, int chip);
34 void (*unlock)(struct snd_akm4xxx *ak, int chip);
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020035 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
36 unsigned char val);
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010037 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
40#define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
41
Takashi Iwai723b2b02006-08-30 16:49:54 +020042/* DAC label and channels */
43struct snd_akm4xxx_dac_channel {
44 char *name; /* mixer volume name */
45 unsigned int num_channels;
Pavel Hofmanea7cfcd2007-05-19 17:21:04 +020046 char *switch_name; /* mixer switch*/
Takashi Iwai723b2b02006-08-30 16:49:54 +020047};
48
49/* ADC labels and channels */
50struct snd_akm4xxx_adc_channel {
51 char *name; /* capture gain volume label */
Takashi Iwai723b2b02006-08-30 16:49:54 +020052 char *switch_name; /* capture switch */
53 unsigned int num_channels;
Jochen Vossa58e7cb2006-10-04 18:04:10 +020054 char *selector_name; /* capture source select label */
55 const char **input_names; /* capture source names (NULL terminated) */
Takashi Iwai723b2b02006-08-30 16:49:54 +020056};
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058struct snd_akm4xxx {
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010059 struct snd_card *card;
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020060 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
61 unsigned int num_dacs; /* AK4524 or AK4528 DACs */
62 unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
Takashi Iwai723b2b02006-08-30 16:49:54 +020063 unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
65 void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
66 /* template should fill the following fields */
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020067 unsigned int idx_offset; /* control index offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 enum {
69 SND_AK4524, SND_AK4528, SND_AK4529,
Jochen Voss683fe152006-08-08 21:12:44 +020070 SND_AK4355, SND_AK4358, SND_AK4381,
Pavel Hofman841b23d2008-03-17 08:45:33 +010071 SND_AK5365
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 } type;
Takashi Iwai723b2b02006-08-30 16:49:54 +020073
74 /* (array) information of combined codecs */
Takashi Iwai517400c2007-01-29 15:27:56 +010075 const struct snd_akm4xxx_dac_channel *dac_info;
76 const struct snd_akm4xxx_adc_channel *adc_info;
Takashi Iwai723b2b02006-08-30 16:49:54 +020077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 struct snd_ak4xxx_ops ops;
79};
80
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020081void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
82 unsigned char val);
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010083void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
84void snd_akm4xxx_init(struct snd_akm4xxx *ak);
85int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020087#define snd_akm4xxx_get(ak,chip,reg) \
88 (ak)->images[(chip) * 16 + (reg)]
89#define snd_akm4xxx_set(ak,chip,reg,val) \
90 ((ak)->images[(chip) * 16 + (reg)] = (val))
Takashi Iwai723b2b02006-08-30 16:49:54 +020091#define snd_akm4xxx_get_vol(ak,chip,reg) \
92 (ak)->volumes[(chip) * 16 + (reg)]
93#define snd_akm4xxx_set_vol(ak,chip,reg,val) \
94 ((ak)->volumes[(chip) * 16 + (reg)] = (val))
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#endif /* __SOUND_AK4XXX_ADDA_H */