diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-25 15:21:28 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-25 15:21:28 +0200 |
commit | 3f2dcb6411eb3fd4a8be5d3713be0e2c1c750d6d (patch) | |
tree | 247bf8d27526c48f8508a39cad29eb61262f9d0a /drivers/video | |
parent | Merge tag 'mfd-next-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/le... (diff) | |
parent | backlight: Remove ld9040 driver (diff) | |
download | linux-3f2dcb6411eb3fd4a8be5d3713be0e2c1c750d6d.tar.xz linux-3f2dcb6411eb3fd4a8be5d3713be0e2c1c750d6d.zip |
Merge tag 'backlight-next-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones:
"Old Drivers
- Remove driver for S6E63M0
- Remove driver for LD9040
Fix-ups
- Trivial (email address update); adp*_bl
- Use 'atomic' PWM API; pwm_bl
Bug Fixes
- Remove pointless boolen '&ptr' check; lm3639_bl"
* tag 'backlight-next-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
backlight: Remove ld9040 driver
backlight: Remove s6e63m0 driver
backlight: lm3639: Unconditionally call led_classdev_unregister
backlight: pwm_bl: Switch to using "atomic" PWM API
backlight: Update MODULE AUTHOR email address
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/Kconfig | 16 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 2 | ||||
-rw-r--r-- | drivers/video/backlight/adp5520_bl.c | 2 | ||||
-rw-r--r-- | drivers/video/backlight/adp8860_bl.c | 2 | ||||
-rw-r--r-- | drivers/video/backlight/adp8870_bl.c | 2 | ||||
-rw-r--r-- | drivers/video/backlight/ld9040.c | 811 | ||||
-rw-r--r-- | drivers/video/backlight/ld9040_gamma.h | 202 | ||||
-rw-r--r-- | drivers/video/backlight/lm3639_bl.c | 6 | ||||
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 81 | ||||
-rw-r--r-- | drivers/video/backlight/s6e63m0.c | 857 | ||||
-rw-r--r-- | drivers/video/backlight/s6e63m0_gamma.h | 266 |
11 files changed, 47 insertions, 2200 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 2919e2334052..71ee978c848f 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -111,22 +111,6 @@ config LCD_HP700 If you have an HP Jornada 700 series handheld (710/720/728) say Y to enable LCD control driver. -config LCD_S6E63M0 - tristate "S6E63M0 AMOLED LCD Driver" - depends on SPI && BACKLIGHT_CLASS_DEVICE - default n - help - If you have an S6E63M0 LCD Panel, say Y to enable its - LCD control driver. - -config LCD_LD9040 - tristate "LD9040 AMOLED LCD Driver" - depends on SPI && BACKLIGHT_CLASS_DEVICE - default n - help - If you have an LD9040 Panel, say Y to enable its - control driver. - config LCD_AMS369FG06 tristate "AMS369FG06 AMOLED LCD Driver" depends on SPI && BACKLIGHT_CLASS_DEVICE diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 0dcc2c745c03..63c507c07437 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -9,13 +9,11 @@ obj-$(CONFIG_LCD_HX8357) += hx8357.o obj-$(CONFIG_LCD_ILI922X) += ili922x.o obj-$(CONFIG_LCD_ILI9320) += ili9320.o obj-$(CONFIG_LCD_L4F00242T03) += l4f00242t03.o -obj-$(CONFIG_LCD_LD9040) += ld9040.o obj-$(CONFIG_LCD_LMS283GF05) += lms283gf05.o obj-$(CONFIG_LCD_LMS501KF03) += lms501kf03.o obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o obj-$(CONFIG_LCD_OTM3225A) += otm3225a.o obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o -obj-$(CONFIG_LCD_S6E63M0) += s6e63m0.o obj-$(CONFIG_LCD_TDO24M) += tdo24m.o obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index 35373e2065b2..5e38353b4423 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c @@ -391,7 +391,7 @@ static struct platform_driver adp5520_bl_driver = { module_platform_driver(adp5520_bl_driver); -MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); +MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); MODULE_DESCRIPTION("ADP5520(01) Backlight Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:adp5520-backlight"); diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index f1dc41cf19e3..85318236da2f 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -822,5 +822,5 @@ static struct i2c_driver adp8860_driver = { module_i2c_driver(adp8860_driver); MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); +MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); MODULE_DESCRIPTION("ADP8860 Backlight driver"); diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 4fec9aa92d9b..8d50e0299578 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -992,5 +992,5 @@ static struct i2c_driver adp8870_driver = { module_i2c_driver(adp8870_driver); MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); +MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>"); MODULE_DESCRIPTION("ADP8870 Backlight driver"); diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c deleted file mode 100644 index 677f8abba27c..000000000000 --- a/drivers/video/backlight/ld9040.c +++ /dev/null @@ -1,811 +0,0 @@ -/* - * ld9040 AMOLED LCD panel driver. - * - * Copyright (c) 2011 Samsung Electronics - * Author: Donghwa Lee <dh09.lee@samsung.com> - * Derived from drivers/video/backlight/s6e63m0.c - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include <linux/backlight.h> -#include <linux/delay.h> -#include <linux/fb.h> -#include <linux/gpio.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/kernel.h> -#include <linux/lcd.h> -#include <linux/module.h> -#include <linux/regulator/consumer.h> -#include <linux/spi/spi.h> -#include <linux/wait.h> - -#include "ld9040_gamma.h" - -#define SLEEPMSEC 0x1000 -#define ENDDEF 0x2000 -#define DEFMASK 0xFF00 -#define COMMAND_ONLY 0xFE -#define DATA_ONLY 0xFF - -#define MIN_BRIGHTNESS 0 -#define MAX_BRIGHTNESS 24 - -struct ld9040 { - struct device *dev; - struct spi_device *spi; - unsigned int power; - unsigned int current_brightness; - - struct lcd_device *ld; - struct backlight_device *bd; - struct lcd_platform_data *lcd_pd; - - struct mutex lock; - bool enabled; -}; - -static struct regulator_bulk_data supplies[] = { - { .supply = "vdd3", }, - { .supply = "vci", }, -}; - -static void ld9040_regulator_enable(struct ld9040 *lcd) -{ - int ret = 0; - struct lcd_platform_data *pd = NULL; - - pd = lcd->lcd_pd; - mutex_lock(&lcd->lock); - if (!lcd->enabled) { - ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies); - if (ret) - goto out; - - lcd->enabled = true; - } - msleep(pd->power_on_delay); -out: - mutex_unlock(&lcd->lock); -} - -static void ld9040_regulator_disable(struct ld9040 *lcd) -{ - int ret = 0; - - mutex_lock(&lcd->lock); - if (lcd->enabled) { - ret = regulator_bulk_disable(ARRAY_SIZE(supplies), supplies); - if (ret) - goto out; - - lcd->enabled = false; - } -out: - mutex_unlock(&lcd->lock); -} - -static const unsigned short seq_swreset[] = { - 0x01, COMMAND_ONLY, - ENDDEF, 0x00 -}; - -static const unsigned short seq_user_setting[] = { - 0xF0, 0x5A, - - DATA_ONLY, 0x5A, - ENDDEF, 0x00 -}; - -static const unsigned short seq_elvss_on[] = { - 0xB1, 0x0D, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x16, - ENDDEF, 0x00 -}; - -static const unsigned short seq_gtcon[] = { - 0xF7, 0x09, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - ENDDEF, 0x00 -}; - -static const unsigned short seq_panel_condition[] = { - 0xF8, 0x05, - - DATA_ONLY, 0x65, - DATA_ONLY, 0x96, - DATA_ONLY, 0x71, - DATA_ONLY, 0x7D, - DATA_ONLY, 0x19, - DATA_ONLY, 0x3B, - DATA_ONLY, 0x0D, - DATA_ONLY, 0x19, - DATA_ONLY, 0x7E, - DATA_ONLY, 0x0D, - DATA_ONLY, 0xE2, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x7E, - DATA_ONLY, 0x7D, - DATA_ONLY, 0x07, - DATA_ONLY, 0x07, - DATA_ONLY, 0x20, - DATA_ONLY, 0x20, - DATA_ONLY, 0x20, - DATA_ONLY, 0x02, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_gamma_set1[] = { - 0xF9, 0x00, - - DATA_ONLY, 0xA7, - DATA_ONLY, 0xB4, - DATA_ONLY, 0xAE, - DATA_ONLY, 0xBF, - DATA_ONLY, 0x00, - DATA_ONLY, 0x91, - DATA_ONLY, 0x00, - DATA_ONLY, 0xB2, - DATA_ONLY, 0xB4, - DATA_ONLY, 0xAA, - DATA_ONLY, 0xBB, - DATA_ONLY, 0x00, - DATA_ONLY, 0xAC, - DATA_ONLY, 0x00, - DATA_ONLY, 0xB3, - DATA_ONLY, 0xB1, - DATA_ONLY, 0xAA, - DATA_ONLY, 0xBC, - DATA_ONLY, 0x00, - DATA_ONLY, 0xB3, - ENDDEF, 0x00 -}; - -static const unsigned short seq_gamma_ctrl[] = { - 0xFB, 0x02, - - DATA_ONLY, 0x5A, - ENDDEF, 0x00 -}; - -static const unsigned short seq_gamma_start[] = { - 0xF9, COMMAND_ONLY, - - ENDDEF, 0x00 -}; - -static const unsigned short seq_apon[] = { - 0xF3, 0x00, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x0A, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_display_ctrl[] = { - 0xF2, 0x02, - - DATA_ONLY, 0x08, - DATA_ONLY, 0x08, - DATA_ONLY, 0x10, - DATA_ONLY, 0x10, - ENDDEF, 0x00 -}; - -static const unsigned short seq_manual_pwr[] = { - 0xB0, 0x04, - ENDDEF, 0x00 -}; - -static const unsigned short seq_pwr_ctrl[] = { - 0xF4, 0x0A, - - DATA_ONLY, 0x87, - DATA_ONLY, 0x25, - DATA_ONLY, 0x6A, - DATA_ONLY, 0x44, - DATA_ONLY, 0x02, - DATA_ONLY, 0x88, - ENDDEF, 0x00 -}; - -static const unsigned short seq_sleep_out[] = { - 0x11, COMMAND_ONLY, - ENDDEF, 0x00 -}; - -static const unsigned short seq_sleep_in[] = { - 0x10, COMMAND_ONLY, - ENDDEF, 0x00 -}; - -static const unsigned short seq_display_on[] = { - 0x29, COMMAND_ONLY, - ENDDEF, 0x00 -}; - -static const unsigned short seq_display_off[] = { - 0x28, COMMAND_ONLY, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vci1_1st_en[] = { - 0xF3, 0x10, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vl1_en[] = { - 0xF3, 0x11, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vl2_en[] = { - 0xF3, 0x13, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vci1_2nd_en[] = { - 0xF3, 0x33, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vl3_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vreg1_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0x01, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vgh_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0x11, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vgl_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0x31, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x02, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vmos_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xB1, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vint_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xF1, - /* DATA_ONLY, 0x71, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static const unsigned short seq_vbh_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xF9, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - ENDDEF, 0x00 -}; - -static const unsigned short seq_vbl_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFD, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - ENDDEF, 0x00 -}; - -static const unsigned short seq_gam_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFF, - /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static const unsigned short seq_sd_amp_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFF, - /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x80, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static const unsigned short seq_gls_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFF, - /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x81, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static const unsigned short seq_els_en[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFF, - /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x83, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static const unsigned short seq_el_on[] = { - 0xF3, 0x37, - - DATA_ONLY, 0xFF, - /* DATA_ONLY, 0x73, VMOS/VBL/VBH not used */ - DATA_ONLY, 0x87, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - /* DATA_ONLY, 0x02, VMOS/VBL/VBH not used */ - ENDDEF, 0x00 -}; - -static int ld9040_spi_write_byte(struct ld9040 *lcd, int addr, int data) -{ - u16 buf[1]; - struct spi_message msg; - - struct spi_transfer xfer = { - .len = 2, - .tx_buf = buf, - }; - - buf[0] = (addr << 8) | data; - - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - - return spi_sync(lcd->spi, &msg); -} - -static int ld9040_spi_write(struct ld9040 *lcd, unsigned char address, - unsigned char command) -{ - int ret = 0; - - if (address != DATA_ONLY) - ret = ld9040_spi_write_byte(lcd, 0x0, address); - if (command != COMMAND_ONLY) - ret = ld9040_spi_write_byte(lcd, 0x1, command); - - return ret; -} - -static int ld9040_panel_send_sequence(struct ld9040 *lcd, - const unsigned short *wbuf) -{ - int ret = 0, i = 0; - - while ((wbuf[i] & DEFMASK) != ENDDEF) { - if ((wbuf[i] & DEFMASK) != SLEEPMSEC) { - ret = ld9040_spi_write(lcd, wbuf[i], wbuf[i+1]); - if (ret) - break; - } else { - msleep(wbuf[i+1]); - } - i += 2; - } - - return ret; -} - -static int _ld9040_gamma_ctl(struct ld9040 *lcd, const unsigned int *gamma) -{ - unsigned int i = 0; - int ret = 0; - - /* start gamma table updating. */ - ret = ld9040_panel_send_sequence(lcd, seq_gamma_start); - if (ret) { - dev_err(lcd->dev, "failed to disable gamma table updating.\n"); - goto gamma_err; - } - - for (i = 0 ; i < GAMMA_TABLE_COUNT; i++) { - ret = ld9040_spi_write(lcd, DATA_ONLY, gamma[i]); - if (ret) { - dev_err(lcd->dev, "failed to set gamma table.\n"); - goto gamma_err; - } - } - - /* update gamma table. */ - ret = ld9040_panel_send_sequence(lcd, seq_gamma_ctrl); - if (ret) - dev_err(lcd->dev, "failed to update gamma table.\n"); - -gamma_err: - return ret; -} - -static int ld9040_gamma_ctl(struct ld9040 *lcd, int gamma) -{ - return _ld9040_gamma_ctl(lcd, gamma_table.gamma_22_table[gamma]); -} - -static int ld9040_ldi_init(struct ld9040 *lcd) -{ - int ret, i; - static const unsigned short *init_seq[] = { - seq_user_setting, - seq_panel_condition, - seq_display_ctrl, - seq_manual_pwr, - seq_elvss_on, - seq_gtcon, - seq_gamma_set1, - seq_gamma_ctrl, - seq_sleep_out, - }; - - for (i = 0; i < ARRAY_SIZE(init_seq); i++) { - ret = ld9040_panel_send_sequence(lcd, init_seq[i]); - /* workaround: minimum delay time for transferring CMD */ - usleep_range(300, 310); - if (ret) - break; - } - - return ret; -} - -static int ld9040_ldi_enable(struct ld9040 *lcd) -{ - return ld9040_panel_send_sequence(lcd, seq_display_on); -} - -static int ld9040_ldi_disable(struct ld9040 *lcd) -{ - int ret; - - ret = ld9040_panel_send_sequence(lcd, seq_display_off); - ret = ld9040_panel_send_sequence(lcd, seq_sleep_in); - - return ret; -} - -static int ld9040_power_is_on(int power) -{ - return power <= FB_BLANK_NORMAL; -} - -static int ld9040_power_on(struct ld9040 *lcd) -{ - int ret = 0; - struct lcd_platform_data *pd; - - pd = lcd->lcd_pd; - - /* lcd power on */ - ld9040_regulator_enable(lcd); - - if (!pd->reset) { - dev_err(lcd->dev, "reset is NULL.\n"); - return -EINVAL; - } - - pd->reset(lcd->ld); - msleep(pd->reset_delay); - - ret = ld9040_ldi_init(lcd); - if (ret) { - dev_err(lcd->dev, "failed to initialize ldi.\n"); - return ret; - } - - ret = ld9040_ldi_enable(lcd); - if (ret) { - dev_err(lcd->dev, "failed to enable ldi.\n"); - return ret; - } - - return 0; -} - -static int ld9040_power_off(struct ld9040 *lcd) -{ - int ret; - struct lcd_platform_data *pd; - - pd = lcd->lcd_pd; - - ret = ld9040_ldi_disable(lcd); - if (ret) { - dev_err(lcd->dev, "lcd setting failed.\n"); - return -EIO; - } - - msleep(pd->power_off_delay); - - /* lcd power off */ - ld9040_regulator_disable(lcd); - - return 0; -} - -static int ld9040_power(struct ld9040 *lcd, int power) -{ - int ret = 0; - - if (ld9040_power_is_on(power) && !ld9040_power_is_on(lcd->power)) - ret = ld9040_power_on(lcd); - else if (!ld9040_power_is_on(power) && ld9040_power_is_on(lcd->power)) - ret = ld9040_power_off(lcd); - - if (!ret) - lcd->power = power; - - return ret; -} - -static int ld9040_set_power(struct lcd_device *ld, int power) -{ - struct ld9040 *lcd = lcd_get_data(ld); - - if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN && - power != FB_BLANK_NORMAL) { - dev_err(lcd->dev, "power value should be 0, 1 or 4.\n"); - return -EINVAL; - } - - return ld9040_power(lcd, power); -} - -static int ld9040_get_power(struct lcd_device *ld) -{ - struct ld9040 *lcd = lcd_get_data(ld); - - return lcd->power; -} - -static int ld9040_set_brightness(struct backlight_device *bd) -{ - int ret = 0, brightness = bd->props.brightness; - struct ld9040 *lcd = bl_get_data(bd); - - if (brightness < MIN_BRIGHTNESS || - brightness > bd->props.max_brightness) { - dev_err(&bd->dev, "lcd brightness should be %d to %d.\n", - MIN_BRIGHTNESS, MAX_BRIGHTNESS); - return -EINVAL; - } - - ret = ld9040_gamma_ctl(lcd, bd->props.brightness); - if (ret) { - dev_err(&bd->dev, "lcd brightness setting failed.\n"); - return -EIO; - } - - return ret; -} - -static struct lcd_ops ld9040_lcd_ops = { - .set_power = ld9040_set_power, - .get_power = ld9040_get_power, -}; - -static const struct backlight_ops ld9040_backlight_ops = { - .update_status = ld9040_set_brightness, -}; - -static int ld9040_probe(struct spi_device *spi) -{ - int ret = 0; - struct ld9040 *lcd = NULL; - struct lcd_device *ld = NULL; - struct backlight_device *bd = NULL; - struct backlight_properties props; - - lcd = devm_kzalloc(&spi->dev, sizeof(struct ld9040), GFP_KERNEL); - if (!lcd) - return -ENOMEM; - - /* ld9040 lcd panel uses 3-wire 9bits SPI Mode. */ - spi->bits_per_word = 9; - - ret = spi_setup(spi); - if (ret < 0) { - dev_err(&spi->dev, "spi setup failed.\n"); - return ret; - } - - lcd->spi = spi; - lcd->dev = &spi->dev; - - lcd->lcd_pd = dev_get_platdata(&spi->dev); - if (!lcd->lcd_pd) { - dev_err(&spi->dev, "platform data is NULL.\n"); - return -EINVAL; - } - - mutex_init(&lcd->lock); - - ret = devm_regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); - if (ret) { - dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); - return ret; - } - - ld = devm_lcd_device_register(&spi->dev, "ld9040", &spi->dev, lcd, - &ld9040_lcd_ops); - if (IS_ERR(ld)) - return PTR_ERR(ld); - - lcd->ld = ld; - - memset(&props, 0, sizeof(struct backlight_properties)); - props.type = BACKLIGHT_RAW; - props.max_brightness = MAX_BRIGHTNESS; - - bd = devm_backlight_device_register(&spi->dev, "ld9040-bl", &spi->dev, - lcd, &ld9040_backlight_ops, &props); - if (IS_ERR(bd)) - return PTR_ERR(bd); - - bd->props.brightness = MAX_BRIGHTNESS; - lcd->bd = bd; - - /* - * if lcd panel was on from bootloader like u-boot then - * do not lcd on. - */ - if (!lcd->lcd_pd->lcd_enabled) { - /* - * if lcd panel was off from bootloader then - * current lcd status is powerdown and then - * it enables lcd panel. - */ - lcd->power = FB_BLANK_POWERDOWN; - - ld9040_power(lcd, FB_BLANK_UNBLANK); - } else { - lcd->power = FB_BLANK_UNBLANK; - } - - spi_set_drvdata(spi, lcd); - - dev_info(&spi->dev, "ld9040 panel driver has been probed.\n"); - return 0; -} - -static int ld9040_remove(struct spi_device *spi) -{ - struct ld9040 *lcd = spi_get_drvdata(spi); - - ld9040_power(lcd, FB_BLANK_POWERDOWN); - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int ld9040_suspend(struct device *dev) -{ - struct ld9040 *lcd = dev_get_drvdata(dev); - - dev_dbg(dev, "lcd->power = %d\n", lcd->power); - - /* - * when lcd panel is suspend, lcd panel becomes off - * regardless of status. - */ - return ld9040_power(lcd, FB_BLANK_POWERDOWN); -} - -static int ld9040_resume(struct device *dev) -{ - struct ld9040 *lcd = dev_get_drvdata(dev); - - lcd->power = FB_BLANK_POWERDOWN; - - return ld9040_power(lcd, FB_BLANK_UNBLANK); -} -#endif - -static SIMPLE_DEV_PM_OPS(ld9040_pm_ops, ld9040_suspend, ld9040_resume); - -/* Power down all displays on reboot, poweroff or halt. */ -static void ld9040_shutdown(struct spi_device *spi) -{ - struct ld9040 *lcd = spi_get_drvdata(spi); - - ld9040_power(lcd, FB_BLANK_POWERDOWN); -} - -static struct spi_driver ld9040_driver = { - .driver = { - .name = "ld9040", - .pm = &ld9040_pm_ops, - }, - .probe = ld9040_probe, - .remove = ld9040_remove, - .shutdown = ld9040_shutdown, -}; - -module_spi_driver(ld9040_driver); - -MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>"); -MODULE_DESCRIPTION("ld9040 LCD Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/backlight/ld9040_gamma.h b/drivers/video/backlight/ld9040_gamma.h deleted file mode 100644 index c5e586d97385..000000000000 --- a/drivers/video/backlight/ld9040_gamma.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Gamma level definitions. - * - * Copyright (c) 2011 Samsung Electronics - * InKi Dae <inki.dae@samsung.com> - * Donghwa Lee <dh09.lee@samsung.com> - * - * 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. -*/ - -#ifndef _LD9040_BRIGHTNESS_H -#define _LD9040_BRIGHTNESS_H - -#define MAX_GAMMA_LEVEL 25 -#define GAMMA_TABLE_COUNT 21 - -/* gamma value: 2.2 */ -static const unsigned int ld9040_22_300[] = { - 0x00, 0xa7, 0xb4, 0xae, 0xbf, 0x00, 0x91, - 0x00, 0xb2, 0xb4, 0xaa, 0xbb, 0x00, 0xac, - 0x00, 0xb3, 0xb1, 0xaa, 0xbc, 0x00, 0xb3 -}; - -static const unsigned int ld9040_22_290[] = { - 0x00, 0xa9, 0xb7, 0xae, 0xbd, 0x00, 0x89, - 0x00, 0xb7, 0xb6, 0xa8, 0xba, 0x00, 0xa4, - 0x00, 0xb1, 0xb4, 0xaa, 0xbb, 0x00, 0xaa -}; - -static const unsigned int ld9040_22_280[] = { - 0x00, 0xa9, 0xb6, 0xad, 0xbf, 0x00, 0x86, - 0x00, 0xb8, 0xb5, 0xa8, 0xbc, 0x00, 0xa0, - 0x00, 0xb3, 0xb3, 0xa9, 0xbc, 0x00, 0xa7 -}; - -static const unsigned int ld9040_22_270[] = { - 0x00, 0xa8, 0xb8, 0xae, 0xbe, 0x00, 0x84, - 0x00, 0xb9, 0xb7, 0xa8, 0xbc, 0x00, 0x9d, - 0x00, 0xb2, 0xb5, 0xaa, 0xbc, 0x00, 0xa4 - -}; -static const unsigned int ld9040_22_260[] = { - 0x00, 0xa4, 0xb8, 0xb0, 0xbf, 0x00, 0x80, - 0x00, 0xb8, 0xb6, 0xaa, 0xbc, 0x00, 0x9a, - 0x00, 0xb0, 0xb5, 0xab, 0xbd, 0x00, 0xa0 -}; - -static const unsigned int ld9040_22_250[] = { - 0x00, 0xa4, 0xb9, 0xaf, 0xc1, 0x00, 0x7d, - 0x00, 0xb9, 0xb6, 0xaa, 0xbb, 0x00, 0x97, - 0x00, 0xb1, 0xb5, 0xaa, 0xbf, 0x00, 0x9d -}; - -static const unsigned int ld9040_22_240[] = { - 0x00, 0xa2, 0xb9, 0xaf, 0xc2, 0x00, 0x7a, - 0x00, 0xb9, 0xb7, 0xaa, 0xbd, 0x00, 0x94, - 0x00, 0xb0, 0xb5, 0xab, 0xbf, 0x00, 0x9a -}; - -static const unsigned int ld9040_22_230[] = { - 0x00, 0xa0, 0xb9, 0xaf, 0xc3, 0x00, 0x77, - 0x00, 0xb9, 0xb7, 0xab, 0xbe, 0x00, 0x90, - 0x00, 0xb0, 0xb6, 0xab, 0xbf, 0x00, 0x97 -}; - -static const unsigned int ld9040_22_220[] = { - 0x00, 0x9e, 0xba, 0xb0, 0xc2, 0x00, 0x75, - 0x00, 0xb9, 0xb8, 0xab, 0xbe, 0x00, 0x8e, - 0x00, 0xb0, 0xb6, 0xac, 0xbf, 0x00, 0x94 -}; - -static const unsigned int ld9040_22_210[] = { - 0x00, 0x9c, 0xb9, 0xb0, 0xc4, 0x00, 0x72, - 0x00, 0xb8, 0xb8, 0xac, 0xbf, 0x00, 0x8a, - 0x00, 0xb0, 0xb6, 0xac, 0xc0, 0x00, 0x91 -}; - -static const unsigned int ld9040_22_200[] = { - 0x00, 0x9a, 0xba, 0xb1, 0xc4, 0x00, 0x6f, - 0x00, 0xb8, 0xb8, 0xad, 0xc0, 0x00, 0x86, - 0x00, 0xb0, 0xb7, 0xad, 0xc0, 0x00, 0x8d -}; - -static const unsigned int ld9040_22_190[] = { - 0x00, 0x97, 0xba, 0xb2, 0xc5, 0x00, 0x6c, - 0x00, 0xb8, 0xb8, 0xae, 0xc1, 0x00, 0x82, - 0x00, 0xb0, 0xb6, 0xae, 0xc2, 0x00, 0x89 -}; - -static const unsigned int ld9040_22_180[] = { - 0x00, 0x93, 0xba, 0xb3, 0xc5, 0x00, 0x69, - 0x00, 0xb8, 0xb9, 0xae, 0xc1, 0x00, 0x7f, - 0x00, 0xb0, 0xb6, 0xae, 0xc3, 0x00, 0x85 -}; - -static const unsigned int ld9040_22_170[] = { - 0x00, 0x8b, 0xb9, 0xb3, 0xc7, 0x00, 0x65, - 0x00, 0xb7, 0xb8, 0xaf, 0xc3, 0x00, 0x7a, - 0x00, 0x80, 0xb6, 0xae, 0xc4, 0x00, 0x81 -}; - -static const unsigned int ld9040_22_160[] = { - 0x00, 0x89, 0xba, 0xb3, 0xc8, 0x00, 0x62, - 0x00, 0xb6, 0xba, 0xaf, 0xc3, 0x00, 0x76, - 0x00, 0xaf, 0xb7, 0xae, 0xc4, 0x00, 0x7e -}; - -static const unsigned int ld9040_22_150[] = { - 0x00, 0x82, 0xba, 0xb4, 0xc7, 0x00, 0x5f, - 0x00, 0xb5, 0xba, 0xb0, 0xc3, 0x00, 0x72, - 0x00, 0xae, 0xb8, 0xb0, 0xc3, 0x00, 0x7a -}; - -static const unsigned int ld9040_22_140[] = { - 0x00, 0x7b, 0xbb, 0xb4, 0xc8, 0x00, 0x5b, - 0x00, 0xb5, 0xba, 0xb1, 0xc4, 0x00, 0x6e, - 0x00, 0xae, 0xb9, 0xb0, 0xc5, 0x00, 0x75 -}; - -static const unsigned int ld9040_22_130[] = { - 0x00, 0x71, 0xbb, 0xb5, 0xc8, 0x00, 0x57, - 0x00, 0xb5, 0xbb, 0xb0, 0xc5, 0x00, 0x6a, - 0x00, 0xae, 0xb9, 0xb1, 0xc6, 0x00, 0x70 -}; - -static const unsigned int ld9040_22_120[] = { - 0x00, 0x47, 0xba, 0xb6, 0xca, 0x00, 0x53, - 0x00, 0xb5, 0xbb, 0xb3, 0xc6, 0x00, 0x65, - 0x00, 0xae, 0xb8, 0xb3, 0xc7, 0x00, 0x6c -}; - -static const unsigned int ld9040_22_110[] = { - 0x00, 0x13, 0xbb, 0xb7, 0xca, 0x00, 0x4f, - 0x00, 0xb4, 0xbb, 0xb3, 0xc7, 0x00, 0x60, - 0x00, 0xad, 0xb8, 0xb4, 0xc7, 0x00, 0x67 -}; - -static const unsigned int ld9040_22_100[] = { - 0x00, 0x13, 0xba, 0xb8, 0xcb, 0x00, 0x4b, - 0x00, 0xb3, 0xbc, 0xb4, 0xc7, 0x00, 0x5c, - 0x00, 0xac, 0xb8, 0xb4, 0xc8, 0x00, 0x62 -}; - -static const unsigned int ld9040_22_90[] = { - 0x00, 0x13, 0xb9, 0xb8, 0xcd, 0x00, 0x46, - 0x00, 0xb1, 0xbc, 0xb5, 0xc8, 0x00, 0x56, - 0x00, 0xaa, 0xb8, 0xb4, 0xc9, 0x00, 0x5d -}; - -static const unsigned int ld9040_22_80[] = { - 0x00, 0x13, 0xba, 0xb9, 0xcd, 0x00, 0x41, - 0x00, 0xb0, 0xbe, 0xb5, 0xc9, 0x00, 0x51, - 0x00, 0xa9, 0xb9, 0xb5, 0xca, 0x00, 0x57 -}; - -static const unsigned int ld9040_22_70[] = { - 0x00, 0x13, 0xb9, 0xb9, 0xd0, 0x00, 0x3c, - 0x00, 0xaf, 0xbf, 0xb6, 0xcb, 0x00, 0x4b, - 0x00, 0xa8, 0xb9, 0xb5, 0xcc, 0x00, 0x52 -}; - -static const unsigned int ld9040_22_50[] = { - 0x00, 0x13, 0xb2, 0xba, 0xd2, 0x00, 0x30, - 0x00, 0xaf, 0xc0, 0xb8, 0xcd, 0x00, 0x3d, - 0x00, 0xa8, 0xb8, 0xb7, 0xcd, 0x00, 0x44 -}; - -struct ld9040_gamma { - unsigned int *gamma_22_table[MAX_GAMMA_LEVEL]; -}; - -static struct ld9040_gamma gamma_table = { - .gamma_22_table[0] = (unsigned int *)&ld9040_22_50, - .gamma_22_table[1] = (unsigned int *)&ld9040_22_70, - .gamma_22_table[2] = (unsigned int *)&ld9040_22_80, - .gamma_22_table[3] = (unsigned int *)&ld9040_22_90, - .gamma_22_table[4] = (unsigned int *)&ld9040_22_100, - .gamma_22_table[5] = (unsigned int *)&ld9040_22_110, - .gamma_22_table[6] = (unsigned int *)&ld9040_22_120, - .gamma_22_table[7] = (unsigned int *)&ld9040_22_130, - .gamma_22_table[8] = (unsigned int *)&ld9040_22_140, - .gamma_22_table[9] = (unsigned int *)&ld9040_22_150, - .gamma_22_table[10] = (unsigned int *)&ld9040_22_160, - .gamma_22_table[11] = (unsigned int *)&ld9040_22_170, - .gamma_22_table[12] = (unsigned int *)&ld9040_22_180, - .gamma_22_table[13] = (unsigned int *)&ld9040_22_190, - .gamma_22_table[14] = (unsigned int *)&ld9040_22_200, - .gamma_22_table[15] = (unsigned int *)&ld9040_22_210, - .gamma_22_table[16] = (unsigned int *)&ld9040_22_220, - .gamma_22_table[17] = (unsigned int *)&ld9040_22_230, - .gamma_22_table[18] = (unsigned int *)&ld9040_22_240, - .gamma_22_table[19] = (unsigned int *)&ld9040_22_250, - .gamma_22_table[20] = (unsigned int *)&ld9040_22_260, - .gamma_22_table[21] = (unsigned int *)&ld9040_22_270, - .gamma_22_table[22] = (unsigned int *)&ld9040_22_280, - .gamma_22_table[23] = (unsigned int *)&ld9040_22_290, - .gamma_22_table[24] = (unsigned int *)&ld9040_22_300, -}; - -#endif diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c index cd50df5807ea..086611c7bc03 100644 --- a/drivers/video/backlight/lm3639_bl.c +++ b/drivers/video/backlight/lm3639_bl.c @@ -400,10 +400,8 @@ static int lm3639_remove(struct i2c_client *client) regmap_write(pchip->regmap, REG_ENABLE, 0x00); - if (&pchip->cdev_torch) - led_classdev_unregister(&pchip->cdev_torch); - if (&pchip->cdev_flash) - led_classdev_unregister(&pchip->cdev_flash); + led_classdev_unregister(&pchip->cdev_torch); + led_classdev_unregister(&pchip->cdev_flash); if (pchip->bled) device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); return 0; diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index bdfcc0a71db1..678b27063198 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -28,10 +28,8 @@ struct pwm_bl_data { struct pwm_device *pwm; struct device *dev; - unsigned int period; unsigned int lth_brightness; unsigned int *levels; - bool enabled; struct regulator *power_supply; struct gpio_desc *enable_gpio; unsigned int scale; @@ -46,31 +44,35 @@ struct pwm_bl_data { void (*exit)(struct device *); }; -static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness) +static void pwm_backlight_power_on(struct pwm_bl_data *pb) { + struct pwm_state state; int err; - if (pb->enabled) + pwm_get_state(pb->pwm, &state); + if (state.enabled) return; err = regulator_enable(pb->power_supply); if (err < 0) dev_err(pb->dev, "failed to enable power supply\n"); - pwm_enable(pb->pwm); + state.enabled = true; + pwm_apply_state(pb->pwm, &state); if (pb->post_pwm_on_delay) msleep(pb->post_pwm_on_delay); if (pb->enable_gpio) gpiod_set_value_cansleep(pb->enable_gpio, 1); - - pb->enabled = true; } static void pwm_backlight_power_off(struct pwm_bl_data *pb) { - if (!pb->enabled) + struct pwm_state state; + + pwm_get_state(pb->pwm, &state); + if (!state.enabled) return; if (pb->enable_gpio) @@ -79,24 +81,27 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) if (pb->pwm_off_delay) msleep(pb->pwm_off_delay); - pwm_config(pb->pwm, 0, pb->period); - pwm_disable(pb->pwm); + state.enabled = false; + state.duty_cycle = 0; + pwm_apply_state(pb->pwm, &state); regulator_disable(pb->power_supply); - pb->enabled = false; } static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) { unsigned int lth = pb->lth_brightness; + struct pwm_state state; u64 duty_cycle; + pwm_get_state(pb->pwm, &state); + if (pb->levels) duty_cycle = pb->levels[brightness]; else duty_cycle = brightness; - duty_cycle *= pb->period - lth; + duty_cycle *= state.period - lth; do_div(duty_cycle, pb->scale); return duty_cycle + lth; @@ -106,7 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl) { struct pwm_bl_data *pb = bl_get_data(bl); int brightness = bl->props.brightness; - int duty_cycle; + struct pwm_state state; if (bl->props.power != FB_BLANK_UNBLANK || bl->props.fb_blank != FB_BLANK_UNBLANK || @@ -117,9 +122,10 @@ static int pwm_backlight_update_status(struct backlight_device *bl) brightness = pb->notify(pb->dev, brightness); if (brightness > 0) { - duty_cycle = compute_duty_cycle(pb, brightness); - pwm_config(pb->pwm, duty_cycle, pb->period); - pwm_backlight_power_on(pb, brightness); + pwm_get_state(pb->pwm, &state); + state.duty_cycle = compute_duty_cycle(pb, brightness); + pwm_apply_state(pb->pwm, &state); + pwm_backlight_power_on(pb); } else pwm_backlight_power_off(pb); @@ -447,7 +453,6 @@ static int pwm_backlight_probe(struct platform_device *pdev) struct device_node *node = pdev->dev.of_node; struct pwm_bl_data *pb; struct pwm_state state; - struct pwm_args pargs; unsigned int i; int ret; @@ -478,7 +483,6 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->check_fb = data->check_fb; pb->exit = data->exit; pb->dev = &pdev->dev; - pb->enabled = false; pb->post_pwm_on_delay = data->post_pwm_on_delay; pb->pwm_off_delay = data->pwm_off_delay; @@ -539,10 +543,26 @@ static int pwm_backlight_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "got pwm for backlight\n"); - if (!data->levels) { - /* Get the PWM period (in nanoseconds) */ - pwm_get_state(pb->pwm, &state); + /* Sync up PWM state. */ + pwm_init_state(pb->pwm, &state); + /* + * The DT case will set the pwm_period_ns field to 0 and store the + * period, parsed from the DT, in the PWM device. For the non-DT case, + * set the period from platform data if it has not already been set + * via the PWM lookup table. + */ + if (!state.period && (data->pwm_period_ns > 0)) + state.period = data->pwm_period_ns; + + ret = pwm_apply_state(pb->pwm, &state); + if (ret) { + dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n", + ret); + goto err_alloc; + } + + if (!data->levels) { ret = pwm_backlight_brightness_default(&pdev->dev, data, state.period); if (ret < 0) { @@ -559,24 +579,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->levels = data->levels; } - /* - * FIXME: pwm_apply_args() should be removed when switching to - * the atomic PWM API. - */ - pwm_apply_args(pb->pwm); - - /* - * The DT case will set the pwm_period_ns field to 0 and store the - * period, parsed from the DT, in the PWM device. For the non-DT case, - * set the period from platform data if it has not already been set - * via the PWM lookup table. - */ - pwm_get_args(pb->pwm, &pargs); - pb->period = pargs.period; - if (!pb->period && (data->pwm_period_ns > 0)) - pb->period = data->pwm_period_ns; - - pb->lth_brightness = data->lth_brightness * (pb->period / pb->scale); + pb->lth_brightness = data->lth_brightness * (state.period / pb->scale); memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c deleted file mode 100644 index 3c4a22a3063a..000000000000 --- a/drivers/video/backlight/s6e63m0.c +++ /dev/null @@ -1,857 +0,0 @@ -/* - * S6E63M0 AMOLED LCD panel driver. - * - * Author: InKi Dae <inki.dae@samsung.com> - * - * Derived from drivers/video/omap/lcd-apollon.c - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include <linux/backlight.h> -#include <linux/delay.h> -#include <linux/fb.h> -#include <linux/gpio.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/kernel.h> -#include <linux/lcd.h> -#include <linux/module.h> -#include <linux/spi/spi.h> -#include <linux/wait.h> - -#include "s6e63m0_gamma.h" - -#define SLEEPMSEC 0x1000 -#define ENDDEF 0x2000 -#define DEFMASK 0xFF00 -#define COMMAND_ONLY 0xFE -#define DATA_ONLY 0xFF - -#define MIN_BRIGHTNESS 0 -#define MAX_BRIGHTNESS 10 - -struct s6e63m0 { - struct device *dev; - struct spi_device *spi; - unsigned int power; - unsigned int current_brightness; - unsigned int gamma_mode; - unsigned int gamma_table_count; - struct lcd_device *ld; - struct backlight_device *bd; - struct lcd_platform_data *lcd_pd; -}; - -static const unsigned short seq_panel_condition_set[] = { - 0xF8, 0x01, - DATA_ONLY, 0x27, - DATA_ONLY, 0x27, - DATA_ONLY, 0x07, - DATA_ONLY, 0x07, - DATA_ONLY, 0x54, - DATA_ONLY, 0x9f, - DATA_ONLY, 0x63, - DATA_ONLY, 0x86, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x33, - DATA_ONLY, 0x0d, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_display_condition_set[] = { - 0xf2, 0x02, - DATA_ONLY, 0x03, - DATA_ONLY, 0x1c, - DATA_ONLY, 0x10, - DATA_ONLY, 0x10, - - 0xf7, 0x03, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_gamma_setting[] = { - 0xfa, 0x00, - DATA_ONLY, 0x18, - DATA_ONLY, 0x08, - DATA_ONLY, 0x24, - DATA_ONLY, 0x64, - DATA_ONLY, 0x56, - DATA_ONLY, 0x33, - DATA_ONLY, 0xb6, - DATA_ONLY, 0xba, - DATA_ONLY, 0xa8, - DATA_ONLY, 0xac, - DATA_ONLY, 0xb1, - DATA_ONLY, 0x9d, - DATA_ONLY, 0xc1, - DATA_ONLY, 0xc1, - DATA_ONLY, 0xb7, - DATA_ONLY, 0x00, - DATA_ONLY, 0x9c, - DATA_ONLY, 0x00, - DATA_ONLY, 0x9f, - DATA_ONLY, 0x00, - DATA_ONLY, 0xd6, - - 0xfa, 0x01, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_etc_condition_set[] = { - 0xf6, 0x00, - DATA_ONLY, 0x8c, - DATA_ONLY, 0x07, - - 0xb3, 0xc, - - 0xb5, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xb6, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xb7, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xb8, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xb9, 0x2c, - DATA_ONLY, 0x12, - DATA_ONLY, 0x0c, - DATA_ONLY, 0x0a, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0e, - DATA_ONLY, 0x17, - DATA_ONLY, 0x13, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x2a, - DATA_ONLY, 0x24, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x1b, - DATA_ONLY, 0x1a, - DATA_ONLY, 0x17, - - DATA_ONLY, 0x2b, - DATA_ONLY, 0x26, - DATA_ONLY, 0x22, - DATA_ONLY, 0x20, - DATA_ONLY, 0x3a, - DATA_ONLY, 0x34, - DATA_ONLY, 0x30, - DATA_ONLY, 0x2c, - DATA_ONLY, 0x29, - DATA_ONLY, 0x26, - DATA_ONLY, 0x25, - DATA_ONLY, 0x23, - DATA_ONLY, 0x21, - DATA_ONLY, 0x20, - DATA_ONLY, 0x1e, - DATA_ONLY, 0x1e, - - 0xba, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x11, - DATA_ONLY, 0x22, - DATA_ONLY, 0x33, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - DATA_ONLY, 0x44, - - DATA_ONLY, 0x55, - DATA_ONLY, 0x55, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - DATA_ONLY, 0x66, - - 0xc1, 0x4d, - DATA_ONLY, 0x96, - DATA_ONLY, 0x1d, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x01, - DATA_ONLY, 0xdf, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - DATA_ONLY, 0x1f, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x00, - DATA_ONLY, 0x03, - DATA_ONLY, 0x06, - DATA_ONLY, 0x09, - DATA_ONLY, 0x0d, - DATA_ONLY, 0x0f, - DATA_ONLY, 0x12, - DATA_ONLY, 0x15, - DATA_ONLY, 0x18, - - 0xb2, 0x10, - DATA_ONLY, 0x10, - DATA_ONLY, 0x0b, - DATA_ONLY, 0x05, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_acl_on[] = { - /* ACL on */ - 0xc0, 0x01, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_acl_off[] = { - /* ACL off */ - 0xc0, 0x00, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_elvss_on[] = { - /* ELVSS on */ - 0xb1, 0x0b, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_elvss_off[] = { - /* ELVSS off */ - 0xb1, 0x0a, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_stand_by_off[] = { - 0x11, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_stand_by_on[] = { - 0x10, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - -static const unsigned short seq_display_on[] = { - 0x29, COMMAND_ONLY, - - ENDDEF, 0x0000 -}; - - -static int s6e63m0_spi_write_byte(struct s6e63m0 *lcd, int addr, int data) -{ - u16 buf[1]; - struct spi_message msg; - - struct spi_transfer xfer = { - .len = 2, - .tx_buf = buf, - }; - - buf[0] = (addr << 8) | data; - - spi_message_init(&msg); - spi_message_add_tail(&xfer, &msg); - - return spi_sync(lcd->spi, &msg); -} - -static int s6e63m0_spi_write(struct s6e63m0 *lcd, unsigned char address, - unsigned char command) -{ - int ret = 0; - - if (address != DATA_ONLY) - ret = s6e63m0_spi_write_byte(lcd, 0x0, address); - if (command != COMMAND_ONLY) - ret = s6e63m0_spi_write_byte(lcd, 0x1, command); - - return ret; -} - -static int s6e63m0_panel_send_sequence(struct s6e63m0 *lcd, - const unsigned short *wbuf) -{ - int ret = 0, i = 0; - - while ((wbuf[i] & DEFMASK) != ENDDEF) { - if ((wbuf[i] & DEFMASK) != SLEEPMSEC) { - ret = s6e63m0_spi_write(lcd, wbuf[i], wbuf[i+1]); - if (ret) - break; - } else { - msleep(wbuf[i+1]); - } - i += 2; - } - - return ret; -} - -static int _s6e63m0_gamma_ctl(struct s6e63m0 *lcd, const unsigned int *gamma) -{ - unsigned int i = 0; - int ret = 0; - - /* disable gamma table updating. */ - ret = s6e63m0_spi_write(lcd, 0xfa, 0x00); - if (ret) { - dev_err(lcd->dev, "failed to disable gamma table updating.\n"); - goto gamma_err; - } - - for (i = 0 ; i < GAMMA_TABLE_COUNT; i++) { - ret = s6e63m0_spi_write(lcd, DATA_ONLY, gamma[i]); - if (ret) { - dev_err(lcd->dev, "failed to set gamma table.\n"); - goto gamma_err; - } - } - - /* update gamma table. */ - ret = s6e63m0_spi_write(lcd, 0xfa, 0x01); - if (ret) - dev_err(lcd->dev, "failed to update gamma table.\n"); - -gamma_err: - return ret; -} - -static int s6e63m0_gamma_ctl(struct s6e63m0 *lcd, int gamma) -{ - int ret = 0; - - ret = _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[gamma]); - - return ret; -} - - -static int s6e63m0_ldi_init(struct s6e63m0 *lcd) -{ - int ret, i; - const unsigned short *init_seq[] = { - seq_panel_condition_set, - seq_display_condition_set, - seq_gamma_setting, - seq_etc_condition_set, - seq_acl_on, - seq_elvss_on, - }; - - for (i = 0; i < ARRAY_SIZE(init_seq); i++) { - ret = s6e63m0_panel_send_sequence(lcd, init_seq[i]); - if (ret) - break; - } - - return ret; -} - -static int s6e63m0_ldi_enable(struct s6e63m0 *lcd) -{ - int ret = 0, i; - const unsigned short *enable_seq[] = { - seq_stand_by_off, - seq_display_on, - }; - - for (i = 0; i < ARRAY_SIZE(enable_seq); i++) { - ret = s6e63m0_panel_send_sequence(lcd, enable_seq[i]); - if (ret) - break; - } - - return ret; -} - -static int s6e63m0_ldi_disable(struct s6e63m0 *lcd) -{ - int ret; - - ret = s6e63m0_panel_send_sequence(lcd, seq_stand_by_on); - - return ret; -} - -static int s6e63m0_power_is_on(int power) -{ - return power <= FB_BLANK_NORMAL; -} - -static int s6e63m0_power_on(struct s6e63m0 *lcd) -{ - int ret = 0; - struct lcd_platform_data *pd; - struct backlight_device *bd; - - pd = lcd->lcd_pd; - bd = lcd->bd; - - if (!pd->power_on) { - dev_err(lcd->dev, "power_on is NULL.\n"); - return -EINVAL; - } - - pd->power_on(lcd->ld, 1); - msleep(pd->power_on_delay); - - if (!pd->reset) { - dev_err(lcd->dev, "reset is NULL.\n"); - return -EINVAL; - } - - pd->reset(lcd->ld); - msleep(pd->reset_delay); - - ret = s6e63m0_ldi_init(lcd); - if (ret) { - dev_err(lcd->dev, "failed to initialize ldi.\n"); - return ret; - } - - ret = s6e63m0_ldi_enable(lcd); - if (ret) { - dev_err(lcd->dev, "failed to enable ldi.\n"); - return ret; - } - - /* set brightness to current value after power on or resume. */ - ret = s6e63m0_gamma_ctl(lcd, bd->props.brightness); - if (ret) { - dev_err(lcd->dev, "lcd gamma setting failed.\n"); - return ret; - } - - return 0; -} - -static int s6e63m0_power_off(struct s6e63m0 *lcd) -{ - int ret; - struct lcd_platform_data *pd; - - pd = lcd->lcd_pd; - - ret = s6e63m0_ldi_disable(lcd); - if (ret) { - dev_err(lcd->dev, "lcd setting failed.\n"); - return -EIO; - } - - msleep(pd->power_off_delay); - - pd->power_on(lcd->ld, 0); - - return 0; -} - -static int s6e63m0_power(struct s6e63m0 *lcd, int power) -{ - int ret = 0; - - if (s6e63m0_power_is_on(power) && !s6e63m0_power_is_on(lcd->power)) - ret = s6e63m0_power_on(lcd); - else if (!s6e63m0_power_is_on(power) && s6e63m0_power_is_on(lcd->power)) - ret = s6e63m0_power_off(lcd); - - if (!ret) - lcd->power = power; - - return ret; -} - -static int s6e63m0_set_power(struct lcd_device *ld, int power) -{ - struct s6e63m0 *lcd = lcd_get_data(ld); - - if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN && - power != FB_BLANK_NORMAL) { - dev_err(lcd->dev, "power value should be 0, 1 or 4.\n"); - return -EINVAL; - } - - return s6e63m0_power(lcd, power); -} - -static int s6e63m0_get_power(struct lcd_device *ld) -{ - struct s6e63m0 *lcd = lcd_get_data(ld); - - return lcd->power; -} - -static int s6e63m0_set_brightness(struct backlight_device *bd) -{ - int ret = 0, brightness = bd->props.brightness; - struct s6e63m0 *lcd = bl_get_data(bd); - - if (brightness < MIN_BRIGHTNESS || - brightness > bd->props.max_brightness) { - dev_err(&bd->dev, "lcd brightness should be %d to %d.\n", - MIN_BRIGHTNESS, MAX_BRIGHTNESS); - return -EINVAL; - } - - ret = s6e63m0_gamma_ctl(lcd, bd->props.brightness); - if (ret) { - dev_err(&bd->dev, "lcd brightness setting failed.\n"); - return -EIO; - } - - return ret; -} - -static struct lcd_ops s6e63m0_lcd_ops = { - .set_power = s6e63m0_set_power, - .get_power = s6e63m0_get_power, -}; - -static const struct backlight_ops s6e63m0_backlight_ops = { - .update_status = s6e63m0_set_brightness, -}; - -static ssize_t s6e63m0_sysfs_show_gamma_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - char temp[10]; - - switch (lcd->gamma_mode) { - case 0: - sprintf(temp, "2.2 mode\n"); - strcat(buf, temp); - break; - case 1: - sprintf(temp, "1.9 mode\n"); - strcat(buf, temp); - break; - case 2: - sprintf(temp, "1.7 mode\n"); - strcat(buf, temp); - break; - default: - dev_info(dev, "gamma mode could be 0:2.2, 1:1.9 or 2:1.7)n"); - break; - } - - return strlen(buf); -} - -static ssize_t s6e63m0_sysfs_store_gamma_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - struct backlight_device *bd = NULL; - int brightness, rc; - - rc = kstrtouint(buf, 0, &lcd->gamma_mode); - if (rc < 0) - return rc; - - bd = lcd->bd; - - brightness = bd->props.brightness; - - switch (lcd->gamma_mode) { - case 0: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[brightness]); - break; - case 1: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_19_table[brightness]); - break; - case 2: - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_17_table[brightness]); - break; - default: - dev_info(dev, "gamma mode could be 0:2.2, 1:1.9 or 2:1.7\n"); - _s6e63m0_gamma_ctl(lcd, gamma_table.gamma_22_table[brightness]); - break; - } - return len; -} - -static DEVICE_ATTR(gamma_mode, 0644, - s6e63m0_sysfs_show_gamma_mode, s6e63m0_sysfs_store_gamma_mode); - -static ssize_t s6e63m0_sysfs_show_gamma_table(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - char temp[3]; - - sprintf(temp, "%u\n", lcd->gamma_table_count); - strcpy(buf, temp); - - return strlen(buf); -} -static DEVICE_ATTR(gamma_table, 0444, - s6e63m0_sysfs_show_gamma_table, NULL); - -static int s6e63m0_probe(struct spi_device *spi) -{ - int ret = 0; - struct s6e63m0 *lcd = NULL; - struct lcd_device *ld = NULL; - struct backlight_device *bd = NULL; - struct backlight_properties props; - - lcd = devm_kzalloc(&spi->dev, sizeof(struct s6e63m0), GFP_KERNEL); - if (!lcd) - return -ENOMEM; - - /* s6e63m0 lcd panel uses 3-wire 9bits SPI Mode. */ - spi->bits_per_word = 9; - - ret = spi_setup(spi); - if (ret < 0) { - dev_err(&spi->dev, "spi setup failed.\n"); - return ret; - } - - lcd->spi = spi; - lcd->dev = &spi->dev; - - lcd->lcd_pd = dev_get_platdata(&spi->dev); - if (!lcd->lcd_pd) { - dev_err(&spi->dev, "platform data is NULL.\n"); - return -EINVAL; - } - - ld = devm_lcd_device_register(&spi->dev, "s6e63m0", &spi->dev, lcd, - &s6e63m0_lcd_ops); - if (IS_ERR(ld)) - return PTR_ERR(ld); - - lcd->ld = ld; - - memset(&props, 0, sizeof(struct backlight_properties)); - props.type = BACKLIGHT_RAW; - props.max_brightness = MAX_BRIGHTNESS; - - bd = devm_backlight_device_register(&spi->dev, "s6e63m0bl-bl", - &spi->dev, lcd, &s6e63m0_backlight_ops, - &props); - if (IS_ERR(bd)) - return PTR_ERR(bd); - - bd->props.brightness = MAX_BRIGHTNESS; - lcd->bd = bd; - - /* - * it gets gamma table count available so it gets user - * know that. - */ - lcd->gamma_table_count = - sizeof(gamma_table) / (MAX_GAMMA_LEVEL * sizeof(int *)); - - ret = device_create_file(&(spi->dev), &dev_attr_gamma_mode); - if (ret < 0) - dev_err(&(spi->dev), "failed to add sysfs entries\n"); - - ret = device_create_file(&(spi->dev), &dev_attr_gamma_table); - if (ret < 0) - dev_err(&(spi->dev), "failed to add sysfs entries\n"); - - /* - * if lcd panel was on from bootloader like u-boot then - * do not lcd on. - */ - if (!lcd->lcd_pd->lcd_enabled) { - /* - * if lcd panel was off from bootloader then - * current lcd status is powerdown and then - * it enables lcd panel. - */ - lcd->power = FB_BLANK_POWERDOWN; - - s6e63m0_power(lcd, FB_BLANK_UNBLANK); - } else { - lcd->power = FB_BLANK_UNBLANK; - } - - spi_set_drvdata(spi, lcd); - - dev_info(&spi->dev, "s6e63m0 panel driver has been probed.\n"); - - return 0; -} - -static int s6e63m0_remove(struct spi_device *spi) -{ - struct s6e63m0 *lcd = spi_get_drvdata(spi); - - s6e63m0_power(lcd, FB_BLANK_POWERDOWN); - device_remove_file(&spi->dev, &dev_attr_gamma_table); - device_remove_file(&spi->dev, &dev_attr_gamma_mode); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int s6e63m0_suspend(struct device *dev) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - - dev_dbg(dev, "lcd->power = %d\n", lcd->power); - - /* - * when lcd panel is suspend, lcd panel becomes off - * regardless of status. - */ - return s6e63m0_power(lcd, FB_BLANK_POWERDOWN); -} - -static int s6e63m0_resume(struct device *dev) -{ - struct s6e63m0 *lcd = dev_get_drvdata(dev); - - lcd->power = FB_BLANK_POWERDOWN; - - return s6e63m0_power(lcd, FB_BLANK_UNBLANK); -} -#endif - -static SIMPLE_DEV_PM_OPS(s6e63m0_pm_ops, s6e63m0_suspend, s6e63m0_resume); - -/* Power down all displays on reboot, poweroff or halt. */ -static void s6e63m0_shutdown(struct spi_device *spi) -{ - struct s6e63m0 *lcd = spi_get_drvdata(spi); - - s6e63m0_power(lcd, FB_BLANK_POWERDOWN); -} - -static struct spi_driver s6e63m0_driver = { - .driver = { - .name = "s6e63m0", - .pm = &s6e63m0_pm_ops, - }, - .probe = s6e63m0_probe, - .remove = s6e63m0_remove, - .shutdown = s6e63m0_shutdown, -}; - -module_spi_driver(s6e63m0_driver); - -MODULE_AUTHOR("InKi Dae <inki.dae@samsung.com>"); -MODULE_DESCRIPTION("S6E63M0 LCD Driver"); -MODULE_LICENSE("GPL"); - diff --git a/drivers/video/backlight/s6e63m0_gamma.h b/drivers/video/backlight/s6e63m0_gamma.h deleted file mode 100644 index 2c44bdb0696b..000000000000 --- a/drivers/video/backlight/s6e63m0_gamma.h +++ /dev/null @@ -1,266 +0,0 @@ -/* linux/drivers/video/samsung/s6e63m0_brightness.h - * - * Gamma level definitions. - * - * Copyright (c) 2009 Samsung Electronics - * InKi Dae <inki.dae@samsung.com> - * - * 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. -*/ - -#ifndef _S6E63M0_BRIGHTNESS_H -#define _S6E63M0_BRIGHTNESS_H - -#define MAX_GAMMA_LEVEL 11 -#define GAMMA_TABLE_COUNT 21 - -/* gamma value: 2.2 */ -static const unsigned int s6e63m0_22_300[] = { - 0x18, 0x08, 0x24, 0x5f, 0x50, 0x2d, 0xB6, - 0xB9, 0xA7, 0xAd, 0xB1, 0x9f, 0xbe, 0xC0, - 0xB5, 0x00, 0xa0, 0x00, 0xa4, 0x00, 0xdb -}; - -static const unsigned int s6e63m0_22_280[] = { - 0x18, 0x08, 0x24, 0x64, 0x56, 0x33, 0xB6, - 0xBA, 0xA8, 0xAC, 0xB1, 0x9D, 0xC1, 0xC1, - 0xB7, 0x00, 0x9C, 0x00, 0x9F, 0x00, 0xD6 -}; - -static const unsigned int s6e63m0_22_260[] = { - 0x18, 0x08, 0x24, 0x66, 0x58, 0x34, 0xB6, - 0xBA, 0xA7, 0xAF, 0xB3, 0xA0, 0xC1, 0xC2, - 0xB7, 0x00, 0x97, 0x00, 0x9A, 0x00, 0xD1 - -}; - -static const unsigned int s6e63m0_22_240[] = { - 0x18, 0x08, 0x24, 0x62, 0x54, 0x30, 0xB9, - 0xBB, 0xA9, 0xB0, 0xB3, 0xA1, 0xC1, 0xC3, - 0xB7, 0x00, 0x91, 0x00, 0x95, 0x00, 0xDA - -}; -static const unsigned int s6e63m0_22_220[] = { - 0x18, 0x08, 0x24, 0x63, 0x53, 0x31, 0xB8, - 0xBC, 0xA9, 0xB0, 0xB5, 0xA2, 0xC4, 0xC4, - 0xB8, 0x00, 0x8B, 0x00, 0x8E, 0x00, 0xC2 -}; - -static const unsigned int s6e63m0_22_200[] = { - 0x18, 0x08, 0x24, 0x66, 0x55, 0x34, 0xBA, - 0xBD, 0xAB, 0xB1, 0xB5, 0xA3, 0xC5, 0xC6, - 0xB9, 0x00, 0x85, 0x00, 0x88, 0x00, 0xBA -}; - -static const unsigned int s6e63m0_22_170[] = { - 0x18, 0x08, 0x24, 0x69, 0x54, 0x37, 0xBB, - 0xBE, 0xAC, 0xB4, 0xB7, 0xA6, 0xC7, 0xC8, - 0xBC, 0x00, 0x7B, 0x00, 0x7E, 0x00, 0xAB -}; - -static const unsigned int s6e63m0_22_140[] = { - 0x18, 0x08, 0x24, 0x6C, 0x54, 0x3A, 0xBC, - 0xBF, 0xAC, 0xB7, 0xBB, 0xA9, 0xC9, 0xC9, - 0xBE, 0x00, 0x71, 0x00, 0x73, 0x00, 0x9E -}; - -static const unsigned int s6e63m0_22_110[] = { - 0x18, 0x08, 0x24, 0x70, 0x51, 0x3E, 0xBF, - 0xC1, 0xAF, 0xB9, 0xBC, 0xAB, 0xCC, 0xCC, - 0xC2, 0x00, 0x65, 0x00, 0x67, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_22_90[] = { - 0x18, 0x08, 0x24, 0x73, 0x4A, 0x3D, 0xC0, - 0xC2, 0xB1, 0xBB, 0xBE, 0xAC, 0xCE, 0xCF, - 0xC5, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x82 -}; - -static const unsigned int s6e63m0_22_30[] = { - 0x18, 0x08, 0x24, 0x78, 0xEC, 0x3D, 0xC8, - 0xC2, 0xB6, 0xC4, 0xC7, 0xB6, 0xD5, 0xD7, - 0xCC, 0x00, 0x39, 0x00, 0x36, 0x00, 0x51 -}; - -/* gamma value: 1.9 */ -static const unsigned int s6e63m0_19_300[] = { - 0x18, 0x08, 0x24, 0x61, 0x5F, 0x39, 0xBA, - 0xBD, 0xAD, 0xB1, 0xB6, 0xA5, 0xC4, 0xC5, - 0xBC, 0x00, 0xA0, 0x00, 0xA4, 0x00, 0xDB -}; - -static const unsigned int s6e63m0_19_280[] = { - 0x18, 0x08, 0x24, 0x61, 0x60, 0x39, 0xBB, - 0xBE, 0xAD, 0xB2, 0xB6, 0xA6, 0xC5, 0xC7, - 0xBD, 0x00, 0x9B, 0x00, 0x9E, 0x00, 0xD5 -}; - -static const unsigned int s6e63m0_19_260[] = { - 0x18, 0x08, 0x24, 0x63, 0x61, 0x3B, 0xBA, - 0xBE, 0xAC, 0xB3, 0xB8, 0xA7, 0xC6, 0xC8, - 0xBD, 0x00, 0x96, 0x00, 0x98, 0x00, 0xCF -}; - -static const unsigned int s6e63m0_19_240[] = { - 0x18, 0x08, 0x24, 0x67, 0x64, 0x3F, 0xBB, - 0xBE, 0xAD, 0xB3, 0xB9, 0xA7, 0xC8, 0xC9, - 0xBE, 0x00, 0x90, 0x00, 0x92, 0x00, 0xC8 -}; - -static const unsigned int s6e63m0_19_220[] = { - 0x18, 0x08, 0x24, 0x68, 0x64, 0x40, 0xBC, - 0xBF, 0xAF, 0xB4, 0xBA, 0xA9, 0xC8, 0xCA, - 0xBE, 0x00, 0x8B, 0x00, 0x8C, 0x00, 0xC0 -}; - -static const unsigned int s6e63m0_19_200[] = { - 0x18, 0x08, 0x24, 0x68, 0x64, 0x3F, 0xBE, - 0xC0, 0xB0, 0xB6, 0xBB, 0xAB, 0xC8, 0xCB, - 0xBF, 0x00, 0x85, 0x00, 0x86, 0x00, 0xB8 -}; - -static const unsigned int s6e63m0_19_170[] = { - 0x18, 0x08, 0x24, 0x69, 0x64, 0x40, 0xBF, - 0xC1, 0xB0, 0xB9, 0xBE, 0xAD, 0xCB, 0xCD, - 0xC2, 0x00, 0x7A, 0x00, 0x7B, 0x00, 0xAA -}; - -static const unsigned int s6e63m0_19_140[] = { - 0x18, 0x08, 0x24, 0x6E, 0x65, 0x45, 0xC0, - 0xC3, 0xB2, 0xBA, 0xBE, 0xAE, 0xCD, 0xD0, - 0xC4, 0x00, 0x70, 0x00, 0x70, 0x00, 0x9C -}; - -static const unsigned int s6e63m0_19_110[] = { - 0x18, 0x08, 0x24, 0x6F, 0x65, 0x46, 0xC2, - 0xC4, 0xB3, 0xBF, 0xC2, 0xB2, 0xCF, 0xD1, - 0xC6, 0x00, 0x64, 0x00, 0x64, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_19_90[] = { - 0x18, 0x08, 0x24, 0x74, 0x60, 0x4A, 0xC3, - 0xC6, 0xB5, 0xBF, 0xC3, 0xB2, 0xD2, 0xD3, - 0xC8, 0x00, 0x5B, 0x00, 0x5B, 0x00, 0x81 -}; - -static const unsigned int s6e63m0_19_30[] = { - 0x18, 0x08, 0x24, 0x84, 0x45, 0x4F, 0xCA, - 0xCB, 0xBC, 0xC9, 0xCB, 0xBC, 0xDA, 0xDA, - 0xD0, 0x00, 0x35, 0x00, 0x34, 0x00, 0x4E -}; - -/* gamma value: 1.7 */ -static const unsigned int s6e63m0_17_300[] = { - 0x18, 0x08, 0x24, 0x70, 0x70, 0x4F, 0xBF, - 0xC2, 0xB2, 0xB8, 0xBC, 0xAC, 0xCB, 0xCD, - 0xC3, 0x00, 0xA0, 0x00, 0xA4, 0x00, 0xDB -}; - -static const unsigned int s6e63m0_17_280[] = { - 0x18, 0x08, 0x24, 0x71, 0x71, 0x50, 0xBF, - 0xC2, 0xB2, 0xBA, 0xBE, 0xAE, 0xCB, 0xCD, - 0xC3, 0x00, 0x9C, 0x00, 0x9F, 0x00, 0xD6 -}; - -static const unsigned int s6e63m0_17_260[] = { - 0x18, 0x08, 0x24, 0x72, 0x72, 0x50, 0xC0, - 0xC3, 0xB4, 0xB9, 0xBE, 0xAE, 0xCC, 0xCF, - 0xC4, 0x00, 0x97, 0x00, 0x9A, 0x00, 0xD1 -}; - -static const unsigned int s6e63m0_17_240[] = { - 0x18, 0x08, 0x24, 0x71, 0x72, 0x4F, 0xC2, - 0xC4, 0xB5, 0xBB, 0xBF, 0xB0, 0xCC, 0xCF, - 0xC3, 0x00, 0x91, 0x00, 0x95, 0x00, 0xCA -}; - -static const unsigned int s6e63m0_17_220[] = { - 0x18, 0x08, 0x24, 0x71, 0x73, 0x4F, 0xC2, - 0xC5, 0xB5, 0xBD, 0xC0, 0xB2, 0xCD, 0xD1, - 0xC5, 0x00, 0x8B, 0x00, 0x8E, 0x00, 0xC2 -}; - -static const unsigned int s6e63m0_17_200[] = { - 0x18, 0x08, 0x24, 0x72, 0x75, 0x51, 0xC2, - 0xC6, 0xB5, 0xBF, 0xC1, 0xB3, 0xCE, 0xD1, - 0xC6, 0x00, 0x85, 0x00, 0x88, 0x00, 0xBA -}; - -static const unsigned int s6e63m0_17_170[] = { - 0x18, 0x08, 0x24, 0x75, 0x77, 0x54, 0xC3, - 0xC7, 0xB7, 0xC0, 0xC3, 0xB4, 0xD1, 0xD3, - 0xC9, 0x00, 0x7B, 0x00, 0x7E, 0x00, 0xAB -}; - -static const unsigned int s6e63m0_17_140[] = { - 0x18, 0x08, 0x24, 0x7B, 0x77, 0x58, 0xC3, - 0xC8, 0xB8, 0xC2, 0xC6, 0xB6, 0xD3, 0xD4, - 0xCA, 0x00, 0x71, 0x00, 0x73, 0x00, 0x9E -}; - -static const unsigned int s6e63m0_17_110[] = { - 0x18, 0x08, 0x24, 0x81, 0x7B, 0x5D, 0xC6, - 0xCA, 0xBB, 0xC3, 0xC7, 0xB8, 0xD6, 0xD8, - 0xCD, 0x00, 0x65, 0x00, 0x67, 0x00, 0x8D -}; - -static const unsigned int s6e63m0_17_90[] = { - 0x18, 0x08, 0x24, 0x82, 0x7A, 0x5B, 0xC8, - 0xCB, 0xBD, 0xC5, 0xCA, 0xBA, 0xD6, 0xD8, - 0xCE, 0x00, 0x5D, 0x00, 0x5E, 0x00, 0x82 -}; - -static const unsigned int s6e63m0_17_30[] = { - 0x18, 0x08, 0x24, 0x8F, 0x73, 0x63, 0xD1, - 0xD0, 0xC5, 0xCC, 0xD1, 0xC2, 0xDE, 0xE0, - 0xD6, 0x00, 0x39, 0x00, 0x36, 0x00, 0x51 -}; - -struct s6e63m0_gamma { - unsigned int *gamma_22_table[MAX_GAMMA_LEVEL]; - unsigned int *gamma_19_table[MAX_GAMMA_LEVEL]; - unsigned int *gamma_17_table[MAX_GAMMA_LEVEL]; -}; - -static struct s6e63m0_gamma gamma_table = { - .gamma_22_table[0] = (unsigned int *)&s6e63m0_22_30, - .gamma_22_table[1] = (unsigned int *)&s6e63m0_22_90, - .gamma_22_table[2] = (unsigned int *)&s6e63m0_22_110, - .gamma_22_table[3] = (unsigned int *)&s6e63m0_22_140, - .gamma_22_table[4] = (unsigned int *)&s6e63m0_22_170, - .gamma_22_table[5] = (unsigned int *)&s6e63m0_22_200, - .gamma_22_table[6] = (unsigned int *)&s6e63m0_22_220, - .gamma_22_table[7] = (unsigned int *)&s6e63m0_22_240, - .gamma_22_table[8] = (unsigned int *)&s6e63m0_22_260, - .gamma_22_table[9] = (unsigned int *)&s6e63m0_22_280, - .gamma_22_table[10] = (unsigned int *)&s6e63m0_22_300, - - .gamma_19_table[0] = (unsigned int *)&s6e63m0_19_30, - .gamma_19_table[1] = (unsigned int *)&s6e63m0_19_90, - .gamma_19_table[2] = (unsigned int *)&s6e63m0_19_110, - .gamma_19_table[3] = (unsigned int *)&s6e63m0_19_140, - .gamma_19_table[4] = (unsigned int *)&s6e63m0_19_170, - .gamma_19_table[5] = (unsigned int *)&s6e63m0_19_200, - .gamma_19_table[6] = (unsigned int *)&s6e63m0_19_220, - .gamma_19_table[7] = (unsigned int *)&s6e63m0_19_240, - .gamma_19_table[8] = (unsigned int *)&s6e63m0_19_260, - .gamma_19_table[9] = (unsigned int *)&s6e63m0_19_280, - .gamma_19_table[10] = (unsigned int *)&s6e63m0_19_300, - - .gamma_17_table[0] = (unsigned int *)&s6e63m0_17_30, - .gamma_17_table[1] = (unsigned int *)&s6e63m0_17_90, - .gamma_17_table[2] = (unsigned int *)&s6e63m0_17_110, - .gamma_17_table[3] = (unsigned int *)&s6e63m0_17_140, - .gamma_17_table[4] = (unsigned int *)&s6e63m0_17_170, - .gamma_17_table[5] = (unsigned int *)&s6e63m0_17_200, - .gamma_17_table[6] = (unsigned int *)&s6e63m0_17_220, - .gamma_17_table[7] = (unsigned int *)&s6e63m0_17_240, - .gamma_17_table[8] = (unsigned int *)&s6e63m0_17_260, - .gamma_17_table[9] = (unsigned int *)&s6e63m0_17_280, - .gamma_17_table[10] = (unsigned int *)&s6e63m0_17_300, -}; - -#endif - |