Deleted Added
full compact
dpms.c (197469) dpms.c (198251)
1/*-
2 * Copyright (c) 2008 Yahoo!, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 45 unchanged lines hidden (view full) ---

54 * SUCH DAMAGE.
55 */
56
57/*
58 * Support for managing the display via DPMS for suspend/resume.
59 */
60
61#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Yahoo!, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 45 unchanged lines hidden (view full) ---

54 * SUCH DAMAGE.
55 */
56
57/*
58 * Support for managing the display via DPMS for suspend/resume.
59 */
60
61#include <sys/cdefs.h>
62__FBSDID("$FreeBSD: head/sys/dev/dpms/dpms.c 197469 2009-09-24 20:23:24Z jkim $");
62__FBSDID("$FreeBSD: head/sys/dev/dpms/dpms.c 198251 2009-10-19 20:58:10Z jkim $");
63
64#include <sys/param.h>
65#include <sys/bus.h>
66#include <sys/kernel.h>
67#include <sys/libkern.h>
68#include <sys/module.h>
69
70#include <compat/x86bios/x86bios.h>

--- 49 unchanged lines hidden (view full) ---

120
121DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL);
122MODULE_DEPEND(dpms, x86bios, 1, 1, 1);
123
124static void
125dpms_identify(driver_t *driver, device_t parent)
126{
127
63
64#include <sys/param.h>
65#include <sys/bus.h>
66#include <sys/kernel.h>
67#include <sys/libkern.h>
68#include <sys/module.h>
69
70#include <compat/x86bios/x86bios.h>

--- 49 unchanged lines hidden (view full) ---

120
121DRIVER_MODULE(dpms, vgapci, dpms_driver, dpms_devclass, NULL, NULL);
122MODULE_DEPEND(dpms, x86bios, 1, 1, 1);
123
124static void
125dpms_identify(driver_t *driver, device_t parent)
126{
127
128 /*
129 * XXX: The DPMS VBE only allows for manipulating a single
130 * monitor, but we don't know which one. Just attach to the
131 * first vgapci(4) device we encounter and hope it is the
132 * right one.
133 */
134 if (devclass_get_device(dpms_devclass, 0) == NULL)
128 /* The DPMS VBE only allows for manipulating a single monitor. */
129 if (devclass_get_device(dpms_devclass, 0) != NULL)
130 return;
131
132 if ((x86bios_match_device(0xc0000, parent) &&
133 device_get_flags(parent) != 0) ||
134 x86bios_get_orm(0xc0000) != NULL)
135 device_add_child(parent, "dpms", 0);
136}
137
138static int
139dpms_probe(device_t dev)
140{
141 int error, states;
142

--- 24 unchanged lines hidden (view full) ---

167{
168
169 return (0);
170}
171
172static int
173dpms_suspend(device_t dev)
174{
135 device_add_child(parent, "dpms", 0);
136}
137
138static int
139dpms_probe(device_t dev)
140{
141 int error, states;
142

--- 24 unchanged lines hidden (view full) ---

167{
168
169 return (0);
170}
171
172static int
173dpms_suspend(device_t dev)
174{
175 struct dpms_softc *sc;
175
176
176 dpms_set_state(DPMS_OFF);
177 sc = device_get_softc(dev);
178 if ((sc->dpms_supported_states & DPMS_OFF) != 0)
179 dpms_set_state(DPMS_OFF);
177 return (0);
178}
179
180static int
181dpms_resume(device_t dev)
182{
183 struct dpms_softc *sc;
184
185 sc = device_get_softc(dev);
186 dpms_set_state(sc->dpms_initial_state);
187 return (0);
188}
189
190static int
191dpms_call_bios(int subfunction, int *bh)
192{
193 x86regs_t regs;
194
180 return (0);
181}
182
183static int
184dpms_resume(device_t dev)
185{
186 struct dpms_softc *sc;
187
188 sc = device_get_softc(dev);
189 dpms_set_state(sc->dpms_initial_state);
190 return (0);
191}
192
193static int
194dpms_call_bios(int subfunction, int *bh)
195{
196 x86regs_t regs;
197
195 bzero(&regs, sizeof(regs));
198 if (x86bios_get_intr(0x10) == 0)
199 return (ENXIO);
200
201 x86bios_init_regs(&regs);
196 regs.R_AX = VBE_DPMS_FUNCTION;
197 regs.R_BL = subfunction;
198 regs.R_BH = *bh;
202 regs.R_AX = VBE_DPMS_FUNCTION;
203 regs.R_BL = subfunction;
204 regs.R_BH = *bh;
199 regs.R_ES = 0;
200 regs.R_DI = 0;
201 x86bios_intr(&regs, 0x10);
202
205 x86bios_intr(&regs, 0x10);
206
203 if ((regs.R_EAX & 0xffff) != 0x004f)
207 if (regs.R_AX != 0x004f)
204 return (ENXIO);
205
206 *bh = regs.R_BH;
207
208 return (0);
209}
210
211static int

--- 21 unchanged lines hidden ---
208 return (ENXIO);
209
210 *bh = regs.R_BH;
211
212 return (0);
213}
214
215static int

--- 21 unchanged lines hidden ---