# vesa driver already for amd64!



## paradox (Aug 14, 2009)

tested on amd64 freebsd 8 current/stable

http://paradox.lissyara.su/vesa.tar.bz2

add to kernel conf "options SC_PIXEL_MODE"
and rebuild kernel

after reboot

```
tar xjvf vesa.tar.bz2
cd vesa
make
make load
```

use

```
vidcontrol -i mode
```
to show graphics modes

on my NVIDIA card iam use a MODE_277
800x600x32

to use it

```
vidcontrol MODE_277
```

ps:
any 32bit/16bit modes will be work
8bit not tested yet

to support 8bit depth
need my old patch for scvgarndr.c
http://www.freebsd.org/cgi/query-pr.cgi?pr=124902

to be continue


----------



## aragon (Aug 14, 2009)

Wow, have you PR'd this yet?  This looks like a huge chunk of work (particularly the x86 emulation).

Will try it out soon.


----------



## paradox (Aug 14, 2009)

no its little work within one day
x86emu taked from openbsd

I think this driver will work under the i386 arch too


----------



## zeiz (Aug 16, 2009)

I am using vesa on 8.0 from ports. It's not nvidia but works pretty fine if no effects enabled.
Please explain how this driver differ from the one in ports?


----------



## john_doe (Aug 16, 2009)

Unlike X11 driver, vesa(4) allows you to set graphic modes for *console* so you can view images or play video without leaving it.

Ex.:
with sysutils/jfbterm you can get not limited to 256 chars unicode support
www/w3m allows you to browse www sites with images on jfbterm
using libSDL + libvgl you can play some videos or graphical games
all the while Xserver is *not* running


----------



## zeiz (Aug 16, 2009)

WOW! Thanks a lot!

...but where the tarball is? 
Tried http://paradox.lissyara.su, http://www.paradox.lissyara.su, ftp://ftp.paradox.lissyara.su...where it is?


----------



## paradox (Aug 16, 2009)

the tarball is
http://paradox.lissyara.su/vesa.tar.bz2


----------



## zeiz (Aug 16, 2009)

Got it. Thanks!


----------



## paradox (Aug 17, 2009)

continued

http://paradox.lissyara.su/8bit.patch

```
cp 8bit.patch /usr/src
patch -p1 < 8bit.patch
```
and rebuild yr kernel

this patch allow the console to switch in the 8bit modes
from a list

```
vidcontrol -i mode
```


----------



## paradox (Aug 18, 2009)

continued

http://paradox.lissyara.su/syscons.c.diff for freebsd 8 stable

```
cp syscons.c.diff /usr/src
patch -p1 < syscons.c.diff
```
and rebuild yr kernel

this is patch to allow switch the console to graphic mode early at boot time
the new flags is hint.sc.0.flags=0x01150180
where
0x100 - the flag for keyboard (used by default in freebsd)
0x80 - flag to switch the graphic console at boot(new flag)
0x0115 - the graphic mode that can be see from vidcontrol -i mode(new flag)
add this flag 0xXXX mode after testing with vidcontorl MODE_****
as example MODE_277 is 0x0115

all virtual console will be to switched to new graphic mode

don't forget the install vesa driver  and add to loader.conf vesa_load="YES" options

dont use any more allscreens_flags= in rc.conf
becouse its clear boot log in console


----------



## gnemmi (Aug 21, 2009)

will this make it into BETA3?


----------



## paradox (Aug 21, 2009)

yes


----------



## gnemmi (Aug 22, 2009)

paradox, thanks for your work man !

I just gave it a go on my BETA2 install (Dell 1318 notebook, i386, Celeron(R) CPU 560 @ 2.13GHz) and it works OK.

