smart_mtp_se6e8fa: add gamma control

Change-Id: I068480f89ac941e887ea53bd93452862fea38c59
This commit is contained in:
franciscofranco 2014-07-05 13:13:54 -05:00 committed by invisiblek
parent b58710680d
commit 354aebb812
5 changed files with 460 additions and 30 deletions

View File

@ -753,6 +753,13 @@ config SEC_TORCH_FLASH
help
This driver provides torch flash function.
config GAMMA_CONTROL
bool "Gamma Control for OLED"
depends on FB_MSM_MIPI_DSI_SAMSUNG_OCTA
default y
help
This adds full support for shifting RGB panel colors.
config TIMA_LOG
tristate "Support for dumping TIMA log"
default m

View File

@ -88,3 +88,4 @@ obj-$(CONFIG_SLIMPORT_ANX7808) += slimport_anx7808/
obj-$(CONFIG_2MIC_ES305) += a2220.o
obj-$(CONFIG_SEC_TORCH_FLASH) += sec_torch.o
obj-$(CONFIG_TIMA_LOG) += tima_debug_log.o
obj-$(CONFIG_GAMMA_CONTROL) += gamma_control.o

View File

@ -0,0 +1,402 @@
/*
* Copyright 2013 Francisco Franco
* 2014 Reworked for Samsung OLED, Luis Cruz
*
* 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 <linux/init.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
#define GAMMACONTROL_VERSION 2
// r g b
int v255_val[3] = { 0, 0, 0};
int vt_val[3] = { 0, 0, 0};
int v203_val[3] = { 0, 0, 0};
int v151_val[3] = { 0, 0, 0};
int v87_val[3] = { 0, 0, 0};
int v51_val[3] = { 0, 0, 0};
int v35_val[3] = { 0, 0, 0};
int v23_val[3] = { 0, 0, 0};
int v11_val[3] = { 0, 0, 0};
int v3_val[3] = { 0, 0, 0};
int tuner[3] = { 60, 60, 60};
int red_tint[10] = {15, 20, 9, 9, 9, 9, 9, 9, 9, 9};
int grn_tint[10] = {15, 20, 9, 9, 9, 9, 9, 9, 9, 9};
int blu_tint[10] = {15, 20, 9, 9, 9, 9, 9, 9, 9, 9};
extern void panel_load_colors(void);
static ssize_t v255_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v255_val[0], v255_val[1], v255_val[2]);
}
static ssize_t v255_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v255_val[0] || new_g != v255_val[1] || new_b != v255_val[2]) {
pr_debug("New v255: %d %d %d\n", new_r, new_g, new_b);
v255_val[0] = new_r;
v255_val[1] = new_g;
v255_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t vt_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", vt_val[0], vt_val[1], vt_val[2]);
}
static ssize_t vt_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != vt_val[0] || new_g != vt_val[1] || new_b != vt_val[2]) {
pr_debug("New vt: %d %d %d\n", new_r, new_g, new_b);
vt_val[0] = new_r;
vt_val[1] = new_g;
vt_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v203_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v203_val[0], v203_val[1], v203_val[2]);
}
static ssize_t v203_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v203_val[0] || new_g != v203_val[1] || new_b != v203_val[2]) {
pr_debug("New v203: %d %d %d\n", new_r, new_g, new_b);
v203_val[0] = new_r;
v203_val[1] = new_g;
v203_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v151_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v151_val[0], v151_val[1], v151_val[2]);
}
static ssize_t v151_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v151_val[0] || new_g != v151_val[1] || new_b != v151_val[2]) {
pr_debug("New v151: %d %d %d\n", new_r, new_g, new_b);
v151_val[0] = new_r;
v151_val[1] = new_g;
v151_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v87_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v87_val[0], v87_val[1], v87_val[2]);
}
static ssize_t v87_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v87_val[0] || new_g != v87_val[1] || new_b != v87_val[2]) {
pr_debug("New v87: %d %d %d\n", new_r, new_g, new_b);
v87_val[0] = new_r;
v87_val[1] = new_g;
v87_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v51_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v51_val[0], v51_val[1], v51_val[2]);
}
static ssize_t v51_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v51_val[0] || new_g != v51_val[1] || new_b != v51_val[2]) {
pr_debug("New v51: %d %d %d\n", new_r, new_g, new_b);
v51_val[0] = new_r;
v51_val[1] = new_g;
v51_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v35_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v35_val[0], v35_val[1], v35_val[2]);
}
static ssize_t v35_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v35_val[0] || new_g != v35_val[1] || new_b != v35_val[2]) {
pr_debug("New v35: %d %d %d\n", new_r, new_g, new_b);
v35_val[0] = new_r;
v35_val[1] = new_g;
v35_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v23_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v23_val[0], v23_val[1], v23_val[2]);
}
static ssize_t v23_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v23_val[0] || new_g != v23_val[1] || new_b != v23_val[2]) {
pr_debug("New v23: %d %d %d\n", new_r, new_g, new_b);
v23_val[0] = new_r;
v23_val[1] = new_g;
v23_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v11_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v11_val[0], v11_val[1], v11_val[2]);
}
static ssize_t v11_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v11_val[0] || new_g != v11_val[1] || new_b != v11_val[2]) {
pr_debug("New v11: %d %d %d\n", new_r, new_g, new_b);
v11_val[0] = new_r;
v11_val[1] = new_g;
v11_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t v3_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", v3_val[0], v3_val[1], v3_val[2]);
}
static ssize_t v3_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r != v3_val[0] || new_g != v3_val[1] || new_b != v3_val[2]) {
pr_debug("New v3: %d %d %d\n", new_r, new_g, new_b);
v3_val[0] = new_r;
v3_val[1] = new_g;
v3_val[2] = new_b;
panel_load_colors();
}
return size;
}
static ssize_t tuner_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d %d %d\n", tuner[0], tuner[1], tuner[2]);
}
#define calc_r_shift(n) \
(red_tint[n] * (tuner[0] - 60) / 60)
#define calc_g_shift(n) \
(grn_tint[n] * (tuner[1] - 60) / 60)
#define calc_b_shift(n) \
(blu_tint[n] * (tuner[2] - 60) / 60)
static ssize_t tuner_store(struct device * dev, struct device_attribute * attr, const char * buf, size_t size)
{
int new_r, new_g, new_b;
sscanf(buf, "%d %d %d", &new_r, &new_g, &new_b);
if (new_r > 120 || new_r < 0 || new_g > 120 || new_g < 0 || new_b > 120 || new_b < 0) {
new_r = new_g = new_b = 60;
pr_err("Master tuner out of bounds, reset!\n");
}
if (new_r != tuner[0]) {
tuner[0] = new_r;
v255_val[0] = calc_r_shift(0);
vt_val[0] = calc_r_shift(1);
v203_val[0] = calc_r_shift(2);
v151_val[0] = calc_r_shift(3);
v87_val[0] = calc_r_shift(4);
v51_val[0] = calc_r_shift(5);
v35_val[0] = calc_r_shift(6);
v23_val[0] = calc_r_shift(7);
v11_val[0] = calc_r_shift(8);
v3_val[0] = calc_r_shift(9);
if (new_g == tuner[1] && new_b == tuner[2])
goto load_colors;
if (new_g == tuner[1])
goto blue;
}
if (new_g != tuner[1]) {
tuner[1] = new_g;
v255_val[1] = calc_g_shift(0);
vt_val[1] = calc_g_shift(1);
v203_val[1] = calc_g_shift(2);
v151_val[1] = calc_g_shift(3);
v87_val[1] = calc_g_shift(4);
v51_val[1] = calc_g_shift(5);
v35_val[1] = calc_g_shift(6);
v23_val[1] = calc_g_shift(7);
v11_val[1] = calc_g_shift(8);
v3_val[1] = calc_g_shift(9);
if (new_b == tuner[2])
goto load_colors;
}
blue:
if (new_b != tuner[2]) {
tuner[2] = new_b;
v255_val[2] = calc_b_shift(0);
vt_val[2] = calc_b_shift(1);
v203_val[2] = calc_b_shift(2);
v151_val[2] = calc_b_shift(3);
v87_val[2] = calc_b_shift(4);
v51_val[2] = calc_b_shift(5);
v35_val[2] = calc_b_shift(6);
v23_val[2] = calc_b_shift(7);
v11_val[2] = calc_b_shift(8);
v3_val[2] = calc_b_shift(9);
load_colors:
pr_debug("New master tuner: %d %d %d\n", new_r, new_g, new_b);
panel_load_colors();
}
return size;
}
static ssize_t gammacontrol_version(struct device * dev, struct device_attribute * attr, char * buf)
{
return sprintf(buf, "%u\n", GAMMACONTROL_VERSION);
}
static DEVICE_ATTR(v255rgb, 0644, v255_show, v255_store);
static DEVICE_ATTR(vtrgb, 0644, vt_show, vt_store);
static DEVICE_ATTR(v203rgb, 0644, v203_show, v203_store);
static DEVICE_ATTR(v151rgb, 0644, v151_show, v151_store);
static DEVICE_ATTR(v87rgb, 0644, v87_show, v87_store);
static DEVICE_ATTR(v51rgb, 0644, v51_show, v51_store);
static DEVICE_ATTR(v35rgb, 0644, v35_show, v35_store);
static DEVICE_ATTR(v23rgb, 0644, v23_show, v23_store);
static DEVICE_ATTR(v11rgb, 0644, v11_show, v11_store);
static DEVICE_ATTR(v3rgb, 0644, v3_show, v3_store);
static DEVICE_ATTR(version, 0644, gammacontrol_version, NULL);
static DEVICE_ATTR(tuner, 0644, tuner_show, tuner_store);
static struct attribute *gammacontrol_attributes[] =
{
&dev_attr_v255rgb.attr,
&dev_attr_vtrgb.attr,
&dev_attr_v203rgb.attr,
&dev_attr_v151rgb.attr,
&dev_attr_v87rgb.attr,
&dev_attr_v51rgb.attr,
&dev_attr_v35rgb.attr,
&dev_attr_v23rgb.attr,
&dev_attr_v11rgb.attr,
&dev_attr_v3rgb.attr,
&dev_attr_tuner.attr,
&dev_attr_version.attr,
NULL
};
static struct attribute_group gammacontrol_group =
{
.attrs = gammacontrol_attributes,
};
static struct miscdevice gammacontrol_device =
{
.minor = MISC_DYNAMIC_MINOR,
.name = "gammacontrol",
};
static int __init gammacontrol_init(void)
{
int ret;
pr_info("%s misc_register(%s)\n", __FUNCTION__, gammacontrol_device.name);
ret = misc_register(&gammacontrol_device);
if (ret) {
pr_err("%s misc_register(%s) fail\n", __FUNCTION__, gammacontrol_device.name);
return 1;
}
if (sysfs_create_group(&gammacontrol_device.this_device->kobj, &gammacontrol_group) < 0) {
pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
pr_err("Failed to create sysfs group for device (%s)!\n", gammacontrol_device.name);
}
return 0;
}
device_initcall(gammacontrol_init);

View File

@ -270,6 +270,7 @@ config FB_MSM_MIPI_DSI_RENESAS_TFT
config FB_MSM_MIPI_DSI_SAMSUNG_OCTA
bool
select FB_MSM_MIPI_DSI
select GAMMA_CONTROL
default n
config FB_MSM_MIPI_DSI_SAMSUNG_OLED

View File

@ -38,6 +38,8 @@ Copyright (C) 2012, Samsung Electronics. All rights reserved.
#define SMART_DIMMING_DEBUG
*/
struct SMART_DIM *gpsmart;
static char max_lux_table[GAMMA_SET_MAX];
static char min_lux_table[GAMMA_SET_MAX];
@ -102,6 +104,22 @@ static int char_to_int(char data1)
return cal_data;
}
extern int v255_val[3];
extern int vt_val[3];
extern int v203_val[3];
extern int v151_val[3];
extern int v87_val[3];
extern int v51_val[3];
extern int v35_val[3];
extern int v23_val[3];
extern int v11_val[3];
extern int v3_val[3];
void panel_load_colors(void)
{
smart_dimming_init(gpsmart);
}
static int char_to_int_v255(char data1, char data2)
{
int cal_data;
@ -127,7 +145,7 @@ static int v255_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
add_mtp = LSB + v255_value;
result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
result_1 = result_2 = (v255_coefficient+add_mtp + v255_val[0]) << BIT_SHIFT;
do_div(result_2, v255_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -138,7 +156,7 @@ static int v255_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
add_mtp = LSB + v255_value;
result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
result_1 = result_2 = (v255_coefficient+add_mtp + v255_val[1]) << BIT_SHIFT;
do_div(result_2, v255_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -149,7 +167,7 @@ static int v255_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
add_mtp = LSB + v255_value;
result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
result_1 = result_2 = (v255_coefficient+add_mtp + v255_val[2]) << BIT_SHIFT;
do_div(result_2, v255_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -211,7 +229,7 @@ static int vt_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1);
add_mtp = LSB + VT_300CD_R;
result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
result_1 = result_2 = (vt_coefficient[LSB] + vt_val[0]) << BIT_SHIFT;
do_div(result_2, vt_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -219,7 +237,7 @@ static int vt_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1);
add_mtp = LSB + VT_300CD_G;
result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
result_1 = result_2 = (vt_coefficient[LSB] + vt_val[1]) << BIT_SHIFT;
do_div(result_2, vt_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -227,7 +245,7 @@ static int vt_adjustment(struct SMART_DIM *pSmart)
LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1);
add_mtp = LSB + VT_300CD_B;
result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
result_1 = result_2 = (vt_coefficient[LSB] + vt_val[2]) << BIT_SHIFT;
do_div(result_2, vt_denominator);
result_3 = (S6E8FA_VREG0_REF * result_2) >> BIT_SHIFT;
result_4 = S6E8FA_VREG0_REF - result_3;
@ -263,7 +281,7 @@ static int v203_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V203_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_255);
result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v203_coefficient + add_mtp + v203_val[0]) << BIT_SHIFT;
do_div(result_2, v203_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -273,7 +291,7 @@ static int v203_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V203_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_255);
result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v203_coefficient + add_mtp + v203_val[1]) << BIT_SHIFT;
do_div(result_2, v203_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -283,7 +301,7 @@ static int v203_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V203_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
result_2 = (v203_coefficient+add_mtp) << BIT_SHIFT;
result_2 = (v203_coefficient + add_mtp + v203_val[2]) << BIT_SHIFT;
do_div(result_2, v203_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -342,7 +360,7 @@ static int v151_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V151_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_203);
result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v151_coefficient + add_mtp + v151_val[0]) << BIT_SHIFT;
do_div(result_2, v151_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -352,7 +370,7 @@ static int v151_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V151_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_203);
result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v151_coefficient + add_mtp + v151_val[1]) << BIT_SHIFT;
do_div(result_2, v151_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -362,7 +380,7 @@ static int v151_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V151_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v151_coefficient + add_mtp + v151_val[2]) << BIT_SHIFT;
do_div(result_2, v151_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -420,7 +438,7 @@ static int v87_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V87_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_151);
result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v87_coefficient + add_mtp + v87_val[0]) << BIT_SHIFT;
do_div(result_2, v87_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -430,7 +448,7 @@ static int v87_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V87_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_151);
result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v87_coefficient + add_mtp + v87_val[1]) << BIT_SHIFT;
do_div(result_2, v87_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -440,7 +458,7 @@ static int v87_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V87_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v87_coefficient + add_mtp + v87_val[2]) << BIT_SHIFT;
do_div(result_2, v87_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -498,7 +516,7 @@ static int v51_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V51_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_87);
result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v51_coefficient + add_mtp + v51_val[0]) << BIT_SHIFT;
do_div(result_2, v51_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -508,7 +526,7 @@ static int v51_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V51_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_87);
result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v51_coefficient + add_mtp + v51_val[1]) << BIT_SHIFT;
do_div(result_2, v51_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -518,7 +536,7 @@ static int v51_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V51_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v51_coefficient + add_mtp + v51_val[2]) << BIT_SHIFT;
do_div(result_2, v51_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -577,7 +595,7 @@ static int v35_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V35_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_51);
result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v35_coefficient + add_mtp + v35_val[0]) << BIT_SHIFT;
do_div(result_2, v35_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -587,7 +605,7 @@ static int v35_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V35_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_51);
result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v35_coefficient + add_mtp + v35_val[1]) << BIT_SHIFT;
do_div(result_2, v35_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -597,7 +615,7 @@ static int v35_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V35_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v35_coefficient + add_mtp + v35_val[2]) << BIT_SHIFT;
do_div(result_2, v35_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -656,7 +674,7 @@ static int v23_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V23_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_35);
result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v23_coefficient + add_mtp + v23_val[0]) << BIT_SHIFT;
do_div(result_2, v23_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -666,7 +684,7 @@ static int v23_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V23_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_35);
result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v23_coefficient + add_mtp + v23_val[1]) << BIT_SHIFT;
do_div(result_2, v23_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -676,7 +694,7 @@ static int v23_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V23_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v23_coefficient + add_mtp + v23_val[2]) << BIT_SHIFT;
do_div(result_2, v23_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -735,7 +753,7 @@ static int v11_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V11_300CD_R;
result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_23);
result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v11_coefficient + add_mtp + v11_val[0]) << BIT_SHIFT;
do_div(result_2, v11_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
@ -745,7 +763,7 @@ static int v11_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V11_300CD_G;
result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_23);
result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v11_coefficient + add_mtp + v11_val[1]) << BIT_SHIFT;
do_div(result_2, v11_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
@ -755,7 +773,7 @@ static int v11_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V11_300CD_B;
result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v11_coefficient + add_mtp + v11_val[2]) << BIT_SHIFT;
do_div(result_2, v11_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
@ -814,7 +832,7 @@ static int v3_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V3_300CD_R;
result_1 = (S6E8FA_VREG0_REF)
- (pSmart->RGB_OUTPUT.R_VOLTAGE.level_11);
result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v3_coefficient + add_mtp + v3_val[0]) << BIT_SHIFT;
do_div(result_2, v3_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (S6E8FA_VREG0_REF) - result_3;
@ -824,7 +842,7 @@ static int v3_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V3_300CD_G;
result_1 = (S6E8FA_VREG0_REF)
- (pSmart->RGB_OUTPUT.G_VOLTAGE.level_11);
result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v3_coefficient + add_mtp + v3_val[1]) << BIT_SHIFT;
do_div(result_2, v3_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (S6E8FA_VREG0_REF) - result_3;
@ -834,7 +852,7 @@ static int v3_adjustment(struct SMART_DIM *pSmart)
add_mtp = LSB + V3_300CD_B;
result_1 = (S6E8FA_VREG0_REF)
- (pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
result_2 = (v3_coefficient + add_mtp + v3_val[2]) << BIT_SHIFT;
do_div(result_2, v3_denominator);
result_3 = (result_1 * result_2) >> BIT_SHIFT;
result_4 = (S6E8FA_VREG0_REF) - result_3;
@ -3461,6 +3479,7 @@ int smart_dimming_init(struct SMART_DIM *psmart)
char pBuffer[256];
memset(pBuffer, 0x00, 256);
#endif
gpsmart = psmart;
id1 = (psmart->ldi_revision & 0x00FF0000) >> 16;
id2 = (psmart->ldi_revision & 0x0000FF00) >> 8;
id3 = psmart->ldi_revision & 0xFF;