Commit bb7ca747 authored by Matthew Garrett's avatar Matthew Garrett Committed by Linus Torvalds

backlight: add backlight type

There may be multiple ways of controlling the backlight on a given
machine.  Allow drivers to expose the type of interface they are
providing, making it possible for userspace to make appropriate policy
decisions.
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ccd7510f
...@@ -34,3 +34,23 @@ Contact: Richard Purdie <rpurdie@rpsys.net> ...@@ -34,3 +34,23 @@ Contact: Richard Purdie <rpurdie@rpsys.net>
Description: Description:
Maximum brightness for <backlight>. Maximum brightness for <backlight>.
Users: HAL Users: HAL
What: /sys/class/backlight/<backlight>/type
Date: September 2010
KernelVersion: 2.6.37
Contact: Matthew Garrett <mjg@redhat.com>
Description:
The type of interface controlled by <backlight>.
"firmware": The driver uses a standard firmware interface
"platform": The driver uses a platform-specific interface
"raw": The driver controls hardware registers directly
In the general case, when multiple backlight
interfaces are available for a single device, firmware
control should be preferred to platform control should
be preferred to raw control. Using a firmware
interface reduces the probability of confusion with
the hardware and the OS independently updating the
backlight state. Platform interfaces are mostly a
holdover from pre-standardisation of firmware
interfaces.
...@@ -795,6 +795,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) ...@@ -795,6 +795,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
count++; count++;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_FIRMWARE;
props.max_brightness = device->brightness->count - 3; props.max_brightness = device->brightness->count - 3;
device->backlight = backlight_device_register(name, NULL, device, device->backlight = backlight_device_register(name, NULL, device,
&acpi_backlight_ops, &acpi_backlight_ops,
......
...@@ -98,6 +98,7 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev) ...@@ -98,6 +98,7 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev)
return 0; return 0;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 31; props.max_brightness = 31;
bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
&nv40_bl_ops, &props); &nv40_bl_ops, &props);
...@@ -121,6 +122,7 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev) ...@@ -121,6 +122,7 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev)
return 0; return 0;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 1025; props.max_brightness = 1025;
bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
&nv50_bl_ops, &props); &nv50_bl_ops, &props);
......
...@@ -944,6 +944,7 @@ static int picolcd_init_backlight(struct picolcd_data *data, struct hid_report * ...@@ -944,6 +944,7 @@ static int picolcd_init_backlight(struct picolcd_data *data, struct hid_report *
} }
memset(&props, 0, sizeof(props)); memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.max_brightness = 0xff; props.max_brightness = 0xff;
bdev = backlight_device_register(dev_name(dev), dev, data, bdev = backlight_device_register(dev_name(dev), dev, data,
&picolcd_blops, &props); &picolcd_blops, &props);
......
...@@ -163,6 +163,7 @@ void __init pmu_backlight_init() ...@@ -163,6 +163,7 @@ void __init pmu_backlight_init()
snprintf(name, sizeof(name), "pmubl"); snprintf(name, sizeof(name), "pmubl");
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data, bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data,
&props); &props);
......
...@@ -1031,6 +1031,7 @@ static int __devinit acer_backlight_init(struct device *dev) ...@@ -1031,6 +1031,7 @@ static int __devinit acer_backlight_init(struct device *dev)
struct backlight_device *bd; struct backlight_device *bd;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = max_brightness; props.max_brightness = max_brightness;
bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops, bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops,
&props); &props);
......
...@@ -667,6 +667,7 @@ static int asus_backlight_init(struct asus_laptop *asus) ...@@ -667,6 +667,7 @@ static int asus_backlight_init(struct asus_laptop *asus)
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = 15; props.max_brightness = 15;
props.type = BACKLIGHT_PLATFORM;
bd = backlight_device_register(ASUS_LAPTOP_FILE, bd = backlight_device_register(ASUS_LAPTOP_FILE,
&asus->platform_device->dev, asus, &asus->platform_device->dev, asus,
......
...@@ -1507,6 +1507,7 @@ static int __init asus_acpi_init(void) ...@@ -1507,6 +1507,7 @@ static int __init asus_acpi_init(void)
} }
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = 15; props.max_brightness = 15;
asus_backlight_device = backlight_device_register("asus", NULL, NULL, asus_backlight_device = backlight_device_register("asus", NULL, NULL,
&asus_backlight_data, &asus_backlight_data,
......
...@@ -564,6 +564,7 @@ static int cmpc_ipml_add(struct acpi_device *acpi) ...@@ -564,6 +564,7 @@ static int cmpc_ipml_add(struct acpi_device *acpi)
return -ENOMEM; return -ENOMEM;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = 7; props.max_brightness = 7;
ipml->bd = backlight_device_register("cmpc_bl", &acpi->dev, ipml->bd = backlight_device_register("cmpc_bl", &acpi->dev,
acpi->handle, &cmpc_bl_ops, acpi->handle, &cmpc_bl_ops,
......
...@@ -970,6 +970,7 @@ static int __init compal_init(void) ...@@ -970,6 +970,7 @@ static int __init compal_init(void)
if (!acpi_video_backlight_support()) { if (!acpi_video_backlight_support()) {
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = BACKLIGHT_LEVEL_MAX; props.max_brightness = BACKLIGHT_LEVEL_MAX;
compalbl_device = backlight_device_register(DRIVER_NAME, compalbl_device = backlight_device_register(DRIVER_NAME,
NULL, NULL, NULL, NULL,
......
...@@ -671,6 +671,7 @@ static int __init dell_init(void) ...@@ -671,6 +671,7 @@ static int __init dell_init(void)
if (max_intensity) { if (max_intensity) {
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = max_intensity; props.max_brightness = max_intensity;
dell_backlight_device = backlight_device_register("dell_backlight", dell_backlight_device = backlight_device_register("dell_backlight",
&platform_device->dev, &platform_device->dev,
......
...@@ -1147,6 +1147,7 @@ static int eeepc_backlight_init(struct eeepc_laptop *eeepc) ...@@ -1147,6 +1147,7 @@ static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
struct backlight_device *bd; struct backlight_device *bd;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = 15; props.max_brightness = 15;
bd = backlight_device_register(EEEPC_LAPTOP_FILE, bd = backlight_device_register(EEEPC_LAPTOP_FILE,
&eeepc->platform_device->dev, eeepc, &eeepc->platform_device->dev, eeepc,
......
...@@ -1128,6 +1128,7 @@ static int __init fujitsu_init(void) ...@@ -1128,6 +1128,7 @@ static int __init fujitsu_init(void)
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
max_brightness = fujitsu->max_brightness; max_brightness = fujitsu->max_brightness;
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = max_brightness - 1; props.max_brightness = max_brightness - 1;
fujitsu->bl_device = backlight_device_register("fujitsu-laptop", fujitsu->bl_device = backlight_device_register("fujitsu-laptop",
NULL, NULL, NULL, NULL,
......
...@@ -804,6 +804,7 @@ static int __init msi_init(void) ...@@ -804,6 +804,7 @@ static int __init msi_init(void)
} else { } else {
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = MSI_LCD_LEVEL_MAX - 1; props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
msibl_device = backlight_device_register("msi-laptop-bl", NULL, msibl_device = backlight_device_register("msi-laptop-bl", NULL,
NULL, &msibl_ops, NULL, &msibl_ops,
......
...@@ -254,6 +254,7 @@ static int __init msi_wmi_init(void) ...@@ -254,6 +254,7 @@ static int __init msi_wmi_init(void)
if (!acpi_video_backlight_support()) { if (!acpi_video_backlight_support()) {
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = ARRAY_SIZE(backlight_map) - 1; props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
backlight = backlight_device_register(DRV_NAME, NULL, NULL, backlight = backlight_device_register(DRV_NAME, NULL, NULL,
&msi_backlight_ops, &msi_backlight_ops,
......
...@@ -602,6 +602,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) ...@@ -602,6 +602,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
} }
/* initialize backlight */ /* initialize backlight */
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT]; props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
pcc->backlight = backlight_device_register("panasonic", NULL, pcc, pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
&pcc_backlight_ops, &props); &pcc_backlight_ops, &props);
......
...@@ -1305,8 +1305,9 @@ static int sony_nc_add(struct acpi_device *device) ...@@ -1305,8 +1305,9 @@ static int sony_nc_add(struct acpi_device *device)
"controlled by ACPI video driver\n"); "controlled by ACPI video driver\n");
} else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
&handle))) { &handle))) {
struct backlight_properties props; struct backlight_properties props;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = SONY_MAX_BRIGHTNESS - 1; props.max_brightness = SONY_MAX_BRIGHTNESS - 1;
sony_backlight_device = backlight_device_register("sony", NULL, sony_backlight_device = backlight_device_register("sony", NULL,
NULL, NULL,
......
...@@ -6307,6 +6307,7 @@ static int __init brightness_init(struct ibm_init_struct *iibm) ...@@ -6307,6 +6307,7 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
return 1; return 1;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = bright_maxlvl; props.max_brightness = bright_maxlvl;
props.brightness = b & TP_EC_BACKLIGHT_LVLMSK; props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
ibm_backlight_device = backlight_device_register(TPACPI_BACKLIGHT_DEV_NAME, ibm_backlight_device = backlight_device_register(TPACPI_BACKLIGHT_DEV_NAME,
......
...@@ -1018,6 +1018,7 @@ static int __init toshiba_acpi_init(void) ...@@ -1018,6 +1018,7 @@ static int __init toshiba_acpi_init(void)
create_toshiba_proc_entries(); create_toshiba_proc_entries();
} }
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
toshiba_backlight_device = backlight_device_register("toshiba", toshiba_backlight_device = backlight_device_register("toshiba",
&toshiba_acpi.p_dev->dev, &toshiba_acpi.p_dev->dev,
......
...@@ -574,6 +574,7 @@ static const struct backlight_ops dcon_bl_ops = { ...@@ -574,6 +574,7 @@ static const struct backlight_ops dcon_bl_ops = {
static struct backlight_properties dcon_bl_props = { static struct backlight_properties dcon_bl_props = {
.max_brightness = 15, .max_brightness = 15,
.type = BACKLIGHT_RAW,
.power = FB_BLANK_UNBLANK, .power = FB_BLANK_UNBLANK,
}; };
......
...@@ -781,6 +781,7 @@ static int __init samsung_init(void) ...@@ -781,6 +781,7 @@ static int __init samsung_init(void)
/* create a backlight device to talk to this one */ /* create a backlight device to talk to this one */
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = sabi_config->max_brightness; props.max_brightness = sabi_config->max_brightness;
backlight_device = backlight_device_register("samsung", &sdev->dev, backlight_device = backlight_device_register("samsung", &sdev->dev,
NULL, &backlight_ops, NULL, &backlight_ops,
......
...@@ -282,6 +282,7 @@ static int appledisplay_probe(struct usb_interface *iface, ...@@ -282,6 +282,7 @@ static int appledisplay_probe(struct usb_interface *iface,
snprintf(bl_name, sizeof(bl_name), "appledisplay%d", snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
atomic_inc_return(&count_displays) - 1); atomic_inc_return(&count_displays) - 1);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 0xff; props.max_brightness = 0xff;
pdata->bd = backlight_device_register(bl_name, NULL, pdata, pdata->bd = backlight_device_register(bl_name, NULL, pdata,
&appledisplay_bl_data, &props); &appledisplay_bl_data, &props);
......
...@@ -127,6 +127,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo) ...@@ -127,6 +127,7 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
return; return;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 0xff; props.max_brightness = 0xff;
bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo, bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo,
&atmel_lcdc_bl_ops, &props); &atmel_lcdc_bl_ops, &props);
......
...@@ -1818,6 +1818,7 @@ static void aty128_bl_init(struct aty128fb_par *par) ...@@ -1818,6 +1818,7 @@ static void aty128_bl_init(struct aty128fb_par *par)
snprintf(name, sizeof(name), "aty128bl%d", info->node); snprintf(name, sizeof(name), "aty128bl%d", info->node);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, info->dev, par, &aty128_bl_data, bd = backlight_device_register(name, info->dev, par, &aty128_bl_data,
&props); &props);
......
...@@ -2241,6 +2241,7 @@ static void aty_bl_init(struct atyfb_par *par) ...@@ -2241,6 +2241,7 @@ static void aty_bl_init(struct atyfb_par *par)
snprintf(name, sizeof(name), "atybl%d", info->node); snprintf(name, sizeof(name), "atybl%d", info->node);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, info->dev, par, &aty_bl_data, bd = backlight_device_register(name, info->dev, par, &aty_bl_data,
&props); &props);
......
...@@ -158,6 +158,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) ...@@ -158,6 +158,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node); snprintf(name, sizeof(name), "radeonbl%d", rinfo->info->node);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, rinfo->info->dev, pdata, bd = backlight_device_register(name, rinfo->info->dev, pdata,
&radeon_bl_data, &props); &radeon_bl_data, &props);
......
...@@ -227,6 +227,7 @@ static int pm860x_backlight_probe(struct platform_device *pdev) ...@@ -227,6 +227,7 @@ static int pm860x_backlight_probe(struct platform_device *pdev)
} }
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = MAX_BRIGHTNESS; props.max_brightness = MAX_BRIGHTNESS;
bl = backlight_device_register(name, &pdev->dev, data, bl = backlight_device_register(name, &pdev->dev, data,
&pm860x_backlight_ops, &props); &pm860x_backlight_ops, &props);
......
...@@ -303,6 +303,7 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev) ...@@ -303,6 +303,7 @@ static int __devinit adp5520_bl_probe(struct platform_device *pdev)
mutex_init(&data->lock); mutex_init(&data->lock);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = ADP5020_MAX_BRIGHTNESS; props.max_brightness = ADP5020_MAX_BRIGHTNESS;
bl = backlight_device_register(pdev->name, data->master, data, bl = backlight_device_register(pdev->name, data->master, data,
&adp5520_bl_ops, &props); &adp5520_bl_ops, &props);
......
...@@ -709,6 +709,7 @@ static int __devinit adp8860_probe(struct i2c_client *client, ...@@ -709,6 +709,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
memset(&props, 0, sizeof(props)); memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.max_brightness = ADP8860_MAX_BRIGHTNESS; props.max_brightness = ADP8860_MAX_BRIGHTNESS;
mutex_init(&data->lock); mutex_init(&data->lock);
......
...@@ -104,6 +104,7 @@ static int __devinit adx_backlight_probe(struct platform_device *pdev) ...@@ -104,6 +104,7 @@ static int __devinit adx_backlight_probe(struct platform_device *pdev)
} }
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 0xff; props.max_brightness = 0xff;
bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev,
bl, &adx_backlight_ops, &props); bl, &adx_backlight_ops, &props);
......
...@@ -168,6 +168,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) ...@@ -168,6 +168,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev)
} }
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl, bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl,
&atmel_pwm_bl_ops, &props); &atmel_pwm_bl_ops, &props);
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
#include <asm/backlight.h> #include <asm/backlight.h>
#endif #endif
static const char const *backlight_types[] = {
[BACKLIGHT_RAW] = "raw",
[BACKLIGHT_PLATFORM] = "platform",
[BACKLIGHT_FIRMWARE] = "firmware",
};
#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
/* This callback gets called when something important happens inside a /* This callback gets called when something important happens inside a
...@@ -169,6 +175,14 @@ static ssize_t backlight_store_brightness(struct device *dev, ...@@ -169,6 +175,14 @@ static ssize_t backlight_store_brightness(struct device *dev,
return rc; return rc;
} }
static ssize_t backlight_show_type(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct backlight_device *bd = to_backlight_device(dev);
return sprintf(buf, "%s\n", backlight_types[bd->props.type]);
}
static ssize_t backlight_show_max_brightness(struct device *dev, static ssize_t backlight_show_max_brightness(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -234,6 +248,7 @@ static struct device_attribute bl_device_attributes[] = { ...@@ -234,6 +248,7 @@ static struct device_attribute bl_device_attributes[] = {
__ATTR(actual_brightness, 0444, backlight_show_actual_brightness, __ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
NULL), NULL),
__ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL), __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
__ATTR(type, 0444, backlight_show_type, NULL),
__ATTR_NULL, __ATTR_NULL,
}; };
...@@ -292,9 +307,16 @@ struct backlight_device *backlight_device_register(const char *name, ...@@ -292,9 +307,16 @@ struct backlight_device *backlight_device_register(const char *name,
dev_set_drvdata(&new_bd->dev, devdata); dev_set_drvdata(&new_bd->dev, devdata);
/* Set default properties */ /* Set default properties */
if (props) if (props) {
memcpy(&new_bd->props, props, memcpy(&new_bd->props, props,
sizeof(struct backlight_properties)); sizeof(struct backlight_properties));
if (props->type <= 0 || props->type >= BACKLIGHT_TYPE_MAX) {
WARN(1, "%s: invalid backlight type", name);
new_bd->props.type = BACKLIGHT_RAW;
}
} else {
new_bd->props.type = BACKLIGHT_RAW;
}
rc = device_register(&new_bd->dev); rc = device_register(&new_bd->dev);
if (rc) { if (rc) {
......
...@@ -562,6 +562,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi) ...@@ -562,6 +562,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = pdata->max_intensity; props.max_brightness = pdata->max_intensity;
lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd, lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
&corgi_bl_ops, &props); &corgi_bl_ops, &props);
......
...@@ -193,6 +193,7 @@ static int cr_backlight_probe(struct platform_device *pdev) ...@@ -193,6 +193,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
} }
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL, bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL,
&cr_backlight_ops, &props); &cr_backlight_ops, &props);
if (IS_ERR(bdp)) { if (IS_ERR(bdp)) {
......
...@@ -136,6 +136,7 @@ static int da903x_backlight_probe(struct platform_device *pdev) ...@@ -136,6 +136,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2,
DA9034_WLED_ISET(pdata->output_current)); DA9034_WLED_ISET(pdata->output_current));
props.type = BACKLIGHT_RAW;
props.max_brightness = max_brightness; props.max_brightness = max_brightness;
bl = backlight_device_register(pdev->name, data->da903x_dev, data, bl = backlight_device_register(pdev->name, data->da903x_dev, data,
&da903x_backlight_ops, &props); &da903x_backlight_ops, &props);
......
...@@ -87,6 +87,7 @@ static int __init ep93xxbl_probe(struct platform_device *dev) ...@@ -87,6 +87,7 @@ static int __init ep93xxbl_probe(struct platform_device *dev)
ep93xxbl->mmio = EP93XX_RASTER_BRIGHTNESS; ep93xxbl->mmio = EP93XX_RASTER_BRIGHTNESS;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = EP93XX_MAX_BRIGHT; props.max_brightness = EP93XX_MAX_BRIGHT;
bl = backlight_device_register(dev->name, &dev->dev, ep93xxbl, bl = backlight_device_register(dev->name, &dev->dev, ep93xxbl,
&ep93xxbl_ops, &props); &ep93xxbl_ops, &props);
......
...@@ -91,6 +91,7 @@ static int genericbl_probe(struct platform_device *pdev) ...@@ -91,6 +91,7 @@ static int genericbl_probe(struct platform_device *pdev)
name = machinfo->name; name = machinfo->name;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = machinfo->max_intensity; props.max_brightness = machinfo->max_intensity;
bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops, bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops,
&props); &props);
......
...@@ -109,6 +109,7 @@ static int __devinit hp680bl_probe(struct platform_device *pdev) ...@@ -109,6 +109,7 @@ static int __devinit hp680bl_probe(struct platform_device *pdev)
struct backlight_device *bd; struct backlight_device *bd;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = HP680_MAX_INTENSITY; props.max_brightness = HP680_MAX_INTENSITY;
bd = backlight_device_register("hp680-bl", &pdev->dev, NULL, bd = backlight_device_register("hp680-bl", &pdev->dev, NULL,
&hp680bl_ops, &props); &hp680bl_ops, &props);
......
...@@ -106,6 +106,7 @@ static int jornada_bl_probe(struct platform_device *pdev) ...@@ -106,6 +106,7 @@ static int jornada_bl_probe(struct platform_device *pdev)
struct backlight_device *bd; struct backlight_device *bd;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = BL_MAX_BRIGHT; props.max_brightness = BL_MAX_BRIGHT;
bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL,
&jornada_bl_ops, &props); &jornada_bl_ops, &props);
......
...@@ -149,6 +149,7 @@ static int kb3886bl_probe(struct platform_device *pdev) ...@@ -149,6 +149,7 @@ static int kb3886bl_probe(struct platform_device *pdev)
machinfo->limit_mask = -1; machinfo->limit_mask = -1;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = machinfo->max_intensity; props.max_brightness = machinfo->max_intensity;
kb3886_backlight_device = backlight_device_register("kb3886-bl", kb3886_backlight_device = backlight_device_register("kb3886-bl",
&pdev->dev, NULL, &pdev->dev, NULL,
......
...@@ -184,6 +184,7 @@ static int locomolcd_probe(struct locomo_dev *ldev) ...@@ -184,6 +184,7 @@ static int locomolcd_probe(struct locomo_dev *ldev)
local_irq_restore(flags); local_irq_restore(flags);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 4; props.max_brightness = 4;
locomolcd_bl_device = backlight_device_register("locomo-bl", locomolcd_bl_device = backlight_device_register("locomo-bl",
&ldev->dev, NULL, &ldev->dev, NULL,
......
...@@ -136,6 +136,7 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev) ...@@ -136,6 +136,7 @@ static int __devinit max8925_backlight_probe(struct platform_device *pdev)
data->current_brightness = 0; data->current_brightness = 0;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = MAX_BRIGHTNESS; props.max_brightness = MAX_BRIGHTNESS;
bl = backlight_device_register(name, &pdev->dev, data, bl = backlight_device_register(name, &pdev->dev, data,
&max8925_backlight_ops, &props); &max8925_backlight_ops, &props);
......
...@@ -367,6 +367,7 @@ static int __init mbp_init(void) ...@@ -367,6 +367,7 @@ static int __init mbp_init(void)
return -ENXIO; return -ENXIO;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = 15; props.max_brightness = 15;
mbp_backlight_device = backlight_device_register("mbp_backlight", NULL, mbp_backlight_device = backlight_device_register("mbp_backlight", NULL,
NULL, NULL,
......
...@@ -146,6 +146,7 @@ static int omapbl_probe(struct platform_device *pdev) ...@@ -146,6 +146,7 @@ static int omapbl_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = OMAPBL_MAX_INTENSITY; props.max_brightness = OMAPBL_MAX_INTENSITY;
dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops, dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops,
&props); &props);
......
...@@ -112,6 +112,7 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev) ...@@ -112,6 +112,7 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
if (!pcf_bl) if (!pcf_bl)
return -ENOMEM; return -ENOMEM;
bl_props.type = BACKLIGHT_RAW;
bl_props.max_brightness = 0x3f; bl_props.max_brightness = 0x3f;
bl_props.power = FB_BLANK_UNBLANK; bl_props.power = FB_BLANK_UNBLANK;
......
...@@ -84,6 +84,7 @@ static int progearbl_probe(struct platform_device *pdev) ...@@ -84,6 +84,7 @@ static int progearbl_probe(struct platform_device *pdev)
pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20); pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; props.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN;
progear_backlight_device = backlight_device_register("progear-bl", progear_backlight_device = backlight_device_register("progear-bl",
&pdev->dev, NULL, &pdev->dev, NULL,
......
...@@ -108,6 +108,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -108,6 +108,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "got pwm for backlight\n"); dev_dbg(&pdev->dev, "got pwm for backlight\n");
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = data->max_brightness; props.max_brightness = data->max_brightness;
bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
&pwm_backlight_ops, &props); &pwm_backlight_ops, &props);
......
...@@ -778,6 +778,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi) ...@@ -778,6 +778,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi)
bd->props.max_brightness = MAX_BRIGHTNESS; bd->props.max_brightness = MAX_BRIGHTNESS;
bd->props.brightness = MAX_BRIGHTNESS; bd->props.brightness = MAX_BRIGHTNESS;
bd->props.type = BACKLIGHT_RAW;
lcd->bd = bd; lcd->bd = bd;
/* /*
......
...@@ -102,6 +102,7 @@ static int __devinit tosa_bl_probe(struct i2c_client *client, ...@@ -102,6 +102,7 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
data->i2c = client; data->i2c = client;
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 512 - 1; props.max_brightness = 512 - 1;
data->bl = backlight_device_register("tosa-bl", &client->dev, data, data->bl = backlight_device_register("tosa-bl", &client->dev, data,
&bl_ops, &props); &bl_ops, &props);
......
...@@ -193,6 +193,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev) ...@@ -193,6 +193,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
data->current_brightness = 0; data->current_brightness = 0;
data->isink_reg = isink_reg; data->isink_reg = isink_reg;
props.type = BACKLIGHT_RAW;
props.max_brightness = max_isel; props.max_brightness = max_isel;
bl = backlight_device_register("wm831x", &pdev->dev, data, bl = backlight_device_register("wm831x", &pdev->dev, data,
&wm831x_backlight_ops, &props); &wm831x_backlight_ops, &props);
......
...@@ -649,6 +649,7 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev) ...@@ -649,6 +649,7 @@ static int __devinit bfin_bf54x_probe(struct platform_device *pdev)
} }
#ifndef NO_BL_SUPPORT #ifndef NO_BL_SUPPORT
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 255; props.max_brightness = 255;
bl_dev = backlight_device_register("bf54x-bl", NULL, NULL, bl_dev = backlight_device_register("bf54x-bl", NULL, NULL,
&bfin_lq043fb_bl_ops, &props); &bfin_lq043fb_bl_ops, &props);
......
...@@ -545,6 +545,7 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev) ...@@ -545,6 +545,7 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
} }
#ifndef NO_BL_SUPPORT #ifndef NO_BL_SUPPORT
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 255; props.max_brightness = 255;
bl_dev = backlight_device_register("bf52x-bl", NULL, NULL, bl_dev = backlight_device_register("bf52x-bl", NULL, NULL,
&bfin_lq043fb_bl_ops, &props); &bfin_lq043fb_bl_ops, &props);
......
...@@ -499,6 +499,7 @@ static void imxfb_init_backlight(struct imxfb_info *fbi) ...@@ -499,6 +499,7 @@ static void imxfb_init_backlight(struct imxfb_info *fbi)
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = 0xff; props.max_brightness = 0xff;
props.type = BACKLIGHT_RAW;
writel(fbi->pwmr, fbi->regs + LCDC_PWMR); writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
bl = backlight_device_register("imxfb-bl", &fbi->pdev->dev, fbi, bl = backlight_device_register("imxfb-bl", &fbi->pdev->dev, fbi,
......
...@@ -111,6 +111,7 @@ void nvidia_bl_init(struct nvidia_par *par) ...@@ -111,6 +111,7 @@ void nvidia_bl_init(struct nvidia_par *par)
snprintf(name, sizeof(name), "nvidiabl%d", info->node); snprintf(name, sizeof(name), "nvidiabl%d", info->node);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops, bd = backlight_device_register(name, info->dev, par, &nvidia_bl_ops,
&props); &props);
......
...@@ -534,6 +534,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev) ...@@ -534,6 +534,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev)
props.fb_blank = FB_BLANK_UNBLANK; props.fb_blank = FB_BLANK_UNBLANK;
props.power = FB_BLANK_UNBLANK; props.power = FB_BLANK_UNBLANK;
props.type = BACKLIGHT_RAW;
bldev = backlight_device_register("acx565akm", &md->spi->dev, bldev = backlight_device_register("acx565akm", &md->spi->dev,
md, &acx565akm_bl_ops, &props); md, &acx565akm_bl_ops, &props);
......
...@@ -99,6 +99,7 @@ static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) ...@@ -99,6 +99,7 @@ static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = dssdev->max_backlight_level; props.max_brightness = dssdev->max_backlight_level;
props.type = BACKLIGHT_RAW;
bl = backlight_device_register("sharp-ls", &dssdev->dev, dssdev, bl = backlight_device_register("sharp-ls", &dssdev->dev, dssdev,
&sharp_ls_bl_ops, &props); &sharp_ls_bl_ops, &props);
......
...@@ -729,6 +729,8 @@ static int taal_probe(struct omap_dss_device *dssdev) ...@@ -729,6 +729,8 @@ static int taal_probe(struct omap_dss_device *dssdev)
props.max_brightness = 255; props.max_brightness = 255;
else else
props.max_brightness = 127; props.max_brightness = 127;
props.type = BACKLIGHT_RAW;
bldev = backlight_device_register("taal", &dssdev->dev, dssdev, bldev = backlight_device_register("taal", &dssdev->dev, dssdev,
&taal_bl_ops, &props); &taal_bl_ops, &props);
if (IS_ERR(bldev)) { if (IS_ERR(bldev)) {
......
...@@ -355,6 +355,7 @@ static void riva_bl_init(struct riva_par *par) ...@@ -355,6 +355,7 @@ static void riva_bl_init(struct riva_par *par)
snprintf(name, sizeof(name), "rivabl%d", info->node); snprintf(name, sizeof(name), "rivabl%d", info->node);
memset(&props, 0, sizeof(struct backlight_properties)); memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = FB_BACKLIGHT_LEVELS - 1; props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
bd = backlight_device_register(name, info->dev, par, &riva_bl_ops, bd = backlight_device_register(name, info->dev, par, &riva_bl_ops,
&props); &props);
......
...@@ -32,6 +32,13 @@ enum backlight_update_reason { ...@@ -32,6 +32,13 @@ enum backlight_update_reason {
BACKLIGHT_UPDATE_SYSFS, BACKLIGHT_UPDATE_SYSFS,
}; };
enum backlight_type {
BACKLIGHT_RAW = 1,
BACKLIGHT_PLATFORM,
BACKLIGHT_FIRMWARE,
BACKLIGHT_TYPE_MAX,
};
struct backlight_device; struct backlight_device;
struct fb_info; struct fb_info;
...@@ -62,6 +69,8 @@ struct backlight_properties { ...@@ -62,6 +69,8 @@ struct backlight_properties {
/* FB Blanking active? (values as for power) */ /* FB Blanking active? (values as for power) */
/* Due to be removed, please use (state & BL_CORE_FBBLANK) */ /* Due to be removed, please use (state & BL_CORE_FBBLANK) */
int fb_blank; int fb_blank;
/* Backlight type */
enum backlight_type type;
/* Flags used to signal drivers of state changes */ /* Flags used to signal drivers of state changes */
/* Upper 4 bits are reserved for driver internal use */ /* Upper 4 bits are reserved for driver internal use */
unsigned int state; unsigned int state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment