]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
backlight: lp855x: add support for backlight curve
authorDaniel Solomon <daniels@nvidia.com>
Wed, 20 May 2015 21:30:00 +0000 (14:30 -0700)
committerMitch Luban <mluban@nvidia.com>
Mon, 8 Jun 2015 18:47:30 +0000 (11:47 -0700)
By default, backlight updates are linear with respect
to brightness. In some cases it's desirable to use
specific transfer functions instead of a simpler linear
response.
This change adds bl_curve to the LP855x platform data,
a LUT used to implement backlight transfer functions.
LUT data is parsed from DT.

Bug 1647733

Change-Id: I0448de936149b32ade29c1a183a8ead925b617c1
Signed-off-by: Daniel Solomon <daniels@nvidia.com>
Reviewed-on: http://git-master/r/745147
(cherry picked from commit 0ddd6e1e68c30940b6d9c495eced21af3e753382)
Reviewed-on: http://git-master/r/751051
Reviewed-by: Mitch Luban <mluban@nvidia.com>
arch/arm/mach-tegra/board-panel.c
drivers/video/backlight/lp855x_bl.c
include/linux/platform_data/lp855x.h

index f9f98345b0f99d1ba6619affc5b02d8cdd2ad7bb..e9d2a2d6c9fc92322a460854ffc4e0e9f024a644 100644 (file)
@@ -116,6 +116,8 @@ static int tegra_bl_notify(struct device *dev, int brightness)
        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"));
@@ -128,10 +130,6 @@ static int tegra_bl_notify(struct device *dev, int brightness)
                        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");
@@ -152,10 +150,22 @@ static int tegra_bl_notify(struct device *dev, int brightness)
                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;
 }
 
index 5c5ae2e8be6d9a20922b25eed55d2d71ad862961..012709cc5bab25f96cebf455a5d3d82358a5ecd9 100644 (file)
@@ -323,6 +323,7 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node)
        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;
@@ -378,6 +379,21 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node)
                        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;
index 2deb27453d36f2ca25dc4aa7e0e77144d9da4255..769a14b08d27bc2f2a4b1879927e5d2da06bfb70 100644 (file)
@@ -117,6 +117,8 @@ struct lp855x_rom_data {
                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;
@@ -126,6 +128,7 @@ struct lp855x_platform_data {
        int size_program;
        struct lp855x_rom_data *rom_data;
        u8 *bl_measured;
+       u8 *bl_curve;
 };
 
 enum lp855x_brightness_ctrl_mode {