1 /*
2  * Copyright (C) 2014 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 
17 package com.android.server.hdmi;
18 
19 import android.hardware.hdmi.HdmiPortInfo;
20 import android.util.SparseArray;
21 
22 import com.android.internal.util.IndentingPrintWriter;
23 
24 /**
25  * A handler class for MHL control command. It converts user's command into MHL command and pass it
26  * to MHL HAL layer.
27  * <p>
28  * It can be created only by {@link HdmiMhlControllerStub#create}.
29  */
30 final class HdmiMhlControllerStub {
31 
32     private static final SparseArray<HdmiMhlLocalDeviceStub> mLocalDevices = new SparseArray<>();
33     private static final HdmiPortInfo[] EMPTY_PORT_INFO = new HdmiPortInfo[0];
34     private static final int INVALID_MHL_VERSION = 0;
35     private static final int NO_SUPPORTED_FEATURES = 0;
36     private static final int INVALID_DEVICE_ROLES = 0;
37 
38     // Private constructor. Use HdmiMhlControllerStub.create().
HdmiMhlControllerStub(HdmiControlService service)39     private HdmiMhlControllerStub(HdmiControlService service) {
40     }
41 
42     // Returns true if MHL controller is initialized and ready to use.
isReady()43     boolean isReady() {
44         return false;
45     }
46 
create(HdmiControlService service)47     static HdmiMhlControllerStub create(HdmiControlService service) {
48         return new HdmiMhlControllerStub(service);
49     }
50 
getPortInfos()51     HdmiPortInfo[] getPortInfos() {
52         return EMPTY_PORT_INFO;
53     }
54 
55     /**
56      * Return {@link HdmiMhlLocalDeviceStub} matched with the given port id.
57      *
58      * @return null if has no matched port id
59      */
getLocalDevice(int portId)60     HdmiMhlLocalDeviceStub getLocalDevice(int portId) {
61         return null;
62     }
63 
64     /**
65      * Return {@link HdmiMhlLocalDeviceStub} matched with the given device id.
66      *
67      * @return null if has no matched id
68      */
getLocalDeviceById(int deviceId)69     HdmiMhlLocalDeviceStub getLocalDeviceById(int deviceId) {
70         return null;
71     }
72 
getAllLocalDevices()73     SparseArray<HdmiMhlLocalDeviceStub> getAllLocalDevices() {
74         return mLocalDevices;
75     }
76 
77     /**
78      * Remove a {@link HdmiMhlLocalDeviceStub} matched with the given port id.
79      *
80      * @return removed {@link HdmiMhlLocalDeviceStub}. Return null if no matched port id.
81      */
removeLocalDevice(int portId)82     HdmiMhlLocalDeviceStub removeLocalDevice(int portId) {
83         return null;
84     }
85 
86     /**
87      * Add a new {@link HdmiMhlLocalDeviceStub}.
88      *
89      * @return old {@link HdmiMhlLocalDeviceStub} having same port id
90      */
addLocalDevice(HdmiMhlLocalDeviceStub device)91     HdmiMhlLocalDeviceStub addLocalDevice(HdmiMhlLocalDeviceStub device) {
92         return null;
93     }
94 
clearAllLocalDevices()95     void clearAllLocalDevices() {
96     }
97 
sendVendorCommand(int portId, int offset, int length, byte[] data)98     void sendVendorCommand(int portId, int offset, int length, byte[] data) {
99     }
100 
setOption(int flag, int value)101     void setOption(int flag, int value) {
102     }
103 
104     /**
105      * Get the MHL version supported by underlying hardware port of the given {@code portId}.
106      * MHL specification version 2.0 returns 0x20, 3.0 will return 0x30 respectively.
107      * The return value is stored in 'version'. Return INVALID_VERSION if MHL hardware layer
108      * is not ready.
109      */
getMhlVersion(int portId)110     int getMhlVersion(int portId) {
111         return INVALID_MHL_VERSION;
112     }
113 
114     /**
115      * Get MHL version of a device which is connected to a port of the given {@code portId}.
116      * MHL specification version 2.0 returns 0x20, 3.0 will return 0x30 respectively.
117      * The return value is stored in 'version'.
118      */
getPeerMhlVersion(int portId)119     int getPeerMhlVersion(int portId) {
120         return INVALID_MHL_VERSION;
121     }
122 
123     /**
124      * Get the bit flags describing the features supported by the system. Refer to feature support
125      * flag register info in MHL specification.
126      */
getSupportedFeatures(int portId)127     int getSupportedFeatures(int portId) {
128         return NO_SUPPORTED_FEATURES;
129     }
130 
131     /**
132      * Get the bit flags describing the roles which ECBUS device can play. Refer to the
133      * ECBUS_DEV_ROLES Register info MHL3.0 specification
134      */
getEcbusDeviceRoles(int portId)135     int getEcbusDeviceRoles(int portId) {
136         return INVALID_DEVICE_ROLES;
137     }
138 
dump(IndentingPrintWriter pw)139     void dump(IndentingPrintWriter pw) {
140     }
141 }
142