Lines Matching +full:hssync +full:- +full:start +full:- +full:delay
2 * controlfb.c -- frame buffer device for the PowerMac 'control' display
11 * drivers/video/chipsfb.c -- frame buffer device for
18 * And from the frame buffer device for Open Firmware-initialized devices:
40 #include <linux/delay.h>
93 #define DIRTY(z) ((x)->z != (y)->z)
94 #define DIRTY_CMAP(z) (memcmp(&((x)->z), &((y)->z), sizeof((y)->z)))
135 #define CNTRL_REG(INFO,REG) (&(((INFO)->control_regs->REG).r))
160 out_8(&p->cmap_regs->addr, regno); /* tell clut what addr to fill */ in controlfb_setcolreg()
161 out_8(&p->cmap_regs->lut, r); /* send one color channel at */ in controlfb_setcolreg()
162 out_8(&p->cmap_regs->lut, g); /* a time... */ in controlfb_setcolreg()
163 out_8(&p->cmap_regs->lut, b); in controlfb_setcolreg()
167 switch (p->par.cmode) { in controlfb_setcolreg()
169 p->pseudo_palette[regno] = in controlfb_setcolreg()
174 p->pseudo_palette[regno] = (i << 16) | i; in controlfb_setcolreg()
203 * Set screen start address according to var offset values
208 struct fb_par_control *par = &p->par; in set_screen_start()
210 par->xoffset = xoffset; in set_screen_start()
211 par->yoffset = yoffset; in set_screen_start()
213 par->yoffset * par->pitch + (par->xoffset << par->cmode)); in set_screen_start()
217 out_8(&p->cmap_regs->addr, (a)); \
218 out_8(&p->cmap_regs->dat, (d))
228 if (PAR_EQUAL(&p->par, par)) { in control_set_hardware()
233 if (p->par.xoffset != par->xoffset || in control_set_hardware()
234 p->par.yoffset != par->yoffset) in control_set_hardware()
235 set_screen_start(par->xoffset, par->yoffset, p); in control_set_hardware()
240 p->par = *par; in control_set_hardware()
241 cmode = p->par.cmode; in control_set_hardware()
242 r = &par->regvals; in control_set_hardware()
245 out_le32(CNTRL_REG(p,ctrl), 0x400 | par->ctrl); in control_set_hardware()
247 set_control_clock(r->clock_params); in control_set_hardware()
249 RADACAL_WRITE(0x20, r->radacal_ctrl); in control_set_hardware()
250 RADACAL_WRITE(0x21, p->control_use_bank2 ? 0 : 1); in control_set_hardware()
254 rp = &p->control_regs->vswin; in control_set_hardware()
256 out_le32(&rp->r, r->regs[i]); in control_set_hardware()
258 out_le32(CNTRL_REG(p,pitch), par->pitch); in control_set_hardware()
259 out_le32(CNTRL_REG(p,mode), r->mode); in control_set_hardware()
260 out_le32(CNTRL_REG(p,vram_attr), p->vram_attr); in control_set_hardware()
261 out_le32(CNTRL_REG(p,start_addr), par->yoffset * par->pitch in control_set_hardware()
262 + (par->xoffset << cmode)); in control_set_hardware()
267 out_le32(CNTRL_REG(p,ctrl), par->ctrl); in control_set_hardware()
270 btext_update_display(p->frame_buffer_phys + CTRLFB_OFF, in control_set_hardware()
271 p->par.xres, p->par.yres, in control_set_hardware()
273 p->par.pitch); in control_set_hardware()
291 out_8(&p->frame_buffer[0x600000], 0xb3); in find_vram_size()
292 out_8(&p->frame_buffer[0x600001], 0x71); in find_vram_size()
293 invalid_vram_cache(&p->frame_buffer[0x600000]); in find_vram_size()
295 bank2 = (in_8(&p->frame_buffer[0x600000]) == 0xb3) in find_vram_size()
296 && (in_8(&p->frame_buffer[0x600001]) == 0x71); in find_vram_size()
305 out_8(&p->frame_buffer[0], 0x5a); in find_vram_size()
306 out_8(&p->frame_buffer[1], 0xc7); in find_vram_size()
307 invalid_vram_cache(&p->frame_buffer[0]); in find_vram_size()
309 bank1 = (in_8(&p->frame_buffer[0]) == 0x5a) in find_vram_size()
310 && (in_8(&p->frame_buffer[1]) == 0xc7); in find_vram_size()
317 p->control_use_bank2 = 1; in find_vram_size()
318 p->vram_attr = 0x39; in find_vram_size()
319 p->frame_buffer += 0x600000; in find_vram_size()
320 p->frame_buffer_phys += 0x600000; in find_vram_size()
325 p->vram_attr = 0x51; in find_vram_size()
331 p->vram_attr = 0x31; in find_vram_size()
334 p->total_vram = (bank1 + bank2) * 0x200000; in find_vram_size()
417 * This routine takes a user-supplied var, and picks the best vmode/cmode
425 unsigned hperiod, hssync, hsblank, hesync, heblank, piped, heq, hlfln, in control_var_to_par() local
430 struct control_regvals *r = &par->regvals; in control_var_to_par()
432 switch (var->bits_per_pixel) { in control_var_to_par()
434 par->cmode = CMODE_8; in control_var_to_par()
435 if (p->total_vram > 0x200000) { in control_var_to_par()
436 r->mode = 3; in control_var_to_par()
437 r->radacal_ctrl = 0x20; in control_var_to_par()
440 r->mode = 2; in control_var_to_par()
441 r->radacal_ctrl = 0x10; in control_var_to_par()
447 par->cmode = CMODE_16; in control_var_to_par()
448 if (p->total_vram > 0x200000) { in control_var_to_par()
449 r->mode = 2; in control_var_to_par()
450 r->radacal_ctrl = 0x24; in control_var_to_par()
453 r->mode = 1; in control_var_to_par()
454 r->radacal_ctrl = 0x14; in control_var_to_par()
459 par->cmode = CMODE_32; in control_var_to_par()
460 if (p->total_vram > 0x200000) { in control_var_to_par()
461 r->mode = 1; in control_var_to_par()
462 r->radacal_ctrl = 0x28; in control_var_to_par()
464 r->mode = 0; in control_var_to_par()
465 r->radacal_ctrl = 0x18; in control_var_to_par()
470 return -EINVAL; in control_var_to_par()
475 * 32-byte aligned in control_var_to_par()
477 hstep = 31 >> par->cmode; in control_var_to_par()
478 par->xres = (var->xres + hstep) & ~hstep; in control_var_to_par()
479 par->vxres = (var->xres_virtual + hstep) & ~hstep; in control_var_to_par()
480 par->xoffset = (var->xoffset + hstep) & ~hstep; in control_var_to_par()
481 if (par->vxres < par->xres) in control_var_to_par()
482 par->vxres = par->xres; in control_var_to_par()
483 par->pitch = par->vxres << par->cmode; in control_var_to_par()
485 par->yres = var->yres; in control_var_to_par()
486 par->vyres = var->yres_virtual; in control_var_to_par()
487 par->yoffset = var->yoffset; in control_var_to_par()
488 if (par->vyres < par->yres) in control_var_to_par()
489 par->vyres = par->yres; in control_var_to_par()
491 par->sync = var->sync; in control_var_to_par()
493 if (par->pitch * par->vyres + CTRLFB_OFF > p->total_vram) in control_var_to_par()
494 return -EINVAL; in control_var_to_par()
496 if (par->xoffset + par->xres > par->vxres) in control_var_to_par()
497 par->xoffset = par->vxres - par->xres; in control_var_to_par()
498 if (par->yoffset + par->yres > par->vyres) in control_var_to_par()
499 par->yoffset = par->vyres - par->yres; in control_var_to_par()
501 pixclock = (var->pixclock < CONTROL_PIXCLOCK_MIN)? CONTROL_PIXCLOCK_MIN: in control_var_to_par()
502 var->pixclock; in control_var_to_par()
503 if (calc_clock_params(pixclock, r->clock_params)) in control_var_to_par()
504 return -EINVAL; in control_var_to_par()
506 hperiod = ((var->left_margin + par->xres + var->right_margin in control_var_to_par()
507 + var->hsync_len) >> 1) - 2; in control_var_to_par()
508 hssync = hperiod + 1; in control_var_to_par()
509 hsblank = hssync - (var->right_margin >> 1); in control_var_to_par()
510 hesync = (var->hsync_len >> 1) - 1; in control_var_to_par()
511 heblank = (var->left_margin >> 1) + hesync; in control_var_to_par()
512 piped = heblank - piped_diff; in control_var_to_par()
513 heq = var->hsync_len >> 2; in control_var_to_par()
515 hserr = hssync-hesync; in control_var_to_par()
516 vperiod = (var->vsync_len + var->lower_margin + par->yres in control_var_to_par()
517 + var->upper_margin) << 1; in control_var_to_par()
518 vssync = vperiod - 2; in control_var_to_par()
519 vesync = (var->vsync_len << 1) - vperiod + vssync; in control_var_to_par()
520 veblank = (var->upper_margin << 1) + vesync; in control_var_to_par()
521 vsblank = vssync - (var->lower_margin << 1); in control_var_to_par()
525 r->regs[0] = vswin; in control_var_to_par()
526 r->regs[1] = vsblank; in control_var_to_par()
527 r->regs[2] = veblank; in control_var_to_par()
528 r->regs[3] = vewin; in control_var_to_par()
529 r->regs[4] = vesync; in control_var_to_par()
530 r->regs[5] = vssync; in control_var_to_par()
531 r->regs[6] = vperiod; in control_var_to_par()
532 r->regs[7] = piped; in control_var_to_par()
533 r->regs[8] = hperiod; in control_var_to_par()
534 r->regs[9] = hsblank; in control_var_to_par()
535 r->regs[10] = heblank; in control_var_to_par()
536 r->regs[11] = hesync; in control_var_to_par()
537 r->regs[12] = hssync; in control_var_to_par()
538 r->regs[13] = heq; in control_var_to_par()
539 r->regs[14] = hlfln; in control_var_to_par()
540 r->regs[15] = hserr; in control_var_to_par()
542 if (par->xres >= 1280 && par->cmode >= CMODE_16) in control_var_to_par()
543 par->ctrl = 0x7f; in control_var_to_par()
545 par->ctrl = 0x3b; in control_var_to_par()
547 if (mac_var_to_vmode(var, &par->vmode, &cmode)) in control_var_to_par()
548 par->vmode = 0; in control_var_to_par()
562 rv = (struct control_regints *) par->regvals.regs; in control_par_to_var()
565 var->xres = par->xres; in control_par_to_var()
566 var->yres = par->yres; in control_par_to_var()
567 var->xres_virtual = par->vxres; in control_par_to_var()
568 var->yres_virtual = par->vyres; in control_par_to_var()
569 var->xoffset = par->xoffset; in control_par_to_var()
570 var->yoffset = par->yoffset; in control_par_to_var()
572 switch(par->cmode) { in control_par_to_var()
575 var->bits_per_pixel = 8; in control_par_to_var()
576 var->red.length = 8; in control_par_to_var()
577 var->green.length = 8; in control_par_to_var()
578 var->blue.length = 8; in control_par_to_var()
581 var->bits_per_pixel = 16; in control_par_to_var()
582 var->red.offset = 10; in control_par_to_var()
583 var->red.length = 5; in control_par_to_var()
584 var->green.offset = 5; in control_par_to_var()
585 var->green.length = 5; in control_par_to_var()
586 var->blue.length = 5; in control_par_to_var()
589 var->bits_per_pixel = 32; in control_par_to_var()
590 var->red.offset = 16; in control_par_to_var()
591 var->red.length = 8; in control_par_to_var()
592 var->green.offset = 8; in control_par_to_var()
593 var->green.length = 8; in control_par_to_var()
594 var->blue.length = 8; in control_par_to_var()
595 var->transp.offset = 24; in control_par_to_var()
596 var->transp.length = 8; in control_par_to_var()
599 var->height = -1; in control_par_to_var()
600 var->width = -1; in control_par_to_var()
601 var->vmode = FB_VMODE_NONINTERLACED; in control_par_to_var()
603 var->left_margin = (rv->heblank - rv->hesync) << 1; in control_par_to_var()
604 var->right_margin = (rv->hssync - rv->hsblank) << 1; in control_par_to_var()
605 var->hsync_len = (rv->hperiod + 2 - rv->hssync + rv->hesync) << 1; in control_par_to_var()
607 var->upper_margin = (rv->veblank - rv->vesync) >> 1; in control_par_to_var()
608 var->lower_margin = (rv->vssync - rv->vsblank) >> 1; in control_par_to_var()
609 var->vsync_len = (rv->vperiod - rv->vssync + rv->vesync) >> 1; in control_par_to_var()
611 var->sync = par->sync; in control_par_to_var()
620 var->pixclock = CONTROL_PIXCLOCK_BASE * par->regvals.clock_params[0]; in control_par_to_var()
621 var->pixclock /= par->regvals.clock_params[1]; in control_par_to_var()
622 var->pixclock >>= par->regvals.clock_params[2]; in control_par_to_var()
653 if((err = control_var_to_par(&info->var, &par, info))) { in controlfb_set_par()
661 info->fix.visual = (p->par.cmode == CMODE_8) ? in controlfb_set_par()
663 info->fix.line_length = p->par.pitch; in controlfb_set_par()
664 info->fix.xpanstep = 32 >> p->par.cmode; in controlfb_set_par()
665 info->fix.ypanstep = 1; in controlfb_set_par()
676 struct fb_par_control *par = &p->par; in controlfb_pan_display()
679 * make sure start addr will be 32-byte aligned in controlfb_pan_display()
681 hstep = 0x1f >> par->cmode; in controlfb_pan_display()
682 xoffset = (var->xoffset + hstep) & ~hstep; in controlfb_pan_display()
684 if (xoffset+par->xres > par->vxres || in controlfb_pan_display()
685 var->yoffset+par->yres > par->vyres) in controlfb_pan_display()
686 return -EINVAL; in controlfb_pan_display()
688 set_screen_start(xoffset, var->yoffset, p); in controlfb_pan_display()
735 unsigned long start; in controlfb_mmap() local
738 start = info->fix.smem_start; in controlfb_mmap()
739 len = info->fix.smem_len; in controlfb_mmap()
740 mmio_pgoff = PAGE_ALIGN((start & ~PAGE_MASK) + len) >> PAGE_SHIFT; in controlfb_mmap()
741 if (vma->vm_pgoff >= mmio_pgoff) { in controlfb_mmap()
742 if (info->var.accel_flags) in controlfb_mmap()
743 return -EINVAL; in controlfb_mmap()
744 vma->vm_pgoff -= mmio_pgoff; in controlfb_mmap()
745 start = info->fix.mmio_start; in controlfb_mmap()
746 len = info->fix.mmio_len; in controlfb_mmap()
747 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in controlfb_mmap()
750 vma->vm_page_prot = pgprot_cached_wthru(vma->vm_page_prot); in controlfb_mmap()
753 return vm_iomap_memory(vma, start, len); in controlfb_mmap()
774 info->par = &p->par; in control_init_info()
775 info->fbops = &controlfb_ops; in control_init_info()
776 info->pseudo_palette = p->pseudo_palette; in control_init_info()
777 info->flags = FBINFO_HWACCEL_YPAN; in control_init_info()
778 info->screen_base = p->frame_buffer + CTRLFB_OFF; in control_init_info()
780 fb_alloc_cmap(&info->cmap, 256, 0); in control_init_info()
783 strcpy(info->fix.id, "control"); in control_init_info()
784 info->fix.mmio_start = p->control_regs_phys; in control_init_info()
785 info->fix.mmio_len = sizeof(struct control_regs); in control_init_info()
786 info->fix.type = FB_TYPE_PACKED_PIXELS; in control_init_info()
787 info->fix.smem_start = p->frame_buffer_phys + CTRLFB_OFF; in control_init_info()
788 info->fix.smem_len = p->total_vram - CTRLFB_OFF; in control_init_info()
789 info->fix.ywrapstep = 0; in control_init_info()
790 info->fix.type_aux = 0; in control_init_info()
791 info->fix.accel = FB_ACCEL_NONE; in control_init_info()
808 control_mac_modes[vmode - 1].m[1] >= 0) in control_setup()
845 full = p->total_vram == 0x400000; in init_control()
858 control_mac_modes[vmode - 1].m[full] < cmode) { in init_control()
862 if (control_mac_modes[vmode - 1].m[full] < 0) in init_control()
864 cmode = min(cmode, control_mac_modes[vmode - 1].m[full]); in init_control()
868 control_init_info(&p->info, p); in init_control()
879 return -ENXIO; in init_control()
885 vyres = (p->total_vram - CTRLFB_OFF) / (var.xres << cmode); in init_control()
891 rc = fb_set_var(&p->info, &var); in init_control()
896 if (register_framebuffer(&p->info) < 0) in init_control()
897 return -ENXIO; in init_control()
899 fb_info(&p->info, "control display adapter\n"); in init_control()
911 if (p->cmap_regs) in control_cleanup()
912 iounmap(p->cmap_regs); in control_cleanup()
913 if (p->control_regs) in control_cleanup()
914 iounmap(p->control_regs); in control_cleanup()
915 if (p->frame_buffer) { in control_cleanup()
916 if (p->control_use_bank2) in control_cleanup()
917 p->frame_buffer -= 0x600000; in control_cleanup()
918 iounmap(p->frame_buffer); in control_cleanup()
920 if (p->cmap_regs_phys) in control_cleanup()
921 release_mem_region(p->cmap_regs_phys, 0x1000); in control_cleanup()
922 if (p->control_regs_phys) in control_cleanup()
923 release_mem_region(p->control_regs_phys, p->control_regs_size); in control_cleanup()
924 if (p->fb_orig_base) in control_cleanup()
925 release_mem_region(p->fb_orig_base, p->fb_orig_size); in control_cleanup()
939 return -ENXIO; in control_of_init()
945 return -ENXIO; in control_of_init()
949 return -ENOMEM; in control_of_init()
953 p->fb_orig_base = fb_res.start; in control_of_init()
954 p->fb_orig_size = resource_size(&fb_res); in control_of_init()
955 /* use the big-endian aperture (??) */ in control_of_init()
956 p->frame_buffer_phys = fb_res.start + 0x800000; in control_of_init()
957 p->control_regs_phys = reg_res.start; in control_of_init()
958 p->control_regs_size = resource_size(®_res); in control_of_init()
960 if (!p->fb_orig_base || in control_of_init()
961 !request_mem_region(p->fb_orig_base,p->fb_orig_size,"controlfb")) { in control_of_init()
962 p->fb_orig_base = 0; in control_of_init()
966 p->frame_buffer = ioremap_wt(p->frame_buffer_phys, 0x800000); in control_of_init()
968 if (!p->control_regs_phys || in control_of_init()
969 !request_mem_region(p->control_regs_phys, p->control_regs_size, in control_of_init()
971 p->control_regs_phys = 0; in control_of_init()
974 p->control_regs = ioremap(p->control_regs_phys, p->control_regs_size); in control_of_init()
976 p->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */ in control_of_init()
977 if (!request_mem_region(p->cmap_regs_phys, 0x1000, "controlfb cmap")) { in control_of_init()
978 p->cmap_regs_phys = 0; in control_of_init()
981 p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000); in control_of_init()
983 if (!p->cmap_regs || !p->control_regs || !p->frame_buffer) in control_of_init()
987 if (!p->total_vram) in control_of_init()
997 return -ENXIO; in control_of_init()
1004 int ret = -ENXIO; in control_init()
1007 return -ENODEV; in control_init()