From: Huang Jiachai Date: Thu, 3 Dec 2015 07:03:26 +0000 (+0800) Subject: video: rockchip: add support linux 4.4 X-Git-Tag: firefly_0821_release~3551 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0493a6826b3492d749accd888c600d1316d9ef39;p=firefly-linux-kernel-4.4.55.git video: rockchip: add support linux 4.4 Change-Id: I6c77124074d4810245610774475cc64c459e47b3 Signed-off-by: Huang Jiachai --- diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index e0606c01e8ac..7e0ac1996627 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -29,6 +29,7 @@ source "drivers/video/fbdev/Kconfig" endmenu source "drivers/video/backlight/Kconfig" +source "drivers/video/rockchip/Kconfig" config VGASTATE tristate diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 9ad3c17d6456..6eb93e61e56f 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_HDMI) += hdmi.o obj-$(CONFIG_VT) += console/ obj-$(CONFIG_LOGO) += logo/ obj-y += backlight/ +obj-$(CONFIG_FB_ROCKCHIP) += rockchip/ obj-y += fbdev/ diff --git a/drivers/video/rockchip/Makefile b/drivers/video/rockchip/Makefile index 8f8f8ce307f7..4d899cbd9a69 100755 --- a/drivers/video/rockchip/Makefile +++ b/drivers/video/rockchip/Makefile @@ -1,9 +1,7 @@ obj-$(CONFIG_ROCKCHIP_RGA) += rga/ obj-$(CONFIG_ROCKCHIP_RGA2) += rga2/ obj-$(CONFIG_FB_ROCKCHIP) += rk_fb.o rkfb_sysfs.o bmp_helper.o screen/ -obj-$(CONFIG_DRM_ROCKCHIP) += rk_drm_fb.o screen/ obj-$(CONFIG_RK_TRSM) += transmitter/ -obj-$(CONFIG_DRM_ROCKCHIP) += lcdc/ obj-$(CONFIG_FB_ROCKCHIP) += display-sys.o lcdc/ obj-$(CONFIG_RK_HDMI) += hdmi/ obj-$(CONFIG_IEP) += iep/ diff --git a/drivers/video/rockchip/display-sys.c b/drivers/video/rockchip/display-sys.c old mode 100755 new mode 100644 index df94268066b6..7b12b59a7c36 --- a/drivers/video/rockchip/display-sys.c +++ b/drivers/video/rockchip/display-sys.c @@ -8,7 +8,7 @@ static struct list_head main_display_device_list; static struct list_head aux_display_device_list; -static ssize_t display_show_name(struct device *dev, +static ssize_t display_name_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -16,7 +16,9 @@ static ssize_t display_show_name(struct device *dev, return snprintf(buf, PAGE_SIZE, "%s\n", dsp->name); } -static ssize_t display_show_type(struct device *dev, +static DEVICE_ATTR_RO(display_name); + +static ssize_t display_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -24,7 +26,9 @@ static ssize_t display_show_type(struct device *dev, return snprintf(buf, PAGE_SIZE, "%s\n", dsp->type); } -static ssize_t display_show_property(struct device *dev, +static DEVICE_ATTR_RO(display_type); + +static ssize_t display_property_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -32,7 +36,9 @@ static ssize_t display_show_property(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", dsp->property); } -static ssize_t display_show_enable(struct device *dev, +static DEVICE_ATTR_RO(display_property); + +static ssize_t display_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -45,7 +51,7 @@ static ssize_t display_show_enable(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", enable); } -static ssize_t display_store_enable(struct device *dev, +static ssize_t display_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { @@ -59,7 +65,9 @@ static ssize_t display_store_enable(struct device *dev, return size; } -static ssize_t display_show_connect(struct device *dev, +static DEVICE_ATTR_RW(display_enable); + +static ssize_t display_connect_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -72,6 +80,8 @@ static ssize_t display_show_connect(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", connect); } +static DEVICE_ATTR_RO(display_connect); + static int mode_string(char *buf, unsigned int offset, const struct fb_videomode *mode) { @@ -105,7 +115,7 @@ static int mode_string(char *buf, unsigned int offset, mode->xres, mode->yres, v, mode->refresh); } -static ssize_t display_show_modes(struct device *dev, +static ssize_t display_modes_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -139,7 +149,9 @@ static ssize_t display_show_modes(struct device *dev, return i; } -static ssize_t display_show_mode(struct device *dev, +static DEVICE_ATTR_RO(display_modes); + +static ssize_t display_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -151,7 +163,7 @@ static ssize_t display_show_mode(struct device *dev, return 0; } -static ssize_t display_store_mode(struct device *dev, +static ssize_t display_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -195,7 +207,9 @@ static ssize_t display_store_mode(struct device *dev, return -EINVAL; } -static ssize_t display_show_scale(struct device *dev, +static DEVICE_ATTR_RW(display_mode); + +static ssize_t display_scale_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -213,7 +227,7 @@ static ssize_t display_show_scale(struct device *dev, return -EINVAL; } -static ssize_t display_store_scale(struct device *dev, +static ssize_t display_scale_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -246,7 +260,9 @@ static ssize_t display_store_scale(struct device *dev, return -EINVAL; } -static ssize_t display_show_3dmode(struct device *dev, +static DEVICE_ATTR_RW(display_scale); + +static ssize_t display_3dmode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -312,7 +328,7 @@ static ssize_t display_show_3dmode(struct device *dev, return i; } -static ssize_t display_store_3dmode(struct device *dev, +static ssize_t display_3dmode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -330,7 +346,9 @@ static ssize_t display_store_3dmode(struct device *dev, return -EINVAL; } -static ssize_t display_show_color(struct device *dev, +static DEVICE_ATTR_RW(display_3dmode); + +static ssize_t display_color_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -343,7 +361,7 @@ static ssize_t display_show_color(struct device *dev, return ret; } -static ssize_t display_store_color(struct device *dev, +static ssize_t display_color_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -360,7 +378,9 @@ static ssize_t display_store_color(struct device *dev, return -EINVAL; } -static ssize_t display_show_sinkaudioinfo(struct device *dev, +static DEVICE_ATTR_RW(display_color); + +static ssize_t display_sinkaudioinfo_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -380,7 +400,9 @@ static ssize_t display_show_sinkaudioinfo(struct device *dev, return -EINVAL; } -static ssize_t display_show_monspecs(struct device *dev, +static DEVICE_ATTR_RO(display_sinkaudioinfo); + +static ssize_t display_monspecs_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -400,7 +422,9 @@ static ssize_t display_show_monspecs(struct device *dev, return -EINVAL; } -static ssize_t display_show_debug(struct device *dev, +static DEVICE_ATTR_RO(display_monspecs); + +static ssize_t display_debug_show(struct device *dev, struct device_attribute *attr, char *buf) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -413,7 +437,7 @@ static ssize_t display_show_debug(struct device *dev, return ret; } -static ssize_t display_store_debug(struct device *dev, +static ssize_t display_debug_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -430,23 +454,27 @@ static ssize_t display_store_debug(struct device *dev, return ret; } -static struct device_attribute display_attrs[] = { - __ATTR(name, S_IRUGO, display_show_name, NULL), - __ATTR(type, S_IRUGO, display_show_type, NULL), - __ATTR(property, S_IRUGO, display_show_property, NULL), - __ATTR(enable, 0666, display_show_enable, display_store_enable), - __ATTR(connect, S_IRUGO, display_show_connect, NULL), - __ATTR(modes, S_IRUGO, display_show_modes, NULL), - __ATTR(mode, 0666, display_show_mode, display_store_mode), - __ATTR(scale, 0666, display_show_scale, display_store_scale), - __ATTR(3dmode, 0666, display_show_3dmode, display_store_3dmode), - __ATTR(color, 0666, display_show_color, display_store_color), - __ATTR(audioinfo, S_IRUGO, display_show_sinkaudioinfo, NULL), - __ATTR(monspecs, S_IRUGO, display_show_monspecs, NULL), - __ATTR(debug, 0664, display_show_debug, display_store_debug), - __ATTR_NULL +static DEVICE_ATTR_RW(display_debug); + +static struct attribute *display_device_attrs[] = { + &dev_attr_display_name.attr, + &dev_attr_display_type.attr, + &dev_attr_display_property.attr, + &dev_attr_display_enable.attr, + &dev_attr_display_connect.attr, + &dev_attr_display_modes.attr, + &dev_attr_display_mode.attr, + &dev_attr_display_scale.attr, + &dev_attr_display_3dmode.attr, + &dev_attr_display_color.attr, + &dev_attr_display_sinkaudioinfo.attr, + &dev_attr_display_monspecs.attr, + &dev_attr_display_debug.attr, + NULL, }; +ATTRIBUTE_GROUPS(display_device); + static int display_suspend(struct device *dev, pm_message_t state) { struct rk_display_device *dsp = dev_get_drvdata(dev); @@ -733,7 +761,7 @@ static int __init rk_display_class_init(void) display_class = NULL; return -EINVAL; } - display_class->dev_attrs = display_attrs; + display_class->dev_groups = display_device_groups; display_class->suspend = display_suspend; display_class->resume = display_resume; mutex_init(&allocated_dsp_lock); diff --git a/drivers/video/rockchip/lcdc/rk3288_lcdc.c b/drivers/video/rockchip/lcdc/rk3288_lcdc.c index 63c019339bd2..7e594a70aef6 100755 --- a/drivers/video/rockchip/lcdc/rk3288_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3288_lcdc.c @@ -3958,9 +3958,6 @@ static irqreturn_t rk3288_lcdc_isr(int irq, void *dev_id) complete(&(lcdc_dev->driver.frame_done)); spin_unlock(&(lcdc_dev->driver.cpl_lock)); } -#ifdef CONFIG_DRM_ROCKCHIP - lcdc_dev->driver.irq_call_back(&lcdc_dev->driver); -#endif lcdc_dev->driver.vsync_info.timestamp = timestamp; wake_up_interruptible_all(&lcdc_dev->driver.vsync_info.wait); diff --git a/drivers/video/rockchip/lcdc/rk3368_lcdc.c b/drivers/video/rockchip/lcdc/rk3368_lcdc.c old mode 100755 new mode 100644 index 292121bd497b..35c116ce0f4c --- a/drivers/video/rockchip/lcdc/rk3368_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3368_lcdc.c @@ -81,6 +81,16 @@ static struct rk_lcdc_win lcdc_win[] = { static int rk3368_lcdc_set_bcsh(struct rk_lcdc_driver *dev_drv, bool enable); +void __weak rk_pwm_set(int bl_pwm_period, int bl_pwm_duty) +{ + pr_info("If you want to use CABC, this func need implement at pwm\n"); +} + +void __weak rk_pwm_get(int *bl_pwm_period, int *bl_pwm_duty) +{ + pr_info("If you want to use CABC, this func need implement at pwm\n"); +} + /*#define WAIT_FOR_SYNC 1*/ u32 rk3368_get_hard_ware_vskiplines(u32 srch, u32 dsth) { @@ -153,7 +163,8 @@ static int rk3368_lcdc_clk_enable(struct lcdc_device *lcdc_dev) clk_prepare_enable(lcdc_dev->hclk); clk_prepare_enable(lcdc_dev->dclk); clk_prepare_enable(lcdc_dev->aclk); - clk_prepare_enable(lcdc_dev->pd); + if (lcdc_dev->pd) + clk_prepare_enable(lcdc_dev->pd); spin_lock(&lcdc_dev->reg_lock); lcdc_dev->clk_on = 1; spin_unlock(&lcdc_dev->reg_lock); @@ -176,7 +187,8 @@ static int rk3368_lcdc_clk_disable(struct lcdc_device *lcdc_dev) clk_disable_unprepare(lcdc_dev->dclk); clk_disable_unprepare(lcdc_dev->hclk); clk_disable_unprepare(lcdc_dev->aclk); - clk_disable_unprepare(lcdc_dev->pd); + if (lcdc_dev->pd) + clk_disable_unprepare(lcdc_dev->pd); } return 0; @@ -429,13 +441,19 @@ static int rk3368_lcdc_pre_init(struct rk_lcdc_driver *dev_drv) lcdc_dev->hclk = devm_clk_get(lcdc_dev->dev, "hclk_lcdc"); lcdc_dev->aclk = devm_clk_get(lcdc_dev->dev, "aclk_lcdc"); lcdc_dev->dclk = devm_clk_get(lcdc_dev->dev, "dclk_lcdc"); - lcdc_dev->pd = devm_clk_get(lcdc_dev->dev, "pd_lcdc"); - - if (IS_ERR(lcdc_dev->pd) || (IS_ERR(lcdc_dev->aclk)) || - (IS_ERR(lcdc_dev->dclk)) || (IS_ERR(lcdc_dev->hclk))) { + if ((IS_ERR(lcdc_dev->aclk)) || (IS_ERR(lcdc_dev->dclk)) || + (IS_ERR(lcdc_dev->hclk))) { dev_err(lcdc_dev->dev, "failed to get lcdc%d clk source\n", lcdc_dev->id); } + + lcdc_dev->pd = devm_clk_get(lcdc_dev->dev, "pd_lcdc"); + if (IS_ERR(lcdc_dev->pd)) { + dev_err(lcdc_dev->dev, "failed to get lcdc%d pdclk source\n", + lcdc_dev->id); + lcdc_dev->pd = NULL; + } + if (!support_uboot_display()) rk_disp_pwr_enable(dev_drv); rk3368_lcdc_clk_enable(lcdc_dev); @@ -1545,7 +1563,7 @@ static int __maybe_unused rk3368_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv) pr_info("%s,clk_on = %d\n", __func__, lcdc_dev->clk_on); return 0; } -#if defined(CONFIG_ROCKCHIP_IOMMU) +#if defined(CONFIG_RK_IOMMU) if (dev_drv->iommu_enabled) { if (!lcdc_dev->iommu_status && dev_drv->mmu_dev) { if (likely(lcdc_dev->clk_on)) { @@ -2213,7 +2231,7 @@ static int rk3368_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, rk3368_lcdc_pre_init(dev_drv); rk3368_lcdc_clk_enable(lcdc_dev); rk3368_lcdc_enable_irq(dev_drv); -#if defined(CONFIG_ROCKCHIP_IOMMU) +#if defined(CONFIG_RK_IOMMU) if (dev_drv->iommu_enabled) { if (!dev_drv->mmu_dev) { dev_drv->mmu_dev = @@ -2263,7 +2281,7 @@ static int rk3368_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, /*if ((!open) && (!lcdc_dev->atv_layer_cnt)) { rk3368_lcdc_disable_irq(lcdc_dev); rk3368_lcdc_reg_update(dev_drv); - #if defined(CONFIG_ROCKCHIP_IOMMU) + #if defined(CONFIG_RK_IOMMU) if (dev_drv->iommu_enabled) { if (dev_drv->mmu_dev) rockchip_iovmm_deactivate(dev_drv->dev); @@ -4771,9 +4789,6 @@ static irqreturn_t rk3368_lcdc_isr(int irq, void *dev_id) complete(&(lcdc_dev->driver.frame_done)); spin_unlock(&(lcdc_dev->driver.cpl_lock)); } -#ifdef CONFIG_DRM_ROCKCHIP - lcdc_dev->driver.irq_call_back(&lcdc_dev->driver); -#endif lcdc_dev->driver.vsync_info.timestamp = timestamp; wake_up_interruptible_all(&lcdc_dev->driver.vsync_info.wait); if ((screen->mode.vmode & FB_VMODE_NONINTERLACED) || @@ -4907,7 +4922,7 @@ static int rk3368_lcdc_parse_dt(struct lcdc_device *lcdc_dev) dev_drv->bcsh.cos_hue = (val >> 8) & 0xff; } -#if defined(CONFIG_ROCKCHIP_IOMMU) +#if defined(CONFIG_RK_IOMMU) if (of_property_read_u32(np, "rockchip,iommu-enabled", &val)) dev_drv->iommu_enabled = 0; else @@ -4974,7 +4989,7 @@ static int rk3368_lcdc_probe(struct platform_device *pdev) syscon_regmap_lookup_by_phandle(np, "rockchip,cru"); if (IS_ERR(lcdc_dev->cru_base)) { dev_err(&pdev->dev, "can't find lcdc cru_base property\n"); - return PTR_ERR(lcdc_dev->cru_base); + lcdc_dev->cru_base = NULL; } lcdc_dev->id = 0; @@ -4996,7 +5011,7 @@ static int rk3368_lcdc_probe(struct platform_device *pdev) } ret = devm_request_irq(dev, lcdc_dev->irq, rk3368_lcdc_isr, - IRQF_DISABLED | IRQF_SHARED, + IRQF_SHARED, dev_name(dev), lcdc_dev); if (ret) { dev_err(&pdev->dev, "cannot requeset irq %d - err %d\n", diff --git a/drivers/video/rockchip/rk_drm_fb.c b/drivers/video/rockchip/rk_drm_fb.c deleted file mode 100755 index 6381615b41ce..000000000000 --- a/drivers/video/rockchip/rk_drm_fb.c +++ /dev/null @@ -1,972 +0,0 @@ -/* - * drivers/video/rockchip/rk_fb.c - * - * Copyright (C) ROCKCHIP, Inc. - * Author:yzq - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_OF -#include -#include -#include