I used the same hint (hint.sc.0.flags=0x01150180) you used because any resolution above 800x600 is way too high (1280x800, native resolution, would be unusable ... yet still it's not even available anyways). I couldn't figure out why "0x0115" if vidcontrol -i mode reports "0x115"?

So far the catch seems to be that the resolution goes up as soon as sc0 gets loaded (wich happens to be halfway through the boot process ... so the first half of the boot process looks big and the second half looks as expected at 800x600x32).

The only problem I found is that if I use "vesa" instead of "i915" I don't get the screen back when I resume from supend (acpiconf -s 3)

Really nice job .. will be looking forward to try your next patches 

Best Regards
Gonzalo


----------



## paradox (Aug 22, 2009)

the value 0x0115 and 0x115 the same
suspend not tested yet


----------



## paradox (Aug 22, 2009)

> will this make it into BETA3?


what you mean?

will be included in beta3 this patch?
or
Is it possible to apply this patch to beta3?


----------



## macbias (Aug 22, 2009)

S-w-e-e-e-e-e-t


----------



## gnemmi (Aug 22, 2009)

I meant if this patch was going to be included into BETA3


----------



## paradox (Aug 22, 2009)

i don't know


----------



## aragon (Aug 22, 2009)

I highly doubt it.  Maybe 8.1.


----------



## joel@ (Aug 23, 2009)

If you want something committed to the FreeBSD svn repository, find someone who can review and commit it for you, or send a PR with the patch.


----------



## nickolas (Aug 24, 2009)

john_doe said:
			
		

> I've made a port (vesa-kmod.diff) based on *paradox*'s work. It should work on 7.x as well. Anyone wants to test/comment?
> 
> To apply use
> `$ cd /usr/ports`
> ...



It doesn't works:

```
vidcontrol: obtaining new video mode parameters: Operation not supported by device
```


```
# uname -a
FreeBSD cloud.zone 7.2-STABLE FreeBSD 7.2-STABLE #38: Sun Aug  2 16:40:23 EEST 2009     root@cloud.zone:/usr/obj/usr/src/sys/CLOUD  amd64
```

If I write in loader.conf:

```
vesa_load="YES"
hint.sc.0.flags="0x01150180"
```

I got a blank screen.


----------



## paradox (Aug 24, 2009)

add to kernel conf "options SC_PIXEL_MODE"
and rebuild kernel


----------



## nickolas (Aug 24, 2009)

paradox said:
			
		

> add to kernel conf "options SC_PIXEL_MODE"
> and rebuild kernel



No change.
I've use john_doe's port. 
Meybe it's better use your kernel patch?


----------



## paradox (Aug 24, 2009)

show me your 

```
vidcontrol -i mode
```
after load vesa.ko


----------



## paradox (Aug 24, 2009)

> hint.sc.0.flags="0x01150180"


this flag allowed only on freebsd 8/9
not for freebsd 7

you can use only the 

```
allscreens_flags="MODE_277"
```
in rc.conf
as example
to switch the graphic console after boot


----------



## nickolas (Aug 24, 2009)

paradox said:
			
		

> you can use only the
> 
> ```
> allscreens_flags="MODE_277"
> ```



Now it works, thank you!


----------



## paradox (Sep 11, 2009)

all patches already in 9-current


----------



## Bas (Sep 26, 2009)

```
[bas@gw /usr/ports/misc/vesa-kmod]# make
===>  Building for vesa-kmod-20090921
===> dpms (all)
Warning: Object directory not changed from original /usr/ports/misc/vesa-kmod/work/vesa-20090921/dpms
===> s3 (all)
Warning: Object directory not changed from original /usr/ports/misc/vesa-kmod/work/vesa-20090921/s3
===> vesa (all)
Warning: Object directory not changed from original /usr/ports/misc/vesa-kmod/work/vesa-20090921/vesa
/usr/local/libexec/ccache/cc -O2 -fno-strict-aliasing -pipe  -D_KERNEL -DKLD_MODULE -std=c99 -nostdinc   -I. -I@ -I@/contrib/altq -finline-
limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -g -fno-omit-frame-pointer -mcmodel=kernel 
-mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow  -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -Wall 
-Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign 
-fformat-extensions -c vesa.c
vesa.c: In function 'vesa_map_buffer':
vesa.c:858: error: 'PAT_WRITE_COMBINING' undeclared (first use in this function)
vesa.c:858: error: (Each undeclared identifier is reported only once
vesa.c:858: error: for each function it appears in.)
*** Error code 1

Stop in /usr/ports/misc/vesa-kmod/work/vesa-20090921/vesa.
*** Error code 1

Stop in /usr/ports/misc/vesa-kmod/work/vesa-20090921.
*** Error code 1

Stop in /usr/ports/misc/vesa-kmod.
```


```
[bas@gw /usr/home/bas]# uname -a
FreeBSD gw.*.ru 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Sat Sep 26 17:02:24 PETST 2009     bas@gw.*.ru:/usr/src/sys/amd64/compile/GW  amd64
```

May be some fixes or i do something wrong?


----------



## john_doe (Sep 26, 2009)

I think r197323 wasn't meant for 7.2 release. I've added
	
	



```
.if ${OSVERSION} < 702106
EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-vesa.c
.endif
```
Can you redownload vesa-kmod.diff and try again?


----------



## Bas (Sep 27, 2009)

john_doe said:
			
		

> Can you redownload vesa-kmod.diff and try again?


Great job, man! Tnx. Now all work properly.


----------



## HUNTERok (Dec 2, 2009)

http://paradox.lissyara.su/vesa.tar.bz2

link broken, reupload plz.


----------



## HUNTERok (Dec 3, 2009)

HUNTERok said:
			
		

> http://paradox.lissyara.su/vesa.tar.bz2
> 
> link broken, reupload plz.



up pls )


