2007-10-25 23:32:15 +04:00
|
|
|
/* $NetBSD: uvisor.c,v 1.36 2007/10/25 19:32:15 plunky Exp $ */
|
2000-03-30 20:56:19 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-04-27 19:26:44 +04:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
2000-03-30 20:56:19 +04:00
|
|
|
* Carlstedt Research & Technology.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-03-31 17:08:01 +04:00
|
|
|
* Handspring Visor (Palmpilot compatible PDA) driver
|
2000-03-30 20:56:19 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 09:24:53 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-10-25 23:32:15 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: uvisor.c,v 1.36 2007/10/25 19:32:15 plunky Exp $");
|
2001-11-13 09:24:53 +03:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usb.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdevs.h>
|
|
|
|
|
|
|
|
#include <dev/usb/ucomvar.h>
|
|
|
|
|
|
|
|
#ifdef UVISOR_DEBUG
|
|
|
|
#define DPRINTF(x) if (uvisordebug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (uvisordebug>(n)) printf x
|
2000-04-05 15:12:48 +04:00
|
|
|
int uvisordebug = 0;
|
2000-03-30 20:56:19 +04:00
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UVISOR_CONFIG_INDEX 0
|
|
|
|
#define UVISOR_IFACE_INDEX 0
|
|
|
|
|
|
|
|
/* From the Linux driver */
|
|
|
|
/*
|
|
|
|
* UVISOR_REQUEST_BYTES_AVAILABLE asks the visor for the number of bytes that
|
|
|
|
* are available to be transfered to the host for the specified endpoint.
|
|
|
|
* Currently this is not used, and always returns 0x0001
|
|
|
|
*/
|
|
|
|
#define UVISOR_REQUEST_BYTES_AVAILABLE 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UVISOR_CLOSE_NOTIFICATION is set to the device to notify it that the host
|
|
|
|
* is now closing the pipe. An empty packet is sent in response.
|
|
|
|
*/
|
|
|
|
#define UVISOR_CLOSE_NOTIFICATION 0x02
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UVISOR_GET_CONNECTION_INFORMATION is sent by the host during enumeration to
|
|
|
|
* get the endpoints used by the connection.
|
|
|
|
*/
|
|
|
|
#define UVISOR_GET_CONNECTION_INFORMATION 0x03
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UVISOR_GET_CONNECTION_INFORMATION returns data in the following format
|
|
|
|
*/
|
2001-01-24 00:19:44 +03:00
|
|
|
#define UVISOR_MAX_CONN 8
|
2000-03-30 20:56:19 +04:00
|
|
|
struct uvisor_connection_info {
|
|
|
|
uWord num_ports;
|
|
|
|
struct {
|
|
|
|
uByte port_function_id;
|
|
|
|
uByte port;
|
2001-01-24 00:19:44 +03:00
|
|
|
} connections[UVISOR_MAX_CONN];
|
2000-03-30 20:56:19 +04:00
|
|
|
};
|
|
|
|
#define UVISOR_CONNECTION_INFO_SIZE 18
|
|
|
|
|
|
|
|
/* struct uvisor_connection_info.connection[x].port_function_id defines: */
|
|
|
|
#define UVISOR_FUNCTION_GENERIC 0x00
|
|
|
|
#define UVISOR_FUNCTION_DEBUGGER 0x01
|
|
|
|
#define UVISOR_FUNCTION_HOTSYNC 0x02
|
|
|
|
#define UVISOR_FUNCTION_CONSOLE 0x03
|
|
|
|
#define UVISOR_FUNCTION_REMOTE_FILE_SYS 0x04
|
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
/*
|
|
|
|
* Unknown PalmOS stuff.
|
|
|
|
*/
|
|
|
|
#define UVISOR_GET_PALM_INFORMATION 0x04
|
2003-08-04 01:59:26 +04:00
|
|
|
#define UVISOR_GET_PALM_INFORMATION_LEN 0x44
|
|
|
|
|
|
|
|
struct uvisor_palm_connection_info {
|
|
|
|
uByte num_ports;
|
|
|
|
uByte endpoint_numbers_different;
|
|
|
|
uWord reserved1;
|
|
|
|
struct {
|
|
|
|
uDWord port_function_id;
|
|
|
|
uByte port;
|
|
|
|
uByte end_point_info;
|
|
|
|
uWord reserved;
|
|
|
|
} connections[UVISOR_MAX_CONN];
|
|
|
|
};
|
2002-02-28 02:00:03 +03:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
|
|
|
|
#define UVISORIBUFSIZE 64
|
2000-04-06 17:32:28 +04:00
|
|
|
#define UVISOROBUFSIZE 1024
|
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
struct uvisor_softc {
|
|
|
|
USBBASEDEVICE sc_dev; /* base device */
|
|
|
|
usbd_device_handle sc_udev; /* device */
|
|
|
|
usbd_interface_handle sc_iface; /* interface */
|
|
|
|
|
2001-01-24 00:19:44 +03:00
|
|
|
device_ptr_t sc_subdevs[UVISOR_MAX_CONN];
|
|
|
|
int sc_numcon;
|
2000-03-30 20:56:19 +04:00
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
u_int16_t sc_flags;
|
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
u_char sc_dying;
|
|
|
|
};
|
|
|
|
|
2002-07-12 01:14:24 +04:00
|
|
|
Static usbd_status uvisor_init(struct uvisor_softc *,
|
2003-08-04 01:59:26 +04:00
|
|
|
struct uvisor_connection_info *,
|
|
|
|
struct uvisor_palm_connection_info *);
|
2000-03-30 20:56:19 +04:00
|
|
|
|
2000-06-01 18:28:57 +04:00
|
|
|
Static void uvisor_close(void *, int);
|
2000-03-30 20:56:19 +04:00
|
|
|
|
|
|
|
|
|
|
|
struct ucom_methods uvisor_methods = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
uvisor_close,
|
2000-04-14 18:21:55 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-03-30 20:56:19 +04:00
|
|
|
};
|
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
struct uvisor_type {
|
|
|
|
struct usb_devno uv_dev;
|
|
|
|
u_int16_t uv_flags;
|
|
|
|
#define PALM4 0x0001
|
2003-08-04 01:59:26 +04:00
|
|
|
#define VISOR 0x0002
|
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
};
|
|
|
|
static const struct uvisor_type uvisor_devs[] = {
|
2003-08-04 01:59:26 +04:00
|
|
|
{{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_VISOR }, VISOR },
|
2003-02-07 21:12:37 +03:00
|
|
|
{{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_TREO }, PALM4 },
|
2003-11-08 00:27:56 +03:00
|
|
|
{{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_TREO600 }, PALM4 },
|
2002-02-28 02:00:03 +03:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M500 }, PALM4 },
|
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M505 }, PALM4 },
|
2002-08-13 15:38:15 +04:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M515 }, PALM4 },
|
2003-02-07 21:12:37 +03:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_I705 }, PALM4 },
|
2002-02-28 02:00:03 +03:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M125 }, PALM4 },
|
2003-02-07 21:12:37 +03:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M130 }, PALM4 },
|
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_TUNGSTEN_Z }, PALM4 },
|
2003-04-11 05:30:10 +04:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_TUNGSTEN_T }, PALM4 },
|
2004-07-08 01:11:02 +04:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE31 }, PALM4 },
|
2003-02-05 03:50:14 +03:00
|
|
|
{{ USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE }, PALM4 },
|
2002-02-28 02:00:03 +03:00
|
|
|
{{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40 }, PALM4 },
|
2003-08-04 01:59:26 +04:00
|
|
|
{{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41 }, PALM4 },
|
2003-02-07 21:12:37 +03:00
|
|
|
{{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_S360 }, PALM4 },
|
|
|
|
{{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_NX60 }, PALM4 },
|
2004-01-29 01:01:38 +03:00
|
|
|
{{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_35 }, 0 },
|
2002-02-28 02:00:03 +03:00
|
|
|
/* {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_25 }, PALM4 },*/
|
|
|
|
};
|
2005-05-30 08:21:39 +04:00
|
|
|
#define uvisor_lookup(v, p) ((const struct uvisor_type *)usb_lookup(uvisor_devs, v, p))
|
2002-02-28 02:00:03 +03:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
USB_DECLARE_DRIVER(uvisor);
|
|
|
|
|
|
|
|
USB_MATCH(uvisor)
|
|
|
|
{
|
|
|
|
USB_MATCH_START(uvisor, uaa);
|
2002-07-12 01:14:24 +04:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
DPRINTFN(20,("uvisor: vendor=0x%x, product=0x%x\n",
|
|
|
|
uaa->vendor, uaa->product));
|
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
return (uvisor_lookup(uaa->vendor, uaa->product) != NULL ?
|
|
|
|
UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
|
2000-03-30 20:56:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
USB_ATTACH(uvisor)
|
|
|
|
{
|
|
|
|
USB_ATTACH_START(uvisor, sc, uaa);
|
|
|
|
usbd_device_handle dev = uaa->device;
|
|
|
|
usbd_interface_handle iface;
|
|
|
|
usb_interface_descriptor_t *id;
|
2001-01-24 00:19:44 +03:00
|
|
|
struct uvisor_connection_info coninfo;
|
2003-08-04 01:59:26 +04:00
|
|
|
struct uvisor_palm_connection_info palmconinfo;
|
2000-03-30 20:56:19 +04:00
|
|
|
usb_endpoint_descriptor_t *ed;
|
2005-05-11 14:02:28 +04:00
|
|
|
char *devinfop;
|
2000-03-30 20:56:19 +04:00
|
|
|
char *devname = USBDEVNAME(sc->sc_dev);
|
2001-01-24 00:19:44 +03:00
|
|
|
int i, j, hasin, hasout, port;
|
2000-03-30 20:56:19 +04:00
|
|
|
usbd_status err;
|
|
|
|
struct ucom_attach_args uca;
|
|
|
|
|
|
|
|
DPRINTFN(10,("\nuvisor_attach: sc=%p\n", sc));
|
|
|
|
|
|
|
|
/* Move the device into the configured state. */
|
|
|
|
err = usbd_set_config_index(dev, UVISOR_CONFIG_INDEX, 1);
|
|
|
|
if (err) {
|
|
|
|
printf("\n%s: failed to set configuration, err=%s\n",
|
|
|
|
devname, usbd_errstr(err));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = usbd_device2interface_handle(dev, UVISOR_IFACE_INDEX, &iface);
|
|
|
|
if (err) {
|
|
|
|
printf("\n%s: failed to get interface, err=%s\n",
|
|
|
|
devname, usbd_errstr(err));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2005-05-11 14:02:28 +04:00
|
|
|
devinfop = usbd_devinfo_alloc(dev, 0);
|
2000-03-30 20:56:19 +04:00
|
|
|
USB_ATTACH_SETUP;
|
2005-05-11 14:02:28 +04:00
|
|
|
printf("%s: %s\n", devname, devinfop);
|
|
|
|
usbd_devinfo_free(devinfop);
|
2000-03-30 20:56:19 +04:00
|
|
|
|
2002-02-28 02:00:03 +03:00
|
|
|
sc->sc_flags = uvisor_lookup(uaa->vendor, uaa->product)->uv_flags;
|
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
if ((sc->sc_flags & (VISOR | PALM4)) == 0) {
|
2005-02-27 03:26:58 +03:00
|
|
|
printf("%s: init failed, device type is neither visor nor palm\n",
|
2003-08-04 01:59:26 +04:00
|
|
|
USBDEVNAME(sc->sc_dev));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
id = usbd_get_interface_descriptor(iface);
|
2000-04-05 15:12:48 +04:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
sc->sc_udev = dev;
|
2000-04-05 15:12:48 +04:00
|
|
|
sc->sc_iface = iface;
|
2000-03-30 20:56:19 +04:00
|
|
|
|
2000-04-06 17:32:28 +04:00
|
|
|
uca.ibufsize = UVISORIBUFSIZE;
|
|
|
|
uca.obufsize = UVISOROBUFSIZE;
|
2000-04-14 18:21:55 +04:00
|
|
|
uca.ibufsizepad = UVISORIBUFSIZE;
|
2000-09-03 23:15:45 +04:00
|
|
|
uca.opkthdrlen = 0;
|
2000-04-06 17:32:28 +04:00
|
|
|
uca.device = dev;
|
|
|
|
uca.iface = iface;
|
|
|
|
uca.methods = &uvisor_methods;
|
|
|
|
uca.arg = sc;
|
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
err = uvisor_init(sc, &coninfo, &palmconinfo);
|
2000-03-30 20:56:19 +04:00
|
|
|
if (err) {
|
|
|
|
printf("%s: init failed, %s\n", USBDEVNAME(sc->sc_dev),
|
|
|
|
usbd_errstr(err));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2001-01-23 17:04:13 +03:00
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
|
|
|
|
USBDEV(sc->sc_dev));
|
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
if (sc->sc_flags & VISOR) {
|
|
|
|
sc->sc_numcon = UGETW(coninfo.num_ports);
|
|
|
|
if (sc->sc_numcon > UVISOR_MAX_CONN)
|
|
|
|
sc->sc_numcon = UVISOR_MAX_CONN;
|
|
|
|
|
|
|
|
/* Attach a ucom for each connection. */
|
|
|
|
for (i = 0; i < sc->sc_numcon; ++i) {
|
|
|
|
switch (coninfo.connections[i].port_function_id) {
|
|
|
|
case UVISOR_FUNCTION_GENERIC:
|
|
|
|
uca.info = "Generic";
|
|
|
|
break;
|
|
|
|
case UVISOR_FUNCTION_DEBUGGER:
|
|
|
|
uca.info = "Debugger";
|
|
|
|
break;
|
|
|
|
case UVISOR_FUNCTION_HOTSYNC:
|
|
|
|
uca.info = "HotSync";
|
|
|
|
break;
|
|
|
|
case UVISOR_FUNCTION_REMOTE_FILE_SYS:
|
|
|
|
uca.info = "Remote File System";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
uca.info = "unknown";
|
2001-01-24 00:19:44 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-08-04 01:59:26 +04:00
|
|
|
port = coninfo.connections[i].port;
|
|
|
|
uca.portno = port;
|
|
|
|
uca.bulkin = port | UE_DIR_IN;
|
|
|
|
uca.bulkout = port | UE_DIR_OUT;
|
|
|
|
/* Verify that endpoints exist. */
|
|
|
|
hasin = 0;
|
|
|
|
hasout = 0;
|
|
|
|
for (j = 0; j < id->bNumEndpoints; j++) {
|
|
|
|
ed = usbd_interface2endpoint_descriptor(iface, j);
|
|
|
|
if (ed == NULL)
|
|
|
|
break;
|
|
|
|
if (UE_GET_ADDR(ed->bEndpointAddress) == port &&
|
|
|
|
(ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
|
|
|
|
if (UE_GET_DIR(ed->bEndpointAddress)
|
|
|
|
== UE_DIR_IN)
|
|
|
|
hasin++;
|
|
|
|
else
|
|
|
|
hasout++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasin == 1 && hasout == 1)
|
2004-09-13 16:55:47 +04:00
|
|
|
sc->sc_subdevs[i] = config_found_sm_loc(self,
|
|
|
|
"ucombus", NULL, &uca,
|
|
|
|
ucomprint, ucomsubmatch);
|
2003-08-04 01:59:26 +04:00
|
|
|
else
|
|
|
|
printf("%s: no proper endpoints for port %d (%d,%d)\n",
|
|
|
|
USBDEVNAME(sc->sc_dev), port, hasin, hasout);
|
2001-01-24 00:19:44 +03:00
|
|
|
}
|
2003-08-04 01:59:26 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
sc->sc_numcon = palmconinfo.num_ports;
|
|
|
|
if (sc->sc_numcon > UVISOR_MAX_CONN)
|
|
|
|
sc->sc_numcon = UVISOR_MAX_CONN;
|
|
|
|
|
|
|
|
/* Attach a ucom for each connection. */
|
|
|
|
for (i = 0; i < sc->sc_numcon; ++i) {
|
2005-02-27 03:26:58 +03:00
|
|
|
/*
|
|
|
|
* XXX this should copy out 4-char string from the
|
2003-08-04 01:59:26 +04:00
|
|
|
* XXX port_function_id, but where would the string go?
|
|
|
|
* XXX uca.info is a const char *, not an array.
|
|
|
|
*/
|
|
|
|
uca.info = "sync";
|
|
|
|
uca.portno = i;
|
|
|
|
if (palmconinfo.endpoint_numbers_different) {
|
|
|
|
port = palmconinfo.connections[i].end_point_info;
|
|
|
|
uca.bulkin = (port >> 4) | UE_DIR_IN;
|
|
|
|
uca.bulkout = (port & 0xf) | UE_DIR_OUT;
|
|
|
|
} else {
|
|
|
|
port = palmconinfo.connections[i].port;
|
|
|
|
uca.bulkin = port | UE_DIR_IN;
|
|
|
|
uca.bulkout = port | UE_DIR_OUT;
|
|
|
|
}
|
2004-09-13 16:55:47 +04:00
|
|
|
sc->sc_subdevs[i] = config_found_sm_loc(self, "ucombus",
|
|
|
|
NULL, &uca, ucomprint, ucomsubmatch);
|
2003-08-04 01:59:26 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
}
|
2001-01-24 00:19:44 +03:00
|
|
|
}
|
2002-07-12 01:14:24 +04:00
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
USB_ATTACH_SUCCESS_RETURN;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
DPRINTF(("uvisor_attach: ATTACH ERROR\n"));
|
|
|
|
sc->sc_dying = 1;
|
|
|
|
USB_ATTACH_ERROR_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-06-01 18:28:57 +04:00
|
|
|
uvisor_activate(device_ptr_t self, enum devact act)
|
2000-03-30 20:56:19 +04:00
|
|
|
{
|
|
|
|
struct uvisor_softc *sc = (struct uvisor_softc *)self;
|
|
|
|
int rv = 0;
|
2001-01-24 00:19:44 +03:00
|
|
|
int i;
|
2000-03-30 20:56:19 +04:00
|
|
|
|
|
|
|
switch (act) {
|
|
|
|
case DVACT_ACTIVATE:
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DVACT_DEACTIVATE:
|
2001-01-24 00:19:44 +03:00
|
|
|
for (i = 0; i < sc->sc_numcon; i++)
|
|
|
|
if (sc->sc_subdevs[i] != NULL)
|
2003-10-29 02:33:46 +03:00
|
|
|
rv |= config_deactivate(sc->sc_subdevs[i]);
|
2000-03-30 20:56:19 +04:00
|
|
|
sc->sc_dying = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-06-01 18:28:57 +04:00
|
|
|
uvisor_detach(device_ptr_t self, int flags)
|
2000-03-30 20:56:19 +04:00
|
|
|
{
|
|
|
|
struct uvisor_softc *sc = (struct uvisor_softc *)self;
|
|
|
|
int rv = 0;
|
2001-01-24 00:19:44 +03:00
|
|
|
int i;
|
2000-03-30 20:56:19 +04:00
|
|
|
|
|
|
|
DPRINTF(("uvisor_detach: sc=%p flags=%d\n", sc, flags));
|
|
|
|
sc->sc_dying = 1;
|
2001-01-24 00:19:44 +03:00
|
|
|
for (i = 0; i < sc->sc_numcon; i++) {
|
|
|
|
if (sc->sc_subdevs[i] != NULL) {
|
|
|
|
rv |= config_detach(sc->sc_subdevs[i], flags);
|
|
|
|
sc->sc_subdevs[i] = NULL;
|
|
|
|
}
|
2000-03-30 20:56:19 +04:00
|
|
|
}
|
2001-01-23 17:04:13 +03:00
|
|
|
|
2007-01-24 15:26:49 +03:00
|
|
|
if (sc->sc_udev)
|
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
|
|
|
|
USBDEV(sc->sc_dev));
|
2001-01-23 17:04:13 +03:00
|
|
|
|
|
|
|
|
2001-01-24 00:19:44 +03:00
|
|
|
return (rv);
|
2000-03-30 20:56:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
usbd_status
|
2003-08-04 01:59:26 +04:00
|
|
|
uvisor_init(struct uvisor_softc *sc, struct uvisor_connection_info *ci,
|
|
|
|
struct uvisor_palm_connection_info *cpi)
|
2000-03-30 20:56:19 +04:00
|
|
|
{
|
|
|
|
usbd_status err;
|
|
|
|
usb_device_request_t req;
|
|
|
|
int actlen;
|
|
|
|
uWord avail;
|
|
|
|
|
2003-08-04 01:59:26 +04:00
|
|
|
if (sc->sc_flags & VISOR) {
|
|
|
|
DPRINTF(("uvisor_init: getting Visor connection info\n"));
|
2002-02-28 02:00:03 +03:00
|
|
|
req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
|
2003-08-04 01:59:26 +04:00
|
|
|
req.bRequest = UVISOR_GET_CONNECTION_INFORMATION;
|
2002-02-28 02:00:03 +03:00
|
|
|
USETW(req.wValue, 0);
|
|
|
|
USETW(req.wIndex, 0);
|
2003-08-04 01:59:26 +04:00
|
|
|
USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE);
|
|
|
|
err = usbd_do_request_flags(sc->sc_udev, &req, ci,
|
|
|
|
USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT);
|
2002-02-28 02:00:03 +03:00
|
|
|
if (err)
|
|
|
|
return (err);
|
2003-08-04 01:59:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_flags & PALM4) {
|
|
|
|
DPRINTF(("uvisor_init: getting Palm connection info\n"));
|
2002-02-28 02:00:03 +03:00
|
|
|
req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
|
|
|
|
req.bRequest = UVISOR_GET_PALM_INFORMATION;
|
|
|
|
USETW(req.wValue, 0);
|
|
|
|
USETW(req.wIndex, 0);
|
|
|
|
USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN);
|
2003-08-04 01:59:26 +04:00
|
|
|
err = usbd_do_request_flags(sc->sc_udev, &req, cpi,
|
|
|
|
USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT);
|
2002-02-28 02:00:03 +03:00
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
DPRINTF(("uvisor_init: getting available bytes\n"));
|
|
|
|
req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
|
|
|
|
req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE;
|
|
|
|
USETW(req.wValue, 0);
|
|
|
|
USETW(req.wIndex, 5);
|
|
|
|
USETW(req.wLength, sizeof avail);
|
|
|
|
err = usbd_do_request(sc->sc_udev, &req, &avail);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
DPRINTF(("uvisor_init: avail=%d\n", UGETW(avail)));
|
|
|
|
|
|
|
|
DPRINTF(("uvisor_init: done\n"));
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
uvisor_close(void *addr, int portno)
|
2000-03-30 20:56:19 +04:00
|
|
|
{
|
|
|
|
struct uvisor_softc *sc = addr;
|
|
|
|
usb_device_request_t req;
|
|
|
|
struct uvisor_connection_info coninfo; /* XXX ? */
|
|
|
|
int actlen;
|
|
|
|
|
2000-04-05 15:12:48 +04:00
|
|
|
if (sc->sc_dying)
|
|
|
|
return;
|
|
|
|
|
2000-03-30 20:56:19 +04:00
|
|
|
req.bmRequestType = UT_READ_VENDOR_ENDPOINT; /* XXX read? */
|
|
|
|
req.bRequest = UVISOR_CLOSE_NOTIFICATION;
|
|
|
|
USETW(req.wValue, 0);
|
|
|
|
USETW(req.wIndex, 0);
|
|
|
|
USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE);
|
2002-07-12 01:14:24 +04:00
|
|
|
(void)usbd_do_request_flags(sc->sc_udev, &req, &coninfo,
|
2002-02-11 18:11:49 +03:00
|
|
|
USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT);
|
2000-03-30 20:56:19 +04:00
|
|
|
}
|