Lines Matching +full:sync +full:- +full:on +full:- +full:green
1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include <linux/dma-mapping.h>
19 if (var->bits_per_pixel == 8) in var_to_pixfmt()
25 if (var->bits_per_pixel == 16 && var->red.length == 8 && in var_to_pixfmt()
26 var->green.length == 4 && var->blue.length == 4) { in var_to_pixfmt()
27 if (var->green.offset >= var->blue.offset) in var_to_pixfmt()
36 if (var->bits_per_pixel == 12 && var->red.length == 8 && in var_to_pixfmt()
37 var->green.length == 2 && var->blue.length == 2) { in var_to_pixfmt()
38 if (var->green.offset >= var->blue.offset) in var_to_pixfmt()
47 if (var->bits_per_pixel == 16 && var->red.length == 16 && in var_to_pixfmt()
48 var->green.length == 16 && var->blue.length == 16) { in var_to_pixfmt()
49 if (var->red.offset == 0) in var_to_pixfmt()
51 else if (var->green.offset >= var->blue.offset) in var_to_pixfmt()
60 if (var->bits_per_pixel == 16 && var->red.length <= 5 && in var_to_pixfmt()
61 var->green.length <= 6 && var->blue.length <= 5) { in var_to_pixfmt()
62 if (var->transp.length == 0) { in var_to_pixfmt()
63 if (var->red.offset >= var->blue.offset) in var_to_pixfmt()
73 if (var->bits_per_pixel <= 32 && var->red.length <= 8 && in var_to_pixfmt()
74 var->green.length <= 8 && var->blue.length <= 8) { in var_to_pixfmt()
75 if (var->bits_per_pixel == 24 && var->transp.length == 0) { in var_to_pixfmt()
76 if (var->red.offset >= var->blue.offset) in var_to_pixfmt()
82 if (var->bits_per_pixel == 32 && var->transp.offset == 24) { in var_to_pixfmt()
83 if (var->red.offset >= var->blue.offset) in var_to_pixfmt()
88 if (var->red.offset >= var->blue.offset) in var_to_pixfmt()
95 return -EINVAL; in var_to_pixfmt()
102 var->bits_per_pixel = 16; in pixfmt_to_var()
103 var->red.offset = 11; var->red.length = 5; in pixfmt_to_var()
104 var->green.offset = 5; var->green.length = 6; in pixfmt_to_var()
105 var->blue.offset = 0; var->blue.length = 5; in pixfmt_to_var()
106 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
109 var->bits_per_pixel = 16; in pixfmt_to_var()
110 var->red.offset = 0; var->red.length = 5; in pixfmt_to_var()
111 var->green.offset = 5; var->green.length = 6; in pixfmt_to_var()
112 var->blue.offset = 11; var->blue.length = 5; in pixfmt_to_var()
113 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
116 var->bits_per_pixel = 32; in pixfmt_to_var()
117 var->red.offset = 16; var->red.length = 8; in pixfmt_to_var()
118 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
119 var->blue.offset = 0; var->blue.length = 8; in pixfmt_to_var()
120 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
123 var->bits_per_pixel = 32; in pixfmt_to_var()
124 var->red.offset = 0; var->red.length = 8; in pixfmt_to_var()
125 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
126 var->blue.offset = 16; var->blue.length = 8; in pixfmt_to_var()
127 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
130 var->bits_per_pixel = 32; in pixfmt_to_var()
131 var->red.offset = 16; var->red.length = 8; in pixfmt_to_var()
132 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
133 var->blue.offset = 0; var->blue.length = 8; in pixfmt_to_var()
134 var->transp.offset = 24; var->transp.length = 8; in pixfmt_to_var()
137 var->bits_per_pixel = 32; in pixfmt_to_var()
138 var->red.offset = 0; var->red.length = 8; in pixfmt_to_var()
139 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
140 var->blue.offset = 16; var->blue.length = 8; in pixfmt_to_var()
141 var->transp.offset = 24; var->transp.length = 8; in pixfmt_to_var()
144 var->bits_per_pixel = 24; in pixfmt_to_var()
145 var->red.offset = 16; var->red.length = 8; in pixfmt_to_var()
146 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
147 var->blue.offset = 0; var->blue.length = 8; in pixfmt_to_var()
148 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
151 var->bits_per_pixel = 24; in pixfmt_to_var()
152 var->red.offset = 0; var->red.length = 8; in pixfmt_to_var()
153 var->green.offset = 8; var->green.length = 8; in pixfmt_to_var()
154 var->blue.offset = 16; var->blue.length = 8; in pixfmt_to_var()
155 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
158 var->bits_per_pixel = 12; in pixfmt_to_var()
159 var->red.offset = 4; var->red.length = 8; in pixfmt_to_var()
160 var->green.offset = 2; var->green.length = 2; in pixfmt_to_var()
161 var->blue.offset = 0; var->blue.length = 2; in pixfmt_to_var()
162 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
165 var->bits_per_pixel = 12; in pixfmt_to_var()
166 var->red.offset = 4; var->red.length = 8; in pixfmt_to_var()
167 var->green.offset = 0; var->green.length = 2; in pixfmt_to_var()
168 var->blue.offset = 2; var->blue.length = 2; in pixfmt_to_var()
169 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
172 var->bits_per_pixel = 16; in pixfmt_to_var()
173 var->red.offset = 8; var->red.length = 8; in pixfmt_to_var()
174 var->green.offset = 4; var->green.length = 4; in pixfmt_to_var()
175 var->blue.offset = 0; var->blue.length = 4; in pixfmt_to_var()
176 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
179 var->bits_per_pixel = 16; in pixfmt_to_var()
180 var->red.offset = 8; var->red.length = 8; in pixfmt_to_var()
181 var->green.offset = 0; var->green.length = 4; in pixfmt_to_var()
182 var->blue.offset = 4; var->blue.length = 4; in pixfmt_to_var()
183 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
186 var->bits_per_pixel = 16; in pixfmt_to_var()
187 var->red.offset = 8; var->red.length = 16; in pixfmt_to_var()
188 var->green.offset = 4; var->green.length = 16; in pixfmt_to_var()
189 var->blue.offset = 0; var->blue.length = 16; in pixfmt_to_var()
190 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
193 var->bits_per_pixel = 16; in pixfmt_to_var()
194 var->red.offset = 8; var->red.length = 16; in pixfmt_to_var()
195 var->green.offset = 0; var->green.length = 16; in pixfmt_to_var()
196 var->blue.offset = 4; var->blue.length = 16; in pixfmt_to_var()
197 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
200 var->bits_per_pixel = 16; in pixfmt_to_var()
201 var->red.offset = 0; var->red.length = 16; in pixfmt_to_var()
202 var->green.offset = 4; var->green.length = 16; in pixfmt_to_var()
203 var->blue.offset = 8; var->blue.length = 16; in pixfmt_to_var()
204 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
207 var->bits_per_pixel = 8; in pixfmt_to_var()
208 var->red.offset = 0; var->red.length = 8; in pixfmt_to_var()
209 var->green.offset = 0; var->green.length = 8; in pixfmt_to_var()
210 var->blue.offset = 0; var->blue.length = 8; in pixfmt_to_var()
211 var->transp.offset = 0; var->transp.length = 0; in pixfmt_to_var()
227 mode->name = videomode->name; in fbmode_to_mmpmode()
228 mode->refresh = videomode->refresh; in fbmode_to_mmpmode()
229 mode->xres = videomode->xres; in fbmode_to_mmpmode()
230 mode->yres = videomode->yres; in fbmode_to_mmpmode()
232 do_div(div_result, videomode->pixclock); in fbmode_to_mmpmode()
233 mode->pixclock_freq = (u32)div_result; in fbmode_to_mmpmode()
235 mode->left_margin = videomode->left_margin; in fbmode_to_mmpmode()
236 mode->right_margin = videomode->right_margin; in fbmode_to_mmpmode()
237 mode->upper_margin = videomode->upper_margin; in fbmode_to_mmpmode()
238 mode->lower_margin = videomode->lower_margin; in fbmode_to_mmpmode()
239 mode->hsync_len = videomode->hsync_len; in fbmode_to_mmpmode()
240 mode->vsync_len = videomode->vsync_len; in fbmode_to_mmpmode()
241 mode->hsync_invert = !!(videomode->sync & FB_SYNC_HOR_HIGH_ACT); in fbmode_to_mmpmode()
242 mode->vsync_invert = !!(videomode->sync & FB_SYNC_VERT_HIGH_ACT); in fbmode_to_mmpmode()
244 mode->invert_pixclock = !!(videomode->vmode & 8); in fbmode_to_mmpmode()
245 mode->pix_fmt_out = output_fmt; in fbmode_to_mmpmode()
253 videomode->name = mode->name; in mmpmode_to_fbmode()
254 videomode->refresh = mode->refresh; in mmpmode_to_fbmode()
255 videomode->xres = mode->xres; in mmpmode_to_fbmode()
256 videomode->yres = mode->yres; in mmpmode_to_fbmode()
258 do_div(div_result, mode->pixclock_freq); in mmpmode_to_fbmode()
259 videomode->pixclock = (u32)div_result; in mmpmode_to_fbmode()
261 videomode->left_margin = mode->left_margin; in mmpmode_to_fbmode()
262 videomode->right_margin = mode->right_margin; in mmpmode_to_fbmode()
263 videomode->upper_margin = mode->upper_margin; in mmpmode_to_fbmode()
264 videomode->lower_margin = mode->lower_margin; in mmpmode_to_fbmode()
265 videomode->hsync_len = mode->hsync_len; in mmpmode_to_fbmode()
266 videomode->vsync_len = mode->vsync_len; in mmpmode_to_fbmode()
267 videomode->sync = (mode->hsync_invert ? FB_SYNC_HOR_HIGH_ACT : 0) in mmpmode_to_fbmode()
268 | (mode->vsync_invert ? FB_SYNC_VERT_HIGH_ACT : 0); in mmpmode_to_fbmode()
269 videomode->vmode = mode->invert_pixclock ? 8 : 0; in mmpmode_to_fbmode()
275 struct mmpfb_info *fbi = info->par; in mmpfb_check_var()
277 if (var->bits_per_pixel == 8) in mmpfb_check_var()
278 return -EINVAL; in mmpfb_check_var()
282 if (var->xoffset + var->xres > var->xres_virtual) in mmpfb_check_var()
283 return -EINVAL; in mmpfb_check_var()
284 if (var->yoffset + var->yres > var->yres_virtual) in mmpfb_check_var()
285 return -EINVAL; in mmpfb_check_var()
290 if (var->xres_virtual * var->yres_virtual * in mmpfb_check_var()
291 (var->bits_per_pixel >> 3) > fbi->fb_size) in mmpfb_check_var()
292 return -EINVAL; in mmpfb_check_var()
299 return ((chan & 0xffff) >> (16 - bf->length)) << bf->offset; in chan_to_field()
302 static u32 to_rgb(u16 red, u16 green, u16 blue) in to_rgb() argument
305 green >>= 8; in to_rgb()
308 return (red << 16) | (green << 8) | blue; in to_rgb()
312 unsigned int green, unsigned int blue, in mmpfb_setcolreg() argument
315 struct mmpfb_info *fbi = info->par; in mmpfb_setcolreg()
318 if (info->fix.visual == FB_VISUAL_TRUECOLOR && regno < 16) { in mmpfb_setcolreg()
319 val = chan_to_field(red, &info->var.red); in mmpfb_setcolreg()
320 val |= chan_to_field(green, &info->var.green); in mmpfb_setcolreg()
321 val |= chan_to_field(blue , &info->var.blue); in mmpfb_setcolreg()
322 fbi->pseudo_palette[regno] = val; in mmpfb_setcolreg()
325 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) { in mmpfb_setcolreg()
326 val = to_rgb(red, green, blue); in mmpfb_setcolreg()
336 struct mmpfb_info *fbi = info->par; in mmpfb_pan_display()
340 addr.phys[0] = (var->yoffset * var->xres_virtual + var->xoffset) in mmpfb_pan_display()
341 * var->bits_per_pixel / 8 + fbi->fb_start_dma; in mmpfb_pan_display()
342 mmp_overlay_set_addr(fbi->overlay, &addr); in mmpfb_pan_display()
349 struct mmpfb_info *fbi = info->par; in var_update()
350 struct fb_var_screeninfo *var = &info->var; in var_update()
357 return -EINVAL; in var_update()
359 fbi->pix_fmt = pix_fmt; in var_update()
362 m = (struct fb_videomode *)fb_match_mode(var, &info->modelist); in var_update()
364 dev_err(fbi->dev, "set par: no match mode, use best mode\n"); in var_update()
366 &info->modelist); in var_update()
369 memcpy(&fbi->mode, m, sizeof(struct fb_videomode)); in var_update()
372 var->yres_virtual = var->yres * 2; in var_update()
373 info->fix.visual = (pix_fmt == PIXFMT_PSEUDOCOLOR) ? in var_update()
375 info->fix.line_length = var->xres_virtual * var->bits_per_pixel / 8; in var_update()
376 info->fix.ypanstep = var->yres; in var_update()
382 struct mmpfb_info *fbi = info->par; in mmpfb_set_win()
383 struct fb_var_screeninfo *var = &info->var; in mmpfb_set_win()
388 win.xsrc = win.xdst = fbi->mode.xres; in mmpfb_set_win()
389 win.ysrc = win.ydst = fbi->mode.yres; in mmpfb_set_win()
390 win.pix_fmt = fbi->pix_fmt; in mmpfb_set_win()
392 win.pitch[0] = var->xres_virtual * stride; in mmpfb_set_win()
394 (stride == 1) ? (var->xres_virtual >> 1) : 0; in mmpfb_set_win()
395 mmp_overlay_set_win(fbi->overlay, &win); in mmpfb_set_win()
400 struct mmpfb_info *fbi = info->par; in mmpfb_set_par()
401 struct fb_var_screeninfo *var = &info->var; in mmpfb_set_par()
411 fbmode_to_mmpmode(&mode, &fbi->mode, fbi->output_fmt); in mmpfb_set_par()
412 mmp_path_set_mode(fbi->path, &mode); in mmpfb_set_par()
419 addr.phys[0] = (var->yoffset * var->xres_virtual + var->xoffset) in mmpfb_set_par()
420 * var->bits_per_pixel / 8 + fbi->fb_start_dma; in mmpfb_set_par()
421 mmp_overlay_set_addr(fbi->overlay, &addr); in mmpfb_set_par()
429 struct fb_var_screeninfo *var = &fbi->fb_info->var; in mmpfb_power()
431 /* for power on, always set address/window again */ in mmpfb_power()
434 mmpfb_set_win(fbi->fb_info); in mmpfb_power()
438 addr.phys[0] = fbi->fb_start_dma + in mmpfb_power()
439 (var->yoffset * var->xres_virtual + var->xoffset) in mmpfb_power()
440 * var->bits_per_pixel / 8; in mmpfb_power()
441 mmp_overlay_set_addr(fbi->overlay, &addr); in mmpfb_power()
443 mmp_overlay_set_onoff(fbi->overlay, power); in mmpfb_power()
448 struct mmpfb_info *fbi = info->par; in mmpfb_blank()
471 struct fb_info *info = fbi->fb_info; in modes_setup()
475 videomode_num = mmp_path_get_modelist(fbi->path, &mmp_modes); in modes_setup()
477 dev_warn(fbi->dev, "can't get videomode num\n"); in modes_setup()
484 return -ENOMEM; in modes_setup()
488 fb_videomode_to_modelist(videomodes, videomode_num, &info->modelist); in modes_setup()
491 memcpy(&fbi->mode, &videomodes[0], sizeof(struct fb_videomode)); in modes_setup()
492 fbi->output_fmt = mmp_modes[0].pix_fmt_out; in modes_setup()
493 fb_videomode_to_var(&info->var, &fbi->mode); in modes_setup()
494 mmp_path_set_mode(fbi->path, &mmp_modes[0]); in modes_setup()
505 info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK | in fb_info_setup()
507 info->node = -1; in fb_info_setup()
508 strcpy(info->fix.id, fbi->name); in fb_info_setup()
509 info->fix.type = FB_TYPE_PACKED_PIXELS; in fb_info_setup()
510 info->fix.type_aux = 0; in fb_info_setup()
511 info->fix.xpanstep = 0; in fb_info_setup()
512 info->fix.ypanstep = info->var.yres; in fb_info_setup()
513 info->fix.ywrapstep = 0; in fb_info_setup()
514 info->fix.accel = FB_ACCEL_NONE; in fb_info_setup()
515 info->fix.smem_start = fbi->fb_start_dma; in fb_info_setup()
516 info->fix.smem_len = fbi->fb_size; in fb_info_setup()
517 info->fix.visual = (fbi->pix_fmt == PIXFMT_PSEUDOCOLOR) ? in fb_info_setup()
519 info->fix.line_length = info->var.xres_virtual * in fb_info_setup()
520 info->var.bits_per_pixel / 8; in fb_info_setup()
521 info->fbops = &mmpfb_ops; in fb_info_setup()
522 info->pseudo_palette = fbi->pseudo_palette; in fb_info_setup()
523 info->screen_buffer = fbi->fb_start; in fb_info_setup()
524 info->screen_size = fbi->fb_size; in fb_info_setup()
527 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) in fb_info_setup()
528 ret = -ENOMEM; in fb_info_setup()
535 fb_dealloc_cmap(&info->cmap); in fb_info_clear()
545 mi = pdev->dev.platform_data; in mmpfb_probe()
547 dev_err(&pdev->dev, "no platform data defined\n"); in mmpfb_probe()
548 return -EINVAL; in mmpfb_probe()
552 info = framebuffer_alloc(sizeof(struct mmpfb_info), &pdev->dev); in mmpfb_probe()
554 return -ENOMEM; in mmpfb_probe()
555 fbi = info->par; in mmpfb_probe()
558 fbi->fb_info = info; in mmpfb_probe()
560 fbi->dev = &pdev->dev; in mmpfb_probe()
561 fbi->name = mi->name; in mmpfb_probe()
562 fbi->pix_fmt = mi->default_pixfmt; in mmpfb_probe()
563 pixfmt_to_var(&info->var, fbi->pix_fmt); in mmpfb_probe()
564 mutex_init(&fbi->access_ok); in mmpfb_probe()
567 fbi->path = mmp_get_path(mi->path_name); in mmpfb_probe()
568 if (!fbi->path) { in mmpfb_probe()
569 dev_err(&pdev->dev, "can't get the path %s\n", mi->path_name); in mmpfb_probe()
570 ret = -EINVAL; in mmpfb_probe()
574 dev_info(fbi->dev, "path %s get\n", fbi->path->name); in mmpfb_probe()
577 fbi->overlay = mmp_path_get_overlay(fbi->path, mi->overlay_id); in mmpfb_probe()
578 if (!fbi->overlay) { in mmpfb_probe()
579 ret = -EINVAL; in mmpfb_probe()
583 mmp_overlay_set_fetch(fbi->overlay, mi->dmafetch_id); in mmpfb_probe()
597 info->var.yres_virtual = info->var.yres * 2; in mmpfb_probe()
600 fbi->fb_size = info->var.xres_virtual * info->var.yres_virtual in mmpfb_probe()
601 * info->var.bits_per_pixel / 8; in mmpfb_probe()
603 fbi->fb_size = MMPFB_DEFAULT_SIZE; in mmpfb_probe()
606 fbi->fb_start = dma_alloc_coherent(&pdev->dev, PAGE_ALIGN(fbi->fb_size), in mmpfb_probe()
607 &fbi->fb_start_dma, GFP_KERNEL); in mmpfb_probe()
608 if (fbi->fb_start == NULL) { in mmpfb_probe()
609 dev_err(&pdev->dev, "can't alloc framebuffer\n"); in mmpfb_probe()
610 ret = -ENOMEM; in mmpfb_probe()
613 dev_info(fbi->dev, "fb %dk allocated\n", fbi->fb_size/1024); in mmpfb_probe()
615 /* fb power on */ in mmpfb_probe()
625 dev_err(&pdev->dev, "Failed to register fb: %d\n", ret); in mmpfb_probe()
626 ret = -ENXIO; in mmpfb_probe()
630 dev_info(fbi->dev, "loaded to /dev/fb%d <%s>.\n", in mmpfb_probe()
631 info->node, info->fix.id); in mmpfb_probe()
634 if (fbi->fb_start) { in mmpfb_probe()
645 dma_free_coherent(&pdev->dev, PAGE_ALIGN(fbi->fb_size), fbi->fb_start, in mmpfb_probe()
646 fbi->fb_start_dma); in mmpfb_probe()
648 mutex_destroy(&fbi->access_ok); in mmpfb_probe()
649 dev_err(fbi->dev, "mmp-fb: frame buffer device init failed\n"); in mmpfb_probe()
658 .name = "mmp-fb",