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 Input Terminal interface.
     23  * see Audio20.pdf section 3.13.2 Input Terminal
     24  */
     25 public final class Usb20ACInputTerminal extends UsbACTerminal {
     26     private static final String TAG = "Usb20ACInputTerminal";
     27 
     28     // See Audio20.pdf - Table 4-9
     29     // Always 17 bytes
     30     private byte mClkSourceID;  // 7:1 - ID of the Clock Entity to which this Input
     31                                 // Terminal is connected.
     32     private byte mNumChannels;  // 8:1 - Number of logical output channels in the
     33                                 // Terminals output audio channel cluster.
     34     private int mChanConfig;    // 9:4 - Describes the spatial location of the
     35                                 // logical channels.
     36     private byte mChanNames;    // 13:1 - Index of a string descriptor, describing the
     37                                 // name of the first logical channel.
     38     private int mControls;      // 14:2 - Bitmask (see Audio20.pdf Table 4-9)
     39     private byte mTerminalName; // 16:1 - Index of a string descriptor, describing the
     40                                 // Input Terminal.
     41 
     42     public Usb20ACInputTerminal(int length, byte type, byte subtype, int subclass) {
     43         super(length, type, subtype, subclass);
     44     }
     45 
     46     public byte getClkSourceID() {
     47         return mClkSourceID;
     48     }
     49 
     50     public byte getNumChannels() {
     51         return mNumChannels;
     52     }
     53 
     54     public int getChanConfig() {
     55         return mChanConfig;
     56     }
     57 
     58     public int getControls() {
     59         return mControls;
     60     }
     61 
     62     @Override
     63     public int parseRawDescriptors(ByteStream stream) {
     64         super.parseRawDescriptors(stream);
     65 
     66         mClkSourceID = stream.getByte();
     67         mNumChannels = stream.getByte();
     68         mChanConfig = stream.unpackUsbInt();
     69         mChanNames = stream.getByte();
     70         mControls = stream.unpackUsbShort();
     71         mTerminalName = stream.getByte();
     72 
     73         return mLength;
     74     }
     75 
     76     @Override
     77     public void report(ReportCanvas canvas) {
     78         super.report(canvas);
     79 
     80         canvas.openList();
     81         canvas.writeListItem("Clock Source: " + getClkSourceID());
     82         canvas.writeListItem("" + getNumChannels() + " Channels. Config: "
     83                 + ReportCanvas.getHexString(getChanConfig()));
     84         canvas.closeList();
     85     }
     86 }
     87