[ALSA] hda-codec - Code clean up
[deliverable/linux.git] / sound / pci / hda / hda_codec.c
index 6bfb081d12ddf179d3476d547abe8e8f30de1de6..20f7762f714444a8ed5e516977cb0ac4bd4487bd 100644 (file)
@@ -1163,10 +1163,17 @@ int snd_hda_build_controls(struct hda_bus *bus)
 /*
  * stream formats
  */
-static unsigned int rate_bits[][3] = {
+struct hda_rate_tbl {
+       unsigned int hz;
+       unsigned int alsa_bits;
+       unsigned int hda_fmt;
+};
+
+static struct hda_rate_tbl rate_bits[] = {
        /* rate in Hz, ALSA rate bitmask, HDA format value */
+
+       /* autodetected value used in snd_hda_query_supported_pcm */
        { 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */
-       { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
        { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */
        { 16000, SNDRV_PCM_RATE_16000, 0x0200 }, /* 1/3 x 48 */
        { 22050, SNDRV_PCM_RATE_22050, 0x4100 }, /* 1/2 x 44 */
@@ -1177,7 +1184,11 @@ static unsigned int rate_bits[][3] = {
        { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
        { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
        { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
-       { 0 }
+
+       /* not autodetected value */
+       { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
+
+       { 0 } /* terminator */
 };
 
 /**
@@ -1199,12 +1210,12 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
        int i;
        unsigned int val = 0;
 
-       for (i = 0; rate_bits[i][0]; i++)
-               if (rate_bits[i][0] == rate) {
-                       val = rate_bits[i][2];
+       for (i = 0; rate_bits[i].hz; i++)
+               if (rate_bits[i].hz == rate) {
+                       val = rate_bits[i].hda_fmt;
                        break;
                }
-       if (! rate_bits[i][0]) {
+       if (! rate_bits[i].hz) {
                snd_printdd("invalid rate %d\n", rate);
                return 0;
        }
@@ -1267,9 +1278,9 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
 
        if (ratesp) {
                u32 rates = 0;
-               for (i = 0; rate_bits[i][0]; i++) {
+               for (i = 0; rate_bits[i].hz; i++) {
                        if (val & (1 << i))
-                               rates |= rate_bits[i][1];
+                               rates |= rate_bits[i].alsa_bits;
                }
                *ratesp = rates;
        }
@@ -1361,13 +1372,13 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
        }
 
        rate = format & 0xff00;
-       for (i = 0; rate_bits[i][0]; i++)
-               if (rate_bits[i][2] == rate) {
+       for (i = 0; rate_bits[i].hz; i++)
+               if (rate_bits[i].hda_fmt == rate) {
                        if (val & (1 << i))
                                break;
                        return 0;
                }
-       if (! rate_bits[i][0])
+       if (! rate_bits[i].hz)
                return 0;
 
        stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
This page took 0.026073 seconds and 5 git commands to generate.