From 16fd24847d7a2bc8bcc823aa77415a49ff26c58d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 12 Jun 2015 10:18:57 +0200 Subject: video: stmfb: Add device tree support Signed-off-by: Sascha Hauer --- drivers/video/stm.c | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/video/stm.c b/drivers/video/stm.c index 3c90c0dc3f..bf913f1ec6 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -317,7 +317,7 @@ static int stmfb_activate_var(struct fb_info *fb_info) size = calc_line_length(mode->xres, fb_info->bits_per_pixel) * mode->yres; - if (pdata->fixed_screen) { + if (pdata && pdata->fixed_screen) { if (pdata->fixed_screen_size < size) return -ENOMEM; fb_info->screen_base = pdata->fixed_screen; @@ -497,16 +497,37 @@ static int stmfb_probe(struct device_d *hw_dev) return PTR_ERR(fbi.clk); clk_enable(fbi.clk); + fbi.info.bits_per_pixel = 16; + /* add runtime video info */ - fbi.info.modes.modes = pdata->mode_list; - fbi.info.modes.num_modes = pdata->mode_cnt; - fbi.info.mode = &fbi.info.modes.modes[0]; - fbi.info.xres = fbi.info.mode->xres; - fbi.info.yres = fbi.info.mode->yres; - if (pdata->bits_per_pixel) - fbi.info.bits_per_pixel = pdata->bits_per_pixel; - else - fbi.info.bits_per_pixel = 16; + if (pdata) { + fbi.info.modes.modes = pdata->mode_list; + fbi.info.modes.num_modes = pdata->mode_cnt; + fbi.info.mode = &fbi.info.modes.modes[0]; + if (pdata->bits_per_pixel) + fbi.info.bits_per_pixel = pdata->bits_per_pixel; + } else { + struct display_timings *modes; + struct device_node *display; + + if (!IS_ENABLED(CONFIG_OFDEVICE) || !hw_dev->device_node) + return -EINVAL; + + display = of_parse_phandle(hw_dev->device_node, "display", 0); + if (!display) { + dev_err(hw_dev, "no display phandle\n"); + return -EINVAL; + } + + modes = of_get_display_timings(display); + if (IS_ERR(modes)) { + dev_err(hw_dev, "unable to parse display timings\n"); + return PTR_ERR(modes); + } + + fbi.info.modes.modes = modes->modes; + fbi.info.modes.num_modes = modes->num_modes; + } hw_dev->info = stmfb_info; @@ -519,9 +540,20 @@ static int stmfb_probe(struct device_d *hw_dev) return 0; } +static __maybe_unused struct of_device_id stmfb_compatible[] = { + { + .compatible = "fsl,imx23-lcdif", + }, { + .compatible = "fsl,imx28-lcdif", + }, { + /* sentinel */ + } +}; + static struct driver_d stmfb_driver = { .name = "stmfb", .probe = stmfb_probe, + .of_compatible = DRV_OF_COMPAT(stmfb_compatible), }; device_platform_driver(stmfb_driver); -- cgit v1.2.3 From e3ea90860e9991bb6097ed79d8f0d533a05ad56b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 15 Dec 2014 16:13:16 +0100 Subject: video: Add backlight support This adds a small backlight layer. It provides a backlight device on which the brightness parameter can be used to adjust the brightness. Signed-off-by: Sascha Hauer --- drivers/video/Kconfig | 4 +++ drivers/video/Makefile | 1 + drivers/video/backlight.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ include/video/backlight.h | 20 +++++++++++ 4 files changed, 115 insertions(+) create mode 100644 drivers/video/backlight.c create mode 100644 include/video/backlight.h diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index f096a5456b..e108d8a5b9 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -93,4 +93,8 @@ config DRIVER_VIDEO_EDID This enabled support for reading and parsing EDID data from an attached monitor. +config DRIVER_VIDEO_BACKLIGHT + bool "Add backlight support" + help + Enable this for backlight support. endif diff --git a/drivers/video/Makefile b/drivers/video/Makefile index ae9f6e545e..0655b0f705 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_VIDEO) += fb.o obj-$(CONFIG_DRIVER_VIDEO_EDID) += edid.o obj-$(CONFIG_OFDEVICE) += of_display_timing.o +obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT) += backlight.o obj-$(CONFIG_DRIVER_VIDEO_ATMEL) += atmel_lcdfb.o atmel_lcdfb_core.o obj-$(CONFIG_DRIVER_VIDEO_ATMEL_HLCD) += atmel_hlcdfb.o atmel_lcdfb_core.o diff --git a/drivers/video/backlight.c b/drivers/video/backlight.c new file mode 100644 index 0000000000..ddde6f8523 --- /dev/null +++ b/drivers/video/backlight.c @@ -0,0 +1,90 @@ +#include +#include +#include +#include