From 17f2e8e1dbe2cae66e99fd1a684db10bde792570 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 30 Jan 2016 17:44:32 +0300 Subject: video: fbdev: metronomefb: two harmless off by one bugs par->metromem_cmd->args[] is an array of 31 elements of size u16. Here we have initialized the first "i" elements and want to set the rest to zero. The issue here is that ARRAY_SIZE(par->metromem_cmd->args) is 31 and not 32 as in the original code. It means that we set ->csum to zero, but that is harmless because we immediately set it to the correct value on the next line. Still, the buffer overflow upsets static checkers so let's correct the math. Signed-off-by: Dan Carpenter Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/metronomefb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/metronomefb.c b/drivers/video/fbdev/metronomefb.c index ad04a01e2761..abb6bbf226d5 100644 --- a/drivers/video/fbdev/metronomefb.c +++ b/drivers/video/fbdev/metronomefb.c @@ -354,7 +354,8 @@ static int metronome_powerup_cmd(struct metronomefb_par *par) } /* the rest are 0 */ - memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2); + memset(&par->metromem_cmd->args[i], 0, + (ARRAY_SIZE(par->metromem_cmd->args) - i) * 2); par->metromem_cmd->csum = cs; @@ -376,7 +377,8 @@ static int metronome_config_cmd(struct metronomefb_par *par) memcpy(par->metromem_cmd->args, epd_frame_table[par->dt].config, sizeof(epd_frame_table[par->dt].config)); /* the rest are 0 */ - memset((u8 *) (par->metromem_cmd->args + 4), 0, (32-4)*2); + memset(&par->metromem_cmd->args[4], 0, + (ARRAY_SIZE(par->metromem_cmd->args) - 4) * 2); par->metromem_cmd->csum = 0xCC10; par->metromem_cmd->csum += calc_img_cksum(par->metromem_cmd->args, 4); -- cgit v1.2.3-59-g8ed1b From 206fc20598157ce15597822cf01b94377e30075b Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 9 Feb 2016 10:18:32 +0100 Subject: video: Use bool instead int pointer for get_opt_bool() argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the function name already indicates that get_opt_bool() parses for a bool. It is not a surprise that compiler is complaining about it when -Werror=incompatible-pointer-types is used: drivers/video/fbdev/intelfb/intelfbdrv.c: In function ‘intelfb_setup’: drivers/video/fbdev/intelfb/intelfbdrv.c:353:39: error: passing argument 3 of ‘get_opt_bool’ from incompatible pointer type [-Werror=incompatible-pointer-types] if (get_opt_bool(this_opt, "accel", &accel)) Signed-off-by: Daniel Wagner Reported-by: Fengguang Wu Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/intelfb/intelfbdrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index bbec737eef30..bf207444ba0c 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -302,7 +302,7 @@ static __inline__ int get_opt_int(const char *this_opt, const char *name, } static __inline__ int get_opt_bool(const char *this_opt, const char *name, - int *ret) + bool *ret) { if (!ret) return 0; -- cgit v1.2.3-59-g8ed1b From f059c4b220b821f8ed7b1b12387cce86373f666e Mon Sep 17 00:00:00 2001 From: Andrzej Hajda Date: Mon, 15 Feb 2016 15:35:24 +0100 Subject: fbdev: exynos: fix IS_ERR_VALUE usage IS_ERR_VALUE macro should be used only with unsigned long type. For signed types comparison 'ret < 0' should be used. The patch follows conclusion from discussion on LKML [1][2]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2120927 [2]: http://permalink.gmane.org/gmane.linux.kernel/2150581 Signed-off-by: Andrzej Hajda Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/exynos/exynos_mipi_dsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/exynos/exynos_mipi_dsi.c b/drivers/video/fbdev/exynos/exynos_mipi_dsi.c index b527fe464628..951b592794e3 100644 --- a/drivers/video/fbdev/exynos/exynos_mipi_dsi.c +++ b/drivers/video/fbdev/exynos/exynos_mipi_dsi.c @@ -402,12 +402,12 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) goto error; } - dsim->irq = platform_get_irq(pdev, 0); - if (IS_ERR_VALUE(dsim->irq)) { + ret = platform_get_irq(pdev, 0); + if (ret < 0) { dev_err(&pdev->dev, "failed to request dsim irq resource\n"); - ret = -EINVAL; goto error; } + dsim->irq = ret; init_completion(&dsim_wr_comp); init_completion(&dsim_rd_comp); -- cgit v1.2.3-59-g8ed1b From 7fdfc702d301a127d875e5608342a249201fdb4a Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 23 Feb 2016 18:14:17 +0530 Subject: fbdev: n411: check return value We were not checking the return value of platform_device_add_data() which can fail. Signed-off-by: Sudip Mukherjee Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/n411.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/n411.c b/drivers/video/fbdev/n411.c index 935830fea7b6..053deacad7cc 100644 --- a/drivers/video/fbdev/n411.c +++ b/drivers/video/fbdev/n411.c @@ -165,16 +165,22 @@ static int __init n411_init(void) if (!n411_device) return -ENOMEM; - platform_device_add_data(n411_device, &n411_board, sizeof(n411_board)); + ret = platform_device_add_data(n411_device, &n411_board, + sizeof(n411_board)); + if (ret) + goto put_plat_device; /* this _add binds hecubafb to n411. hecubafb refcounts n411 */ ret = platform_device_add(n411_device); if (ret) - platform_device_put(n411_device); + goto put_plat_device; - return ret; + return 0; +put_plat_device: + platform_device_put(n411_device); + return ret; } static void __exit n411_exit(void) -- cgit v1.2.3-59-g8ed1b From 8b4c78a35adb19be89c9e8829074289e16d0bb4b Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 22 Feb 2016 10:59:51 +0900 Subject: fbdev: sh_mobile_lcdc: Use ARCH_RENESAS Make use of ARCH_RENESAS in place of ARCH_SHMOBILE. This is part of an ongoing process to migrate from ARCH_SHMOBILE to ARCH_RENESAS the motivation for which being that RENESAS seems to be a more appropriate name than SHMOBILE for the majority of Renesas ARM based SoCs. Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 8ea45a5cd806..936ebd4bcf73 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -1985,7 +1985,7 @@ config FB_W100 config FB_SH_MOBILE_LCDC tristate "SuperH Mobile LCDC framebuffer support" - depends on FB && (SUPERH || ARCH_SHMOBILE) && HAVE_CLK + depends on FB && (SUPERH || ARCH_RENESAS) && HAVE_CLK depends on FB_SH_MOBILE_MERAM || !FB_SH_MOBILE_MERAM select FB_SYS_FILLRECT select FB_SYS_COPYAREA -- cgit v1.2.3-59-g8ed1b From af22f647b4a0b4a549ccbbc55a324edc54089564 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 22 Feb 2016 01:54:46 +0000 Subject: video: fbdev: pmag-ba-fb: Fix the lower margin size According to the board specification[1] the width of the vertical sync front porch is 12 pixels or the same as the width of the horizontal sync front porch. This in turn means the size of the lower margin is 0, because the vertical sync starts as soon as the start of the horizontal sync terminates the last line. References: [1] "PMAG-BA TURBOchannel Color Frame Buffer Functional Specification", Revision 1.2, Workstation Systems Engineering, Digital Equipment Corporation, August 27, 1990, Table 3-5: "Video Timing" Signed-off-by: Maciej W. Rozycki Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/pmag-ba-fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/pmag-ba-fb.c b/drivers/video/fbdev/pmag-ba-fb.c index 914a52ba8477..5872bc4af3ce 100644 --- a/drivers/video/fbdev/pmag-ba-fb.c +++ b/drivers/video/fbdev/pmag-ba-fb.c @@ -60,7 +60,7 @@ static struct fb_var_screeninfo pmagbafb_defined = { .left_margin = 116, .right_margin = 12, .upper_margin = 34, - .lower_margin = 12, + .lower_margin = 0, .hsync_len = 128, .vsync_len = 3, .sync = FB_SYNC_ON_GREEN, -- cgit v1.2.3-59-g8ed1b From 90c83176e5cfa666bb2e7643d74ca87e08e171cb Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 22 Feb 2016 01:54:59 +0000 Subject: video: fbdev: pmag-aa-fb: Adapt to current APIs Rework the driver to use the current frambuffer and TURBOchannel APIs, including proper resource management and using the new framework for hardware cursor support. NB two Bt431 cursor generators are included onboard, both responding at the same TURBOchannel bus addresses and with their host data buses wired to byte lanes #0 and #1 respectively of the 32-bit bus. Therefore both can be accessed simultaneously with 16-bit data transfers. Cursor outputs of the chip wired to lane #0 drive the respective overlay select inputs of the Bt455 RAMDAC, whereas cursor outputs of the chip wired to lane #1 drive the respective P3 pixel select inputs of the RAMDAC. So 5 (out of 17) Bt455 color registers are usable with this board: palette entries #0 and #1 for frame buffer pixel data driven while neither cursor generator is active, palette entries #8 and #9 for frame buffer pixel data driven while cursor generator #1 is active only and the overlay entry while cursor generator #0 is active. Signed-off-by: Maciej W. Rozycki Signed-off-by: Tomi Valkeinen --- drivers/video/fbdev/bt431.h | 41 +-- drivers/video/fbdev/pmag-aa-fb.c | 595 +++++++++++++-------------------------- 2 files changed, 215 insertions(+), 421 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/bt431.h b/drivers/video/fbdev/bt431.h index 04e0cfbba538..108fab39fd78 100644 --- a/drivers/video/fbdev/bt431.h +++ b/drivers/video/fbdev/bt431.h @@ -2,6 +2,7 @@ * linux/drivers/video/bt431.h * * Copyright 2003 Thiemo Seufer + * Copyright 2016 Maciej W. Rozycki * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this @@ -9,6 +10,8 @@ */ #include +#define BT431_CURSOR_SIZE 64 + /* * Bt431 cursor generator registers, 32-bit aligned. * Two twin Bt431 are used on the DECstation's PMAG-AA. @@ -196,28 +199,30 @@ static inline void bt431_position_cursor(struct bt431_regs *regs, u16 x, u16 y) bt431_write_reg_inc(regs, (y >> 8) & 0x0f); /* BT431_REG_CYHI */ } -static inline void bt431_set_font(struct bt431_regs *regs, u8 fgc, - u16 width, u16 height) +static inline void bt431_set_cursor(struct bt431_regs *regs, + const char *data, const char *mask, + u16 rop, u16 width, u16 height) { + u16 x, y; int i; - u16 fgp = fgc ? 0xffff : 0x0000; - u16 bgp = fgc ? 0x0000 : 0xffff; + i = 0; + width = DIV_ROUND_UP(width, 8); bt431_select_reg(regs, BT431_REG_CRAM_BASE); - for (i = BT431_REG_CRAM_BASE; i <= BT431_REG_CRAM_END; i++) { - u16 value; - - if (height << 6 <= i << 3) - value = bgp; - else if (width <= i % 8 << 3) - value = bgp; - else if (((width >> 3) & 0xffff) > i % 8) - value = fgp; - else - value = fgp & ~(bgp << (width % 8 << 1)); - - bt431_write_cmap_inc(regs, value); - } + for (y = 0; y < BT431_CURSOR_SIZE; y++) + for (x = 0; x < BT431_CURSOR_SIZE / 8; x++) { + u16 val = 0; + + if (y < height && x < width) { + val = mask[i]; + if (rop == ROP_XOR) + val = (val << 8) | (val ^ data[i]); + else + val = (val << 8) | (val & data[i]); + i++; + } + bt431_write_cmap_inc(regs, val); + } } static inline void bt431_init_cursor(struct bt431_regs *regs) diff --git a/drivers/video/fbdev/pmag-aa-fb.c b/drivers/video/fbdev/pmag-aa-fb.c index 838424817de2..3920b4ec8fc4 100644 --- a/drivers/video/fbdev/pmag-aa-fb.c +++ b/drivers/video/fbdev/pmag-aa-fb.c @@ -8,6 +8,7 @@ * and Harald Koerfgen , which itself is derived from * "HP300 Topcat framebuffer support (derived from macfb of all things) * Phil Blundell 1998" + * Copyright (c) 2016 Maciej W. Rozycki * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this @@ -21,37 +22,29 @@ * * 2003-09-21 Thiemo Seufer * Hardware cursor support. + * + * 2016-02-21 Maciej W. Rozycki + * Version 0.03: Rewritten for the new FB and TC APIs. */ -#include -#include + +#include #include -#include -#include -#include -#include -#include #include -#include - -#include -#include -#include - -#include