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 // import com.android.server.usb.descriptors.report.ReportCanvas;
     19 
     20 /**
     21  * @hide
     22  * An audio class-specific Selector Unit Interface.
     23  * see audio10.pdf section 4.3.2.4
     24  */
     25 public final class UsbACSelectorUnit extends UsbACInterface {
     26     private static final String TAG = "UsbACSelectorUnit";
     27 
     28     private byte mUnitID;   // 3:1 Constant uniquely identifying the Unit within the audio function.
     29                             // This value is used in all requests to address this Unit.
     30     private byte mNumPins;  // 4:1 Number of input pins in this unit
     31     private byte[] mSourceIDs;  // 5+mNumPins:1 ID of the Unit or Terminal to which the first
     32                                 // Input Pin of this Selector Unit is connected.
     33     private byte mNameIndex;    // Index of a string descriptor, describing the Selector Unit.
     34 
     35     public UsbACSelectorUnit(int length, byte type, byte subtype, int subClass) {
     36         super(length, type, subtype, subClass);
     37     }
     38 
     39     public byte getUnitID() {
     40         return mUnitID;
     41     }
     42 
     43     public byte getNumPins() {
     44         return mNumPins;
     45     }
     46 
     47     public byte[] getSourceIDs() {
     48         return mSourceIDs;
     49     }
     50 
     51     public byte getNameIndex() {
     52         return mNameIndex;
     53     }
     54 
     55     @Override
     56     public int parseRawDescriptors(ByteStream stream) {
     57         mUnitID = stream.getByte();
     58         mNumPins = stream.getByte();
     59         mSourceIDs = new byte[mNumPins];
     60         for (int index = 0; index < mNumPins; index++) {
     61             mSourceIDs[index] = stream.getByte();
     62         }
     63         mNameIndex = stream.getByte();
     64 
     65         return mLength;
     66     }
     67 
     68 //    @Override
     69 //    public void report(ReportCanvas canvas) {
     70 //        super.report(canvas);
     71 //
     72 //        //TODO
     73 //    }
     74 }
     75