15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/string.h>
20 #include <linux/slab.h>
31 #include <video/pxa168fb.h>
35 #define DEFAULT_REFRESH 60
49 var->
green.length <= 6 && var->
blue.length <= 5) {
50 if (var->
transp.length == 0) {
51 if (var->
red.offset >= var->
blue.offset)
57 if (var->
transp.length == 1 && var->
green.length <= 5) {
58 if (var->
red.offset >= var->
blue.offset)
71 var->
green.length <= 8 && var->
blue.length <= 8) {
73 if (var->
red.offset >= var->
blue.offset)
80 if (var->
red.offset >= var->
blue.offset)
85 if (var->
red.offset >= var->
blue.offset)
102 var->
red.offset = 11; var->
red.length = 5;
104 var->
blue.offset = 0; var->
blue.length = 5;
109 var->
red.offset = 0; var->
red.length = 5;
111 var->
blue.offset = 11; var->
blue.length = 5;
116 var->
red.offset = 10; var->
red.length = 5;
118 var->
blue.offset = 0; var->
blue.length = 5;
123 var->
red.offset = 0; var->
red.length = 5;
125 var->
blue.offset = 10; var->
blue.length = 5;
130 var->
red.offset = 16; var->
red.length = 8;
132 var->
blue.offset = 0; var->
blue.length = 8;
137 var->
red.offset = 0; var->
red.length = 8;
139 var->
blue.offset = 16; var->
blue.length = 8;
144 var->
red.offset = 16; var->
red.length = 8;
146 var->
blue.offset = 0; var->
blue.length = 8;
151 var->
red.offset = 0; var->
red.length = 8;
153 var->
blue.offset = 16; var->
blue.length = 8;
158 var->
red.offset = 0; var->
red.length = 8;
160 var->
blue.offset = 0; var->
blue.length = 8;
171 set_pix_fmt(var, pix_fmt);
204 pix_fmt = determine_best_pix_fmt(var);
207 set_pix_fmt(var, pix_fmt);
262 dev_err(fbi->
dev,
"Input refresh or pixclock is wrong.\n");
274 div_result = 1000000000000ll;
276 needed_pixclk = (
u32)div_result;
281 if (divider_int < 2) {
282 dev_warn(fbi->
dev,
"Warning: clock source is too slow."
283 "Try smaller resolution\n");
316 x |= (fbi->
pix_fmt >> 1) << 16;
351 static void set_graphics_start(
struct fb_info *info,
int xoffset,
int yoffset)
364 static void set_dumb_panel_control(
struct fb_info *info)
389 static void set_dumb_screen_dimensions(
struct fb_info *info)
402 static int pxa168fb_set_par(
struct fb_info *info)
410 mi = fbi->
dev->platform_data;
420 info->
fix.ypanstep = var->
yres;
440 set_clock_divider(fbi, &mode);
443 set_dma_control0(fbi);
444 set_dma_control1(fbi, info->
var.sync);
460 set_dumb_panel_control(info);
461 set_dumb_screen_dimensions(info);
479 return ((chan & 0xffff) >> (16 - bf->
length)) << bf->
offset;
488 return (red << 16) | (green << 8) | blue;
492 pxa168fb_setcolreg(
unsigned int regno,
unsigned int red,
unsigned int green,
493 unsigned int blue,
unsigned int trans,
struct fb_info *info)
498 if (info->
var.grayscale)
499 red = green = blue = (19595 * red + 38470 * green +
503 val = chan_to_field(red, &info->
var.red);
504 val |= chan_to_field(green, &info->
var.green);
505 val |= chan_to_field(blue , &info->
var.blue);
510 val = to_rgb(red, green, blue);
518 static int pxa168fb_blank(
int blank,
struct fb_info *info)
523 set_dumb_panel_control(info);
543 writel(isr & (~GRA_FRAME_IRQ0_ENA_MASK),
551 static struct fb_ops pxa168fb_ops = {
553 .fb_check_var = pxa168fb_check_var,
554 .fb_set_par = pxa168fb_set_par,
555 .fb_setcolreg = pxa168fb_setcolreg,
556 .fb_blank = pxa168fb_blank,
557 .fb_pan_display = pxa168fb_pan_display,
569 u32 total_w, total_h, refresh;
587 dev_dbg(fbi->
dev,
"pxa168fb: find best mode: res = %dx%d\n",
596 div_result = 1000000000000ll;
597 do_div(div_result, total_w * total_h * refresh);
612 mi = pdev->
dev.platform_data;
614 dev_err(&pdev->
dev,
"no platform data defined\n");
626 dev_err(&pdev->
dev,
"no IO memory defined\n");
661 info->
fix.type_aux = 0;
662 info->
fix.xpanstep = 0;
663 info->
fix.ypanstep = 0;
664 info->
fix.ywrapstep = 0;
666 info->
fix.mmio_len = resource_size(res);
668 info->
fbops = &pxa168fb_ops;
678 goto failed_free_info;
690 goto failed_free_info;
694 set_graphics_start(info, 0, 0);
706 pxa168fb_init_mode(info, mi);
711 ret = pxa168fb_check_var(&info->
var, info);
713 goto failed_free_fbmem;
720 pxa168fb_set_par(info);
738 goto failed_free_clk;
744 ret = devm_request_irq(&pdev->
dev, irq, pxa168fb_handle_irq,
747 dev_err(&pdev->
dev,
"unable to request IRQ\n");
749 goto failed_free_cmap;
762 dev_err(&pdev->
dev,
"Failed to register pxa168-fb: %d\n", ret);
764 goto failed_free_cmap;
767 platform_set_drvdata(pdev, fbi);
782 dev_err(&pdev->
dev,
"frame buffer device init failed with %d\n", ret);
828 .probe = pxa168fb_probe,