aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-28 08:08:30 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-17 12:32:14 -0400
commit325c642380fb9a8c628696ed8d64544d73b653ed (patch)
tree322c370a3e6d08528637ee1c1f2bae12703087a0
parenteed5d2150752bd08b22333d739f3120151773d28 (diff)
extcon: arizona: Update cable reporting calls and split headset
Use extcon_set_state_ for performance and split the headset into separate headphone and microphone reports as this is more idiomatic. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/extcon/extcon-arizona.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index b068bc9defe1..0626754d6e04 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -54,22 +54,17 @@ static const struct arizona_micd_config micd_default_modes[] = {
54 { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 }, 54 { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
55}; 55};
56 56
57#define ARIZONA_CABLE_MECHANICAL "Mechanical" 57#define ARIZONA_CABLE_MECHANICAL 0
58#define ARIZONA_CABLE_HEADPHONE "Headphone" 58#define ARIZONA_CABLE_MICROPHONE 1
59#define ARIZONA_CABLE_HEADSET "Headset" 59#define ARIZONA_CABLE_HEADPHONE 2
60 60
61static const char *arizona_cable[] = { 61static const char *arizona_cable[] = {
62 ARIZONA_CABLE_MECHANICAL, 62 "Mechanical",
63 ARIZONA_CABLE_HEADSET, 63 "Microphone",
64 ARIZONA_CABLE_HEADPHONE, 64 "Headphone",
65 NULL, 65 NULL,
66}; 66};
67 67
68static const u32 arizona_exclusions[] = {
69 0x6, /* Headphone and headset */
70 0,
71};
72
73static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) 68static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
74{ 69{
75 struct arizona *arizona = info->arizona; 70 struct arizona *arizona = info->arizona;
@@ -174,8 +169,11 @@ static irqreturn_t arizona_micdet(int irq, void *data)
174 169
175 /* If we got a high impedence we should have a headset, report it. */ 170 /* If we got a high impedence we should have a headset, report it. */
176 if (info->detecting && (val & 0x400)) { 171 if (info->detecting && (val & 0x400)) {
177 ret = extcon_set_cable_state(&info->edev, 172 ret = extcon_update_state(&info->edev,
178 ARIZONA_CABLE_HEADSET, true); 173 1 << ARIZONA_CABLE_MICROPHONE |
174 1 << ARIZONA_CABLE_HEADPHONE,
175 1 << ARIZONA_CABLE_MICROPHONE |
176 1 << ARIZONA_CABLE_HEADPHONE);
179 177
180 if (ret != 0) 178 if (ret != 0)
181 dev_err(arizona->dev, "Headset report failed: %d\n", 179 dev_err(arizona->dev, "Headset report failed: %d\n",
@@ -198,9 +196,9 @@ static irqreturn_t arizona_micdet(int irq, void *data)
198 if (info->jack_flips >= info->micd_num_modes) { 196 if (info->jack_flips >= info->micd_num_modes) {
199 dev_dbg(arizona->dev, "Detected headphone\n"); 197 dev_dbg(arizona->dev, "Detected headphone\n");
200 info->detecting = false; 198 info->detecting = false;
201 ret = extcon_set_cable_state(&info->edev, 199 ret = extcon_set_cable_state_(&info->edev,
202 ARIZONA_CABLE_HEADPHONE, 200 ARIZONA_CABLE_HEADPHONE,
203 true); 201 true);
204 if (ret != 0) 202 if (ret != 0)
205 dev_err(arizona->dev, 203 dev_err(arizona->dev,
206 "Headphone report failed: %d\n", 204 "Headphone report failed: %d\n",
@@ -231,9 +229,9 @@ static irqreturn_t arizona_micdet(int irq, void *data)
231 info->detecting = false; 229 info->detecting = false;
232 arizona_stop_mic(info); 230 arizona_stop_mic(info);
233 231
234 ret = extcon_set_cable_state(&info->edev, 232 ret = extcon_set_cable_state_(&info->edev,
235 ARIZONA_CABLE_HEADPHONE, 233 ARIZONA_CABLE_HEADPHONE,
236 true); 234 true);
237 if (ret != 0) 235 if (ret != 0)
238 dev_err(arizona->dev, 236 dev_err(arizona->dev,
239 "Headphone report failed: %d\n", 237 "Headphone report failed: %d\n",
@@ -275,8 +273,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
275 273
276 if (val & ARIZONA_JD1_STS) { 274 if (val & ARIZONA_JD1_STS) {
277 dev_dbg(arizona->dev, "Detected jack\n"); 275 dev_dbg(arizona->dev, "Detected jack\n");
278 ret = extcon_set_cable_state(&info->edev, 276 ret = extcon_set_cable_state_(&info->edev,
279 ARIZONA_CABLE_MECHANICAL, true); 277 ARIZONA_CABLE_MECHANICAL, true);
280 278
281 if (ret != 0) 279 if (ret != 0)
282 dev_err(arizona->dev, "Mechanical report failed: %d\n", 280 dev_err(arizona->dev, "Mechanical report failed: %d\n",
@@ -347,7 +345,6 @@ static int __devinit arizona_extcon_probe(struct platform_device *pdev)
347 345
348 info->edev.name = "Headset Jack"; 346 info->edev.name = "Headset Jack";
349 info->edev.supported_cable = arizona_cable; 347 info->edev.supported_cable = arizona_cable;
350 info->edev.mutually_exclusive = arizona_exclusions;
351 348
352 ret = extcon_dev_register(&info->edev, arizona->dev); 349 ret = extcon_dev_register(&info->edev, arizona->dev);
353 if (ret < 0) { 350 if (ret < 0) {