1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Gadget Function Driver for Android USB accessories 4 * 5 * Copyright 2011-2024 Google LLC 6 * 7 */ 8 9 #ifndef _UAPI_ANDROID_ACCESSORY_H 10 #define _UAPI_ANDROID_ACCESSORY_H 11 12 /* Use Google Vendor ID when in accessory mode */ 13 #define USB_ACCESSORY_VENDOR_ID 0x18D1 14 15 /* Product ID to use when in accessory mode */ 16 #define USB_ACCESSORY_PRODUCT_ID 0x2D00 17 18 /* Product ID to use when in accessory mode and adb is enabled */ 19 #define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01 20 21 /* Indexes for strings sent by the host via ACCESSORY_SEND_STRING */ 22 #define ACCESSORY_STRING_MANUFACTURER 0 23 #define ACCESSORY_STRING_MODEL 1 24 #define ACCESSORY_STRING_DESCRIPTION 2 25 #define ACCESSORY_STRING_VERSION 3 26 #define ACCESSORY_STRING_URI 4 27 #define ACCESSORY_STRING_SERIAL 5 28 29 #define ACC_STRING_SIZE 256 30 31 /* Control request for retrieving device's protocol version 32 * 33 * requestType: USB_DIR_IN | USB_TYPE_VENDOR 34 * request: ACCESSORY_GET_PROTOCOL 35 * value: 0 36 * index: 0 37 * data: version number (16 bits little endian) 38 * 1 for original accessory support 39 * 2 adds HID and device to host audio support 40 */ 41 #define ACCESSORY_GET_PROTOCOL 51 42 43 /* Control request for host to send a string to the device 44 * 45 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 46 * request: ACCESSORY_SEND_STRING 47 * value: 0 48 * index: string ID 49 * data: zero terminated UTF8 string 50 * 51 * The device can later retrieve these strings via the 52 * ACCESSORY_GET_STRING_* ioctls 53 */ 54 #define ACCESSORY_SEND_STRING 52 55 56 /* Control request for starting device in accessory mode. 57 * The host sends this after setting all its strings to the device. 58 * 59 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 60 * request: ACCESSORY_START 61 * value: 0 62 * index: 0 63 * data: none 64 */ 65 #define ACCESSORY_START 53 66 67 /* Control request for registering a HID device. 68 * Upon registering, a unique ID is sent by the accessory in the 69 * value parameter. This ID will be used for future commands for 70 * the device 71 * 72 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 73 * request: ACCESSORY_REGISTER_HID_DEVICE 74 * value: Accessory assigned ID for the HID device 75 * index: total length of the HID report descriptor 76 * data: none 77 */ 78 #define ACCESSORY_REGISTER_HID 54 79 80 /* Control request for unregistering a HID device. 81 * 82 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 83 * request: ACCESSORY_REGISTER_HID 84 * value: Accessory assigned ID for the HID device 85 * index: 0 86 * data: none 87 */ 88 #define ACCESSORY_UNREGISTER_HID 55 89 90 /* Control request for sending the HID report descriptor. 91 * If the HID descriptor is longer than the endpoint zero max packet size, 92 * the descriptor will be sent in multiple ACCESSORY_SET_HID_REPORT_DESC 93 * commands. The data for the descriptor must be sent sequentially 94 * if multiple packets are needed. 95 * 96 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 97 * request: ACCESSORY_SET_HID_REPORT_DESC 98 * value: Accessory assigned ID for the HID device 99 * index: offset of data in descriptor 100 * (needed when HID descriptor is too big for one packet) 101 * data: the HID report descriptor 102 */ 103 #define ACCESSORY_SET_HID_REPORT_DESC 56 104 105 /* Control request for sending HID events. 106 * 107 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 108 * request: ACCESSORY_SEND_HID_EVENT 109 * value: Accessory assigned ID for the HID device 110 * index: 0 111 * data: the HID report for the event 112 */ 113 #define ACCESSORY_SEND_HID_EVENT 57 114 115 /* Control request for setting the audio mode. 116 * 117 * DEPRECATED! Do not implement a new device which uses this. 118 * 119 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR 120 * request: ACCESSORY_SET_AUDIO_MODE 121 * value: 0 - no audio 122 * 1 - device to host, 44100 16-bit stereo PCM 123 * index: 0 124 * data: none 125 */ 126 #define ACCESSORY_SET_AUDIO_MODE 58 127 128 /* ioctls for retrieving strings set by the host */ 129 #define ACCESSORY_GET_STRING_MANUFACTURER _IOW('M', 1, char[ACC_STRING_SIZE]) 130 #define ACCESSORY_GET_STRING_MODEL _IOW('M', 2, char[ACC_STRING_SIZE]) 131 #define ACCESSORY_GET_STRING_DESCRIPTION _IOW('M', 3, char[ACC_STRING_SIZE]) 132 #define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[ACC_STRING_SIZE]) 133 #define ACCESSORY_GET_STRING_URI _IOW('M', 5, char[ACC_STRING_SIZE]) 134 #define ACCESSORY_GET_STRING_SERIAL _IOW('M', 6, char[ACC_STRING_SIZE]) 135 /* returns 1 if there is a start request pending */ 136 #define ACCESSORY_IS_START_REQUESTED _IO('M', 7) 137 /* returns audio mode (set via the ACCESSORY_SET_AUDIO_MODE control request) */ 138 #define ACCESSORY_GET_AUDIO_MODE _IO('M', 8) 139 140 #endif /* _UAPI_ANDROID__ACCESSORY_H */ 141