1184610Salfred/* $FreeBSD$ */ 2184610Salfred/*- 3184610Salfred * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4184610Salfred * 5184610Salfred * Redistribution and use in source and binary forms, with or without 6184610Salfred * modification, are permitted provided that the following conditions 7184610Salfred * are met: 8184610Salfred * 1. Redistributions of source code must retain the above copyright 9184610Salfred * notice, this list of conditions and the following disclaimer. 10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 11184610Salfred * notice, this list of conditions and the following disclaimer in the 12184610Salfred * documentation and/or other materials provided with the distribution. 13184610Salfred * 14184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22184610Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24184610Salfred * SUCH DAMAGE. 25184610Salfred */ 26184610Salfred 27184610Salfred/* This file contains various factored out debug macros. */ 28184610Salfred 29194230Sthompsa#ifndef _USB_DEBUG_H_ 30194230Sthompsa#define _USB_DEBUG_H_ 31184610Salfred 32184610Salfred/* Declare global USB debug variable. */ 33194228Sthompsaextern int usb_debug; 34184610Salfred 35184610Salfred/* Check if USB debugging is enabled. */ 36184610Salfred#ifdef USB_DEBUG_VAR 37207077Sthompsa#ifdef USB_DEBUG 38199816Sthompsa#define DPRINTFN(n,fmt,...) do { \ 39199816Sthompsa if ((USB_DEBUG_VAR) >= (n)) { \ 40199816Sthompsa printf("%s: " fmt, \ 41250205Shselasky __FUNCTION__ ,##__VA_ARGS__); \ 42199816Sthompsa } \ 43184610Salfred} while (0) 44184610Salfred#define DPRINTF(...) DPRINTFN(1, __VA_ARGS__) 45184610Salfred#else 46184610Salfred#define DPRINTF(...) do { } while (0) 47184610Salfred#define DPRINTFN(...) do { } while (0) 48184610Salfred#endif 49184610Salfred#endif 50184610Salfred 51192984Sthompsastruct usb_interface; 52192984Sthompsastruct usb_device; 53193644Sthompsastruct usb_endpoint; 54192984Sthompsastruct usb_xfer; 55184610Salfred 56194228Sthompsavoid usb_dump_iface(struct usb_interface *iface); 57194228Sthompsavoid usb_dump_device(struct usb_device *udev); 58194228Sthompsavoid usb_dump_queue(struct usb_endpoint *ep); 59194228Sthompsavoid usb_dump_endpoint(struct usb_endpoint *ep); 60194228Sthompsavoid usb_dump_xfer(struct usb_xfer *xfer); 61184610Salfred 62241987Shselasky#ifdef USB_DEBUG 63241987Shselaskyextern unsigned int usb_port_reset_delay; 64241987Shselaskyextern unsigned int usb_port_root_reset_delay; 65241987Shselaskyextern unsigned int usb_port_reset_recovery; 66241987Shselaskyextern unsigned int usb_port_powerup_delay; 67241987Shselaskyextern unsigned int usb_port_resume_delay; 68241987Shselaskyextern unsigned int usb_set_address_settle; 69241987Shselaskyextern unsigned int usb_resume_delay; 70241987Shselaskyextern unsigned int usb_resume_wait; 71241987Shselaskyextern unsigned int usb_resume_recovery; 72241987Shselaskyextern unsigned int usb_extra_power_up_time; 73241987Shselasky#else 74241987Shselasky#define usb_port_reset_delay USB_PORT_RESET_DELAY 75241987Shselasky#define usb_port_root_reset_delay USB_PORT_ROOT_RESET_DELAY 76241987Shselasky#define usb_port_reset_recovery USB_PORT_RESET_RECOVERY 77241987Shselasky#define usb_port_powerup_delay USB_PORT_POWERUP_DELAY 78241987Shselasky#define usb_port_resume_delay USB_PORT_RESUME_DELAY 79241987Shselasky#define usb_set_address_settle USB_SET_ADDRESS_SETTLE 80241987Shselasky#define usb_resume_delay USB_RESUME_DELAY 81241987Shselasky#define usb_resume_wait USB_RESUME_WAIT 82241987Shselasky#define usb_resume_recovery USB_RESUME_RECOVERY 83241987Shselasky#define usb_extra_power_up_time USB_EXTRA_POWER_UP_TIME 84241987Shselasky#endif 85241987Shselasky 86194230Sthompsa#endif /* _USB_DEBUG_H_ */ 87