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 Output Terminal interface.
     23  * see Audio20.pdf section 3.13.3 Output Terminal
     24  */
     25 public final class Usb20ACOutputTerminal extends UsbACTerminal {
     26     private static final String TAG = "Usb20ACOutputTerminal";
     27 
     28     // Audio20.pdf - section 4.7.2.5, Table  4-10
     29     // Always 12 bytes
     30     private byte mSourceID;     // 7:1 - ID of the Unit or Terminal to which this
     31                                 // Terminal is connected.
     32     private byte mClkSoureID;   // 8:1 - ID of the Clock Entity to which this Output
     33     // Terminal is connected.
     34     private int mControls;      // 9:2 - see Audio20.pdf Table 4-10
     35     private byte mTerminalID;   // 11:1 - Index of a string descriptor, describing the
     36 
     37     public Usb20ACOutputTerminal(int length, byte type, byte subtype, int subClass) {
     38         super(length, type, subtype, subClass);
     39     }
     40 
     41     public byte getSourceID() {
     42         return mSourceID;
     43     }
     44 
     45     public byte getClkSourceID() {
     46         return mClkSoureID;
     47     }
     48 
     49     public int getControls() {
     50         return mControls;
     51     }
     52 
     53     public byte getTerminalID() {
     54         return mTerminalID;
     55     }
     56 
     57     @Override
     58     public int parseRawDescriptors(ByteStream stream) {
     59         super.parseRawDescriptors(stream);
     60 
     61         mSourceID = stream.getByte();
     62         mClkSoureID = stream.getByte();
     63         mControls = stream.unpackUsbShort();
     64         mTerminalID = stream.getByte();
     65 
     66         return mLength;
     67     }
     68 
     69     @Override
     70     public void report(ReportCanvas canvas) {
     71         super.report(canvas);
     72 
     73         canvas.openList();
     74         canvas.writeListItem("Clock Source ID: " + getClkSourceID());
     75         canvas.writeListItem("Controls: " + ReportCanvas.getHexString(getControls()));
     76         canvas.writeListItem("Terminal Name ID: " + getTerminalID());
     77         canvas.closeList();
     78     }
     79 }
     80