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 */ 16package com.android.server.usb.descriptors; 17 18/** 19 * @hide 20 * An audio class-specific Mixer Unit interface. 21 * see Audio20.pdf section 4.7.2.6 Mixer Unit Descriptor 22 */ 23public final class Usb20ACMixerUnit extends UsbACMixerUnit { 24 private static final String TAG = "Usb20ACMixerUnit"; 25 26 private int mChanConfig; // 6+p:4 Describes the spatial location of the 27 // logical channels. 28 private byte mChanNames; // 10+p:1 Index of a string descriptor, describing the 29 // name of the first logical channel. 30 private byte[] mControls; // 11+p:N bitmasks of which controls are present for each channel 31 // for N, see UsbACMixerUnit.calcControlArraySize() 32 private byte mControlsMask; // 11+p+N:1 bitmasks of which controls are present for each channel 33 private byte mNameID; // 12+p+N:1 Index of a string descriptor, describing the 34 // Mixer Unit. 35 36 public Usb20ACMixerUnit(int length, byte type, byte subtype, byte subClass) { 37 super(length, type, subtype, subClass); 38 } 39 40 @Override 41 public int parseRawDescriptors(ByteStream stream) { 42 super.parseRawDescriptors(stream); 43 44 mChanConfig = stream.unpackUsbInt(); 45 mChanNames = stream.getByte(); 46 int controlArraySize = calcControlArraySize(mNumInputs, mNumOutputs); 47 mControls = new byte[controlArraySize]; 48 for (int index = 0; index < controlArraySize; index++) { 49 mControls[index] = stream.getByte(); 50 } 51 mControlsMask = stream.getByte(); 52 mNameID = stream.getByte(); 53 54 return mLength; 55 } 56} 57