diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-led.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-led.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 41addd1c7261..f547233c5b79 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c | |||
@@ -78,6 +78,29 @@ static const struct { | |||
78 | #define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */ | 78 | #define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */ |
79 | #define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1) | 79 | #define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1) |
80 | 80 | ||
81 | /* | ||
82 | * Adjust led blink rate to compensate on a MAC Clock difference on every HW | ||
83 | * Led blink rate analysis showed an average deviation of 0% on 3945, | ||
84 | * 5% on 4965 HW and 20% on 5000 series and up. | ||
85 | * Need to compensate on the led on/off time per HW according to the deviation | ||
86 | * to achieve the desired led frequency | ||
87 | * The calculation is: (100-averageDeviation)/100 * blinkTime | ||
88 | * For code efficiency the calculation will be: | ||
89 | * compensation = (100 - averageDeviation) * 64 / 100 | ||
90 | * NewBlinkTime = (compensation * BlinkTime) / 64 | ||
91 | */ | ||
92 | static inline u8 iwl_blink_compensation(struct iwl_priv *priv, | ||
93 | u8 time, u16 compensation) | ||
94 | { | ||
95 | if (!compensation) { | ||
96 | IWL_ERR(priv, "undefined blink compensation: " | ||
97 | "use pre-defined blinking time\n"); | ||
98 | return time; | ||
99 | } | ||
100 | |||
101 | return (u8)((time * compensation) >> 6); | ||
102 | } | ||
103 | |||
81 | /* [0-256] -> [0..8] FIXME: we need [0..10] */ | 104 | /* [0-256] -> [0..8] FIXME: we need [0..10] */ |
82 | static inline int iwl_brightness_to_idx(enum led_brightness brightness) | 105 | static inline int iwl_brightness_to_idx(enum led_brightness brightness) |
83 | { | 106 | { |
@@ -114,8 +137,14 @@ static int iwl_led_pattern(struct iwl_priv *priv, int led_id, | |||
114 | 137 | ||
115 | BUG_ON(idx > IWL_MAX_BLINK_TBL); | 138 | BUG_ON(idx > IWL_MAX_BLINK_TBL); |
116 | 139 | ||
117 | led_cmd.on = blink_tbl[idx].on_time; | 140 | IWL_DEBUG_LED(priv, "Led blink time compensation= %u\n", |
118 | led_cmd.off = blink_tbl[idx].off_time; | 141 | priv->cfg->led_compensation); |
142 | led_cmd.on = | ||
143 | iwl_blink_compensation(priv, blink_tbl[idx].on_time, | ||
144 | priv->cfg->led_compensation); | ||
145 | led_cmd.off = | ||
146 | iwl_blink_compensation(priv, blink_tbl[idx].off_time, | ||
147 | priv->cfg->led_compensation); | ||
119 | 148 | ||
120 | return iwl_send_led_cmd(priv, &led_cmd); | 149 | return iwl_send_led_cmd(priv, &led_cmd); |
121 | } | 150 | } |