aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-08-03 08:21:00 -0400
committerTakashi Iwai <tiwai@suse.de>2010-08-03 08:21:00 -0400
commit92f10b3f5d53f9e35da5285eb8ea4bc88082b71e (patch)
tree26d90b68bb30f44921c54371d2cf248b9e4b247d /sound/pci/hda/hda_codec.c
parent1b0e372d7b52c9fc96348779015a6db7df7f286e (diff)
ALSA: hda - Define AC_FMT_* constants
Define constants for the HD-audio stream format bits, and replace the magic numbers in codes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index bd8d7a63d7fe..05e8995f9aec 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3013,26 +3013,31 @@ struct hda_rate_tbl {
3013 unsigned int hda_fmt; 3013 unsigned int hda_fmt;
3014}; 3014};
3015 3015
3016/* rate = base * mult / div */
3017#define HDA_RATE(base, mult, div) \
3018 (AC_FMT_BASE_##base##K | (((mult) - 1) << AC_FMT_MULT_SHIFT) | \
3019 (((div) - 1) << AC_FMT_DIV_SHIFT))
3020
3016static struct hda_rate_tbl rate_bits[] = { 3021static struct hda_rate_tbl rate_bits[] = {
3017 /* rate in Hz, ALSA rate bitmask, HDA format value */ 3022 /* rate in Hz, ALSA rate bitmask, HDA format value */
3018 3023
3019 /* autodetected value used in snd_hda_query_supported_pcm */ 3024 /* autodetected value used in snd_hda_query_supported_pcm */
3020 { 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */ 3025 { 8000, SNDRV_PCM_RATE_8000, HDA_RATE(48, 1, 6) },
3021 { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */ 3026 { 11025, SNDRV_PCM_RATE_11025, HDA_RATE(44, 1, 4) },
3022 { 16000, SNDRV_PCM_RATE_16000, 0x0200 }, /* 1/3 x 48 */ 3027 { 16000, SNDRV_PCM_RATE_16000, HDA_RATE(48, 1, 3) },
3023 { 22050, SNDRV_PCM_RATE_22050, 0x4100 }, /* 1/2 x 44 */ 3028 { 22050, SNDRV_PCM_RATE_22050, HDA_RATE(44, 1, 2) },
3024 { 32000, SNDRV_PCM_RATE_32000, 0x0a00 }, /* 2/3 x 48 */ 3029 { 32000, SNDRV_PCM_RATE_32000, HDA_RATE(48, 2, 3) },
3025 { 44100, SNDRV_PCM_RATE_44100, 0x4000 }, /* 44 */ 3030 { 44100, SNDRV_PCM_RATE_44100, HDA_RATE(44, 1, 1) },
3026 { 48000, SNDRV_PCM_RATE_48000, 0x0000 }, /* 48 */ 3031 { 48000, SNDRV_PCM_RATE_48000, HDA_RATE(48, 1, 1) },
3027 { 88200, SNDRV_PCM_RATE_88200, 0x4800 }, /* 2 x 44 */ 3032 { 88200, SNDRV_PCM_RATE_88200, HDA_RATE(44, 2, 1) },
3028 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ 3033 { 96000, SNDRV_PCM_RATE_96000, HDA_RATE(48, 2, 1) },
3029 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 3034 { 176400, SNDRV_PCM_RATE_176400, HDA_RATE(44, 4, 1) },
3030 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 3035 { 192000, SNDRV_PCM_RATE_192000, HDA_RATE(48, 4, 1) },
3031#define AC_PAR_PCM_RATE_BITS 11 3036#define AC_PAR_PCM_RATE_BITS 11
3032 /* up to bits 10, 384kHZ isn't supported properly */ 3037 /* up to bits 10, 384kHZ isn't supported properly */
3033 3038
3034 /* not autodetected value */ 3039 /* not autodetected value */
3035 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */ 3040 { 9600, SNDRV_PCM_RATE_KNOT, HDA_RATE(48, 1, 5) },
3036 3041
3037 { 0 } /* terminator */ 3042 { 0 } /* terminator */
3038}; 3043};
@@ -3075,20 +3080,20 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
3075 3080
3076 switch (snd_pcm_format_width(format)) { 3081 switch (snd_pcm_format_width(format)) {
3077 case 8: 3082 case 8:
3078 val |= 0x00; 3083 val |= AC_FMT_BITS_8;
3079 break; 3084 break;
3080 case 16: 3085 case 16:
3081 val |= 0x10; 3086 val |= AC_FMT_BITS_16;
3082 break; 3087 break;
3083 case 20: 3088 case 20:
3084 case 24: 3089 case 24:
3085 case 32: 3090 case 32:
3086 if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE) 3091 if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE)
3087 val |= 0x40; 3092 val |= AC_FMT_BITS_32;
3088 else if (maxbps >= 24) 3093 else if (maxbps >= 24)
3089 val |= 0x30; 3094 val |= AC_FMT_BITS_24;
3090 else 3095 else
3091 val |= 0x20; 3096 val |= AC_FMT_BITS_20;
3092 break; 3097 break;
3093 default: 3098 default:
3094 snd_printdd("invalid format width %d\n", 3099 snd_printdd("invalid format width %d\n",
@@ -3097,7 +3102,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
3097 } 3102 }
3098 3103
3099 if (spdif_ctls & AC_DIG1_NONAUDIO) 3104 if (spdif_ctls & AC_DIG1_NONAUDIO)
3100 val |= 0x8000; 3105 val |= AC_FMT_TYPE_NON_PCM;
3101 3106
3102 return val; 3107 return val;
3103} 3108}