Copy the following files to new places, a subsequent commit would remove
them from the old place. This commit necessary so that the tree would not enter a broken state. sys/i386/isa/vesa.c -> dev/fb/vesa.c sys/i386/include/pc/vesa.h -> dev/fb/vesa.h sys/i386/isa/dpms.c -> dev/dpms/dpms.c
This commit is contained in:
parent
fedf3e9ed3
commit
f45c063aa7
230
sys/dev/dpms/dpms.c
Normal file
230
sys/dev/dpms/dpms.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*-
|
||||
* Copyright (c) 2008 Yahoo!, Inc.
|
||||
* All rights reserved.
|
||||
* Written by: John Baldwin <jhb@FreeBSD.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Benjamin Close <Benjamin.Close@clearchain.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support for managing the display via DPMS for suspend/resume.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/libkern.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <machine/vm86.h>
|
||||
|
||||
/*
|
||||
* VESA DPMS States
|
||||
*/
|
||||
#define DPMS_ON 0x00
|
||||
#define DPMS_STANDBY 0x01
|
||||
#define DPMS_SUSPEND 0x02
|
||||
#define DPMS_OFF 0x04
|
||||
#define DPMS_REDUCEDON 0x08
|
||||
|
||||
#define VBE_DPMS_FUNCTION 0x4F10
|
||||
#define VBE_DPMS_GET_SUPPORTED_STATES 0x00
|
||||
#define VBE_DPMS_GET_STATE 0x02
|
||||
#define VBE_DPMS_SET_STATE 0x01
|
||||
#define VBE_MAJORVERSION_MASK 0x0F
|
||||
#define VBE_MINORVERSION_MASK 0xF0
|
||||
|
||||
struct dpms_softc {
|
||||
int dpms_supported_states;
|
||||
int dpms_initial_state;
|
||||
};
|
||||
|
||||
static int dpms_attach(device_t);
|
||||
static int dpms_detach(device_t);
|
||||
static int dpms_get_supported_states(int *);
|
||||
static int dpms_get_current_state(int *);
|
||||
static void dpms_identify(driver_t *, device_t);
|
||||
static int dpms_probe(device_t);
|
||||
static int dpms_resume(device_t);
|
||||
static int dpms_set_state(int);
|
||||
static int dpms_suspend(device_t);
|
||||
|
||||
static device_method_t dpms_methods[] = {
|
||||
DEVMETHOD(device_identify, dpms_identify),
|
||||
DEVMETHOD(device_probe, dpms_probe),
|
||||
DEVMETHOD(device_attach, dpms_attach),
|
||||
DEVMETHOD(device_detach, dpms_detach),
|
||||
DEVMETHOD(device_suspend, dpms_suspend),
|
||||
DEVMETHOD(device_resume, dpms_resume),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t dpms_driver = {
|
||||
"dpms",
|
||||
dpms_methods,
|
||||
sizeof(struct dpms_softc),
|
||||
};
|
||||
|
||||
static devclass_t dpms_devclass;
|
||||
|
||||
DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL);
|
||||
|
||||
static void
|
||||
dpms_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
|
||||
/*
|
||||
* XXX: The DPMS VBE only allows for manipulating a single
|
||||
* monitor, but we don't know which one. Just attach to the
|
||||
* first vgapci(4) device we encounter and hope it is the
|
||||
* right one.
|
||||
*/
|
||||
if (devclass_get_device(dpms_devclass, 0) == NULL)
|
||||
device_add_child(parent, "dpms", 0);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_probe(device_t dev)
|
||||
{
|
||||
int error, states;
|
||||
|
||||
error = dpms_get_supported_states(&states);
|
||||
if (error)
|
||||
return (error);
|
||||
device_set_desc(dev, "DPMS suspend/resume");
|
||||
device_quiet(dev);
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_attach(device_t dev)
|
||||
{
|
||||
struct dpms_softc *sc;
|
||||
int error;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
error = dpms_get_supported_states(&sc->dpms_supported_states);
|
||||
if (error)
|
||||
return (error);
|
||||
error = dpms_get_current_state(&sc->dpms_initial_state);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_detach(device_t dev)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_suspend(device_t dev)
|
||||
{
|
||||
|
||||
dpms_set_state(DPMS_OFF);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_resume(device_t dev)
|
||||
{
|
||||
struct dpms_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
dpms_set_state(sc->dpms_initial_state);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_call_bios(int subfunction, int *bh)
|
||||
{
|
||||
struct vm86frame vmf;
|
||||
int error;
|
||||
|
||||
bzero(&vmf, sizeof(vmf));
|
||||
vmf.vmf_ax = VBE_DPMS_FUNCTION;
|
||||
vmf.vmf_bl = subfunction;
|
||||
vmf.vmf_bh = *bh;
|
||||
vmf.vmf_es = 0;
|
||||
vmf.vmf_di = 0;
|
||||
error = vm86_intcall(0x10, &vmf);
|
||||
if (error == 0 && (vmf.vmf_eax & 0xffff) != 0x004f)
|
||||
error = ENXIO;
|
||||
if (error == 0)
|
||||
*bh = vmf.vmf_bh;
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_get_supported_states(int *states)
|
||||
{
|
||||
|
||||
*states = 0;
|
||||
return (dpms_call_bios(VBE_DPMS_GET_SUPPORTED_STATES, states));
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_get_current_state(int *state)
|
||||
{
|
||||
|
||||
*state = 0;
|
||||
return (dpms_call_bios(VBE_DPMS_GET_STATE, state));
|
||||
}
|
||||
|
||||
static int
|
||||
dpms_set_state(int state)
|
||||
{
|
||||
|
||||
return (dpms_call_bios(VBE_DPMS_SET_STATE, &state));
|
||||
}
|
1696
sys/dev/fb/vesa.c
Normal file
1696
sys/dev/fb/vesa.c
Normal file
File diff suppressed because it is too large
Load Diff
120
sys/dev/fb/vesa.h
Normal file
120
sys/dev/fb/vesa.h
Normal file
@ -0,0 +1,120 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Michael Smith and Kazutaka YOKOTA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer as
|
||||
* the first lines of this file unmodified.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_PC_VESA_H
|
||||
#define _MACHINE_PC_VESA_H
|
||||
|
||||
struct vesa_info
|
||||
{
|
||||
/* mandatory fields */
|
||||
u_int8_t v_sig[4]; /* VESA */
|
||||
u_int16_t v_version; /* ver in BCD */
|
||||
u_int32_t v_oemstr; /* OEM string */
|
||||
u_int32_t v_flags; /* flags */
|
||||
#define V_DAC8 (1<<0)
|
||||
#define V_NONVGA (1<<1)
|
||||
#define V_SNOW (1<<2)
|
||||
u_int32_t v_modetable; /* modes */
|
||||
u_int16_t v_memsize; /* in 64K */
|
||||
/* 2.0 */
|
||||
u_int16_t v_revision; /* software rev */
|
||||
u_int32_t v_venderstr; /* vender */
|
||||
u_int32_t v_prodstr; /* product name */
|
||||
u_int32_t v_revstr; /* product rev */
|
||||
} __packed;
|
||||
|
||||
struct vesa_mode
|
||||
{
|
||||
/* mandatory fields */
|
||||
u_int16_t v_modeattr;
|
||||
#define V_MODESUPP (1<<0) /* VESA mode attributes */
|
||||
#define V_MODEOPTINFO (1<<1)
|
||||
#define V_MODEBIOSOUT (1<<2)
|
||||
#define V_MODECOLOR (1<<3)
|
||||
#define V_MODEGRAPHICS (1<<4)
|
||||
#define V_MODENONVGA (1<<5)
|
||||
#define V_MODENONBANK (1<<6)
|
||||
#define V_MODELFB (1<<7)
|
||||
#define V_MODEVESA (1<<16) /* Private attributes */
|
||||
u_int8_t v_waattr;
|
||||
u_int8_t v_wbattr;
|
||||
#define V_WATTREXIST (1<<0)
|
||||
#define V_WATTRREAD (1<<1)
|
||||
#define V_WATTRWRITE (1<<2)
|
||||
u_int16_t v_wgran;
|
||||
u_int16_t v_wsize;
|
||||
u_int16_t v_waseg;
|
||||
u_int16_t v_wbseg;
|
||||
u_int32_t v_posfunc;
|
||||
u_int16_t v_bpscanline;
|
||||
/* fields optional for 1.0/1.1 implementations */
|
||||
u_int16_t v_width;
|
||||
u_int16_t v_height;
|
||||
u_int8_t v_cwidth;
|
||||
u_int8_t v_cheight;
|
||||
u_int8_t v_planes;
|
||||
u_int8_t v_bpp;
|
||||
u_int8_t v_banks;
|
||||
u_int8_t v_memmodel;
|
||||
#define V_MMTEXT 0
|
||||
#define V_MMCGA 1
|
||||
#define V_MMHGC 2
|
||||
#define V_MMEGA 3
|
||||
#define V_MMPACKED 4
|
||||
#define V_MMSEQU256 5
|
||||
#define V_MMDIRCOLOR 6
|
||||
#define V_MMYUV 7
|
||||
u_int8_t v_banksize;
|
||||
u_int8_t v_ipages;
|
||||
u_int8_t v_reserved0;
|
||||
/* fields for 1.2+ implementations */
|
||||
u_int8_t v_redmasksize;
|
||||
u_int8_t v_redfieldpos;
|
||||
u_int8_t v_greenmasksize;
|
||||
u_int8_t v_greenfieldpos;
|
||||
u_int8_t v_bluemasksize;
|
||||
u_int8_t v_bluefieldpos;
|
||||
u_int8_t v_resmasksize;
|
||||
u_int8_t v_resfieldpos;
|
||||
u_int8_t v_dircolormode;
|
||||
/* 2.0 implementations */
|
||||
u_int32_t v_lfb;
|
||||
u_int32_t v_offscreen;
|
||||
u_int16_t v_offscreensize;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define VESA_MODE(x) ((x) >= M_VESA_BASE)
|
||||
|
||||
int vesa_load_ioctl(void);
|
||||
int vesa_unload_ioctl(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_PC_VESA_H */
|
Loading…
x
Reference in New Issue
Block a user