diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2013-11-14 11:18:21 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2014-01-06 21:54:28 -0500 |
commit | ffae24fed8a83afd5682865e0262731eac369a5b (patch) | |
tree | b70c6c57694ca58050fba81241de7973b4dac469 /drivers/extcon | |
parent | b7d2d5be3c910fddd19cafa0861016712c665168 (diff) |
extcon: arizona: Add defines for microphone detection levels
Improve readability by creating a define for each microphone detection
level.
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index a287cece0593..5775f055bd02 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -44,6 +44,15 @@ | |||
44 | #define HPDET_DEBOUNCE 500 | 44 | #define HPDET_DEBOUNCE 500 |
45 | #define DEFAULT_MICD_TIMEOUT 2000 | 45 | #define DEFAULT_MICD_TIMEOUT 2000 |
46 | 46 | ||
47 | #define MICD_LVL_1_TO_7 (ARIZONA_MICD_LVL_1 | ARIZONA_MICD_LVL_2 | \ | ||
48 | ARIZONA_MICD_LVL_3 | ARIZONA_MICD_LVL_4 | \ | ||
49 | ARIZONA_MICD_LVL_5 | ARIZONA_MICD_LVL_6 | \ | ||
50 | ARIZONA_MICD_LVL_7) | ||
51 | |||
52 | #define MICD_LVL_0_TO_7 (ARIZONA_MICD_LVL_0 | MICD_LVL_1_TO_7) | ||
53 | |||
54 | #define MICD_LVL_0_TO_8 (MICD_LVL_0_TO_7 | ARIZONA_MICD_LVL_8) | ||
55 | |||
47 | struct arizona_extcon_info { | 56 | struct arizona_extcon_info { |
48 | struct device *dev; | 57 | struct device *dev; |
49 | struct arizona *arizona; | 58 | struct arizona *arizona; |
@@ -765,7 +774,7 @@ static void arizona_micd_detect(struct work_struct *work) | |||
765 | 774 | ||
766 | mutex_lock(&info->lock); | 775 | mutex_lock(&info->lock); |
767 | 776 | ||
768 | for (i = 0; i < 10 && !(val & 0x7fc); i++) { | 777 | for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) { |
769 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); | 778 | ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); |
770 | if (ret != 0) { | 779 | if (ret != 0) { |
771 | dev_err(arizona->dev, | 780 | dev_err(arizona->dev, |
@@ -784,7 +793,7 @@ static void arizona_micd_detect(struct work_struct *work) | |||
784 | } | 793 | } |
785 | } | 794 | } |
786 | 795 | ||
787 | if (i == 10 && !(val & 0x7fc)) { | 796 | if (i == 10 && !(val & MICD_LVL_0_TO_8)) { |
788 | dev_err(arizona->dev, "Failed to get valid MICDET value\n"); | 797 | dev_err(arizona->dev, "Failed to get valid MICDET value\n"); |
789 | mutex_unlock(&info->lock); | 798 | mutex_unlock(&info->lock); |
790 | return; | 799 | return; |
@@ -798,7 +807,7 @@ static void arizona_micd_detect(struct work_struct *work) | |||
798 | } | 807 | } |
799 | 808 | ||
800 | /* If we got a high impedence we should have a headset, report it. */ | 809 | /* If we got a high impedence we should have a headset, report it. */ |
801 | if (info->detecting && (val & 0x400)) { | 810 | if (info->detecting && (val & ARIZONA_MICD_LVL_8)) { |
802 | arizona_identify_headphone(info); | 811 | arizona_identify_headphone(info); |
803 | 812 | ||
804 | ret = extcon_update_state(&info->edev, | 813 | ret = extcon_update_state(&info->edev, |
@@ -827,7 +836,7 @@ static void arizona_micd_detect(struct work_struct *work) | |||
827 | * plain headphones. If both polarities report a low | 836 | * plain headphones. If both polarities report a low |
828 | * impedence then give up and report headphones. | 837 | * impedence then give up and report headphones. |
829 | */ | 838 | */ |
830 | if (info->detecting && (val & 0x3f8)) { | 839 | if (info->detecting && (val & MICD_LVL_1_TO_7)) { |
831 | if (info->jack_flips >= info->micd_num_modes * 10) { | 840 | if (info->jack_flips >= info->micd_num_modes * 10) { |
832 | dev_dbg(arizona->dev, "Detected HP/line\n"); | 841 | dev_dbg(arizona->dev, "Detected HP/line\n"); |
833 | arizona_identify_headphone(info); | 842 | arizona_identify_headphone(info); |
@@ -851,7 +860,7 @@ static void arizona_micd_detect(struct work_struct *work) | |||
851 | * If we're still detecting and we detect a short then we've | 860 | * If we're still detecting and we detect a short then we've |
852 | * got a headphone. Otherwise it's a button press. | 861 | * got a headphone. Otherwise it's a button press. |
853 | */ | 862 | */ |
854 | if (val & 0x3fc) { | 863 | if (val & MICD_LVL_0_TO_7) { |
855 | if (info->mic) { | 864 | if (info->mic) { |
856 | dev_dbg(arizona->dev, "Mic button detected\n"); | 865 | dev_dbg(arizona->dev, "Mic button detected\n"); |
857 | 866 | ||