Lines Matching +full:sense +full:- +full:mode

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:
94 #define DIRTY(z) ((x)->z != (y)->z)
95 #define DIRTY_CMAP(z) (memcmp(&((x)->z), &((y)->z), sizeof((y)->z)))
143 #define CNTRL_REG(INFO,REG) (&(((INFO)->control_regs->REG).r))
168 out_8(&p->cmap_regs->addr, regno); /* tell clut what addr to fill */ in controlfb_setcolreg()
169 out_8(&p->cmap_regs->lut, r); /* send one color channel at */ in controlfb_setcolreg()
170 out_8(&p->cmap_regs->lut, g); /* a time... */ in controlfb_setcolreg()
171 out_8(&p->cmap_regs->lut, b); in controlfb_setcolreg()
175 switch (p->par.cmode) { in controlfb_setcolreg()
177 p->pseudo_palette[regno] = in controlfb_setcolreg()
182 p->pseudo_palette[regno] = (i << 16) | i; in controlfb_setcolreg()
216 struct fb_par_control *par = &p->par; in set_screen_start()
218 par->xoffset = xoffset; in set_screen_start()
219 par->yoffset = yoffset; in set_screen_start()
221 par->yoffset * par->pitch + (par->xoffset << par->cmode)); in set_screen_start()
225 out_8(&p->cmap_regs->addr, (a)); \
226 out_8(&p->cmap_regs->dat, (d))
236 if (PAR_EQUAL(&p->par, par)) { in control_set_hardware()
241 if (p->par.xoffset != par->xoffset || in control_set_hardware()
242 p->par.yoffset != par->yoffset) in control_set_hardware()
243 set_screen_start(par->xoffset, par->yoffset, p); in control_set_hardware()
248 p->par = *par; in control_set_hardware()
249 cmode = p->par.cmode; in control_set_hardware()
250 r = &par->regvals; in control_set_hardware()
253 out_le32(CNTRL_REG(p,ctrl), 0x400 | par->ctrl); in control_set_hardware()
255 set_control_clock(r->clock_params); in control_set_hardware()
257 RADACAL_WRITE(0x20, r->radacal_ctrl); in control_set_hardware()
258 RADACAL_WRITE(0x21, p->control_use_bank2 ? 0 : 1); in control_set_hardware()
262 rp = &p->control_regs->vswin; in control_set_hardware()
264 out_le32(&rp->r, r->regs[i]); in control_set_hardware()
266 out_le32(CNTRL_REG(p,pitch), par->pitch); in control_set_hardware()
267 out_le32(CNTRL_REG(p,mode), r->mode); in control_set_hardware()
268 out_le32(CNTRL_REG(p,vram_attr), p->vram_attr); in control_set_hardware()
269 out_le32(CNTRL_REG(p,start_addr), par->yoffset * par->pitch in control_set_hardware()
270 + (par->xoffset << cmode)); in control_set_hardware()
275 out_le32(CNTRL_REG(p,ctrl), par->ctrl); in control_set_hardware()
278 btext_update_display(p->frame_buffer_phys + CTRLFB_OFF, in control_set_hardware()
279 p->par.xres, p->par.yres, in control_set_hardware()
281 p->par.pitch); in control_set_hardware()
293 * Set VRAM in 2MB (bank 1) mode in find_vram_size()
299 out_8(&p->frame_buffer[0x600000], 0xb3); in find_vram_size()
300 out_8(&p->frame_buffer[0x600001], 0x71); in find_vram_size()
301 invalid_vram_cache(&p->frame_buffer[0x600000]); in find_vram_size()
303 bank2 = (in_8(&p->frame_buffer[0x600000]) == 0xb3) in find_vram_size()
304 && (in_8(&p->frame_buffer[0x600001]) == 0x71); in find_vram_size()
307 * Set VRAM in 2MB (bank 2) mode in find_vram_size()
313 out_8(&p->frame_buffer[0], 0x5a); in find_vram_size()
314 out_8(&p->frame_buffer[1], 0xc7); in find_vram_size()
315 invalid_vram_cache(&p->frame_buffer[0]); in find_vram_size()
317 bank1 = (in_8(&p->frame_buffer[0]) == 0x5a) in find_vram_size()
318 && (in_8(&p->frame_buffer[1]) == 0xc7); in find_vram_size()
325 p->control_use_bank2 = 1; in find_vram_size()
326 p->vram_attr = 0x39; in find_vram_size()
327 p->frame_buffer += 0x600000; in find_vram_size()
328 p->frame_buffer_phys += 0x600000; in find_vram_size()
333 p->vram_attr = 0x51; in find_vram_size()
339 p->vram_attr = 0x31; in find_vram_size()
342 p->total_vram = (bank1 + bank2) * 0x200000; in find_vram_size()
350 * Get the monitor sense value.
356 int sense; in read_control_sense() local
362 sense = (in_le32(CNTRL_REG(p,mon_sense)) & 0x1c0) << 2; in read_control_sense()
364 /* drive each sense line low in turn and collect the other 2 */ in read_control_sense()
367 sense |= (in_le32(CNTRL_REG(p,mon_sense)) & 0xc0) >> 2; in read_control_sense()
370 sense |= ((in_le32(CNTRL_REG(p,mon_sense)) & 0x100) >> 5) in read_control_sense()
374 sense |= (in_le32(CNTRL_REG(p,mon_sense)) & 0x180) >> 7; in read_control_sense()
378 return sense; in read_control_sense()
425 * This routine takes a user-supplied var, and picks the best vmode/cmode
438 struct control_regvals *r = &par->regvals; in control_var_to_par()
440 switch (var->bits_per_pixel) { in control_var_to_par()
442 par->cmode = CMODE_8; in control_var_to_par()
443 if (p->total_vram > 0x200000) { in control_var_to_par()
444 r->mode = 3; in control_var_to_par()
445 r->radacal_ctrl = 0x20; in control_var_to_par()
448 r->mode = 2; in control_var_to_par()
449 r->radacal_ctrl = 0x10; in control_var_to_par()
455 par->cmode = CMODE_16; in control_var_to_par()
456 if (p->total_vram > 0x200000) { in control_var_to_par()
457 r->mode = 2; in control_var_to_par()
458 r->radacal_ctrl = 0x24; in control_var_to_par()
461 r->mode = 1; in control_var_to_par()
462 r->radacal_ctrl = 0x14; in control_var_to_par()
467 par->cmode = CMODE_32; in control_var_to_par()
468 if (p->total_vram > 0x200000) { in control_var_to_par()
469 r->mode = 1; in control_var_to_par()
470 r->radacal_ctrl = 0x28; in control_var_to_par()
472 r->mode = 0; in control_var_to_par()
473 r->radacal_ctrl = 0x18; in control_var_to_par()
478 return -EINVAL; in control_var_to_par()
483 * 32-byte aligned in control_var_to_par()
485 hstep = 31 >> par->cmode; in control_var_to_par()
486 par->xres = (var->xres + hstep) & ~hstep; in control_var_to_par()
487 par->vxres = (var->xres_virtual + hstep) & ~hstep; in control_var_to_par()
488 par->xoffset = (var->xoffset + hstep) & ~hstep; in control_var_to_par()
489 if (par->vxres < par->xres) in control_var_to_par()
490 par->vxres = par->xres; in control_var_to_par()
491 par->pitch = par->vxres << par->cmode; in control_var_to_par()
493 par->yres = var->yres; in control_var_to_par()
494 par->vyres = var->yres_virtual; in control_var_to_par()
495 par->yoffset = var->yoffset; in control_var_to_par()
496 if (par->vyres < par->yres) in control_var_to_par()
497 par->vyres = par->yres; in control_var_to_par()
499 par->sync = var->sync; in control_var_to_par()
501 if (par->pitch * par->vyres + CTRLFB_OFF > p->total_vram) in control_var_to_par()
502 return -EINVAL; in control_var_to_par()
504 if (par->xoffset + par->xres > par->vxres) in control_var_to_par()
505 par->xoffset = par->vxres - par->xres; in control_var_to_par()
506 if (par->yoffset + par->yres > par->vyres) in control_var_to_par()
507 par->yoffset = par->vyres - par->yres; in control_var_to_par()
509 pixclock = (var->pixclock < CONTROL_PIXCLOCK_MIN)? CONTROL_PIXCLOCK_MIN: in control_var_to_par()
510 var->pixclock; in control_var_to_par()
511 if (calc_clock_params(pixclock, r->clock_params)) in control_var_to_par()
512 return -EINVAL; in control_var_to_par()
514 hperiod = ((var->left_margin + par->xres + var->right_margin in control_var_to_par()
515 + var->hsync_len) >> 1) - 2; in control_var_to_par()
517 hsblank = hssync - (var->right_margin >> 1); in control_var_to_par()
518 hesync = (var->hsync_len >> 1) - 1; in control_var_to_par()
519 heblank = (var->left_margin >> 1) + hesync; in control_var_to_par()
520 piped = heblank - piped_diff; in control_var_to_par()
521 heq = var->hsync_len >> 2; in control_var_to_par()
523 hserr = hssync-hesync; in control_var_to_par()
524 vperiod = (var->vsync_len + var->lower_margin + par->yres in control_var_to_par()
525 + var->upper_margin) << 1; in control_var_to_par()
526 vssync = vperiod - 2; in control_var_to_par()
527 vesync = (var->vsync_len << 1) - vperiod + vssync; in control_var_to_par()
528 veblank = (var->upper_margin << 1) + vesync; in control_var_to_par()
529 vsblank = vssync - (var->lower_margin << 1); in control_var_to_par()
533 r->regs[0] = vswin; in control_var_to_par()
534 r->regs[1] = vsblank; in control_var_to_par()
535 r->regs[2] = veblank; in control_var_to_par()
536 r->regs[3] = vewin; in control_var_to_par()
537 r->regs[4] = vesync; in control_var_to_par()
538 r->regs[5] = vssync; in control_var_to_par()
539 r->regs[6] = vperiod; in control_var_to_par()
540 r->regs[7] = piped; in control_var_to_par()
541 r->regs[8] = hperiod; in control_var_to_par()
542 r->regs[9] = hsblank; in control_var_to_par()
543 r->regs[10] = heblank; in control_var_to_par()
544 r->regs[11] = hesync; in control_var_to_par()
545 r->regs[12] = hssync; in control_var_to_par()
546 r->regs[13] = heq; in control_var_to_par()
547 r->regs[14] = hlfln; in control_var_to_par()
548 r->regs[15] = hserr; in control_var_to_par()
550 if (par->xres >= 1280 && par->cmode >= CMODE_16) in control_var_to_par()
551 par->ctrl = 0x7f; in control_var_to_par()
553 par->ctrl = 0x3b; in control_var_to_par()
555 if (mac_var_to_vmode(var, &par->vmode, &cmode)) in control_var_to_par()
556 par->vmode = 0; in control_var_to_par()
570 rv = (struct control_regints *) par->regvals.regs; in control_par_to_var()
573 var->xres = par->xres; in control_par_to_var()
574 var->yres = par->yres; in control_par_to_var()
575 var->xres_virtual = par->vxres; in control_par_to_var()
576 var->yres_virtual = par->vyres; in control_par_to_var()
577 var->xoffset = par->xoffset; in control_par_to_var()
578 var->yoffset = par->yoffset; in control_par_to_var()
580 switch(par->cmode) { in control_par_to_var()
583 var->bits_per_pixel = 8; in control_par_to_var()
584 var->red.length = 8; in control_par_to_var()
585 var->green.length = 8; in control_par_to_var()
586 var->blue.length = 8; in control_par_to_var()
589 var->bits_per_pixel = 16; in control_par_to_var()
590 var->red.offset = 10; in control_par_to_var()
591 var->red.length = 5; in control_par_to_var()
592 var->green.offset = 5; in control_par_to_var()
593 var->green.length = 5; in control_par_to_var()
594 var->blue.length = 5; in control_par_to_var()
597 var->bits_per_pixel = 32; in control_par_to_var()
598 var->red.offset = 16; in control_par_to_var()
599 var->red.length = 8; in control_par_to_var()
600 var->green.offset = 8; in control_par_to_var()
601 var->green.length = 8; in control_par_to_var()
602 var->blue.length = 8; in control_par_to_var()
603 var->transp.offset = 24; in control_par_to_var()
604 var->transp.length = 8; in control_par_to_var()
607 var->height = -1; in control_par_to_var()
608 var->width = -1; in control_par_to_var()
609 var->vmode = FB_VMODE_NONINTERLACED; in control_par_to_var()
611 var->left_margin = (rv->heblank - rv->hesync) << 1; in control_par_to_var()
612 var->right_margin = (rv->hssync - rv->hsblank) << 1; in control_par_to_var()
613 var->hsync_len = (rv->hperiod + 2 - rv->hssync + rv->hesync) << 1; in control_par_to_var()
615 var->upper_margin = (rv->veblank - rv->vesync) >> 1; in control_par_to_var()
616 var->lower_margin = (rv->vssync - rv->vsblank) >> 1; in control_par_to_var()
617 var->vsync_len = (rv->vperiod - rv->vssync + rv->vesync) >> 1; in control_par_to_var()
619 var->sync = par->sync; in control_par_to_var()
628 var->pixclock = CONTROL_PIXCLOCK_BASE * par->regvals.clock_params[0]; in control_par_to_var()
629 var->pixclock /= par->regvals.clock_params[1]; in control_par_to_var()
630 var->pixclock >>= par->regvals.clock_params[2]; in control_par_to_var()
661 if((err = control_var_to_par(&info->var, &par, info))) { in controlfb_set_par()
669 info->fix.visual = (p->par.cmode == CMODE_8) ? in controlfb_set_par()
671 info->fix.line_length = p->par.pitch; in controlfb_set_par()
672 info->fix.xpanstep = 32 >> p->par.cmode; in controlfb_set_par()
673 info->fix.ypanstep = 1; in controlfb_set_par()
684 struct fb_par_control *par = &p->par; in controlfb_pan_display()
687 * make sure start addr will be 32-byte aligned in controlfb_pan_display()
689 hstep = 0x1f >> par->cmode; in controlfb_pan_display()
690 xoffset = (var->xoffset + hstep) & ~hstep; in controlfb_pan_display()
692 if (xoffset+par->xres > par->vxres || in controlfb_pan_display()
693 var->yoffset+par->yres > par->vyres) in controlfb_pan_display()
694 return -EINVAL; in controlfb_pan_display()
696 set_screen_start(xoffset, var->yoffset, p); in controlfb_pan_display()
746 start = info->fix.smem_start; in controlfb_mmap()
747 len = info->fix.smem_len; in controlfb_mmap()
749 if (vma->vm_pgoff >= mmio_pgoff) { in controlfb_mmap()
750 if (info->var.accel_flags) in controlfb_mmap()
751 return -EINVAL; in controlfb_mmap()
752 vma->vm_pgoff -= mmio_pgoff; in controlfb_mmap()
753 start = info->fix.mmio_start; in controlfb_mmap()
754 len = info->fix.mmio_len; in controlfb_mmap()
755 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in controlfb_mmap()
758 vma->vm_page_prot = pgprot_cached_wthru(vma->vm_page_prot); in controlfb_mmap()
783 info->par = &p->par; in control_init_info()
784 info->fbops = &controlfb_ops; in control_init_info()
785 info->pseudo_palette = p->pseudo_palette; in control_init_info()
786 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; in control_init_info()
787 info->screen_base = p->frame_buffer + CTRLFB_OFF; in control_init_info()
789 fb_alloc_cmap(&info->cmap, 256, 0); in control_init_info()
792 strcpy(info->fix.id, "control"); in control_init_info()
793 info->fix.mmio_start = p->control_regs_phys; in control_init_info()
794 info->fix.mmio_len = sizeof(struct control_regs); in control_init_info()
795 info->fix.type = FB_TYPE_PACKED_PIXELS; in control_init_info()
796 info->fix.smem_start = p->frame_buffer_phys + CTRLFB_OFF; in control_init_info()
797 info->fix.smem_len = p->total_vram - CTRLFB_OFF; in control_init_info()
798 info->fix.ywrapstep = 0; in control_init_info()
799 info->fix.type_aux = 0; in control_init_info()
800 info->fix.accel = FB_ACCEL_NONE; in control_init_info()
817 control_mac_modes[vmode - 1].m[1] >= 0) in control_setup()
848 int full, sense, vmode, cmode, vyres; in init_control() local
854 full = p->total_vram == 0x400000; in init_control()
856 /* Try to pick a video mode out of NVRAM if we have one. */ in init_control()
867 control_mac_modes[vmode - 1].m[full] < cmode) { in init_control()
868 sense = read_control_sense(p); in init_control()
869 printk(KERN_CONT "Monitor sense value = 0x%x, ", sense); in init_control()
870 vmode = mac_map_monitor_sense(sense); in init_control()
871 if (control_mac_modes[vmode - 1].m[full] < 0) in init_control()
873 cmode = min(cmode, control_mac_modes[vmode - 1].m[full]); in init_control()
877 control_init_info(&p->info, p); in init_control()
888 return -ENXIO; in init_control()
892 printk("using video mode %d and color mode %d.\n", vmode, cmode); in init_control()
894 vyres = (p->total_vram - CTRLFB_OFF) / (var.xres << cmode); in init_control()
900 rc = fb_set_var(&p->info, &var); in init_control()
905 if (register_framebuffer(&p->info) < 0) in init_control()
906 return -ENXIO; in init_control()
908 fb_info(&p->info, "control display adapter\n"); in init_control()
920 if (p->cmap_regs) in control_cleanup()
921 iounmap(p->cmap_regs); in control_cleanup()
922 if (p->control_regs) in control_cleanup()
923 iounmap(p->control_regs); in control_cleanup()
924 if (p->frame_buffer) { in control_cleanup()
925 if (p->control_use_bank2) in control_cleanup()
926 p->frame_buffer -= 0x600000; in control_cleanup()
927 iounmap(p->frame_buffer); in control_cleanup()
929 if (p->cmap_regs_phys) in control_cleanup()
930 release_mem_region(p->cmap_regs_phys, 0x1000); in control_cleanup()
931 if (p->control_regs_phys) in control_cleanup()
932 release_mem_region(p->control_regs_phys, p->control_regs_size); in control_cleanup()
933 if (p->fb_orig_base) in control_cleanup()
934 release_mem_region(p->fb_orig_base, p->fb_orig_size); in control_cleanup()
948 return -ENXIO; in control_of_init()
954 return -ENXIO; in control_of_init()
958 return -ENOMEM; in control_of_init()
962 p->fb_orig_base = fb_res.start; in control_of_init()
963 p->fb_orig_size = resource_size(&fb_res); in control_of_init()
964 /* use the big-endian aperture (??) */ in control_of_init()
965 p->frame_buffer_phys = fb_res.start + 0x800000; in control_of_init()
966 p->control_regs_phys = reg_res.start; in control_of_init()
967 p->control_regs_size = resource_size(&reg_res); in control_of_init()
969 if (!p->fb_orig_base || in control_of_init()
970 !request_mem_region(p->fb_orig_base,p->fb_orig_size,"controlfb")) { in control_of_init()
971 p->fb_orig_base = 0; in control_of_init()
975 p->frame_buffer = ioremap_wt(p->frame_buffer_phys, 0x800000); in control_of_init()
977 if (!p->control_regs_phys || in control_of_init()
978 !request_mem_region(p->control_regs_phys, p->control_regs_size, in control_of_init()
980 p->control_regs_phys = 0; in control_of_init()
983 p->control_regs = ioremap(p->control_regs_phys, p->control_regs_size); in control_of_init()
985 p->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */ in control_of_init()
986 if (!request_mem_region(p->cmap_regs_phys, 0x1000, "controlfb cmap")) { in control_of_init()
987 p->cmap_regs_phys = 0; in control_of_init()
990 p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000); in control_of_init()
992 if (!p->cmap_regs || !p->control_regs || !p->frame_buffer) in control_of_init()
996 if (!p->total_vram) in control_of_init()
1006 return -ENXIO; in control_of_init()
1013 int ret = -ENXIO; in control_init()
1016 return -ENODEV; in control_init()