jcs's openbsd hax
openbsd

Rename acpihid(4) into inthid(4). This driver is really an Intel thing and I'd like to re-use acpihid(4) for a new driver that supports the generic button device that is defined by recent versions of the ACPI standard.

ok jcs@, mlarkin@

kettenis 240a7d41 2423c712

+62 -62
+2 -2
sys/arch/amd64/conf/GENERIC
··· 1 - # $OpenBSD: GENERIC,v 1.536 2025/11/14 01:55:07 jcs Exp $ 1 + # $OpenBSD: GENERIC,v 1.537 2025/12/27 12:58:23 kettenis Exp $ 2 2 # 3 3 # For further information on compiling OpenBSD kernels, see the config(8) 4 4 # man page. ··· 81 81 tpm* at acpi? 82 82 acpihve* at acpi? 83 83 acpisurface* at acpi? 84 - acpihid* at acpi? 84 + inthid* at acpi? 85 85 ipmi0 at acpi? disable 86 86 ccpmic* at iic? 87 87 tipmic* at iic?
+56 -56
sys/dev/acpi/acpihid.c sys/dev/acpi/inthid.c
··· 1 - /* $OpenBSD: acpihid.c,v 1.4 2022/05/29 22:03:44 jca Exp $ */ 1 + /* $OpenBSD: inthid.c,v 1.1 2025/12/27 12:58:23 kettenis Exp $ */ 2 2 /* 3 - * ACPI HID event and 5-button array driver 3 + * Intel HID event and 5-button array driver 4 4 * 5 5 * Copyright (c) 2018, 2020 joshua stein <jcs@jcs.org> 6 6 * ··· 35 35 #include "audio.h" 36 36 #include "wskbd.h" 37 37 38 - /* #define ACPIHID_DEBUG */ 38 + /* #define INTHID_DEBUG */ 39 39 40 - #ifdef ACPIHID_DEBUG 40 + #ifdef INTHID_DEBUG 41 41 #define DPRINTF(x) printf x 42 42 #else 43 43 #define DPRINTF(x) 44 44 #endif 45 45 46 - struct acpihid_softc { 46 + struct inthid_softc { 47 47 struct device sc_dev; 48 48 49 49 bus_space_tag_t sc_iot; ··· 88 88 }; 89 89 90 90 enum { 91 - ACPIHID_FUNC_INVALID, 92 - ACPIHID_FUNC_BTNL, 93 - ACPIHID_FUNC_HDMM, 94 - ACPIHID_FUNC_HDSM, 95 - ACPIHID_FUNC_HDEM, 96 - ACPIHID_FUNC_BTNS, 97 - ACPIHID_FUNC_BTNE, 98 - ACPIHID_FUNC_HEBC_V1, 99 - ACPIHID_FUNC_VGBS, 100 - ACPIHID_FUNC_HEBC_V2, 101 - ACPIHID_FUNC_MAX, 91 + INTHID_FUNC_INVALID, 92 + INTHID_FUNC_BTNL, 93 + INTHID_FUNC_HDMM, 94 + INTHID_FUNC_HDSM, 95 + INTHID_FUNC_HDEM, 96 + INTHID_FUNC_BTNS, 97 + INTHID_FUNC_BTNE, 98 + INTHID_FUNC_HEBC_V1, 99 + INTHID_FUNC_VGBS, 100 + INTHID_FUNC_HEBC_V2, 101 + INTHID_FUNC_MAX, 102 102 }; 103 103 104 - static const char *acpihid_dsm_funcs[] = { 104 + static const char *inthid_dsm_funcs[] = { 105 105 NULL, 106 106 "BTNL", 107 107 "HDMM", ··· 114 114 "HEBC", 115 115 }; 116 116 117 - int acpihid_match(struct device *, void *, void *); 118 - void acpihid_attach(struct device *, struct device *, void *); 119 - void acpihid_init_dsm(struct acpihid_softc *); 120 - int acpihid_button_array_enable(struct acpihid_softc *, int); 121 - int acpihid_eval(struct acpihid_softc *, int, int64_t, int64_t *); 122 - int acpihid_notify(struct aml_node *, int, void *); 117 + int inthid_match(struct device *, void *, void *); 118 + void inthid_attach(struct device *, struct device *, void *); 119 + void inthid_init_dsm(struct inthid_softc *); 120 + int inthid_button_array_enable(struct inthid_softc *, int); 121 + int inthid_eval(struct inthid_softc *, int, int64_t, int64_t *); 122 + int inthid_notify(struct aml_node *, int, void *); 123 123 124 124 #if NAUDIO > 0 && NWSKBD > 0 125 125 extern int wskbd_set_mixervolume(long, long); 126 126 #endif 127 127 128 - const struct cfattach acpihid_ca = { 129 - sizeof(struct acpihid_softc), 130 - acpihid_match, 131 - acpihid_attach, 128 + const struct cfattach inthid_ca = { 129 + sizeof(struct inthid_softc), 130 + inthid_match, 131 + inthid_attach, 132 132 NULL, 133 133 NULL, 134 134 }; 135 135 136 - struct cfdriver acpihid_cd = { 137 - NULL, "acpihid", DV_DULL 136 + struct cfdriver inthid_cd = { 137 + NULL, "inthid", DV_DULL 138 138 }; 139 139 140 - const char *acpihid_hids[] = { 140 + const char *inthid_hids[] = { 141 141 "INT33D5", 142 142 NULL 143 143 }; 144 144 145 145 /* eeec56b3-4442-408f-a792-4edd4d758054 */ 146 - static uint8_t acpihid_guid[] = { 146 + static uint8_t inthid_guid[] = { 147 147 0xB3, 0x56, 0xEC, 0xEE, 0x42, 0x44, 0x8F, 0x40, 148 148 0xA7, 0x92, 0x4E, 0xDD, 0x4D, 0x75, 0x80, 0x54, 149 149 }; 150 150 151 151 int 152 - acpihid_match(struct device *parent, void *match, void *aux) 152 + inthid_match(struct device *parent, void *match, void *aux) 153 153 { 154 154 struct acpi_attach_args *aa = aux; 155 155 struct cfdata *cf = match; 156 156 157 - return (acpi_matchhids(aa, acpihid_hids, cf->cf_driver->cd_name)); 157 + return (acpi_matchhids(aa, inthid_hids, cf->cf_driver->cd_name)); 158 158 } 159 159 160 160 void 161 - acpihid_attach(struct device *parent, struct device *self, void *aux) 161 + inthid_attach(struct device *parent, struct device *self, void *aux) 162 162 { 163 - struct acpihid_softc *sc = (struct acpihid_softc *)self; 163 + struct inthid_softc *sc = (struct inthid_softc *)self; 164 164 struct acpi_attach_args *aa = aux; 165 165 uint64_t val; 166 166 ··· 169 169 170 170 printf(": %s", sc->sc_devnode->name); 171 171 172 - acpihid_init_dsm(sc); 172 + inthid_init_dsm(sc); 173 173 174 - if (acpihid_eval(sc, ACPIHID_FUNC_HDMM, 0, &val) != 0) { 174 + if (inthid_eval(sc, INTHID_FUNC_HDMM, 0, &val) != 0) { 175 175 printf(", failed reading mode\n"); 176 176 return; 177 177 } else if (val != 0) { ··· 179 179 return; 180 180 } 181 181 182 - if ((acpihid_eval(sc, ACPIHID_FUNC_HEBC_V2, 0, &val) == 0 && 182 + if ((inthid_eval(sc, INTHID_FUNC_HEBC_V2, 0, &val) == 0 && 183 183 (val & 0x60000)) || 184 - (acpihid_eval(sc, ACPIHID_FUNC_HEBC_V1, 0, &val) == 0 && 184 + (inthid_eval(sc, INTHID_FUNC_HEBC_V1, 0, &val) == 0 && 185 185 (val & 0x20000))) 186 186 sc->sc_5_button = 1; 187 187 188 - aml_register_notify(sc->sc_devnode, aa->aaa_dev, acpihid_notify, 188 + aml_register_notify(sc->sc_devnode, aa->aaa_dev, inthid_notify, 189 189 sc, ACPIDEV_NOPOLL); 190 190 191 191 /* enable hid set */ 192 - acpihid_eval(sc, ACPIHID_FUNC_HDSM, 1, NULL); 192 + inthid_eval(sc, INTHID_FUNC_HDSM, 1, NULL); 193 193 194 194 if (sc->sc_5_button) { 195 - acpihid_button_array_enable(sc, 1); 195 + inthid_button_array_enable(sc, 1); 196 196 197 - if (acpihid_eval(sc, ACPIHID_FUNC_BTNL, 0, NULL) == 0) 197 + if (inthid_eval(sc, INTHID_FUNC_BTNL, 0, NULL) == 0) 198 198 printf(", 5 button array"); 199 199 else 200 200 printf(", failed enabling HID power button"); ··· 204 204 } 205 205 206 206 void 207 - acpihid_init_dsm(struct acpihid_softc *sc) 207 + inthid_init_dsm(struct inthid_softc *sc) 208 208 { 209 209 struct aml_value cmd[4], res; 210 210 ··· 217 217 218 218 bzero(&cmd, sizeof(cmd)); 219 219 cmd[0].type = AML_OBJTYPE_BUFFER; 220 - cmd[0].v_buffer = (uint8_t *)&acpihid_guid; 221 - cmd[0].length = sizeof(acpihid_guid); 220 + cmd[0].v_buffer = (uint8_t *)&inthid_guid; 221 + cmd[0].length = sizeof(inthid_guid); 222 222 /* rev */ 223 223 cmd[1].type = AML_OBJTYPE_INTEGER; 224 224 cmd[1].v_integer = 1; ··· 253 253 } 254 254 255 255 int 256 - acpihid_eval(struct acpihid_softc *sc, int idx, int64_t arg, int64_t *ret) 256 + inthid_eval(struct inthid_softc *sc, int idx, int64_t arg, int64_t *ret) 257 257 { 258 258 struct aml_value cmd[4], pkg, *ppkg; 259 259 int64_t tret; 260 260 const char *dsm_func; 261 261 262 - if (idx <= ACPIHID_FUNC_INVALID || idx >= ACPIHID_FUNC_MAX) { 262 + if (idx <= INTHID_FUNC_INVALID || idx >= INTHID_FUNC_MAX) { 263 263 printf("%s: _DSM func index %d out of bounds\n", 264 264 sc->sc_dev.dv_xname, idx); 265 265 return 1; 266 266 } 267 267 268 - dsm_func = acpihid_dsm_funcs[idx]; 268 + dsm_func = inthid_dsm_funcs[idx]; 269 269 270 270 DPRINTF(("%s: executing _DSM %s\n", sc->sc_dev.dv_xname, dsm_func)); 271 271 ··· 283 283 284 284 bzero(&cmd, sizeof(cmd)); 285 285 cmd[0].type = AML_OBJTYPE_BUFFER; 286 - cmd[0].v_buffer = (uint8_t *)&acpihid_guid; 287 - cmd[0].length = sizeof(acpihid_guid); 286 + cmd[0].v_buffer = (uint8_t *)&inthid_guid; 287 + cmd[0].length = sizeof(inthid_guid); 288 288 /* rev */ 289 289 cmd[1].type = AML_OBJTYPE_INTEGER; 290 290 cmd[1].v_integer = 1; ··· 332 332 } 333 333 334 334 int 335 - acpihid_button_array_enable(struct acpihid_softc *sc, int enable) 335 + inthid_button_array_enable(struct inthid_softc *sc, int enable) 336 336 { 337 337 int64_t cap; 338 338 ··· 343 343 return 1; 344 344 } 345 345 346 - if (acpihid_eval(sc, ACPIHID_FUNC_BTNE, enable ? cap : 1, NULL) != 0) { 346 + if (inthid_eval(sc, INTHID_FUNC_BTNE, enable ? cap : 1, NULL) != 0) { 347 347 printf("%s: failed enabling button array\n", 348 348 sc->sc_dev.dv_xname); 349 349 return 1; ··· 353 353 } 354 354 355 355 int 356 - acpihid_notify(struct aml_node *node, int notify_type, void *arg) 356 + inthid_notify(struct aml_node *node, int notify_type, void *arg) 357 357 { 358 - #ifdef ACPIHID_DEBUG 359 - struct acpihid_softc *sc = arg; 358 + #ifdef INTHID_DEBUG 359 + struct inthid_softc *sc = arg; 360 360 361 361 DPRINTF(("%s: %s: %.2x\n", sc->sc_dev.dv_xname, __func__, 362 362 notify_type));
+4 -4
sys/dev/acpi/files.acpi
··· 1 - # $OpenBSD: files.acpi,v 1.77 2025/11/14 01:55:07 jcs Exp $ 1 + # $OpenBSD: files.acpi,v 1.78 2025/12/27 12:58:23 kettenis Exp $ 2 2 # 3 3 # Config file and device description for machine-independent ACPI code. 4 4 # Included by ports that need it. ··· 264 264 file dev/acpi/if_bse_acpi.c bse_acpi 265 265 266 266 # Intel HID event and 5-button array 267 - device acpihid 268 - attach acpihid at acpi 269 - file dev/acpi/acpihid.c acpihid 267 + device inthid 268 + attach inthid at acpi 269 + file dev/acpi/inthid.c inthid 270 270 271 271 # Freescale i.MX I2C controller 272 272 attach imxiic at acpi with imxiic_acpi