root/drivers/video/backlight/generic_bl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. genericbl_send_intensity
  2. genericbl_get_intensity
  3. genericbl_probe
  4. genericbl_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  *  Generic Backlight Driver
   4  *
   5  *  Copyright (c) 2004-2008 Richard Purdie
   6  */
   7 
   8 #include <linux/module.h>
   9 #include <linux/kernel.h>
  10 #include <linux/init.h>
  11 #include <linux/platform_device.h>
  12 #include <linux/mutex.h>
  13 #include <linux/fb.h>
  14 #include <linux/backlight.h>
  15 
  16 static int genericbl_intensity;
  17 static struct backlight_device *generic_backlight_device;
  18 static struct generic_bl_info *bl_machinfo;
  19 
  20 static int genericbl_send_intensity(struct backlight_device *bd)
  21 {
  22         int intensity = bd->props.brightness;
  23 
  24         if (bd->props.power != FB_BLANK_UNBLANK)
  25                 intensity = 0;
  26         if (bd->props.state & BL_CORE_FBBLANK)
  27                 intensity = 0;
  28         if (bd->props.state & BL_CORE_SUSPENDED)
  29                 intensity = 0;
  30 
  31         bl_machinfo->set_bl_intensity(intensity);
  32 
  33         genericbl_intensity = intensity;
  34 
  35         if (bl_machinfo->kick_battery)
  36                 bl_machinfo->kick_battery();
  37 
  38         return 0;
  39 }
  40 
  41 static int genericbl_get_intensity(struct backlight_device *bd)
  42 {
  43         return genericbl_intensity;
  44 }
  45 
  46 static const struct backlight_ops genericbl_ops = {
  47         .options = BL_CORE_SUSPENDRESUME,
  48         .get_brightness = genericbl_get_intensity,
  49         .update_status  = genericbl_send_intensity,
  50 };
  51 
  52 static int genericbl_probe(struct platform_device *pdev)
  53 {
  54         struct backlight_properties props;
  55         struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev);
  56         const char *name = "generic-bl";
  57         struct backlight_device *bd;
  58 
  59         bl_machinfo = machinfo;
  60         if (!machinfo->limit_mask)
  61                 machinfo->limit_mask = -1;
  62 
  63         if (machinfo->name)
  64                 name = machinfo->name;
  65 
  66         memset(&props, 0, sizeof(struct backlight_properties));
  67         props.type = BACKLIGHT_RAW;
  68         props.max_brightness = machinfo->max_intensity;
  69         bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
  70                                         NULL, &genericbl_ops, &props);
  71         if (IS_ERR(bd))
  72                 return PTR_ERR(bd);
  73 
  74         platform_set_drvdata(pdev, bd);
  75 
  76         bd->props.power = FB_BLANK_UNBLANK;
  77         bd->props.brightness = machinfo->default_intensity;
  78         backlight_update_status(bd);
  79 
  80         generic_backlight_device = bd;
  81 
  82         dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n");
  83         return 0;
  84 }
  85 
  86 static int genericbl_remove(struct platform_device *pdev)
  87 {
  88         struct backlight_device *bd = platform_get_drvdata(pdev);
  89 
  90         bd->props.power = 0;
  91         bd->props.brightness = 0;
  92         backlight_update_status(bd);
  93 
  94         dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n");
  95         return 0;
  96 }
  97 
  98 static struct platform_driver genericbl_driver = {
  99         .probe          = genericbl_probe,
 100         .remove         = genericbl_remove,
 101         .driver         = {
 102                 .name   = "generic-bl",
 103         },
 104 };
 105 
 106 module_platform_driver(genericbl_driver);
 107 
 108 MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
 109 MODULE_DESCRIPTION("Generic Backlight Driver");
 110 MODULE_LICENSE("GPL");

/* [<][>][^][v][top][bottom][index][help] */