fbdev: uvesafb driver
PATCH 3/4 fbdev: uvesafb driver
Add the uvesafb driver, an enhanced version of vesafb that makes use of a userspace helper to run x86 Video BIOS code.
--- drivers/video/Kconfig | 18 + drivers/video/Makefile | 1 + drivers/video/uvesafb.c | 1902 +++++++++++++++++++++++++++++++++++++++++++++++ include/video/Kbuild | 2 +- include/video/uvesafb.h | 208 ++++++ 5 files changed, 2130 insertions(+), 1 deletions(-)
drivers/video/Kconfig +18 -0
@@ -585,6 +585,24 @@ config FB_TGA Say Y if you have one of those. +config FB_UVESA + tristate "Userspace VESA VGA graphics support" + depends on FB && CONNECTOR + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select FB_MODE_HELPERS + help + This is the frame buffer driver for generic VBE 2.0 compliant + graphic cards. It can also take advantage of VBE 3.0 features, + such as refresh rate adjustment. + + This driver generally provides more features than vesafb but + requires a userspace helper application called 'v86d'. See + <file:Documentation/fb/uvesafb.txt> for more information. + + If unsure, say N. + config FB_VESA bool "VESA VGA graphics support" depends on (FB = y) && X86
drivers/video/Makefile +1 -0
@@ -115,6 +115,7 @@ obj-$(CONFIG_FB_SM501) += sm501fb.o obj-$(CONFIG_FB_XILINX) += xilinxfb.o # Platform or fallback drivers go here +obj-$(CONFIG_FB_UVESA) += uvesafb.o obj-$(CONFIG_FB_VESA) += vesafb.o obj-$(CONFIG_FB_IMAC) += imacfb.o obj-$(CONFIG_FB_VGA16) += vga16fb.o
drivers/video/uvesafb.c new file +1902 -0
1,902 lines not on this page · raw message
include/video/Kbuild +1 -1
@@ -1 +1 @@ -unifdef-y += sisfb.h +unifdef-y += sisfb.h uvesafb.h
include/video/uvesafb.h new file +208 -0
208 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
drivers/video/uvesafb.c line 69
Quoted 13 lines · Michal Januszewski
drivers/video/uvesafb.c new file +13
-0+static void uvesafb_cn_callback (void *data) +{ +struct cn_msg *msg = (struct cn_msg *)data; +struct uvesafb_task *utask = (struct uvesafb_task *)msg->data; +struct uvesafb_ktask *task; + +if (msg->seq >=UVESAFB_TASKS_MAX ) +return ; + + task = uvfb_tasks[msg->seq]; + +if (!task || msg->ack != task->ack) +return ;
You need utask only here, so could spare setting it before the checking above.
drivers/video/uvesafb.c line 79
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ +memcpy (&task->t, utask,sizeof (struct uvesafb_task )); + +if (task->t.buf_len && task->buf) +memcpy (task->buf, ((u8 *)utask) +sizeof (struct uvesafb_task ), + task->t.buf_len); + +complete (task->done); +return ; +}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Quoted 17 lines · On Sat, 23 Jun 2007 12:52:43 +0200 Michal Januszewski <[email protected]> wrote:
Add the uvesafb driver, an enhanced version of vesafb that makes use of a userspace helper to run x86 Video BIOS code.
Signed-off-by Michal Januszewski <[email protected]>--- drivers/video/Kconfig | 18 + drivers/video/Makefile | 1 + drivers/video/uvesafb.c | 1902 +++++++++++++++++++++++++++++++++++++++++++++++ include/video/Kbuild | 2 +- include/video/uvesafb.h | 208 ++++++ 5 files changed, 2130 insertions(+), 1 deletions(-)drivers/video/Kconfig +0
-0
drivers/video/Kconfig config FB_TGA · line 590
Quoted 6 lines
drivers/video/Kconfig +3
-0@@ -585,6 +585,24 @@ config FB_TGA Say Y if you have one of those. +config FB_UVESA + tristate "Userspace VESA VGA graphics support" + depends on FB && CONNECTOR
These dependencies are insufficient.
Quoted 18 lines
...
drivers/video/uvesafb.c new file +13
-0@@ -0,0 +1,1902 @@ +/* +* A framebuffer driver for VBE 2.0+ compliant video cards +* +* (c) 2007 Michal Januszewski <[email protected]> +* Loosely based upon the vesafb driver. +* +*/ +#include <linux/init.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/skbuff.h> +#include <linux/timer.h> +#include <linux/completion.h>
drivers/video/uvesafb.c line 23
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+#include <linux/connector.h> +#include <linux/random.h> +#include <linux/platform_device.h> +#include <linux/limits.h> +#include <linux/fb.h> +#include <video/edid.h> +#include <video/vga.h> +#include <video/uvesafb.h> +#include <asm/io.h> +#include <asm/mtrr.h>
Only x86 has mtrr.h: you just broke allmodconfig on all other architectures.
drivers/video/uvesafb.c line 32
Quoted 8 lines
drivers/video/uvesafb.c new file +8
-0+#include "edid.h" + +static struct cb_id uvesafb_cn_id = { + .idx =CN_IDX_V86D , + .val =CN_VAL_V86D_UVESAFB +}; +static struct sock *nls; +static char v86d_path[PATH_MAX ] ="/sbin/v86d" ;
Remove the PATH_MAX, save some memory.
Oh, it gets set via sysfs. hrm.
drivers/video/uvesafb.c line 33
Quoted 1 line
drivers/video/uvesafb.c new file +1
-0+static char v86d_started =0 ;/* has v86d been started by uvesafb? */
Unneeded initialisation-to-zero.
scripts/checkpatch.pl would have reported this. It in fact generates 93 warnings against this patch and from a quick scan, they all look legitimate.
drivers/video/uvesafb.c line 59
Quoted 3 lines
drivers/video/uvesafb.c new file +3
-0+static void uvesafb_cn_callback (void *data) +{ +struct cn_msg *msg = (struct cn_msg *)data;
unneeded cast of void*
Quoted 6 lines
drivers/video/uvesafb.c new file +6
-0+struct uvesafb_task *utask = (struct uvesafb_task *)msg->data; +struct uvesafb_ktask *task; + +if (msg->seq >=UVESAFB_TASKS_MAX ) +return ; +
drivers/video/uvesafb.c line 75
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ task = uvfb_tasks[msg->seq]; + +if (!task || msg->ack != task->ack) +return ; + +memcpy (&task->t, utask,sizeof (struct uvesafb_task )); + +if (task->t.buf_len && task->buf) +memcpy (task->buf, ((u8 *)utask) +sizeof (struct uvesafb_task ), + task->t.buf_len);
Isn't this
memcpy(task->buf, utask + 1, task->t.buf_len);
?
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ +complete (task->done); +return ; +} + +static int uvesafb_helper_start (void ) +{ +char *envp[] = { +"HOME=/" , +"PATH=/sbin:/bin" ,
drivers/video/uvesafb.c line 95
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ NULL, + }; + +char *argv[] = { + v86d_path, +NULL , + }; + +return call_usermodehelper (v86d_path, argv, envp,1 ); +}
Now I'm wondering what this code actually does. It would be nice to have an overall design and implementation description in the changelog so we don't have to reverse-engineer your thoughts from your implementation...
The comment over uvesafb_exec() helps.
Quoted 4 lines
drivers/video/uvesafb.c new file +4
-0+static struct uvesafb_ktask *uvesafb_prep (void ) +{ +struct uvesafb_ktask *task; +
drivers/video/uvesafb.c line 110
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ task =kzalloc (sizeof (struct uvesafb_ktask ),GFP_ATOMIC ); +if (task) { + task->done =kzalloc (sizeof (struct completion ),GFP_ATOMIC ); +if (!task->done) { +kfree (task); + task =NULL ; + } + } +return task; +}
GFP_ATOMIC is unreliable and should be strenuously avoided. I suspect all callers can use GFP_KERNEL here. If not, we should at least pass the gfp_t into this function as an argument so that we can use GFP_KERNEL from as many callsites as possible.
Quoted 22 lines
drivers/video/uvesafb.c new file +22
-0+/* +* Execute a uvesafb task. +* +* Returns 0 if the task is executed successfully. +* +* A message sent to the userspace consists of the uvesafb_task +* struct and (optionally) a buffer. The uvesafb_task struct is +* a simplified version of uvesafb_ktask (its kernel counterpart) +* containing only the register values, flags and the length of +* the buffer. +* +* Each message is assigned a sequence number (increased linearly) +* and a random ack number. The sequence number is used as a key +* for the uvfb_tasks array which holds pointers to uvesafb_ktask +* structs for all requests. +*/ +static int uvesafb_exec (struct uvesafb_ktask *task) +{ +static int seq =0 ; +struct cn_msg *m; +int err; +int len =sizeof (task->t) + task->t.buf_len;
drivers/video/uvesafb.c line 143
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ +/* Check whether the message isn't longer than the maximum +* allowed by connector */ +if (sizeof (*m) + len >CONNECTOR_MAX_MSG_SIZE ) { +printk (KERN_WARNING "uvesafb: message too long (%d), " +"can't exec task\n" , (int )(sizeof (*m) + len)); +return -E2BIG ; + } + + m =kmalloc (sizeof (*m) + len,GFP_ATOMIC );
More GFP_ATOMIC badness
drivers/video/uvesafb.c line 149
Quoted 6 lines
drivers/video/uvesafb.c new file +6
-0+if (!m) +return -ENOMEM ; + +init_completion (task->done); + +memset (m,0 ,sizeof (*m) + len);
kzalloc()
Quoted 33 lines
drivers/video/uvesafb.c new file +33
-0+memcpy (&m->id, &uvesafb_cn_id,sizeof (m->id)); + m->seq = seq; + m->len = len; + m->ack =random32 (); + +/* uvesafb_task structure */ +memcpy (m +1 , &task->t,sizeof (task->t)); + +/* Buffer */ +memcpy ((u8 *)m +sizeof (task->t) +sizeof (*m), + task->buf, task->t.buf_len); + +/* Save the message ack number so that we can find the kernel +* part of this task when a reply is received from userspace. */ + task->ack = m->ack; + +/* If all slots are taken -- bail out. */ +if (uvfb_tasks[seq]) +return -EBUSY ; + +/* Save a pointer to the kernel part of the task struct. */ + uvfb_tasks[seq] = task; + + err =cn_netlink_send (m,0 ,gfp_any ()); +if (err == -ESRCH ) { +/* Try to start the userspace helper if sending +* the request failed the first time. */ + err =uvesafb_helper_start (); +if (err) { +printk (KERN_ERR "uvesafb: failed to execute %s\n" , + v86d_path); +printk (KERN_ERR "uvesafb: make sure that the v86d" +"helper is installed and executable\n" );
drivers/video/uvesafb.c line 192
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ }else { + v86d_started =1 ; + err =cn_netlink_send (m,0 ,gfp_any ()); + } + } +kfree (m); + +if (!err && !(task->t.flags &TF_EXIT )) + err = !wait_for_completion_timeout (task->done, +msecs_to_jiffies (UVESAFB_TIMEOUT ));
If you can run wait_for_completion() here then you can use GFP_KERNEL up there.
Quoted 29 lines
drivers/video/uvesafb.c new file +26
-0+ uvfb_tasks[seq] =NULL ; + + seq++; +if (seq >=UVESAFB_TASKS_MAX ) + seq =0 ; + +return err; +} +static int __devinit uvesafb_vbe_getinfo (struct uvesafb_ktask *task, +struct uvesafb_par *par) +{ +int err; + + task->t.regs.eax =0x4f00 ; + task->t.flags =TF_VBEIB ; + task->t.buf_len =sizeof (struct vbe_ib ); + task->buf = (u8 *) &par->vbe_ib; +strncpy (par->vbe_ib.vbe_signature,"VBE2" ,4 ); + + err =uvesafb_exec (task); +if (err || (task->t.regs.eax &0xffff ) !=0x004f ) { +printk (KERN_ERR "uvesafb: Getting VBE info block failed " +"(eax=0x%x, err=%x)\n" , (u32 )task->t.regs.eax, + err); +return -EINVAL ; + }
drivers/video/uvesafb.c
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ +if (par->vbe_ib.vbe_version <0x0200 ) { +printk (KERN_ERR "uvesafb: Sorry, pre-VBE 2.0 cards are " +"not supported.\n" ); +return -EINVAL ; + } + +if (!par->vbe_ib.mode_list_ptr) { +printk (KERN_ERR "uvesafb: Missing mode list!\n" ); +return -EINVAL ;
whitespace went wonky here.
drivers/video/uvesafb.c line 392
Quoted 7 lines
drivers/video/uvesafb.c new file +7
-0+ } + +printk (KERN_INFO "uvesafb: " ); + +/* Convert string pointers and the mode list pointer into +* usable addresses. Print informational messages about the +* video adapter and its vendor. */
Commenting style is
/* Convert string pointers and the mode list pointer into * usable addresses. Print informational messages about the * video adapter and its vendor. */
or
/*
* Convert string pointers and the mode list pointer into
* usable addresses. Print informational messages about the
* video adapter and its vendor.
*/
Quoted 53 lines
drivers/video/uvesafb.c new file +53
-0+if (par->vbe_ib.oem_vendor_name_ptr) +printk ("%s, " , + (char *)(task->buf + par->vbe_ib.oem_vendor_name_ptr)); + +if (par->vbe_ib.oem_product_name_ptr) +printk ("%s, " , + (char *)(task->buf + par->vbe_ib.oem_product_name_ptr)); + +if (par->vbe_ib.oem_product_rev_ptr) +printk ("%s, " , + (char *)(task->buf + par->vbe_ib.oem_product_rev_ptr)); + +if (par->vbe_ib.oem_string_ptr) +printk ("OEM: %s, " , + (char *)(task->buf + par->vbe_ib.oem_string_ptr)); + +printk ("VBE v%d.%d\n" , ((par->vbe_ib.vbe_version &0xff00 ) >>8 ), + par->vbe_ib.vbe_version &0xff ); + +return 0 ; +} + +static int __devinit uvesafb_vbe_getmodes (struct uvesafb_ktask *task, +struct uvesafb_par *par) +{ +int off =0 , err; +u16 *mode; + + par->vbe_modes_cnt =0 ; + +/* Count available modes. */ + mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); +while (*mode !=0xffff ) { + par->vbe_modes_cnt++; + mode++; + } + + par->vbe_modes =kzalloc (sizeof (struct vbe_mode_ib ) * + par->vbe_modes_cnt,GFP_KERNEL ); +if (!par->vbe_modes) +return -ENOMEM ; + +/* Get info about all available modes. */ + mode = (u16 *) (((u8 *)&par->vbe_ib) + par->vbe_ib.mode_list_ptr); +while (*mode !=0xffff ) { +struct vbe_mode_ib *mib; + +uvesafb_reset (task); + task->t.regs.eax =0x4f01 ; + task->t.regs.ecx = (u32) *mode; + task->t.flags =TF_BUF_RET |TF_BUF_ESDI ; + task->t.buf_len =sizeof (struct vbe_mode_ib ); + task->buf = (u8 *) (par->vbe_modes + off);
drivers/video/uvesafb.c line 455
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ + err =uvesafb_exec (task); +if (err || (task->t.regs.eax &0xffff ) !=0x004f ) { +printk (KERN_ERR "uvesafb: Getting mode info block " +"for mode 0x%x failed (eax=0x%x, err=%x)\n" , + *mode, (u32 )task->t.regs.eax, err); +return -EINVAL ; + } + + mib = (struct vbe_mode_ib *)task->buf;
Perhaps uvesafb_ktask.buf should be void* so we can lose some typecasts.
Quoted 15 lines
drivers/video/uvesafb.c new file +15
-0+ mib->mode_id = *mode; + +/* We only want modes that are supported with the current +* hardware configuration, color, graphics and that have +* support for the LFB. */ +if ((mib->mode_attr &VBE_MODE_MASK ) ==VBE_MODE_MASK && + mib->bits_per_pixel >=8 ) { + off++; + }else { + par->vbe_modes_cnt--; + } + mode++; + mib->depth = mib->red_len + mib->green_len + mib->blue_len; + +/* Handle 8bpp modes and modes with broken color component
drivers/video/uvesafb.c line 480
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+* lengths. */ +if (mib->depth ==0 || (mib->depth ==24 && + mib->bits_per_pixel ==32 )) + mib->depth = mib->bits_per_pixel; + } + +return 0 ; +} + +#ifdef __i386__
CONFIG_X86 would be more typical.
Be aware that CONFIG_X86 is true for both i386 and x86_64. You don't state whether this code works on x86_64. If it can, it should.
Quoted 33 lines
drivers/video/uvesafb.c new file +33
-0+static int __devinit uvesafb_vbe_getpmi (struct uvesafb_ktask *task, +struct uvesafb_par *par) +{ +int i, err; + +uvesafb_reset (task); + task->t.regs.eax =0x4f0a ; + task->t.regs.ebx =0x0 ; + err =uvesafb_exec (task); + +if ((task->t.regs.eax &0xffff ) !=0x4f || task->t.regs.es <0xc000 ) { + par->pmi_setpal = par->ypan =0 ; + }else { + par->pmi_base = (u16 *)phys_to_virt (((u32 )task->t.regs.es <<4 ) + + task->t.regs.edi); + par->pmi_start = (void *)((char *)par->pmi_base + + par->pmi_base[1 ]); + par->pmi_pal = (void *)((char *)par->pmi_base + + par->pmi_base[2 ]); +printk (KERN_INFO "uvesafb: protected mode interface info at " +"%04x:%04x\n" , + (u16 )task->t.regs.es, (u16 )task->t.regs.edi); +printk (KERN_INFO "uvesafb: pmi: set display start = %p, " +"set palette = %p\n" , par->pmi_start, + par->pmi_pal); + +if (par->pmi_base[3 ]) { +printk (KERN_INFO "uvesafb: pmi: ports = " ); +for (i = par->pmi_base[3 ]/2 ; + par->pmi_base[i] !=0xffff ; i++) +printk ("%x " , par->pmi_base[i]); +printk ("\n" ); +
drivers/video/uvesafb.c line 523
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+if (par->pmi_base[i] !=0xffff ) { +printk (KERN_INFO "uvesafb: can't handle memory" +" requests, pmi disabled\n" ); + par->ypan = par->pmi_setpal =0 ; + } + } + } +return 0 ; +} +#endif
You might care to cc "H. Peter Anvin" <[email protected]> on the next version of this patch - he's a whizz at this sort of low-level x86 bios communication stuff.
Quoted 12 lines
drivers/video/uvesafb.c new file +12
-0+/* Check whether a video mode is supported by the Video BIOS and is +* compatible with the monitor limits. */ +static int __devinit uvesafb_is_valid_mode (struct fb_videomode *mode, +struct fb_info *info) +{ +if (info->monspecs.gtf) { +fb_videomode_to_var (&info->var, mode); +if (fb_validate_mode (&info->var, info)) +return -1 ; + } + + if (uvesafb_vbe_find_mode(info->par, mode->xres, mode->yres, 8,
drivers/video/uvesafb.c line 546
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ UVESAFB_NEED_EXACT_RES) == -1) +return -1 ; + +return 0 ; +} + +static int __devinit uvesafb_vbe_getedid (struct uvesafb_ktask *task, +struct fb_info *info) +{ +struct uvesafb_par *par = (struct uvesafb_par *)info->par;
fb_info.par has type void* hence all casts such as the above can and should be removed.
Quoted 54 lines
drivers/video/uvesafb.c new file +54
-0+int err =0 ; + +if (noedid || par->vbe_ib.vbe_version <0x0300 ) +return -EINVAL ; + + task->t.regs.eax =0x4f15 ; + task->t.regs.ebx =0 ; + task->t.regs.ecx =0 ; + task->t.buf_len =0 ; + task->t.flags =0 ; + + err =uvesafb_exec (task); + +if ((task->t.regs.eax &0xffff ) !=0x004f || err) +return -EINVAL ; + +if ((task->t.regs.ebx &0x3 ) ==3 ) { +printk (KERN_INFO "uvesafb: VBIOS/hardware supports both " +"DDC1 and DDC2 transfers\n" ); + }else if ((task->t.regs.ebx &0x3 ) ==2 ) { +printk (KERN_INFO "uvesafb: VBIOS/hardware supports DDC2 " +"transfers\n" ); + }else if ((task->t.regs.ebx &0x3 ) ==1 ) { +printk (KERN_INFO "uvesafb: VBIOS/hardware supports DDC1 " +"transfers\n" ); + }else { +printk (KERN_INFO "uvesafb: VBIOS/hardware doesn't support " +"DDC transfers\n" ); +return -EINVAL ; + } + + task->t.regs.eax =0x4f15 ; + task->t.regs.ebx =1 ; + task->t.regs.ecx = task->t.regs.edx =0 ; + task->t.flags =TF_BUF_RET |TF_BUF_ESDI ; + task->t.buf_len =EDID_LENGTH ; + task->buf =kzalloc (EDID_LENGTH ,GFP_KERNEL ); + + err =uvesafb_exec (task); + +if ((task->t.regs.eax &0xffff ) ==0x004f && !err) { +fb_edid_to_monspecs (task->buf, &info->monspecs); + +if (info->monspecs.vfmax && info->monspecs.hfmax) { +/* If the maximum pixel clock wasn't specified in +* the EDID block, set it to 300 MHz. */ +if (info->monspecs.dclkmax ==0 ) + info->monspecs.dclkmax =300 *1000000 ; + info->monspecs.gtf =1 ; + } + }else { + err = -EINVAL ; + } +
drivers/video/uvesafb.c line 610
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+kfree (task->buf); +return err; +} + +static void __devinit uvesafb_vbe_getmonspecs (struct uvesafb_ktask *task, +struct fb_info *info) +{ +struct uvesafb_par *par = info->par; +int i; +memset (&info->monspecs,0 ,sizeof (struct fb_monspecs ));
Missing a newline above.
Quoted 59 lines
drivers/video/uvesafb.c new file +59
-0+/* If we don't get all necessary data from the EDID block, +* mark it as incompatible with the GTF. */ +if (uvesafb_vbe_getedid (task, info)) + info->monspecs.gtf =0 ; + +/* Kernel command line overrides. */ +if (maxclk) + info->monspecs.dclkmax = maxclk *1000000 ; +if (maxvf) + info->monspecs.vfmax = maxvf; +if (maxhf) + info->monspecs.hfmax = maxhf *1000 ; + +/* In case DDC transfers are not supported the user can provide +* monitor limits manually. Lower limits are set to "safe" values. */ +if (info->monspecs.gtf ==0 && maxclk && maxvf && maxhf) { + info->monspecs.dclkmin =0 ; + info->monspecs.vfmin =60 ; + info->monspecs.hfmin =29000 ; + info->monspecs.gtf =1 ; + } + +if (info->monspecs.gtf) +printk (KERN_INFO +"uvesafb: monitor limits: vf = %d Hz, hf = %d kHz, " +"clk = %d MHz\n" , info->monspecs.vfmax, + (int )(info->monspecs.hfmax /1000 ), + (int )(info->monspecs.dclkmax /1000000 )); +else +printk (KERN_INFO "uvesafb: no monitor limits have been set\n" ); + +/* Add VBE modes to the modelist. */ +for (i =0 ; i < par->vbe_modes_cnt; i++) { +struct fb_var_screeninfo var; +struct vbe_mode_ib *mode; +struct fb_videomode vmode; + + mode = &par->vbe_modes[i]; +memset (&var,0 ,sizeof (var)); + + var.xres = mode->x_res; + var.yres = mode->y_res; + +fb_get_mode (FB_VSYNCTIMINGS |FB_IGNOREMON ,60 , &var, info); +fb_var_to_videomode (&vmode, &var); +fb_add_videomode (&vmode, &info->modelist); + } + +/* Add valid VESA modes to our modelist. */ +for (i =0 ; i <VESA_MODEDB_SIZE ; i++) { +if (!uvesafb_is_valid_mode ((struct fb_videomode *) + &vesa_modes[i], info)) +fb_add_videomode (&vesa_modes[i], &info->modelist); + } + +for (i =0 ; i < info->monspecs.modedb_len; i++) { +if (!uvesafb_is_valid_mode (&info->monspecs.modedb[i], info)) +fb_add_videomode (&info->monspecs.modedb[i], + &info->modelist);
drivers/video/uvesafb.c line 680
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ } + +return ; +} + +static void __devinit uvesafb_vbe_getstatesize (struct uvesafb_ktask *task, +struct uvesafb_par *par) +{ +int err; +uvesafb_reset (task);
Here also.
Quoted 21 lines
drivers/video/uvesafb.c new file +21
-0+/* Get the VBE state buffer size. We want all available +* hardware state data (CL = 0x0f). */ + task->t.regs.eax =0x4f04 ; + task->t.regs.ecx =0x000f ; + task->t.regs.edx =0x0000 ; + task->t.flags =0 ; + + err =uvesafb_exec (task); + +if (err || (task->t.regs.eax &0xffff ) !=0x004f ) { +printk (KERN_WARNING "uvesafb: VBE state buffer size " +"cannot be determined (eax=0x%x, err=%d)\n" , + task->t.regs.eax, err); + par->vbe_state_size =0 ; +return ; + } + + par->vbe_state_size =64 * (task->t.regs.ebx &0xffff ); +} + +static int __devinit uvesafb_vbe_init (struct fb_info *info)
drivers/video/uvesafb.c line 712
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+{ +struct uvesafb_ktask *task =NULL ; +struct uvesafb_par *par = info->par; +int err; + + task =uvesafb_prep (); +if (!task) +return -ENOMEM ; + +if ((err =uvesafb_vbe_getinfo (task, par)))
checkpatch.pl will do my work here..
Quoted 43 lines
drivers/video/uvesafb.c new file +43
-0+ goto out; +if ((err =uvesafb_vbe_getmodes (task, par))) + goto out; + par->nocrtc = nocrtc; +#ifdef __i386__ + par->pmi_setpal = pmi_setpal; + par->ypan = ypan; + +if (par->pmi_setpal || par->ypan) +uvesafb_vbe_getpmi (task, par); +#else +/* The protected mode interface is not available on non-x86. */ + par->pmi_setpal = par->ypan =0 ; +#endif + +INIT_LIST_HEAD (&info->modelist); +uvesafb_vbe_getmonspecs (task, info); +uvesafb_vbe_getstatesize (task, par); + +out:uvesafb_free (task); +return err; +} + +static int __devinit uvesafb_vbe_init_mode (struct fb_info *info) +{ +struct list_head *pos; +struct fb_modelist *modelist; +struct fb_videomode *mode; +struct uvesafb_par *par = info->par; +int i, modeid; + +/* Has the user requested a specific VESA mode? */ +if (vbemode) { +for (i =0 ; i < par->vbe_modes_cnt; i++) { +if (par->vbe_modes[i].mode_id == vbemode) { +fb_get_mode (FB_VSYNCTIMINGS |FB_IGNOREMON ,60 , + &info->var, info); +/* With pixclock set to 0, the default BIOS +* timings will be used in set_par(). */ + info->var.pixclock =0 ; + modeid = i; + goto gotmode; + }
drivers/video/uvesafb.c line 765
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ } +printk (KERN_INFO "uvesafb: requested VBE mode 0x%x is " +"unavailable\n" , vbemode); + vbemode =0 ; + } + + i =0 ; +list_for_each (pos, &info->modelist) { + i++; + }
Unneeded braces
drivers/video/uvesafb.c line 767
Quoted 1 line
drivers/video/uvesafb.c new file +1
-0+ mode =kzalloc (i *sizeof (*mode),GFP_KERNEL );
Check for and handle the allocation failure, please.
Quoted 73 lines
drivers/video/uvesafb.c new file +73
-0+ i =0 ; +list_for_each (pos, &info->modelist) { + modelist = list_entry(pos, struct fb_modelist, list); + mode[i] = modelist->mode; + i++; + } + +if (!mode_option) + mode_option =UVESAFB_DEFAULT_MODE ; + + i =fb_find_mode (&info->var, info, mode_option, mode, i, +NULL ,8 ); + +kfree (mode); + +/* fb_find_mode() failed */ +if (i ==0 || i >=3 ) { + info->var.xres =640 ; + info->var.yres =480 ; + mode = (struct fb_videomode *) +fb_find_best_mode (&info->var, &info->modelist); + +if (mode) { +fb_videomode_to_var (&info->var, mode); + }else { + modeid = par->vbe_modes[0 ].mode_id; +fb_get_mode (FB_VSYNCTIMINGS |FB_IGNOREMON ,60 , + &info->var, info); + goto gotmode; + } + } + +/* Look for a matching VBE mode. */ + modeid =uvesafb_vbe_find_mode (par, info->var.xres, info->var.yres, + info->var.bits_per_pixel,UVESAFB_NEED_EXACT_RES ); + +if (modeid ==-1 ) +return -EINVAL ; + +gotmode: +uvesafb_setup_var (&info->var, info, &par->vbe_modes[modeid]); + +/* If we are not VBE3.0+ compliant, we're done -- the BIOS will +* ignore our mode timings anyway. */ +if (par->vbe_ib.vbe_version <0x0300 ) +fb_get_mode (FB_VSYNCTIMINGS |FB_IGNOREMON ,60 , + &info->var, info); + +return modeid; +} + +static int uvesafb_setpalette (struct uvesafb_pal_entry *entries,int count, +int start,struct fb_info *info) +{ +struct uvesafb_ktask *task; +struct uvesafb_par *par = info->par; +int i = par->mode_idx; +int err =0 ; + +/* We support palette modifications for 8 bpp modes only, so +* there can never be more than 256 entries. */ +if (start + count >256 ) +return -EINVAL ; + +/* Use VGA registers if mode is VGA-compatible. */ +if (i >=0 && i < par->vbe_modes_cnt && + par->vbe_modes[i].mode_attr &VBE_MODE_VGACOMPAT ) { +for (i =0 ; i < count; i++) { +outb_p (start + i, dac_reg); +outb_p (entries[i].red, dac_val); +outb_p (entries[i].green, dac_val); +outb_p (entries[i].blue, dac_val); + }
drivers/video/uvesafb.c line 850
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ }else if (par->pmi_setpal) { + __asm__ __volatile__( +"call *(%%esi)" + :/* no return value */ + :"a" (0x4f09 ),/* EAX */ +"b" (0 ),/* EBX */ +"c" (count),/* ECX */ +"d" (start),/* EDX */ +"D" (entries),/* EDI */ +"S" (&par->pmi_pal));/* ESI */
uh, so we're CONFIG_X86_32-only, yes?
Quoted 26 lines
drivers/video/uvesafb.c new file +23
-0+ }else { + task =uvesafb_prep (); +if (!task) +return -ENOMEM ; + + task->t.regs.eax =0x4f09 ; + task->t.regs.ebx =0x0 ; + task->t.regs.ecx = count; + task->t.regs.edx = start; + task->t.flags =TF_BUF_ESDI ; + task->t.buf_len =sizeof (struct uvesafb_pal_entry ) * count; + task->buf = (u8 *) entries; + + err =uvesafb_exec (task); +if ((task->t.regs.eax &0xffff ) !=0x004f ) + err =1 ; + +uvesafb_free (task); + } +return err; +} + +
drivers/video/uvesafb.c
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+static struct device_attribute device_attrs[] = { +__ATTR (vbe_version,S_IRUGO , uvesafb_show_vbe_ver,NULL ), +__ATTR (vbe_modes,S_IRUGO , uvesafb_show_vbe_modes,NULL ), +__ATTR (oem_vendor,S_IRUGO , uvesafb_show_vendor,NULL ), +__ATTR (oem_product_name,S_IRUGO , uvesafb_show_product_name,NULL ), +__ATTR (oem_product_rev,S_IRUGO , uvesafb_show_product_rev,NULL ), +__ATTR (oem_string,S_IRUGO , uvesafb_show_oem_string,NULL ), +__ATTR (nocrtc,S_IRUGO |S_IWUSR , uvesafb_show_nocrtc, + uvesafb_store_nocrtc), +};
Can we use an attribute group here?
drivers/video/uvesafb.c line 1546
Quoted 8 lines
drivers/video/uvesafb.c new file +8
-0+static void __devinit uvesafb_create_sysfs (struct device *dev, +struct fb_info *info) +{ +int i, err =0 ; + +for (i =0 ; i <ARRAY_SIZE (device_attrs); i++) { + err |=device_create_file (dev, &device_attrs[i]); + }
Unneeded braces
drivers/video/uvesafb.c line 1559
Quoted 12 lines
drivers/video/uvesafb.c new file +12
-0+if (err !=0 ) +printk (KERN_WARNING "fb%d: failed to register attributes\n" , + info->node); +} + +static void __devinit uvesafb_remove_sysfs (struct device *dev) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (device_attrs); i++) { +device_remove_file (dev, &device_attrs[i]); + }
ditto
Quoted 33 lines
drivers/video/uvesafb.c new file +33
-0+} + +static int __devinit uvesafb_probe (struct platform_device *dev) +{ +struct fb_info *info; +struct vbe_mode_ib *mode =NULL ; +struct uvesafb_par *par; +int err =0 , i; + + info =framebuffer_alloc (sizeof (*par) +sizeof (u32) *256 , &dev->dev); +if (!info) +return -ENOMEM ; + + par = info->par; + +if ((err =uvesafb_vbe_init (info))) { +printk (KERN_ERR "uvesafb: vbe_init() failed with %d\n" , err); + goto out; + } + + info->fbops = &uvesafb_ops; + + i =uvesafb_vbe_init_mode (info); +if (i <0 ) { + err = -EINVAL ; + goto out; + }else { + mode = &par->vbe_modes[i]; + } + +if (fb_alloc_cmap (&info->cmap,256 ,0 ) <0 ) { + err = -ENXIO ; + goto out;
drivers/video/uvesafb.c line 1602
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ } + +uvesafb_init_info (info, mode); + +if (!request_mem_region (info->fix.smem_start, info->fix.smem_len, +"uvesafb" )) { +printk (KERN_WARNING "uvesafb: cannot reserve video memory at " +"0x%lx\n" , info->fix.smem_start); +/* We cannot make this fatal. Sometimes this comes from magic +spaces our resource handlers simply don't know about. */
so... what happens? The driver starts altering mrmory regions which it doesn't own?
Quoted 103 lines
drivers/video/uvesafb.c new file +100
-0+ } + + info->screen_base =ioremap (info->fix.smem_start, info->fix.smem_len); + +if (!info->screen_base) { +printk (KERN_ERR +"uvesafb: abort, cannot ioremap 0x%x bytes of video " +"memory at 0x%lx\n" , + info->fix.smem_len, info->fix.smem_start); + err = -EIO ; + goto out_mem; + } + +if (!request_region (0x3c0 ,32 ,"uvesafb" )) { +printk (KERN_ERR "uvesafb: request region 0x3c0-0x3e0 failed\n" ); + err = -EIO ; + goto out_unmap; + } + +uvesafb_init_mtrr (info); +platform_set_drvdata (dev, info); + +if (register_framebuffer (info) <0 ) { +printk (KERN_ERR +"uvesafb: failed to register framebuffer device\n" ); + err = -EINVAL ; + goto out_reg; + } + +printk (KERN_INFO "uvesafb: framebuffer at 0x%lx, mapped to 0x%p, " +"using %dk, total %dk\n" , info->fix.smem_start, + info->screen_base, info->fix.smem_len/1024 , + par->vbe_ib.total_memory *64 ); +printk (KERN_INFO "fb%d: %s frame buffer device\n" , info->node, + info->fix.id); + +uvesafb_create_sysfs (&dev->dev, info); +return 0 ; + +out_reg: +release_region (0x3c0 ,32 ); +out_unmap: +iounmap (info->screen_base); +out_mem: +release_mem_region (info->fix.smem_start, info->fix.smem_len); +if (!list_empty (&info->modelist)) +fb_destroy_modelist (&info->modelist); +fb_destroy_modedb (info->monspecs.modedb); +fb_dealloc_cmap (&info->cmap); +out: +if (par->vbe_modes) +kfree (par->vbe_modes); + +framebuffer_release (info); +return err; +} +#ifndef MODULE +static int __devinit uvesafb_setup (char *options) +{ +char *this_opt; + +if (!options || !*options) +return 0 ; + +while ((this_opt =strsep (&options,"," )) !=NULL ) { +if (!*this_opt)continue ; + +if (!strcmp (this_opt,"redraw" )) + ypan =0 ; +else if (!strcmp (this_opt,"ypan" )) + ypan =1 ; +else if (!strcmp (this_opt,"ywrap" )) + ypan =2 ; +else if (!strcmp (this_opt,"vgapal" )) + pmi_setpal =0 ; +else if (!strcmp (this_opt,"pmipal" )) + pmi_setpal =1 ; +else if (!strncmp (this_opt,"mtrr:" ,5 )) + mtrr =simple_strtoul (this_opt+5 ,NULL ,0 ); +else if (!strcmp (this_opt,"nomtrr" )) + mtrr =0 ; +else if (!strcmp (this_opt,"nocrtc" )) + nocrtc =1 ; +else if (!strcmp (this_opt,"noedid" )) + noedid =1 ; +else if (!strcmp (this_opt,"noblank" )) + blank =0 ; +else if (!strncmp (this_opt,"vtotal:" ,7 )) + vram_total =simple_strtoul (this_opt +7 ,NULL ,0 ); +else if (!strncmp (this_opt,"vremap:" ,7 )) + vram_remap =simple_strtoul (this_opt +7 ,NULL ,0 ); +else if (!strncmp (this_opt,"maxhf:" ,6 )) + maxhf =simple_strtoul (this_opt +6 ,NULL ,0 ); +else if (!strncmp (this_opt,"maxvf:" ,6 )) + maxvf =simple_strtoul (this_opt +6 ,NULL ,0 ); +else if (!strncmp (this_opt,"maxclk:" ,7 )) + maxclk =simple_strtoul (this_opt +7 ,NULL ,0 ); +else if (!strncmp (this_opt,"vbemode:" ,8 )) + vbemode =simple_strtoul (this_opt +8 ,NULL ,0 ); +else if (this_opt[0 ] >='0' && this_opt[0 ] <='9' ) {
drivers/video/uvesafb.c line 1752
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ mode_option = this_opt; + }else { +printk (KERN_WARNING +"uvesafb: unrecognized option %s\n" , this_opt); + } + } + +return 0 ; +} +#endif /* !MODULE */
The #ifdef MODULE is unpleasing. Can we use module_param() here? That'll work for both modular and non-modular case.
drivers/video/uvesafb.c
Quoted 9 lines
drivers/video/uvesafb.c new file +9
-0+#define uvesafb_free (task) \ +do { \ + if (task) { \ + if (task->done) \ + kfree(task->done); \ + kfree(task); \ + task = NULL; \ + } \ +} while(0)
I don't think this need to be a macro? Code should be written in C unless there is some reason why it _must_ be a macro.
Oh, it sneakily zeroes a variable within the caller's context. Ow. Can we not do that please? Someone who is reading this code will see a call to a "function" called uvesafb_free() and the last thing they will expect is that "function" magically zeroed out a local variable.
drivers/video/uvesafb.c
Quoted 6 lines
drivers/video/uvesafb.c new file +6
-0+#define uvesafb_reset (task) \ +do { \ + struct completion *cpl = task->done; \ + memset(task, 0, sizeof(struct uvesafb_ktask)); \ + task->done = cpl; \ +} while(0) \
This can be a regular C function.
Quoted 17 lines
drivers/video/uvesafb.c new file +17
-0+static int uvesafb_exec (struct uvesafb_ktask *tsk); + +#define UVESAFB_NEED_EXACT_RES 1 +#define UVESAFB_NEED_EXACT_DEPTH 2 + +struct uvesafb_par { +struct vbe_ib vbe_ib;/* VBE Info Block */ +struct vbe_mode_ib *vbe_modes;/* list of supported VBE modes */ +int vbe_modes_cnt; + +u8 nocrtc; +u8 ypan;/* 0 - nothing, 1 - ypan, 2 - ywrap */ +u8 pmi_setpal;/* pmi for palette changes */ +u16 *pmi_base;/* protected mode interface location */ +void (*pmi_start)(void ); +void (*pmi_pal)(void ); +
drivers/video/uvesafb.c
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+u8 *vbe_state_orig;/* original hardware state, before the driver was loaded */ +u8 *vbe_state_saved;/* state saved by fb_save_state */ +int vbe_state_size; +atomic_t ref_count; + +int mode_idx; + struct vbe_crtc_ib crtc; +}; + +#endif
A comment on the endif would be nice.
Quoted 1 line
+#endif /*
_UVESAFB_H*/
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Sat, 23 Jun 2007 12:52:43 +0200 Michal Januszewski <[email protected]> wrote:
drivers/video/Kconfig +0
-0@@ -585,6 +585,24 @@ config FB_TGA
Quoted 7 lines
drivers/video/Kconfig config FB_TGA · line 590
Quoted 5 lines
drivers/video/Kconfig +3
-0Say Y if you have one of those. +config FB_UVESA + tristate "Userspace VESA VGA graphics support" + depends on FB && CONNECTORThese dependencies are insufficient.
What exactly is missing here? A dep on X86? This would indicate the arches on which the driver has actually been tested. But which arches are supported and which aren't is, in the end, up to the userspace helper.
Quoted 10 lines
drivers/video/Kconfig config FB_TGA · line 596
Quoted 6 lines
drivers/video/Kconfig +6
-0+static struct cb_id uvesafb_cn_id = { + .idx = CN_IDX_V86D, + .val = CN_VAL_V86D_UVESAFB +}; +static struct sock *nls; +static char v86d_path[PATH_MAX] = "/sbin/v86d";Remove the
PATH_MAX, save some memory.Oh, it gets set via sysfs. hrm.
Hmm, I guess I could make it a hard-coded value, but paths to userspace helpers should generally be configurable, right?
Quoted 3 lines
Now I'm wondering what this code actually does. It would be nice to have an overall design and implementation description in the changelog so we don't have to reverse-engineer your thoughts from your implementation...
OK, I'll include a more detailed description in the next round of the patches.
Quoted 6 lines
drivers/video/Kconfig config FB_TGA · line 597
Quoted 1 line
drivers/video/Kconfig +1
-0+#ifdef __i386__
CONFIG_X86would be more typical.Be aware that
CONFIG_X86is true for both i386 andx86_64. You don't state whether this code works onx86_64. If it can, it should.
AFAIK, it can't. PMI code is meant to be run in 32-bit protected mode. I'll add a note about this to the patch and change __i386__ to CONFIG_X86_32.
Quoted 3 lines
You might care to cc "H. Peter Anvin" <[email protected]> on the next version of this patch - he's a whizz at this sort of low-level x86 bios communication stuff.
Thanks, I'll do that.
Quoted 9 lines
drivers/video/Kconfig config FB_TGA · line 603
Quoted 6 lines
drivers/video/Kconfig +6
-0+ if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, + "uvesafb")) { + printk(KERN_WARNING "uvesafb: cannot reserve video memory at " + "0x%lx\n", info->fix.smem_start); + /* We cannot make this fatal. Sometimes this comes from magic + spaces our resource handlers simply don't know about. */so... what happens? The driver starts altering mrmory regions which it doesn't own?
Fixed. This was a leftover from vesafb.c. Are there any reasons for not fixing it there as well?
Quoted 49 lines
Quoted 49 lines
drivers/video/Kconfig +49
-0+#ifndef MODULE +static int __devinit uvesafb_setup(char *options) +{ + char *this_opt; + + if (!options || !*options) + return 0; + + while ((this_opt = strsep(&options, ",")) != NULL) { + if (!*this_opt) continue; + + if (!strcmp(this_opt, "redraw")) + ypan = 0; + else if (!strcmp(this_opt, "ypan")) + ypan = 1; + else if (!strcmp(this_opt, "ywrap")) + ypan = 2; + else if (!strcmp(this_opt, "vgapal")) + pmi_setpal = 0; + else if (!strcmp(this_opt, "pmipal")) + pmi_setpal = 1; + else if (!strncmp(this_opt, "mtrr:", 5)) + mtrr = simple_strtoul(this_opt+5, NULL, 0); + else if (!strcmp(this_opt, "nomtrr")) + mtrr = 0; + else if (!strcmp(this_opt, "nocrtc")) + nocrtc = 1; + else if (!strcmp(this_opt, "noedid")) + noedid = 1; + else if (!strcmp(this_opt, "noblank")) + blank = 0; + else if (!strncmp(this_opt, "vtotal:", 7)) + vram_total = simple_strtoul(this_opt + 7, NULL, 0); + else if (!strncmp(this_opt, "vremap:", 7)) + vram_remap = simple_strtoul(this_opt + 7, NULL, 0); + else if (!strncmp(this_opt, "maxhf:", 6)) + maxhf = simple_strtoul(this_opt + 6, NULL, 0); + else if (!strncmp(this_opt, "maxvf:", 6)) + maxvf = simple_strtoul(this_opt + 6, NULL, 0); + else if (!strncmp(this_opt, "maxclk:", 7)) + maxclk = simple_strtoul(this_opt + 7, NULL, 0); + else if (!strncmp(this_opt, "vbemode:", 8)) + vbemode = simple_strtoul(this_opt + 8, NULL,0); + else if (this_opt[0] >= '0' && this_opt[0] <= '9') { + mode_option = this_opt; + } else { + printk(KERN_WARNING + "uvesafb: unrecognized option %s\n", this_opt); + }
Quoted 8 lines
drivers/video/Kconfig
Quoted 5 lines
drivers/video/Kconfig +5
-0+ } + + return 0; +} +#endif /* !MODULE */The #ifdef MODULE is unpleasing. Can we use
module_param()here? That'll work for both modular and non-modular case.
True, but it would also make uvesafb the only (?) fb driver that doesn't support the "video=smthfb:<options>" way of setting options. Unless it's considered deprecated, I think it would be best to leave it as it is, for the sake of consistency.
Thanks for all your comments & suggestions, and I'm sorry for the screw-up with checkpatch.pl. I've fixed the code in my git tree and the updates will be included in the next version of this patch.
Best regards,
Michal
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Quoted 7 lines · On Sun, 24 Jun 2007 01:20:33 +0200 Michal Januszewski <[email protected]> wrote:
Quoted 5 lines
drivers/video/Kconfig config FB_TGA · line 590
Quoted 3 lines
drivers/video/Kconfig +3
-0+config FB_UVESA + tristate "Userspace VESA VGA graphics support" + depends on FB && CONNECTORThese dependencies are insufficient.
What exactly is missing here? A dep on X86?
Yes. From your other comments it appears that a dependency on X86_32 is needed.
Quoted 3 lines
This would indicate the
arches on which the driver has actually been tested. But which arches are supported and which aren't is, in the end, up to the userspace helper.
The other architectures won't compile: they don't have mtrr.h
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Quoted 42 lines
drivers/video/uvesafb.c new file +42
-0+static int uvesafb_blank (int blank,struct fb_info *info) +{ +struct uvesafb_par *par = info->par; +struct uvesafb_ktask *task; +int err =1 ; + +if (par->vbe_ib.capabilities &VBE_CAP_VGACOMPAT ) { +int loop =10000 ; +u8 seq =0 , crtc17 =0 ; + +if (blank ==FB_BLANK_POWERDOWN ) { + seq =0x20 ; + crtc17 =0x00 ; + err =0 ; + }else { + seq =0x00 ; + crtc17 =0x80 ; + err = (blank ==FB_BLANK_UNBLANK ) ?0 : -EINVAL ; + } + +vga_wseq (NULL ,0x00 ,0x01 ); + seq |=vga_rseq (NULL ,0x01 ) & ~0x20 ; +vga_wseq (NULL ,0x00 , seq); + + crtc17 |=vga_rcrt (NULL ,0x17 ) & ~0x80 ; +while (loop--); +vga_wcrt (NULL ,0x17 , crtc17); +vga_wseq (NULL ,0x00 ,0x03 ); + }else { + task =uvesafb_prep (); +if (!task) +return -ENOMEM ; + + task->t.regs.eax =0x4f10 ; +switch (blank) { +case FB_BLANK_UNBLANK : + task->t.regs.ebx =0x0001 ; +break ; +case FB_BLANK_NORMAL : + task->t.regs.ebx =0x0101 ;/* standby */ +break ; +case FB_BLANK_POWERDOWN :
drivers/video/uvesafb.c line 1033
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+ task->t.regs.ebx =0x0401 ;/* powerdown */ +break ; +default : + goto out; + } + task->t.flags =0 ; + + err =uvesafb_exec (task); +if (!err && (task->t.regs.eax &0xffff ) ==0x004f ) + err =0 ;
There is no effect to this assignment.
if (!err && ... ) err = 0;
Quoted 4 lines
drivers/video/uvesafb.c new file +4
-0+out:uvesafb_free (task); + } +return err; +}
[...]
Quoted 17 lines
drivers/video/uvesafb.c new file +17
-0+static int __devinit uvesafb_init (void ) +{ +int err; + +#ifndef MODULE +char *option =NULL ; + +if (fb_get_options ("uvesafb" , &option)) +return -ENODEV ; +uvesafb_setup (option); +#endif + err =cn_add_callback (&uvesafb_cn_id,"uvesafb" , uvesafb_cn_callback); +if (err) + goto err_out; + + err =platform_driver_register (&uvesafb_driver); +
drivers/video/uvesafb.c line 1794
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+if (!err) { + uvesafb_device =platform_device_alloc ("uvesafb" ,0 ); +if (uvesafb_device) + err =platform_device_add (uvesafb_device); +else + err = -ENOMEM ; + +if (err) { +platform_device_put (uvesafb_device); +platform_driver_unregister (&uvesafb_driver);
Initialization failed. It should return from this function here. Otherwise it will attempt to call driver_create_file() with unregistered driver below.
And you forgot to put:
cn_del_callback(&uvesafb_cn_id);
Quoted 5 lines
drivers/video/uvesafb.c new file +5
-0+ } + + err =driver_create_file (&uvesafb_driver.driver, + &driver_attr_v86d); +if (err) {
drivers/video/uvesafb.c line 1809
Quoted 10 lines
drivers/video/uvesafb.c new file +10
-0+printk (KERN_WARNING "uvesafb: failed to register " +"attributes\n" ); + err =0 ; + } + } +return err; + +err_out: +if (nls && nls->sk_socket) +sock_release (nls->sk_socket);
I can't find any uses of nls in this driver.
Quoted 2 lines
(quoted diff) +2
-0+ return err; +}
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Sun, 24 Jun 2007 01:20:33 +0200 Michal Januszewski <[email protected]> wrote:
Quoted 5 lines
drivers/video/Kconfig config FB_TGA · line 590
Quoted 3 lines
drivers/video/Kconfig +3
-0+config FB_UVESA + tristate "Userspace VESA VGA graphics support" + depends on FB && CONNECTORThese dependencies are insufficient.
Quoted 4 lines
Quoted 1 line
What exactly is missing here? A dep on X86?
Yes. From your other comments it appears that a dependency on
X86_32is needed.
X86_32 is only needed for a bunch of specific operations that make use of the PMI. The driver can work without those (it has already been tested on X86_64, where PMI cannot be used).
Quoted 5 lines
Quoted 3 lines
This would indicate the
arches on which the driver has actually been tested. But which arches are supported and which aren't is, in the end, up to the userspace helper.The other architectures won't compile: they don't have
mtrr.h
That was my mistake of not putting the mtrr.h include inside a #ifdef CONFIG_MTRR. After fixing that and a few other things you pointed out in your previous message, I was able to successfully compile uvesafb for PPC (using a cross-compiler).
Best regards,
Michal
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/