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 Format I interface. 23 * see Frmts20.pdf section 2.3.1.6 Type I Format Type Descriptor 24 */ 25 public final class Usb20ASFormatI extends UsbASFormat { 26 private static final String TAG = "Usb20ASFormatI"; 27 28 // Frmts20.pdf Table 2-2: Type I Format Type Descriptor 29 private byte mSubSlotSize; // 4:1 The number of bytes occupied by one 30 // audio subslot. Can be 1, 2, 3 or 4. 31 private byte mBitResolution; // 5:1 The number of effectively used bits from 32 // the available bits in an audio subslot. 33 34 public Usb20ASFormatI(int length, byte type, byte subtype, byte formatType, int subclass) { 35 super(length, type, subtype, formatType, subclass); 36 } 37 38 /** 39 * TBD 40 */ 41 public byte getSubSlotSize() { 42 return mSubSlotSize; 43 } 44 45 /** 46 * TBD 47 */ 48 public byte getBitResolution() { 49 return mBitResolution; 50 } 51 52 @Override 53 public int parseRawDescriptors(ByteStream stream) { 54 mSubSlotSize = stream.getByte(); 55 mBitResolution = stream.getByte(); 56 57 return mLength; 58 } 59 60 @Override 61 public void report(ReportCanvas canvas) { 62 super.report(canvas); 63 64 canvas.openList(); 65 canvas.writeListItem("Subslot Size: " + getSubSlotSize()); 66 canvas.writeListItem("Bit Resolution: " + getBitResolution()); 67 canvas.closeList(); 68 } 69 } 70