aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-08-22 07:57:55 -0400
committerJaroslav Kysela <perex@suse.cz>2005-08-30 02:47:02 -0400
commitbefdf316eaba02ed52284fb78a8027ff35c6a736 (patch)
tree629325f6d110c4dc2799423b2cd679aabbfe1f6f
parent9d8f53f2bba3c2c06e1e78126222aecf91f8ecdd (diff)
[ALSA] hda-codec - Code clean up
HDA Codec driver Use struct instead of array to improve the readability of hda_codec.c. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_codec.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e067a14a2d9e..20f7762f7144 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1163,7 +1163,13 @@ int snd_hda_build_controls(struct hda_bus *bus)
1163/* 1163/*
1164 * stream formats 1164 * stream formats
1165 */ 1165 */
1166static unsigned int rate_bits[][3] = { 1166struct hda_rate_tbl {
1167 unsigned int hz;
1168 unsigned int alsa_bits;
1169 unsigned int hda_fmt;
1170};
1171
1172static struct hda_rate_tbl rate_bits[] = {
1167 /* rate in Hz, ALSA rate bitmask, HDA format value */ 1173 /* rate in Hz, ALSA rate bitmask, HDA format value */
1168 1174
1169 /* autodetected value used in snd_hda_query_supported_pcm */ 1175 /* autodetected value used in snd_hda_query_supported_pcm */
@@ -1181,7 +1187,8 @@ static unsigned int rate_bits[][3] = {
1181 1187
1182 /* not autodetected value */ 1188 /* not autodetected value */
1183 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */ 1189 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1184 { 0 } 1190
1191 { 0 } /* terminator */
1185}; 1192};
1186 1193
1187/** 1194/**
@@ -1203,12 +1210,12 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1203 int i; 1210 int i;
1204 unsigned int val = 0; 1211 unsigned int val = 0;
1205 1212
1206 for (i = 0; rate_bits[i][0]; i++) 1213 for (i = 0; rate_bits[i].hz; i++)
1207 if (rate_bits[i][0] == rate) { 1214 if (rate_bits[i].hz == rate) {
1208 val = rate_bits[i][2]; 1215 val = rate_bits[i].hda_fmt;
1209 break; 1216 break;
1210 } 1217 }
1211 if (! rate_bits[i][0]) { 1218 if (! rate_bits[i].hz) {
1212 snd_printdd("invalid rate %d\n", rate); 1219 snd_printdd("invalid rate %d\n", rate);
1213 return 0; 1220 return 0;
1214 } 1221 }
@@ -1271,9 +1278,9 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1271 1278
1272 if (ratesp) { 1279 if (ratesp) {
1273 u32 rates = 0; 1280 u32 rates = 0;
1274 for (i = 0; rate_bits[i][0]; i++) { 1281 for (i = 0; rate_bits[i].hz; i++) {
1275 if (val & (1 << i)) 1282 if (val & (1 << i))
1276 rates |= rate_bits[i][1]; 1283 rates |= rate_bits[i].alsa_bits;
1277 } 1284 }
1278 *ratesp = rates; 1285 *ratesp = rates;
1279 } 1286 }
@@ -1365,13 +1372,13 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1365 } 1372 }
1366 1373
1367 rate = format & 0xff00; 1374 rate = format & 0xff00;
1368 for (i = 0; rate_bits[i][0]; i++) 1375 for (i = 0; rate_bits[i].hz; i++)
1369 if (rate_bits[i][2] == rate) { 1376 if (rate_bits[i].hda_fmt == rate) {
1370 if (val & (1 << i)) 1377 if (val & (1 << i))
1371 break; 1378 break;
1372 return 0; 1379 return 0;
1373 } 1380 }
1374 if (! rate_bits[i][0]) 1381 if (! rate_bits[i].hz)
1375 return 0; 1382 return 0;
1376 1383
1377 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1384 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);