102ac6454SAndrew Thompson /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 402ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 502ac6454SAndrew Thompson * 602ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 702ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 802ac6454SAndrew Thompson * are met: 902ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1002ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1102ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1202ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1302ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1402ac6454SAndrew Thompson * 1502ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1602ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1702ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1802ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1902ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2002ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2102ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2202ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2302ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2402ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2502ac6454SAndrew Thompson * SUCH DAMAGE. 2602ac6454SAndrew Thompson */ 2702ac6454SAndrew Thompson 2802ac6454SAndrew Thompson /* This file contains various factored out debug macros. */ 2902ac6454SAndrew Thompson 3075973647SAndrew Thompson #ifndef _USB_DEBUG_H_ 3175973647SAndrew Thompson #define _USB_DEBUG_H_ 3202ac6454SAndrew Thompson 3302ac6454SAndrew Thompson /* Declare global USB debug variable. */ 34a593f6b8SAndrew Thompson extern int usb_debug; 3502ac6454SAndrew Thompson 3602ac6454SAndrew Thompson /* Check if USB debugging is enabled. */ 3702ac6454SAndrew Thompson #ifdef USB_DEBUG_VAR 38b850ecc1SAndrew Thompson #ifdef USB_DEBUG 3902ac6454SAndrew Thompson #define DPRINTFN(n,fmt,...) do { \ 4002ac6454SAndrew Thompson if ((USB_DEBUG_VAR) >= (n)) { \ 41767cb2e2SAndrew Thompson printf("%s: " fmt, \ 42767cb2e2SAndrew Thompson __FUNCTION__ ,##__VA_ARGS__); \ 4302ac6454SAndrew Thompson } \ 4402ac6454SAndrew Thompson } while (0) 4502ac6454SAndrew Thompson #define DPRINTF(...) DPRINTFN(1, __VA_ARGS__) 46ffd8101eSJohn Baldwin #define __usbdebug_used 4702ac6454SAndrew Thompson #else 4802ac6454SAndrew Thompson #define DPRINTF(...) do { } while (0) 4902ac6454SAndrew Thompson #define DPRINTFN(...) do { } while (0) 50ffd8101eSJohn Baldwin #define __usbdebug_used __unused 5102ac6454SAndrew Thompson #endif 5202ac6454SAndrew Thompson #endif 5302ac6454SAndrew Thompson 54760bc48eSAndrew Thompson struct usb_interface; 55760bc48eSAndrew Thompson struct usb_device; 56ae60fdfbSAndrew Thompson struct usb_endpoint; 57760bc48eSAndrew Thompson struct usb_xfer; 5802ac6454SAndrew Thompson 59a593f6b8SAndrew Thompson void usb_dump_iface(struct usb_interface *iface); 60a593f6b8SAndrew Thompson void usb_dump_device(struct usb_device *udev); 61a593f6b8SAndrew Thompson void usb_dump_queue(struct usb_endpoint *ep); 62a593f6b8SAndrew Thompson void usb_dump_endpoint(struct usb_endpoint *ep); 63a593f6b8SAndrew Thompson void usb_dump_xfer(struct usb_xfer *xfer); 6402ac6454SAndrew Thompson 6537506412SHans Petter Selasky #ifdef USB_DEBUG 6662d42655SHans Petter Selasky extern unsigned usb_port_reset_delay; 6762d42655SHans Petter Selasky extern unsigned usb_port_root_reset_delay; 6862d42655SHans Petter Selasky extern unsigned usb_port_reset_recovery; 6962d42655SHans Petter Selasky extern unsigned usb_port_powerup_delay; 7062d42655SHans Petter Selasky extern unsigned usb_port_resume_delay; 7162d42655SHans Petter Selasky extern unsigned usb_set_address_settle; 7262d42655SHans Petter Selasky extern unsigned usb_resume_delay; 7362d42655SHans Petter Selasky extern unsigned usb_resume_wait; 7462d42655SHans Petter Selasky extern unsigned usb_resume_recovery; 7562d42655SHans Petter Selasky extern unsigned usb_extra_power_up_time; 7662d42655SHans Petter Selasky extern unsigned usb_enum_nice_time; 7737506412SHans Petter Selasky #else 7837506412SHans Petter Selasky #define usb_port_reset_delay USB_PORT_RESET_DELAY 7937506412SHans Petter Selasky #define usb_port_root_reset_delay USB_PORT_ROOT_RESET_DELAY 8037506412SHans Petter Selasky #define usb_port_reset_recovery USB_PORT_RESET_RECOVERY 8137506412SHans Petter Selasky #define usb_port_powerup_delay USB_PORT_POWERUP_DELAY 8237506412SHans Petter Selasky #define usb_port_resume_delay USB_PORT_RESUME_DELAY 8337506412SHans Petter Selasky #define usb_set_address_settle USB_SET_ADDRESS_SETTLE 8437506412SHans Petter Selasky #define usb_resume_delay USB_RESUME_DELAY 8537506412SHans Petter Selasky #define usb_resume_wait USB_RESUME_WAIT 8637506412SHans Petter Selasky #define usb_resume_recovery USB_RESUME_RECOVERY 8737506412SHans Petter Selasky #define usb_extra_power_up_time USB_EXTRA_POWER_UP_TIME 888758aabbSHans Petter Selasky #define usb_enum_nice_time USB_ENUM_NICE_TIME 8937506412SHans Petter Selasky #endif 9037506412SHans Petter Selasky 9175973647SAndrew Thompson #endif /* _USB_DEBUG_H_ */ 92