Merge branch develop-3.10
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / rkfb_sysfs.c
index ffbc0fc3df1cce9eb4ce96cb86fd58fb1a70d2e0..6a9f6037f2a2a988d1ffff443a3e507cea2b7c68 100644 (file)
@@ -492,6 +492,50 @@ static ssize_t set_hwc_lut(struct device *dev, struct device_attribute *attr,
        return count;
 }
 
+static ssize_t show_cabc_lut(struct device *dev,
+                            struct device_attribute *attr, char *buf)
+{
+       return 0;
+}
+
+static ssize_t set_cabc_lut(struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
+{
+       int cabc_lut[256];
+       const char *start = buf;
+       int i = 256, temp;
+       int space_max = 10;
+
+       struct fb_info *fbi = dev_get_drvdata(dev);
+       struct rk_fb_par *fb_par = (struct rk_fb_par *)fbi->par;
+       struct rk_lcdc_driver *dev_drv = fb_par->lcdc_drv;
+
+       for (i = 0; i < 256; i++) {
+               temp = i;
+               /*init by default value*/
+               cabc_lut[i] = temp + (temp << 8) + (temp << 16);
+       }
+       for (i = 0; i < 256; i++) {
+               space_max = 10; /*max space number 10*/
+               temp = simple_strtoul(start, NULL, 10);
+               cabc_lut[i] = temp;
+               do {
+                       start++;
+                       space_max--;
+               } while ((*start != ' ') && space_max);
+
+               if (!space_max)
+                       break;
+               else
+                       start++;
+       }
+       if (dev_drv->ops->set_cabc_lut)
+               dev_drv->ops->set_cabc_lut(dev_drv, cabc_lut);
+
+       return count;
+}
+
+
 static ssize_t show_dsp_lut(struct device *dev,
                            struct device_attribute *attr, char *buf)
 {
@@ -687,14 +731,13 @@ static ssize_t show_scale(struct device *dev,
        struct fb_info *fbi = dev_get_drvdata(dev);
        struct rk_fb_par *fb_par = (struct rk_fb_par *)fbi->par;
        struct rk_lcdc_driver *dev_drv = fb_par->lcdc_drv;
-       struct rk_screen *screen = dev_drv->cur_screen;
 
        return snprintf(buf, PAGE_SIZE,
                "xscale=%d yscale=%d\nleft=%d top=%d right=%d bottom=%d\n",
-               (screen->overscan.left + screen->overscan.right)/2,
-               (screen->overscan.top + screen->overscan.bottom)/2,
-               screen->overscan.left, screen->overscan.top,
-               screen->overscan.right, screen->overscan.bottom);
+               (dev_drv->overscan.left + dev_drv->overscan.right) / 2,
+               (dev_drv->overscan.top + dev_drv->overscan.bottom) / 2,
+               dev_drv->overscan.left, dev_drv->overscan.top,
+               dev_drv->overscan.right, dev_drv->overscan.bottom);
 }
 
 static ssize_t set_scale(struct device *dev, struct device_attribute *attr,
@@ -703,60 +746,59 @@ static ssize_t set_scale(struct device *dev, struct device_attribute *attr,
        struct fb_info *fbi = dev_get_drvdata(dev);
        struct rk_fb_par *fb_par = (struct rk_fb_par *)fbi->par;
        struct rk_lcdc_driver *dev_drv = fb_par->lcdc_drv;
-       struct rk_screen *screen = dev_drv->cur_screen;
        u32 left, top, right, bottom;
 
        if (!strncmp(buf, "overscan", 8)) {
                sscanf(buf,
                       "overscan %d,%d,%d,%d", &left, &top, &right, &bottom);
                if (left > 0 && left <= 100)
-                       screen->overscan.left = left;
+                       dev_drv->overscan.left = left;
                if (top > 0 && top <= 100)
-                       screen->overscan.top = top;
+                       dev_drv->overscan.top = top;
                if (right > 0 && right <= 100)
-                       screen->overscan.right = right;
+                       dev_drv->overscan.right = right;
                if (bottom > 0 && bottom <= 100)
-                       screen->overscan.bottom = bottom;
+                       dev_drv->overscan.bottom = bottom;
        } else if (!strncmp(buf, "left", 4)) {
                sscanf(buf, "left=%d", &left);
                if (left > 0 && left <= 100)
-                       screen->overscan.left = left;
+                       dev_drv->overscan.left = left;
        } else if (!strncmp(buf, "top", 3)) {
                sscanf(buf, "top=%d", &top);
                if (top > 0 && top <= 100)
-                       screen->overscan.top = top;
+                       dev_drv->overscan.top = top;
        } else if (!strncmp(buf, "right", 5)) {
                sscanf(buf, "right=%d", &right);
                if (right > 0 && right <= 100)
-                       screen->overscan.right = right;
+                       dev_drv->overscan.right = right;
        } else if (!strncmp(buf, "bottom", 6)) {
                sscanf(buf, "bottom=%d", &bottom);
                if (bottom > 0 && bottom <= 100)
-                       screen->overscan.bottom = bottom;
+                       dev_drv->overscan.bottom = bottom;
        } else if (!strncmp(buf, "xscale", 6)) {
                sscanf(buf, "xscale=%d", &left);
                if (left > 0 && left <= 100) {
-                       screen->overscan.left = left;
-                       screen->overscan.right = left;
+                       dev_drv->overscan.left = left;
+                       dev_drv->overscan.right = left;
                }
        } else if (!strncmp(buf, "yscale", 6)) {
                sscanf(buf, "yscale=%d", &left);
                if (left > 0 && left <= 100) {
-                       screen->overscan.top = left;
-                       screen->overscan.bottom = left;
+                       dev_drv->overscan.top = left;
+                       dev_drv->overscan.bottom = left;
                }
        } else {
                sscanf(buf, "%d", &left);
                if (left > 0 && left <= 100) {
-                       screen->overscan.left = left;
-                       screen->overscan.right = left;
-                       screen->overscan.top = left;
-                       screen->overscan.bottom = left;
+                       dev_drv->overscan.left = left;
+                       dev_drv->overscan.right = left;
+                       dev_drv->overscan.top = left;
+                       dev_drv->overscan.bottom = left;
                }
        }
 
        if (dev_drv->ops->set_overscan)
-               dev_drv->ops->set_overscan(dev_drv, &screen->overscan);
+               dev_drv->ops->set_overscan(dev_drv, &dev_drv->overscan);
 
        return count;
 }
@@ -772,6 +814,7 @@ static struct device_attribute rkfb_attrs[] = {
        __ATTR(fps, S_IRUGO | S_IWUSR, show_fps, set_fps),
        __ATTR(map, S_IRUGO | S_IWUSR, show_fb_win_map, set_fb_win_map),
        __ATTR(dsp_lut, S_IRUGO | S_IWUSR, show_dsp_lut, set_dsp_lut),
+       __ATTR(cabc_lut, S_IRUGO | S_IWUSR, show_cabc_lut, set_cabc_lut),
        __ATTR(hwc_lut, S_IRUGO | S_IWUSR, show_hwc_lut, set_hwc_lut),
        __ATTR(cabc, S_IRUGO | S_IWUSR, show_dsp_cabc, set_dsp_cabc),
        __ATTR(bcsh, S_IRUGO | S_IWUSR, show_dsp_bcsh, set_dsp_bcsh),