From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
patches@opensource.wolfsonmicro.com,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 1/2] extcon: arizona: Update cable reporting calls and split headset
Date: Thu, 28 Jun 2012 13:08:30 +0100 [thread overview]
Message-ID: <1340885311-12368-1-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
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>
---
drivers/extcon/extcon-arizona.c | 41 ++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index b068bc9..0626754 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[] = {
{ 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
};
-#define ARIZONA_CABLE_MECHANICAL "Mechanical"
-#define ARIZONA_CABLE_HEADPHONE "Headphone"
-#define ARIZONA_CABLE_HEADSET "Headset"
+#define ARIZONA_CABLE_MECHANICAL 0
+#define ARIZONA_CABLE_MICROPHONE 1
+#define ARIZONA_CABLE_HEADPHONE 2
static const char *arizona_cable[] = {
- ARIZONA_CABLE_MECHANICAL,
- ARIZONA_CABLE_HEADSET,
- ARIZONA_CABLE_HEADPHONE,
+ "Mechanical",
+ "Microphone",
+ "Headphone",
NULL,
};
-static const u32 arizona_exclusions[] = {
- 0x6, /* Headphone and headset */
- 0,
-};
-
static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
{
struct arizona *arizona = info->arizona;
@@ -174,8 +169,11 @@ static irqreturn_t arizona_micdet(int irq, void *data)
/* If we got a high impedence we should have a headset, report it. */
if (info->detecting && (val & 0x400)) {
- ret = extcon_set_cable_state(&info->edev,
- ARIZONA_CABLE_HEADSET, true);
+ ret = extcon_update_state(&info->edev,
+ 1 << ARIZONA_CABLE_MICROPHONE |
+ 1 << ARIZONA_CABLE_HEADPHONE,
+ 1 << ARIZONA_CABLE_MICROPHONE |
+ 1 << ARIZONA_CABLE_HEADPHONE);
if (ret != 0)
dev_err(arizona->dev, "Headset report failed: %d\n",
@@ -198,9 +196,9 @@ static irqreturn_t arizona_micdet(int irq, void *data)
if (info->jack_flips >= info->micd_num_modes) {
dev_dbg(arizona->dev, "Detected headphone\n");
info->detecting = false;
- ret = extcon_set_cable_state(&info->edev,
- ARIZONA_CABLE_HEADPHONE,
- true);
+ ret = extcon_set_cable_state_(&info->edev,
+ ARIZONA_CABLE_HEADPHONE,
+ true);
if (ret != 0)
dev_err(arizona->dev,
"Headphone report failed: %d\n",
@@ -231,9 +229,9 @@ static irqreturn_t arizona_micdet(int irq, void *data)
info->detecting = false;
arizona_stop_mic(info);
- ret = extcon_set_cable_state(&info->edev,
- ARIZONA_CABLE_HEADPHONE,
- true);
+ ret = extcon_set_cable_state_(&info->edev,
+ ARIZONA_CABLE_HEADPHONE,
+ true);
if (ret != 0)
dev_err(arizona->dev,
"Headphone report failed: %d\n",
@@ -275,8 +273,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
if (val & ARIZONA_JD1_STS) {
dev_dbg(arizona->dev, "Detected jack\n");
- ret = extcon_set_cable_state(&info->edev,
- ARIZONA_CABLE_MECHANICAL, true);
+ ret = extcon_set_cable_state_(&info->edev,
+ ARIZONA_CABLE_MECHANICAL, true);
if (ret != 0)
dev_err(arizona->dev, "Mechanical report failed: %d\n",
@@ -347,7 +345,6 @@ static int __devinit arizona_extcon_probe(struct platform_device *pdev)
info->edev.name = "Headset Jack";
info->edev.supported_cable = arizona_cable;
- info->edev.mutually_exclusive = arizona_exclusions;
ret = extcon_dev_register(&info->edev, arizona->dev);
if (ret < 0) {
--
1.7.10
next reply other threads:[~2012-06-28 12:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 12:08 Mark Brown [this message]
2012-06-28 12:08 ` [PATCH 2/2] extcon: arizona: Stop microphone detection if we give up on it Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340885311-12368-1-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=cw00.choi@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®