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
18import com.android.server.usb.descriptors.report.ReportCanvas;
19
20/**
21 * @hide
22 * An audio class-specific Format III interface.
23 * see Frmts20.pdf section 2.3.1.6 2.3.3.1 Type III Format Type Descriptor
24 */
25public final class Usb20ASFormatIII extends UsbASFormat {
26    private static final String TAG = "Usb20ASFormatIII";
27
28    // frmts20.pdf Table 2-4: Type III Format Type Descriptor
29    private byte mSubslotSize;      // 4:1 The number of bytes occupied by one
30                                    // audio subslot. Must be set to two.
31    private byte mBitResolution;    // 5:1 The number of effectively used bits from
32                                    // the available bits in an audio subframe.
33
34    public Usb20ASFormatIII(int length, byte type, byte subtype, byte formatType, int subclass) {
35        super(length, type, subtype, formatType, subclass);
36    }
37
38    public byte getSubslotSize() {
39        return mSubslotSize;
40    }
41
42    public byte getBitResolution() {
43        return mBitResolution;
44    }
45
46    @Override
47    public int parseRawDescriptors(ByteStream stream) {
48        mSubslotSize = stream.getByte();
49        mBitResolution = stream.getByte();
50
51        return mLength;
52    }
53
54    @Override
55    public void report(ReportCanvas canvas) {
56        super.report(canvas);
57
58        canvas.openList();
59        canvas.writeListItem("Subslot Size: " + getSubslotSize());
60        canvas.writeListItem("Bit Resolution: " + getBitResolution());
61        canvas.closeList();
62    }
63}
64