* [PATCH v2] extcon: arizona: Update manual headphone detection calculation
@ 2014-05-30 12:19 Charles Keepax
2014-06-02 0:35 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Charles Keepax @ 2014-05-30 12:19 UTC (permalink / raw)
To: cw00.choi; +Cc: myungjoo.ham, patches, linux-kernel
The higher levels of impedance have a higher minimum value than the
first level. As the same value was used for all levels, higher impedances
were reported with a very low level of accuracy. This patch applies the
approriate lower threshold for each level, whilst we are changing things
add a define for the maximum value at each level to improve readability.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Changes since v1:
- Added define for range maximum as per review comments
drivers/extcon/extcon-arizona.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index c634796..c2eed30 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -329,14 +329,17 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
}
static struct {
+ unsigned int threshold;
unsigned int factor_a;
unsigned int factor_b;
} arizona_hpdet_b_ranges[] = {
- { 5528, 362464 },
- { 11084, 6186851 },
- { 11065, 65460395 },
+ { 100, 5528, 362464 },
+ { 169, 11084, 6186851 },
+ { 169, 11065, 65460395 },
};
+#define ARIZONA_HPDET_B_RANGE_MAX 0x3fb
+
static struct {
int min;
int max;
@@ -391,7 +394,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
>> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 &&
- (val < 100 || val >= 0x3fb)) {
+ (val < arizona_hpdet_b_ranges[range].threshold ||
+ val >= ARIZONA_HPDET_B_RANGE_MAX)) {
range++;
dev_dbg(arizona->dev, "Moving to HPDET range %d\n",
range);
@@ -404,7 +408,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
}
/* If we go out of range report top of range */
- if (val < 100 || val >= 0x3fb) {
+ if (val < arizona_hpdet_b_ranges[range].threshold ||
+ val >= ARIZONA_HPDET_B_RANGE_MAX) {
dev_dbg(arizona->dev, "Measurement out of range\n");
return ARIZONA_HPDET_MAX;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] extcon: arizona: Update manual headphone detection calculation
2014-05-30 12:19 [PATCH v2] extcon: arizona: Update manual headphone detection calculation Charles Keepax
@ 2014-06-02 0:35 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2014-06-02 0:35 UTC (permalink / raw)
To: Charles Keepax; +Cc: myungjoo.ham, patches, linux-kernel
On 05/30/2014 09:19 PM, Charles Keepax wrote:
> The higher levels of impedance have a higher minimum value than the
> first level. As the same value was used for all levels, higher impedances
> were reported with a very low level of accuracy. This patch applies the
> approriate lower threshold for each level, whilst we are changing things
> add a define for the maximum value at each level to improve readability.
>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>
> Changes since v1:
> - Added define for range maximum as per review comments
>
> drivers/extcon/extcon-arizona.c | 15 ++++++++++-----
> 1 files changed, 10 insertions(+), 5 deletions(-)
Applied.
Thanks,
Chanwoo Choi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-02 0:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30 12:19 [PATCH v2] extcon: arizona: Update manual headphone detection calculation Charles Keepax
2014-06-02 0:35 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox