Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 325c6423 authored by Mark Brown's avatar Mark Brown Committed by Greg Kroah-Hartman
Browse files

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eed5d215
Loading
Loading
Loading
Loading
+19 −22
Original line number Original line Diff line number Diff line
@@ -54,22 +54,17 @@ static const struct arizona_micd_config micd_default_modes[] = {
	{ 0,                  2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
	{ 0,                  2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
};
};


#define ARIZONA_CABLE_MECHANICAL "Mechanical"
#define ARIZONA_CABLE_MECHANICAL 0
#define ARIZONA_CABLE_HEADPHONE  "Headphone"
#define ARIZONA_CABLE_MICROPHONE 1
#define ARIZONA_CABLE_HEADSET    "Headset"
#define ARIZONA_CABLE_HEADPHONE  2


static const char *arizona_cable[] = {
static const char *arizona_cable[] = {
	ARIZONA_CABLE_MECHANICAL,
	"Mechanical",
	ARIZONA_CABLE_HEADSET,
	"Microphone",
	ARIZONA_CABLE_HEADPHONE,
	"Headphone",
	NULL,
	NULL,
};
};


static const u32 arizona_exclusions[] = {
	0x6,   /* Headphone and headset */
	0,
};

static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
{
{
	struct arizona *arizona = info->arizona;
	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 we got a high impedence we should have a headset, report it. */
	if (info->detecting && (val & 0x400)) {
	if (info->detecting && (val & 0x400)) {
		ret = extcon_set_cable_state(&info->edev,
		ret = extcon_update_state(&info->edev,
					     ARIZONA_CABLE_HEADSET, true);
					  1 << ARIZONA_CABLE_MICROPHONE |
					  1 << ARIZONA_CABLE_HEADPHONE,
					  1 << ARIZONA_CABLE_MICROPHONE |
					  1 << ARIZONA_CABLE_HEADPHONE);


		if (ret != 0)
		if (ret != 0)
			dev_err(arizona->dev, "Headset report failed: %d\n",
			dev_err(arizona->dev, "Headset report failed: %d\n",
@@ -198,7 +196,7 @@ static irqreturn_t arizona_micdet(int irq, void *data)
		if (info->jack_flips >= info->micd_num_modes) {
		if (info->jack_flips >= info->micd_num_modes) {
			dev_dbg(arizona->dev, "Detected headphone\n");
			dev_dbg(arizona->dev, "Detected headphone\n");
			info->detecting = false;
			info->detecting = false;
			ret = extcon_set_cable_state(&info->edev,
			ret = extcon_set_cable_state_(&info->edev,
						      ARIZONA_CABLE_HEADPHONE,
						      ARIZONA_CABLE_HEADPHONE,
						      true);
						      true);
			if (ret != 0)
			if (ret != 0)
@@ -231,7 +229,7 @@ static irqreturn_t arizona_micdet(int irq, void *data)
			info->detecting = false;
			info->detecting = false;
			arizona_stop_mic(info);
			arizona_stop_mic(info);


			ret = extcon_set_cable_state(&info->edev,
			ret = extcon_set_cable_state_(&info->edev,
						      ARIZONA_CABLE_HEADPHONE,
						      ARIZONA_CABLE_HEADPHONE,
						      true);
						      true);
			if (ret != 0)
			if (ret != 0)
@@ -275,7 +273,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)


	if (val & ARIZONA_JD1_STS) {
	if (val & ARIZONA_JD1_STS) {
		dev_dbg(arizona->dev, "Detected jack\n");
		dev_dbg(arizona->dev, "Detected jack\n");
		ret = extcon_set_cable_state(&info->edev,
		ret = extcon_set_cable_state_(&info->edev,
					      ARIZONA_CABLE_MECHANICAL, true);
					      ARIZONA_CABLE_MECHANICAL, true);


		if (ret != 0)
		if (ret != 0)
@@ -347,7 +345,6 @@ static int __devinit arizona_extcon_probe(struct platform_device *pdev)


	info->edev.name = "Headset Jack";
	info->edev.name = "Headset Jack";
	info->edev.supported_cable = arizona_cable;
	info->edev.supported_cable = arizona_cable;
	info->edev.mutually_exclusive = arizona_exclusions;


	ret = extcon_dev_register(&info->edev, arizona->dev);
	ret = extcon_dev_register(&info->edev, arizona->dev);
	if (ret < 0) {
	if (ret < 0) {