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 audio10.pdf section 4.3.2.1 24 */ 25 public final class Usb10ACInputTerminal extends UsbACTerminal { 26 private static final String TAG = "Usb10ACInputTerminal"; 27 28 private byte mNrChannels; // 7:1 1 Channel (0x01) 29 // Number of logical output channels in the 30 // Terminals output audio channel cluster 31 private int mChannelConfig; // 8:2 Mono (0x0000) 32 private byte mChannelNames; // 10:1 Unused (0x00) 33 private byte mTerminal; // 11:1 Unused (0x00) 34 35 public Usb10ACInputTerminal(int length, byte type, byte subtype, int subclass) { 36 super(length, type, subtype, subclass); 37 } 38 39 public byte getNrChannels() { 40 return mNrChannels; 41 } 42 43 public int getChannelConfig() { 44 return mChannelConfig; 45 } 46 47 public byte getChannelNames() { 48 return mChannelNames; 49 } 50 51 public byte getTerminal() { 52 return mTerminal; 53 } 54 55 @Override 56 public int parseRawDescriptors(ByteStream stream) { 57 super.parseRawDescriptors(stream); 58 59 mNrChannels = stream.getByte(); 60 mChannelConfig = stream.unpackUsbShort(); 61 mChannelNames = stream.getByte(); 62 mTerminal = stream.getByte(); 63 64 return mLength; 65 } 66 67 @Override 68 public void report(ReportCanvas canvas) { 69 super.report(canvas); 70 71 canvas.openList(); 72 canvas.writeListItem("Associated Terminal: " 73 + ReportCanvas.getHexString(getAssocTerminal())); 74 canvas.writeListItem("" + getNrChannels() + " Chans. Config: " 75 + ReportCanvas.getHexString(getChannelConfig())); 76 canvas.closeList(); 77 } 78 } 79