aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/ad1848
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2008-07-31 15:06:46 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-06 09:39:52 -0400
commit0c5e3e98220e743f8ac095249b09ca8c87bd655b (patch)
treef25e84d71152eee480a354e2e6d924568df516cd /sound/isa/ad1848
parentece11c9b6db5b96179df8eb9cdc54c78953a4c0f (diff)
ALSA: wss_lib: replace ad1848 mixer element macros with wss ones
Use the wss macros instead of ad1848 ones. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Reviewed-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/isa/ad1848')
-rw-r--r--sound/isa/ad1848/ad1848_lib.c123
1 files changed, 51 insertions, 72 deletions
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 5aa8f6dae75b..4f7aaf4e0989 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -1163,88 +1163,64 @@ static int snd_ad1848_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1163 return change; 1163 return change;
1164} 1164}
1165 1165
1166/*
1167 */
1168int snd_ad1848_add_ctl_elem(struct snd_wss *chip,
1169 const struct ad1848_mix_elem *c)
1170{
1171 static struct snd_kcontrol_new newctls[] = {
1172 [AD1848_MIX_SINGLE] = {
1173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1174 .info = snd_ad1848_info_single,
1175 .get = snd_ad1848_get_single,
1176 .put = snd_ad1848_put_single,
1177 },
1178 [AD1848_MIX_DOUBLE] = {
1179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1180 .info = snd_ad1848_info_double,
1181 .get = snd_ad1848_get_double,
1182 .put = snd_ad1848_put_double,
1183 },
1184 [AD1848_MIX_CAPTURE] = {
1185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1186 .info = snd_ad1848_info_mux,
1187 .get = snd_ad1848_get_mux,
1188 .put = snd_ad1848_put_mux,
1189 },
1190 };
1191 struct snd_kcontrol *ctl;
1192 int err;
1193
1194 ctl = snd_ctl_new1(&newctls[c->type], chip);
1195 if (! ctl)
1196 return -ENOMEM;
1197 strlcpy(ctl->id.name, c->name, sizeof(ctl->id.name));
1198 ctl->id.index = c->index;
1199 ctl->private_value = c->private_value;
1200 if (c->tlv) {
1201 ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
1202 ctl->tlv.p = c->tlv;
1203 }
1204 if ((err = snd_ctl_add(chip->card, ctl)) < 0)
1205 return err;
1206 return 0;
1207}
1208
1209EXPORT_SYMBOL(snd_ad1848_add_ctl_elem);
1210
1211static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); 1166static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
1212static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); 1167static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
1213static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); 1168static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
1214 1169
1215#define AD1848_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ 1170#define AD1848_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
1216{ .name = xname, \ 1171{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1172 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
1173 .name = xname, \
1217 .index = xindex, \ 1174 .index = xindex, \
1218 .type = AD1848_MIX_SINGLE, \ 1175 .info = snd_ad1848_info_single, \
1219 .private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert), \ 1176 .get = snd_ad1848_get_single, \
1220 .tlv = xtlv } 1177 .put = snd_ad1848_put_single, \
1178 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \
1179 .tlv = { .p = (xtlv) } }
1221 1180
1222#define AD1848_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \ 1181#define AD1848_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \
1223{ .name = xname, \ 1182{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1183 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
1184 .name = xname, \
1224 .index = xindex, \ 1185 .index = xindex, \
1225 .type = AD1848_MIX_DOUBLE, \ 1186 .info = snd_ad1848_info_double, \
1226 .private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert), \ 1187 .get = snd_ad1848_get_double, \
1227 .tlv = xtlv } 1188 .put = snd_ad1848_put_double, \
1228 1189 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \
1229static struct ad1848_mix_elem snd_ad1848_controls[] = { 1190 (shift_right << 19) | (mask << 24) | (invert << 22), \
1230AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1), 1191 .tlv = { .p = (xtlv) } }
1231AD1848_DOUBLE_TLV("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1, 1192
1232 db_scale_6bit), 1193static struct snd_kcontrol_new snd_ad1848_controls[] = {
1233AD1848_DOUBLE("Aux Playback Switch", 0, AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 7, 7, 1, 1), 1194WSS_DOUBLE("PCM Playback Switch", 0,
1234AD1848_DOUBLE_TLV("Aux Playback Volume", 0, AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 0, 0, 31, 1, 1195 AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1),
1235 db_scale_5bit_12db_max), 1196AD1848_DOUBLE_TLV("PCM Playback Volume", 0,
1236AD1848_DOUBLE("Aux Playback Switch", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 7, 7, 1, 1), 1197 AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1,
1237AD1848_DOUBLE_TLV("Aux Playback Volume", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 0, 0, 31, 1, 1198 db_scale_6bit),
1238 db_scale_5bit_12db_max), 1199WSS_DOUBLE("Aux Playback Switch", 0,
1239AD1848_DOUBLE_TLV("Capture Volume", 0, AD1848_LEFT_INPUT, AD1848_RIGHT_INPUT, 0, 0, 15, 0, 1200 AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
1240 db_scale_rec_gain), 1201AD1848_DOUBLE_TLV("Aux Playback Volume", 0,
1202 AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 0, 0, 31, 1,
1203 db_scale_5bit_12db_max),
1204WSS_DOUBLE("Aux Playback Switch", 1,
1205 AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
1206AD1848_DOUBLE_TLV("Aux Playback Volume", 1,
1207 AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 0, 0, 31, 1,
1208 db_scale_5bit_12db_max),
1209AD1848_DOUBLE_TLV("Capture Volume", 0,
1210 AD1848_LEFT_INPUT, AD1848_RIGHT_INPUT, 0, 0, 15, 0,
1211 db_scale_rec_gain),
1241{ 1212{
1242 .name = "Capture Source", 1213 .name = "Capture Source",
1243 .type = AD1848_MIX_CAPTURE, 1214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1215 .info = snd_ad1848_info_mux,
1216 .get = snd_ad1848_get_mux,
1217 .put = snd_ad1848_put_mux,
1244}, 1218},
1245AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK, 0, 1, 0), 1219WSS_SINGLE("Loopback Capture Switch", 0,
1246AD1848_SINGLE_TLV("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0, 1220 AD1848_LOOPBACK, 0, 1, 0),
1247 db_scale_6bit), 1221AD1848_SINGLE_TLV("Loopback Capture Volume", 0,
1222 AD1848_LOOPBACK, 1, 63, 0,
1223 db_scale_6bit),
1248}; 1224};
1249 1225
1250int snd_ad1848_mixer(struct snd_wss *chip) 1226int snd_ad1848_mixer(struct snd_wss *chip)
@@ -1261,9 +1237,12 @@ int snd_ad1848_mixer(struct snd_wss *chip)
1261 1237
1262 strcpy(card->mixername, pcm->name); 1238 strcpy(card->mixername, pcm->name);
1263 1239
1264 for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) 1240 for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) {
1265 if ((err = snd_ad1848_add_ctl_elem(chip, &snd_ad1848_controls[idx])) < 0) 1241 err = snd_ctl_add(card,
1242 snd_ctl_new1(&snd_ad1848_controls[idx], chip));
1243 if (err < 0)
1266 return err; 1244 return err;
1245 }
1267 1246
1268 return 0; 1247 return 0;
1269} 1248}