----------



## robbak (Dec 3, 2009)

ngls brkn, pls rpst


----------



## paradox (Dec 8, 2009)

see at post #11


----------



## Jamz (Dec 15, 2009)

*8.0-release ?*

Anyone tried this on 8-RELEASE ?

The syscons stuff doesn't seem to work for me, tried it on i386 and amd64, both the same. I can change resolution via vidcontrol after boot but the flags in loader.conf don't seem to do anything. I can see from dmesg that they're being picked up by sc0 but the res never changes.

Any ideas ?


----------



## paradox (Dec 16, 2009)

are you correct load the modules vesa.ko and rebuild kernel?
look at the post #1 and use the port from post #11


----------



## Jamz (Dec 16, 2009)

The driver and patches were installed via the port on post #11, kernel was rebuilt with 'options SC_PIXEL_MODE' and I can set 1280x1024x32 (MODE_283) after boot.

vidcontrol -i mode


```
283 (0x11b) 0x0000000f G 1280x1024x32 1  8x16  0xa0000 64k 64k 0xe8000000 8000k
```

kldstat 


```
Id Refs Address    Size     Name
 1    5 0xc0400000 b70ec4   kernel
 2    1 0xc0f71000 6a9c     vesa.ko
 3    2 0xc0f78000 1026c    x86bios.ko
```

cat /boot/loader.conf


```
module_path="/boot/modules;/boot/kernel"
vesa_load="YES"
hint.sc.0.flags="0x11b0180"
```

dmesg


```
sc0: <System console> at flags 0x11b0180 on isa0
sc0: VGA <16 virtual consoles, flags=0x11b0380>
```


----------



## Jamz (Dec 17, 2009)

I've done a bit more fiddling and it looks like an issue with the onboard video card in this Dell GX270 (the i386 PC, see below).


```
vgapci0: <VGA-compatible display> port 0xed98-0xed9f mem 0xe8000000-0xefffffff,0xfeb80000-0xfebfffff irq 16 at device 2.0 on pci0
agp0: <Intel 82865G (865G GMCH) SVGA controller> on vgapci0
agp0: detected 8060k stolen memory
agp0: aperture size is 128M
```

I've found and fitted an old half-height ATI Rage Pro 128 AGP card and now I get a nice black screen mid-way through boot (yey!).

The black screen isn't related to your stuff as I pretty much can't get any graphical resolutions with this card using yours or the default vesa driver.

The amd64 box is also a Dell (745) which I believe has an intel card too, I'll check when I get to work tomorrow.


----------



## john_doe (Dec 17, 2009)

The flags in loader.conf are meant only for 9.0-CURRENT. They touch dev/syscons/syscons.c that's not part of any module. Look at r197085 and subsequent commits. I think it shouldn't be hard to backport them. IOW, r197085 looks almost exactly like the patch in #10 looked.

FYI, the port is just a fairly old snapshot. Expect things more improved in HEAD.


----------



## paradox (Dec 17, 2009)

*Jamz*
turn on verbose (by sysctl) to show the whole process of recognition of your BIOS VESA


----------



## bigwillyg (Dec 18, 2009)

excellent, I applied the vesa-kmod.diff patch and then installed the vesa-kmod port. I loaded the vesa.ko after a reboot and I now have 1024x768 on my freebsd-8.0 system. Thanks so much.


----------



## aragon (Dec 18, 2009)

What is the status of this being committed to the project's source?  Has it been PR'd or reviewed by any FreeBSD committers yet?


----------



## bigwillyg (Dec 18, 2009)

something odd though, even though I can do "vidcontrol MODE_280" manually, it wont take it in the allscreens_flags in rc.conf nor will it work with the hints line in the loader.conf

