Home | History | Annotate | Download | only in sink
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.accessorydisplay.sink;
     18 
     19 // Constants from kernel include/linux/usb/f_accessory.h
     20 final class UsbAccessoryConstants {
     21     /* Use Google Vendor ID when in accessory mode */
     22     public static final int USB_ACCESSORY_VENDOR_ID = 0x18D1;
     23 
     24     /* Product ID to use when in accessory mode */
     25     public static final int USB_ACCESSORY_PRODUCT_ID = 0x2D00;
     26 
     27     /* Product ID to use when in accessory mode and adb is enabled */
     28     public static final int USB_ACCESSORY_ADB_PRODUCT_ID = 0x2D01;
     29 
     30     /* Indexes for strings sent by the host via ACCESSORY_SEND_STRING */
     31     public static final int ACCESSORY_STRING_MANUFACTURER = 0;
     32     public static final int ACCESSORY_STRING_MODEL = 1;
     33     public static final int ACCESSORY_STRING_DESCRIPTION = 2;
     34     public static final int ACCESSORY_STRING_VERSION = 3;
     35     public static final int ACCESSORY_STRING_URI = 4;
     36     public static final int ACCESSORY_STRING_SERIAL = 5;
     37 
     38     /* Control request for retrieving device's protocol version
     39      *
     40      *  requestType:    USB_DIR_IN | USB_TYPE_VENDOR
     41      *  request:        ACCESSORY_GET_PROTOCOL
     42      *  value:          0
     43      *  index:          0
     44      *  data            version number (16 bits little endian)
     45      *                     1 for original accessory support
     46      *                     2 adds HID and device to host audio support
     47      */
     48     public static final int ACCESSORY_GET_PROTOCOL = 51;
     49 
     50     /* Control request for host to send a string to the device
     51      *
     52      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
     53      *  request:        ACCESSORY_SEND_STRING
     54      *  value:          0
     55      *  index:          string ID
     56      *  data            zero terminated UTF8 string
     57      *
     58      *  The device can later retrieve these strings via the
     59      *  ACCESSORY_GET_STRING_* ioctls
     60      */
     61     public static final int ACCESSORY_SEND_STRING = 52;
     62 
     63     /* Control request for starting device in accessory mode.
     64      * The host sends this after setting all its strings to the device.
     65      *
     66      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
     67      *  request:        ACCESSORY_START
     68      *  value:          0
     69      *  index:          0
     70      *  data            none
     71      */
     72     public static final int ACCESSORY_START = 53;
     73 
     74     /* Control request for registering a HID device.
     75      * Upon registering, a unique ID is sent by the accessory in the
     76      * value parameter. This ID will be used for future commands for
     77      * the device
     78      *
     79      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
     80      *  request:        ACCESSORY_REGISTER_HID_DEVICE
     81      *  value:          Accessory assigned ID for the HID device
     82      *  index:          total length of the HID report descriptor
     83      *  data            none
     84      */
     85     public static final int ACCESSORY_REGISTER_HID = 54;
     86 
     87     /* Control request for unregistering a HID device.
     88      *
     89      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
     90      *  request:        ACCESSORY_REGISTER_HID
     91      *  value:          Accessory assigned ID for the HID device
     92      *  index:          0
     93      *  data            none
     94      */
     95     public static final int ACCESSORY_UNREGISTER_HID = 55;
     96 
     97     /* Control request for sending the HID report descriptor.
     98      * If the HID descriptor is longer than the endpoint zero max packet size,
     99      * the descriptor will be sent in multiple ACCESSORY_SET_HID_REPORT_DESC
    100      * commands. The data for the descriptor must be sent sequentially
    101      * if multiple packets are needed.
    102      *
    103      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
    104      *  request:        ACCESSORY_SET_HID_REPORT_DESC
    105      *  value:          Accessory assigned ID for the HID device
    106      *  index:          offset of data in descriptor
    107      *                      (needed when HID descriptor is too big for one packet)
    108      *  data            the HID report descriptor
    109      */
    110     public static final int ACCESSORY_SET_HID_REPORT_DESC = 56;
    111 
    112     /* Control request for sending HID events.
    113      *
    114      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
    115      *  request:        ACCESSORY_SEND_HID_EVENT
    116      *  value:          Accessory assigned ID for the HID device
    117      *  index:          0
    118      *  data            the HID report for the event
    119      */
    120     public static final int ACCESSORY_SEND_HID_EVENT = 57;
    121 
    122     /* Control request for setting the audio mode.
    123      *
    124      *  requestType:    USB_DIR_OUT | USB_TYPE_VENDOR
    125      *  request:        ACCESSORY_SET_AUDIO_MODE
    126      *  value:          0 - no audio
    127      *                     1 - device to host, 44100 16-bit stereo PCM
    128      *  index:          0
    129      *  data            none
    130      */
    131     public static final int ACCESSORY_SET_AUDIO_MODE = 58;
    132 
    133     private UsbAccessoryConstants() {
    134     }
    135 }
    136