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 public class UsbACMixerUnit extends UsbACInterface { 19 private static final String TAG = "UsbACMixerUnit"; 20 21 protected byte mUnitID; // 3:1 22 protected byte mNumInputs; // 4:1 Number of Input Pins of this Unit. 23 protected byte[] mInputIDs; // 5...:1 ID of the Unit or Terminal to which the Input Pins 24 // are connected. 25 protected byte mNumOutputs; // The number of output channels 26 27 public UsbACMixerUnit(int length, byte type, byte subtype, int subClass) { 28 super(length, type, subtype, subClass); 29 } 30 31 public byte getUnitID() { 32 return mUnitID; 33 } 34 35 public byte getNumInputs() { 36 return mNumInputs; 37 } 38 39 public byte[] getInputIDs() { 40 return mInputIDs; 41 } 42 43 public byte getNumOutputs() { 44 return mNumOutputs; 45 } 46 47 protected static int calcControlArraySize(int numInputs, int numOutputs) { 48 int totalChannels = numInputs * numOutputs; 49 return (totalChannels + 7) / 8; 50 } 51 52 @Override 53 public int parseRawDescriptors(ByteStream stream) { 54 mUnitID = stream.getByte(); 55 mNumInputs = stream.getByte(); 56 mInputIDs = new byte[mNumInputs]; 57 for (int input = 0; input < mNumInputs; input++) { 58 mInputIDs[input] = stream.getByte(); 59 } 60 mNumOutputs = stream.getByte(); 61 62 return mLength; 63 } 64 } 65