0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __SOUND_HDA_JACK_H
0009 #define __SOUND_HDA_JACK_H
0010
0011 #include <linux/err.h>
0012 #include <sound/jack.h>
0013
0014 struct auto_pin_cfg;
0015 struct hda_jack_tbl;
0016 struct hda_jack_callback;
0017
0018 typedef void (*hda_jack_callback_fn) (struct hda_codec *, struct hda_jack_callback *);
0019
0020 struct hda_jack_callback {
0021 hda_nid_t nid;
0022 int dev_id;
0023 hda_jack_callback_fn func;
0024 unsigned int private_data;
0025 unsigned int unsol_res;
0026 struct hda_jack_tbl *jack;
0027 struct hda_jack_callback *next;
0028 };
0029
0030 struct hda_jack_tbl {
0031 hda_nid_t nid;
0032 int dev_id;
0033 unsigned char tag;
0034 struct hda_jack_callback *callback;
0035
0036 unsigned int pin_sense;
0037 unsigned int jack_detect:1;
0038 unsigned int jack_dirty:1;
0039 unsigned int phantom_jack:1;
0040 unsigned int block_report:1;
0041 hda_nid_t gating_jack;
0042 hda_nid_t gated_jack;
0043 hda_nid_t key_report_jack;
0044 int type;
0045 int button_state;
0046 struct snd_jack *jack;
0047 };
0048
0049 struct hda_jack_keymap {
0050 enum snd_jack_types type;
0051 int key;
0052 };
0053
0054 struct hda_jack_tbl *
0055 snd_hda_jack_tbl_get_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id);
0056
0057
0058
0059
0060
0061
0062 static inline struct hda_jack_tbl *
0063 snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid)
0064 {
0065 return snd_hda_jack_tbl_get_mst(codec, nid, 0);
0066 }
0067
0068 struct hda_jack_tbl *
0069 snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec,
0070 unsigned char tag, int dev_id);
0071
0072 void snd_hda_jack_tbl_disconnect(struct hda_codec *codec);
0073 void snd_hda_jack_tbl_clear(struct hda_codec *codec);
0074
0075 void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
0076
0077 int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
0078 int dev_id);
0079
0080 struct hda_jack_callback *
0081 snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid,
0082 int dev_id, hda_jack_callback_fn func);
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 static inline struct hda_jack_callback *
0095 snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
0096 hda_jack_callback_fn cb)
0097 {
0098 return snd_hda_jack_detect_enable_callback_mst(codec, nid, 0, cb);
0099 }
0100
0101 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
0102 hda_nid_t gating_nid);
0103
0104 int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid,
0105 const struct hda_jack_keymap *keymap,
0106 hda_nid_t jack_nid);
0107
0108 void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid,
0109 int button_state);
0110
0111 u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id);
0112
0113
0114 enum {
0115 HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT, HDA_JACK_PHANTOM,
0116 };
0117
0118 int snd_hda_jack_detect_state_mst(struct hda_codec *codec, hda_nid_t nid,
0119 int dev_id);
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 static inline int
0130 snd_hda_jack_detect_state(struct hda_codec *codec, hda_nid_t nid)
0131 {
0132 return snd_hda_jack_detect_state_mst(codec, nid, 0);
0133 }
0134
0135
0136
0137
0138
0139
0140
0141 static inline bool
0142 snd_hda_jack_detect_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id)
0143 {
0144 return snd_hda_jack_detect_state_mst(codec, nid, dev_id) !=
0145 HDA_JACK_NOT_PRESENT;
0146 }
0147
0148
0149
0150
0151
0152
0153 static inline bool
0154 snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
0155 {
0156 return snd_hda_jack_detect_mst(codec, nid, 0);
0157 }
0158
0159 bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
0160
0161 int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid,
0162 int dev_id, const char *name, bool phantom_jack,
0163 int type, const struct hda_jack_keymap *keymap);
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 static inline int
0178 snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
0179 const char *name, bool phantom_jack,
0180 int type, const struct hda_jack_keymap *keymap)
0181 {
0182 return snd_hda_jack_add_kctl_mst(codec, nid, 0,
0183 name, phantom_jack, type, keymap);
0184 }
0185
0186 int snd_hda_jack_add_kctls(struct hda_codec *codec,
0187 const struct auto_pin_cfg *cfg);
0188
0189 void snd_hda_jack_report_sync(struct hda_codec *codec);
0190
0191 void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res);
0192
0193 void snd_hda_jack_poll_all(struct hda_codec *codec);
0194
0195 #endif