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