Home | History | Annotate | Download | only in descriptors
      1 /*
      2  * Copyright (C) 2017 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 package com.android.server.usb.descriptors;
     17 
     18 /**
     19  * @hide
     20  * An audio class-specific Audio Control Endpoint.
     21  * audio10.pdf section 4.4.2.1
     22  */
     23 public class UsbACAudioControlEndpoint extends UsbACEndpoint {
     24     private static final String TAG = "UsbACAudioControlEndpoint";
     25 
     26     private byte mAddress;  // 2:1 The address of the endpoint on the USB device.
     27                             // D7: Direction. 1 = IN endpoint
     28                             // D6..4: Reserved, reset to zero
     29                             // D3..0: The endpoint number.
     30     private byte mAttribs;  // 3:1 (see ATTRIBSMASK_* below
     31     private int mMaxPacketSize; // 4:2 Maximum packet size this endpoint is capable of sending
     32                                 // or receiving when this configuration is selected.
     33     private byte mInterval; // 6:1
     34 
     35     static final byte ADDRESSMASK_DIRECTION = (byte) 0x80;
     36     static final byte ADDRESSMASK_ENDPOINT  = 0x0F;
     37 
     38     static final byte ATTRIBSMASK_SYNC  = 0x0C;
     39     static final byte ATTRIBMASK_TRANS  = 0x03;
     40 
     41     public UsbACAudioControlEndpoint(int length, byte type, int subclass) {
     42         super(length, type, subclass);
     43     }
     44 
     45     public byte getAddress() {
     46         return mAddress;
     47     }
     48 
     49     public byte getAttribs() {
     50         return mAttribs;
     51     }
     52 
     53     public int getMaxPacketSize() {
     54         return mMaxPacketSize;
     55     }
     56 
     57     public byte getInterval() {
     58         return mInterval;
     59     }
     60 
     61     @Override
     62     public int parseRawDescriptors(ByteStream stream) {
     63         super.parseRawDescriptors(stream);
     64 
     65         mAddress = stream.getByte();
     66         mAttribs = stream.getByte();
     67         mMaxPacketSize = stream.unpackUsbShort();
     68         mInterval = stream.getByte();
     69 
     70         return mLength;
     71     }
     72 }
     73