Lines Matching +full:offset +full:- +full:y
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/video/omap2/omapfb-main.c
16 #include <linux/dma-mapping.h>
54 static void draw_pixel(struct fb_info *fbi, int x, int y, unsigned color) in draw_pixel() argument
56 struct fb_var_screeninfo *var = &fbi->var; in draw_pixel()
57 struct fb_fix_screeninfo *fix = &fbi->fix; in draw_pixel()
58 void __iomem *addr = fbi->screen_base; in draw_pixel()
59 const unsigned bytespp = var->bits_per_pixel >> 3; in draw_pixel()
60 const unsigned line_len = fix->line_length / bytespp; in draw_pixel()
66 if (var->bits_per_pixel == 16) { in draw_pixel()
68 p += y * line_len + x; in draw_pixel()
75 } else if (var->bits_per_pixel == 24) { in draw_pixel()
77 p += (y * line_len + x) * 3; in draw_pixel()
82 } else if (var->bits_per_pixel == 32) { in draw_pixel()
84 p += y * line_len + x; in draw_pixel()
91 struct fb_var_screeninfo *var = &fbi->var; in fill_fb()
92 const short w = var->xres_virtual; in fill_fb()
93 const short h = var->yres_virtual; in fill_fb()
94 void __iomem *addr = fbi->screen_base; in fill_fb()
95 int y, x; in fill_fb() local
100 DBG("fill_fb %dx%d, line_len %d bytes\n", w, h, fbi->fix.line_length); in fill_fb()
102 for (y = 0; y < h; y++) { in fill_fb()
104 if (x < 20 && y < 20) in fill_fb()
105 draw_pixel(fbi, x, y, 0xffffff); in fill_fb()
106 else if (x < 20 && (y > 20 && y < h - 20)) in fill_fb()
107 draw_pixel(fbi, x, y, 0xff); in fill_fb()
108 else if (y < 20 && (x > 20 && x < w - 20)) in fill_fb()
109 draw_pixel(fbi, x, y, 0xff00); in fill_fb()
110 else if (x > w - 20 && (y > 20 && y < h - 20)) in fill_fb()
111 draw_pixel(fbi, x, y, 0xff0000); in fill_fb()
112 else if (y > h - 20 && (x > 20 && x < w - 20)) in fill_fb()
113 draw_pixel(fbi, x, y, 0xffff00); in fill_fb()
114 else if (x == 20 || x == w - 20 || in fill_fb()
115 y == 20 || y == h - 20) in fill_fb()
116 draw_pixel(fbi, x, y, 0xffffff); in fill_fb()
117 else if (x == y || w - x == h - y) in fill_fb()
118 draw_pixel(fbi, x, y, 0xff00ff); in fill_fb()
119 else if (w - x == y || x == h - y) in fill_fb()
120 draw_pixel(fbi, x, y, 0x00ffff); in fill_fb()
121 else if (x > 20 && y > 20 && x < w - 20 && y < h - 20) { in fill_fb()
125 if (var->bits_per_pixel == 16) { in fill_fb()
127 b = (y % 32) * 256 / 32; in fill_fb()
129 g = (y % 64) * 256 / 64; in fill_fb()
131 r = (y % 32) * 256 / 32; in fill_fb()
134 b = (y % 256); in fill_fb()
136 g = (y % 256); in fill_fb()
138 r = (y % 256); in fill_fb()
141 draw_pixel(fbi, x, y, c); in fill_fb()
143 draw_pixel(fbi, x, y, 0); in fill_fb()
152 const struct vrfb *vrfb = &ofbi->region->vrfb; in omapfb_get_vrfb_offset()
153 unsigned offset; in omapfb_get_vrfb_offset() local
157 offset = 0; in omapfb_get_vrfb_offset()
160 offset = vrfb->yoffset; in omapfb_get_vrfb_offset()
163 offset = vrfb->yoffset * OMAP_VRFB_LINE_LEN + vrfb->xoffset; in omapfb_get_vrfb_offset()
166 offset = vrfb->xoffset * OMAP_VRFB_LINE_LEN; in omapfb_get_vrfb_offset()
173 offset *= vrfb->bytespp; in omapfb_get_vrfb_offset()
175 return offset; in omapfb_get_vrfb_offset()
180 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in omapfb_get_region_rot_paddr()
181 return ofbi->region->vrfb.paddr[rot] in omapfb_get_region_rot_paddr()
184 return ofbi->region->paddr; in omapfb_get_region_rot_paddr()
190 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_get_region_paddr()
191 return ofbi->region->vrfb.paddr[0]; in omapfb_get_region_paddr()
193 return ofbi->region->paddr; in omapfb_get_region_paddr()
198 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_get_region_vaddr()
199 return ofbi->region->vrfb.vaddr[0]; in omapfb_get_region_vaddr()
201 return ofbi->region->vaddr; in omapfb_get_region_vaddr()
216 .red = { .length = 4, .offset = 8, .msb_right = 0 },
217 .green = { .length = 4, .offset = 4, .msb_right = 0 },
218 .blue = { .length = 4, .offset = 0, .msb_right = 0 },
219 .transp = { .length = 4, .offset = 12, .msb_right = 0 },
223 .red = { .length = 5, .offset = 11, .msb_right = 0 },
224 .green = { .length = 6, .offset = 5, .msb_right = 0 },
225 .blue = { .length = 5, .offset = 0, .msb_right = 0 },
226 .transp = { .length = 0, .offset = 0, .msb_right = 0 },
230 .red = { .length = 8, .offset = 16, .msb_right = 0 },
231 .green = { .length = 8, .offset = 8, .msb_right = 0 },
232 .blue = { .length = 8, .offset = 0, .msb_right = 0 },
233 .transp = { .length = 0, .offset = 0, .msb_right = 0 },
237 .red = { .length = 8, .offset = 16, .msb_right = 0 },
238 .green = { .length = 8, .offset = 8, .msb_right = 0 },
239 .blue = { .length = 8, .offset = 0, .msb_right = 0 },
240 .transp = { .length = 0, .offset = 0, .msb_right = 0 },
244 .red = { .length = 8, .offset = 16, .msb_right = 0 },
245 .green = { .length = 8, .offset = 8, .msb_right = 0 },
246 .blue = { .length = 8, .offset = 0, .msb_right = 0 },
247 .transp = { .length = 8, .offset = 24, .msb_right = 0 },
251 .red = { .length = 8, .offset = 24, .msb_right = 0 },
252 .green = { .length = 8, .offset = 16, .msb_right = 0 },
253 .blue = { .length = 8, .offset = 8, .msb_right = 0 },
254 .transp = { .length = 8, .offset = 0, .msb_right = 0 },
258 .red = { .length = 8, .offset = 24, .msb_right = 0 },
259 .green = { .length = 8, .offset = 16, .msb_right = 0 },
260 .blue = { .length = 8, .offset = 8, .msb_right = 0 },
261 .transp = { .length = 0, .offset = 0, .msb_right = 0 },
267 return f1->length == f2->length && in cmp_component()
268 f1->offset == f2->offset && in cmp_component()
269 f1->msb_right == f2->msb_right; in cmp_component()
275 if (var->bits_per_pixel == 0 || in cmp_var_to_colormode()
276 var->red.length == 0 || in cmp_var_to_colormode()
277 var->blue.length == 0 || in cmp_var_to_colormode()
278 var->green.length == 0) in cmp_var_to_colormode()
281 return var->bits_per_pixel == color->bits_per_pixel && in cmp_var_to_colormode()
282 cmp_component(&var->red, &color->red) && in cmp_var_to_colormode()
283 cmp_component(&var->green, &color->green) && in cmp_var_to_colormode()
284 cmp_component(&var->blue, &color->blue) && in cmp_var_to_colormode()
285 cmp_component(&var->transp, &color->transp); in cmp_var_to_colormode()
291 var->bits_per_pixel = color->bits_per_pixel; in assign_colormode_to_var()
292 var->nonstd = color->nonstd; in assign_colormode_to_var()
293 var->red = color->red; in assign_colormode_to_var()
294 var->green = color->green; in assign_colormode_to_var()
295 var->blue = color->blue; in assign_colormode_to_var()
296 var->transp = color->transp; in assign_colormode_to_var()
306 if (var->nonstd) { in fb_mode_to_dss_mode()
309 if (var->nonstd == m->nonstd) { in fb_mode_to_dss_mode()
311 *mode = m->dssmode; in fb_mode_to_dss_mode()
316 return -EINVAL; in fb_mode_to_dss_mode()
324 *mode = m->dssmode; in fb_mode_to_dss_mode()
331 switch (var->bits_per_pixel) { in fb_mode_to_dss_mode()
357 return -EINVAL; in fb_mode_to_dss_mode()
362 if (dssmode == m->dssmode) { in fb_mode_to_dss_mode()
364 *mode = m->dssmode; in fb_mode_to_dss_mode()
369 return -EINVAL; in fb_mode_to_dss_mode()
380 if (var->xres_virtual == 0) in check_fb_res_bounds()
381 var->xres_virtual = var->xres; in check_fb_res_bounds()
383 if (var->yres_virtual == 0) in check_fb_res_bounds()
384 var->yres_virtual = var->yres; in check_fb_res_bounds()
386 if (var->xres_virtual < xres_min || var->yres_virtual < yres_min) in check_fb_res_bounds()
387 return -EINVAL; in check_fb_res_bounds()
389 if (var->xres < xres_min) in check_fb_res_bounds()
390 var->xres = xres_min; in check_fb_res_bounds()
391 if (var->yres < yres_min) in check_fb_res_bounds()
392 var->yres = yres_min; in check_fb_res_bounds()
393 if (var->xres > xres_max) in check_fb_res_bounds()
394 var->xres = xres_max; in check_fb_res_bounds()
395 if (var->yres > yres_max) in check_fb_res_bounds()
396 var->yres = yres_max; in check_fb_res_bounds()
398 if (var->xres > var->xres_virtual) in check_fb_res_bounds()
399 var->xres = var->xres_virtual; in check_fb_res_bounds()
400 if (var->yres > var->yres_virtual) in check_fb_res_bounds()
401 var->yres = var->yres_virtual; in check_fb_res_bounds()
409 DBG("can't fit FB into memory, reducing y\n"); in shrink_height()
410 var->yres_virtual = max_frame_size / in shrink_height()
411 (var->xres_virtual * var->bits_per_pixel >> 3); in shrink_height()
413 if (var->yres_virtual < OMAPFB_PLANE_YRES_MIN) in shrink_height()
414 var->yres_virtual = OMAPFB_PLANE_YRES_MIN; in shrink_height()
416 if (var->yres > var->yres_virtual) in shrink_height()
417 var->yres = var->yres_virtual; in shrink_height()
424 var->xres_virtual = max_frame_size / var->yres_virtual / in shrink_width()
425 (var->bits_per_pixel >> 3); in shrink_width()
427 if (var->xres_virtual < OMAPFB_PLANE_XRES_MIN) in shrink_width()
428 var->xres_virtual = OMAPFB_PLANE_XRES_MIN; in shrink_width()
430 if (var->xres > var->xres_virtual) in shrink_width()
431 var->xres = var->xres_virtual; in shrink_width()
437 unsigned long min_phys_size = omap_vrfb_min_phys_size(var->xres_virtual, in check_vrfb_fb_size()
438 var->yres_virtual, var->bits_per_pixel >> 3); in check_vrfb_fb_size()
440 return min_phys_size > region_size ? -EINVAL : 0; in check_vrfb_fb_size()
446 unsigned long max_frame_size = ofbi->region->size; in check_fb_size()
447 int bytespp = var->bits_per_pixel >> 3; in check_fb_size()
448 unsigned long line_size = var->xres_virtual * bytespp; in check_fb_size()
450 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in check_fb_size()
454 max_frame_size, var->xres_virtual, bytespp) * in check_fb_size()
459 return -EINVAL; in check_fb_size()
467 if (line_size * var->yres_virtual > max_frame_size) in check_fb_size()
470 if (line_size * var->yres_virtual > max_frame_size) { in check_fb_size()
472 line_size = var->xres_virtual * bytespp; in check_fb_size()
475 if (line_size * var->yres_virtual > max_frame_size) { in check_fb_size()
477 return -EINVAL; in check_fb_size()
493 struct omapfb2_mem_region *rg = ofbi->region; in setup_vrfb_rotation()
494 struct vrfb *vrfb = &rg->vrfb; in setup_vrfb_rotation()
495 struct fb_var_screeninfo *var = &fbi->var; in setup_vrfb_rotation()
496 struct fb_fix_screeninfo *fix = &fbi->fix; in setup_vrfb_rotation()
503 if (!rg->size || ofbi->rotation_type != OMAP_DSS_ROT_VRFB) in setup_vrfb_rotation()
512 bytespp = var->bits_per_pixel >> 3; in setup_vrfb_rotation()
523 if (yuv_mode != vrfb->yuv_mode) in setup_vrfb_rotation()
525 else if (bytespp != vrfb->bytespp) in setup_vrfb_rotation()
527 else if (vrfb->xres != var->xres_virtual || in setup_vrfb_rotation()
528 vrfb->yres != var->yres_virtual) in setup_vrfb_rotation()
531 if (vrfb->vaddr[0] && reconf) { in setup_vrfb_rotation()
532 fbi->screen_base = NULL; in setup_vrfb_rotation()
533 fix->smem_start = 0; in setup_vrfb_rotation()
534 fix->smem_len = 0; in setup_vrfb_rotation()
535 iounmap(vrfb->vaddr[0]); in setup_vrfb_rotation()
536 vrfb->vaddr[0] = NULL; in setup_vrfb_rotation()
540 if (vrfb->vaddr[0]) in setup_vrfb_rotation()
543 omap_vrfb_setup(&rg->vrfb, rg->paddr, in setup_vrfb_rotation()
544 var->xres_virtual, in setup_vrfb_rotation()
545 var->yres_virtual, in setup_vrfb_rotation()
549 r = omap_vrfb_map_angle(vrfb, var->yres_virtual, 0); in setup_vrfb_rotation()
554 fbi->screen_base = ofbi->region->vrfb.vaddr[0]; in setup_vrfb_rotation()
556 fix->smem_start = ofbi->region->vrfb.paddr[0]; in setup_vrfb_rotation()
558 switch (var->nonstd) { in setup_vrfb_rotation()
561 fix->line_length = in setup_vrfb_rotation()
562 (OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 2; in setup_vrfb_rotation()
565 fix->line_length = in setup_vrfb_rotation()
566 (OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 3; in setup_vrfb_rotation()
570 fix->smem_len = var->yres_virtual * fix->line_length; in setup_vrfb_rotation()
582 if (dssmode == mode->dssmode) { in dss_mode_to_fb_mode()
587 return -ENOENT; in dss_mode_to_fb_mode()
592 struct fb_fix_screeninfo *fix = &fbi->fix; in set_fb_fix()
593 struct fb_var_screeninfo *var = &fbi->var; in set_fb_fix()
595 struct omapfb2_mem_region *rg = ofbi->region; in set_fb_fix()
600 fbi->screen_base = (char __iomem *)omapfb_get_region_vaddr(ofbi); in set_fb_fix()
603 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in set_fb_fix()
604 switch (var->nonstd) { in set_fb_fix()
607 fix->line_length = in set_fb_fix()
608 (OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 2; in set_fb_fix()
611 fix->line_length = in set_fb_fix()
612 (OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 3; in set_fb_fix()
616 fix->smem_len = var->yres_virtual * fix->line_length; in set_fb_fix()
618 fix->line_length = in set_fb_fix()
619 (var->xres_virtual * var->bits_per_pixel) >> 3; in set_fb_fix()
620 fix->smem_len = rg->size; in set_fb_fix()
623 fix->smem_start = omapfb_get_region_paddr(ofbi); in set_fb_fix()
625 fix->type = FB_TYPE_PACKED_PIXELS; in set_fb_fix()
627 if (var->nonstd) in set_fb_fix()
628 fix->visual = FB_VISUAL_PSEUDOCOLOR; in set_fb_fix()
630 switch (var->bits_per_pixel) { in set_fb_fix()
635 fix->visual = FB_VISUAL_TRUECOLOR; in set_fb_fix()
642 fix->visual = FB_VISUAL_PSEUDOCOLOR; in set_fb_fix()
647 fix->accel = FB_ACCEL_NONE; in set_fb_fix()
649 fix->xpanstep = 1; in set_fb_fix()
650 fix->ypanstep = 1; in set_fb_fix()
662 DBG("check_fb_var %d\n", ofbi->id); in check_fb_var()
664 WARN_ON(!atomic_read(&ofbi->region->lock_count)); in check_fb_var()
672 for (i = 0; i < ofbi->num_overlays; ++i) { in check_fb_var()
673 if ((ofbi->overlays[i]->supported_modes & mode) == 0) { in check_fb_var()
675 return -EINVAL; in check_fb_var()
679 if (var->rotate > 3) in check_fb_var()
680 return -EINVAL; in check_fb_var()
683 return -EINVAL; in check_fb_var()
686 if (ofbi->region->size != 0 && check_fb_size(ofbi, var)) in check_fb_var()
687 return -EINVAL; in check_fb_var()
689 if (var->xres + var->xoffset > var->xres_virtual) in check_fb_var()
690 var->xoffset = var->xres_virtual - var->xres; in check_fb_var()
691 if (var->yres + var->yoffset > var->yres_virtual) in check_fb_var()
692 var->yoffset = var->yres_virtual - var->yres; in check_fb_var()
695 var->xres, var->yres, in check_fb_var()
696 var->xres_virtual, var->yres_virtual); in check_fb_var()
698 if (display && display->driver->get_dimensions) { in check_fb_var()
700 display->driver->get_dimensions(display, &w, &h); in check_fb_var()
701 var->width = DIV_ROUND_CLOSEST(w, 1000); in check_fb_var()
702 var->height = DIV_ROUND_CLOSEST(h, 1000); in check_fb_var()
704 var->height = -1; in check_fb_var()
705 var->width = -1; in check_fb_var()
708 var->grayscale = 0; in check_fb_var()
710 if (display && display->driver->get_timings) { in check_fb_var()
712 display->driver->get_timings(display, &timings); in check_fb_var()
715 var->pixclock = timings.pixelclock != 0 ? in check_fb_var()
718 var->left_margin = timings.hbp; in check_fb_var()
719 var->right_margin = timings.hfp; in check_fb_var()
720 var->upper_margin = timings.vbp; in check_fb_var()
721 var->lower_margin = timings.vfp; in check_fb_var()
722 var->hsync_len = timings.hsw; in check_fb_var()
723 var->vsync_len = timings.vsw; in check_fb_var()
724 var->sync |= timings.hsync_level == OMAPDSS_SIG_ACTIVE_HIGH ? in check_fb_var()
726 var->sync |= timings.vsync_level == OMAPDSS_SIG_ACTIVE_HIGH ? in check_fb_var()
728 var->vmode = timings.interlace ? in check_fb_var()
731 var->pixclock = 0; in check_fb_var()
732 var->left_margin = 0; in check_fb_var()
733 var->right_margin = 0; in check_fb_var()
734 var->upper_margin = 0; in check_fb_var()
735 var->lower_margin = 0; in check_fb_var()
736 var->hsync_len = 0; in check_fb_var()
737 var->vsync_len = 0; in check_fb_var()
738 var->sync = 0; in check_fb_var()
739 var->vmode = FB_VMODE_NONINTERLACED; in check_fb_var()
746 * ---------------------------------------------------------------------------
748 * ---------------------------------------------------------------------------
763 unsigned offset; in calc_rotation_offset_dma() local
765 offset = var->yoffset * fix->line_length + in calc_rotation_offset_dma()
766 var->xoffset * (var->bits_per_pixel >> 3); in calc_rotation_offset_dma()
768 return offset; in calc_rotation_offset_dma()
774 unsigned offset; in calc_rotation_offset_vrfb() local
777 offset = (var->yres_virtual - var->yres) * in calc_rotation_offset_vrfb()
778 fix->line_length; in calc_rotation_offset_vrfb()
780 offset = (var->yres_virtual - var->yres) * in calc_rotation_offset_vrfb()
781 (var->bits_per_pixel >> 3); in calc_rotation_offset_vrfb()
783 offset = 0; in calc_rotation_offset_vrfb()
786 offset += var->yoffset * fix->line_length + in calc_rotation_offset_vrfb()
787 var->xoffset * (var->bits_per_pixel >> 3); in calc_rotation_offset_vrfb()
789 offset -= var->yoffset * fix->line_length + in calc_rotation_offset_vrfb()
790 var->xoffset * (var->bits_per_pixel >> 3); in calc_rotation_offset_vrfb()
792 offset -= var->xoffset * fix->line_length + in calc_rotation_offset_vrfb()
793 var->yoffset * (var->bits_per_pixel >> 3); in calc_rotation_offset_vrfb()
795 offset += var->xoffset * fix->line_length + in calc_rotation_offset_vrfb()
796 var->yoffset * (var->bits_per_pixel >> 3); in calc_rotation_offset_vrfb()
798 return offset; in calc_rotation_offset_vrfb()
807 int offset; in omapfb_calc_addr() local
809 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_calc_addr()
814 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_calc_addr()
815 offset = calc_rotation_offset_vrfb(var, fix, rotation); in omapfb_calc_addr()
817 offset = calc_rotation_offset_dma(var, fix, rotation); in omapfb_calc_addr()
819 data_start_p += offset; in omapfb_calc_addr()
821 if (offset) in omapfb_calc_addr()
822 DBG("offset %d, %d = %d\n", in omapfb_calc_addr()
823 var->xoffset, var->yoffset, offset); in omapfb_calc_addr()
836 struct fb_var_screeninfo *var = &fbi->var; in omapfb_setup_overlay()
837 struct fb_fix_screeninfo *fix = &fbi->fix; in omapfb_setup_overlay()
844 int rotation = var->rotate; in omapfb_setup_overlay()
847 WARN_ON(!atomic_read(&ofbi->region->lock_count)); in omapfb_setup_overlay()
849 for (i = 0; i < ofbi->num_overlays; i++) { in omapfb_setup_overlay()
850 if (ovl != ofbi->overlays[i]) in omapfb_setup_overlay()
853 rotation = (rotation + ofbi->rotation[i]) % 4; in omapfb_setup_overlay()
857 DBG("setup_overlay %d, posx %d, posy %d, outw %d, outh %d\n", ofbi->id, in omapfb_setup_overlay()
861 xres = var->yres; in omapfb_setup_overlay()
862 yres = var->xres; in omapfb_setup_overlay()
864 xres = var->xres; in omapfb_setup_overlay()
865 yres = var->yres; in omapfb_setup_overlay()
868 if (ofbi->region->size) in omapfb_setup_overlay()
877 switch (var->nonstd) { in omapfb_setup_overlay()
880 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in omapfb_setup_overlay()
881 screen_width = fix->line_length in omapfb_setup_overlay()
882 / (var->bits_per_pixel >> 2); in omapfb_setup_overlay()
887 screen_width = fix->line_length / (var->bits_per_pixel >> 3); in omapfb_setup_overlay()
891 ovl->get_overlay_info(ovl, &info); in omapfb_setup_overlay()
893 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_setup_overlay()
896 mirror = ofbi->mirror; in omapfb_setup_overlay()
903 info.rotation_type = ofbi->rotation_type; in omapfb_setup_overlay()
912 r = ovl->set_overlay_info(ovl, &info); in omapfb_setup_overlay()
914 DBG("ovl->setup_overlay_info failed\n"); in omapfb_setup_overlay()
930 struct fb_var_screeninfo *var = &fbi->var; in omapfb_apply_changes()
941 WARN_ON(!atomic_read(&ofbi->region->lock_count)); in omapfb_apply_changes()
943 for (i = 0; i < ofbi->num_overlays; i++) { in omapfb_apply_changes()
944 ovl = ofbi->overlays[i]; in omapfb_apply_changes()
946 DBG("apply_changes, fb %d, ovl %d\n", ofbi->id, ovl->id); in omapfb_apply_changes()
948 if (ofbi->region->size == 0) { in omapfb_apply_changes()
951 if (!init && ovl->manager) in omapfb_apply_changes()
952 ovl->manager->apply(ovl->manager); in omapfb_apply_changes()
956 if (init || (ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) { in omapfb_apply_changes()
957 int rotation = (var->rotate + ofbi->rotation[i]) % 4; in omapfb_apply_changes()
960 outw = var->yres; in omapfb_apply_changes()
961 outh = var->xres; in omapfb_apply_changes()
963 outw = var->xres; in omapfb_apply_changes()
964 outh = var->yres; in omapfb_apply_changes()
968 ovl->get_overlay_info(ovl, &info); in omapfb_apply_changes()
978 ovl->get_overlay_info(ovl, &info); in omapfb_apply_changes()
987 if (!init && ovl->manager) in omapfb_apply_changes()
988 ovl->manager->apply(ovl->manager); in omapfb_apply_changes()
1003 DBG("check_var(%d)\n", FB2OFB(fbi)->id); in omapfb_check_var()
1005 omapfb_get_mem_region(ofbi->region); in omapfb_check_var()
1009 omapfb_put_mem_region(ofbi->region); in omapfb_check_var()
1014 /* set the video mode according to info->var */
1020 DBG("set_par(%d)\n", FB2OFB(fbi)->id); in omapfb_set_par()
1022 omapfb_get_mem_region(ofbi->region); in omapfb_set_par()
1033 omapfb_put_mem_region(ofbi->region); in omapfb_set_par()
1045 DBG("pan_display(%d)\n", FB2OFB(fbi)->id); in omapfb_pan_display()
1047 if (var->xoffset == fbi->var.xoffset && in omapfb_pan_display()
1048 var->yoffset == fbi->var.yoffset) in omapfb_pan_display()
1051 new_var = fbi->var; in omapfb_pan_display()
1052 new_var.xoffset = var->xoffset; in omapfb_pan_display()
1053 new_var.yoffset = var->yoffset; in omapfb_pan_display()
1055 fbi->var = new_var; in omapfb_pan_display()
1057 omapfb_get_mem_region(ofbi->region); in omapfb_pan_display()
1061 omapfb_put_mem_region(ofbi->region); in omapfb_pan_display()
1068 struct omapfb2_mem_region *rg = vma->vm_private_data; in mmap_user_open()
1071 atomic_inc(&rg->map_count); in mmap_user_open()
1077 struct omapfb2_mem_region *rg = vma->vm_private_data; in mmap_user_close()
1080 atomic_dec(&rg->map_count); in mmap_user_close()
1092 struct fb_fix_screeninfo *fix = &fbi->fix; in omapfb_mmap()
1098 rg = omapfb_get_mem_region(ofbi->region); in omapfb_mmap()
1101 len = fix->smem_len; in omapfb_mmap()
1104 vma->vm_pgoff << PAGE_SHIFT); in omapfb_mmap()
1106 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); in omapfb_mmap()
1107 vma->vm_ops = &mmap_user_ops; in omapfb_mmap()
1108 vma->vm_private_data = rg; in omapfb_mmap()
1115 atomic_inc(&rg->map_count); in omapfb_mmap()
1122 omapfb_put_mem_region(ofbi->region); in omapfb_mmap()
1135 /*struct omapfb2_device *fbdev = ofbi->fbdev;*/ in _setcolreg()
1136 struct fb_var_screeninfo *var = &fbi->var; in _setcolreg()
1141 /*switch (plane->color_mode) {*/ in _setcolreg()
1146 r = -EINVAL; in _setcolreg()
1153 if (fbdev->ctrl->setcolreg) in _setcolreg()
1154 r = fbdev->ctrl->setcolreg(regno, red, green, blue, in _setcolreg()
1157 r = -EINVAL; in _setcolreg()
1165 pal = ((red >> (16 - var->red.length)) << in _setcolreg()
1166 var->red.offset) | in _setcolreg()
1167 ((green >> (16 - var->green.length)) << in _setcolreg()
1168 var->green.offset) | in _setcolreg()
1169 (blue >> (16 - var->blue.length)); in _setcolreg()
1170 ((u32 *)(fbi->pseudo_palette))[regno] = pal; in _setcolreg()
1195 red = cmap->red; in omapfb_setcmap()
1196 green = cmap->green; in omapfb_setcmap()
1197 blue = cmap->blue; in omapfb_setcmap()
1198 transp = cmap->transp; in omapfb_setcmap()
1199 index = cmap->start; in omapfb_setcmap()
1201 for (count = 0; count < cmap->len; count++) { in omapfb_setcmap()
1205 count == cmap->len - 1); in omapfb_setcmap()
1216 struct omapfb2_device *fbdev = ofbi->fbdev; in omapfb_blank()
1222 return -EINVAL; in omapfb_blank()
1230 if (display->state == OMAP_DSS_DISPLAY_ACTIVE) in omapfb_blank()
1233 r = display->driver->enable(display); in omapfb_blank()
1235 if ((display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) && in omapfb_blank()
1236 d->update_mode == OMAPFB_AUTO_UPDATE && in omapfb_blank()
1237 !d->auto_update_work_enabled) in omapfb_blank()
1248 if (display->state != OMAP_DSS_DISPLAY_ACTIVE) in omapfb_blank()
1251 if (d->auto_update_work_enabled) in omapfb_blank()
1254 display->driver->disable(display); in omapfb_blank()
1259 r = -EINVAL; in omapfb_blank()
1300 struct omapfb2_device *fbdev = ofbi->fbdev; in omapfb_free_fbmem()
1303 rg = ofbi->region; in omapfb_free_fbmem()
1305 if (rg->token == NULL) in omapfb_free_fbmem()
1308 WARN_ON(atomic_read(&rg->map_count)); in omapfb_free_fbmem()
1310 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in omapfb_free_fbmem()
1312 if (rg->vrfb.vaddr[0]) { in omapfb_free_fbmem()
1313 iounmap(rg->vrfb.vaddr[0]); in omapfb_free_fbmem()
1314 rg->vrfb.vaddr[0] = NULL; in omapfb_free_fbmem()
1317 omap_vrfb_release_ctx(&rg->vrfb); in omapfb_free_fbmem()
1320 dma_free_attrs(fbdev->dev, rg->size, rg->token, rg->dma_handle, in omapfb_free_fbmem()
1321 rg->attrs); in omapfb_free_fbmem()
1323 rg->token = NULL; in omapfb_free_fbmem()
1324 rg->vaddr = NULL; in omapfb_free_fbmem()
1325 rg->paddr = 0; in omapfb_free_fbmem()
1326 rg->alloc = 0; in omapfb_free_fbmem()
1327 rg->size = 0; in omapfb_free_fbmem()
1332 memset(&fbi->var, 0, sizeof(fbi->var)); in clear_fb_info()
1333 memset(&fbi->fix, 0, sizeof(fbi->fix)); in clear_fb_info()
1334 strlcpy(fbi->fix.id, MODULE_NAME, sizeof(fbi->fix.id)); in clear_fb_info()
1343 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_free_all_fbmem()
1344 struct fb_info *fbi = fbdev->fbs[i]; in omapfb_free_all_fbmem()
1356 struct omapfb2_device *fbdev = ofbi->fbdev; in omapfb_alloc_fbmem()
1363 rg = ofbi->region; in omapfb_alloc_fbmem()
1365 rg->paddr = 0; in omapfb_alloc_fbmem()
1366 rg->vaddr = NULL; in omapfb_alloc_fbmem()
1367 memset(&rg->vrfb, 0, sizeof rg->vrfb); in omapfb_alloc_fbmem()
1368 rg->size = 0; in omapfb_alloc_fbmem()
1369 rg->type = 0; in omapfb_alloc_fbmem()
1370 rg->alloc = false; in omapfb_alloc_fbmem()
1371 rg->map = false; in omapfb_alloc_fbmem()
1377 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) in omapfb_alloc_fbmem()
1380 DBG("allocating %lu bytes for fb %d\n", size, ofbi->id); in omapfb_alloc_fbmem()
1382 token = dma_alloc_attrs(fbdev->dev, size, &dma_handle, in omapfb_alloc_fbmem()
1386 dev_err(fbdev->dev, "failed to allocate framebuffer\n"); in omapfb_alloc_fbmem()
1387 return -ENOMEM; in omapfb_alloc_fbmem()
1393 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in omapfb_alloc_fbmem()
1394 r = omap_vrfb_request_ctx(&rg->vrfb); in omapfb_alloc_fbmem()
1396 dma_free_attrs(fbdev->dev, size, token, dma_handle, in omapfb_alloc_fbmem()
1398 dev_err(fbdev->dev, "vrfb create ctx failed\n"); in omapfb_alloc_fbmem()
1403 rg->attrs = attrs; in omapfb_alloc_fbmem()
1404 rg->token = token; in omapfb_alloc_fbmem()
1405 rg->dma_handle = dma_handle; in omapfb_alloc_fbmem()
1407 rg->paddr = (unsigned long)dma_handle; in omapfb_alloc_fbmem()
1408 rg->vaddr = (void __iomem *)token; in omapfb_alloc_fbmem()
1409 rg->size = size; in omapfb_alloc_fbmem()
1410 rg->alloc = 1; in omapfb_alloc_fbmem()
1420 struct omapfb2_device *fbdev = ofbi->fbdev; in omapfb_alloc_fbmem_display()
1444 display->driver->get_resolution(display, &w, &h); in omapfb_alloc_fbmem_display()
1446 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { in omapfb_alloc_fbmem_display()
1450 DBG("adjusting fb mem size for VRFB, %u -> %lu\n", in omapfb_alloc_fbmem_display()
1479 return -EINVAL; in omapfb_parse_vram_param()
1482 return -EINVAL; in omapfb_parse_vram_param()
1485 return -EINVAL; in omapfb_parse_vram_param()
1490 return -EINVAL; in omapfb_parse_vram_param()
1498 return -EINVAL; in omapfb_parse_vram_param()
1512 return -EINVAL; in omapfb_parse_vram_param()
1533 dev_err(fbdev->dev, "failed to parse vram parameter\n"); in omapfb_allocate_all_fbs()
1539 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_allocate_all_fbs()
1543 r = omapfb_alloc_fbmem_display(fbdev->fbs[i], in omapfb_allocate_all_fbs()
1551 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_allocate_all_fbs()
1552 struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]); in omapfb_allocate_all_fbs()
1554 rg = ofbi->region; in omapfb_allocate_all_fbs()
1558 rg->paddr, in omapfb_allocate_all_fbs()
1559 rg->vaddr, in omapfb_allocate_all_fbs()
1560 rg->size); in omapfb_allocate_all_fbs()
1571 .width = fbi->var.xres_virtual, in omapfb_clear_fb()
1572 .height = fbi->var.yres_virtual, in omapfb_clear_fb()
1583 struct omapfb2_device *fbdev = ofbi->fbdev; in omapfb_realloc_fbmem()
1584 struct omapfb2_mem_region *rg = ofbi->region; in omapfb_realloc_fbmem()
1585 unsigned long old_size = rg->size; in omapfb_realloc_fbmem()
1586 unsigned long old_paddr = rg->paddr; in omapfb_realloc_fbmem()
1587 int old_type = rg->type; in omapfb_realloc_fbmem()
1591 return -EINVAL; in omapfb_realloc_fbmem()
1611 if (rg->size == 0) in omapfb_realloc_fbmem()
1621 DBG("initializing fb %d\n", ofbi->id); in omapfb_realloc_fbmem()
1634 memcpy(&new_var, &fbi->var, sizeof(new_var)); in omapfb_realloc_fbmem()
1638 memcpy(&fbi->var, &new_var, sizeof(fbi->var)); in omapfb_realloc_fbmem()
1666 dssdev = d->dssdev; in omapfb_auto_update_work()
1667 dssdrv = dssdev->driver; in omapfb_auto_update_work()
1668 fbdev = d->fbdev; in omapfb_auto_update_work()
1670 if (!dssdrv || !dssdrv->update) in omapfb_auto_update_work()
1673 if (dssdrv->sync) in omapfb_auto_update_work()
1674 dssdrv->sync(dssdev); in omapfb_auto_update_work()
1676 dssdrv->get_resolution(dssdev, &w, &h); in omapfb_auto_update_work()
1677 dssdrv->update(dssdev, 0, 0, w, h); in omapfb_auto_update_work()
1682 queue_delayed_work(fbdev->auto_update_wq, in omapfb_auto_update_work()
1683 &d->auto_update_work, HZ / freq); in omapfb_auto_update_work()
1691 if (fbdev->auto_update_wq == NULL) { in omapfb_start_auto_update()
1697 dev_err(fbdev->dev, "Failed to create workqueue for " in omapfb_start_auto_update()
1698 "auto-update\n"); in omapfb_start_auto_update()
1702 fbdev->auto_update_wq = wq; in omapfb_start_auto_update()
1707 INIT_DELAYED_WORK(&d->auto_update_work, omapfb_auto_update_work); in omapfb_start_auto_update()
1709 d->auto_update_work_enabled = true; in omapfb_start_auto_update()
1711 omapfb_auto_update_work(&d->auto_update_work.work); in omapfb_start_auto_update()
1721 cancel_delayed_work_sync(&d->auto_update_work); in omapfb_stop_auto_update()
1723 d->auto_update_work_enabled = false; in omapfb_stop_auto_update()
1729 struct fb_var_screeninfo *var = &fbi->var; in omapfb_fb_init()
1734 fbi->fbops = &omapfb_ops; in omapfb_fb_init()
1735 fbi->flags = FBINFO_FLAG_DEFAULT; in omapfb_fb_init()
1736 fbi->pseudo_palette = fbdev->pseudo_palette; in omapfb_fb_init()
1738 if (ofbi->region->size == 0) { in omapfb_fb_init()
1743 var->nonstd = 0; in omapfb_fb_init()
1744 var->bits_per_pixel = 0; in omapfb_fb_init()
1746 var->rotate = def_rotate; in omapfb_fb_init()
1750 int rotation = (var->rotate + ofbi->rotation[0]) % 4; in omapfb_fb_init()
1752 display->driver->get_resolution(display, &w, &h); in omapfb_fb_init()
1756 var->xres = h; in omapfb_fb_init()
1757 var->yres = w; in omapfb_fb_init()
1759 var->xres = w; in omapfb_fb_init()
1760 var->yres = h; in omapfb_fb_init()
1763 var->xres_virtual = var->xres; in omapfb_fb_init()
1764 var->yres_virtual = var->yres; in omapfb_fb_init()
1766 if (!var->bits_per_pixel) { in omapfb_fb_init()
1769 var->bits_per_pixel = 16; in omapfb_fb_init()
1772 var->bits_per_pixel = 32; in omapfb_fb_init()
1775 dev_err(fbdev->dev, "illegal display " in omapfb_fb_init()
1777 return -EINVAL; in omapfb_fb_init()
1782 var->xres = 320; in omapfb_fb_init()
1783 var->yres = 240; in omapfb_fb_init()
1784 var->xres_virtual = var->xres; in omapfb_fb_init()
1785 var->yres_virtual = var->yres; in omapfb_fb_init()
1786 if (!var->bits_per_pixel) in omapfb_fb_init()
1787 var->bits_per_pixel = 16; in omapfb_fb_init()
1799 r = fb_alloc_cmap(&fbi->cmap, 256, 0); in omapfb_fb_init()
1801 dev_err(fbdev->dev, "unable to allocate color map memory\n"); in omapfb_fb_init()
1809 fb_dealloc_cmap(&fbi->cmap); in fbinfo_cleanup()
1822 for (i = 0; i < fbdev->num_overlays; i++) { in omapfb_free_resources()
1823 struct omap_overlay *ovl = fbdev->overlays[i]; in omapfb_free_resources()
1825 ovl->disable(ovl); in omapfb_free_resources()
1827 if (ovl->manager) in omapfb_free_resources()
1828 ovl->unset_manager(ovl); in omapfb_free_resources()
1831 for (i = 0; i < fbdev->num_fbs; i++) in omapfb_free_resources()
1832 unregister_framebuffer(fbdev->fbs[i]); in omapfb_free_resources()
1837 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_free_resources()
1838 fbinfo_cleanup(fbdev, fbdev->fbs[i]); in omapfb_free_resources()
1839 framebuffer_release(fbdev->fbs[i]); in omapfb_free_resources()
1842 for (i = 0; i < fbdev->num_displays; i++) { in omapfb_free_resources()
1843 struct omap_dss_device *dssdev = fbdev->displays[i].dssdev; in omapfb_free_resources()
1845 if (fbdev->displays[i].auto_update_work_enabled) in omapfb_free_resources()
1848 if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) in omapfb_free_resources()
1849 dssdev->driver->disable(dssdev); in omapfb_free_resources()
1851 dssdev->driver->disconnect(dssdev); in omapfb_free_resources()
1856 if (fbdev->auto_update_wq != NULL) { in omapfb_free_resources()
1857 flush_workqueue(fbdev->auto_update_wq); in omapfb_free_resources()
1858 destroy_workqueue(fbdev->auto_update_wq); in omapfb_free_resources()
1859 fbdev->auto_update_wq = NULL; in omapfb_free_resources()
1862 dev_set_drvdata(fbdev->dev, NULL); in omapfb_free_resources()
1869 fbdev->num_fbs = 0; in omapfb_create_framebuffers()
1879 fbdev->dev); in omapfb_create_framebuffers()
1881 return -ENOMEM; in omapfb_create_framebuffers()
1885 fbdev->fbs[i] = fbi; in omapfb_create_framebuffers()
1888 ofbi->fbdev = fbdev; in omapfb_create_framebuffers()
1889 ofbi->id = i; in omapfb_create_framebuffers()
1891 ofbi->region = &fbdev->regions[i]; in omapfb_create_framebuffers()
1892 ofbi->region->id = i; in omapfb_create_framebuffers()
1893 init_rwsem(&ofbi->region->lock); in omapfb_create_framebuffers()
1896 ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB : in omapfb_create_framebuffers()
1898 ofbi->mirror = def_mirror; in omapfb_create_framebuffers()
1900 fbdev->num_fbs++; in omapfb_create_framebuffers()
1906 for (i = 0; i < min(fbdev->num_fbs, fbdev->num_overlays); i++) { in omapfb_create_framebuffers()
1907 struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]); in omapfb_create_framebuffers()
1909 ofbi->overlays[0] = fbdev->overlays[i]; in omapfb_create_framebuffers()
1910 ofbi->num_overlays = 1; in omapfb_create_framebuffers()
1916 dev_err(fbdev->dev, "failed to allocate fbmem\n"); in omapfb_create_framebuffers()
1923 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_create_framebuffers()
1924 struct fb_info *fbi = fbdev->fbs[i]; in omapfb_create_framebuffers()
1927 omapfb_get_mem_region(ofbi->region); in omapfb_create_framebuffers()
1929 omapfb_put_mem_region(ofbi->region); in omapfb_create_framebuffers()
1932 dev_err(fbdev->dev, "failed to setup fb_info\n"); in omapfb_create_framebuffers()
1937 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_create_framebuffers()
1938 struct fb_info *fbi = fbdev->fbs[i]; in omapfb_create_framebuffers()
1941 if (ofbi->region->size == 0) in omapfb_create_framebuffers()
1949 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_create_framebuffers()
1950 r = register_framebuffer(fbdev->fbs[i]); in omapfb_create_framebuffers()
1952 dev_err(fbdev->dev, in omapfb_create_framebuffers()
1960 for (i = 0; i < fbdev->num_fbs; i++) { in omapfb_create_framebuffers()
1961 struct fb_info *fbi = fbdev->fbs[i]; in omapfb_create_framebuffers()
1964 omapfb_get_mem_region(ofbi->region); in omapfb_create_framebuffers()
1966 omapfb_put_mem_region(ofbi->region); in omapfb_create_framebuffers()
1969 dev_err(fbdev->dev, "failed to change mode\n"); in omapfb_create_framebuffers()
1975 if (fbdev->num_fbs > 0) { in omapfb_create_framebuffers()
1976 struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[0]); in omapfb_create_framebuffers()
1978 if (ofbi->num_overlays > 0) { in omapfb_create_framebuffers()
1979 struct omap_overlay *ovl = ofbi->overlays[0]; in omapfb_create_framebuffers()
1981 ovl->manager->apply(ovl->manager); in omapfb_create_framebuffers()
1986 dev_err(fbdev->dev, in omapfb_create_framebuffers()
2029 r = -ENOMEM; in omapfb_mode_to_timings()
2035 r = -ENOMEM; in omapfb_mode_to_timings()
2041 r = -ENOMEM; in omapfb_mode_to_timings()
2045 fbi->fbops = fbops; in omapfb_mode_to_timings()
2049 r = -EINVAL; in omapfb_mode_to_timings()
2053 if (display->driver->get_timings) { in omapfb_mode_to_timings()
2054 display->driver->get_timings(display, timings); in omapfb_mode_to_timings()
2056 timings->data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE; in omapfb_mode_to_timings()
2057 timings->de_level = OMAPDSS_SIG_ACTIVE_HIGH; in omapfb_mode_to_timings()
2058 timings->sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE; in omapfb_mode_to_timings()
2061 timings->pixelclock = PICOS2KHZ(var->pixclock) * 1000; in omapfb_mode_to_timings()
2062 timings->hbp = var->left_margin; in omapfb_mode_to_timings()
2063 timings->hfp = var->right_margin; in omapfb_mode_to_timings()
2064 timings->vbp = var->upper_margin; in omapfb_mode_to_timings()
2065 timings->vfp = var->lower_margin; in omapfb_mode_to_timings()
2066 timings->hsw = var->hsync_len; in omapfb_mode_to_timings()
2067 timings->vsw = var->vsync_len; in omapfb_mode_to_timings()
2068 timings->x_res = var->xres; in omapfb_mode_to_timings()
2069 timings->y_res = var->yres; in omapfb_mode_to_timings()
2070 timings->hsync_level = var->sync & FB_SYNC_HOR_HIGH_ACT ? in omapfb_mode_to_timings()
2073 timings->vsync_level = var->sync & FB_SYNC_VERT_HIGH_ACT ? in omapfb_mode_to_timings()
2076 timings->interlace = var->vmode & FB_VMODE_INTERLACED; in omapfb_mode_to_timings()
2078 switch (var->bits_per_pixel) { in omapfb_mode_to_timings()
2112 d->bpp_override = bpp; in omapfb_set_def_mode()
2114 if (display->driver->check_timings) { in omapfb_set_def_mode()
2115 r = display->driver->check_timings(display, &timings); in omapfb_set_def_mode()
2120 if (display->driver->get_timings) { in omapfb_set_def_mode()
2121 display->driver->get_timings(display, &temp_timings); in omapfb_set_def_mode()
2125 return -EINVAL; in omapfb_set_def_mode()
2129 if (display->driver->set_timings) in omapfb_set_def_mode()
2130 display->driver->set_timings(display, &timings); in omapfb_set_def_mode()
2140 BUG_ON(dssdev->driver->get_recommended_bpp == NULL); in omapfb_get_recommended_bpp()
2144 if (d->bpp_override != 0) in omapfb_get_recommended_bpp()
2145 return d->bpp_override; in omapfb_get_recommended_bpp()
2147 return dssdev->driver->get_recommended_bpp(dssdev); in omapfb_get_recommended_bpp()
2157 return -ENOMEM; in omapfb_parse_def_modes()
2167 r = -EINVAL; in omapfb_parse_def_modes()
2176 for (i = 0; i < fbdev->num_displays; ++i) { in omapfb_parse_def_modes()
2177 if (strcmp(fbdev->displays[i].dssdev->name, in omapfb_parse_def_modes()
2179 display = fbdev->displays[i].dssdev; in omapfb_parse_def_modes()
2185 r = -EINVAL; in omapfb_parse_def_modes()
2203 if (display->driver->get_timings) { in fb_videomode_to_omap_timings()
2204 display->driver->get_timings(display, t); in fb_videomode_to_omap_timings()
2206 t->data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE; in fb_videomode_to_omap_timings()
2207 t->de_level = OMAPDSS_SIG_ACTIVE_HIGH; in fb_videomode_to_omap_timings()
2208 t->sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE; in fb_videomode_to_omap_timings()
2211 t->x_res = m->xres; in fb_videomode_to_omap_timings()
2212 t->y_res = m->yres; in fb_videomode_to_omap_timings()
2213 t->pixelclock = PICOS2KHZ(m->pixclock) * 1000; in fb_videomode_to_omap_timings()
2214 t->hsw = m->hsync_len; in fb_videomode_to_omap_timings()
2215 t->hfp = m->right_margin; in fb_videomode_to_omap_timings()
2216 t->hbp = m->left_margin; in fb_videomode_to_omap_timings()
2217 t->vsw = m->vsync_len; in fb_videomode_to_omap_timings()
2218 t->vfp = m->lower_margin; in fb_videomode_to_omap_timings()
2219 t->vbp = m->upper_margin; in fb_videomode_to_omap_timings()
2220 t->hsync_level = m->sync & FB_SYNC_HOR_HIGH_ACT ? in fb_videomode_to_omap_timings()
2223 t->vsync_level = m->sync & FB_SYNC_VERT_HIGH_ACT ? in fb_videomode_to_omap_timings()
2226 t->interlace = m->vmode & FB_VMODE_INTERLACED; in fb_videomode_to_omap_timings()
2236 if (!display->driver->read_edid) in omapfb_find_best_mode()
2237 return -ENODEV; in omapfb_find_best_mode()
2242 return -ENOMEM; in omapfb_find_best_mode()
2244 r = display->driver->read_edid(display, edid, len); in omapfb_find_best_mode()
2250 r = -ENOMEM; in omapfb_find_best_mode()
2256 best_idx = -1; in omapfb_find_best_mode()
2258 for (i = 0; i < specs->modedb_len; ++i) { in omapfb_find_best_mode()
2262 m = &specs->modedb[i]; in omapfb_find_best_mode()
2264 if (m->pixclock == 0) in omapfb_find_best_mode()
2268 if (m->xres == 2880 || m->xres == 1440) in omapfb_find_best_mode()
2271 if (m->vmode & FB_VMODE_INTERLACED || in omapfb_find_best_mode()
2272 m->vmode & FB_VMODE_DOUBLE) in omapfb_find_best_mode()
2277 r = display->driver->check_timings(display, &t); in omapfb_find_best_mode()
2284 if (best_idx == -1) { in omapfb_find_best_mode()
2285 r = -ENOENT; in omapfb_find_best_mode()
2289 fb_videomode_to_omap_timings(&specs->modedb[best_idx], display, in omapfb_find_best_mode()
2295 fb_destroy_modedb(specs->modedb); in omapfb_find_best_mode()
2306 struct omap_dss_driver *dssdrv = dssdev->driver; in omapfb_init_display()
2310 r = dssdrv->enable(dssdev); in omapfb_init_display()
2312 dev_warn(fbdev->dev, "Failed to enable display '%s'\n", in omapfb_init_display()
2313 dssdev->name); in omapfb_init_display()
2319 d->fbdev = fbdev; in omapfb_init_display()
2321 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) { in omapfb_init_display()
2326 d->update_mode = OMAPFB_AUTO_UPDATE; in omapfb_init_display()
2328 d->update_mode = OMAPFB_MANUAL_UPDATE; in omapfb_init_display()
2331 if (dssdrv->enable_te) { in omapfb_init_display()
2332 r = dssdrv->enable_te(dssdev, 1); in omapfb_init_display()
2334 dev_err(fbdev->dev, "Failed to set TE\n"); in omapfb_init_display()
2339 dssdrv->get_resolution(dssdev, &w, &h); in omapfb_init_display()
2340 r = dssdrv->update(dssdev, 0, 0, w, h); in omapfb_init_display()
2342 dev_err(fbdev->dev, in omapfb_init_display()
2347 d->update_mode = OMAPFB_AUTO_UPDATE; in omapfb_init_display()
2359 r = def_dssdev->driver->connect(def_dssdev); in omapfb_init_connections()
2361 dev_err(fbdev->dev, "failed to connect default display\n"); in omapfb_init_connections()
2365 for (i = 0; i < fbdev->num_displays; ++i) { in omapfb_init_connections()
2366 struct omap_dss_device *dssdev = fbdev->displays[i].dssdev; in omapfb_init_connections()
2375 dssdev->driver->connect(dssdev); in omapfb_init_connections()
2381 dev_err(fbdev->dev, "no ovl manager for the default display\n"); in omapfb_init_connections()
2382 return -EINVAL; in omapfb_init_connections()
2385 for (i = 0; i < fbdev->num_overlays; i++) { in omapfb_init_connections()
2386 struct omap_overlay *ovl = fbdev->overlays[i]; in omapfb_init_connections()
2388 if (ovl->manager) in omapfb_init_connections()
2389 ovl->unset_manager(ovl); in omapfb_init_connections()
2391 r = ovl->set_manager(ovl, mgr); in omapfb_init_connections()
2393 dev_warn(fbdev->dev, in omapfb_init_connections()
2395 ovl->name, mgr->name); in omapfb_init_connections()
2415 for (i = 0; i < fbdev->num_displays; ++i) { in omapfb_find_default_display()
2418 dssdev = fbdev->displays[i].dssdev; in omapfb_find_default_display()
2420 if (dssdev->name && strcmp(def_name, dssdev->name) == 0) in omapfb_find_default_display()
2423 if (strcmp(def_name, dssdev->alias) == 0) in omapfb_find_default_display()
2432 for (i = 0; i < fbdev->num_displays; ++i) { in omapfb_find_default_display()
2436 dssdev = fbdev->displays[i].dssdev; in omapfb_find_default_display()
2438 if (dssdev->dev->of_node == NULL) in omapfb_find_default_display()
2441 id = of_alias_get_id(dssdev->dev->of_node, "display"); in omapfb_find_default_display()
2447 return fbdev->displays[0].dssdev; in omapfb_find_default_display()
2461 return -EPROBE_DEFER; in omapfb_probe()
2463 if (pdev->num_resources != 0) { in omapfb_probe()
2464 dev_err(&pdev->dev, "probed for an unknown device\n"); in omapfb_probe()
2465 r = -ENODEV; in omapfb_probe()
2469 fbdev = devm_kzalloc(&pdev->dev, sizeof(struct omapfb2_device), in omapfb_probe()
2472 r = -ENOMEM; in omapfb_probe()
2478 dev_warn(&pdev->dev, "VRFB is not supported on this hardware, " in omapfb_probe()
2479 "ignoring the module parameter vrfb=y\n"); in omapfb_probe()
2486 mutex_init(&fbdev->mtx); in omapfb_probe()
2488 fbdev->dev = &pdev->dev; in omapfb_probe()
2491 fbdev->num_displays = 0; in omapfb_probe()
2498 if (!dssdev->driver) { in omapfb_probe()
2499 dev_warn(&pdev->dev, "no driver for display: %s\n", in omapfb_probe()
2500 dssdev->name); in omapfb_probe()
2505 d = &fbdev->displays[fbdev->num_displays++]; in omapfb_probe()
2506 d->dssdev = dssdev; in omapfb_probe()
2507 if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) in omapfb_probe()
2508 d->update_mode = OMAPFB_MANUAL_UPDATE; in omapfb_probe()
2510 d->update_mode = OMAPFB_AUTO_UPDATE; in omapfb_probe()
2513 if (fbdev->num_displays == 0) { in omapfb_probe()
2514 dev_err(&pdev->dev, "no displays\n"); in omapfb_probe()
2515 r = -EPROBE_DEFER; in omapfb_probe()
2519 fbdev->num_overlays = omap_dss_get_num_overlays(); in omapfb_probe()
2520 for (i = 0; i < fbdev->num_overlays; i++) in omapfb_probe()
2521 fbdev->overlays[i] = omap_dss_get_overlay(i); in omapfb_probe()
2523 fbdev->num_managers = omap_dss_get_num_overlay_managers(); in omapfb_probe()
2524 for (i = 0; i < fbdev->num_managers; i++) in omapfb_probe()
2525 fbdev->managers[i] = omap_dss_get_overlay_manager(i); in omapfb_probe()
2529 dev_err(fbdev->dev, "failed to find default display\n"); in omapfb_probe()
2530 r = -EPROBE_DEFER; in omapfb_probe()
2536 dev_err(fbdev->dev, "failed to init overlay connections\n"); in omapfb_probe()
2542 dev_warn(&pdev->dev, "cannot parse default modes\n"); in omapfb_probe()
2543 } else if (def_display && def_display->driver->set_timings && in omapfb_probe()
2544 def_display->driver->check_timings) { in omapfb_probe()
2550 def_display->driver->set_timings(def_display, &t); in omapfb_probe()
2557 for (i = 0; i < fbdev->num_managers; i++) { in omapfb_probe()
2559 mgr = fbdev->managers[i]; in omapfb_probe()
2560 r = mgr->apply(mgr); in omapfb_probe()
2562 dev_warn(fbdev->dev, "failed to apply dispc config\n"); in omapfb_probe()
2565 DBG("mgr->apply'ed\n"); in omapfb_probe()
2570 dev_err(fbdev->dev, in omapfb_probe()
2580 dev_err(fbdev->dev, "failed to create sysfs entries\n"); in omapfb_probe()
2587 def_display->driver->get_resolution(def_display, &w, &h); in omapfb_probe()
2589 dev_info(fbdev->dev, "using display '%s' mode %dx%d\n", in omapfb_probe()
2590 def_display->name, w, h); in omapfb_probe()
2599 dev_err(&pdev->dev, "failed to setup omapfb\n"); in omapfb_probe()