xref: /openbsd-src/sys/dev/adb/adb_subr.c (revision ac9b4aacc1da35008afea06a5d23c2f2dea9b93e)
1 /*	$OpenBSD: adb_subr.c,v 1.3 2011/06/15 21:32:05 miod Exp $	*/
2 /*	$NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $	*/
3 
4 /*-
5  * Copyright (C) 1994	Bradley A. Grantham
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by Bradley A. Grantham.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 
38 #include <dev/adb/adb.h>
39 
40 struct cfdriver adb_cd = {
41 	NULL, "adb", DV_DULL
42 };
43 
44 const char adb_device_name[] = "adb_device";
45 
46 int
47 adbprint(void *args, const char *name)
48 {
49 	struct adb_attach_args *aa_args = (struct adb_attach_args *)args;
50 	int rv = UNCONF;
51 
52 	if (name) {	/* no configured device matched */
53 		rv = UNSUPP; /* most ADB device types are unsupported */
54 
55 		/* print out what kind of ADB device we have found */
56 		switch(aa_args->origaddr) {
57 #ifdef ADBVERBOSE
58 		case ADBADDR_SECURE:
59 			printf("security dongle (%d)", aa_args->handler_id);
60 			break;
61 #endif
62 		case ADBADDR_MAP:
63 			printf("mapped device (%d)", aa_args->handler_id);
64 			rv = UNCONF;
65 			break;
66 		case ADBADDR_REL:
67 			printf("relative positioning device (%d)",
68 			    aa_args->handler_id);
69 			rv = UNCONF;
70 			break;
71 #ifdef ADBVERBOSE
72 		case ADBADDR_ABS:
73 			switch (aa_args->handler_id) {
74 			case ADB_ARTPAD:
75 				printf("WACOM ArtPad II");
76 				break;
77 			default:
78 				printf("absolute positioning device (%d)",
79 				    aa_args->handler_id);
80 				break;
81 			}
82 			break;
83 		case ADBADDR_DATATX:
84 			printf("data transfer device (modem?) (%d)",
85 			    aa_args->handler_id);
86 			break;
87 		case ADBADDR_MISC:
88 			switch (aa_args->handler_id) {
89 			case ADB_POWERKEY:
90 				printf("Sophisticated Circuits PowerKey");
91 				break;
92 			default:
93 				printf("misc. device (remote control?) (%d)",
94 				    aa_args->handler_id);
95 				break;
96 			}
97 			break;
98 #endif /* ADBVERBOSE */
99 		default:
100 			printf("unknown type %d device, (handler %d)",
101 			    aa_args->origaddr, aa_args->handler_id);
102 			break;
103 		}
104 		printf(" at %s", name);
105 	}
106 
107 	printf(" addr %d", aa_args->adbaddr);
108 
109 	return (rv);
110 }
111