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 | #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 Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 9 | * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef AK4XXX_MAX_CHIPS |
| 13 | #define AK4XXX_MAX_CHIPS 4 |
| 14 | #endif |
| 15 | |
Takashi Iwai | dc4cafba | 2005-11-17 14:19:28 +0100 | [diff] [blame] | 16 | struct snd_akm4xxx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | struct snd_ak4xxx_ops { |
Takashi Iwai | dc4cafba | 2005-11-17 14:19:28 +0100 | [diff] [blame] | 19 | void (*lock)(struct snd_akm4xxx *ak, int chip); |
| 20 | void (*unlock)(struct snd_akm4xxx *ak, int chip); |
Takashi Iwai | cb9d24e | 2006-06-27 17:49:12 +0200 | [diff] [blame] | 21 | void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg, |
| 22 | unsigned char val); |
Takashi Iwai | dc4cafba | 2005-11-17 14:19:28 +0100 | [diff] [blame] | 23 | void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */ |
| 27 | |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 28 | /* DAC label and channels */ |
| 29 | struct snd_akm4xxx_dac_channel { |
| 30 | char *name; /* mixer volume name */ |
| 31 | unsigned int num_channels; |
Pavel Hofman | ea7cfcd | 2007-05-19 17:21:04 +0200 | [diff] [blame] | 32 | char *switch_name; /* mixer switch*/ |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | /* ADC labels and channels */ |
| 36 | struct snd_akm4xxx_adc_channel { |
| 37 | char *name; /* capture gain volume label */ |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 38 | char *switch_name; /* capture switch */ |
| 39 | unsigned int num_channels; |
Jochen Voss | a58e7cb | 2006-10-04 18:04:10 +0200 | [diff] [blame] | 40 | char *selector_name; /* capture source select label */ |
| 41 | const char **input_names; /* capture source names (NULL terminated) */ |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | struct snd_akm4xxx { |
Takashi Iwai | dc4cafba | 2005-11-17 14:19:28 +0100 | [diff] [blame] | 45 | struct snd_card *card; |
Takashi Iwai | cb9d24e | 2006-06-27 17:49:12 +0200 | [diff] [blame] | 46 | 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 Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 49 | unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | 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 Iwai | cb9d24e | 2006-06-27 17:49:12 +0200 | [diff] [blame] | 53 | unsigned int idx_offset; /* control index offset */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | enum { |
| 55 | SND_AK4524, SND_AK4528, SND_AK4529, |
Jochen Voss | 683fe15 | 2006-08-08 21:12:44 +0200 | [diff] [blame] | 56 | SND_AK4355, SND_AK4358, SND_AK4381, |
Pavel Hofman | 8f34692 | 2009-09-16 22:25:36 +0200 | [diff] [blame] | 57 | SND_AK5365, SND_AK4620, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } type; |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 59 | |
| 60 | /* (array) information of combined codecs */ |
Takashi Iwai | 517400c | 2007-01-29 15:27:56 +0100 | [diff] [blame] | 61 | const struct snd_akm4xxx_dac_channel *dac_info; |
| 62 | const struct snd_akm4xxx_adc_channel *adc_info; |
Takashi Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | struct snd_ak4xxx_ops ops; |
Pavel Hofman | 8f34692 | 2009-09-16 22:25:36 +0200 | [diff] [blame] | 65 | unsigned int num_chips; |
| 66 | unsigned int total_regs; |
| 67 | const char *name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | cb9d24e | 2006-06-27 17:49:12 +0200 | [diff] [blame] | 70 | void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, |
| 71 | unsigned char val); |
Takashi Iwai | dc4cafba | 2005-11-17 14:19:28 +0100 | [diff] [blame] | 72 | void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state); |
| 73 | void snd_akm4xxx_init(struct snd_akm4xxx *ak); |
| 74 | int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Takashi Iwai | cb9d24e | 2006-06-27 17:49:12 +0200 | [diff] [blame] | 76 | #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 Iwai | 723b2b0 | 2006-08-30 16:49:54 +0200 | [diff] [blame] | 80 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #endif /* __SOUND_AK4XXX_ADDA_H */ |