forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/pci/hda/hda_jack.h
....@@ -1,18 +1,15 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Jack-detection handling for HD-audio
34 *
45 * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
5
- *
6
- * This driver is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #ifndef __SOUND_HDA_JACK_H
139 #define __SOUND_HDA_JACK_H
1410
1511 #include <linux/err.h>
12
+#include <sound/jack.h>
1613
1714 struct auto_pin_cfg;
1815 struct hda_jack_tbl;
....@@ -22,13 +19,17 @@
2219
2320 struct hda_jack_callback {
2421 hda_nid_t nid;
22
+ int dev_id;
2523 hda_jack_callback_fn func;
2624 unsigned int private_data; /* arbitrary data */
25
+ unsigned int unsol_res; /* unsolicited event bits */
26
+ struct hda_jack_tbl *jack; /* associated jack entry */
2727 struct hda_jack_callback *next;
2828 };
2929
3030 struct hda_jack_tbl {
3131 hda_nid_t nid;
32
+ int dev_id;
3233 unsigned char tag; /* unsol event tag */
3334 struct hda_jack_callback *callback;
3435 /* jack-detection stuff */
....@@ -40,49 +41,139 @@
4041 hda_nid_t gating_jack; /* valid when gating jack plugged */
4142 hda_nid_t gated_jack; /* gated is dependent on this jack */
4243 int type;
44
+ int button_state;
4345 struct snd_jack *jack;
4446 };
4547
48
+struct hda_jack_keymap {
49
+ enum snd_jack_types type;
50
+ int key;
51
+};
52
+
4653 struct hda_jack_tbl *
47
-snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
54
+snd_hda_jack_tbl_get_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id);
55
+
56
+/**
57
+ * snd_hda_jack_tbl_get - query the jack-table entry for the given NID
58
+ * @codec: the HDA codec
59
+ * @nid: pin NID to refer to
60
+ */
61
+static inline struct hda_jack_tbl *
62
+snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid)
63
+{
64
+ return snd_hda_jack_tbl_get_mst(codec, nid, 0);
65
+}
66
+
4867 struct hda_jack_tbl *
49
-snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag);
68
+snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec,
69
+ unsigned char tag, int dev_id);
5070
5171 void snd_hda_jack_tbl_clear(struct hda_codec *codec);
5272
5373 void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
5474
55
-int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid);
75
+int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
76
+ int dev_id);
77
+
5678 struct hda_jack_callback *
79
+snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid,
80
+ int dev_id, hda_jack_callback_fn func);
81
+
82
+/**
83
+ * snd_hda_jack_detect_enable - enable the jack-detection
84
+ * @codec: the HDA codec
85
+ * @nid: pin NID to enable
86
+ * @func: callback function to register
87
+ *
88
+ * In the case of error, the return value will be a pointer embedded with
89
+ * errno. Check and handle the return value appropriately with standard
90
+ * macros such as @IS_ERR() and @PTR_ERR().
91
+ */
92
+static inline struct hda_jack_callback *
5793 snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
58
- hda_jack_callback_fn cb);
94
+ hda_jack_callback_fn cb)
95
+{
96
+ return snd_hda_jack_detect_enable_callback_mst(codec, nid, 0, cb);
97
+}
5998
6099 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
61100 hda_nid_t gating_nid);
62101
63
-u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
102
+u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id);
64103
65104 /* the jack state returned from snd_hda_jack_detect_state() */
66105 enum {
67106 HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT, HDA_JACK_PHANTOM,
68107 };
69108
70
-int snd_hda_jack_detect_state(struct hda_codec *codec, hda_nid_t nid);
109
+int snd_hda_jack_detect_state_mst(struct hda_codec *codec, hda_nid_t nid,
110
+ int dev_id);
111
+
112
+/**
113
+ * snd_hda_jack_detect_state - query pin Presence Detect status
114
+ * @codec: the CODEC to sense
115
+ * @nid: the pin NID to sense
116
+ *
117
+ * Query and return the pin's Presence Detect status, as either
118
+ * HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT or HDA_JACK_PHANTOM.
119
+ */
120
+static inline int
121
+snd_hda_jack_detect_state(struct hda_codec *codec, hda_nid_t nid)
122
+{
123
+ return snd_hda_jack_detect_state_mst(codec, nid, 0);
124
+}
125
+
126
+/**
127
+ * snd_hda_jack_detect_mst - Detect the jack
128
+ * @codec: the HDA codec
129
+ * @nid: pin NID to check jack detection
130
+ * @dev_id: pin device entry id
131
+ */
132
+static inline bool
133
+snd_hda_jack_detect_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id)
134
+{
135
+ return snd_hda_jack_detect_state_mst(codec, nid, dev_id) !=
136
+ HDA_JACK_NOT_PRESENT;
137
+}
71138
72139 /**
73140 * snd_hda_jack_detect - Detect the jack
74141 * @codec: the HDA codec
75142 * @nid: pin NID to check jack detection
76143 */
77
-static inline bool snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
144
+static inline bool
145
+snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
78146 {
79
- return snd_hda_jack_detect_state(codec, nid) != HDA_JACK_NOT_PRESENT;
147
+ return snd_hda_jack_detect_mst(codec, nid, 0);
80148 }
81149
82150 bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
83151
84
-int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
85
- const char *name, bool phantom_jack);
152
+int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid,
153
+ int dev_id, const char *name, bool phantom_jack,
154
+ int type, const struct hda_jack_keymap *keymap);
155
+
156
+/**
157
+ * snd_hda_jack_add_kctl - Add a kctl for the given pin
158
+ * @codec: the HDA codec
159
+ * @nid: pin NID to assign
160
+ * @name: string name for the jack
161
+ * @phantom_jack: flag to deal as a phantom jack
162
+ * @type: jack type bits to be reported, 0 for guessing from pincfg
163
+ * @keymap: optional jack / key mapping
164
+ *
165
+ * This assigns a jack-detection kctl to the given pin. The kcontrol
166
+ * will have the given name and index.
167
+ */
168
+static inline int
169
+snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
170
+ const char *name, bool phantom_jack,
171
+ int type, const struct hda_jack_keymap *keymap)
172
+{
173
+ return snd_hda_jack_add_kctl_mst(codec, nid, 0,
174
+ name, phantom_jack, type, keymap);
175
+}
176
+
86177 int snd_hda_jack_add_kctls(struct hda_codec *codec,
87178 const struct auto_pin_cfg *cfg);
88179