xref: /titanic_50/usr/src/uts/common/sys/hotkey_drv.h (revision 2d6b5ea734bb47d251c82670646fde46af15fd69)
1*2d6b5ea7SGuoli Shu /*
2*2d6b5ea7SGuoli Shu  * CDDL HEADER START
3*2d6b5ea7SGuoli Shu  *
4*2d6b5ea7SGuoli Shu  * The contents of this file are subject to the terms of the
5*2d6b5ea7SGuoli Shu  * Common Development and Distribution License (the "License").
6*2d6b5ea7SGuoli Shu  * You may not use this file except in compliance with the License.
7*2d6b5ea7SGuoli Shu  *
8*2d6b5ea7SGuoli Shu  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2d6b5ea7SGuoli Shu  * or http://www.opensolaris.org/os/licensing.
10*2d6b5ea7SGuoli Shu  * See the License for the specific language governing permissions
11*2d6b5ea7SGuoli Shu  * and limitations under the License.
12*2d6b5ea7SGuoli Shu  *
13*2d6b5ea7SGuoli Shu  * When distributing Covered Code, include this CDDL HEADER in each
14*2d6b5ea7SGuoli Shu  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2d6b5ea7SGuoli Shu  * If applicable, add the following below this CDDL HEADER, with the
16*2d6b5ea7SGuoli Shu  * fields enclosed by brackets "[]" replaced with your own identifying
17*2d6b5ea7SGuoli Shu  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2d6b5ea7SGuoli Shu  *
19*2d6b5ea7SGuoli Shu  * CDDL HEADER END
20*2d6b5ea7SGuoli Shu  */
21*2d6b5ea7SGuoli Shu 
22*2d6b5ea7SGuoli Shu /*
23*2d6b5ea7SGuoli Shu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*2d6b5ea7SGuoli Shu  * Use is subject to license terms.
25*2d6b5ea7SGuoli Shu  */
26*2d6b5ea7SGuoli Shu 
27*2d6b5ea7SGuoli Shu #ifndef _HOTKEY_DRV_H
28*2d6b5ea7SGuoli Shu #define	_HOTKEY_DRV_H
29*2d6b5ea7SGuoli Shu 
30*2d6b5ea7SGuoli Shu #ifdef	__cplusplus
31*2d6b5ea7SGuoli Shu extern "C" {
32*2d6b5ea7SGuoli Shu #endif
33*2d6b5ea7SGuoli Shu 
34*2d6b5ea7SGuoli Shu #include <sys/types.h>
35*2d6b5ea7SGuoli Shu #include <sys/conf.h>
36*2d6b5ea7SGuoli Shu #include <sys/stat.h>
37*2d6b5ea7SGuoli Shu #include <sys/note.h>
38*2d6b5ea7SGuoli Shu #include <sys/modctl.h>
39*2d6b5ea7SGuoli Shu #include <sys/ddi.h>
40*2d6b5ea7SGuoli Shu #include <sys/sunddi.h>
41*2d6b5ea7SGuoli Shu #include <sys/acpi/acpi.h>
42*2d6b5ea7SGuoli Shu #include <sys/acpica.h>
43*2d6b5ea7SGuoli Shu #include <sys/sysevent/eventdefs.h>
44*2d6b5ea7SGuoli Shu #include <sys/acpi_drv.h>
45*2d6b5ea7SGuoli Shu 
46*2d6b5ea7SGuoli Shu 
47*2d6b5ea7SGuoli Shu #define	ID_LEN		9
48*2d6b5ea7SGuoli Shu 
49*2d6b5ea7SGuoli Shu struct acpi_drv_dev {
50*2d6b5ea7SGuoli Shu 	ACPI_HANDLE hdl;
51*2d6b5ea7SGuoli Shu 	char hid[ID_LEN];	/* ACPI HardwareId */
52*2d6b5ea7SGuoli Shu 	char uid[ID_LEN];	/* ACPI UniqueId */
53*2d6b5ea7SGuoli Shu 	ACPI_INTEGER adr;	/* Bus device Id */
54*2d6b5ea7SGuoli Shu 	int valid;		/* the device state is valid */
55*2d6b5ea7SGuoli Shu 
56*2d6b5ea7SGuoli Shu 	/*
57*2d6b5ea7SGuoli Shu 	 * Unlike most other devices, when a battery is inserted or
58*2d6b5ea7SGuoli Shu 	 * removed from the system, the device itself(the battery bay)
59*2d6b5ea7SGuoli Shu 	 * is still considered to be present in the system.
60*2d6b5ea7SGuoli Shu 	 *
61*2d6b5ea7SGuoli Shu 	 * Value:
62*2d6b5ea7SGuoli Shu 	 *    0 -- Off-line
63*2d6b5ea7SGuoli Shu 	 *    1 -- On-line
64*2d6b5ea7SGuoli Shu 	 *   -1 -- Unknown
65*2d6b5ea7SGuoli Shu 	 */
66*2d6b5ea7SGuoli Shu 	int present;
67*2d6b5ea7SGuoli Shu 	enum acpi_drv_type type;
68*2d6b5ea7SGuoli Shu 	int index;	/* device index */
69*2d6b5ea7SGuoli Shu 	int minor;
70*2d6b5ea7SGuoli Shu };
71*2d6b5ea7SGuoli Shu 
72*2d6b5ea7SGuoli Shu /*
73*2d6b5ea7SGuoli Shu  * hotkey driver soft-state structure
74*2d6b5ea7SGuoli Shu  */
75*2d6b5ea7SGuoli Shu typedef struct hotkey_drv {
76*2d6b5ea7SGuoli Shu 	struct acpi_drv_dev	dev;
77*2d6b5ea7SGuoli Shu 	dev_info_t		*dip;
78*2d6b5ea7SGuoli Shu 	void			*private;	/* Vendor specific structure */
79*2d6b5ea7SGuoli Shu 	kmutex_t		*hotkey_lock;
80*2d6b5ea7SGuoli Shu 	int			hotkey_method;
81*2d6b5ea7SGuoli Shu 	int			modid;
82*2d6b5ea7SGuoli Shu 	int			(*vendor_ioctl)(struct hotkey_drv *,
83*2d6b5ea7SGuoli Shu 				    int cmd, intptr_t arg, int mode,
84*2d6b5ea7SGuoli Shu 				    cred_t *cr, int *rval);
85*2d6b5ea7SGuoli Shu 	int			(*vendor_fini)(struct hotkey_drv *);
86*2d6b5ea7SGuoli Shu 	boolean_t		check_acpi_video;
87*2d6b5ea7SGuoli Shu 	void			*acpi_video;
88*2d6b5ea7SGuoli Shu } hotkey_drv_t;
89*2d6b5ea7SGuoli Shu 
90*2d6b5ea7SGuoli Shu /*
91*2d6b5ea7SGuoli Shu  * Collection of vendor specific hotkey support
92*2d6b5ea7SGuoli Shu  */
93*2d6b5ea7SGuoli Shu struct vendor_hotkey_drv {
94*2d6b5ea7SGuoli Shu 	const char		*vid;
95*2d6b5ea7SGuoli Shu 	const char		*module;
96*2d6b5ea7SGuoli Shu 	boolean_t		enable;
97*2d6b5ea7SGuoli Shu };
98*2d6b5ea7SGuoli Shu 
99*2d6b5ea7SGuoli Shu #define	HOTKEY_DRV_OK			0
100*2d6b5ea7SGuoli Shu #define	HOTKEY_DRV_ERR			-1
101*2d6b5ea7SGuoli Shu #define	HOTKEY_DBG_NOTICE		0x8000
102*2d6b5ea7SGuoli Shu #define	HOTKEY_DBG_WARN			0x0001
103*2d6b5ea7SGuoli Shu 
104*2d6b5ea7SGuoli Shu #define	HOTKEY_METHOD_NONE		0x0
105*2d6b5ea7SGuoli Shu #define	HOTKEY_METHOD_VENDOR		0x1
106*2d6b5ea7SGuoli Shu #define	HOTKEY_METHOD_ACPI_VIDEO	0x2
107*2d6b5ea7SGuoli Shu #define	HOTKEY_METHOD_MISC		(HOTKEY_METHOD_VENDOR | \
108*2d6b5ea7SGuoli Shu 					HOTKEY_METHOD_ACPI_VIDEO)
109*2d6b5ea7SGuoli Shu /*
110*2d6b5ea7SGuoli Shu  * Inter-source-file linkage ...
111*2d6b5ea7SGuoli Shu  */
112*2d6b5ea7SGuoli Shu extern struct hotkey_drv acpi_hotkey;
113*2d6b5ea7SGuoli Shu extern int hotkey_drv_debug;
114*2d6b5ea7SGuoli Shu int acpi_drv_set_int(ACPI_HANDLE dev, char *method, uint32_t aint);
115*2d6b5ea7SGuoli Shu void acpi_drv_gen_sysevent(struct acpi_drv_dev *devp, char *ev, uint32_t val);
116*2d6b5ea7SGuoli Shu int acpi_drv_dev_init(struct acpi_drv_dev *p);
117*2d6b5ea7SGuoli Shu 
118*2d6b5ea7SGuoli Shu int hotkey_init(hotkey_drv_t *htkp);
119*2d6b5ea7SGuoli Shu int hotkey_fini(hotkey_drv_t *htkp);
120*2d6b5ea7SGuoli Shu int acpi_drv_hotkey_ioctl(int cmd, intptr_t arg, int mode, cred_t *cr,
121*2d6b5ea7SGuoli Shu     int *rval);
122*2d6b5ea7SGuoli Shu int acpi_video_ioctl(void *vidp, int cmd, intptr_t arg, int mode, cred_t *cr,
123*2d6b5ea7SGuoli Shu     int *rval);
124*2d6b5ea7SGuoli Shu int hotkey_brightness_inc(hotkey_drv_t *htkp);
125*2d6b5ea7SGuoli Shu int hotkey_brightness_dec(hotkey_drv_t *htkp);
126*2d6b5ea7SGuoli Shu void hotkey_drv_gen_sysevent(dev_info_t *, char *);
127*2d6b5ea7SGuoli Shu 
128*2d6b5ea7SGuoli Shu #ifdef	__cplusplus
129*2d6b5ea7SGuoli Shu }
130*2d6b5ea7SGuoli Shu #endif
131*2d6b5ea7SGuoli Shu 
132*2d6b5ea7SGuoli Shu #endif /* _HOTKEY_DRV_H */
133