diff options
| -rw-r--r-- | drivers/video/imxfb.c | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 7b3400cfae6d..25323ea33a54 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/drivers/video/imxfb.c | ||
| 3 | * | ||
| 4 | * Freescale i.MX Frame Buffer device driver | 2 | * Freescale i.MX Frame Buffer device driver |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 2004 Sascha Hauer, Pengutronix | 4 | * Copyright (C) 2004 Sascha Hauer, Pengutronix |
| @@ -168,20 +166,21 @@ struct imxfb_info { | |||
| 168 | #define MIN_YRES 64 | 166 | #define MIN_YRES 64 |
| 169 | 167 | ||
| 170 | static struct imxfb_rgb def_rgb_16 = { | 168 | static struct imxfb_rgb def_rgb_16 = { |
| 171 | .red = { .offset = 8, .length = 4, }, | 169 | .red = {.offset = 8, .length = 4,}, |
| 172 | .green = { .offset = 4, .length = 4, }, | 170 | .green = {.offset = 4, .length = 4,}, |
| 173 | .blue = { .offset = 0, .length = 4, }, | 171 | .blue = {.offset = 0, .length = 4,}, |
| 174 | .transp = { .offset = 0, .length = 0, }, | 172 | .transp = {.offset = 0, .length = 0,}, |
| 175 | }; | 173 | }; |
| 176 | 174 | ||
| 177 | static struct imxfb_rgb def_rgb_8 = { | 175 | static struct imxfb_rgb def_rgb_8 = { |
| 178 | .red = { .offset = 0, .length = 8, }, | 176 | .red = {.offset = 0, .length = 8,}, |
| 179 | .green = { .offset = 0, .length = 8, }, | 177 | .green = {.offset = 0, .length = 8,}, |
| 180 | .blue = { .offset = 0, .length = 8, }, | 178 | .blue = {.offset = 0, .length = 8,}, |
| 181 | .transp = { .offset = 0, .length = 0, }, | 179 | .transp = {.offset = 0, .length = 0,}, |
| 182 | }; | 180 | }; |
| 183 | 181 | ||
| 184 | static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info); | 182 | static int imxfb_activate_var(struct fb_var_screeninfo *var, |
| 183 | struct fb_info *info); | ||
| 185 | 184 | ||
| 186 | static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) | 185 | static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) |
| 187 | { | 186 | { |
| @@ -190,9 +189,8 @@ static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) | |||
| 190 | return chan << bf->offset; | 189 | return chan << bf->offset; |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | static int | 192 | static int imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue, |
| 194 | imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue, | 193 | u_int trans, struct fb_info *info) |
| 195 | u_int trans, struct fb_info *info) | ||
| 196 | { | 194 | { |
| 197 | struct imxfb_info *fbi = info->par; | 195 | struct imxfb_info *fbi = info->par; |
| 198 | u_int val, ret = 1; | 196 | u_int val, ret = 1; |
| @@ -209,8 +207,7 @@ imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue, | |||
| 209 | return ret; | 207 | return ret; |
| 210 | } | 208 | } |
| 211 | 209 | ||
| 212 | static int | 210 | static int imxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, |
| 213 | imxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | ||
| 214 | u_int trans, struct fb_info *info) | 211 | u_int trans, struct fb_info *info) |
| 215 | { | 212 | { |
| 216 | struct imxfb_info *fbi = info->par; | 213 | struct imxfb_info *fbi = info->par; |
| @@ -270,8 +267,7 @@ imxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |||
| 270 | * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale, | 267 | * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale, |
| 271 | * bitfields, horizontal timing, vertical timing. | 268 | * bitfields, horizontal timing, vertical timing. |
| 272 | */ | 269 | */ |
| 273 | static int | 270 | static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
| 274 | imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | ||
| 275 | { | 271 | { |
| 276 | struct imxfb_info *fbi = info->par; | 272 | struct imxfb_info *fbi = info->par; |
| 277 | int rgbidx; | 273 | int rgbidx; |
| @@ -343,8 +339,7 @@ static int imxfb_set_par(struct fb_info *info) | |||
| 343 | info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR; | 339 | info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR; |
| 344 | } | 340 | } |
| 345 | 341 | ||
| 346 | info->fix.line_length = var->xres_virtual * | 342 | info->fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; |
| 347 | var->bits_per_pixel / 8; | ||
| 348 | fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16; | 343 | fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16; |
| 349 | 344 | ||
| 350 | imxfb_activate_var(var, info); | 345 | imxfb_activate_var(var, info); |
| @@ -375,9 +370,9 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) | |||
| 375 | 370 | ||
| 376 | writel(RMCR_LCDC_EN, fbi->regs + LCDC_RMCR); | 371 | writel(RMCR_LCDC_EN, fbi->regs + LCDC_RMCR); |
| 377 | 372 | ||
| 378 | if(fbi->backlight_power) | 373 | if (fbi->backlight_power) |
| 379 | fbi->backlight_power(1); | 374 | fbi->backlight_power(1); |
| 380 | if(fbi->lcd_power) | 375 | if (fbi->lcd_power) |
| 381 | fbi->lcd_power(1); | 376 | fbi->lcd_power(1); |
| 382 | } | 377 | } |
| 383 | 378 | ||
| @@ -385,9 +380,9 @@ static void imxfb_disable_controller(struct imxfb_info *fbi) | |||
| 385 | { | 380 | { |
| 386 | pr_debug("Disabling LCD controller\n"); | 381 | pr_debug("Disabling LCD controller\n"); |
| 387 | 382 | ||
| 388 | if(fbi->backlight_power) | 383 | if (fbi->backlight_power) |
| 389 | fbi->backlight_power(0); | 384 | fbi->backlight_power(0); |
| 390 | if(fbi->lcd_power) | 385 | if (fbi->lcd_power) |
| 391 | fbi->lcd_power(0); | 386 | fbi->lcd_power(0); |
| 392 | 387 | ||
| 393 | writel(0, fbi->regs + LCDC_RMCR); | 388 | writel(0, fbi->regs + LCDC_RMCR); |
| @@ -495,7 +490,8 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf | |||
| 495 | static int imxfb_suspend(struct platform_device *dev, pm_message_t state) | 490 | static int imxfb_suspend(struct platform_device *dev, pm_message_t state) |
| 496 | { | 491 | { |
| 497 | struct imxfb_info *fbi = platform_get_drvdata(dev); | 492 | struct imxfb_info *fbi = platform_get_drvdata(dev); |
| 498 | pr_debug("%s\n",__func__); | 493 | |
| 494 | pr_debug("%s\n", __func__); | ||
| 499 | 495 | ||
| 500 | imxfb_disable_controller(fbi); | 496 | imxfb_disable_controller(fbi); |
| 501 | return 0; | 497 | return 0; |
| @@ -504,7 +500,8 @@ static int imxfb_suspend(struct platform_device *dev, pm_message_t state) | |||
| 504 | static int imxfb_resume(struct platform_device *dev) | 500 | static int imxfb_resume(struct platform_device *dev) |
| 505 | { | 501 | { |
| 506 | struct imxfb_info *fbi = platform_get_drvdata(dev); | 502 | struct imxfb_info *fbi = platform_get_drvdata(dev); |
| 507 | pr_debug("%s\n",__func__); | 503 | |
| 504 | pr_debug("%s\n", __func__); | ||
| 508 | 505 | ||
| 509 | imxfb_enable_controller(fbi); | 506 | imxfb_enable_controller(fbi); |
| 510 | return 0; | 507 | return 0; |
| @@ -522,7 +519,7 @@ static int __init imxfb_init_fbinfo(struct platform_device *pdev) | |||
| 522 | 519 | ||
| 523 | pr_debug("%s\n",__func__); | 520 | pr_debug("%s\n",__func__); |
| 524 | 521 | ||
| 525 | info->pseudo_palette = kmalloc( sizeof(u32) * 16, GFP_KERNEL); | 522 | info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); |
| 526 | if (!info->pseudo_palette) | 523 | if (!info->pseudo_palette) |
| 527 | return -ENOMEM; | 524 | return -ENOMEM; |
| 528 | 525 | ||
| @@ -530,22 +527,23 @@ static int __init imxfb_init_fbinfo(struct platform_device *pdev) | |||
| 530 | 527 | ||
| 531 | strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id)); | 528 | strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id)); |
| 532 | 529 | ||
| 533 | info->fix.type = FB_TYPE_PACKED_PIXELS; | 530 | info->fix.type = FB_TYPE_PACKED_PIXELS; |
| 534 | info->fix.type_aux = 0; | 531 | info->fix.type_aux = 0; |
| 535 | info->fix.xpanstep = 0; | 532 | info->fix.xpanstep = 0; |
| 536 | info->fix.ypanstep = 0; | 533 | info->fix.ypanstep = 0; |
| 537 | info->fix.ywrapstep = 0; | 534 | info->fix.ywrapstep = 0; |
| 538 | info->fix.accel = FB_ACCEL_NONE; | 535 | info->fix.accel = FB_ACCEL_NONE; |
| 539 | 536 | ||
| 540 | info->var.nonstd = 0; | 537 | info->var.nonstd = 0; |
| 541 | info->var.activate = FB_ACTIVATE_NOW; | 538 | info->var.activate = FB_ACTIVATE_NOW; |
| 542 | info->var.height = -1; | 539 | info->var.height = -1; |
| 543 | info->var.width = -1; | 540 | info->var.width = -1; |
| 544 | info->var.accel_flags = 0; | 541 | info->var.accel_flags = 0; |
| 545 | info->var.vmode = FB_VMODE_NONINTERLACED; | 542 | info->var.vmode = FB_VMODE_NONINTERLACED; |
| 546 | 543 | ||
| 547 | info->fbops = &imxfb_ops; | 544 | info->fbops = &imxfb_ops; |
| 548 | info->flags = FBINFO_FLAG_DEFAULT | FBINFO_READS_FAST; | 545 | info->flags = FBINFO_FLAG_DEFAULT | |
| 546 | FBINFO_READS_FAST; | ||
| 549 | 547 | ||
| 550 | fbi->rgb[RGB_16] = &def_rgb_16; | 548 | fbi->rgb[RGB_16] = &def_rgb_16; |
| 551 | fbi->rgb[RGB_8] = &def_rgb_8; | 549 | fbi->rgb[RGB_8] = &def_rgb_8; |
| @@ -593,17 +591,17 @@ static int __init imxfb_probe(struct platform_device *pdev) | |||
| 593 | printk("i.MX Framebuffer driver\n"); | 591 | printk("i.MX Framebuffer driver\n"); |
| 594 | 592 | ||
| 595 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 593 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 596 | if(!res) | 594 | if (!res) |
| 597 | return -ENODEV; | 595 | return -ENODEV; |
| 598 | 596 | ||
| 599 | inf = pdev->dev.platform_data; | 597 | inf = pdev->dev.platform_data; |
| 600 | if(!inf) { | 598 | if (!inf) { |
| 601 | dev_err(&pdev->dev,"No platform_data available\n"); | 599 | dev_err(&pdev->dev,"No platform_data available\n"); |
| 602 | return -ENOMEM; | 600 | return -ENOMEM; |
| 603 | } | 601 | } |
| 604 | 602 | ||
| 605 | info = framebuffer_alloc(sizeof(struct imxfb_info), &pdev->dev); | 603 | info = framebuffer_alloc(sizeof(struct imxfb_info), &pdev->dev); |
| 606 | if(!info) | 604 | if (!info) |
| 607 | return -ENOMEM; | 605 | return -ENOMEM; |
| 608 | 606 | ||
| 609 | fbi = info->par; | 607 | fbi = info->par; |
| @@ -611,7 +609,7 @@ static int __init imxfb_probe(struct platform_device *pdev) | |||
| 611 | platform_set_drvdata(pdev, info); | 609 | platform_set_drvdata(pdev, info); |
| 612 | 610 | ||
| 613 | ret = imxfb_init_fbinfo(pdev); | 611 | ret = imxfb_init_fbinfo(pdev); |
| 614 | if( ret < 0 ) | 612 | if (ret < 0) |
| 615 | goto failed_init; | 613 | goto failed_init; |
| 616 | 614 | ||
| 617 | res = request_mem_region(res->start, resource_size(res), | 615 | res = request_mem_region(res->start, resource_size(res), |
| @@ -658,7 +656,7 @@ static int __init imxfb_probe(struct platform_device *pdev) | |||
| 658 | */ | 656 | */ |
| 659 | imxfb_check_var(&info->var, info); | 657 | imxfb_check_var(&info->var, info); |
| 660 | 658 | ||
| 661 | ret = fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); | 659 | ret = fb_alloc_cmap(&info->cmap, 1 << info->var.bits_per_pixel, 0); |
| 662 | if (ret < 0) | 660 | if (ret < 0) |
| 663 | goto failed_cmap; | 661 | goto failed_cmap; |
| 664 | 662 | ||
