Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sound/soc/codecs/rt700.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static int rt700_headset_detect(struct rt700_priv *rt700)
{
unsigned int buf, loop = 0;
int ret;
unsigned int jack_status = 0, reg;

ret = rt700_index_read(rt700->regmap,
RT700_COMBO_JACK_AUTO_CTL2, &buf);
Expand All @@ -130,6 +131,11 @@ static int rt700_headset_detect(struct rt700_priv *rt700)
RT700_COMBO_JACK_AUTO_CTL2, &buf);
if (ret < 0)
goto io_error;

reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT;
ret = regmap_read(rt700->regmap, reg, &jack_status);
if ((jack_status & (1 << 31)) == 0)
goto remove_error;
}

if (loop >= 500)
Expand All @@ -150,6 +156,9 @@ static int rt700_headset_detect(struct rt700_priv *rt700)
io_error:
pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret);
return ret;
remove_error:
pr_err_ratelimited("Jack removal in %s\n", __func__);
return -ENODEV;
}

static void rt700_jack_detect_handler(struct work_struct *work)
Expand Down
11 changes: 11 additions & 0 deletions sound/soc/codecs/rt711.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static int rt711_headset_detect(struct rt711_priv *rt711)
{
unsigned int buf, loop = 0;
int ret;
unsigned int jack_status = 0, reg;

ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
RT711_COMBO_JACK_AUTO_CTL2, &buf);
Expand All @@ -208,6 +209,13 @@ static int rt711_headset_detect(struct rt711_priv *rt711)
RT711_COMBO_JACK_AUTO_CTL2, &buf);
if (ret < 0)
goto io_error;

reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT;
ret = regmap_read(rt711->regmap, reg, &jack_status);
if (ret < 0)
goto io_error;
if ((jack_status & (1 << 31)) == 0)
goto remove_error;
}

if (loop >= 500)
Expand All @@ -228,6 +236,9 @@ static int rt711_headset_detect(struct rt711_priv *rt711)
io_error:
pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret);
return ret;
remove_error:
pr_err_ratelimited("Jack removal in %s\n", __func__);
return -ENODEV;
}

static void rt711_jack_detect_handler(struct work_struct *work)
Expand Down