Commit 1c3e3557 authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

Added Kcal mdp3, builds but can't find the path to the editing files.

parent bad90159
......@@ -9,3 +9,4 @@ It is my goal to modify this kernel. Here are the modifications thus far:
+ Added CPU voltage control for big cores.
+ Added Sweep2Wake and DoubleTap2Wake - May not be fully functional, my prox sensor is smashed.
+ Added Little CPU core voltage control.
+ Added KCAL mdp3 support - builds but is not recognized, Kppd may be the better option.
......@@ -2676,6 +2676,7 @@ CONFIG_FB_MSM_MDSS_WRITEBACK=y
# CONFIG_FB_MSM_MDSS_EDP_PANEL is not set
# CONFIG_FB_MSM_MDSS_MDP3 is not set
CONFIG_FB_MSM_MDSS_XLOG_DEBUG=y
CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL=y
# CONFIG_FB_SSD1307 is not set
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_LCD_CLASS_DEVICE=m
......
......@@ -62,3 +62,10 @@ config FB_MSM_MDSS_XLOG_DEBUG
features to: Dump MDSS registers during driver errors, panic
driver during fatal errors and enable some display-driver logging
into an internal buffer (this avoids logging overhead).
config FB_MSM_MDSS_MDP3_KCAL_CTRL
depends on FB_MSM_MDSS_MDP3
bool "MDP3 color control"
---help---
Enable sysfs for rgb/lut control for mdp3 display controllers
in MDSS.
......@@ -2108,7 +2108,7 @@ static int mdp3_lut_combine_gain(struct fb_cmap *cmap, struct mdp3_dma *dma)
/* Called from within pp_lock and session lock locked context */
static int mdp3_ctrl_lut_update(struct msm_fb_data_type *mfd,
struct fb_cmap *cmap)
struct fb_cmap *cmap, void *setup)
{
int rc = 0;
struct mdp3_session_data *mdp3_session = mfd->mdp.private1;
......@@ -2126,6 +2126,9 @@ static int mdp3_ctrl_lut_update(struct msm_fb_data_type *mfd,
lut_config.lut_sel = mdp3_session->lut_sel;
lut_config.lut_position = 1;
lut_config.lut_dirty = true;
lut.color0_lut = setup ? r : cmap->red;
lut.color1_lut = setup ? g : cmap->green;
lut.color2_lut = setup ? b : cmap->blue;
if (!mdp3_session->status) {
pr_err("display off!\n");
......@@ -2142,6 +2145,119 @@ static int mdp3_ctrl_lut_update(struct msm_fb_data_type *mfd,
return rc;
}
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
static int update_preset_lcdc_lut(struct msm_fb_data_type *mfd,
void *setup, int kr, int kg, int kb)
{
int ret = 0;
struct fb_cmap cmap;
cmap.start = 0;
cmap.len = 256;
cmap.transp = NULL;
cmap.red = (uint16_t *)&(kr);
cmap.green = (uint16_t *)&(kg);
cmap.blue = (uint16_t *)&(kb);
ret = mdp3_ctrl_lut_update(mfd, &cmap, (void *)setup);
if (ret)
pr_err("%s: failed to set lut: %d\n", __func__, ret);
return ret;
}
static void mdp3_ctrl_kcal_apply(struct msm_fb_data_type *mfd,
struct mdp3_session_data *mdp3_session)
{
mdp3_session->lut_data.red = (mdp3_session->lut_data.red <
mdp3_session->lut_data.minimum) ? mdp3_session->lut_data.minimum :
mdp3_session->lut_data.red;
mdp3_session->lut_data.green = (mdp3_session->lut_data.green <
mdp3_session->lut_data.minimum) ? mdp3_session->lut_data.minimum :
mdp3_session->lut_data.green;
mdp3_session->lut_data.blue = (mdp3_session->lut_data.blue <
mdp3_session->lut_data.minimum) ? mdp3_session->lut_data.minimum :
mdp3_session->lut_data.blue;
update_preset_lcdc_lut(mfd, NULL, mdp3_session->lut_data.red,
mdp3_session->lut_data.green, mdp3_session->lut_data.blue);
}
static ssize_t mdp3_ctrl_kcal_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int kcal_r, kcal_g, kcal_b;
struct fb_info *fbi = dev_get_drvdata(dev);
struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)fbi->par;
struct mdp3_session_data *mdp3_session = NULL;
if (!mfd || !mfd->mdp.private1)
return -EAGAIN;
mdp3_session = (struct mdp3_session_data *)mfd->mdp.private1;
if (count < 6 || count > 12)
return -EINVAL;
sscanf(buf, "%d %d %d", &kcal_r, &kcal_g, &kcal_b);
if (kcal_r < 0 || kcal_r > 255)
return -EINVAL;
if (kcal_g < 0 || kcal_g > 255)
return -EINVAL;
if (kcal_b < 0 || kcal_b > 255)
return -EINVAL;
mdp3_session->lut_data.red = kcal_r;
mdp3_session->lut_data.green = kcal_g;
mdp3_session->lut_data.blue = kcal_b;
mdp3_ctrl_kcal_apply(mfd, mdp3_session);
return count;
}
static ssize_t mdp3_ctrl_kcal_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct fb_info *fbi = dev_get_drvdata(dev);
struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)fbi->par;
struct mdp3_session_data *mdp3_session = NULL;
if (!mfd || !mfd->mdp.private1)
return -EAGAIN;
mdp3_session = (struct mdp3_session_data *)mfd->mdp.private1;
return sprintf(buf, "%d %d %d\n", mdp3_session->lut_data.red,
mdp3_session->lut_data.green, mdp3_session->lut_data.blue);
}
static ssize_t mdp3_ctrl_kcal_min_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int kcal_min;
struct fb_info *fbi = dev_get_drvdata(dev);
struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)fbi->par;
struct mdp3_session_data *mdp3_session = NULL;
if (!mfd || !mfd->mdp.private1)
return -EAGAIN;
mdp3_session = (struct mdp3_session_data *)mfd->mdp.private1;
if (count < 2 || count > 4)
return -EINVAL;
sscanf(buf, "%d", &kcal_min);
if (kcal_min < 0 || kcal_min > 255)
return -EINVAL;
mdp3_session->lut_data.minimum = kcal_min;
mdp3_ctrl_kcal_apply(mfd, mdp3_session);
return count;
}
static ssize_t mdp3_ctrl_kcal_min_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct fb_info *fbi = dev_get_drvdata(dev);
struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)fbi->par;
struct mdp3_session_data *mdp3_session = NULL;
if (!mfd || !mfd->mdp.private1)
return -EAGAIN;
mdp3_session = (struct mdp3_session_data *)mfd->mdp.private1;
return sprintf(buf, "%d\n", mdp3_session->lut_data.minimum);
}
static DEVICE_ATTR(kcal, 0644, mdp3_ctrl_kcal_show, mdp3_ctrl_kcal_store);
static DEVICE_ATTR(kcal_min, 0644, mdp3_ctrl_kcal_min_show,
mdp3_ctrl_kcal_min_store);
static struct attribute *kcal_fs_attrs[] = {
&dev_attr_kcal.attr,
&dev_attr_kcal_min.attr,
NULL,
};
static struct attribute_group kcal_fs_attr_group = {
.attrs = kcal_fs_attrs,
};
#endif
static int mdp3_ctrl_lut_config(struct msm_fb_data_type *mfd,
struct mdp_rgb_lut_data *cfg)
{
......@@ -2166,15 +2282,18 @@ static int mdp3_ctrl_lut_config(struct msm_fb_data_type *mfd,
mutex_lock(&mdp3_session->lock);
mutex_lock(&dma->pp_lock);
rc = copy_from_user(cmap->red + cfg->cmap.start,
cfg->cmap.red, sizeof(u16) * cfg->cmap.len);
rc |= copy_from_user(cmap->green + cfg->cmap.start,
cfg->cmap.green, sizeof(u16) * cfg->cmap.len);
rc |= copy_from_user(cmap->blue + cfg->cmap.start,
cfg->cmap.blue, sizeof(u16) * cfg->cmap.len);
if (rc) {
pr_err("Copying user data failed!\n");
goto exit_err;
if (setup) {
rc = copy_from_user(cmap->red + cfg->cmap.start,
cfg->cmap.red, sizeof(u16) * cfg->cmap.len);
rc |= copy_from_user(cmap->green + cfg->cmap.start,
cfg->cmap.green, sizeof(u16) * cfg->cmap.len);
rc |= copy_from_user(cmap->blue + cfg->cmap.start,
cfg->cmap.blue, sizeof(u16) * cfg->cmap.len);
if (rc) {
pr_err("Copying user data failed!\n");
goto exit_err;
}
}
switch (cfg->lut_type) {
......@@ -2698,6 +2817,19 @@ int mdp3_ctrl_init(struct msm_fb_data_type *mfd)
mdp3_session->vsync_timer.data = (u32)mdp3_session;
mdp3_session->vsync_period = 1000 / mfd->panel_info->mipi.frame_rate;
mfd->mdp.private1 = mdp3_session;
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
rc = sysfs_create_group(&dev->kobj, &kcal_fs_attr_group);
if (rc) {
pr_err("kcal sysfs group creation failed, ret=%d\n", rc);
goto init_done;
}
mdp3_session->lut_data.red = MAX_KCAL_V;
mdp3_session->lut_data.green = MAX_KCAL_V;
mdp3_session->lut_data.blue = MAX_KCAL_V;
mdp3_session->lut_data.minimum = 35;
#endif
init_completion(&mdp3_session->dma_completion);
if (intf_type != MDP3_DMA_OUTPUT_SEL_DSI_VIDEO)
mdp3_session->wait_for_dma_done = mdp3_wait_for_dma_done;
......@@ -2751,6 +2883,12 @@ int mdp3_ctrl_init(struct msm_fb_data_type *mfd)
}
mdp3_session->vsync_before_commit = true;
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
update_preset_lcdc_lut(mfd, (void *)1, mdp3_session->lut_data.red,
mdp3_session->lut_data.green, mdp3_session->lut_data.blue);
#endif
mdp3_session->dyn_pu_state = mfd->panel_info->partial_update_enabled;
init_done:
if (IS_ERR_VALUE(rc))
......
......@@ -35,6 +35,27 @@ struct mdp3_buffer_queue {
int pop_idx;
};
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
#define R_MASK 0xff0000
#define G_MASK 0xff00
#define B_MASK 0xff
#define R_SHIFT 16
#define G_SHIFT 8
#define B_SHIFT 0
#define NUM_QLUT 256
#define MAX_KCAL_V (NUM_QLUT - 1)
#define lut2rgb(lut,mask,shift) ((lut & mask) >> shift)
#define scaled_by_kcal(rgb, kcal) \
(((((unsigned int)(rgb) * (unsigned int)(kcal)) << 16) / \
(unsigned int)MAX_KCAL_V) >> 16)
struct kcal_lut_data {
int red;
int green;
int blue;
int minimum;
};
#endif
struct mdp3_session_data {
struct mutex lock;
int status;
......@@ -63,6 +84,11 @@ struct mdp3_session_data {
int vsync_enabled;
atomic_t vsync_countdown; /* Used to count down */
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
struct kcal_lut_data lut_data;
#endif
bool in_splash_screen;
bool esd_recovery;
int dyn_pu_state; /* dynamic partial update status */
......
......@@ -18,6 +18,10 @@
#include "mdp3_hwio.h"
#include "mdss_debug.h"
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
#include "mdp3_ctrl.h"
#endif
#define DMA_STOP_POLL_SLEEP_US 1000
#define DMA_STOP_POLL_TIMEOUT_US 200000
#define DMA_HISTO_RESET_TIMEOUT_MS 40
......@@ -564,6 +568,76 @@ static int mdp3_dmap_ccs_config(struct mdp3_dma *dma,
return 0;
}
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
static unsigned int lcd_rgb_linear_lut[256] = {
/* default linear qlut */
0x00000000, 0x00010101, 0x00020202, 0x00030303,
0x00040404, 0x00050505, 0x00060606, 0x00070707,
0x00080808, 0x00090909, 0x000a0a0a, 0x000b0b0b,
0x000c0c0c, 0x000d0d0d, 0x000e0e0e, 0x000f0f0f,
0x00101010, 0x00111111, 0x00121212, 0x00131313,
0x00141414, 0x00151515, 0x00161616, 0x00171717,
0x00181818, 0x00191919, 0x001a1a1a, 0x001b1b1b,
0x001c1c1c, 0x001d1d1d, 0x001e1e1e, 0x001f1f1f,
0x00202020, 0x00212121, 0x00222222, 0x00232323,
0x00242424, 0x00252525, 0x00262626, 0x00272727,
0x00282828, 0x00292929, 0x002a2a2a, 0x002b2b2b,
0x002c2c2c, 0x002d2d2d, 0x002e2e2e, 0x002f2f2f,
0x00303030, 0x00313131, 0x00323232, 0x00333333,
0x00343434, 0x00353535, 0x00363636, 0x00373737,
0x00383838, 0x00393939, 0x003a3a3a, 0x003b3b3b,
0x003c3c3c, 0x003d3d3d, 0x003e3e3e, 0x003f3f3f,
0x00404040, 0x00414141, 0x00424242, 0x00434343,
0x00444444, 0x00454545, 0x00464646, 0x00474747,
0x00484848, 0x00494949, 0x004a4a4a, 0x004b4b4b,
0x004c4c4c, 0x004d4d4d, 0x004e4e4e, 0x004f4f4f,
0x00505050, 0x00515151, 0x00525252, 0x00535353,
0x00545454, 0x00555555, 0x00565656, 0x00575757,
0x00585858, 0x00595959, 0x005a5a5a, 0x005b5b5b,
0x005c5c5c, 0x005d5d5d, 0x005e5e5e, 0x005f5f5f,
0x00606060, 0x00616161, 0x00626262, 0x00636363,
0x00646464, 0x00656565, 0x00666666, 0x00676767,
0x00686868, 0x00696969, 0x006a6a6a, 0x006b6b6b,
0x006c6c6c, 0x006d6d6d, 0x006e6e6e, 0x006f6f6f,
0x00707070, 0x00717171, 0x00727272, 0x00737373,
0x00747474, 0x00757575, 0x00767676, 0x00777777,
0x00787878, 0x00797979, 0x007a7a7a, 0x007b7b7b,
0x007c7c7c, 0x007d7d7d, 0x007e7e7e, 0x007f7f7f,
0x00808080, 0x00818181, 0x00828282, 0x00838383,
0x00848484, 0x00858585, 0x00868686, 0x00878787,
0x00888888, 0x00898989, 0x008a8a8a, 0x008b8b8b,
0x008c8c8c, 0x008d8d8d, 0x008e8e8e, 0x008f8f8f,
0x00909090, 0x00919191, 0x00929292, 0x00939393,
0x00949494, 0x00959595, 0x00969696, 0x00979797,
0x00989898, 0x00999999, 0x009a9a9a, 0x009b9b9b,
0x009c9c9c, 0x009d9d9d, 0x009e9e9e, 0x009f9f9f,
0x00a0a0a0, 0x00a1a1a1, 0x00a2a2a2, 0x00a3a3a3,
0x00a4a4a4, 0x00a5a5a5, 0x00a6a6a6, 0x00a7a7a7,
0x00a8a8a8, 0x00a9a9a9, 0x00aaaaaa, 0x00ababab,
0x00acacac, 0x00adadad, 0x00aeaeae, 0x00afafaf,
0x00b0b0b0, 0x00b1b1b1, 0x00b2b2b2, 0x00b3b3b3,
0x00b4b4b4, 0x00b5b5b5, 0x00b6b6b6, 0x00b7b7b7,
0x00b8b8b8, 0x00b9b9b9, 0x00bababa, 0x00bbbbbb,
0x00bcbcbc, 0x00bdbdbd, 0x00bebebe, 0x00bfbfbf,
0x00c0c0c0, 0x00c1c1c1, 0x00c2c2c2, 0x00c3c3c3,
0x00c4c4c4, 0x00c5c5c5, 0x00c6c6c6, 0x00c7c7c7,
0x00c8c8c8, 0x00c9c9c9, 0x00cacaca, 0x00cbcbcb,
0x00cccccc, 0x00cdcdcd, 0x00cecece, 0x00cfcfcf,
0x00d0d0d0, 0x00d1d1d1, 0x00d2d2d2, 0x00d3d3d3,
0x00d4d4d4, 0x00d5d5d5, 0x00d6d6d6, 0x00d7d7d7,
0x00d8d8d8, 0x00d9d9d9, 0x00dadada, 0x00dbdbdb,
0x00dcdcdc, 0x00dddddd, 0x00dedede, 0x00dfdfdf,
0x00e0e0e0, 0x00e1e1e1, 0x00e2e2e2, 0x00e3e3e3,
0x00e4e4e4, 0x00e5e5e5, 0x00e6e6e6, 0x00e7e7e7,
0x00e8e8e8, 0x00e9e9e9, 0x00eaeaea, 0x00ebebeb,
0x00ececec, 0x00ededed, 0x00eeeeee, 0x00efefef,
0x00f0f0f0, 0x00f1f1f1, 0x00f2f2f2, 0x00f3f3f3,
0x00f4f4f4, 0x00f5f5f5, 0x00f6f6f6, 0x00f7f7f7,
0x00f8f8f8, 0x00f9f9f9, 0x00fafafa, 0x00fbfbfb,
0x00fcfcfc, 0x00fdfdfd, 0x00fefefe, 0x00ffffff
};
#endif
static int mdp3_dmap_lut_config(struct mdp3_dma *dma,
struct mdp3_dma_lut_config *config,
struct fb_cmap *cmap)
......@@ -571,15 +645,33 @@ static int mdp3_dmap_lut_config(struct mdp3_dma *dma,
u32 addr, color;
int i;
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
u16 r, g, b;
uint32_t *internal_lut = lcd_rgb_linear_lut;
#endif
if (config->lut_enable && cmap) {
addr = MDP3_REG_DMA_P_CSC_LUT1;
if (config->lut_sel)
addr = MDP3_REG_DMA_P_CSC_LUT2;
for (i = 0; i < MDP_LUT_SIZE; i++) {
#ifdef CONFIG_FB_MSM_MDSS_MDP3_KCAL_CTRL
r = lut2rgb(internal_lut[i], R_MASK, R_SHIFT);
g = lut2rgb(internal_lut[i], G_MASK, G_SHIFT);
b = lut2rgb(internal_lut[i], B_MASK, B_SHIFT);
r = scaled_by_kcal(r, *(lut->color0_lut));
g = scaled_by_kcal(g, *(lut->color1_lut));
b = scaled_by_kcal(b, *(lut->color2_lut));
color = g & 0xff;
color |= (r & 0xff) << 8;
color |= (b & 0xff) << 16;
#else
color = cmap->green[i] & 0xff;
color |= (cmap->red[i] & 0xff) << 8;
color |= (cmap->blue[i] & 0xff) << 16;
#endif
MDP3_REG_WRITE(addr, color);
addr += 4;
}
......
......@@ -3962,7 +3962,7 @@ static int mdss_fb_set_lut(struct fb_info *info, void __user *p)
if (ret)
return ret;
mfd->mdp.lut_update(mfd, &cmap);
mfd->mdp.lut_update(mfd, &cmap, NULL);
return 0;
}
......
......@@ -219,7 +219,8 @@ struct msm_mdp_interface {
struct fb_cursor *cursor);
int (*async_position_update)(struct msm_fb_data_type *mfd,
struct mdp_position_update *update_pos);
int (*lut_update)(struct msm_fb_data_type *mfd, struct fb_cmap *cmap);
int (*lut_update)(struct msm_fb_data_type *mfd, struct fb_cmap *cmap,
void *setup);
int (*do_histogram)(struct msm_fb_data_type *mfd,
struct mdp_histogram *hist);
int (*ad_calc_bl)(struct msm_fb_data_type *mfd, int bl_in,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment