struct lp855x *lp = NULL;
struct platform_device *pdev = NULL;
struct device *dc_dev;
+ u8 *bl_measured = NULL;
+ u8 *bl_curve = NULL;
pdev = to_platform_device(bus_find_device_by_name(
&platform_bus_type, NULL, "tegradc.0"));
nvsd_enbl_dsbl_prism(dc_dev, true);
}
- cur_sd_brightness = atomic_read(&sd_brightness);
- /* SD brightness is a percentage */
- brightness = (brightness * cur_sd_brightness) / 255;
-
/* Apply any backlight response curve */
if (brightness > 255)
pr_info("Error: Brightness > 255!\n");
of_device_is_compatible(dev->of_node,
"ti,lp8557")) {
lp = (struct lp855x *)dev_get_drvdata(dev);
- if (lp->pdata->bl_measured)
- brightness = lp->pdata->bl_measured[brightness];
+ if (lp && lp->pdata) {
+ bl_measured = lp->pdata->bl_measured;
+ bl_curve = lp->pdata->bl_curve;
+ }
}
+ if (bl_curve)
+ brightness = bl_curve[brightness];
+
+ cur_sd_brightness = atomic_read(&sd_brightness);
+ /* SD brightness is a percentage */
+ brightness = (brightness * cur_sd_brightness) / 255;
+
+ if (bl_measured)
+ brightness = bl_measured[brightness];
+
return brightness;
}
struct lp855x_platform_data *pdata;
int rom_length;
int n_bl_measured = 0;
+ int n_bl_curve = 0;
const __be32 *p;
u32 u;
struct property *prop;
pdata->bl_measured[n_bl_measured++] = u;
}
+ of_property_for_each_u32(node, "bl-curve", prop, p, u)
+ n_bl_curve++;
+ if (n_bl_curve > 0) {
+ pdata->bl_curve = devm_kzalloc(dev,
+ sizeof(*pdata->bl_curve) * n_bl_curve, GFP_KERNEL);
+ if (!pdata->bl_curve) {
+ pr_err("bl_curve memory allocation failed\n");
+ ret = -ENOMEM;
+ }
+ n_bl_curve = 0;
+ of_property_for_each_u32(node,
+ "bl-curve", prop, p, u)
+ pdata->bl_curve[n_bl_curve++] = u;
+ }
+
dev->platform_data = pdata;
return 0;
Only valid when mode is PWM_BASED.
* @size_program : total size of lp855x_rom_data
* @rom_data : list of new eeprom/eprom registers
+ * @bl_measured : pwm vs. brightness response linearization LUT
+ * @bl_curve : backlight transfer function
*/
struct lp855x_platform_data {
const char *name;
int size_program;
struct lp855x_rom_data *rom_data;
u8 *bl_measured;
+ u8 *bl_curve;
};
enum lp855x_brightness_ctrl_mode {