/* * Sanyo LV5207LP LED Driver * * Copyright (C) 2013 Ideas on board SPRL * * Contact: Laurent Pinchart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include #include #include #include #include #include #include #define LV5207LP_CTRL1 0x00 #define LV5207LP_CPSW (1 << 7) #define LV5207LP_SCTEN (1 << 6) #define LV5207LP_C10 (1 << 5) #define LV5207LP_CKSW (1 << 4) #define LV5207LP_RSW (1 << 3) #define LV5207LP_GSW (1 << 2) #define LV5207LP_BSW (1 << 1) #define LV5207LP_CTRL2 0x01 #define LV5207LP_MSW (1 << 7) #define LV5207LP_MLED4 (1 << 6) #define LV5207LP_RED 0x02 #define LV5207LP_GREEN 0x03 #define LV5207LP_BLUE 0x04 #define LV5207LP_MAX_BRIGHTNESS 32 struct lv5207lp { struct i2c_client *client; struct backlight_device *backlight; struct lv5207lp_platform_data *pdata; }; static int lv5207lp_write(struct lv5207lp *lv, u8 reg, u8 data) { return i2c_smbus_write_byte_data(lv->client, reg, data); } static int lv5207lp_backlight_update_status(struct backlight_device *backlight) { struct lv5207lp *lv = bl_get_data(backlight); int brightness = backlight->props.brightness; if (backlight->props.power != FB_BLANK_UNBLANK || backlight->props.fb_blank != FB_BLANK_UNBLANK || backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) brightness = 0; if (brightness) { lv5207lp_write(lv, LV5207LP_CTRL1, LV5207LP_CPSW | LV5207LP_C10 | LV5207LP_CKSW); lv5207lp_write(lv, LV5207LP_CTRL2, LV5207LP_MSW | LV5207LP_MLED4 | (brightness - 1)); } else { lv5207lp_write(lv, LV5207LP_CTRL1, 0); lv5207lp_write(lv, LV5207LP_CTRL2, 0); } return 0; } static int lv5207lp_backlight_check_fb(struct backlight_device *backlight, struct fb_info *info) { struct lv5207lp *lv = bl_get_data(backlight); return lv->pdata->fbdev == NULL || lv->pdata->fbdev == info->dev; } static const struct backlight_ops lv5207lp_backlight_ops = { .options = BL_CORE_SUSPENDRESUME, .update_status = lv5207lp_backlight_update_status, .check_fb = lv5207lp_backlight_check_fb, }; static int lv5207lp_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct lv5207lp_platform_data *pdata = dev_get_platdata(&client->dev); struct backlight_device *backlight; struct backlight_properties props; struct lv5207lp *lv; if (pdata == NULL) { dev_err(&client->dev, "No platform data supplied\n"); return -EINVAL; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { dev_warn(&client->dev, "I2C adapter doesn't support I2C_FUNC_SMBUS_BYTE\n"); return -EIO; } lv = devm_kzalloc(&client->dev, sizeof(*lv), GFP_KERNEL); if (!lv) return -ENOMEM; lv->client = client; lv->pdata = pdata; memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = min_t(unsigned int, pdata->max_value, LV5207LP_MAX_BRIGHTNESS); props.brightness = clamp_t(unsigned int, pdata->def_value, 0, props.max_brightness); backlight = devm_backlight_device_register(&client->dev, dev_name(&client->dev), &lv->client->dev, lv, &lv5207lp_backlight_ops, &props); if (IS_ERR(backlight)) { dev_err(&client->dev, "failed to register backlight\n"); return PTR_ERR(backlight); } backlight_update_status(backlight); i2c_set_clientdata(client, backlight); return 0; } static int lv5207lp_remove(struct i2c_client *client) { struct backlight_device *backlight = i2c_get_clientdata(client); backlight->props.brightness = 0; backlight_update_status(backlight); return 0; } static const struct i2c_device_id lv5207lp_ids[] = { { "lv5207lp", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, lv5207lp_ids); static struct i2c_driver lv5207lp_driver = { .driver = { .name = "lv5207lp", }, .probe = lv5207lp_probe, .remove = lv5207lp_remove, .id_table = lv5207lp_ids, }; module_i2c_driver(lv5207lp_driver); MODULE_DESCRIPTION("Sanyo LV5207LP Backlight Driver"); MODULE_AUTHOR("Laurent Pinchart "); MODULE_LICENSE("GPL"); ncache.txt?id=e7aa8c2eb11ba69b1b69099c3c7bd6be3087b0ba'>e7aa8c2eb11ba69b1b69099c3c7bd6be3087b0ba (patch) treef63906f41699c8e38af9d12b063e2ceab0286ef2 /Documentation/vm/cleancache.txt parente34bac726d27056081d0250c0e173e4b155aa340 (diff)parent868c97a846a73e937d835b09b8c885a69df50ec8 (diff)
Merge tag 'docs-4.10' of git://git.lwn.net/linuxHEADmaster
Pull documentation update from Jonathan Corbet: "These are the documentation changes for 4.10. It's another busy cycle for the docs tree, as the sphinx conversion continues. Highlights include: - Further work on PDF output, which remains a bit of a pain but should be more solid now. - Five more DocBook template files converted to Sphinx. Only 27 to go... Lots of plain-text files have also been converted and integrated. - Images in binary formats have been replaced with more source-friendly versions. - Various bits of organizational work, including the renaming of various files discussed at the kernel summit. - New documentation for the device_link mechanism. ... and, of course, lots of typo fixes and small updates" * tag 'docs-4.10' of git://git.lwn.net/linux: (193 commits) dma-buf: Extract dma-buf.rst Update Documentation/00-INDEX docs: 00-INDEX: document directories/files with no docs docs: 00-INDEX: remove non-existing entries docs: 00-INDEX: add missing entries for documentation files/dirs docs: 00-INDEX: consolidate process/ and admin-guide/ description scripts: add a script to check if Documentation/00-INDEX is sane Docs: change sh -> awk in REPORTING-BUGS Documentation/core-api/device_link: Add initial documentation core-api: remove an unexpected unident ppc/idle: Add documentation for powersave=off Doc: Correct typo, "Introdution" => "Introduction" Documentation/atomic_ops.txt: convert to ReST markup Documentation/local_ops.txt: convert to ReST markup Documentation/assoc_array.txt: convert to ReST markup docs-rst: parse-headers.pl: cleanup the documentation docs-rst: fix media cleandocs target docs-rst: media/Makefile: reorganize the rules docs-rst: media: build SVG from graphviz files docs-rst: replace bayer.png by a SVG image ...
Diffstat (limited to 'Documentation/vm/cleancache.txt')