blob: 4f574cefe775d187c08a868e11e8db7bfa601099 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __SOUND_AK4XXX_ADDA_H
3#define __SOUND_AK4XXX_ADDA_H
4
5/*
6 * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4381
7 * AD and DA converters
8 *
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02009 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
12#ifndef AK4XXX_MAX_CHIPS
13#define AK4XXX_MAX_CHIPS 4
14#endif
15
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010016struct snd_akm4xxx;
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18struct snd_ak4xxx_ops {
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010019 void (*lock)(struct snd_akm4xxx *ak, int chip);
20 void (*unlock)(struct snd_akm4xxx *ak, int chip);
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020021 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
22 unsigned char val);
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010023 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024};
25
26#define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
27
Takashi Iwai723b2b02006-08-30 16:49:54 +020028/* DAC label and channels */
29struct snd_akm4xxx_dac_channel {
30 char *name; /* mixer volume name */
31 unsigned int num_channels;
Pavel Hofmanea7cfcd2007-05-19 17:21:04 +020032 char *switch_name; /* mixer switch*/
Takashi Iwai723b2b02006-08-30 16:49:54 +020033};
34
35/* ADC labels and channels */
36struct snd_akm4xxx_adc_channel {
37 char *name; /* capture gain volume label */
Takashi Iwai723b2b02006-08-30 16:49:54 +020038 char *switch_name; /* capture switch */
39 unsigned int num_channels;
Jochen Vossa58e7cb2006-10-04 18:04:10 +020040 char *selector_name; /* capture source select label */
41 const char **input_names; /* capture source names (NULL terminated) */
Takashi Iwai723b2b02006-08-30 16:49:54 +020042};
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044struct snd_akm4xxx {
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010045 struct snd_card *card;
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020046 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
47 unsigned int num_dacs; /* AK4524 or AK4528 DACs */
48 unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
Takashi Iwai723b2b02006-08-30 16:49:54 +020049 unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
51 void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
52 /* template should fill the following fields */
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020053 unsigned int idx_offset; /* control index offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 enum {
55 SND_AK4524, SND_AK4528, SND_AK4529,
Jochen Voss683fe152006-08-08 21:12:44 +020056 SND_AK4355, SND_AK4358, SND_AK4381,
Pavel Hofman8f346922009-09-16 22:25:36 +020057 SND_AK5365, SND_AK4620,
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 } type;
Takashi Iwai723b2b02006-08-30 16:49:54 +020059
60 /* (array) information of combined codecs */
Takashi Iwai517400c2007-01-29 15:27:56 +010061 const struct snd_akm4xxx_dac_channel *dac_info;
62 const struct snd_akm4xxx_adc_channel *adc_info;
Takashi Iwai723b2b02006-08-30 16:49:54 +020063
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 struct snd_ak4xxx_ops ops;
Pavel Hofman8f346922009-09-16 22:25:36 +020065 unsigned int num_chips;
66 unsigned int total_regs;
67 const char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068};
69
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020070void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
71 unsigned char val);
Takashi Iwaidc4cafba2005-11-17 14:19:28 +010072void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
73void snd_akm4xxx_init(struct snd_akm4xxx *ak);
74int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Takashi Iwaicb9d24e2006-06-27 17:49:12 +020076#define snd_akm4xxx_get(ak,chip,reg) \
77 (ak)->images[(chip) * 16 + (reg)]
78#define snd_akm4xxx_set(ak,chip,reg,val) \
79 ((ak)->images[(chip) * 16 + (reg)] = (val))
Takashi Iwai723b2b02006-08-30 16:49:54 +020080#define snd_akm4xxx_get_vol(ak,chip,reg) \
81 (ak)->volumes[(chip) * 16 + (reg)]
82#define snd_akm4xxx_set_vol(ak,chip,reg,val) \
83 ((ak)->volumes[(chip) * 16 + (reg)] = (val))
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085#endif /* __SOUND_AK4XXX_ADDA_H */