/** * snd_hda_jack_add_kctl - Add a kctl for the given pin * * This assigns a jack-detection kctl to the given pin. The kcontrol * will have the given name and index. */ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, const char *name, int idx) { struct hda_jack_tbl *jack; struct snd_kcontrol *kctl; int err, state; jack = snd_hda_jack_tbl_new(codec, nid); if (!jack) return 0; if (jack->kctl) return 0; /* already created */ kctl = snd_kctl_jack_new(name, idx, codec); if (!kctl) return -ENOMEM; err = snd_hda_ctl_add(codec, nid, kctl); if (err < 0) return err; jack->kctl = kctl; state = snd_hda_jack_detect(codec, nid); snd_kctl_jack_report(codec->bus->card, kctl, state); #ifdef CONFIG_SND_HDA_INPUT_JACK jack->type = get_input_jack_type(codec, nid); err = snd_jack_new(codec->bus->card, name, jack->type, &jack->jack); if (err < 0) return err; jack->jack->private_data = jack; jack->jack->private_free = hda_free_jack_priv; snd_jack_report(jack->jack, state ? jack->type : 0); #endif return 0; }
/** * snd_hda_jack_add_kctl - Add a kctl for the given pin * @codec: the HDA codec * @nid: pin NID to assign * @name: string name for the jack * @phantom_jack: flag to deal as a phantom jack * @type: jack type bits to be reported, 0 for guessing from pincfg * @keymap: optional jack / key mapping * * This assigns a jack-detection kctl to the given pin. The kcontrol * will have the given name and index. */ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, const char *name, bool phantom_jack, int type, const struct hda_jack_keymap *keymap) { struct hda_jack_tbl *jack; const struct hda_jack_keymap *map; int err, state, buttons; jack = snd_hda_jack_tbl_new(codec, nid); if (!jack) return 0; if (jack->jack) return 0; /* already created */ if (!type) type = get_input_jack_type(codec, nid); buttons = 0; if (keymap) { for (map = keymap; map->type; map++) buttons |= map->type; } err = snd_jack_new(codec->card, name, type | buttons, &jack->jack, true, phantom_jack); if (err < 0) return err; jack->phantom_jack = !!phantom_jack; jack->type = type; jack->button_state = 0; jack->jack->private_data = jack; jack->jack->private_free = hda_free_jack_priv; if (keymap) { for (map = keymap; map->type; map++) snd_jack_set_key(jack->jack, map->type, map->key); } state = snd_hda_jack_detect(codec, nid); snd_jack_report(jack->jack, state ? jack->type : 0); return 0; }
/** * snd_intelmad_jack- to setup jack settings of the card * * @intelmaddata: pointer to internal context * * This function is called send jack events */ static int snd_intelmad_jack(struct snd_intelmad *intelmaddata) { struct snd_jack *jack; int retval; pr_debug("snd_intelmad_jack called\n"); jack = &intelmaddata->jack[0].jack; snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_PHONE); retval = snd_jack_new(intelmaddata->card, "Intel(R) MID Audio Jack", SND_JACK_HEADPHONE | SND_JACK_HEADSET | SW_JACK_PHYSICAL_INSERT | SND_JACK_BTN_0 | SND_JACK_BTN_1, &jack); pr_debug("snd_intelmad_jack called\n"); if (retval < 0) return retval; snd_jack_report(jack, 0); jack->private_data = jack; intelmaddata->jack[0].jack = *jack; return retval; }