Lines Matching +full:ecx +full:- +full:1000

1 // SPDX-License-Identifier: GPL-2.0-only
80 if (msg->seq >= UVESAFB_TASKS_MAX) in uvesafb_cn_callback()
84 task = uvfb_tasks[msg->seq]; in uvesafb_cn_callback()
86 if (!task || msg->ack != task->ack) { in uvesafb_cn_callback()
91 utask = (struct uvesafb_task *)msg->data; in uvesafb_cn_callback()
94 if (task->t.buf_len < utask->buf_len || in uvesafb_cn_callback()
95 utask->buf_len > msg->len - sizeof(*utask)) { in uvesafb_cn_callback()
100 uvfb_tasks[msg->seq] = NULL; in uvesafb_cn_callback()
103 memcpy(&task->t, utask, sizeof(*utask)); in uvesafb_cn_callback()
105 if (task->t.buf_len && task->buf) in uvesafb_cn_callback()
106 memcpy(task->buf, utask + 1, task->t.buf_len); in uvesafb_cn_callback()
108 complete(task->done); in uvesafb_cn_callback()
149 int len = sizeof(task->t) + task->t.buf_len; in uvesafb_exec()
158 return -E2BIG; in uvesafb_exec()
163 return -ENOMEM; in uvesafb_exec()
165 init_completion(task->done); in uvesafb_exec()
167 memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id)); in uvesafb_exec()
168 m->seq = seq; in uvesafb_exec()
169 m->len = len; in uvesafb_exec()
170 m->ack = get_random_u32(); in uvesafb_exec()
173 memcpy(m + 1, &task->t, sizeof(task->t)); in uvesafb_exec()
176 memcpy((u8 *)(m + 1) + sizeof(task->t), task->buf, task->t.buf_len); in uvesafb_exec()
182 task->ack = m->ack; in uvesafb_exec()
186 /* If all slots are taken -- bail out. */ in uvesafb_exec()
189 err = -EBUSY; in uvesafb_exec()
198 if (err == -ESRCH) { in uvesafb_exec()
210 if (err == -ENOBUFS) in uvesafb_exec()
213 } else if (err == -ENOBUFS) in uvesafb_exec()
216 if (!err && !(task->t.flags & TF_EXIT)) in uvesafb_exec()
217 err = !wait_for_completion_timeout(task->done, in uvesafb_exec()
238 kfree(task->done); in uvesafb_free()
248 struct completion *cpl = task->done; in uvesafb_reset()
251 task->done = cpl; in uvesafb_reset()
263 task->done = kzalloc(sizeof(*task->done), GFP_KERNEL); in uvesafb_prep()
264 if (!task->done) { in uvesafb_prep()
275 struct uvesafb_par *par = info->par; in uvesafb_setup_var()
277 var->vmode = FB_VMODE_NONINTERLACED; in uvesafb_setup_var()
278 var->sync = FB_SYNC_VERT_HIGH_ACT; in uvesafb_setup_var()
280 var->xres = mode->x_res; in uvesafb_setup_var()
281 var->yres = mode->y_res; in uvesafb_setup_var()
282 var->xres_virtual = mode->x_res; in uvesafb_setup_var()
283 var->yres_virtual = (par->ypan) ? in uvesafb_setup_var()
284 info->fix.smem_len / mode->bytes_per_scan_line : in uvesafb_setup_var()
285 mode->y_res; in uvesafb_setup_var()
286 var->xoffset = 0; in uvesafb_setup_var()
287 var->yoffset = 0; in uvesafb_setup_var()
288 var->bits_per_pixel = mode->bits_per_pixel; in uvesafb_setup_var()
290 if (var->bits_per_pixel == 15) in uvesafb_setup_var()
291 var->bits_per_pixel = 16; in uvesafb_setup_var()
293 if (var->bits_per_pixel > 8) { in uvesafb_setup_var()
294 var->red.offset = mode->red_off; in uvesafb_setup_var()
295 var->red.length = mode->red_len; in uvesafb_setup_var()
296 var->green.offset = mode->green_off; in uvesafb_setup_var()
297 var->green.length = mode->green_len; in uvesafb_setup_var()
298 var->blue.offset = mode->blue_off; in uvesafb_setup_var()
299 var->blue.length = mode->blue_len; in uvesafb_setup_var()
300 var->transp.offset = mode->rsvd_off; in uvesafb_setup_var()
301 var->transp.length = mode->rsvd_len; in uvesafb_setup_var()
303 var->red.offset = 0; in uvesafb_setup_var()
304 var->green.offset = 0; in uvesafb_setup_var()
305 var->blue.offset = 0; in uvesafb_setup_var()
306 var->transp.offset = 0; in uvesafb_setup_var()
308 var->red.length = 8; in uvesafb_setup_var()
309 var->green.length = 8; in uvesafb_setup_var()
310 var->blue.length = 8; in uvesafb_setup_var()
311 var->transp.length = 0; in uvesafb_setup_var()
318 int i, match = -1, h = 0, d = 0x7fffffff; in uvesafb_vbe_find_mode()
320 for (i = 0; i < par->vbe_modes_cnt; i++) { in uvesafb_vbe_find_mode()
321 h = abs(par->vbe_modes[i].x_res - xres) + in uvesafb_vbe_find_mode()
322 abs(par->vbe_modes[i].y_res - yres) + in uvesafb_vbe_find_mode()
323 abs(depth - par->vbe_modes[i].depth); in uvesafb_vbe_find_mode()
332 if (h < d || (h == d && par->vbe_modes[i].depth > depth)) { in uvesafb_vbe_find_mode()
340 par->vbe_modes[match].depth != depth) in uvesafb_vbe_find_mode()
349 return -1; in uvesafb_vbe_find_mode()
358 if (!par->vbe_state_size) in uvesafb_vbe_state_save()
361 state = kmalloc(par->vbe_state_size, GFP_KERNEL); in uvesafb_vbe_state_save()
363 return ERR_PTR(-ENOMEM); in uvesafb_vbe_state_save()
371 task->t.regs.eax = 0x4f04; in uvesafb_vbe_state_save()
372 task->t.regs.ecx = 0x000f; in uvesafb_vbe_state_save()
373 task->t.regs.edx = 0x0001; in uvesafb_vbe_state_save()
374 task->t.flags = TF_BUF_RET | TF_BUF_ESBX; in uvesafb_vbe_state_save()
375 task->t.buf_len = par->vbe_state_size; in uvesafb_vbe_state_save()
376 task->buf = state; in uvesafb_vbe_state_save()
379 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { in uvesafb_vbe_state_save()
381 task->t.regs.eax, err); in uvesafb_vbe_state_save()
402 task->t.regs.eax = 0x4f04; in uvesafb_vbe_state_restore()
403 task->t.regs.ecx = 0x000f; in uvesafb_vbe_state_restore()
404 task->t.regs.edx = 0x0002; in uvesafb_vbe_state_restore()
405 task->t.buf_len = par->vbe_state_size; in uvesafb_vbe_state_restore()
406 task->t.flags = TF_BUF_ESBX; in uvesafb_vbe_state_restore()
407 task->buf = state_buf; in uvesafb_vbe_state_restore()
410 if (err || (task->t.regs.eax & 0xffff) != 0x004f) in uvesafb_vbe_state_restore()
412 task->t.regs.eax, err); in uvesafb_vbe_state_restore()
422 task->t.regs.eax = 0x4f00; in uvesafb_vbe_getinfo()
423 task->t.flags = TF_VBEIB; in uvesafb_vbe_getinfo()
424 task->t.buf_len = sizeof(struct vbe_ib); in uvesafb_vbe_getinfo()
425 task->buf = &par->vbe_ib; in uvesafb_vbe_getinfo()
426 memcpy(par->vbe_ib.vbe_signature, "VBE2", 4); in uvesafb_vbe_getinfo()
429 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { in uvesafb_vbe_getinfo()
431 (u32)task->t.regs.eax, err); in uvesafb_vbe_getinfo()
432 return -EINVAL; in uvesafb_vbe_getinfo()
435 if (par->vbe_ib.vbe_version < 0x0200) { in uvesafb_vbe_getinfo()
436 pr_err("Sorry, pre-VBE 2.0 cards are not supported\n"); in uvesafb_vbe_getinfo()
437 return -EINVAL; in uvesafb_vbe_getinfo()
440 if (!par->vbe_ib.mode_list_ptr) { in uvesafb_vbe_getinfo()
442 return -EINVAL; in uvesafb_vbe_getinfo()
452 if (par->vbe_ib.oem_vendor_name_ptr) in uvesafb_vbe_getinfo()
454 ((char *)task->buf) + par->vbe_ib.oem_vendor_name_ptr); in uvesafb_vbe_getinfo()
456 if (par->vbe_ib.oem_product_name_ptr) in uvesafb_vbe_getinfo()
458 ((char *)task->buf) + par->vbe_ib.oem_product_name_ptr); in uvesafb_vbe_getinfo()
460 if (par->vbe_ib.oem_product_rev_ptr) in uvesafb_vbe_getinfo()
462 ((char *)task->buf) + par->vbe_ib.oem_product_rev_ptr); in uvesafb_vbe_getinfo()
464 if (par->vbe_ib.oem_string_ptr) in uvesafb_vbe_getinfo()
466 ((char *)task->buf) + par->vbe_ib.oem_string_ptr); in uvesafb_vbe_getinfo()
469 (par->vbe_ib.vbe_version & 0xff00) >> 8, in uvesafb_vbe_getinfo()
470 par->vbe_ib.vbe_version & 0xff); in uvesafb_vbe_getinfo()
481 par->vbe_modes_cnt = 0; in uvesafb_vbe_getmodes()
484 mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); in uvesafb_vbe_getmodes()
486 par->vbe_modes_cnt++; in uvesafb_vbe_getmodes()
490 par->vbe_modes = kcalloc(par->vbe_modes_cnt, in uvesafb_vbe_getmodes()
493 if (!par->vbe_modes) in uvesafb_vbe_getmodes()
494 return -ENOMEM; in uvesafb_vbe_getmodes()
497 mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); in uvesafb_vbe_getmodes()
502 task->t.regs.eax = 0x4f01; in uvesafb_vbe_getmodes()
503 task->t.regs.ecx = (u32) *mode; in uvesafb_vbe_getmodes()
504 task->t.flags = TF_BUF_RET | TF_BUF_ESDI; in uvesafb_vbe_getmodes()
505 task->t.buf_len = sizeof(struct vbe_mode_ib); in uvesafb_vbe_getmodes()
506 task->buf = par->vbe_modes + off; in uvesafb_vbe_getmodes()
509 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { in uvesafb_vbe_getmodes()
511 *mode, (u32)task->t.regs.eax, err); in uvesafb_vbe_getmodes()
513 par->vbe_modes_cnt--; in uvesafb_vbe_getmodes()
517 mib = task->buf; in uvesafb_vbe_getmodes()
518 mib->mode_id = *mode; in uvesafb_vbe_getmodes()
525 if ((mib->mode_attr & VBE_MODE_MASK) == VBE_MODE_MASK && in uvesafb_vbe_getmodes()
526 mib->bits_per_pixel >= 8) in uvesafb_vbe_getmodes()
529 par->vbe_modes_cnt--; in uvesafb_vbe_getmodes()
532 mib->depth = mib->red_len + mib->green_len + mib->blue_len; in uvesafb_vbe_getmodes()
538 if (mib->depth == 0 || (mib->depth == 24 && in uvesafb_vbe_getmodes()
539 mib->bits_per_pixel == 32)) in uvesafb_vbe_getmodes()
540 mib->depth = mib->bits_per_pixel; in uvesafb_vbe_getmodes()
543 if (par->vbe_modes_cnt > 0) in uvesafb_vbe_getmodes()
546 return -EINVAL; in uvesafb_vbe_getmodes()
550 * The Protected Mode Interface is 32-bit x86 code, so we only run it on
560 task->t.regs.eax = 0x4f0a; in uvesafb_vbe_getpmi()
561 task->t.regs.ebx = 0x0; in uvesafb_vbe_getpmi()
566 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) { in uvesafb_vbe_getpmi()
567 par->pmi_setpal = par->ypan = 0; in uvesafb_vbe_getpmi()
569 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4) in uvesafb_vbe_getpmi()
570 + task->t.regs.edi); in uvesafb_vbe_getpmi()
571 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1]; in uvesafb_vbe_getpmi()
572 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2]; in uvesafb_vbe_getpmi()
574 (u16)task->t.regs.es, (u16)task->t.regs.edi); in uvesafb_vbe_getpmi()
576 par->pmi_start, par->pmi_pal); in uvesafb_vbe_getpmi()
578 if (par->pmi_base[3]) { in uvesafb_vbe_getpmi()
580 for (i = par->pmi_base[3]/2; in uvesafb_vbe_getpmi()
581 par->pmi_base[i] != 0xffff; i++) in uvesafb_vbe_getpmi()
582 pr_cont(" %x", par->pmi_base[i]); in uvesafb_vbe_getpmi()
585 if (par->pmi_base[i] != 0xffff) { in uvesafb_vbe_getpmi()
587 par->ypan = par->pmi_setpal = 0; in uvesafb_vbe_getpmi()
602 if (info->monspecs.gtf) { in uvesafb_is_valid_mode()
603 fb_videomode_to_var(&info->var, mode); in uvesafb_is_valid_mode()
604 if (fb_validate_mode(&info->var, info)) in uvesafb_is_valid_mode()
608 if (uvesafb_vbe_find_mode(info->par, mode->xres, mode->yres, 8, in uvesafb_is_valid_mode()
609 UVESAFB_EXACT_RES) == -1) in uvesafb_is_valid_mode()
617 struct uvesafb_par *par = info->par; in uvesafb_vbe_getedid()
620 if (noedid || par->vbe_ib.vbe_version < 0x0300) in uvesafb_vbe_getedid()
621 return -EINVAL; in uvesafb_vbe_getedid()
623 task->t.regs.eax = 0x4f15; in uvesafb_vbe_getedid()
624 task->t.regs.ebx = 0; in uvesafb_vbe_getedid()
625 task->t.regs.ecx = 0; in uvesafb_vbe_getedid()
626 task->t.buf_len = 0; in uvesafb_vbe_getedid()
627 task->t.flags = 0; in uvesafb_vbe_getedid()
631 if ((task->t.regs.eax & 0xffff) != 0x004f || err) in uvesafb_vbe_getedid()
632 return -EINVAL; in uvesafb_vbe_getedid()
634 if ((task->t.regs.ebx & 0x3) == 3) { in uvesafb_vbe_getedid()
636 } else if ((task->t.regs.ebx & 0x3) == 2) { in uvesafb_vbe_getedid()
638 } else if ((task->t.regs.ebx & 0x3) == 1) { in uvesafb_vbe_getedid()
642 return -EINVAL; in uvesafb_vbe_getedid()
645 task->t.regs.eax = 0x4f15; in uvesafb_vbe_getedid()
646 task->t.regs.ebx = 1; in uvesafb_vbe_getedid()
647 task->t.regs.ecx = task->t.regs.edx = 0; in uvesafb_vbe_getedid()
648 task->t.flags = TF_BUF_RET | TF_BUF_ESDI; in uvesafb_vbe_getedid()
649 task->t.buf_len = EDID_LENGTH; in uvesafb_vbe_getedid()
650 task->buf = kzalloc(EDID_LENGTH, GFP_KERNEL); in uvesafb_vbe_getedid()
651 if (!task->buf) in uvesafb_vbe_getedid()
652 return -ENOMEM; in uvesafb_vbe_getedid()
656 if ((task->t.regs.eax & 0xffff) == 0x004f && !err) { in uvesafb_vbe_getedid()
657 fb_edid_to_monspecs(task->buf, &info->monspecs); in uvesafb_vbe_getedid()
659 if (info->monspecs.vfmax && info->monspecs.hfmax) { in uvesafb_vbe_getedid()
664 if (info->monspecs.dclkmax == 0) in uvesafb_vbe_getedid()
665 info->monspecs.dclkmax = 300 * 1000000; in uvesafb_vbe_getedid()
666 info->monspecs.gtf = 1; in uvesafb_vbe_getedid()
669 err = -EINVAL; in uvesafb_vbe_getedid()
672 kfree(task->buf); in uvesafb_vbe_getedid()
679 struct uvesafb_par *par = info->par; in uvesafb_vbe_getmonspecs()
682 memset(&info->monspecs, 0, sizeof(info->monspecs)); in uvesafb_vbe_getmonspecs()
690 info->monspecs.gtf = 0; in uvesafb_vbe_getmonspecs()
691 par->nocrtc = 1; in uvesafb_vbe_getmonspecs()
696 info->monspecs.dclkmax = maxclk * 1000000; in uvesafb_vbe_getmonspecs()
698 info->monspecs.vfmax = maxvf; in uvesafb_vbe_getmonspecs()
700 info->monspecs.hfmax = maxhf * 1000; in uvesafb_vbe_getmonspecs()
706 if (info->monspecs.gtf == 0 && maxclk && maxvf && maxhf) { in uvesafb_vbe_getmonspecs()
707 info->monspecs.dclkmin = 0; in uvesafb_vbe_getmonspecs()
708 info->monspecs.vfmin = 60; in uvesafb_vbe_getmonspecs()
709 info->monspecs.hfmin = 29000; in uvesafb_vbe_getmonspecs()
710 info->monspecs.gtf = 1; in uvesafb_vbe_getmonspecs()
711 par->nocrtc = 0; in uvesafb_vbe_getmonspecs()
714 if (info->monspecs.gtf) in uvesafb_vbe_getmonspecs()
716 info->monspecs.vfmax, in uvesafb_vbe_getmonspecs()
717 (int)(info->monspecs.hfmax / 1000), in uvesafb_vbe_getmonspecs()
718 (int)(info->monspecs.dclkmax / 1000000)); in uvesafb_vbe_getmonspecs()
723 for (i = 0; i < par->vbe_modes_cnt; i++) { in uvesafb_vbe_getmonspecs()
728 mode = &par->vbe_modes[i]; in uvesafb_vbe_getmonspecs()
731 var.xres = mode->x_res; in uvesafb_vbe_getmonspecs()
732 var.yres = mode->y_res; in uvesafb_vbe_getmonspecs()
736 fb_add_videomode(&vmode, &info->modelist); in uvesafb_vbe_getmonspecs()
743 fb_add_videomode(&vesa_modes[i], &info->modelist); in uvesafb_vbe_getmonspecs()
746 for (i = 0; i < info->monspecs.modedb_len; i++) { in uvesafb_vbe_getmonspecs()
747 if (uvesafb_is_valid_mode(&info->monspecs.modedb[i], info)) in uvesafb_vbe_getmonspecs()
748 fb_add_videomode(&info->monspecs.modedb[i], in uvesafb_vbe_getmonspecs()
749 &info->modelist); in uvesafb_vbe_getmonspecs()
766 task->t.regs.eax = 0x4f04; in uvesafb_vbe_getstatesize()
767 task->t.regs.ecx = 0x000f; in uvesafb_vbe_getstatesize()
768 task->t.regs.edx = 0x0000; in uvesafb_vbe_getstatesize()
769 task->t.flags = 0; in uvesafb_vbe_getstatesize()
773 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { in uvesafb_vbe_getstatesize()
775 task->t.regs.eax, err); in uvesafb_vbe_getstatesize()
776 par->vbe_state_size = 0; in uvesafb_vbe_getstatesize()
780 par->vbe_state_size = 64 * (task->t.regs.ebx & 0xffff); in uvesafb_vbe_getstatesize()
786 struct uvesafb_par *par = info->par; in uvesafb_vbe_init()
791 return -ENOMEM; in uvesafb_vbe_init()
801 par->nocrtc = nocrtc; in uvesafb_vbe_init()
803 par->pmi_setpal = pmi_setpal; in uvesafb_vbe_init()
804 par->ypan = ypan; in uvesafb_vbe_init()
806 if (par->pmi_setpal || par->ypan) { in uvesafb_vbe_init()
808 par->pmi_setpal = par->ypan = 0; in uvesafb_vbe_init()
815 /* The protected mode interface is not available on non-x86. */ in uvesafb_vbe_init()
816 par->pmi_setpal = par->ypan = 0; in uvesafb_vbe_init()
819 INIT_LIST_HEAD(&info->modelist); in uvesafb_vbe_init()
832 struct uvesafb_par *par = info->par; in uvesafb_vbe_init_mode()
837 for (i = 0; i < par->vbe_modes_cnt; i++) { in uvesafb_vbe_init_mode()
838 if (par->vbe_modes[i].mode_id == vbemode) { in uvesafb_vbe_init_mode()
840 uvesafb_setup_var(&info->var, info, in uvesafb_vbe_init_mode()
841 &par->vbe_modes[modeid]); in uvesafb_vbe_init_mode()
843 &info->var, info); in uvesafb_vbe_init_mode()
848 info->var.pixclock = 0; in uvesafb_vbe_init_mode()
858 list_for_each(pos, &info->modelist) in uvesafb_vbe_init_mode()
868 list_for_each(pos, &info->modelist) { in uvesafb_vbe_init_mode()
870 mode[i] = modelist->mode; in uvesafb_vbe_init_mode()
877 i = fb_find_mode(&info->var, info, mode_option, mode, i, in uvesafb_vbe_init_mode()
885 info->var.xres = 640; in uvesafb_vbe_init_mode()
886 info->var.yres = 480; in uvesafb_vbe_init_mode()
888 fb_find_best_mode(&info->var, &info->modelist); in uvesafb_vbe_init_mode()
891 fb_videomode_to_var(&info->var, mode); in uvesafb_vbe_init_mode()
893 modeid = par->vbe_modes[0].mode_id; in uvesafb_vbe_init_mode()
894 uvesafb_setup_var(&info->var, info, in uvesafb_vbe_init_mode()
895 &par->vbe_modes[modeid]); in uvesafb_vbe_init_mode()
897 &info->var, info); in uvesafb_vbe_init_mode()
904 modeid = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, in uvesafb_vbe_init_mode()
905 info->var.bits_per_pixel, UVESAFB_EXACT_RES); in uvesafb_vbe_init_mode()
907 if (modeid == -1) in uvesafb_vbe_init_mode()
908 return -EINVAL; in uvesafb_vbe_init_mode()
910 uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); in uvesafb_vbe_init_mode()
914 * If we are not VBE3.0+ compliant, we're done -- the BIOS will in uvesafb_vbe_init_mode()
917 if (par->vbe_ib.vbe_version < 0x0300 || par->nocrtc) in uvesafb_vbe_init_mode()
919 &info->var, info); in uvesafb_vbe_init_mode()
929 struct uvesafb_par *par = info->par; in uvesafb_setpalette()
930 int i = par->mode_idx; in uvesafb_setpalette()
939 return -EINVAL; in uvesafb_setpalette()
942 /* Use VGA registers if mode is VGA-compatible. */ in uvesafb_setpalette()
943 if (i >= 0 && i < par->vbe_modes_cnt && in uvesafb_setpalette()
944 par->vbe_modes[i].mode_attr & VBE_MODE_VGACOMPAT) { in uvesafb_setpalette()
953 else if (par->pmi_setpal) { in uvesafb_setpalette()
959 "c" (count), /* ECX */ in uvesafb_setpalette()
962 "S" (&par->pmi_pal)); /* ESI */ in uvesafb_setpalette()
970 return -ENOMEM; in uvesafb_setpalette()
972 task->t.regs.eax = 0x4f09; in uvesafb_setpalette()
973 task->t.regs.ebx = 0x0; in uvesafb_setpalette()
974 task->t.regs.ecx = count; in uvesafb_setpalette()
975 task->t.regs.edx = start; in uvesafb_setpalette()
976 task->t.flags = TF_BUF_ESDI; in uvesafb_setpalette()
977 task->t.buf_len = sizeof(struct uvesafb_pal_entry) * count; in uvesafb_setpalette()
978 task->buf = entries; in uvesafb_setpalette()
981 if ((task->t.regs.eax & 0xffff) != 0x004f) in uvesafb_setpalette()
994 int shift = 16 - dac_width; in uvesafb_setcolreg()
997 if (regno >= info->cmap.len) in uvesafb_setcolreg()
998 return -EINVAL; in uvesafb_setcolreg()
1000 if (info->var.bits_per_pixel == 8) { in uvesafb_setcolreg()
1008 switch (info->var.bits_per_pixel) { in uvesafb_setcolreg()
1010 if (info->var.red.offset == 10) { in uvesafb_setcolreg()
1012 ((u32 *) (info->pseudo_palette))[regno] = in uvesafb_setcolreg()
1018 ((u32 *) (info->pseudo_palette))[regno] = in uvesafb_setcolreg()
1030 ((u32 *)(info->pseudo_palette))[regno] = in uvesafb_setcolreg()
1031 (red << info->var.red.offset) | in uvesafb_setcolreg()
1032 (green << info->var.green.offset) | in uvesafb_setcolreg()
1033 (blue << info->var.blue.offset); in uvesafb_setcolreg()
1043 int shift = 16 - dac_width; in uvesafb_setcmap()
1046 if (info->var.bits_per_pixel == 8) { in uvesafb_setcmap()
1047 if (cmap->start + cmap->len > info->cmap.start + in uvesafb_setcmap()
1048 info->cmap.len || cmap->start < info->cmap.start) in uvesafb_setcmap()
1049 return -EINVAL; in uvesafb_setcmap()
1051 entries = kmalloc_array(cmap->len, sizeof(*entries), in uvesafb_setcmap()
1054 return -ENOMEM; in uvesafb_setcmap()
1056 for (i = 0; i < cmap->len; i++) { in uvesafb_setcmap()
1057 entries[i].red = cmap->red[i] >> shift; in uvesafb_setcmap()
1058 entries[i].green = cmap->green[i] >> shift; in uvesafb_setcmap()
1059 entries[i].blue = cmap->blue[i] >> shift; in uvesafb_setcmap()
1062 err = uvesafb_setpalette(entries, cmap->len, cmap->start, info); in uvesafb_setcmap()
1070 for (i = 0; i < cmap->len; i++) { in uvesafb_setcmap()
1071 err |= uvesafb_setcolreg(cmap->start + i, cmap->red[i], in uvesafb_setcmap()
1072 cmap->green[i], cmap->blue[i], in uvesafb_setcmap()
1084 struct uvesafb_par *par = info->par; in uvesafb_pan_display()
1086 offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4; in uvesafb_pan_display()
1092 if (par->pmi_start) { in uvesafb_pan_display()
1098 "c" (offset), /* ECX */ in uvesafb_pan_display()
1100 "D" (&par->pmi_start)); /* EDI */ in uvesafb_pan_display()
1111 struct uvesafb_par *par = info->par; in uvesafb_blank()
1113 if (par->vbe_ib.capabilities & VBE_CAP_VGACOMPAT) { in uvesafb_blank()
1124 err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL; in uvesafb_blank()
1132 while (loop--); in uvesafb_blank()
1140 return -ENOMEM; in uvesafb_blank()
1142 task->t.regs.eax = 0x4f10; in uvesafb_blank()
1145 task->t.regs.ebx = 0x0001; in uvesafb_blank()
1148 task->t.regs.ebx = 0x0101; /* standby */ in uvesafb_blank()
1151 task->t.regs.ebx = 0x0401; /* powerdown */ in uvesafb_blank()
1158 if (err || (task->t.regs.eax & 0xffff) != 0x004f) in uvesafb_blank()
1167 struct uvesafb_par *par = info->par; in uvesafb_open()
1168 int cnt = atomic_read(&par->ref_count); in uvesafb_open()
1171 if (!cnt && par->vbe_state_size) { in uvesafb_open()
1177 par->vbe_state_orig = buf; in uvesafb_open()
1181 atomic_inc(&par->ref_count); in uvesafb_open()
1188 struct uvesafb_par *par = info->par; in uvesafb_release()
1189 int cnt = atomic_read(&par->ref_count); in uvesafb_release()
1192 return -EINVAL; in uvesafb_release()
1202 task->t.regs.eax = 0x0003; in uvesafb_release()
1209 uvesafb_vbe_state_restore(par, par->vbe_state_orig); in uvesafb_release()
1211 atomic_dec(&par->ref_count); in uvesafb_release()
1218 struct uvesafb_par *par = info->par; in uvesafb_set_par()
1222 int i, err = 0, depth = info->var.bits_per_pixel; in uvesafb_set_par()
1225 depth = info->var.red.length + info->var.green.length + in uvesafb_set_par()
1226 info->var.blue.length; in uvesafb_set_par()
1228 i = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, depth, in uvesafb_set_par()
1231 mode = &par->vbe_modes[i]; in uvesafb_set_par()
1233 return -EINVAL; in uvesafb_set_par()
1237 return -ENOMEM; in uvesafb_set_par()
1239 task->t.regs.eax = 0x4f02; in uvesafb_set_par()
1240 task->t.regs.ebx = mode->mode_id | 0x4000; /* use LFB */ in uvesafb_set_par()
1242 if (par->vbe_ib.vbe_version >= 0x0300 && !par->nocrtc && in uvesafb_set_par()
1243 info->var.pixclock != 0) { in uvesafb_set_par()
1244 task->t.regs.ebx |= 0x0800; /* use CRTC data */ in uvesafb_set_par()
1245 task->t.flags = TF_BUF_ESDI; in uvesafb_set_par()
1248 err = -ENOMEM; in uvesafb_set_par()
1251 crtc->horiz_start = info->var.xres + info->var.right_margin; in uvesafb_set_par()
1252 crtc->horiz_end = crtc->horiz_start + info->var.hsync_len; in uvesafb_set_par()
1253 crtc->horiz_total = crtc->horiz_end + info->var.left_margin; in uvesafb_set_par()
1255 crtc->vert_start = info->var.yres + info->var.lower_margin; in uvesafb_set_par()
1256 crtc->vert_end = crtc->vert_start + info->var.vsync_len; in uvesafb_set_par()
1257 crtc->vert_total = crtc->vert_end + info->var.upper_margin; in uvesafb_set_par()
1259 crtc->pixel_clock = PICOS2KHZ(info->var.pixclock) * 1000; in uvesafb_set_par()
1260 crtc->refresh_rate = (u16)(100 * (crtc->pixel_clock / in uvesafb_set_par()
1261 (crtc->vert_total * crtc->horiz_total))); in uvesafb_set_par()
1263 if (info->var.vmode & FB_VMODE_DOUBLE) in uvesafb_set_par()
1264 crtc->flags |= 0x1; in uvesafb_set_par()
1265 if (info->var.vmode & FB_VMODE_INTERLACED) in uvesafb_set_par()
1266 crtc->flags |= 0x2; in uvesafb_set_par()
1267 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) in uvesafb_set_par()
1268 crtc->flags |= 0x4; in uvesafb_set_par()
1269 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) in uvesafb_set_par()
1270 crtc->flags |= 0x8; in uvesafb_set_par()
1271 memcpy(&par->crtc, crtc, sizeof(*crtc)); in uvesafb_set_par()
1273 memset(&par->crtc, 0, sizeof(*crtc)); in uvesafb_set_par()
1276 task->t.buf_len = sizeof(struct vbe_crtc_ib); in uvesafb_set_par()
1277 task->buf = &par->crtc; in uvesafb_set_par()
1280 if (err || (task->t.regs.eax & 0xffff) != 0x004f) { in uvesafb_set_par()
1286 pr_warn("mode switch failed (eax=0x%x, err=%d) - trying again with default timings\n", in uvesafb_set_par()
1287 task->t.regs.eax, err); in uvesafb_set_par()
1291 info->var.pixclock = 0; in uvesafb_set_par()
1295 task->t.regs.eax, err); in uvesafb_set_par()
1296 err = -EINVAL; in uvesafb_set_par()
1300 par->mode_idx = i; in uvesafb_set_par()
1303 if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC && in uvesafb_set_par()
1304 mode->bits_per_pixel <= 8) { in uvesafb_set_par()
1306 task->t.regs.eax = 0x4f08; in uvesafb_set_par()
1307 task->t.regs.ebx = 0x0800; in uvesafb_set_par()
1310 if (err || (task->t.regs.eax & 0xffff) != 0x004f || in uvesafb_set_par()
1311 ((task->t.regs.ebx & 0xff00) >> 8) != 8) { in uvesafb_set_par()
1318 info->fix.visual = (info->var.bits_per_pixel == 8) ? in uvesafb_set_par()
1320 info->fix.line_length = mode->bytes_per_scan_line; in uvesafb_set_par()
1333 struct uvesafb_par *par = info->par; in uvesafb_check_limits()
1339 if (!var->pixclock) in uvesafb_check_limits()
1342 if (par->vbe_ib.vbe_version < 0x0300) { in uvesafb_check_limits()
1350 mode = fb_find_best_mode(var, &info->modelist); in uvesafb_check_limits()
1352 if (mode->xres == var->xres && mode->yres == var->yres && in uvesafb_check_limits()
1353 !(mode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))) { in uvesafb_check_limits()
1359 if (info->monspecs.gtf && !fb_get_mode(FB_MAXTIMINGS, 0, var, info)) in uvesafb_check_limits()
1362 var->pixclock = 0; in uvesafb_check_limits()
1368 struct uvesafb_par *par = info->par; in uvesafb_check_var()
1370 int match = -1; in uvesafb_check_var()
1371 int depth = var->red.length + var->green.length + var->blue.length; in uvesafb_check_var()
1378 if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8) in uvesafb_check_var()
1379 depth = var->bits_per_pixel; in uvesafb_check_var()
1381 match = uvesafb_vbe_find_mode(par, var->xres, var->yres, depth, in uvesafb_check_var()
1383 if (match == -1) in uvesafb_check_var()
1384 return -EINVAL; in uvesafb_check_var()
1386 mode = &par->vbe_modes[match]; in uvesafb_check_var()
1394 if (var->yres * mode->bytes_per_scan_line > info->fix.smem_len in uvesafb_check_var()
1395 && info->fix.smem_len) in uvesafb_check_var()
1396 return -EINVAL; in uvesafb_check_var()
1398 if ((var->vmode & FB_VMODE_DOUBLE) && in uvesafb_check_var()
1399 !(par->vbe_modes[match].mode_attr & 0x100)) in uvesafb_check_var()
1400 var->vmode &= ~FB_VMODE_DOUBLE; in uvesafb_check_var()
1402 if ((var->vmode & FB_VMODE_INTERLACED) && in uvesafb_check_var()
1403 !(par->vbe_modes[match].mode_attr & 0x200)) in uvesafb_check_var()
1404 var->vmode &= ~FB_VMODE_INTERLACED; in uvesafb_check_var()
1408 var->xres_virtual = var->xres; in uvesafb_check_var()
1409 var->yres_virtual = (par->ypan) ? in uvesafb_check_var()
1410 info->fix.smem_len / mode->bytes_per_scan_line : in uvesafb_check_var()
1411 var->yres; in uvesafb_check_var()
1435 struct uvesafb_par *par = info->par; in uvesafb_init_info()
1438 info->pseudo_palette = ((u8 *)info->par + sizeof(struct uvesafb_par)); in uvesafb_init_info()
1439 info->fix = uvesafb_fix; in uvesafb_init_info()
1440 info->fix.ypanstep = par->ypan ? 1 : 0; in uvesafb_init_info()
1441 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0; in uvesafb_init_info()
1452 for (i = 0; i < par->vbe_modes_cnt; i++) { in uvesafb_init_info()
1453 h = par->vbe_modes[i].bytes_per_scan_line * in uvesafb_init_info()
1454 par->vbe_modes[i].y_res; in uvesafb_init_info()
1461 * size_vmode -- that is the amount of memory needed for the in uvesafb_init_info()
1465 size_vmode = info->var.yres * mode->bytes_per_scan_line; in uvesafb_init_info()
1468 * size_total -- all video memory we have. Used for mtrr in uvesafb_init_info()
1472 size_total = par->vbe_ib.total_memory * 65536; in uvesafb_init_info()
1479 * size_remap -- the amount of video memory we are going to in uvesafb_init_info()
1491 info->fix.smem_len = size_remap; in uvesafb_init_info()
1492 info->fix.smem_start = mode->phys_base_ptr; in uvesafb_init_info()
1498 info->var.yres_virtual = info->fix.smem_len / in uvesafb_init_info()
1499 mode->bytes_per_scan_line; in uvesafb_init_info()
1501 if (par->ypan && info->var.yres_virtual > info->var.yres) { in uvesafb_init_info()
1503 (par->ypan > 1) ? "ywrap" : "ypan", in uvesafb_init_info()
1504 info->var.yres_virtual); in uvesafb_init_info()
1507 info->var.yres_virtual = info->var.yres; in uvesafb_init_info()
1508 par->ypan = 0; in uvesafb_init_info()
1511 info->flags = FBINFO_FLAG_DEFAULT | in uvesafb_init_info()
1512 (par->ypan ? FBINFO_HWACCEL_YPAN : 0); in uvesafb_init_info()
1514 if (!par->ypan) in uvesafb_init_info()
1520 struct uvesafb_par *par = info->par; in uvesafb_init_mtrr()
1522 if (mtrr && !(info->fix.smem_start & (PAGE_SIZE - 1))) { in uvesafb_init_mtrr()
1523 int temp_size = info->fix.smem_len; in uvesafb_init_mtrr()
1527 /* Find the largest power-of-two */ in uvesafb_init_mtrr()
1532 rc = arch_phys_wc_add(info->fix.smem_start, temp_size); in uvesafb_init_mtrr()
1534 } while (temp_size >= PAGE_SIZE && rc == -EINVAL); in uvesafb_init_mtrr()
1537 par->mtrr_handle = rc; in uvesafb_init_mtrr()
1543 info->screen_base = ioremap_wc(info->fix.smem_start, info->fix.smem_len); in uvesafb_ioremap()
1550 struct uvesafb_par *par = info->par; in uvesafb_show_vbe_ver()
1552 return snprintf(buf, PAGE_SIZE, "%.4x\n", par->vbe_ib.vbe_version); in uvesafb_show_vbe_ver()
1561 struct uvesafb_par *par = info->par; in uvesafb_show_vbe_modes()
1564 for (i = 0; i < par->vbe_modes_cnt && ret < PAGE_SIZE; i++) { in uvesafb_show_vbe_modes()
1565 ret += scnprintf(buf + ret, PAGE_SIZE - ret, in uvesafb_show_vbe_modes()
1566 "%dx%d-%d, 0x%.4x\n", in uvesafb_show_vbe_modes()
1567 par->vbe_modes[i].x_res, par->vbe_modes[i].y_res, in uvesafb_show_vbe_modes()
1568 par->vbe_modes[i].depth, par->vbe_modes[i].mode_id); in uvesafb_show_vbe_modes()
1580 struct uvesafb_par *par = info->par; in uvesafb_show_vendor()
1582 if (par->vbe_ib.oem_vendor_name_ptr) in uvesafb_show_vendor()
1584 (&par->vbe_ib) + par->vbe_ib.oem_vendor_name_ptr); in uvesafb_show_vendor()
1595 struct uvesafb_par *par = info->par; in uvesafb_show_product_name()
1597 if (par->vbe_ib.oem_product_name_ptr) in uvesafb_show_product_name()
1599 (&par->vbe_ib) + par->vbe_ib.oem_product_name_ptr); in uvesafb_show_product_name()
1610 struct uvesafb_par *par = info->par; in uvesafb_show_product_rev()
1612 if (par->vbe_ib.oem_product_rev_ptr) in uvesafb_show_product_rev()
1614 (&par->vbe_ib) + par->vbe_ib.oem_product_rev_ptr); in uvesafb_show_product_rev()
1625 struct uvesafb_par *par = info->par; in uvesafb_show_oem_string()
1627 if (par->vbe_ib.oem_string_ptr) in uvesafb_show_oem_string()
1629 (char *)(&par->vbe_ib) + par->vbe_ib.oem_string_ptr); in uvesafb_show_oem_string()
1640 struct uvesafb_par *par = info->par; in uvesafb_show_nocrtc()
1642 return scnprintf(buf, PAGE_SIZE, "%d\n", par->nocrtc); in uvesafb_show_nocrtc()
1649 struct uvesafb_par *par = info->par; in uvesafb_store_nocrtc()
1653 par->nocrtc = 0; in uvesafb_store_nocrtc()
1655 par->nocrtc = 1; in uvesafb_store_nocrtc()
1686 info = framebuffer_alloc(sizeof(*par) + sizeof(u32) * 256, &dev->dev); in uvesafb_probe()
1688 return -ENOMEM; in uvesafb_probe()
1690 par = info->par; in uvesafb_probe()
1698 info->fbops = &uvesafb_ops; in uvesafb_probe()
1702 err = -EINVAL; in uvesafb_probe()
1705 mode = &par->vbe_modes[i]; in uvesafb_probe()
1708 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { in uvesafb_probe()
1709 err = -ENXIO; in uvesafb_probe()
1716 pr_err("request region 0x3c0-0x3e0 failed\n"); in uvesafb_probe()
1717 err = -EIO; in uvesafb_probe()
1721 if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, in uvesafb_probe()
1724 info->fix.smem_start); in uvesafb_probe()
1725 err = -EIO; in uvesafb_probe()
1732 if (!info->screen_base) { in uvesafb_probe()
1734 info->fix.smem_len, info->fix.smem_start); in uvesafb_probe()
1735 err = -EIO; in uvesafb_probe()
1743 err = -EINVAL; in uvesafb_probe()
1748 info->fix.smem_start, info->screen_base, in uvesafb_probe()
1749 info->fix.smem_len / 1024, par->vbe_ib.total_memory * 64); in uvesafb_probe()
1750 fb_info(info, "%s frame buffer device\n", info->fix.id); in uvesafb_probe()
1752 err = sysfs_create_group(&dev->dev.kobj, &uvesafb_dev_attgrp); in uvesafb_probe()
1759 iounmap(info->screen_base); in uvesafb_probe()
1761 release_mem_region(info->fix.smem_start, info->fix.smem_len); in uvesafb_probe()
1765 if (!list_empty(&info->modelist)) in uvesafb_probe()
1766 fb_destroy_modelist(&info->modelist); in uvesafb_probe()
1767 fb_destroy_modedb(info->monspecs.modedb); in uvesafb_probe()
1768 fb_dealloc_cmap(&info->cmap); in uvesafb_probe()
1770 kfree(par->vbe_modes); in uvesafb_probe()
1781 struct uvesafb_par *par = info->par; in uvesafb_remove()
1783 sysfs_remove_group(&dev->dev.kobj, &uvesafb_dev_attgrp); in uvesafb_remove()
1786 iounmap(info->screen_base); in uvesafb_remove()
1787 arch_phys_wc_del(par->mtrr_handle); in uvesafb_remove()
1788 release_mem_region(info->fix.smem_start, info->fix.smem_len); in uvesafb_remove()
1789 fb_destroy_modedb(info->monspecs.modedb); in uvesafb_remove()
1790 fb_dealloc_cmap(&info->cmap); in uvesafb_remove()
1792 kfree(par->vbe_modes); in uvesafb_remove()
1793 kfree(par->vbe_state_orig); in uvesafb_remove()
1794 kfree(par->vbe_state_saved); in uvesafb_remove()
1876 strncpy(v86d_path, buf, PATH_MAX - 1); in v86d_store()
1889 return -ENODEV; in uvesafb_init()
1903 err = -ENOMEM; in uvesafb_init()
1931 task->t.flags = TF_EXIT; in uvesafb_exit()
1956 return -EINVAL; in param_set_scroll()
1981 "Ignore EDID-provided monitor limits when setting modes");
1996 "Specify initial video mode as \"<xres>x<yres>[-<bpp>][@<refresh>]\"");