Am I missing something?


----------



## john_doe (Dec 19, 2009)

aragon said:
			
		

> What is the status of this being committed to the project's source?  Has it been PR'd or reviewed by any FreeBSD committers yet?


See #28 post in this thread. Ping delphij@ for MFC in 7.x/8.x.





			
				bigwillyg said:
			
		

> it wont take it in the allscreens_flags in rc.conf


Do you have vesa_load=YES in loader.conf? allscreen_flags basically does same thing as vidcontrol MODE_280. It won't change mode to a graphic one unless vesa.ko is loaded.
	
	



```
# set this mode for all virtual screens
        #
        if [ -n "${allscreens_flags}" ]; then
                sc_init
                echo -n ' allscreens'
                for ttyv in /dev/ttyv*; do
                        vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1
                done
        fi
```


----------



## bigwillyg (Dec 19, 2009)

Yes, I have added VESA_load="yes" into the loader.conf. But the allscreens_flags in rc.conf isn't being read.


----------



## macbias (Jan 10, 2010)

i can't get this to work on my  new setup 8.0R-p2 amd64.
i am getting just a black screen on some modes and some other modes even put the monitor in power saving modes.
can someone explain post #41? debug.bootverbose in loader.conf?


----------



## sng84 (Feb 18, 2010)

Hi guys

I decided to test this patch (i used ports version), everything is ok until i will not start Xorg, then when i'm switching between console and X, i'm getting odd colors on console, text which should be white turnes blue etc. When i try to shutdown system my box hangs

Amd64, FreeBSD 8-STABLE, Tyan K8SD PRO, PowerColor RadeonHD 2400 PCI

Regards


----------



## thuglife (Mar 6, 2010)

The driver got MFCed to 8-STABLE , yay!

http://svn.freebsd.org/viewvc/base?view=revision&revision=204546


----------



## val (Mar 11, 2010)

Hm, may be on amd64 it works, but on i386 it doesn't


----------



## aragon (May 10, 2010)

I tried this today in 8-STABLE.  Works awesomely!  Complements to the chef. 

Has anyone figured out how to correctly craft hint.sc.0.flags so that the kernel sets a mode at bootup other than 800x600x32?


----------



## aragon (May 11, 2010)

Figured it out.  It appears to be incorrectly documented in syscons(4).  Setting the high 16 bits of hint.sc.0.flags will get you no where.  You need to set hint.sc.0.vesa_mode in /boot/loader.conf.  For example, the kernel sets 1024x768x16 for me with this:


```
hint.sc.0.flags=0x0180
hint.sc.0.vesa_mode=0x0117
```

0x0117 is taken from
`# vidcontrol -i mode`
(MODE_279)

A little bit better than allscreens_flags in rc.conf.


----------



## john_doe (May 11, 2010)

delphij@ incorrectly merged r197109 vs. r204546
It's properly documented in /head.


----------



## Markand (Feb 6, 2011)

paradox said:
			
		

> continued
> 
> http://paradox.lissyara.su/syscons.c.diff for freebsd 8 stable
> 
> ...



Hi, 

I wanted to do the same thing :


```
496 (0x1f0) 0x0000001f G 1366x768x32 D   8x16  0xa0000 64k 64k 0xc0000000 4128k
```

This is the mode I want so I modified hint.sc.0.flags to 
	
	



```
hint.sc.0.flags="0x1f00180"
```
 but it seems to use 1024x768 resolution (or something else but not 1366x768).

It works after the boot if I do vidcontrol MODE_496 so I don't know...


----------



## xibo (Feb 10, 2011)

Can't try it right now ( am on Windows OS ), but I think you're supposed to use

```
hint.sc.0.flags=0x180
hint.sc.0.vesa_mode=0xYYY
```
where YYY is the hexadecimal form of the decimal number suffix to MODE_ according to post 51. In your case that would be

```
hint.sc.0.flags=0x180
hint.sc.0.vesa_mode=0x1f0
```


----------



## busyboy (Mar 16, 2011)

Can someone please share an active link for Vesa Module for FreeBSD/AMD64. Thanks


----------



## break19 (Nov 30, 2011)

busyboy said:
			
		

> Can someone please share an active link for Vesa Module for FreeBSD/AMD64. Thanks



Uhm, sure /boot/kernel/vesa.ko, if you run FreeBSD AMD64 8.2 or greater.

In other words: you already have it.


----------

