diff options
-rw-r--r-- | include/sound/uda1341.h | 107 | ||||
-rw-r--r-- | sound/arm/sa11xx-uda1341.c | 38 | ||||
-rw-r--r-- | sound/i2c/l3/uda1341.c | 170 |
3 files changed, 154 insertions, 161 deletions
diff --git a/include/sound/uda1341.h b/include/sound/uda1341.h index 61ff65a628bc..54a048ac6e4f 100644 --- a/include/sound/uda1341.h +++ b/include/sound/uda1341.h | |||
@@ -15,7 +15,7 @@ | |||
15 | * features support | 15 | * features support |
16 | */ | 16 | */ |
17 | 17 | ||
18 | /* $Id: uda1341.h,v 1.6 2004/05/03 17:36:50 tiwai Exp $ */ | 18 | /* $Id: uda1341.h,v 1.7 2005/11/17 10:25:22 tiwai Exp $ */ |
19 | 19 | ||
20 | #define UDA1341_ALSA_NAME "snd-uda1341" | 20 | #define UDA1341_ALSA_NAME "snd-uda1341" |
21 | 21 | ||
@@ -37,11 +37,6 @@ enum uda1341_onoff { | |||
37 | ON, | 37 | ON, |
38 | }; | 38 | }; |
39 | 39 | ||
40 | const char *onoff_names[] = { | ||
41 | "Off", | ||
42 | "On", | ||
43 | }; | ||
44 | |||
45 | enum uda1341_format { | 40 | enum uda1341_format { |
46 | I2S=0, | 41 | I2S=0, |
47 | LSB16, | 42 | LSB16, |
@@ -53,17 +48,6 @@ enum uda1341_format { | |||
53 | LSB20MSB, | 48 | LSB20MSB, |
54 | }; | 49 | }; |
55 | 50 | ||
56 | const char *format_names[] = { | ||
57 | "I2S-bus", | ||
58 | "LSB 16bits", | ||
59 | "LSB 18bits", | ||
60 | "LSB 20bits", | ||
61 | "MSB", | ||
62 | "in LSB 16bits/out MSB", | ||
63 | "in LSB 18bits/out MSB", | ||
64 | "in LSB 20bits/out MSB", | ||
65 | }; | ||
66 | |||
67 | enum uda1341_fs { | 51 | enum uda1341_fs { |
68 | F512=0, | 52 | F512=0, |
69 | F384, | 53 | F384, |
@@ -71,23 +55,11 @@ enum uda1341_fs { | |||
71 | Funused, | 55 | Funused, |
72 | }; | 56 | }; |
73 | 57 | ||
74 | const char *fs_names[] = { | ||
75 | "512*fs", | ||
76 | "384*fs", | ||
77 | "256*fs", | ||
78 | "Unused - bad value!", | ||
79 | }; | ||
80 | |||
81 | enum uda1341_peak { | 58 | enum uda1341_peak { |
82 | BEFORE=0, | 59 | BEFORE=0, |
83 | AFTER, | 60 | AFTER, |
84 | }; | 61 | }; |
85 | 62 | ||
86 | const char *peak_names[] = { | ||
87 | "before", | ||
88 | "after", | ||
89 | }; | ||
90 | |||
91 | enum uda1341_filter { | 63 | enum uda1341_filter { |
92 | FLAT=0, | 64 | FLAT=0, |
93 | MIN, | 65 | MIN, |
@@ -95,24 +67,6 @@ enum uda1341_filter { | |||
95 | MAX, | 67 | MAX, |
96 | }; | 68 | }; |
97 | 69 | ||
98 | const char *filter_names[] = { | ||
99 | "flat", | ||
100 | "min", | ||
101 | "min", | ||
102 | "max", | ||
103 | }; | ||
104 | |||
105 | const char*bass_values[][16] = { | ||
106 | {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", | ||
107 | "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat | ||
108 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | ||
109 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | ||
110 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | ||
111 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | ||
112 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB", | ||
113 | "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max | ||
114 | }; | ||
115 | |||
116 | enum uda1341_mixer { | 70 | enum uda1341_mixer { |
117 | DOUBLE, | 71 | DOUBLE, |
118 | LINE, | 72 | LINE, |
@@ -120,13 +74,6 @@ enum uda1341_mixer { | |||
120 | MIXER, | 74 | MIXER, |
121 | }; | 75 | }; |
122 | 76 | ||
123 | const char *mixer_names[] = { | ||
124 | "double differential", | ||
125 | "input channel 1 (line in)", | ||
126 | "input channel 2 (microphone)", | ||
127 | "digital mixer", | ||
128 | }; | ||
129 | |||
130 | enum uda1341_deemp { | 77 | enum uda1341_deemp { |
131 | NONE, | 78 | NONE, |
132 | D32, | 79 | D32, |
@@ -134,58 +81,6 @@ enum uda1341_deemp { | |||
134 | D48, | 81 | D48, |
135 | }; | 82 | }; |
136 | 83 | ||
137 | const char *deemp_names[] = { | ||
138 | "none", | ||
139 | "32 kHz", | ||
140 | "44.1 kHz", | ||
141 | "48 kHz", | ||
142 | }; | ||
143 | |||
144 | const char *mic_sens_value[] = { | ||
145 | "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used", | ||
146 | }; | ||
147 | |||
148 | const unsigned short AGC_atime[] = { | ||
149 | 11, 16, 11, 16, 21, 11, 16, 21, | ||
150 | }; | ||
151 | |||
152 | const unsigned short AGC_dtime[] = { | ||
153 | 100, 100, 200, 200, 200, 400, 400, 400, | ||
154 | }; | ||
155 | |||
156 | const char *AGC_level[] = { | ||
157 | "-9.0", "-11.5", "-15.0", "-17.5", | ||
158 | }; | ||
159 | |||
160 | const char *ig_small_value[] = { | ||
161 | "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", | ||
162 | }; | ||
163 | |||
164 | /* | ||
165 | * this was computed as peak_value[i] = pow((63-i)*1.42,1.013) | ||
166 | * | ||
167 | * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2 | ||
168 | * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29 | ||
169 | * [61]=-2.78, [62] = -1.48, [63] = 0.0 | ||
170 | * I tried to compute it, but using but even using logarithm with base either 10 or 2 | ||
171 | * i was'n able to get values in the table from the formula. So I constructed another | ||
172 | * formula (see above) to interpolate the values as good as possible. If there is some | ||
173 | * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks. | ||
174 | * UDA1341TS datasheet is available at: | ||
175 | * http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf | ||
176 | */ | ||
177 | const char *peak_value[] = { | ||
178 | "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB", | ||
179 | "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB", | ||
180 | "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB", | ||
181 | "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB", | ||
182 | "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB", | ||
183 | "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB", | ||
184 | "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB", | ||
185 | "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB", | ||
186 | "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", | ||
187 | }; | ||
188 | |||
189 | enum uda1341_config { | 84 | enum uda1341_config { |
190 | CMD_READ_REG = 0, | 85 | CMD_READ_REG = 0, |
191 | CMD_RESET, | 86 | CMD_RESET, |
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 6ee912259cc5..97dffcc3f75f 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * merged HAL layer (patches from Brian) | 21 | * merged HAL layer (patches from Brian) |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* $Id: sa11xx-uda1341.c,v 1.23 2005/09/09 13:22:34 tiwai Exp $ */ | 24 | /* $Id: sa11xx-uda1341.c,v 1.24 2005/11/17 10:25:22 tiwai Exp $ */ |
25 | 25 | ||
26 | /*************************************************************************************************** | 26 | /*************************************************************************************************** |
27 | * | 27 | * |
@@ -141,8 +141,6 @@ typedef struct snd_card_sa11xx_uda1341 { | |||
141 | audio_stream_t s[2]; /* playback & capture */ | 141 | audio_stream_t s[2]; /* playback & capture */ |
142 | } sa11xx_uda1341_t; | 142 | } sa11xx_uda1341_t; |
143 | 143 | ||
144 | static struct snd_card_sa11xx_uda1341 *sa11xx_uda1341 = NULL; | ||
145 | |||
146 | static unsigned int rates[] = { | 144 | static unsigned int rates[] = { |
147 | 8000, 10666, 10985, 14647, | 145 | 8000, 10666, 10985, 14647, |
148 | 16000, 21970, 22050, 24000, | 146 | 16000, 21970, 22050, 24000, |
@@ -411,8 +409,8 @@ static int audio_dma_request(audio_stream_t *s, void (*callback)(void *)) | |||
411 | 409 | ||
412 | static void audio_dma_free(audio_stream_t *s) | 410 | static void audio_dma_free(audio_stream_t *s) |
413 | { | 411 | { |
414 | sa1100_free_dma((s)->dma_regs); | 412 | sa1100_free_dma(s->dma_regs); |
415 | (s)->dma_regs = 0; | 413 | s->dma_regs = 0; |
416 | } | 414 | } |
417 | 415 | ||
418 | #endif | 416 | #endif |
@@ -835,8 +833,8 @@ static int __init snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341_t *sa11xx_uda1341, | |||
835 | * isa works but I'm not sure why (or if) it's the right choice | 833 | * isa works but I'm not sure why (or if) it's the right choice |
836 | * this may be too large, trying it for now | 834 | * this may be too large, trying it for now |
837 | */ | 835 | */ |
838 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_ISA, | 836 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
839 | snd_pcm_dma_flags(0), | 837 | snd_dma_isa_data(), |
840 | 64*1024, 64*1024); | 838 | 64*1024, 64*1024); |
841 | 839 | ||
842 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_sa11xx_uda1341_playback_ops); | 840 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_sa11xx_uda1341_playback_ops); |
@@ -900,15 +898,15 @@ void snd_sa11xx_uda1341_free(snd_card_t *card) | |||
900 | 898 | ||
901 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]); | 899 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]); |
902 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); | 900 | audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); |
903 | sa11xx_uda1341 = NULL; | ||
904 | card->private_data = NULL; | ||
905 | kfree(chip); | ||
906 | } | 901 | } |
907 | 902 | ||
903 | static snd_card_t *sa11xx_uda1341_card; | ||
904 | |||
908 | static int __init sa11xx_uda1341_init(void) | 905 | static int __init sa11xx_uda1341_init(void) |
909 | { | 906 | { |
910 | int err; | 907 | int err; |
911 | snd_card_t *card; | 908 | snd_card_t *card; |
909 | sa11xx_uda1341_t *chip; | ||
912 | 910 | ||
913 | if (!machine_is_h3xxx()) | 911 | if (!machine_is_h3xxx()) |
914 | return -ENODEV; | 912 | return -ENODEV; |
@@ -921,26 +919,25 @@ static int __init sa11xx_uda1341_init(void) | |||
921 | sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL); | 919 | sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL); |
922 | if (sa11xx_uda1341 == NULL) | 920 | if (sa11xx_uda1341 == NULL) |
923 | return -ENOMEM; | 921 | return -ENOMEM; |
922 | card->private_free = snd_sa11xx_uda1341_free; | ||
923 | chip = card->private_data; | ||
924 | spin_lock_init(&chip->s[0].dma_lock); | 924 | spin_lock_init(&chip->s[0].dma_lock); |
925 | spin_lock_init(&chip->s[1].dma_lock); | 925 | spin_lock_init(&chip->s[1].dma_lock); |
926 | 926 | ||
927 | card->private_data = (void *)sa11xx_uda1341; | 927 | chip->card = card; |
928 | card->private_free = snd_sa11xx_uda1341_free; | 928 | chip->samplerate = AUDIO_RATE_DEFAULT; |
929 | |||
930 | sa11xx_uda1341->card = card; | ||
931 | sa11xx_uda1341->samplerate = AUDIO_RATE_DEFAULT; | ||
932 | 929 | ||
933 | // mixer | 930 | // mixer |
934 | if ((err = snd_chip_uda1341_mixer_new(sa11xx_uda1341->card, &sa11xx_uda1341->uda1341))) | 931 | if ((err = snd_chip_uda1341_mixer_new(chip->card, &sa11xx_uda1341->uda1341))) |
935 | goto nodev; | 932 | goto nodev; |
936 | 933 | ||
937 | // PCM | 934 | // PCM |
938 | if ((err = snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341, 0)) < 0) | 935 | if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0) |
939 | goto nodev; | 936 | goto nodev; |
940 | 937 | ||
941 | snd_card_set_generic_pm_callback(card, | 938 | snd_card_set_generic_pm_callback(card, |
942 | snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, | 939 | snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, |
943 | sa11xx_uda1341); | 940 | chip); |
944 | 941 | ||
945 | strcpy(card->driver, "UDA1341"); | 942 | strcpy(card->driver, "UDA1341"); |
946 | strcpy(card->shortname, "H3600 UDA1341TS"); | 943 | strcpy(card->shortname, "H3600 UDA1341TS"); |
@@ -951,6 +948,7 @@ static int __init sa11xx_uda1341_init(void) | |||
951 | 948 | ||
952 | if ((err = snd_card_register(card)) == 0) { | 949 | if ((err = snd_card_register(card)) == 0) { |
953 | printk( KERN_INFO "iPAQ audio support initialized\n" ); | 950 | printk( KERN_INFO "iPAQ audio support initialized\n" ); |
951 | sa11xx_uda1341_card = card; | ||
954 | return 0; | 952 | return 0; |
955 | } | 953 | } |
956 | 954 | ||
@@ -961,7 +959,7 @@ static int __init sa11xx_uda1341_init(void) | |||
961 | 959 | ||
962 | static void __exit sa11xx_uda1341_exit(void) | 960 | static void __exit sa11xx_uda1341_exit(void) |
963 | { | 961 | { |
964 | snd_card_free(sa11xx_uda1341->card); | 962 | snd_card_free(sa11xx_uda1341_card); |
965 | } | 963 | } |
966 | 964 | ||
967 | module_init(sa11xx_uda1341_init); | 965 | module_init(sa11xx_uda1341_init); |
diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c index 103a7dcd0dde..bc7eb23e615f 100644 --- a/sound/i2c/l3/uda1341.c +++ b/sound/i2c/l3/uda1341.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * 2002-05-12 Tomas Kasparek another code cleanup | 17 | * 2002-05-12 Tomas Kasparek another code cleanup |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* $Id: uda1341.c,v 1.16 2005/09/09 13:22:34 tiwai Exp $ */ | 20 | /* $Id: uda1341.c,v 1.17 2005/11/17 10:25:22 tiwai Exp $ */ |
21 | 21 | ||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -56,6 +56,33 @@ | |||
56 | 56 | ||
57 | /* }}} */ | 57 | /* }}} */ |
58 | 58 | ||
59 | |||
60 | static const char *peak_names[] = { | ||
61 | "before", | ||
62 | "after", | ||
63 | }; | ||
64 | |||
65 | static const char *filter_names[] = { | ||
66 | "flat", | ||
67 | "min", | ||
68 | "min", | ||
69 | "max", | ||
70 | }; | ||
71 | |||
72 | static const char *mixer_names[] = { | ||
73 | "double differential", | ||
74 | "input channel 1 (line in)", | ||
75 | "input channel 2 (microphone)", | ||
76 | "digital mixer", | ||
77 | }; | ||
78 | |||
79 | static const char *deemp_names[] = { | ||
80 | "none", | ||
81 | "32 kHz", | ||
82 | "44.1 kHz", | ||
83 | "48 kHz", | ||
84 | }; | ||
85 | |||
59 | enum uda1341_regs_names { | 86 | enum uda1341_regs_names { |
60 | stat0, | 87 | stat0, |
61 | stat1, | 88 | stat1, |
@@ -73,7 +100,7 @@ enum uda1341_regs_names { | |||
73 | uda1341_reg_last, | 100 | uda1341_reg_last, |
74 | }; | 101 | }; |
75 | 102 | ||
76 | const char *uda1341_reg_names[] = { | 103 | static const char *uda1341_reg_names[] = { |
77 | "stat 0 ", | 104 | "stat 0 ", |
78 | "stat 1 ", | 105 | "stat 1 ", |
79 | "data 00", | 106 | "data 00", |
@@ -89,7 +116,7 @@ const char *uda1341_reg_names[] = { | |||
89 | "ext 6", | 116 | "ext 6", |
90 | }; | 117 | }; |
91 | 118 | ||
92 | const int uda1341_enum_items[] = { | 119 | static const int uda1341_enum_items[] = { |
93 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 120 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
94 | 2, //peak - before/after | 121 | 2, //peak - before/after |
95 | 4, //deemp - none/32/44.1/48 | 122 | 4, //deemp - none/32/44.1/48 |
@@ -100,7 +127,7 @@ const int uda1341_enum_items[] = { | |||
100 | 0, 0, 0, 0, 0, | 127 | 0, 0, 0, 0, 0, |
101 | }; | 128 | }; |
102 | 129 | ||
103 | const char ** uda1341_enum_names[] = { | 130 | static const char ** uda1341_enum_names[] = { |
104 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 131 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
105 | peak_names, //peak - before/after | 132 | peak_names, //peak - before/after |
106 | deemp_names, //deemp - none/32/44.1/48 | 133 | deemp_names, //deemp - none/32/44.1/48 |
@@ -129,11 +156,9 @@ struct uda1341 { | |||
129 | #endif | 156 | #endif |
130 | }; | 157 | }; |
131 | 158 | ||
132 | //hack for ALSA magic casting | ||
133 | typedef struct l3_client l3_client_t; | ||
134 | |||
135 | /* transfer 8bit integer into string with binary representation */ | 159 | /* transfer 8bit integer into string with binary representation */ |
136 | void int2str_bin8(uint8_t val, char *buf){ | 160 | static void int2str_bin8(uint8_t val, char *buf) |
161 | { | ||
137 | const int size = sizeof(val) * 8; | 162 | const int size = sizeof(val) * 8; |
138 | int i; | 163 | int i; |
139 | 164 | ||
@@ -146,7 +171,7 @@ void int2str_bin8(uint8_t val, char *buf){ | |||
146 | 171 | ||
147 | /* {{{ HW manipulation routines */ | 172 | /* {{{ HW manipulation routines */ |
148 | 173 | ||
149 | int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned short val) | 174 | static int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned short val) |
150 | { | 175 | { |
151 | struct uda1341 *uda = clnt->driver_data; | 176 | struct uda1341 *uda = clnt->driver_data; |
152 | unsigned char buf[2] = { 0xc0, 0xe0 }; // for EXT addressing | 177 | unsigned char buf[2] = { 0xc0, 0xe0 }; // for EXT addressing |
@@ -171,7 +196,7 @@ int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned | |||
171 | return err; | 196 | return err; |
172 | } | 197 | } |
173 | 198 | ||
174 | int snd_uda1341_codec_read(struct l3_client *clnt, unsigned short reg) | 199 | static int snd_uda1341_codec_read(struct l3_client *clnt, unsigned short reg) |
175 | { | 200 | { |
176 | unsigned char val; | 201 | unsigned char val; |
177 | int err; | 202 | int err; |
@@ -188,8 +213,9 @@ static inline int snd_uda1341_valid_reg(struct l3_client *clnt, unsigned short r | |||
188 | return reg < uda1341_reg_last; | 213 | return reg < uda1341_reg_last; |
189 | } | 214 | } |
190 | 215 | ||
191 | int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, unsigned short mask, | 216 | static int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, |
192 | unsigned short shift, unsigned short value, int flush) | 217 | unsigned short mask, unsigned short shift, |
218 | unsigned short value, int flush) | ||
193 | { | 219 | { |
194 | int change; | 220 | int change; |
195 | unsigned short old, new; | 221 | unsigned short old, new; |
@@ -214,8 +240,8 @@ int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, unsigned | |||
214 | return change; | 240 | return change; |
215 | } | 241 | } |
216 | 242 | ||
217 | int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, | 243 | static int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, |
218 | unsigned short value, int flush) | 244 | unsigned short value, int flush) |
219 | { | 245 | { |
220 | struct uda1341 *uda = clnt->driver_data; | 246 | struct uda1341 *uda = clnt->driver_data; |
221 | int ret = 0; | 247 | int ret = 0; |
@@ -327,6 +353,81 @@ int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, | |||
327 | /* }}} */ | 353 | /* }}} */ |
328 | 354 | ||
329 | /* {{{ Proc interface */ | 355 | /* {{{ Proc interface */ |
356 | #ifdef CONFIG_PROC_FS | ||
357 | |||
358 | static const char *format_names[] = { | ||
359 | "I2S-bus", | ||
360 | "LSB 16bits", | ||
361 | "LSB 18bits", | ||
362 | "LSB 20bits", | ||
363 | "MSB", | ||
364 | "in LSB 16bits/out MSB", | ||
365 | "in LSB 18bits/out MSB", | ||
366 | "in LSB 20bits/out MSB", | ||
367 | }; | ||
368 | |||
369 | static const char *fs_names[] = { | ||
370 | "512*fs", | ||
371 | "384*fs", | ||
372 | "256*fs", | ||
373 | "Unused - bad value!", | ||
374 | }; | ||
375 | |||
376 | static const char* bass_values[][16] = { | ||
377 | {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", | ||
378 | "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat | ||
379 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | ||
380 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | ||
381 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | ||
382 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | ||
383 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB", | ||
384 | "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max | ||
385 | }; | ||
386 | |||
387 | static const char *mic_sens_value[] = { | ||
388 | "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used", | ||
389 | }; | ||
390 | |||
391 | static const unsigned short AGC_atime[] = { | ||
392 | 11, 16, 11, 16, 21, 11, 16, 21, | ||
393 | }; | ||
394 | |||
395 | static const unsigned short AGC_dtime[] = { | ||
396 | 100, 100, 200, 200, 200, 400, 400, 400, | ||
397 | }; | ||
398 | |||
399 | static const char *AGC_level[] = { | ||
400 | "-9.0", "-11.5", "-15.0", "-17.5", | ||
401 | }; | ||
402 | |||
403 | static const char *ig_small_value[] = { | ||
404 | "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", | ||
405 | }; | ||
406 | |||
407 | /* | ||
408 | * this was computed as peak_value[i] = pow((63-i)*1.42,1.013) | ||
409 | * | ||
410 | * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2 | ||
411 | * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29 | ||
412 | * [61]=-2.78, [62] = -1.48, [63] = 0.0 | ||
413 | * I tried to compute it, but using but even using logarithm with base either 10 or 2 | ||
414 | * i was'n able to get values in the table from the formula. So I constructed another | ||
415 | * formula (see above) to interpolate the values as good as possible. If there is some | ||
416 | * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks. | ||
417 | * UDA1341TS datasheet is available at: | ||
418 | * http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf | ||
419 | */ | ||
420 | static const char *peak_value[] = { | ||
421 | "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB", | ||
422 | "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB", | ||
423 | "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB", | ||
424 | "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB", | ||
425 | "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB", | ||
426 | "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB", | ||
427 | "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB", | ||
428 | "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB", | ||
429 | "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", | ||
430 | }; | ||
330 | 431 | ||
331 | static void snd_uda1341_proc_read(snd_info_entry_t *entry, | 432 | static void snd_uda1341_proc_read(snd_info_entry_t *entry, |
332 | snd_info_buffer_t * buffer) | 433 | snd_info_buffer_t * buffer) |
@@ -401,7 +502,6 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, | |||
401 | int reg; | 502 | int reg; |
402 | char buf[12]; | 503 | char buf[12]; |
403 | 504 | ||
404 | spin_lock(&uda->reg_lock); | ||
405 | for (reg = 0; reg < uda1341_reg_last; reg ++) { | 505 | for (reg = 0; reg < uda1341_reg_last; reg ++) { |
406 | if (reg == empty) | 506 | if (reg == empty) |
407 | continue; | 507 | continue; |
@@ -411,9 +511,8 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, | |||
411 | 511 | ||
412 | int2str_bin8(snd_uda1341_codec_read(clnt, UDA1341_DATA1), buf); | 512 | int2str_bin8(snd_uda1341_codec_read(clnt, UDA1341_DATA1), buf); |
413 | snd_iprintf(buffer, "DATA1 = %s\n", buf); | 513 | snd_iprintf(buffer, "DATA1 = %s\n", buf); |
414 | |||
415 | spin_unlock(&uda->reg_lock); | ||
416 | } | 514 | } |
515 | #endif /* CONFIG_PROC_FS */ | ||
417 | 516 | ||
418 | static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client *clnt) | 517 | static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client *clnt) |
419 | { | 518 | { |
@@ -647,10 +746,10 @@ static snd_kcontrol_new_t snd_uda1341_controls[] = { | |||
647 | UDA1341_2REGS("Gain Input Amplifier Gain (channel 2)", CMD_IG, ext4, ext5, 0, 0, 3, 31, 0), | 746 | UDA1341_2REGS("Gain Input Amplifier Gain (channel 2)", CMD_IG, ext4, ext5, 0, 0, 3, 31, 0), |
648 | }; | 747 | }; |
649 | 748 | ||
650 | static void uda1341_free(struct l3_client *uda1341) | 749 | static void uda1341_free(struct l3_client *clnt) |
651 | { | 750 | { |
652 | l3_detach_client(uda1341); // calls kfree for driver_data (uda1341_t) | 751 | l3_detach_client(clnt); // calls kfree for driver_data (uda1341_t) |
653 | kfree(uda1341); | 752 | kfree(clnt); |
654 | } | 753 | } |
655 | 754 | ||
656 | static int uda1341_dev_free(snd_device_t *device) | 755 | static int uda1341_dev_free(snd_device_t *device) |
@@ -660,41 +759,42 @@ static int uda1341_dev_free(snd_device_t *device) | |||
660 | return 0; | 759 | return 0; |
661 | } | 760 | } |
662 | 761 | ||
663 | int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt) | 762 | int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp) |
664 | { | 763 | { |
665 | static snd_device_ops_t ops = { | 764 | static snd_device_ops_t ops = { |
666 | .dev_free = uda1341_dev_free, | 765 | .dev_free = uda1341_dev_free, |
667 | }; | 766 | }; |
668 | struct l3_client *uda1341; | 767 | struct l3_client *clnt; |
669 | int idx, err; | 768 | int idx, err; |
670 | 769 | ||
671 | snd_assert(card != NULL, return -EINVAL); | 770 | snd_assert(card != NULL, return -EINVAL); |
672 | 771 | ||
673 | uda1341 = kzalloc(sizeof(*uda1341), GFP_KERNEL); | 772 | clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); |
674 | if (uda1341 == NULL) | 773 | if (clnt == NULL) |
675 | return -ENOMEM; | 774 | return -ENOMEM; |
676 | 775 | ||
677 | if ((err = l3_attach_client(uda1341, "l3-bit-sa1100-gpio", "snd-uda1341"))) { | 776 | if ((err = l3_attach_client(clnt, "l3-bit-sa1100-gpio", UDA1341_ALSA_NAME))) { |
678 | kfree(uda1341); | 777 | kfree(clnt); |
679 | return err; | ||
680 | } | ||
681 | |||
682 | if ((err = snd_device_new(card, SNDRV_DEV_CODEC, uda1341, &ops)) < 0) { | ||
683 | l3_detach_client(uda1341); | ||
684 | kfree(uda1341); | ||
685 | return err; | 778 | return err; |
686 | } | 779 | } |
687 | 780 | ||
688 | for (idx = 0; idx < ARRAY_SIZE(snd_uda1341_controls); idx++) { | 781 | for (idx = 0; idx < ARRAY_SIZE(snd_uda1341_controls); idx++) { |
689 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_uda1341_controls[idx], uda1341))) < 0) | 782 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_uda1341_controls[idx], clnt))) < 0) { |
783 | uda1341_free(clnt); | ||
690 | return err; | 784 | return err; |
785 | } | ||
786 | } | ||
787 | |||
788 | if ((err = snd_device_new(card, SNDRV_DEV_CODEC, clnt, &ops)) < 0) { | ||
789 | uda1341_free(clnt); | ||
790 | return err; | ||
691 | } | 791 | } |
692 | 792 | ||
693 | *clnt = uda1341; | 793 | *clntp = clnt; |
694 | strcpy(card->mixername, "UDA1341TS Mixer"); | 794 | strcpy(card->mixername, "UDA1341TS Mixer"); |
695 | ((uda1341_t *)uda1341->driver_data)->card = card; | 795 | ((uda1341_t *)uda1341->driver_data)->card = card; |
696 | 796 | ||
697 | snd_uda1341_proc_init(card, uda1341); | 797 | snd_uda1341_proc_init(card, clnt); |
698 | 798 | ||
699 | return 0; | 799 | return 0; |
700 | } | 800 | } |