|
Line 0
Link Here
|
|
|
1 |
/* |
| 2 |
* A framebuffer driver for VBE 2.0+ compliant video cards |
| 3 |
* |
| 4 |
* (c) 2007 Michal Januszewski <spock@gentoo.org> |
| 5 |
* Loosely based upon the vesafb driver. |
| 6 |
* |
| 7 |
*/ |
| 8 |
#include <linux/init.h> |
| 9 |
#include <linux/module.h> |
| 10 |
#include <linux/moduleparam.h> |
| 11 |
#include <linux/skbuff.h> |
| 12 |
#include <linux/timer.h> |
| 13 |
#include <linux/completion.h> |
| 14 |
#include <linux/connector.h> |
| 15 |
#include <linux/random.h> |
| 16 |
#include <linux/platform_device.h> |
| 17 |
#include <linux/limits.h> |
| 18 |
#include <linux/fb.h> |
| 19 |
#include <linux/io.h> |
| 20 |
#include <linux/mutex.h> |
| 21 |
#include <video/edid.h> |
| 22 |
#include <video/vga.h> |
| 23 |
#include <video/uvesafb.h> |
| 24 |
#ifdef CONFIG_MTRR |
| 25 |
#include <asm/mtrr.h> |
| 26 |
#endif |
| 27 |
#include "edid.h" |
| 28 |
#include <linux/percpu.h> |
| 29 |
|
| 30 |
struct rnd_state {u32 s1, s2, s3;}; |
| 31 |
|
| 32 |
static DEFINE_PER_CPU(struct rnd_state, net_rand_state); |
| 33 |
|
| 34 |
#define TAUSWORTHE(s,a,b,c,d) ((s&c)<<d) ^ (((s <<a) ^ s)>>b) |
| 35 |
|
| 36 |
static u32 random32(void) |
| 37 |
{ |
| 38 |
struct rnd_state *state = &get_cpu_var(net_rand_state); |
| 39 |
|
| 40 |
state->s1 = TAUSWORTHE(state->s1, 13, 19, 4294967294UL, 12); |
| 41 |
state->s2 = TAUSWORTHE(state->s2, 2, 25, 4294967288UL, 4); |
| 42 |
state->s3 = TAUSWORTHE(state->s3, 3, 11, 4294967280UL, 17); |
| 43 |
put_cpu_var(state); |
| 44 |
return (state->s1 ^ state->s2 ^ state->s3); |
| 45 |
} |
| 46 |
|
| 47 |
static struct cb_id uvesafb_cn_id = { |
| 48 |
.idx = CN_IDX_V86D, |
| 49 |
.val = CN_VAL_V86D_UVESAFB |
| 50 |
}; |
| 51 |
static char v86d_path[PATH_MAX] = "/sbin/v86d"; |
| 52 |
static char v86d_started; /* has v86d been started by uvesafb? */ |
| 53 |
|
| 54 |
static struct fb_fix_screeninfo uvesafb_fix __devinitdata = { |
| 55 |
.id = "VESA VGA", |
| 56 |
.type = FB_TYPE_PACKED_PIXELS, |
| 57 |
.accel = FB_ACCEL_NONE, |
| 58 |
.visual = FB_VISUAL_TRUECOLOR, |
| 59 |
}; |
| 60 |
|
| 61 |
static int mtrr __devinitdata = 3; /* enable mtrr by default */ |
| 62 |
static int blank __devinitdata = 1; /* enable blanking by default */ |
| 63 |
static int ypan __devinitdata = 1; /* 0: scroll, 1: ypan, 2: ywrap */ |
| 64 |
static int pmi_setpal __devinitdata = 1; /* use PMI for palette changes */ |
| 65 |
static int nocrtc __devinitdata; /* ignore CRTC settings */ |
| 66 |
static int noedid __devinitdata; /* don't try DDC transfers */ |
| 67 |
static int vram_remap __devinitdata; /* set amt. of memory to be used */ |
| 68 |
static int vram_total __devinitdata; /* set total amount of memory */ |
| 69 |
static u16 maxclk __devinitdata; /* maximum pixel clock */ |
| 70 |
static u16 maxvf __devinitdata; /* maximum vertical frequency */ |
| 71 |
static u16 maxhf __devinitdata; /* maximum horizontal frequency */ |
| 72 |
static u16 vbemode __devinitdata; /* force use of a specific VBE mode */ |
| 73 |
static char *mode_option __devinitdata; |
| 74 |
|
| 75 |
static struct uvesafb_ktask *uvfb_tasks[UVESAFB_TASKS_MAX]; |
| 76 |
static DEFINE_MUTEX(uvfb_lock); |
| 77 |
|
| 78 |
/* |
| 79 |
* A handler for replies from userspace. |
| 80 |
* |
| 81 |
* Make sure each message passes consistency checks and if it does, |
| 82 |
* find the kernel part of the task struct, copy the registers and |
| 83 |
* the buffer contents and then complete the task. |
| 84 |
*/ |
| 85 |
static void uvesafb_cn_callback(void *data) |
| 86 |
{ |
| 87 |
struct cn_msg *msg = data; |
| 88 |
struct uvesafb_task *utask; |
| 89 |
struct uvesafb_ktask *task; |
| 90 |
|
| 91 |
if (msg->seq >= UVESAFB_TASKS_MAX) |
| 92 |
return; |
| 93 |
|
| 94 |
mutex_lock(&uvfb_lock); |
| 95 |
task = uvfb_tasks[msg->seq]; |
| 96 |
|
| 97 |
if (!task || msg->ack != task->ack) { |
| 98 |
mutex_unlock(&uvfb_lock); |
| 99 |
return; |
| 100 |
} |
| 101 |
|
| 102 |
utask = (struct uvesafb_task *)msg->data; |
| 103 |
|
| 104 |
/* Sanity checks for the buffer length. */ |
| 105 |
if (task->t.buf_len < utask->buf_len || |
| 106 |
utask->buf_len > msg->len - sizeof(*utask)) { |
| 107 |
mutex_unlock(&uvfb_lock); |
| 108 |
return; |
| 109 |
} |
| 110 |
|
| 111 |
uvfb_tasks[msg->seq] = NULL; |
| 112 |
mutex_unlock(&uvfb_lock); |
| 113 |
|
| 114 |
memcpy(&task->t, utask, sizeof(*utask)); |
| 115 |
|
| 116 |
if (task->t.buf_len && task->buf) |
| 117 |
memcpy(task->buf, utask + 1, task->t.buf_len); |
| 118 |
|
| 119 |
complete(task->done); |
| 120 |
return; |
| 121 |
} |
| 122 |
|
| 123 |
static int uvesafb_helper_start(void) |
| 124 |
{ |
| 125 |
char *envp[] = { |
| 126 |
"HOME=/", |
| 127 |
"PATH=/sbin:/bin", |
| 128 |
NULL, |
| 129 |
}; |
| 130 |
|
| 131 |
char *argv[] = { |
| 132 |
v86d_path, |
| 133 |
NULL, |
| 134 |
}; |
| 135 |
|
| 136 |
return call_usermodehelper(v86d_path, argv, envp, 1); |
| 137 |
} |
| 138 |
|
| 139 |
/* |
| 140 |
* Execute a uvesafb task. |
| 141 |
* |
| 142 |
* Returns 0 if the task is executed successfully. |
| 143 |
* |
| 144 |
* A message sent to the userspace consists of the uvesafb_task |
| 145 |
* struct and (optionally) a buffer. The uvesafb_task struct is |
| 146 |
* a simplified version of uvesafb_ktask (its kernel counterpart) |
| 147 |
* containing only the register values, flags and the length of |
| 148 |
* the buffer. |
| 149 |
* |
| 150 |
* Each message is assigned a sequence number (increased linearly) |
| 151 |
* and a random ack number. The sequence number is used as a key |
| 152 |
* for the uvfb_tasks array which holds pointers to uvesafb_ktask |
| 153 |
* structs for all requests. |
| 154 |
*/ |
| 155 |
static int uvesafb_exec(struct uvesafb_ktask *task) |
| 156 |
{ |
| 157 |
static int seq; |
| 158 |
struct cn_msg *m; |
| 159 |
int err; |
| 160 |
int len = sizeof(task->t) + task->t.buf_len; |
| 161 |
|
| 162 |
/* |
| 163 |
* Check whether the message isn't longer than the maximum |
| 164 |
* allowed by connector. |
| 165 |
*/ |
| 166 |
if (sizeof(*m) + len > CONNECTOR_MAX_MSG_SIZE) { |
| 167 |
printk(KERN_WARNING "uvesafb: message too long (%d), " |
| 168 |
"can't execute task\n", (int)(sizeof(*m) + len)); |
| 169 |
return -E2BIG; |
| 170 |
} |
| 171 |
|
| 172 |
m = kzalloc(sizeof(*m) + len, GFP_KERNEL); |
| 173 |
if (!m) |
| 174 |
return -ENOMEM; |
| 175 |
|
| 176 |
init_completion(task->done); |
| 177 |
|
| 178 |
memcpy(&m->id, &uvesafb_cn_id, sizeof(m->id)); |
| 179 |
m->seq = seq; |
| 180 |
m->len = len; |
| 181 |
m->ack = random32(); |
| 182 |
|
| 183 |
/* uvesafb_task structure */ |
| 184 |
memcpy(m + 1, &task->t, sizeof(task->t)); |
| 185 |
|
| 186 |
/* Buffer */ |
| 187 |
memcpy((u8 *)(m + 1) + sizeof(task->t), task->buf, task->t.buf_len); |
| 188 |
|
| 189 |
/* |
| 190 |
* Save the message ack number so that we can find the kernel |
| 191 |
* part of this task when a reply is received from userspace. |
| 192 |
*/ |
| 193 |
task->ack = m->ack; |
| 194 |
|
| 195 |
mutex_lock(&uvfb_lock); |
| 196 |
|
| 197 |
/* If all slots are taken -- bail out. */ |
| 198 |
if (uvfb_tasks[seq]) { |
| 199 |
mutex_unlock(&uvfb_lock); |
| 200 |
return -EBUSY; |
| 201 |
} |
| 202 |
|
| 203 |
/* Save a pointer to the kernel part of the task struct. */ |
| 204 |
uvfb_tasks[seq] = task; |
| 205 |
mutex_unlock(&uvfb_lock); |
| 206 |
|
| 207 |
err = cn_netlink_send(m, 0, gfp_any()); |
| 208 |
if (err == -ESRCH) { |
| 209 |
/* |
| 210 |
* Try to start the userspace helper if sending |
| 211 |
* the request failed the first time. |
| 212 |
*/ |
| 213 |
err = uvesafb_helper_start(); |
| 214 |
if (err) { |
| 215 |
printk(KERN_ERR "uvesafb: failed to execute %s\n", |
| 216 |
v86d_path); |
| 217 |
printk(KERN_ERR "uvesafb: make sure that the v86d " |
| 218 |
"helper is installed and executable\n"); |
| 219 |
} else { |
| 220 |
v86d_started = 1; |
| 221 |
err = cn_netlink_send(m, 0, gfp_any()); |
| 222 |
} |
| 223 |
} |
| 224 |
kfree(m); |
| 225 |
|
| 226 |
if (!err && !(task->t.flags & TF_EXIT)) |
| 227 |
err = !wait_for_completion_timeout(task->done, |
| 228 |
msecs_to_jiffies(UVESAFB_TIMEOUT)); |
| 229 |
|
| 230 |
mutex_lock(&uvfb_lock); |
| 231 |
uvfb_tasks[seq] = NULL; |
| 232 |
mutex_unlock(&uvfb_lock); |
| 233 |
|
| 234 |
seq++; |
| 235 |
if (seq >= UVESAFB_TASKS_MAX) |
| 236 |
seq = 0; |
| 237 |
|
| 238 |
return err; |
| 239 |
} |
| 240 |
|
| 241 |
/* |
| 242 |
* Free a uvesafb_ktask struct. |
| 243 |
*/ |
| 244 |
static void uvesafb_free(struct uvesafb_ktask *task) |
| 245 |
{ |
| 246 |
if (task) { |
| 247 |
if (task->done) |
| 248 |
kfree(task->done); |
| 249 |
kfree(task); |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
/* |
| 254 |
* Prepare a uvesafb_ktask struct to be used again. |
| 255 |
*/ |
| 256 |
static void uvesafb_reset(struct uvesafb_ktask *task) |
| 257 |
{ |
| 258 |
struct completion *cpl = task->done; |
| 259 |
|
| 260 |
memset(task, 0, sizeof(*task)); |
| 261 |
task->done = cpl; |
| 262 |
} |
| 263 |
|
| 264 |
/* |
| 265 |
* Allocate and prepare a uvesafb_ktask struct. |
| 266 |
*/ |
| 267 |
static struct uvesafb_ktask *uvesafb_prep(void) |
| 268 |
{ |
| 269 |
struct uvesafb_ktask *task; |
| 270 |
|
| 271 |
task = kzalloc(sizeof(*task), GFP_KERNEL); |
| 272 |
if (task) { |
| 273 |
task->done = kzalloc(sizeof(*task->done), GFP_KERNEL); |
| 274 |
if (!task->done) { |
| 275 |
kfree(task); |
| 276 |
task = NULL; |
| 277 |
} |
| 278 |
} |
| 279 |
return task; |
| 280 |
} |
| 281 |
|
| 282 |
static void uvesafb_setup_var(struct fb_var_screeninfo *var, |
| 283 |
struct fb_info *info, struct vbe_mode_ib *mode) |
| 284 |
{ |
| 285 |
struct uvesafb_par *par = info->par; |
| 286 |
|
| 287 |
var->vmode = FB_VMODE_NONINTERLACED; |
| 288 |
var->sync = FB_SYNC_VERT_HIGH_ACT; |
| 289 |
|
| 290 |
var->xres = mode->x_res; |
| 291 |
var->yres = mode->y_res; |
| 292 |
var->xres_virtual = mode->x_res; |
| 293 |
var->yres_virtual = (par->ypan) ? |
| 294 |
info->fix.smem_len / mode->bytes_per_scan_line : |
| 295 |
mode->y_res; |
| 296 |
var->xoffset = 0; |
| 297 |
var->yoffset = 0; |
| 298 |
var->bits_per_pixel = mode->bits_per_pixel; |
| 299 |
|
| 300 |
if (var->bits_per_pixel == 15) |
| 301 |
var->bits_per_pixel = 16; |
| 302 |
|
| 303 |
if (var->bits_per_pixel > 8) { |
| 304 |
var->red.offset = mode->red_off; |
| 305 |
var->red.length = mode->red_len; |
| 306 |
var->green.offset = mode->green_off; |
| 307 |
var->green.length = mode->green_len; |
| 308 |
var->blue.offset = mode->blue_off; |
| 309 |
var->blue.length = mode->blue_len; |
| 310 |
var->transp.offset = mode->rsvd_off; |
| 311 |
var->transp.length = mode->rsvd_len; |
| 312 |
} else { |
| 313 |
var->red.offset = 0; |
| 314 |
var->green.offset = 0; |
| 315 |
var->blue.offset = 0; |
| 316 |
var->transp.offset = 0; |
| 317 |
|
| 318 |
/* |
| 319 |
* We're assuming that we can switch the DAC to 8 bits. If |
| 320 |
* this proves to be incorrect, we'll update the fields |
| 321 |
* later in set_par(). |
| 322 |
*/ |
| 323 |
if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC) { |
| 324 |
var->red.length = 8; |
| 325 |
var->green.length = 8; |
| 326 |
var->blue.length = 8; |
| 327 |
var->transp.length = 0; |
| 328 |
} else { |
| 329 |
var->red.length = 6; |
| 330 |
var->green.length = 6; |
| 331 |
var->blue.length = 6; |
| 332 |
var->transp.length = 0; |
| 333 |
} |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
static int uvesafb_vbe_find_mode(struct uvesafb_par *par, |
| 338 |
int xres, int yres, int depth, unsigned char flags) |
| 339 |
{ |
| 340 |
int i, match = -1, h = 0, d = 0x7fffffff; |
| 341 |
|
| 342 |
for (i = 0; i < par->vbe_modes_cnt; i++) { |
| 343 |
h = abs(par->vbe_modes[i].x_res - xres) + |
| 344 |
abs(par->vbe_modes[i].y_res - yres) + |
| 345 |
abs(depth - par->vbe_modes[i].depth); |
| 346 |
|
| 347 |
/* |
| 348 |
* We have an exact match in terms of resolution |
| 349 |
* and depth. |
| 350 |
*/ |
| 351 |
if (h == 0) |
| 352 |
return i; |
| 353 |
|
| 354 |
if (h < d || (h == d && par->vbe_modes[i].depth > depth)) { |
| 355 |
d = h; |
| 356 |
match = i; |
| 357 |
} |
| 358 |
} |
| 359 |
i = 1; |
| 360 |
|
| 361 |
if (flags & UVESAFB_EXACT_DEPTH && |
| 362 |
par->vbe_modes[match].depth != depth) |
| 363 |
i = 0; |
| 364 |
|
| 365 |
if (flags & UVESAFB_EXACT_RES && d > 24) |
| 366 |
i = 0; |
| 367 |
|
| 368 |
if (i != 0) |
| 369 |
return match; |
| 370 |
else |
| 371 |
return -1; |
| 372 |
} |
| 373 |
|
| 374 |
static u8 *uvesafb_vbe_state_save(struct uvesafb_par *par) |
| 375 |
{ |
| 376 |
struct uvesafb_ktask *task; |
| 377 |
u8 *state; |
| 378 |
int err; |
| 379 |
|
| 380 |
if (!par->vbe_state_size) |
| 381 |
return NULL; |
| 382 |
|
| 383 |
state = kmalloc(par->vbe_state_size, GFP_KERNEL); |
| 384 |
if (!state) |
| 385 |
return NULL; |
| 386 |
|
| 387 |
task = uvesafb_prep(); |
| 388 |
if (!task) { |
| 389 |
kfree(state); |
| 390 |
return NULL; |
| 391 |
} |
| 392 |
|
| 393 |
task->t.regs.eax = 0x4f04; |
| 394 |
task->t.regs.ecx = 0x000f; |
| 395 |
task->t.regs.edx = 0x0001; |
| 396 |
task->t.flags = TF_BUF_RET | TF_BUF_ESBX; |
| 397 |
task->t.buf_len = par->vbe_state_size; |
| 398 |
task->buf = state; |
| 399 |
err = uvesafb_exec(task); |
| 400 |
|
| 401 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) { |
| 402 |
printk(KERN_WARNING "uvesafb: VBE get state call " |
| 403 |
"failed (eax=0x%x, err=%d)\n", |
| 404 |
task->t.regs.eax, err); |
| 405 |
kfree(state); |
| 406 |
state = NULL; |
| 407 |
} |
| 408 |
|
| 409 |
uvesafb_free(task); |
| 410 |
return state; |
| 411 |
} |
| 412 |
|
| 413 |
static void uvesafb_vbe_state_restore(struct uvesafb_par *par, u8 *state_buf) |
| 414 |
{ |
| 415 |
struct uvesafb_ktask *task; |
| 416 |
int err; |
| 417 |
|
| 418 |
if (!state_buf) |
| 419 |
return; |
| 420 |
|
| 421 |
task = uvesafb_prep(); |
| 422 |
if (!task) |
| 423 |
return; |
| 424 |
|
| 425 |
task->t.regs.eax = 0x4f04; |
| 426 |
task->t.regs.ecx = 0x000f; |
| 427 |
task->t.regs.edx = 0x0002; |
| 428 |
task->t.buf_len = par->vbe_state_size; |
| 429 |
task->t.flags = TF_BUF_ESBX; |
| 430 |
task->buf = state_buf; |
| 431 |
|
| 432 |
err = uvesafb_exec(task); |
| 433 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) |
| 434 |
printk(KERN_WARNING "uvesafb: VBE state restore call " |
| 435 |
"failed (eax=0x%x, err=%d)\n", |
| 436 |
task->t.regs.eax, err); |
| 437 |
|
| 438 |
uvesafb_free(task); |
| 439 |
} |
| 440 |
|
| 441 |
static int __devinit uvesafb_vbe_getinfo(struct uvesafb_ktask *task, |
| 442 |
struct uvesafb_par *par) |
| 443 |
{ |
| 444 |
int err; |
| 445 |
|
| 446 |
task->t.regs.eax = 0x4f00; |
| 447 |
task->t.flags = TF_VBEIB; |
| 448 |
task->t.buf_len = sizeof(struct vbe_ib); |
| 449 |
task->buf = &par->vbe_ib; |
| 450 |
strncpy(par->vbe_ib.vbe_signature, "VBE2", 4); |
| 451 |
|
| 452 |
err = uvesafb_exec(task); |
| 453 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) { |
| 454 |
printk(KERN_ERR "uvesafb: Getting VBE info block failed " |
| 455 |
"(eax=0x%x, err=%d)\n", (u32)task->t.regs.eax, |
| 456 |
err); |
| 457 |
return -EINVAL; |
| 458 |
} |
| 459 |
|
| 460 |
if (par->vbe_ib.vbe_version < 0x0200) { |
| 461 |
printk(KERN_ERR "uvesafb: Sorry, pre-VBE 2.0 cards are " |
| 462 |
"not supported.\n"); |
| 463 |
return -EINVAL; |
| 464 |
} |
| 465 |
|
| 466 |
if (!par->vbe_ib.mode_list_ptr) { |
| 467 |
printk(KERN_ERR "uvesafb: Missing mode list!\n"); |
| 468 |
return -EINVAL; |
| 469 |
} |
| 470 |
|
| 471 |
printk(KERN_INFO "uvesafb: "); |
| 472 |
|
| 473 |
/* |
| 474 |
* Convert string pointers and the mode list pointer into |
| 475 |
* usable addresses. Print informational messages about the |
| 476 |
* video adapter and its vendor. |
| 477 |
*/ |
| 478 |
if (par->vbe_ib.oem_vendor_name_ptr) |
| 479 |
printk("%s, ", |
| 480 |
((char *)task->buf) + par->vbe_ib.oem_vendor_name_ptr); |
| 481 |
|
| 482 |
if (par->vbe_ib.oem_product_name_ptr) |
| 483 |
printk("%s, ", |
| 484 |
((char *)task->buf) + par->vbe_ib.oem_product_name_ptr); |
| 485 |
|
| 486 |
if (par->vbe_ib.oem_product_rev_ptr) |
| 487 |
printk("%s, ", |
| 488 |
((char *)task->buf) + par->vbe_ib.oem_product_rev_ptr); |
| 489 |
|
| 490 |
if (par->vbe_ib.oem_string_ptr) |
| 491 |
printk("OEM: %s, ", |
| 492 |
((char *)task->buf) + par->vbe_ib.oem_string_ptr); |
| 493 |
|
| 494 |
printk("VBE v%d.%d\n", ((par->vbe_ib.vbe_version & 0xff00) >> 8), |
| 495 |
par->vbe_ib.vbe_version & 0xff); |
| 496 |
|
| 497 |
return 0; |
| 498 |
} |
| 499 |
|
| 500 |
static int __devinit uvesafb_vbe_getmodes(struct uvesafb_ktask *task, |
| 501 |
struct uvesafb_par *par) |
| 502 |
{ |
| 503 |
int off = 0, err; |
| 504 |
u16 *mode; |
| 505 |
|
| 506 |
par->vbe_modes_cnt = 0; |
| 507 |
|
| 508 |
/* Count available modes. */ |
| 509 |
mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); |
| 510 |
while (*mode != 0xffff) { |
| 511 |
par->vbe_modes_cnt++; |
| 512 |
mode++; |
| 513 |
} |
| 514 |
|
| 515 |
par->vbe_modes = kzalloc(sizeof(struct vbe_mode_ib) * |
| 516 |
par->vbe_modes_cnt, GFP_KERNEL); |
| 517 |
if (!par->vbe_modes) |
| 518 |
return -ENOMEM; |
| 519 |
|
| 520 |
/* Get info about all available modes. */ |
| 521 |
mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); |
| 522 |
while (*mode != 0xffff) { |
| 523 |
struct vbe_mode_ib *mib; |
| 524 |
|
| 525 |
uvesafb_reset(task); |
| 526 |
task->t.regs.eax = 0x4f01; |
| 527 |
task->t.regs.ecx = (u32) *mode; |
| 528 |
task->t.flags = TF_BUF_RET | TF_BUF_ESDI; |
| 529 |
task->t.buf_len = sizeof(struct vbe_mode_ib); |
| 530 |
task->buf = par->vbe_modes + off; |
| 531 |
|
| 532 |
err = uvesafb_exec(task); |
| 533 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) { |
| 534 |
printk(KERN_ERR "uvesafb: Getting mode info block " |
| 535 |
"for mode 0x%x failed (eax=0x%x, err=%d)\n", |
| 536 |
*mode, (u32)task->t.regs.eax, err); |
| 537 |
return -EINVAL; |
| 538 |
} |
| 539 |
|
| 540 |
mib = task->buf; |
| 541 |
mib->mode_id = *mode; |
| 542 |
|
| 543 |
/* |
| 544 |
* We only want modes that are supported with the current |
| 545 |
* hardware configuration, color, graphics and that have |
| 546 |
* support for the LFB. |
| 547 |
*/ |
| 548 |
if ((mib->mode_attr & VBE_MODE_MASK) == VBE_MODE_MASK && |
| 549 |
mib->bits_per_pixel >= 8) |
| 550 |
off++; |
| 551 |
else |
| 552 |
par->vbe_modes_cnt--; |
| 553 |
|
| 554 |
mode++; |
| 555 |
mib->depth = mib->red_len + mib->green_len + mib->blue_len; |
| 556 |
|
| 557 |
/* |
| 558 |
* Handle 8bpp modes and modes with broken color component |
| 559 |
* lengths. |
| 560 |
*/ |
| 561 |
if (mib->depth == 0 || (mib->depth == 24 && |
| 562 |
mib->bits_per_pixel == 32)) |
| 563 |
mib->depth = mib->bits_per_pixel; |
| 564 |
} |
| 565 |
|
| 566 |
return 0; |
| 567 |
} |
| 568 |
|
| 569 |
/* |
| 570 |
* The Protected Mode Interface is 32-bit x86 code, so we only run it on |
| 571 |
* x86 and not x86_64. |
| 572 |
*/ |
| 573 |
#ifdef CONFIG_X86_32 |
| 574 |
static int __devinit uvesafb_vbe_getpmi(struct uvesafb_ktask *task, |
| 575 |
struct uvesafb_par *par) |
| 576 |
{ |
| 577 |
int i, err; |
| 578 |
|
| 579 |
uvesafb_reset(task); |
| 580 |
task->t.regs.eax = 0x4f0a; |
| 581 |
task->t.regs.ebx = 0x0; |
| 582 |
err = uvesafb_exec(task); |
| 583 |
|
| 584 |
if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) { |
| 585 |
par->pmi_setpal = par->ypan = 0; |
| 586 |
} else { |
| 587 |
par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4) |
| 588 |
+ task->t.regs.edi); |
| 589 |
par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1]; |
| 590 |
par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2]; |
| 591 |
printk(KERN_INFO "uvesafb: protected mode interface info at " |
| 592 |
"%04x:%04x\n", |
| 593 |
(u16)task->t.regs.es, (u16)task->t.regs.edi); |
| 594 |
printk(KERN_INFO "uvesafb: pmi: set display start = %p, " |
| 595 |
"set palette = %p\n", par->pmi_start, |
| 596 |
par->pmi_pal); |
| 597 |
|
| 598 |
if (par->pmi_base[3]) { |
| 599 |
printk(KERN_INFO "uvesafb: pmi: ports = "); |
| 600 |
for (i = par->pmi_base[3]/2; |
| 601 |
par->pmi_base[i] != 0xffff; i++) |
| 602 |
printk("%x ", par->pmi_base[i]); |
| 603 |
printk("\n"); |
| 604 |
|
| 605 |
if (par->pmi_base[i] != 0xffff) { |
| 606 |
printk(KERN_INFO "uvesafb: can't handle memory" |
| 607 |
" requests, pmi disabled\n"); |
| 608 |
par->ypan = par->pmi_setpal = 0; |
| 609 |
} |
| 610 |
} |
| 611 |
} |
| 612 |
return 0; |
| 613 |
} |
| 614 |
#endif /* CONFIG_X86_32 */ |
| 615 |
|
| 616 |
/* |
| 617 |
* Check whether a video mode is supported by the Video BIOS and is |
| 618 |
* compatible with the monitor limits. |
| 619 |
*/ |
| 620 |
static int __devinit uvesafb_is_valid_mode(struct fb_videomode *mode, |
| 621 |
struct fb_info *info) |
| 622 |
{ |
| 623 |
if (info->monspecs.gtf) { |
| 624 |
fb_videomode_to_var(&info->var, mode); |
| 625 |
if (fb_validate_mode(&info->var, info)) |
| 626 |
return 0; |
| 627 |
} |
| 628 |
|
| 629 |
if (uvesafb_vbe_find_mode(info->par, mode->xres, mode->yres, 8, |
| 630 |
UVESAFB_EXACT_RES) == -1) |
| 631 |
return 0; |
| 632 |
|
| 633 |
return 1; |
| 634 |
} |
| 635 |
|
| 636 |
static int __devinit uvesafb_vbe_getedid(struct uvesafb_ktask *task, |
| 637 |
struct fb_info *info) |
| 638 |
{ |
| 639 |
struct uvesafb_par *par = info->par; |
| 640 |
int err = 0; |
| 641 |
|
| 642 |
if (noedid || par->vbe_ib.vbe_version < 0x0300) |
| 643 |
return -EINVAL; |
| 644 |
|
| 645 |
task->t.regs.eax = 0x4f15; |
| 646 |
task->t.regs.ebx = 0; |
| 647 |
task->t.regs.ecx = 0; |
| 648 |
task->t.buf_len = 0; |
| 649 |
task->t.flags = 0; |
| 650 |
|
| 651 |
err = uvesafb_exec(task); |
| 652 |
|
| 653 |
if ((task->t.regs.eax & 0xffff) != 0x004f || err) |
| 654 |
return -EINVAL; |
| 655 |
|
| 656 |
if ((task->t.regs.ebx & 0x3) == 3) { |
| 657 |
printk(KERN_INFO "uvesafb: VBIOS/hardware supports both " |
| 658 |
"DDC1 and DDC2 transfers\n"); |
| 659 |
} else if ((task->t.regs.ebx & 0x3) == 2) { |
| 660 |
printk(KERN_INFO "uvesafb: VBIOS/hardware supports DDC2 " |
| 661 |
"transfers\n"); |
| 662 |
} else if ((task->t.regs.ebx & 0x3) == 1) { |
| 663 |
printk(KERN_INFO "uvesafb: VBIOS/hardware supports DDC1 " |
| 664 |
"transfers\n"); |
| 665 |
} else { |
| 666 |
printk(KERN_INFO "uvesafb: VBIOS/hardware doesn't support " |
| 667 |
"DDC transfers\n"); |
| 668 |
return -EINVAL; |
| 669 |
} |
| 670 |
|
| 671 |
task->t.regs.eax = 0x4f15; |
| 672 |
task->t.regs.ebx = 1; |
| 673 |
task->t.regs.ecx = task->t.regs.edx = 0; |
| 674 |
task->t.flags = TF_BUF_RET | TF_BUF_ESDI; |
| 675 |
task->t.buf_len = EDID_LENGTH; |
| 676 |
task->buf = kzalloc(EDID_LENGTH, GFP_KERNEL); |
| 677 |
|
| 678 |
err = uvesafb_exec(task); |
| 679 |
|
| 680 |
if ((task->t.regs.eax & 0xffff) == 0x004f && !err) { |
| 681 |
fb_edid_to_monspecs(task->buf, &info->monspecs); |
| 682 |
|
| 683 |
if (info->monspecs.vfmax && info->monspecs.hfmax) { |
| 684 |
/* |
| 685 |
* If the maximum pixel clock wasn't specified in |
| 686 |
* the EDID block, set it to 300 MHz. |
| 687 |
*/ |
| 688 |
if (info->monspecs.dclkmax == 0) |
| 689 |
info->monspecs.dclkmax = 300 * 1000000; |
| 690 |
info->monspecs.gtf = 1; |
| 691 |
} |
| 692 |
} else { |
| 693 |
err = -EINVAL; |
| 694 |
} |
| 695 |
|
| 696 |
kfree(task->buf); |
| 697 |
return err; |
| 698 |
} |
| 699 |
|
| 700 |
static void __devinit uvesafb_vbe_getmonspecs(struct uvesafb_ktask *task, |
| 701 |
struct fb_info *info) |
| 702 |
{ |
| 703 |
struct uvesafb_par *par = info->par; |
| 704 |
int i; |
| 705 |
|
| 706 |
memset(&info->monspecs, 0, sizeof(info->monspecs)); |
| 707 |
|
| 708 |
/* |
| 709 |
* If we don't get all necessary data from the EDID block, |
| 710 |
* mark it as incompatible with the GTF and set nocrtc so |
| 711 |
* that we always use the default BIOS refresh rate. |
| 712 |
*/ |
| 713 |
if (uvesafb_vbe_getedid(task, info)) { |
| 714 |
info->monspecs.gtf = 0; |
| 715 |
par->nocrtc = 1; |
| 716 |
} |
| 717 |
|
| 718 |
/* Kernel command line overrides. */ |
| 719 |
if (maxclk) |
| 720 |
info->monspecs.dclkmax = maxclk * 1000000; |
| 721 |
if (maxvf) |
| 722 |
info->monspecs.vfmax = maxvf; |
| 723 |
if (maxhf) |
| 724 |
info->monspecs.hfmax = maxhf * 1000; |
| 725 |
|
| 726 |
/* |
| 727 |
* In case DDC transfers are not supported, the user can provide |
| 728 |
* monitor limits manually. Lower limits are set to "safe" values. |
| 729 |
*/ |
| 730 |
if (info->monspecs.gtf == 0 && maxclk && maxvf && maxhf) { |
| 731 |
info->monspecs.dclkmin = 0; |
| 732 |
info->monspecs.vfmin = 60; |
| 733 |
info->monspecs.hfmin = 29000; |
| 734 |
info->monspecs.gtf = 1; |
| 735 |
par->nocrtc = 0; |
| 736 |
} |
| 737 |
|
| 738 |
if (info->monspecs.gtf) |
| 739 |
printk(KERN_INFO |
| 740 |
"uvesafb: monitor limits: vf = %d Hz, hf = %d kHz, " |
| 741 |
"clk = %d MHz\n", info->monspecs.vfmax, |
| 742 |
(int)(info->monspecs.hfmax / 1000), |
| 743 |
(int)(info->monspecs.dclkmax / 1000000)); |
| 744 |
else |
| 745 |
printk(KERN_INFO "uvesafb: no monitor limits have been set, " |
| 746 |
"default refresh rate will be used\n"); |
| 747 |
|
| 748 |
/* Add VBE modes to the modelist. */ |
| 749 |
for (i = 0; i < par->vbe_modes_cnt; i++) { |
| 750 |
struct fb_var_screeninfo var; |
| 751 |
struct vbe_mode_ib *mode; |
| 752 |
struct fb_videomode vmode; |
| 753 |
|
| 754 |
mode = &par->vbe_modes[i]; |
| 755 |
memset(&var, 0, sizeof(var)); |
| 756 |
|
| 757 |
var.xres = mode->x_res; |
| 758 |
var.yres = mode->y_res; |
| 759 |
|
| 760 |
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, &var, info); |
| 761 |
fb_var_to_videomode(&vmode, &var); |
| 762 |
fb_add_videomode(&vmode, &info->modelist); |
| 763 |
} |
| 764 |
|
| 765 |
/* Add valid VESA modes to our modelist. */ |
| 766 |
for (i = 0; i < VESA_MODEDB_SIZE; i++) { |
| 767 |
if (uvesafb_is_valid_mode((struct fb_videomode *) |
| 768 |
&vesa_modes[i], info)) |
| 769 |
fb_add_videomode(&vesa_modes[i], &info->modelist); |
| 770 |
} |
| 771 |
|
| 772 |
for (i = 0; i < info->monspecs.modedb_len; i++) { |
| 773 |
if (uvesafb_is_valid_mode(&info->monspecs.modedb[i], info)) |
| 774 |
fb_add_videomode(&info->monspecs.modedb[i], |
| 775 |
&info->modelist); |
| 776 |
} |
| 777 |
|
| 778 |
return; |
| 779 |
} |
| 780 |
|
| 781 |
static void __devinit uvesafb_vbe_getstatesize(struct uvesafb_ktask *task, |
| 782 |
struct uvesafb_par *par) |
| 783 |
{ |
| 784 |
int err; |
| 785 |
|
| 786 |
uvesafb_reset(task); |
| 787 |
|
| 788 |
/* |
| 789 |
* Get the VBE state buffer size. We want all available |
| 790 |
* hardware state data (CL = 0x0f). |
| 791 |
*/ |
| 792 |
task->t.regs.eax = 0x4f04; |
| 793 |
task->t.regs.ecx = 0x000f; |
| 794 |
task->t.regs.edx = 0x0000; |
| 795 |
task->t.flags = 0; |
| 796 |
|
| 797 |
err = uvesafb_exec(task); |
| 798 |
|
| 799 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) { |
| 800 |
printk(KERN_WARNING "uvesafb: VBE state buffer size " |
| 801 |
"cannot be determined (eax=0x%x, err=%d)\n", |
| 802 |
task->t.regs.eax, err); |
| 803 |
par->vbe_state_size = 0; |
| 804 |
return; |
| 805 |
} |
| 806 |
|
| 807 |
par->vbe_state_size = 64 * (task->t.regs.ebx & 0xffff); |
| 808 |
} |
| 809 |
|
| 810 |
static int __devinit uvesafb_vbe_init(struct fb_info *info) |
| 811 |
{ |
| 812 |
struct uvesafb_ktask *task = NULL; |
| 813 |
struct uvesafb_par *par = info->par; |
| 814 |
int err; |
| 815 |
|
| 816 |
task = uvesafb_prep(); |
| 817 |
if (!task) |
| 818 |
return -ENOMEM; |
| 819 |
|
| 820 |
err = uvesafb_vbe_getinfo(task, par); |
| 821 |
if (err) |
| 822 |
goto out; |
| 823 |
|
| 824 |
err = uvesafb_vbe_getmodes(task, par); |
| 825 |
if (err) |
| 826 |
goto out; |
| 827 |
|
| 828 |
par->nocrtc = nocrtc; |
| 829 |
#ifdef CONFIG_X86_32 |
| 830 |
par->pmi_setpal = pmi_setpal; |
| 831 |
par->ypan = ypan; |
| 832 |
|
| 833 |
if (par->pmi_setpal || par->ypan) |
| 834 |
uvesafb_vbe_getpmi(task, par); |
| 835 |
#else |
| 836 |
/* The protected mode interface is not available on non-x86. */ |
| 837 |
par->pmi_setpal = par->ypan = 0; |
| 838 |
#endif |
| 839 |
|
| 840 |
INIT_LIST_HEAD(&info->modelist); |
| 841 |
uvesafb_vbe_getmonspecs(task, info); |
| 842 |
uvesafb_vbe_getstatesize(task, par); |
| 843 |
|
| 844 |
out: uvesafb_free(task); |
| 845 |
return err; |
| 846 |
} |
| 847 |
|
| 848 |
static int __devinit uvesafb_vbe_init_mode(struct fb_info *info) |
| 849 |
{ |
| 850 |
struct list_head *pos; |
| 851 |
struct fb_modelist *modelist; |
| 852 |
struct fb_videomode *mode; |
| 853 |
struct uvesafb_par *par = info->par; |
| 854 |
int i, modeid; |
| 855 |
|
| 856 |
/* Has the user requested a specific VESA mode? */ |
| 857 |
if (vbemode) { |
| 858 |
for (i = 0; i < par->vbe_modes_cnt; i++) { |
| 859 |
if (par->vbe_modes[i].mode_id == vbemode) { |
| 860 |
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, |
| 861 |
&info->var, info); |
| 862 |
/* |
| 863 |
* With pixclock set to 0, the default BIOS |
| 864 |
* timings will be used in set_par(). |
| 865 |
*/ |
| 866 |
info->var.pixclock = 0; |
| 867 |
modeid = i; |
| 868 |
goto gotmode; |
| 869 |
} |
| 870 |
} |
| 871 |
printk(KERN_INFO "uvesafb: requested VBE mode 0x%x is " |
| 872 |
"unavailable\n", vbemode); |
| 873 |
vbemode = 0; |
| 874 |
} |
| 875 |
|
| 876 |
/* Count the modes in the modelist */ |
| 877 |
i = 0; |
| 878 |
list_for_each(pos, &info->modelist) |
| 879 |
i++; |
| 880 |
|
| 881 |
/* |
| 882 |
* Convert the modelist into a modedb so that we can use it with |
| 883 |
* fb_find_mode(). |
| 884 |
*/ |
| 885 |
mode = kzalloc(i * sizeof(*mode), GFP_KERNEL); |
| 886 |
if (mode) { |
| 887 |
i = 0; |
| 888 |
list_for_each(pos, &info->modelist) { |
| 889 |
modelist = list_entry(pos, struct fb_modelist, list); |
| 890 |
mode[i] = modelist->mode; |
| 891 |
i++; |
| 892 |
} |
| 893 |
|
| 894 |
if (!mode_option) |
| 895 |
mode_option = UVESAFB_DEFAULT_MODE; |
| 896 |
|
| 897 |
i = fb_find_mode(&info->var, info, mode_option, mode, i, |
| 898 |
NULL, 8); |
| 899 |
|
| 900 |
kfree(mode); |
| 901 |
} |
| 902 |
|
| 903 |
/* fb_find_mode() failed */ |
| 904 |
if (i == 0 || i >= 3) { |
| 905 |
info->var.xres = 640; |
| 906 |
info->var.yres = 480; |
| 907 |
mode = (struct fb_videomode *) |
| 908 |
fb_find_best_mode(&info->var, &info->modelist); |
| 909 |
|
| 910 |
if (mode) { |
| 911 |
fb_videomode_to_var(&info->var, mode); |
| 912 |
} else { |
| 913 |
modeid = par->vbe_modes[0].mode_id; |
| 914 |
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, |
| 915 |
&info->var, info); |
| 916 |
goto gotmode; |
| 917 |
} |
| 918 |
} |
| 919 |
|
| 920 |
/* Look for a matching VBE mode. */ |
| 921 |
modeid = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, |
| 922 |
info->var.bits_per_pixel, UVESAFB_EXACT_RES); |
| 923 |
|
| 924 |
if (modeid == -1) |
| 925 |
return -EINVAL; |
| 926 |
|
| 927 |
gotmode: |
| 928 |
uvesafb_setup_var(&info->var, info, &par->vbe_modes[modeid]); |
| 929 |
|
| 930 |
/* |
| 931 |
* If we are not VBE3.0+ compliant, we're done -- the BIOS will |
| 932 |
* ignore our timings anyway. |
| 933 |
*/ |
| 934 |
if (par->vbe_ib.vbe_version < 0x0300 || par->nocrtc) |
| 935 |
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, |
| 936 |
&info->var, info); |
| 937 |
|
| 938 |
return modeid; |
| 939 |
} |
| 940 |
|
| 941 |
static int uvesafb_setpalette(struct uvesafb_pal_entry *entries, int count, |
| 942 |
int start, struct fb_info *info) |
| 943 |
{ |
| 944 |
struct uvesafb_ktask *task; |
| 945 |
struct uvesafb_par *par = info->par; |
| 946 |
int i = par->mode_idx; |
| 947 |
int err = 0; |
| 948 |
|
| 949 |
/* |
| 950 |
* We support palette modifications for 8 bpp modes only, so |
| 951 |
* there can never be more than 256 entries. |
| 952 |
*/ |
| 953 |
if (start + count > 256) |
| 954 |
return -EINVAL; |
| 955 |
|
| 956 |
/* Use VGA registers if mode is VGA-compatible. */ |
| 957 |
if (i >= 0 && i < par->vbe_modes_cnt && |
| 958 |
par->vbe_modes[i].mode_attr & VBE_MODE_VGACOMPAT) { |
| 959 |
for (i = 0; i < count; i++) { |
| 960 |
outb_p(start + i, dac_reg); |
| 961 |
outb_p(entries[i].red, dac_val); |
| 962 |
outb_p(entries[i].green, dac_val); |
| 963 |
outb_p(entries[i].blue, dac_val); |
| 964 |
} |
| 965 |
} |
| 966 |
#ifdef CONFIG_X86_32 |
| 967 |
else if (par->pmi_setpal) { |
| 968 |
__asm__ __volatile__( |
| 969 |
"call *(%%esi)" |
| 970 |
: /* no return value */ |
| 971 |
: "a" (0x4f09), /* EAX */ |
| 972 |
"b" (0), /* EBX */ |
| 973 |
"c" (count), /* ECX */ |
| 974 |
"d" (start), /* EDX */ |
| 975 |
"D" (entries), /* EDI */ |
| 976 |
"S" (&par->pmi_pal)); /* ESI */ |
| 977 |
} |
| 978 |
#endif |
| 979 |
else { |
| 980 |
task = uvesafb_prep(); |
| 981 |
if (!task) |
| 982 |
return -ENOMEM; |
| 983 |
|
| 984 |
task->t.regs.eax = 0x4f09; |
| 985 |
task->t.regs.ebx = 0x0; |
| 986 |
task->t.regs.ecx = count; |
| 987 |
task->t.regs.edx = start; |
| 988 |
task->t.flags = TF_BUF_ESDI; |
| 989 |
task->t.buf_len = sizeof(struct uvesafb_pal_entry) * count; |
| 990 |
task->buf = entries; |
| 991 |
|
| 992 |
err = uvesafb_exec(task); |
| 993 |
if ((task->t.regs.eax & 0xffff) != 0x004f) |
| 994 |
err = 1; |
| 995 |
|
| 996 |
uvesafb_free(task); |
| 997 |
} |
| 998 |
return err; |
| 999 |
} |
| 1000 |
|
| 1001 |
static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 1002 |
unsigned blue, unsigned transp, |
| 1003 |
struct fb_info *info) |
| 1004 |
{ |
| 1005 |
struct uvesafb_pal_entry entry; |
| 1006 |
int shift = 16 - info->var.green.length; |
| 1007 |
int err = 0; |
| 1008 |
|
| 1009 |
if (regno >= info->cmap.len) |
| 1010 |
return -EINVAL; |
| 1011 |
|
| 1012 |
if (info->var.bits_per_pixel == 8) { |
| 1013 |
entry.red = red >> shift; |
| 1014 |
entry.green = green >> shift; |
| 1015 |
entry.blue = blue >> shift; |
| 1016 |
entry.pad = 0; |
| 1017 |
|
| 1018 |
err = uvesafb_setpalette(&entry, 1, regno, info); |
| 1019 |
} else if (regno < 16) { |
| 1020 |
switch (info->var.bits_per_pixel) { |
| 1021 |
case 16: |
| 1022 |
if (info->var.red.offset == 10) { |
| 1023 |
/* 1:5:5:5 */ |
| 1024 |
((u32 *) (info->pseudo_palette))[regno] = |
| 1025 |
((red & 0xf800) >> 1) | |
| 1026 |
((green & 0xf800) >> 6) | |
| 1027 |
((blue & 0xf800) >> 11); |
| 1028 |
} else { |
| 1029 |
/* 0:5:6:5 */ |
| 1030 |
((u32 *) (info->pseudo_palette))[regno] = |
| 1031 |
((red & 0xf800) ) | |
| 1032 |
((green & 0xfc00) >> 5) | |
| 1033 |
((blue & 0xf800) >> 11); |
| 1034 |
} |
| 1035 |
break; |
| 1036 |
|
| 1037 |
case 24: |
| 1038 |
case 32: |
| 1039 |
red >>= 8; |
| 1040 |
green >>= 8; |
| 1041 |
blue >>= 8; |
| 1042 |
((u32 *)(info->pseudo_palette))[regno] = |
| 1043 |
(red << info->var.red.offset) | |
| 1044 |
(green << info->var.green.offset) | |
| 1045 |
(blue << info->var.blue.offset); |
| 1046 |
break; |
| 1047 |
} |
| 1048 |
} |
| 1049 |
return err; |
| 1050 |
} |
| 1051 |
|
| 1052 |
static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) |
| 1053 |
{ |
| 1054 |
struct uvesafb_pal_entry *entries; |
| 1055 |
int shift = 16 - info->var.green.length; |
| 1056 |
int i, err = 0; |
| 1057 |
|
| 1058 |
if (info->var.bits_per_pixel == 8) { |
| 1059 |
if (cmap->start + cmap->len > info->cmap.start + |
| 1060 |
info->cmap.len || cmap->start < info->cmap.start) |
| 1061 |
return -EINVAL; |
| 1062 |
|
| 1063 |
entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL); |
| 1064 |
if (!entries) |
| 1065 |
return -ENOMEM; |
| 1066 |
|
| 1067 |
for (i = 0; i < cmap->len; i++) { |
| 1068 |
entries[i].red = cmap->red[i] >> shift; |
| 1069 |
entries[i].green = cmap->green[i] >> shift; |
| 1070 |
entries[i].blue = cmap->blue[i] >> shift; |
| 1071 |
entries[i].pad = 0; |
| 1072 |
} |
| 1073 |
err = uvesafb_setpalette(entries, cmap->len, cmap->start, info); |
| 1074 |
kfree(entries); |
| 1075 |
} else { |
| 1076 |
/* |
| 1077 |
* For modes with bpp > 8, we only set the pseudo palette in |
| 1078 |
* the fb_info struct. We rely on uvesafb_setcolreg to do all |
| 1079 |
* sanity checking. |
| 1080 |
*/ |
| 1081 |
for (i = 0; i < cmap->len; i++) { |
| 1082 |
err |= uvesafb_setcolreg(cmap->start + i, cmap->red[i], |
| 1083 |
cmap->green[i], cmap->blue[i], |
| 1084 |
0, info); |
| 1085 |
} |
| 1086 |
} |
| 1087 |
return err; |
| 1088 |
} |
| 1089 |
|
| 1090 |
static int uvesafb_pan_display(struct fb_var_screeninfo *var, |
| 1091 |
struct fb_info *info) |
| 1092 |
{ |
| 1093 |
#ifdef CONFIG_X86_32 |
| 1094 |
int offset; |
| 1095 |
struct uvesafb_par *par = info->par; |
| 1096 |
|
| 1097 |
offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4; |
| 1098 |
|
| 1099 |
/* |
| 1100 |
* It turns out it's not the best idea to do panning via vm86, |
| 1101 |
* so we only allow it if we have a PMI. |
| 1102 |
*/ |
| 1103 |
if (par->pmi_start) { |
| 1104 |
__asm__ __volatile__( |
| 1105 |
"call *(%%edi)" |
| 1106 |
: /* no return value */ |
| 1107 |
: "a" (0x4f07), /* EAX */ |
| 1108 |
"b" (0), /* EBX */ |
| 1109 |
"c" (offset), /* ECX */ |
| 1110 |
"d" (offset >> 16), /* EDX */ |
| 1111 |
"D" (&par->pmi_start)); /* EDI */ |
| 1112 |
} |
| 1113 |
#endif |
| 1114 |
return 0; |
| 1115 |
} |
| 1116 |
|
| 1117 |
static int uvesafb_blank(int blank, struct fb_info *info) |
| 1118 |
{ |
| 1119 |
struct uvesafb_par *par = info->par; |
| 1120 |
struct uvesafb_ktask *task; |
| 1121 |
int err = 1; |
| 1122 |
|
| 1123 |
if (par->vbe_ib.capabilities & VBE_CAP_VGACOMPAT) { |
| 1124 |
int loop = 10000; |
| 1125 |
u8 seq = 0, crtc17 = 0; |
| 1126 |
|
| 1127 |
if (blank == FB_BLANK_POWERDOWN) { |
| 1128 |
seq = 0x20; |
| 1129 |
crtc17 = 0x00; |
| 1130 |
err = 0; |
| 1131 |
} else { |
| 1132 |
seq = 0x00; |
| 1133 |
crtc17 = 0x80; |
| 1134 |
err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL; |
| 1135 |
} |
| 1136 |
|
| 1137 |
vga_wseq(NULL, 0x00, 0x01); |
| 1138 |
seq |= vga_rseq(NULL, 0x01) & ~0x20; |
| 1139 |
vga_wseq(NULL, 0x00, seq); |
| 1140 |
|
| 1141 |
crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80; |
| 1142 |
while (loop--); |
| 1143 |
vga_wcrt(NULL, 0x17, crtc17); |
| 1144 |
vga_wseq(NULL, 0x00, 0x03); |
| 1145 |
} else { |
| 1146 |
task = uvesafb_prep(); |
| 1147 |
if (!task) |
| 1148 |
return -ENOMEM; |
| 1149 |
|
| 1150 |
task->t.regs.eax = 0x4f10; |
| 1151 |
switch (blank) { |
| 1152 |
case FB_BLANK_UNBLANK: |
| 1153 |
task->t.regs.ebx = 0x0001; |
| 1154 |
break; |
| 1155 |
case FB_BLANK_NORMAL: |
| 1156 |
task->t.regs.ebx = 0x0101; /* standby */ |
| 1157 |
break; |
| 1158 |
case FB_BLANK_POWERDOWN: |
| 1159 |
task->t.regs.ebx = 0x0401; /* powerdown */ |
| 1160 |
break; |
| 1161 |
default: |
| 1162 |
goto out; |
| 1163 |
} |
| 1164 |
|
| 1165 |
err = uvesafb_exec(task); |
| 1166 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) |
| 1167 |
err = 1; |
| 1168 |
out: uvesafb_free(task); |
| 1169 |
} |
| 1170 |
return err; |
| 1171 |
} |
| 1172 |
|
| 1173 |
static int uvesafb_open(struct fb_info *info, int user) |
| 1174 |
{ |
| 1175 |
struct uvesafb_par *par = info->par; |
| 1176 |
int cnt = atomic_read(&par->ref_count); |
| 1177 |
|
| 1178 |
if (!cnt && par->vbe_state_size) |
| 1179 |
par->vbe_state_orig = uvesafb_vbe_state_save(par); |
| 1180 |
|
| 1181 |
atomic_inc(&par->ref_count); |
| 1182 |
return 0; |
| 1183 |
} |
| 1184 |
|
| 1185 |
static int uvesafb_release(struct fb_info *info, int user) |
| 1186 |
{ |
| 1187 |
struct uvesafb_ktask *task = NULL; |
| 1188 |
struct uvesafb_par *par = info->par; |
| 1189 |
int cnt = atomic_read(&par->ref_count); |
| 1190 |
|
| 1191 |
if (!cnt) |
| 1192 |
return -EINVAL; |
| 1193 |
|
| 1194 |
if (cnt != 1) |
| 1195 |
goto out; |
| 1196 |
|
| 1197 |
task = uvesafb_prep(); |
| 1198 |
if (!task) |
| 1199 |
goto out; |
| 1200 |
|
| 1201 |
/* First, try to set the standard 80x25 text mode. */ |
| 1202 |
task->t.regs.eax = 0x0003; |
| 1203 |
uvesafb_exec(task); |
| 1204 |
|
| 1205 |
/* |
| 1206 |
* Now try to restore whatever hardware state we might have |
| 1207 |
* saved when the fb device was first opened. |
| 1208 |
*/ |
| 1209 |
uvesafb_vbe_state_restore(par, par->vbe_state_orig); |
| 1210 |
out: |
| 1211 |
atomic_dec(&par->ref_count); |
| 1212 |
if (task) |
| 1213 |
uvesafb_free(task); |
| 1214 |
return 0; |
| 1215 |
} |
| 1216 |
|
| 1217 |
static int uvesafb_set_par(struct fb_info *info) |
| 1218 |
{ |
| 1219 |
struct uvesafb_par *par = info->par; |
| 1220 |
struct uvesafb_ktask *task = NULL; |
| 1221 |
struct vbe_crtc_ib *crtc = NULL; |
| 1222 |
struct vbe_mode_ib *mode = NULL; |
| 1223 |
int i, err = 0, depth = info->var.bits_per_pixel; |
| 1224 |
|
| 1225 |
if (depth > 8 && depth != 32) |
| 1226 |
depth = info->var.red.length + info->var.green.length + |
| 1227 |
info->var.blue.length; |
| 1228 |
|
| 1229 |
i = uvesafb_vbe_find_mode(par, info->var.xres, info->var.yres, depth, |
| 1230 |
UVESAFB_EXACT_RES | UVESAFB_EXACT_DEPTH); |
| 1231 |
if (i >= 0) |
| 1232 |
mode = &par->vbe_modes[i]; |
| 1233 |
else |
| 1234 |
return -EINVAL; |
| 1235 |
|
| 1236 |
task = uvesafb_prep(); |
| 1237 |
if (!task) |
| 1238 |
return -ENOMEM; |
| 1239 |
setmode: |
| 1240 |
task->t.regs.eax = 0x4f02; |
| 1241 |
task->t.regs.ebx = mode->mode_id | 0x4000; /* use LFB */ |
| 1242 |
|
| 1243 |
if (par->vbe_ib.vbe_version >= 0x0300 && !par->nocrtc && |
| 1244 |
info->var.pixclock != 0) { |
| 1245 |
task->t.regs.ebx |= 0x0800; /* use CRTC data */ |
| 1246 |
task->t.flags = TF_BUF_ESDI; |
| 1247 |
crtc = kzalloc(sizeof(struct vbe_crtc_ib), GFP_KERNEL); |
| 1248 |
if (!crtc) { |
| 1249 |
err = -ENOMEM; |
| 1250 |
goto out; |
| 1251 |
} |
| 1252 |
crtc->horiz_start = info->var.xres + info->var.right_margin; |
| 1253 |
crtc->horiz_end = crtc->horiz_start + info->var.hsync_len; |
| 1254 |
crtc->horiz_total = crtc->horiz_end + info->var.left_margin; |
| 1255 |
|
| 1256 |
crtc->vert_start = info->var.yres + info->var.lower_margin; |
| 1257 |
crtc->vert_end = crtc->vert_start + info->var.vsync_len; |
| 1258 |
crtc->vert_total = crtc->vert_end + info->var.upper_margin; |
| 1259 |
|
| 1260 |
crtc->pixel_clock = PICOS2KHZ(info->var.pixclock) * 1000; |
| 1261 |
crtc->refresh_rate = (u16)(100 * (crtc->pixel_clock / |
| 1262 |
(crtc->vert_total * crtc->horiz_total))); |
| 1263 |
|
| 1264 |
if (info->var.vmode & FB_VMODE_DOUBLE) |
| 1265 |
crtc->flags |= 0x1; |
| 1266 |
if (info->var.vmode & FB_VMODE_INTERLACED) |
| 1267 |
crtc->flags |= 0x2; |
| 1268 |
if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) |
| 1269 |
crtc->flags |= 0x4; |
| 1270 |
if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) |
| 1271 |
crtc->flags |= 0x8; |
| 1272 |
memcpy(&par->crtc, crtc, sizeof(*crtc)); |
| 1273 |
} else { |
| 1274 |
memset(&par->crtc, 0, sizeof(*crtc)); |
| 1275 |
} |
| 1276 |
|
| 1277 |
task->t.buf_len = sizeof(struct vbe_crtc_ib); |
| 1278 |
task->buf = &par->crtc; |
| 1279 |
|
| 1280 |
err = uvesafb_exec(task); |
| 1281 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f) { |
| 1282 |
/* |
| 1283 |
* The mode switch might have failed because we tried to |
| 1284 |
* use our own timings. Try again with the default timings. |
| 1285 |
*/ |
| 1286 |
if (crtc != NULL) { |
| 1287 |
printk(KERN_WARNING "uvesafb: mode switch failed " |
| 1288 |
"(eax=0x%x, err=%d). Trying again with " |
| 1289 |
"default timings.\n", task->t.regs.eax, err); |
| 1290 |
uvesafb_reset(task); |
| 1291 |
kfree(crtc); |
| 1292 |
crtc = NULL; |
| 1293 |
info->var.pixclock = 0; |
| 1294 |
goto setmode; |
| 1295 |
} else { |
| 1296 |
printk(KERN_ERR "uvesafb: mode switch failed (eax=" |
| 1297 |
"0x%x, err=%d)\n", task->t.regs.eax, err); |
| 1298 |
err = -EINVAL; |
| 1299 |
goto out; |
| 1300 |
} |
| 1301 |
} |
| 1302 |
par->mode_idx = i; |
| 1303 |
|
| 1304 |
/* For 8bpp modes, always try to set the DAC to 8 bits. */ |
| 1305 |
if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC && |
| 1306 |
mode->bits_per_pixel <= 8) { |
| 1307 |
uvesafb_reset(task); |
| 1308 |
task->t.regs.eax = 0x4f08; |
| 1309 |
task->t.regs.ebx = 0x0800; |
| 1310 |
|
| 1311 |
err = uvesafb_exec(task); |
| 1312 |
if (err || (task->t.regs.eax & 0xffff) != 0x004f || |
| 1313 |
((task->t.regs.ebx & 0xff00) >> 8) != 8) { |
| 1314 |
/* |
| 1315 |
* We've failed to set the DAC palette format - |
| 1316 |
* time to correct var. |
| 1317 |
*/ |
| 1318 |
info->var.red.length = 6; |
| 1319 |
info->var.green.length = 6; |
| 1320 |
info->var.blue.length = 6; |
| 1321 |
} |
| 1322 |
} |
| 1323 |
|
| 1324 |
info->fix.visual = (info->var.bits_per_pixel == 8) ? |
| 1325 |
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
| 1326 |
info->fix.line_length = mode->bytes_per_scan_line; |
| 1327 |
|
| 1328 |
out: if (crtc != NULL) |
| 1329 |
kfree(crtc); |
| 1330 |
uvesafb_free(task); |
| 1331 |
|
| 1332 |
return err; |
| 1333 |
} |
| 1334 |
|
| 1335 |
static void uvesafb_check_limits(struct fb_var_screeninfo *var, |
| 1336 |
struct fb_info *info) |
| 1337 |
{ |
| 1338 |
const struct fb_videomode *mode; |
| 1339 |
struct uvesafb_par *par = info->par; |
| 1340 |
|
| 1341 |
/* |
| 1342 |
* If pixclock is set to 0, then we're using default BIOS timings |
| 1343 |
* and thus don't have to perform any checks here. |
| 1344 |
*/ |
| 1345 |
if (!var->pixclock) |
| 1346 |
return; |
| 1347 |
|
| 1348 |
if (par->vbe_ib.vbe_version < 0x0300) { |
| 1349 |
fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, var, info); |
| 1350 |
return; |
| 1351 |
} |
| 1352 |
|
| 1353 |
if (!fb_validate_mode(var, info)) |
| 1354 |
return; |
| 1355 |
|
| 1356 |
mode = fb_find_best_mode(var, &info->modelist); |
| 1357 |
if (mode) { |
| 1358 |
if (mode->xres == var->xres && mode->yres == var->yres && |
| 1359 |
!(mode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))) { |
| 1360 |
fb_videomode_to_var(var, mode); |
| 1361 |
return; |
| 1362 |
} |
| 1363 |
} |
| 1364 |
|
| 1365 |
if (info->monspecs.gtf && !fb_get_mode(FB_MAXTIMINGS, 0, var, info)) |
| 1366 |
return; |
| 1367 |
/* Use default refresh rate */ |
| 1368 |
var->pixclock = 0; |
| 1369 |
} |
| 1370 |
|
| 1371 |
static int uvesafb_check_var(struct fb_var_screeninfo *var, |
| 1372 |
struct fb_info *info) |
| 1373 |
{ |
| 1374 |
struct uvesafb_par *par = info->par; |
| 1375 |
struct vbe_mode_ib *mode = NULL; |
| 1376 |
int match = -1; |
| 1377 |
int depth = var->red.length + var->green.length + var->blue.length; |
| 1378 |
|
| 1379 |
/* |
| 1380 |
* Various apps will use bits_per_pixel to set the color depth, |
| 1381 |
* which is theoretically incorrect, but which we'll try to handle |
| 1382 |
* here. |
| 1383 |
*/ |
| 1384 |
if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8) |
| 1385 |
depth = var->bits_per_pixel; |
| 1386 |
|
| 1387 |
match = uvesafb_vbe_find_mode(par, var->xres, var->yres, depth, |
| 1388 |
UVESAFB_EXACT_RES); |
| 1389 |
if (match == -1) |
| 1390 |
return -EINVAL; |
| 1391 |
|
| 1392 |
mode = &par->vbe_modes[match]; |
| 1393 |
uvesafb_setup_var(var, info, mode); |
| 1394 |
|
| 1395 |
/* |
| 1396 |
* Check whether we have remapped enough memory for this mode. |
| 1397 |
* We might be called at an early stage, when we haven't remapped |
| 1398 |
* any memory yet, in which case we simply skip the check. |
| 1399 |
*/ |
| 1400 |
if (var->yres * mode->bytes_per_scan_line > info->fix.smem_len |
| 1401 |
&& info->fix.smem_len) |
| 1402 |
return -EINVAL; |
| 1403 |
|
| 1404 |
if ((var->vmode & FB_VMODE_DOUBLE) && |
| 1405 |
!(par->vbe_modes[match].mode_attr & 0x100)) |
| 1406 |
var->vmode &= ~FB_VMODE_DOUBLE; |
| 1407 |
|
| 1408 |
if ((var->vmode & FB_VMODE_INTERLACED) && |
| 1409 |
!(par->vbe_modes[match].mode_attr & 0x200)) |
| 1410 |
var->vmode &= ~FB_VMODE_INTERLACED; |
| 1411 |
|
| 1412 |
uvesafb_check_limits(var, info); |
| 1413 |
|
| 1414 |
var->xres_virtual = var->xres; |
| 1415 |
var->yres_virtual = (par->ypan) ? |
| 1416 |
info->fix.smem_len / mode->bytes_per_scan_line : |
| 1417 |
var->yres; |
| 1418 |
return 0; |
| 1419 |
} |
| 1420 |
|
| 1421 |
static void uvesafb_save_state(struct fb_info *info) |
| 1422 |
{ |
| 1423 |
struct uvesafb_par *par = info->par; |
| 1424 |
|
| 1425 |
if (par->vbe_state_saved) |
| 1426 |
kfree(par->vbe_state_saved); |
| 1427 |
|
| 1428 |
par->vbe_state_saved = uvesafb_vbe_state_save(par); |
| 1429 |
} |
| 1430 |
|
| 1431 |
static void uvesafb_restore_state(struct fb_info *info) |
| 1432 |
{ |
| 1433 |
struct uvesafb_par *par = info->par; |
| 1434 |
|
| 1435 |
uvesafb_vbe_state_restore(par, par->vbe_state_saved); |
| 1436 |
} |
| 1437 |
|
| 1438 |
static struct fb_ops uvesafb_ops = { |
| 1439 |
.owner = THIS_MODULE, |
| 1440 |
.fb_open = uvesafb_open, |
| 1441 |
.fb_release = uvesafb_release, |
| 1442 |
.fb_setcolreg = uvesafb_setcolreg, |
| 1443 |
.fb_setcmap = uvesafb_setcmap, |
| 1444 |
.fb_pan_display = uvesafb_pan_display, |
| 1445 |
.fb_blank = uvesafb_blank, |
| 1446 |
.fb_fillrect = cfb_fillrect, |
| 1447 |
.fb_copyarea = cfb_copyarea, |
| 1448 |
.fb_imageblit = cfb_imageblit, |
| 1449 |
.fb_check_var = uvesafb_check_var, |
| 1450 |
.fb_set_par = uvesafb_set_par, |
| 1451 |
.fb_save_state = uvesafb_save_state, |
| 1452 |
.fb_restore_state = uvesafb_restore_state, |
| 1453 |
}; |
| 1454 |
|
| 1455 |
static void __devinit uvesafb_init_info(struct fb_info *info, |
| 1456 |
struct vbe_mode_ib *mode) |
| 1457 |
{ |
| 1458 |
unsigned int size_vmode; |
| 1459 |
unsigned int size_remap; |
| 1460 |
unsigned int size_total; |
| 1461 |
struct uvesafb_par *par = info->par; |
| 1462 |
int i, h; |
| 1463 |
|
| 1464 |
info->pseudo_palette = ((u8 *)info->par + sizeof(struct uvesafb_par)); |
| 1465 |
info->fix = uvesafb_fix; |
| 1466 |
info->fix.ypanstep = par->ypan ? 1 : 0; |
| 1467 |
info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0; |
| 1468 |
|
| 1469 |
/* |
| 1470 |
* If we were unable to get the state buffer size, disable |
| 1471 |
* functions for saving and restoring the hardware state. |
| 1472 |
*/ |
| 1473 |
if (par->vbe_state_size == 0) { |
| 1474 |
info->fbops->fb_save_state = NULL; |
| 1475 |
info->fbops->fb_restore_state = NULL; |
| 1476 |
} |
| 1477 |
|
| 1478 |
/* Disable blanking if the user requested so. */ |
| 1479 |
if (!blank) |
| 1480 |
info->fbops->fb_blank = NULL; |
| 1481 |
|
| 1482 |
/* |
| 1483 |
* Find out how much IO memory is required for the mode with |
| 1484 |
* the highest resolution. |
| 1485 |
*/ |
| 1486 |
size_remap = 0; |
| 1487 |
for (i = 0; i < par->vbe_modes_cnt; i++) { |
| 1488 |
h = par->vbe_modes[i].bytes_per_scan_line * |
| 1489 |
par->vbe_modes[i].y_res; |
| 1490 |
if (h > size_remap) |
| 1491 |
size_remap = h; |
| 1492 |
} |
| 1493 |
size_remap *= 2; |
| 1494 |
|
| 1495 |
/* |
| 1496 |
* size_vmode -- that is the amount of memory needed for the |
| 1497 |
* used video mode, i.e. the minimum amount of |
| 1498 |
* memory we need. |
| 1499 |
*/ |
| 1500 |
if (mode != NULL) { |
| 1501 |
size_vmode = info->var.yres * mode->bytes_per_scan_line; |
| 1502 |
} else { |
| 1503 |
size_vmode = info->var.yres * info->var.xres * |
| 1504 |
((info->var.bits_per_pixel + 7) >> 3); |
| 1505 |
} |
| 1506 |
|
| 1507 |
/* |
| 1508 |
* size_total -- all video memory we have. Used for mtrr |
| 1509 |
* entries, resource allocation and bounds |
| 1510 |
* checking. |
| 1511 |
*/ |
| 1512 |
size_total = par->vbe_ib.total_memory * 65536; |
| 1513 |
if (vram_total) |
| 1514 |
size_total = vram_total * 1024 * 1024; |
| 1515 |
if (size_total < size_vmode) |
| 1516 |
size_total = size_vmode; |
| 1517 |
|
| 1518 |
/* |
| 1519 |
* size_remap -- the amount of video memory we are going to |
| 1520 |
* use for vesafb. With modern cards it is no |
| 1521 |
* option to simply use size_total as th |
| 1522 |
* wastes plenty of kernel address space. |
| 1523 |
*/ |
| 1524 |
if (vram_remap) |
| 1525 |
size_remap = vram_remap * 1024 * 1024; |
| 1526 |
if (size_remap < size_vmode) |
| 1527 |
size_remap = size_vmode; |
| 1528 |
if (size_remap > size_total) |
| 1529 |
size_remap = size_total; |
| 1530 |
|
| 1531 |
info->fix.smem_len = size_remap; |
| 1532 |
info->fix.smem_start = mode->phys_base_ptr; |
| 1533 |
|
| 1534 |
/* |
| 1535 |
* We have to set yres_virtual here because when setup_var() was |
| 1536 |
* called, smem_len wasn't defined yet. |
| 1537 |
*/ |
| 1538 |
info->var.yres_virtual = info->fix.smem_len / |
| 1539 |
mode->bytes_per_scan_line; |
| 1540 |
|
| 1541 |
if (par->ypan && info->var.yres_virtual > info->var.yres) { |
| 1542 |
printk(KERN_INFO "uvesafb: scrolling: %s " |
| 1543 |
"using protected mode interface, " |
| 1544 |
"yres_virtual=%d\n", |
| 1545 |
(par->ypan > 1) ? "ywrap" : "ypan", |
| 1546 |
info->var.yres_virtual); |
| 1547 |
} else { |
| 1548 |
printk(KERN_INFO "uvesafb: scrolling: redraw\n"); |
| 1549 |
info->var.yres_virtual = info->var.yres; |
| 1550 |
par->ypan = 0; |
| 1551 |
} |
| 1552 |
|
| 1553 |
info->flags = FBINFO_FLAG_DEFAULT | |
| 1554 |
(par->ypan) ? FBINFO_HWACCEL_YPAN : 0; |
| 1555 |
|
| 1556 |
if (!par->ypan) |
| 1557 |
info->fbops->fb_pan_display = NULL; |
| 1558 |
} |
| 1559 |
|
| 1560 |
static void uvesafb_init_mtrr(struct fb_info *info) |
| 1561 |
{ |
| 1562 |
#ifdef CONFIG_MTRR |
| 1563 |
if (mtrr && !(info->fix.smem_start & (PAGE_SIZE - 1))) { |
| 1564 |
int temp_size = info->fix.smem_len; |
| 1565 |
unsigned int type = 0; |
| 1566 |
|
| 1567 |
switch (mtrr) { |
| 1568 |
case 1: |
| 1569 |
type = MTRR_TYPE_UNCACHABLE; |
| 1570 |
break; |
| 1571 |
case 2: |
| 1572 |
type = MTRR_TYPE_WRBACK; |
| 1573 |
break; |
| 1574 |
case 3: |
| 1575 |
type = MTRR_TYPE_WRCOMB; |
| 1576 |
break; |
| 1577 |
case 4: |
| 1578 |
type = MTRR_TYPE_WRTHROUGH; |
| 1579 |
break; |
| 1580 |
default: |
| 1581 |
type = 0; |
| 1582 |
break; |
| 1583 |
} |
| 1584 |
|
| 1585 |
if (type) { |
| 1586 |
int rc; |
| 1587 |
|
| 1588 |
/* Find the largest power-of-two */ |
| 1589 |
while (temp_size & (temp_size - 1)) |
| 1590 |
temp_size &= (temp_size - 1); |
| 1591 |
|
| 1592 |
/* Try and find a power of two to add */ |
| 1593 |
do { |
| 1594 |
rc = mtrr_add(info->fix.smem_start, |
| 1595 |
temp_size, type, 1); |
| 1596 |
temp_size >>= 1; |
| 1597 |
} while (temp_size >= PAGE_SIZE && rc == -EINVAL); |
| 1598 |
} |
| 1599 |
} |
| 1600 |
#endif /* CONFIG_MTRR */ |
| 1601 |
} |
| 1602 |
|
| 1603 |
|
| 1604 |
static ssize_t uvesafb_show_vbe_ver(struct device *dev, |
| 1605 |
struct device_attribute *attr, char *buf) |
| 1606 |
{ |
| 1607 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1608 |
struct uvesafb_par *par = info->par; |
| 1609 |
|
| 1610 |
return snprintf(buf, PAGE_SIZE, "%.4x\n", par->vbe_ib.vbe_version); |
| 1611 |
} |
| 1612 |
|
| 1613 |
static DEVICE_ATTR(vbe_version, S_IRUGO, uvesafb_show_vbe_ver, NULL); |
| 1614 |
|
| 1615 |
static ssize_t uvesafb_show_vbe_modes(struct device *dev, |
| 1616 |
struct device_attribute *attr, char *buf) |
| 1617 |
{ |
| 1618 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1619 |
struct uvesafb_par *par = info->par; |
| 1620 |
int ret = 0, i; |
| 1621 |
|
| 1622 |
for (i = 0; i < par->vbe_modes_cnt && ret < PAGE_SIZE; i++) { |
| 1623 |
ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 1624 |
"%dx%d-%d, 0x%.4x\n", |
| 1625 |
par->vbe_modes[i].x_res, par->vbe_modes[i].y_res, |
| 1626 |
par->vbe_modes[i].depth, par->vbe_modes[i].mode_id); |
| 1627 |
} |
| 1628 |
|
| 1629 |
return ret; |
| 1630 |
} |
| 1631 |
|
| 1632 |
static DEVICE_ATTR(vbe_modes, S_IRUGO, uvesafb_show_vbe_modes, NULL); |
| 1633 |
|
| 1634 |
static ssize_t uvesafb_show_vendor(struct device *dev, |
| 1635 |
struct device_attribute *attr, char *buf) |
| 1636 |
{ |
| 1637 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1638 |
struct uvesafb_par *par = info->par; |
| 1639 |
|
| 1640 |
if (par->vbe_ib.oem_vendor_name_ptr) |
| 1641 |
return snprintf(buf, PAGE_SIZE, "%s\n", (char *) |
| 1642 |
(&par->vbe_ib) + par->vbe_ib.oem_vendor_name_ptr); |
| 1643 |
else |
| 1644 |
return 0; |
| 1645 |
} |
| 1646 |
|
| 1647 |
static DEVICE_ATTR(oem_vendor, S_IRUGO, uvesafb_show_vendor, NULL); |
| 1648 |
|
| 1649 |
static ssize_t uvesafb_show_product_name(struct device *dev, |
| 1650 |
struct device_attribute *attr, char *buf) |
| 1651 |
{ |
| 1652 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1653 |
struct uvesafb_par *par = info->par; |
| 1654 |
|
| 1655 |
if (par->vbe_ib.oem_product_name_ptr) |
| 1656 |
return snprintf(buf, PAGE_SIZE, "%s\n", (char *) |
| 1657 |
(&par->vbe_ib) + par->vbe_ib.oem_product_name_ptr); |
| 1658 |
else |
| 1659 |
return 0; |
| 1660 |
} |
| 1661 |
|
| 1662 |
static DEVICE_ATTR(oem_product_name, S_IRUGO, uvesafb_show_product_name, NULL); |
| 1663 |
|
| 1664 |
static ssize_t uvesafb_show_product_rev(struct device *dev, |
| 1665 |
struct device_attribute *attr, char *buf) |
| 1666 |
{ |
| 1667 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1668 |
struct uvesafb_par *par = info->par; |
| 1669 |
|
| 1670 |
if (par->vbe_ib.oem_product_rev_ptr) |
| 1671 |
return snprintf(buf, PAGE_SIZE, "%s\n", (char *) |
| 1672 |
(&par->vbe_ib) + par->vbe_ib.oem_product_rev_ptr); |
| 1673 |
else |
| 1674 |
return 0; |
| 1675 |
} |
| 1676 |
|
| 1677 |
static DEVICE_ATTR(oem_product_rev, S_IRUGO, uvesafb_show_product_rev, NULL); |
| 1678 |
|
| 1679 |
static ssize_t uvesafb_show_oem_string(struct device *dev, |
| 1680 |
struct device_attribute *attr, char *buf) |
| 1681 |
{ |
| 1682 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1683 |
struct uvesafb_par *par = info->par; |
| 1684 |
|
| 1685 |
if (par->vbe_ib.oem_string_ptr) |
| 1686 |
return snprintf(buf, PAGE_SIZE, "%s\n", |
| 1687 |
(char *)(&par->vbe_ib) + par->vbe_ib.oem_string_ptr); |
| 1688 |
else |
| 1689 |
return 0; |
| 1690 |
} |
| 1691 |
|
| 1692 |
static DEVICE_ATTR(oem_string, S_IRUGO, uvesafb_show_oem_string, NULL); |
| 1693 |
|
| 1694 |
static ssize_t uvesafb_show_nocrtc(struct device *dev, |
| 1695 |
struct device_attribute *attr, char *buf) |
| 1696 |
{ |
| 1697 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1698 |
struct uvesafb_par *par = info->par; |
| 1699 |
|
| 1700 |
return snprintf(buf, PAGE_SIZE, "%d\n", par->nocrtc); |
| 1701 |
} |
| 1702 |
|
| 1703 |
static ssize_t uvesafb_store_nocrtc(struct device *dev, |
| 1704 |
struct device_attribute *attr, const char *buf, size_t count) |
| 1705 |
{ |
| 1706 |
struct fb_info *info = platform_get_drvdata(to_platform_device(dev)); |
| 1707 |
struct uvesafb_par *par = info->par; |
| 1708 |
|
| 1709 |
if (count > 0) { |
| 1710 |
if (buf[0] == '0') |
| 1711 |
par->nocrtc = 0; |
| 1712 |
else |
| 1713 |
par->nocrtc = 1; |
| 1714 |
} |
| 1715 |
return count; |
| 1716 |
} |
| 1717 |
|
| 1718 |
static DEVICE_ATTR(nocrtc, S_IRUGO | S_IWUSR, uvesafb_show_nocrtc, |
| 1719 |
uvesafb_store_nocrtc); |
| 1720 |
|
| 1721 |
static struct attribute *uvesafb_dev_attrs[] = { |
| 1722 |
&dev_attr_vbe_version.attr, |
| 1723 |
&dev_attr_vbe_modes.attr, |
| 1724 |
&dev_attr_oem_vendor.attr, |
| 1725 |
&dev_attr_oem_product_name.attr, |
| 1726 |
&dev_attr_oem_product_rev.attr, |
| 1727 |
&dev_attr_oem_string.attr, |
| 1728 |
&dev_attr_nocrtc.attr, |
| 1729 |
NULL, |
| 1730 |
}; |
| 1731 |
|
| 1732 |
static struct attribute_group uvesafb_dev_attgrp = { |
| 1733 |
.name = NULL, |
| 1734 |
.attrs = uvesafb_dev_attrs, |
| 1735 |
}; |
| 1736 |
|
| 1737 |
static int __devinit uvesafb_probe(struct platform_device *dev) |
| 1738 |
{ |
| 1739 |
struct fb_info *info; |
| 1740 |
struct vbe_mode_ib *mode = NULL; |
| 1741 |
struct uvesafb_par *par; |
| 1742 |
int err = 0, i; |
| 1743 |
|
| 1744 |
info = framebuffer_alloc(sizeof(*par) + sizeof(u32) * 256, &dev->dev); |
| 1745 |
if (!info) |
| 1746 |
return -ENOMEM; |
| 1747 |
|
| 1748 |
par = info->par; |
| 1749 |
|
| 1750 |
err = uvesafb_vbe_init(info); |
| 1751 |
if (err) { |
| 1752 |
printk(KERN_ERR "uvesafb: vbe_init() failed with %d\n", err); |
| 1753 |
goto out; |
| 1754 |
} |
| 1755 |
|
| 1756 |
info->fbops = &uvesafb_ops; |
| 1757 |
|
| 1758 |
i = uvesafb_vbe_init_mode(info); |
| 1759 |
if (i < 0) { |
| 1760 |
err = -EINVAL; |
| 1761 |
goto out; |
| 1762 |
} else { |
| 1763 |
mode = &par->vbe_modes[i]; |
| 1764 |
} |
| 1765 |
|
| 1766 |
if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { |
| 1767 |
err = -ENXIO; |
| 1768 |
goto out; |
| 1769 |
} |
| 1770 |
|
| 1771 |
uvesafb_init_info(info, mode); |
| 1772 |
|
| 1773 |
if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, |
| 1774 |
"uvesafb")) { |
| 1775 |
printk(KERN_ERR "uvesafb: cannot reserve video memory at " |
| 1776 |
"0x%lx\n", info->fix.smem_start); |
| 1777 |
err = -EIO; |
| 1778 |
goto out_mode; |
| 1779 |
} |
| 1780 |
|
| 1781 |
info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); |
| 1782 |
|
| 1783 |
if (!info->screen_base) { |
| 1784 |
printk(KERN_ERR |
| 1785 |
"uvesafb: abort, cannot ioremap 0x%x bytes of video " |
| 1786 |
"memory at 0x%lx\n", |
| 1787 |
info->fix.smem_len, info->fix.smem_start); |
| 1788 |
err = -EIO; |
| 1789 |
goto out_mem; |
| 1790 |
} |
| 1791 |
|
| 1792 |
if (!request_region(0x3c0, 32, "uvesafb")) { |
| 1793 |
printk(KERN_ERR "uvesafb: request region 0x3c0-0x3e0 failed\n"); |
| 1794 |
err = -EIO; |
| 1795 |
goto out_unmap; |
| 1796 |
} |
| 1797 |
|
| 1798 |
uvesafb_init_mtrr(info); |
| 1799 |
platform_set_drvdata(dev, info); |
| 1800 |
|
| 1801 |
if (register_framebuffer(info) < 0) { |
| 1802 |
printk(KERN_ERR |
| 1803 |
"uvesafb: failed to register framebuffer device\n"); |
| 1804 |
err = -EINVAL; |
| 1805 |
goto out_reg; |
| 1806 |
} |
| 1807 |
|
| 1808 |
printk(KERN_INFO "uvesafb: framebuffer at 0x%lx, mapped to 0x%p, " |
| 1809 |
"using %dk, total %dk\n", info->fix.smem_start, |
| 1810 |
info->screen_base, info->fix.smem_len/1024, |
| 1811 |
par->vbe_ib.total_memory * 64); |
| 1812 |
printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, |
| 1813 |
info->fix.id); |
| 1814 |
|
| 1815 |
err = sysfs_create_group(&dev->dev.kobj, &uvesafb_dev_attgrp); |
| 1816 |
if (err != 0) |
| 1817 |
printk(KERN_WARNING "fb%d: failed to register attributes\n", |
| 1818 |
info->node); |
| 1819 |
|
| 1820 |
return 0; |
| 1821 |
|
| 1822 |
out_reg: |
| 1823 |
release_region(0x3c0, 32); |
| 1824 |
out_unmap: |
| 1825 |
iounmap(info->screen_base); |
| 1826 |
out_mem: |
| 1827 |
release_mem_region(info->fix.smem_start, info->fix.smem_len); |
| 1828 |
out_mode: |
| 1829 |
if (!list_empty(&info->modelist)) |
| 1830 |
fb_destroy_modelist(&info->modelist); |
| 1831 |
fb_destroy_modedb(info->monspecs.modedb); |
| 1832 |
fb_dealloc_cmap(&info->cmap); |
| 1833 |
out: |
| 1834 |
if (par->vbe_modes) |
| 1835 |
kfree(par->vbe_modes); |
| 1836 |
|
| 1837 |
framebuffer_release(info); |
| 1838 |
return err; |
| 1839 |
} |
| 1840 |
|
| 1841 |
static int uvesafb_remove(struct platform_device *dev) |
| 1842 |
{ |
| 1843 |
struct fb_info *info = platform_get_drvdata(dev); |
| 1844 |
|
| 1845 |
if (info) { |
| 1846 |
struct uvesafb_par *par = info->par; |
| 1847 |
|
| 1848 |
sysfs_remove_group(&dev->dev.kobj, &uvesafb_dev_attgrp); |
| 1849 |
unregister_framebuffer(info); |
| 1850 |
release_region(0x3c0, 32); |
| 1851 |
iounmap(info->screen_base); |
| 1852 |
release_mem_region(info->fix.smem_start, info->fix.smem_len); |
| 1853 |
fb_destroy_modedb(info->monspecs.modedb); |
| 1854 |
fb_dealloc_cmap(&info->cmap); |
| 1855 |
|
| 1856 |
if (par) { |
| 1857 |
if (par->vbe_modes) |
| 1858 |
kfree(par->vbe_modes); |
| 1859 |
if (par->vbe_state_orig) |
| 1860 |
kfree(par->vbe_state_orig); |
| 1861 |
if (par->vbe_state_saved) |
| 1862 |
kfree(par->vbe_state_saved); |
| 1863 |
} |
| 1864 |
|
| 1865 |
framebuffer_release(info); |
| 1866 |
} |
| 1867 |
return 0; |
| 1868 |
} |
| 1869 |
|
| 1870 |
static struct platform_driver uvesafb_driver = { |
| 1871 |
.probe = uvesafb_probe, |
| 1872 |
.remove = uvesafb_remove, |
| 1873 |
.driver = { |
| 1874 |
.name = "uvesafb", |
| 1875 |
}, |
| 1876 |
}; |
| 1877 |
|
| 1878 |
static struct platform_device *uvesafb_device; |
| 1879 |
|
| 1880 |
#ifndef MODULE |
| 1881 |
static int __devinit uvesafb_setup(char *options) |
| 1882 |
{ |
| 1883 |
char *this_opt; |
| 1884 |
|
| 1885 |
if (!options || !*options) |
| 1886 |
return 0; |
| 1887 |
|
| 1888 |
while ((this_opt = strsep(&options, ",")) != NULL) { |
| 1889 |
if (!*this_opt) continue; |
| 1890 |
|
| 1891 |
if (!strcmp(this_opt, "redraw")) |
| 1892 |
ypan = 0; |
| 1893 |
else if (!strcmp(this_opt, "ypan")) |
| 1894 |
ypan = 1; |
| 1895 |
else if (!strcmp(this_opt, "ywrap")) |
| 1896 |
ypan = 2; |
| 1897 |
else if (!strcmp(this_opt, "vgapal")) |
| 1898 |
pmi_setpal = 0; |
| 1899 |
else if (!strcmp(this_opt, "pmipal")) |
| 1900 |
pmi_setpal = 1; |
| 1901 |
else if (!strncmp(this_opt, "mtrr:", 5)) |
| 1902 |
mtrr = simple_strtoul(this_opt+5, NULL, 0); |
| 1903 |
else if (!strcmp(this_opt, "nomtrr")) |
| 1904 |
mtrr = 0; |
| 1905 |
else if (!strcmp(this_opt, "nocrtc")) |
| 1906 |
nocrtc = 1; |
| 1907 |
else if (!strcmp(this_opt, "noedid")) |
| 1908 |
noedid = 1; |
| 1909 |
else if (!strcmp(this_opt, "noblank")) |
| 1910 |
blank = 0; |
| 1911 |
else if (!strncmp(this_opt, "vtotal:", 7)) |
| 1912 |
vram_total = simple_strtoul(this_opt + 7, NULL, 0); |
| 1913 |
else if (!strncmp(this_opt, "vremap:", 7)) |
| 1914 |
vram_remap = simple_strtoul(this_opt + 7, NULL, 0); |
| 1915 |
else if (!strncmp(this_opt, "maxhf:", 6)) |
| 1916 |
maxhf = simple_strtoul(this_opt + 6, NULL, 0); |
| 1917 |
else if (!strncmp(this_opt, "maxvf:", 6)) |
| 1918 |
maxvf = simple_strtoul(this_opt + 6, NULL, 0); |
| 1919 |
else if (!strncmp(this_opt, "maxclk:", 7)) |
| 1920 |
maxclk = simple_strtoul(this_opt + 7, NULL, 0); |
| 1921 |
else if (!strncmp(this_opt, "vbemode:", 8)) |
| 1922 |
vbemode = simple_strtoul(this_opt + 8, NULL, 0); |
| 1923 |
else if (this_opt[0] >= '0' && this_opt[0] <= '9') { |
| 1924 |
mode_option = this_opt; |
| 1925 |
} else { |
| 1926 |
printk(KERN_WARNING |
| 1927 |
"uvesafb: unrecognized option %s\n", this_opt); |
| 1928 |
} |
| 1929 |
} |
| 1930 |
|
| 1931 |
return 0; |
| 1932 |
} |
| 1933 |
#endif /* !MODULE */ |
| 1934 |
|
| 1935 |
static ssize_t show_v86d(struct device_driver *dev, char *buf) |
| 1936 |
{ |
| 1937 |
return snprintf(buf, PAGE_SIZE, "%s\n", v86d_path); |
| 1938 |
} |
| 1939 |
|
| 1940 |
static ssize_t store_v86d(struct device_driver *dev, const char *buf, |
| 1941 |
size_t count) |
| 1942 |
{ |
| 1943 |
strncpy(v86d_path, buf, PATH_MAX); |
| 1944 |
return count; |
| 1945 |
} |
| 1946 |
|
| 1947 |
static DRIVER_ATTR(v86d, S_IRUGO | S_IWUSR, show_v86d, store_v86d); |
| 1948 |
|
| 1949 |
static int __devinit uvesafb_init(void) |
| 1950 |
{ |
| 1951 |
int err; |
| 1952 |
|
| 1953 |
#ifndef MODULE |
| 1954 |
char *option = NULL; |
| 1955 |
|
| 1956 |
if (fb_get_options("uvesafb", &option)) |
| 1957 |
return -ENODEV; |
| 1958 |
uvesafb_setup(option); |
| 1959 |
#endif |
| 1960 |
err = cn_add_callback(&uvesafb_cn_id, "uvesafb", uvesafb_cn_callback); |
| 1961 |
if (err) |
| 1962 |
return err; |
| 1963 |
|
| 1964 |
err = platform_driver_register(&uvesafb_driver); |
| 1965 |
|
| 1966 |
if (!err) { |
| 1967 |
uvesafb_device = platform_device_alloc("uvesafb", 0); |
| 1968 |
if (uvesafb_device) |
| 1969 |
err = platform_device_add(uvesafb_device); |
| 1970 |
else |
| 1971 |
err = -ENOMEM; |
| 1972 |
|
| 1973 |
if (err) { |
| 1974 |
platform_device_put(uvesafb_device); |
| 1975 |
platform_driver_unregister(&uvesafb_driver); |
| 1976 |
cn_del_callback(&uvesafb_cn_id); |
| 1977 |
return err; |
| 1978 |
} |
| 1979 |
|
| 1980 |
err = driver_create_file(&uvesafb_driver.driver, |
| 1981 |
&driver_attr_v86d); |
| 1982 |
if (err) { |
| 1983 |
printk(KERN_WARNING "uvesafb: failed to register " |
| 1984 |
"attributes\n"); |
| 1985 |
err = 0; |
| 1986 |
} |
| 1987 |
} |
| 1988 |
return err; |
| 1989 |
} |
| 1990 |
|
| 1991 |
module_init(uvesafb_init); |
| 1992 |
|
| 1993 |
static void __devexit uvesafb_exit(void) |
| 1994 |
{ |
| 1995 |
struct uvesafb_ktask *task; |
| 1996 |
|
| 1997 |
if (v86d_started) { |
| 1998 |
task = uvesafb_prep(); |
| 1999 |
if (task) { |
| 2000 |
task->t.flags = TF_EXIT; |
| 2001 |
uvesafb_exec(task); |
| 2002 |
uvesafb_free(task); |
| 2003 |
} |
| 2004 |
} |
| 2005 |
|
| 2006 |
cn_del_callback(&uvesafb_cn_id); |
| 2007 |
driver_remove_file(&uvesafb_driver.driver, &driver_attr_v86d); |
| 2008 |
platform_device_unregister(uvesafb_device); |
| 2009 |
platform_driver_unregister(&uvesafb_driver); |
| 2010 |
} |
| 2011 |
|
| 2012 |
module_exit(uvesafb_exit); |
| 2013 |
|
| 2014 |
static inline int param_get_scroll(char *buffer, struct kernel_param *kp) |
| 2015 |
{ |
| 2016 |
return 0; |
| 2017 |
} |
| 2018 |
|
| 2019 |
static inline int param_set_scroll(const char *val, struct kernel_param *kp) |
| 2020 |
{ |
| 2021 |
ypan = 0; |
| 2022 |
|
| 2023 |
if (!strcmp(val, "redraw")) |
| 2024 |
ypan = 0; |
| 2025 |
else if (!strcmp(val, "ypan")) |
| 2026 |
ypan = 1; |
| 2027 |
else if (!strcmp(val, "ywrap")) |
| 2028 |
ypan = 2; |
| 2029 |
|
| 2030 |
return 0; |
| 2031 |
} |
| 2032 |
|
| 2033 |
#define param_check_scroll(name, p) __param_check(name, p, void); |
| 2034 |
|
| 2035 |
module_param_named(scroll, ypan, scroll, 0); |
| 2036 |
MODULE_PARM_DESC(scroll, |
| 2037 |
"Scrolling mode, set to 'redraw', ''ypan' or 'ywrap'"); |
| 2038 |
module_param_named(vgapal, pmi_setpal, invbool, 0); |
| 2039 |
MODULE_PARM_DESC(vgapal, "Set palette using VGA registers"); |
| 2040 |
module_param_named(pmipal, pmi_setpal, bool, 0); |
| 2041 |
MODULE_PARM_DESC(pmipal, "Set palette using PMI calls"); |
| 2042 |
module_param(mtrr, uint, 0); |
| 2043 |
MODULE_PARM_DESC(mtrr, |
| 2044 |
"Memory Type Range Registers setting. Use 0 to disable."); |
| 2045 |
module_param(blank, bool, 0); |
| 2046 |
MODULE_PARM_DESC(blank, "Enable hardware blanking"); |
| 2047 |
module_param(nocrtc, bool, 0); |
| 2048 |
MODULE_PARM_DESC(nocrtc, "Ignore CRTC timings when setting modes"); |
| 2049 |
module_param(noedid, bool, 0); |
| 2050 |
MODULE_PARM_DESC(noedid, |
| 2051 |
"Ignore EDID-provided monitor limits when setting modes"); |
| 2052 |
module_param(vram_remap, uint, 0); |
| 2053 |
MODULE_PARM_DESC(vram_remap, "Set amount of video memory to be used [MiB]"); |
| 2054 |
module_param(vram_total, uint, 0); |
| 2055 |
MODULE_PARM_DESC(vram_total, "Set total amount of video memoery [MiB]"); |
| 2056 |
module_param(maxclk, ushort, 0); |
| 2057 |
MODULE_PARM_DESC(maxclk, "Maximum pixelclock [MHz], overrides EDID data"); |
| 2058 |
module_param(maxhf, ushort, 0); |
| 2059 |
MODULE_PARM_DESC(maxhf, |
| 2060 |
"Maximum horizontal frequency [kHz], overrides EDID data"); |
| 2061 |
module_param(maxvf, ushort, 0); |
| 2062 |
MODULE_PARM_DESC(maxvf, |
| 2063 |
"Maximum vertical frequency [Hz], overrides EDID data"); |
| 2064 |
module_param_named(mode, mode_option, charp, 0); |
| 2065 |
MODULE_PARM_DESC(mode, |
| 2066 |
"Specify initial video mode as \"<xres>x<yres>[-<bpp>][@<refresh>]\""); |
| 2067 |
module_param(vbemode, ushort, 0); |
| 2068 |
MODULE_PARM_DESC(vbemode, |
| 2069 |
"VBE mode number to set, overrides the 'mode' option"); |
| 2070 |
module_param_string(v86d, v86d_path, PATH_MAX, 0660); |
| 2071 |
MODULE_PARM_DESC(v86d, "Path to the v86d userspace helper."); |
| 2072 |
|
| 2073 |
MODULE_LICENSE("GPL"); |
| 2074 |
MODULE_AUTHOR("Michal Januszewski <spock@gentoo.org>"); |
| 2075 |
MODULE_DESCRIPTION("Framebuffer driver for VBE2.0+ compliant graphics boards"); |
| 2076 |
|