···978 *979 * Returns 0 if successful, or a negative error code.980 */981-int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,982- struct hda_codec **codecp)0983{984 struct hda_codec *codec;985 char component[31];···1187 */11881189/* FIXME: more better hash key? */1190-#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))1191#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))1192#define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24))1193#define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24))···1357 if (!codec->no_trigger_sense) {1358 pincap = snd_hda_query_pin_caps(codec, nid);1359 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */1360- snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);01361 }1362 return snd_hda_codec_read(codec, nid, 0,1363 AC_VERB_GET_PIN_SENSE, 0);···1374 */1375int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)1376{1377- u32 sense = snd_hda_pin_sense(codec, nid);1378- return !!(sense & AC_PINSENSE_PRESENCE);1379}1380EXPORT_SYMBOL_HDA(snd_hda_jack_detect);1381···1954 err = snd_hda_ctl_add(codec, 0, kctl);1955 if (err < 0)1956 return err;1957-1958 for (s = slaves; *s; s++) {1959 struct snd_kcontrol *sctl;1960 int i = 0;···2441 {2442 .access = SNDRV_CTL_ELEM_ACCESS_READ,2443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2444- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),2445 .info = snd_hda_spdif_mask_info,2446 .get = snd_hda_spdif_cmask_get,2447 },2448 {2449 .access = SNDRV_CTL_ELEM_ACCESS_READ,2450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2451- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),2452 .info = snd_hda_spdif_mask_info,2453 .get = snd_hda_spdif_pmask_get,2454 },2455 {2456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2457- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),2458 .info = snd_hda_spdif_mask_info,2459 .get = snd_hda_spdif_default_get,2460 .put = snd_hda_spdif_default_put,2461 },2462 {2463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2464- .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),2465 .info = snd_hda_spdif_out_switch_info,2466 .get = snd_hda_spdif_out_switch_get,2467 .put = snd_hda_spdif_out_switch_put,···2612static struct snd_kcontrol_new dig_in_ctls[] = {2613 {2614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2615- .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),2616 .info = snd_hda_spdif_in_switch_info,2617 .get = snd_hda_spdif_in_switch_get,2618 .put = snd_hda_spdif_in_switch_put,···2620 {2621 .access = SNDRV_CTL_ELEM_ACCESS_READ,2622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2623- .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),2624 .info = snd_hda_spdif_mask_info,2625 .get = snd_hda_spdif_in_status_get,2626 },···2885 int err = snd_hda_codec_build_controls(codec);2886 if (err < 0) {2887 printk(KERN_ERR "hda_codec: cannot build controls"2888- "for #%d (error %d)\n", codec->addr, err); 2889 err = snd_hda_codec_reset(codec);2890 if (err < 0) {2891 printk(KERN_ERR···2981 val |= channels - 1;29822983 switch (snd_pcm_format_width(format)) {2984- case 8: val |= 0x00; break;2985- case 16: val |= 0x10; break;00002986 case 20:2987 case 24:2988 case 32:···3304 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))3305 return audio_idx[type][i];33063307- snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]);03308 return -EAGAIN;3309}3310···3343 err = codec->patch_ops.build_pcms(codec);3344 if (err < 0) {3345 printk(KERN_ERR "hda_codec: cannot build PCMs"3346- "for #%d (error %d)\n", codec->addr, err); 3347 err = snd_hda_codec_reset(codec);3348 if (err < 0) {3349 printk(KERN_ERR···34733474/**3475 * snd_hda_check_board_codec_sid_config - compare the current codec3476- subsystem ID with the3477- config table34783479 This is important for Gateway notebooks with SB450 HDA Audio3480 where the vendor ID of the PCI device is:···3614 *3615 * Increment the power-up counter and power up the hardware really when3616 * not turned on yet.3617- */ 3618void snd_hda_power_up(struct hda_codec *codec)3619{3620 struct hda_bus *bus = codec->bus;···3643 *3644 * Decrement the power-up counter and schedules the power-off work if3645 * the counter rearches to zero.3646- */ 3647void snd_hda_power_down(struct hda_codec *codec)3648{3649 --codec->power_count;···3669 *3670 * This function is supposed to be set or called from the check_power_status3671 * patch ops.3672- */ 3673int snd_hda_check_amp_list_power(struct hda_codec *codec,3674 struct hda_loopback_check *check,3675 hda_nid_t nid)···3837{3838 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */3839 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))3840- set_dig_out_convert(codec, nid, 3841 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff,3842 -1);3843 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);···4096/*4097 * Sort an associated group of pins according to their sequence numbers.4098 */4099-static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,4100 int num_pins)4101{4102 int i, j;4103 short seq;4104 hda_nid_t nid;4105-4106 for (i = 0; i < num_pins; i++) {4107 for (j = i + 1; j < num_pins; j++) {4108 if (sequences[i] > sequences[j]) {···4130 * is detected, one of speaker of HP pins is assigned as the primary4131 * output, i.e. to line_out_pins[0]. So, line_outs is always positive4132 * if any analog output exists.4133- * 4134 * The analog input pins are assigned to input_pins array.4135 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,4136 * respectively.···4193 case AC_JACK_SPEAKER:4194 seq = get_defcfg_sequence(def_conf);4195 assoc = get_defcfg_association(def_conf);4196- if (! assoc)4197 continue;4198- if (! assoc_speaker)4199 assoc_speaker = assoc;4200 else if (assoc_speaker != assoc)4201 continue;···4293 cfg->speaker_outs);4294 sort_pins_by_sequence(cfg->hp_pins, sequences_hp,4295 cfg->hp_outs);4296-4297 /* if we have only one mic, make it AUTO_PIN_MIC */4298 if (!cfg->input_pins[AUTO_PIN_MIC] &&4299 cfg->input_pins[AUTO_PIN_FRONT_MIC]) {···4443/**4444 * snd_array_new - get a new element from the given array4445 * @array: the array object4446- * 4447 * Get a new element from the given array. If it exceeds the4448 * pre-allocated array size, re-allocate the array.4449 *
···978 *979 * Returns 0 if successful, or a negative error code.980 */981+int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,982+ unsigned int codec_addr,983+ struct hda_codec **codecp)984{985 struct hda_codec *codec;986 char component[31];···1186 */11871188/* FIXME: more better hash key? */1189+#define HDA_HASH_KEY(nid, dir, idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))1190#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))1191#define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24))1192#define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24))···1356 if (!codec->no_trigger_sense) {1357 pincap = snd_hda_query_pin_caps(codec, nid);1358 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */1359+ snd_hda_codec_read(codec, nid, 0,1360+ AC_VERB_SET_PIN_SENSE, 0);1361 }1362 return snd_hda_codec_read(codec, nid, 0,1363 AC_VERB_GET_PIN_SENSE, 0);···1372 */1373int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)1374{1375+ u32 sense = snd_hda_pin_sense(codec, nid);1376+ return !!(sense & AC_PINSENSE_PRESENCE);1377}1378EXPORT_SYMBOL_HDA(snd_hda_jack_detect);1379···1952 err = snd_hda_ctl_add(codec, 0, kctl);1953 if (err < 0)1954 return err;1955+1956 for (s = slaves; *s; s++) {1957 struct snd_kcontrol *sctl;1958 int i = 0;···2439 {2440 .access = SNDRV_CTL_ELEM_ACCESS_READ,2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2442+ .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK),2443 .info = snd_hda_spdif_mask_info,2444 .get = snd_hda_spdif_cmask_get,2445 },2446 {2447 .access = SNDRV_CTL_ELEM_ACCESS_READ,2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2449+ .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK),2450 .info = snd_hda_spdif_mask_info,2451 .get = snd_hda_spdif_pmask_get,2452 },2453 {2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2455+ .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),2456 .info = snd_hda_spdif_mask_info,2457 .get = snd_hda_spdif_default_get,2458 .put = snd_hda_spdif_default_put,2459 },2460 {2461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2462+ .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH),2463 .info = snd_hda_spdif_out_switch_info,2464 .get = snd_hda_spdif_out_switch_get,2465 .put = snd_hda_spdif_out_switch_put,···2610static struct snd_kcontrol_new dig_in_ctls[] = {2611 {2612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2613+ .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH),2614 .info = snd_hda_spdif_in_switch_info,2615 .get = snd_hda_spdif_in_switch_get,2616 .put = snd_hda_spdif_in_switch_put,···2618 {2619 .access = SNDRV_CTL_ELEM_ACCESS_READ,2620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2621+ .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),2622 .info = snd_hda_spdif_mask_info,2623 .get = snd_hda_spdif_in_status_get,2624 },···2883 int err = snd_hda_codec_build_controls(codec);2884 if (err < 0) {2885 printk(KERN_ERR "hda_codec: cannot build controls"2886+ "for #%d (error %d)\n", codec->addr, err);2887 err = snd_hda_codec_reset(codec);2888 if (err < 0) {2889 printk(KERN_ERR···2979 val |= channels - 1;29802981 switch (snd_pcm_format_width(format)) {2982+ case 8:2983+ val |= 0x00;2984+ break;2985+ case 16:2986+ val |= 0x10;2987+ break;2988 case 20:2989 case 24:2990 case 32:···3298 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))3299 return audio_idx[type][i];33003301+ snd_printk(KERN_WARNING "Too many %s devices\n",3302+ snd_hda_pcm_type_name[type]);3303 return -EAGAIN;3304}3305···3336 err = codec->patch_ops.build_pcms(codec);3337 if (err < 0) {3338 printk(KERN_ERR "hda_codec: cannot build PCMs"3339+ "for #%d (error %d)\n", codec->addr, err);3340 err = snd_hda_codec_reset(codec);3341 if (err < 0) {3342 printk(KERN_ERR···34663467/**3468 * snd_hda_check_board_codec_sid_config - compare the current codec3469+ subsystem ID with the3470+ config table34713472 This is important for Gateway notebooks with SB450 HDA Audio3473 where the vendor ID of the PCI device is:···3607 *3608 * Increment the power-up counter and power up the hardware really when3609 * not turned on yet.3610+ */3611void snd_hda_power_up(struct hda_codec *codec)3612{3613 struct hda_bus *bus = codec->bus;···3636 *3637 * Decrement the power-up counter and schedules the power-off work if3638 * the counter rearches to zero.3639+ */3640void snd_hda_power_down(struct hda_codec *codec)3641{3642 --codec->power_count;···3662 *3663 * This function is supposed to be set or called from the check_power_status3664 * patch ops.3665+ */3666int snd_hda_check_amp_list_power(struct hda_codec *codec,3667 struct hda_loopback_check *check,3668 hda_nid_t nid)···3830{3831 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */3832 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))3833+ set_dig_out_convert(codec, nid,3834 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff,3835 -1);3836 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);···4089/*4090 * Sort an associated group of pins according to their sequence numbers.4091 */4092+static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences,4093 int num_pins)4094{4095 int i, j;4096 short seq;4097 hda_nid_t nid;4098+4099 for (i = 0; i < num_pins; i++) {4100 for (j = i + 1; j < num_pins; j++) {4101 if (sequences[i] > sequences[j]) {···4123 * is detected, one of speaker of HP pins is assigned as the primary4124 * output, i.e. to line_out_pins[0]. So, line_outs is always positive4125 * if any analog output exists.4126+ *4127 * The analog input pins are assigned to input_pins array.4128 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,4129 * respectively.···4186 case AC_JACK_SPEAKER:4187 seq = get_defcfg_sequence(def_conf);4188 assoc = get_defcfg_association(def_conf);4189+ if (!assoc)4190 continue;4191+ if (!assoc_speaker)4192 assoc_speaker = assoc;4193 else if (assoc_speaker != assoc)4194 continue;···4286 cfg->speaker_outs);4287 sort_pins_by_sequence(cfg->hp_pins, sequences_hp,4288 cfg->hp_outs);4289+4290 /* if we have only one mic, make it AUTO_PIN_MIC */4291 if (!cfg->input_pins[AUTO_PIN_MIC] &&4292 cfg->input_pins[AUTO_PIN_FRONT_MIC]) {···4436/**4437 * snd_array_new - get a new element from the given array4438 * @array: the array object4439+ *4440 * Get a new element from the given array. If it exceeds the4441 * pre-allocated array size, re-allocate the array.4442 *