提交 1270be4a 编写于 作者: L Luc Verhaegen 提交者: Tomi Valkeinen

simplefb: formalize pseudo palette handling

Add a proper struct describing simplefb private data, with the palette in there,
instead of directly storing the palette in the fb_info->par pointer.
Signed-off-by: NLuc Verhaegen <libv@skynet.be>
Acked-by: NStephen Warren <swarren@nvidia.com>
[hdegoede@redhat.com: drop unnecessary void * cast]
Reviewed-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NHans de Goede <hdegoede@redhat.com>
Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: NMaxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
Acked-by: NGrant Likely <grant.likely@linaro.org>
Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
上级 9ee4cd1a
...@@ -41,6 +41,8 @@ static struct fb_var_screeninfo simplefb_var = { ...@@ -41,6 +41,8 @@ static struct fb_var_screeninfo simplefb_var = {
.vmode = FB_VMODE_NONINTERLACED, .vmode = FB_VMODE_NONINTERLACED,
}; };
#define PSEUDO_PALETTE_SIZE 16
static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info) u_int transp, struct fb_info *info)
{ {
...@@ -50,7 +52,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -50,7 +52,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u32 cb = blue >> (16 - info->var.blue.length); u32 cb = blue >> (16 - info->var.blue.length);
u32 value; u32 value;
if (regno >= 16) if (regno >= PSEUDO_PALETTE_SIZE)
return -EINVAL; return -EINVAL;
value = (cr << info->var.red.offset) | value = (cr << info->var.red.offset) |
...@@ -163,11 +165,16 @@ static int simplefb_parse_pd(struct platform_device *pdev, ...@@ -163,11 +165,16 @@ static int simplefb_parse_pd(struct platform_device *pdev,
return 0; return 0;
} }
struct simplefb_par {
u32 palette[PSEUDO_PALETTE_SIZE];
};
static int simplefb_probe(struct platform_device *pdev) static int simplefb_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct simplefb_params params; struct simplefb_params params;
struct fb_info *info; struct fb_info *info;
struct simplefb_par *par;
struct resource *mem; struct resource *mem;
if (fb_get_options("simplefb", NULL)) if (fb_get_options("simplefb", NULL))
...@@ -188,11 +195,13 @@ static int simplefb_probe(struct platform_device *pdev) ...@@ -188,11 +195,13 @@ static int simplefb_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
info = framebuffer_alloc(sizeof(u32) * 16, &pdev->dev); info = framebuffer_alloc(sizeof(struct simplefb_par), &pdev->dev);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, info); platform_set_drvdata(pdev, info);
par = info->par;
info->fix = simplefb_fix; info->fix = simplefb_fix;
info->fix.smem_start = mem->start; info->fix.smem_start = mem->start;
info->fix.smem_len = resource_size(mem); info->fix.smem_len = resource_size(mem);
...@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev) ...@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev)
framebuffer_release(info); framebuffer_release(info);
return -ENODEV; return -ENODEV;
} }
info->pseudo_palette = (void *)(info + 1); info->pseudo_palette = par->palette;
dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n", dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n",
info->fix.smem_start, info->fix.smem_len, info->fix.smem_start, info->fix.smem_len,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册