History log of /netbsd-current/sys/dev/wsfb/genfb.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.91 20-Jan-2024 jmcneill

wsfb: add support for optional "devcmap" property

A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.90 01-Aug-2022 riastradh

genfb: Handle uninitialized softc in genfb_enable/disable_polling.

This can happen due to janky MD kludgerosity like x86
x86_genfb_ddb_trap_callback, which should really be cleaned up, but
at least this might help with the recursive traps we've been seeing
in syzbot.


# 1.89 17-Jul-2022 riastradh

genfb(4): Make internal parts of struct genfb_softc private.

This way the ABI has no ifdefs, so it has a chance to be usable in
modules. This also makes genfb much easier to maintain without
worrying about ABI breakage.


# 1.88 17-Jul-2022 riastradh

genfb(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics. No other functional change.


# 1.87 09-Jul-2022 rin

Fix GENFB_GLYPHCACHE with shadow fb.


# 1.86 28-Mar-2022 mlelstv

Add helper to detach genfb console.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.90 01-Aug-2022 riastradh

genfb: Handle uninitialized softc in genfb_enable/disable_polling.

This can happen due to janky MD kludgerosity like x86
x86_genfb_ddb_trap_callback, which should really be cleaned up, but
at least this might help with the recursive traps we've been seeing
in syzbot.


# 1.89 17-Jul-2022 riastradh

genfb(4): Make internal parts of struct genfb_softc private.

This way the ABI has no ifdefs, so it has a chance to be usable in
modules. This also makes genfb much easier to maintain without
worrying about ABI breakage.


# 1.88 17-Jul-2022 riastradh

genfb(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics. No other functional change.


# 1.87 09-Jul-2022 rin

Fix GENFB_GLYPHCACHE with shadow fb.


# 1.86 28-Mar-2022 mlelstv

Add helper to detach genfb console.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.89 17-Jul-2022 riastradh

genfb(4): Make internal parts of struct genfb_softc private.

This way the ABI has no ifdefs, so it has a chance to be usable in
modules. This also makes genfb much easier to maintain without
worrying about ABI breakage.


# 1.88 17-Jul-2022 riastradh

genfb(4): KASSERT(a && b) -> KASSERT(a); KASSERT(b)

Better diagnostics. No other functional change.


# 1.87 09-Jul-2022 rin

Fix GENFB_GLYPHCACHE with shadow fb.


# 1.86 28-Mar-2022 mlelstv

Add helper to detach genfb console.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.87 09-Jul-2022 rin

Fix GENFB_GLYPHCACHE with shadow fb.


# 1.86 28-Mar-2022 mlelstv

Add helper to detach genfb console.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.86 28-Mar-2022 mlelstv

Add helper to detach genfb console.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.85 24-Dec-2021 jmcneill

wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.84 30-Aug-2021 jmcneill

Add 10-bit pixel format support.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.83 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.82 24-Apr-2021 thorpej

branches: 1.82.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.82 24-Apr-2021 thorpej

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.81 27-Jan-2021 macallan

branches: 1.81.2;
add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


# 1.78 19-Oct-2020 rin

branches: 1.78.2;
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.81 27-Jan-2021 macallan

add optional glyph cache for genfb
enable with options GENFB_GLYPHCACHE=n
with n being the desired size of the cache in MB. Should be enough to cache
at least 900 glyphs in whatever video mode used in order to be effective
in 32bit per pixel that's about 1MB


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


Revision tags: thorpej-futex-base
# 1.78 19-Oct-2020 rin

Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.80 26-Jan-2021 macallan

remove outdated comment


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


Revision tags: thorpej-futex-base
# 1.78 19-Oct-2020 rin

Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.79 17-Jan-2021 jmcneill

Prefer printing the framebuffer's PA instead of VA. It's much more useful..


Revision tags: thorpej-futex-base
# 1.78 19-Oct-2020 rin

Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.78 19-Oct-2020 rin

Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


# 1.77 18-Oct-2020 rin

Revert rev 1.75; do not set WSFB_VRAM_IS_RAM flag bit. It indicates
memory type obtained by mmap. I just misunderstood its intention.

Thanks to jmcneill for pointing it out!


# 1.76 18-Oct-2020 rin

Remove stray TABs. No binary changes.


# 1.75 18-Oct-2020 rin

For WSDISPLAYIO_GET_FBINFO ioctl, set WSFB_VRAM_IS_RAM to fbi_flags
when shadow FB is used.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.74 11-Jun-2020 thorpej

Update for proplib(3) API changes.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.73 30-May-2020 jdolecek

reduce stack usage in genfb_calc_hsize()


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

branches: 1.71.4;
Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

branches: 1.61.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.72 13-Apr-2020 msaitoh

Get genfb's address offset correctly when the vaule >= 4G. OK's by jmcneill.

Tested on Intel BXNUC10I3FNK (Comet Lake U).


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.71 23-Feb-2020 martin

Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

branches: 1.70.2;
Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.71 23-Feb-2020 martin

Do not replay the msgbuf if we are booting silent or quiet.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.70 09-Aug-2019 rin

Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

branches: 1.67.2;
Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.70 09-Aug-2019 rin

Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69

is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.


# 1.69 07-Aug-2019 rin

We support anti-aliasing for depth 2.
Use switch appropriately.


# 1.68 02-Aug-2019 rin

Notify size of shadow framebuffer if enabled.


Revision tags: netbsd-9-base
# 1.67 29-Jul-2019 rin

Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.67 29-Jul-2019 rin

Enable anti-aliasing for depth 24.
Style.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.66 28-Jul-2019 rin

sys/dev/rasops routines support anti-aliasing for depths 15 and 16.


Revision tags: phil-wifi-20190609
# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

branches: 1.63.2;
Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.65 31-May-2019 jmcneill

If an EDID is available, attempt to use the screen size to influence font
selection by passing a "wantcols" value to rasops_init that is satisfied
by a font that is at least 3mm wide.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.64 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315
# 1.63 06-Mar-2018 mlelstv

Fix cmap bounds checking.


Revision tags: pgoyette-compat-base
# 1.62 21-Jan-2018 christos

branches: 1.62.2;
CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.62 21-Jan-2018 christos

CID-1427771: Remove incorrect pre-condition (index cannot be 256!)


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.61 01-Jun-2017 chs

remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.60 19-May-2017 macallan

enable font loading and screen resizing


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

branches: 1.58.2; 1.58.4;
Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.


# 1.59 25-Feb-2017 nonaka

genfb(4): Enabling/Disabling shadowfb can be controlled via prop.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.58 01-Jun-2015 nat

Fix splashscreen on resolutions where text is centered.

This commit was approved by macallan@


Revision tags: nick-nhusb-base-20150406
# 1.57 20-Mar-2015 jmcneill

support 24bpp framebuffers


Revision tags: nick-nhusb-base
# 1.56 10-Sep-2014 macallan

branches: 1.56.2;
handle WSDISPLAYIO_GET_EDID and WSDISPLAYIO_GET_FBINFO only if the bus
frontend doesn't ( as in, returns EPASSTHROUGH or doesn't register a
handler )
Now flags passed from things like bcm2835_genfb.c are actually seen by
xf86-video-wsfb again and automatically disabling shadowfb works again,
which results in a major speedup on this kind of hardware.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.55 24-Jul-2014 riastradh

branches: 1.55.2;
Add enable/disable polling hooks to genfb_ops.


# 1.54 22-Jul-2014 riastradh

Do not printf(foobar()). Bad bad bad bad bad!


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.53 18-Mar-2014 riastradh

branches: 1.53.2;
Merge riastradh-drm2 to HEAD.


Revision tags: riastradh-drm2-base3
# 1.52 22-Jan-2014 skrll

Provide a wsdisplay_accessops.pollc

This makes sure that the screen gets painted properly during early boot
input (e.g. boot -a) on the Raspberry PI.


# 1.51 09-Oct-2013 macallan

support WSDISPLAYIO_GET_FBINFO


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.50 10-Jan-2013 jmcneill

branches: 1.50.2; 1.50.8;
for WSDISPLAYIO_SMODE, if the bus ioctl handler returns EPASSTHROUGH, dont treat it as an error


# 1.49 09-Jan-2013 jmcneill

aprint_verbose -> aprint_debug


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4
# 1.48 12-Apr-2012 macallan

branches: 1.48.2;
in 32 bit colour assume RGB ordering, allow override using a device property


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.47 07-Feb-2012 phx

branches: 1.47.2;
On 8-bit screens only enable font anti-aliasing when the cmap_callback
property is defined. It is needed for a suitable R3G3B2 color map.
Ok by releng@


# 1.46 11-Jan-2012 macallan

use rasops_init(0, 0)


# 1.45 04-Jan-2012 macallan

support anti-aliased fonts in 8 bit, generate an appropriate colour map


# 1.44 28-Dec-2011 macallan

if the cursor row passed in a device property doesn't fit on the screen just
ignore it and clear the screen


# 1.43 22-Dec-2011 macallan

support anti-aliased fonts in 32bit colour


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 13-Jul-2011 macallan

branches: 1.42.2; 1.42.6;
use callbacks that match the ioctl() interface to control backlight


Revision tags: rmind-uvmplock-nbase rmind-uvmplock-base
# 1.41 02-Jun-2011 macallan

some steps to make multiple instances work:
- don't bail if we're not the console. If we get the right paramters there is no
reason not to work
- move wsdisplay_accessops into the softc
- call wsdisplay_cnattach only if we're the console


Revision tags: cherry-xenmp-base
# 1.40 08-Mar-2011 macallan

branches: 1.40.2;
fix build for LP32
thanks to uebayasi@


# 1.39 08-Mar-2011 macallan

look for a 'virtual_address' property and use it as fb address


Revision tags: bouyer-quota2-nbase
# 1.38 22-Feb-2011 jmcneill

genfb_enable/disable_polling only matters if genfb is the console screen,
so make it a noop if it's not


# 1.37 18-Feb-2011 jmcneill

call vcons_hard_switch to switch to the console screen when entering polling
mode, makes ddb-from-X work with genfb on x86


Revision tags: bouyer-quota2-base
# 1.36 12-Feb-2011 phx

Fixed NULL-pointer dereferencing when a mode-callback is not defined.


# 1.35 09-Feb-2011 jmcneill

add vcons_{enable,disable}_polling and genfb_{enable,disable}_polling
functions, to switch between intr and polling modes when VCONS_DRAW_INTR
is defined


# 1.34 08-Feb-2011 jmcneill

add a 'setmode' callback to genfb and use it to setup write-combining
MTRRs on x86 whenever switching to WSDISPLAYIO_MODE_EMUL


# 1.33 06-Feb-2011 jmcneill

- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11
# 1.32 07-Oct-2010 macallan

branches: 1.32.2; 1.32.4;
finish device_t-ification


# 1.31 06-Oct-2010 macallan

add support for backlight control via machine dependent callbacks


# 1.30 31-Aug-2010 macallan

make use of a shadow framebuffer optional, use VCONS_DONT_READ by default


Revision tags: uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.29 22-Feb-2010 ahoka

branches: 1.29.2;
Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue


Revision tags: uebayasi-xip-base matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.28 24-Aug-2009 jmcneill

branches: 1.28.2;
Expose genfb_restore_palette and allow MD code to specify PMF callbacks.


# 1.27 20-Aug-2009 macallan

call vcons_replay_msgbuf()


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.26 21-Feb-2009 christos

s/long/intptr_t/


# 1.25 20-Feb-2009 dogcow

sparc complains "cast to pointer from integer of different size"; cast the
int to (void *)(long).


# 1.24 20-Feb-2009 jmcneill

If the bus glue provides an ioctl handler, don't return before we have a
chance to perform generic handling in the WSDISPLAYIO_SMODE case.

ok macallan


# 1.23 17-Feb-2009 jmcneill

Use kmem_alloc instead of malloc for shadowfb


# 1.22 17-Feb-2009 jmcneill

Print the physical address if available instead of a virtual address.


# 1.21 17-Feb-2009 jmcneill

Add clear-screen and cursor-row properties to allow genfb to persist
screen state from the MD console driver.


# 1.20 16-Feb-2009 jmcneill

Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.


# 1.19 15-Feb-2009 jmcneill

Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.


# 1.18 14-Feb-2009 jmcneill

Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base mjf-devfs2-base
# 1.17 29-Apr-2008 martin

branches: 1.17.8; 1.17.14;
Convert to new 2 clause license


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.16 05-Apr-2008 cegger

branches: 1.16.2; 1.16.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.15 09-Mar-2008 phx

missing newline in message


# 1.14 09-Mar-2008 phx

Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.


Revision tags: nick-net80211-sync-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.13 17-Dec-2007 macallan

branches: 1.13.2; 1.13.6;
deal with a bug in the Sun Raptor's firmware which reports
linebytes == width even in 32bit colour


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base jmcneill-pm-base
# 1.12 19-Nov-2007 macallan

branches: 1.12.2; 1.12.6;
sprinkle \n


Revision tags: jmcneill-base
# 1.11 05-Nov-2007 macallan

branches: 1.11.2;
don't panic if we're not finding all the properties we need. Just complain
quietly and return.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.10 30-Aug-2007 jmmv

branches: 1.10.2; 1.10.6;
Clear the screen during initialization so that the first messages are not
printed over "unknown garbage" (e.g. the Mac OS desktop). Agreed with
macallan@.


# 1.9 30-Aug-2007 jmmv

Print some details of the framebuffer configuration during attach.
OK'ed by macallan@.


# 1.8 30-Aug-2007 jmmv

Properly initialize the palette registers by calling the colormap callback
on all of them. A typo made it only initialize half of them. OK'ed by
macallan@.


# 1.7 24-Aug-2007 macallan

branches: 1.7.2;
use bool with prop_dictionary_get_bool()


Revision tags: matt-mips64-base
# 1.6 05-Aug-2007 macallan

branches: 1.6.2;
fix typo - fbsize is /height/ * stride. Doh.


# 1.5 04-Aug-2007 macallan

add shadow fb support
now genfb is actually usable even on slow PCI framebuffers. Yay Jared :)


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base yamt-idlelwp-base8
# 1.4 14-Apr-2007 macallan

branches: 1.4.2; 1.4.4; 1.4.8;
add a callback to change the colour map
so now X with wsfb on top of genfb should look right


Revision tags: thorpej-atomic-base
# 1.3 11-Apr-2007 macallan

add WSDISPLAYIO_LINEBYTES support so we can run XFree86 with wsfb


# 1.2 10-Apr-2007 macallan

branches: 1.2.2;
- move all memory mapping into the bus frontend
- get rid of macppc-isms like *_mmap() returning physical addresses


# 1.1 07-Apr-2007 macallan

add genfb, a generic framebuffer console driver that's configured via
device properties - all it needs is width and height in pixels, stride in
bytes, depth in bits and the framebuffer address.
Features:
- unaccelerated fb console with colours and virtual consoles
- split into console handling and bus frontend
- so far there is only a PCI bus frontend which allows to mmap BARs belonging
to the graphics controller, others should be easy to add.

TODO:
- find an opaque way to change the palette ( probably pass a function
pointer as property ) since this would need to call some firmware interface
which is pretty much always MD
- find a clean way to mmap the framebuffer, just returning the physical
address works on macppc but not on other architectures. Problem is, that
we cannot rely on the address being a bus address - on macppc it is,
but for instance on sparc64 it's not.