Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 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 | |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 19 | import android.hardware.hdmi.HdmiPortInfo; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 20 | import android.os.Handler; |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 21 | import android.os.Looper; |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 22 | import android.os.MessageQueue; |
Yuncheol Heo | ece603b | 2014-05-23 20:10:19 +0900 | [diff] [blame] | 23 | import android.util.Slog; |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 24 | import android.util.SparseArray; |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 25 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 26 | import com.android.internal.util.Predicate; |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 27 | import com.android.server.hdmi.HdmiAnnotations.IoThreadOnly; |
| 28 | import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly; |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 29 | import com.android.server.hdmi.HdmiControlService.DevicePollingCallback; |
| 30 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 31 | import libcore.util.EmptyArray; |
| 32 | |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 33 | import java.util.ArrayList; |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 34 | import java.util.List; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Manages HDMI-CEC command and behaviors. It converts user's command into CEC command |
| 38 | * and pass it to CEC HAL so that it sends message to other device. For incoming |
| 39 | * message it translates the message and delegates it to proper module. |
| 40 | * |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 41 | * <p>It should be careful to access member variables on IO thread because |
| 42 | * it can be accessed from system thread as well. |
| 43 | * |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 44 | * <p>It can be created only by {@link HdmiCecController#create} |
| 45 | * |
| 46 | * <p>Declared as package-private, accessed by {@link HdmiControlService} only. |
| 47 | */ |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 48 | final class HdmiCecController { |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 49 | private static final String TAG = "HdmiCecController"; |
| 50 | |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 51 | /** |
| 52 | * Interface to report allocated logical address. |
| 53 | */ |
| 54 | interface AllocateAddressCallback { |
| 55 | /** |
| 56 | * Called when a new logical address is allocated. |
| 57 | * |
| 58 | * @param deviceType requested device type to allocate logical address |
| 59 | * @param logicalAddress allocated logical address. If it is |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 60 | * {@link Constants#ADDR_UNREGISTERED}, it means that |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 61 | * it failed to allocate logical address for the given device type |
| 62 | */ |
| 63 | void onAllocated(int deviceType, int logicalAddress); |
| 64 | } |
| 65 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 66 | private static final byte[] EMPTY_BODY = EmptyArray.BYTE; |
| 67 | |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 68 | // A message to pass cec send command to IO looper. |
| 69 | private static final int MSG_SEND_CEC_COMMAND = 1; |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 70 | // A message to delegate logical allocation to IO looper. |
| 71 | private static final int MSG_ALLOCATE_LOGICAL_ADDRESS = 2; |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 72 | |
| 73 | // Message types to handle incoming message in main service looper. |
| 74 | private final static int MSG_RECEIVE_CEC_COMMAND = 1; |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 75 | // A message to report allocated logical address to main control looper. |
| 76 | private final static int MSG_REPORT_LOGICAL_ADDRESS = 2; |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 77 | |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 78 | private static final int NUM_LOGICAL_ADDRESS = 16; |
| 79 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 80 | // Predicate for whether the given logical address is remote device's one or not. |
| 81 | private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() { |
| 82 | @Override |
| 83 | public boolean apply(Integer address) { |
| 84 | return !isAllocatedLocalDeviceAddress(address); |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | // Predicate whether the given logical address is system audio's one or not |
| 89 | private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() { |
| 90 | @Override |
| 91 | public boolean apply(Integer address) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 92 | return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 93 | } |
| 94 | }; |
| 95 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 96 | // Handler instance to process synchronous I/O (mainly send) message. |
| 97 | private Handler mIoHandler; |
| 98 | |
| 99 | // Handler instance to process various messages coming from other CEC |
| 100 | // device or issued by internal state change. |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 101 | private Handler mControlHandler; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 102 | |
| 103 | // Stores the pointer to the native implementation of the service that |
| 104 | // interacts with HAL. |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 105 | private volatile long mNativePtr; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 106 | |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 107 | private HdmiControlService mService; |
| 108 | |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 109 | // Stores the local CEC devices in the system. Device type is used for key. |
| 110 | private final SparseArray<HdmiCecLocalDevice> mLocalDevices = new SparseArray<>(); |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 111 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 112 | // Private constructor. Use HdmiCecController.create(). |
| 113 | private HdmiCecController() { |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * A factory method to get {@link HdmiCecController}. If it fails to initialize |
| 118 | * inner device or has no device it will return {@code null}. |
| 119 | * |
| 120 | * <p>Declared as package-private, accessed by {@link HdmiControlService} only. |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 121 | * @param service {@link HdmiControlService} instance used to create internal handler |
| 122 | * and to pass callback for incoming message or event. |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 123 | * @return {@link HdmiCecController} if device is initialized successfully. Otherwise, |
| 124 | * returns {@code null}. |
| 125 | */ |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 126 | static HdmiCecController create(HdmiControlService service) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 127 | HdmiCecController controller = new HdmiCecController(); |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 128 | long nativePtr = nativeInit(controller, service.getServiceLooper().getQueue()); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 129 | if (nativePtr == 0L) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 130 | controller = null; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 131 | return null; |
| 132 | } |
| 133 | |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 134 | controller.init(service, nativePtr); |
| 135 | return controller; |
| 136 | } |
| 137 | |
| 138 | private void init(HdmiControlService service, long nativePtr) { |
| 139 | mService = service; |
| 140 | mIoHandler = new Handler(service.getServiceLooper()); |
| 141 | mControlHandler = new Handler(service.getServiceLooper()); |
| 142 | mNativePtr = nativePtr; |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 143 | } |
| 144 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 145 | @ServiceThreadOnly |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 146 | void addLocalDevice(int deviceType, HdmiCecLocalDevice device) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 147 | assertRunOnServiceThread(); |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 148 | mLocalDevices.put(deviceType, device); |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Allocate a new logical address of the given device type. Allocated |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 153 | * address will be reported through {@link AllocateAddressCallback}. |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 154 | * |
| 155 | * <p> Declared as package-private, accessed by {@link HdmiControlService} only. |
| 156 | * |
| 157 | * @param deviceType type of device to used to determine logical address |
| 158 | * @param preferredAddress a logical address preferred to be allocated. |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 159 | * If sets {@link Constants#ADDR_UNREGISTERED}, scans |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 160 | * the smallest logical address matched with the given device type. |
| 161 | * Otherwise, scan address will start from {@code preferredAddress} |
| 162 | * @param callback callback interface to report allocated logical address to caller |
| 163 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 164 | @ServiceThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 165 | void allocateLogicalAddress(final int deviceType, final int preferredAddress, |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 166 | final AllocateAddressCallback callback) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 167 | assertRunOnServiceThread(); |
| 168 | |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 169 | runOnIoThread(new Runnable() { |
| 170 | @Override |
| 171 | public void run() { |
| 172 | handleAllocateLogicalAddress(deviceType, preferredAddress, callback); |
| 173 | } |
| 174 | }); |
| 175 | } |
| 176 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 177 | @IoThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 178 | private void handleAllocateLogicalAddress(final int deviceType, int preferredAddress, |
Jungshik Jang | 3ee6572 | 2014-06-03 16:22:30 +0900 | [diff] [blame] | 179 | final AllocateAddressCallback callback) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 180 | assertRunOnIoThread(); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 181 | int startAddress = preferredAddress; |
| 182 | // If preferred address is "unregistered", start address will be the smallest |
| 183 | // address matched with the given device type. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 184 | if (preferredAddress == Constants.ADDR_UNREGISTERED) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 185 | for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 186 | if (deviceType == HdmiUtils.getTypeFromAddress(i)) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 187 | startAddress = i; |
| 188 | break; |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 193 | int logicalAddress = Constants.ADDR_UNREGISTERED; |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 194 | // Iterates all possible addresses which has the same device type. |
| 195 | for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) { |
| 196 | int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 197 | if (curAddress != Constants.ADDR_UNREGISTERED |
| 198 | && deviceType == HdmiUtils.getTypeFromAddress(curAddress)) { |
Jinsuk Kim | 5fba96d | 2014-07-11 11:51:34 +0900 | [diff] [blame] | 199 | if (!sendPollMessage(curAddress, curAddress, HdmiConfig.ADDRESS_ALLOCATION_RETRY)) { |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 200 | logicalAddress = curAddress; |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | final int assignedAddress = logicalAddress; |
| 207 | if (callback != null) { |
| 208 | runOnServiceThread(new Runnable() { |
| 209 | @Override |
| 210 | public void run() { |
| 211 | callback.onAllocated(deviceType, assignedAddress); |
| 212 | } |
| 213 | }); |
| 214 | } |
Jungshik Jang | 3f74ab0 | 2014-04-30 14:31:02 +0900 | [diff] [blame] | 215 | } |
| 216 | |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 217 | private static byte[] buildBody(int opcode, byte[] params) { |
| 218 | byte[] body = new byte[params.length + 1]; |
| 219 | body[0] = (byte) opcode; |
| 220 | System.arraycopy(params, 0, body, 1, params.length); |
| 221 | return body; |
| 222 | } |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 223 | |
Jungshik Jang | 7d9a843 | 2014-04-29 15:12:43 +0900 | [diff] [blame] | 224 | |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 225 | HdmiPortInfo[] getPortInfos() { |
| 226 | return nativeGetPortInfos(mNativePtr); |
| 227 | } |
| 228 | |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 229 | /** |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 230 | * Return the locally hosted logical device of a given type. |
| 231 | * |
| 232 | * @param deviceType logical device type |
| 233 | * @return {@link HdmiCecLocalDevice} instance if the instance of the type is available; |
| 234 | * otherwise null. |
| 235 | */ |
| 236 | HdmiCecLocalDevice getLocalDevice(int deviceType) { |
| 237 | return mLocalDevices.get(deviceType); |
| 238 | } |
| 239 | |
| 240 | /** |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 241 | * Add a new logical address to the device. Device's HW should be notified |
| 242 | * when a new logical address is assigned to a device, so that it can accept |
| 243 | * a command having available destinations. |
| 244 | * |
| 245 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 246 | * |
| 247 | * @param newLogicalAddress a logical address to be added |
| 248 | * @return 0 on success. Otherwise, returns negative value |
| 249 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 250 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 251 | int addLogicalAddress(int newLogicalAddress) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 252 | assertRunOnServiceThread(); |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 253 | if (HdmiUtils.isValidAddress(newLogicalAddress)) { |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 254 | return nativeAddLogicalAddress(mNativePtr, newLogicalAddress); |
| 255 | } else { |
| 256 | return -1; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Clear all logical addresses registered in the device. |
| 262 | * |
| 263 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 264 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 265 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 266 | void clearLogicalAddress() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 267 | assertRunOnServiceThread(); |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 268 | // TODO: consider to backup logical address so that new logical address |
| 269 | // allocation can use it as preferred address. |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 270 | for (int i = 0; i < mLocalDevices.size(); ++i) { |
| 271 | mLocalDevices.valueAt(i).clearAddress(); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 272 | } |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 273 | nativeClearLogicalAddress(mNativePtr); |
| 274 | } |
| 275 | |
Jungshik Jang | 4fc1d10 | 2014-07-09 19:24:50 +0900 | [diff] [blame] | 276 | @ServiceThreadOnly |
| 277 | void clearLocalDevices() { |
| 278 | assertRunOnServiceThread(); |
| 279 | mLocalDevices.clear(); |
| 280 | } |
| 281 | |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 282 | /** |
| 283 | * Return the physical address of the device. |
| 284 | * |
| 285 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 286 | * |
| 287 | * @return CEC physical address of the device. The range of success address |
| 288 | * is between 0x0000 and 0xFFFF. If failed it returns -1 |
| 289 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 290 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 291 | int getPhysicalAddress() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 292 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 293 | return nativeGetPhysicalAddress(mNativePtr); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Return CEC version of the device. |
| 298 | * |
| 299 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 300 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 301 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 302 | int getVersion() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 303 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 304 | return nativeGetVersion(mNativePtr); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Return vendor id of the device. |
| 309 | * |
| 310 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 311 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 312 | @ServiceThreadOnly |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 313 | int getVendorId() { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 314 | assertRunOnServiceThread(); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 315 | return nativeGetVendorId(mNativePtr); |
| 316 | } |
| 317 | |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 318 | /** |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 319 | * Set an option to CEC HAL. |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 320 | * |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 321 | * @param flag key of option |
| 322 | * @param value value of option |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 323 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 324 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 325 | void setOption(int flag, int value) { |
| 326 | assertRunOnServiceThread(); |
| 327 | nativeSetOption(mNativePtr, flag, value); |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Configure ARC circuit in the hardware logic to start or stop the feature. |
| 332 | * |
| 333 | * @param enabled whether to enable/disable ARC |
| 334 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 335 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 336 | void setAudioReturnChannel(boolean enabled) { |
| 337 | assertRunOnServiceThread(); |
| 338 | nativeSetAudioReturnChannel(mNativePtr, enabled); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Return the connection status of the specified port |
| 343 | * |
| 344 | * @param port port number to check connection status |
| 345 | * @return true if connected; otherwise, return false |
| 346 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 347 | @ServiceThreadOnly |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 348 | boolean isConnected(int port) { |
| 349 | assertRunOnServiceThread(); |
| 350 | return nativeIsConnected(mNativePtr, port); |
| 351 | } |
| 352 | |
| 353 | /** |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 354 | * Poll all remote devices. It sends <Polling Message> to all remote |
| 355 | * devices. |
| 356 | * |
| 357 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 358 | * |
| 359 | * @param callback an interface used to get a list of all remote devices' address |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 360 | * @param sourceAddress a logical address of source device where sends polling message |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 361 | * @param pickStrategy strategy how to pick polling candidates |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 362 | * @param retryCount the number of retry used to send polling message to remote devices |
| 363 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 364 | @ServiceThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 365 | void pollDevices(DevicePollingCallback callback, int sourceAddress, int pickStrategy, |
| 366 | int retryCount) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 367 | assertRunOnServiceThread(); |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 368 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 369 | // Extract polling candidates. No need to poll against local devices. |
| 370 | List<Integer> pollingCandidates = pickPollCandidates(pickStrategy); |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 371 | runDevicePolling(sourceAddress, pollingCandidates, retryCount, callback); |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 372 | } |
| 373 | |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 374 | /** |
| 375 | * Return a list of all {@link HdmiCecLocalDevice}s. |
| 376 | * |
| 377 | * <p>Declared as package-private. accessed by {@link HdmiControlService} only. |
| 378 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 379 | @ServiceThreadOnly |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 380 | List<HdmiCecLocalDevice> getLocalDeviceList() { |
| 381 | assertRunOnServiceThread(); |
Jungshik Jang | 79c58a4 | 2014-06-16 16:45:36 +0900 | [diff] [blame] | 382 | return HdmiUtils.sparseArrayToList(mLocalDevices); |
Jungshik Jang | cc5ef8c | 2014-05-27 13:27:36 +0900 | [diff] [blame] | 383 | } |
| 384 | |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 385 | private List<Integer> pickPollCandidates(int pickStrategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 386 | int strategy = pickStrategy & Constants.POLL_STRATEGY_MASK; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 387 | Predicate<Integer> pickPredicate = null; |
| 388 | switch (strategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 389 | case Constants.POLL_STRATEGY_SYSTEM_AUDIO: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 390 | pickPredicate = mSystemAudioAddressPredicate; |
| 391 | break; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 392 | case Constants.POLL_STRATEGY_REMOTES_DEVICES: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 393 | default: // The default is POLL_STRATEGY_REMOTES_DEVICES. |
| 394 | pickPredicate = mRemoteDeviceAddressPredicate; |
| 395 | break; |
| 396 | } |
| 397 | |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 398 | int iterationStrategy = pickStrategy & Constants.POLL_ITERATION_STRATEGY_MASK; |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 399 | ArrayList<Integer> pollingCandidates = new ArrayList<>(); |
| 400 | switch (iterationStrategy) { |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 401 | case Constants.POLL_ITERATION_IN_ORDER: |
| 402 | for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) { |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 403 | if (pickPredicate.apply(i)) { |
| 404 | pollingCandidates.add(i); |
| 405 | } |
| 406 | } |
| 407 | break; |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 408 | case Constants.POLL_ITERATION_REVERSE_ORDER: |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 409 | default: // The default is reverse order. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 410 | for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) { |
Jungshik Jang | 0f8b4b7 | 2014-05-28 17:58:58 +0900 | [diff] [blame] | 411 | if (pickPredicate.apply(i)) { |
| 412 | pollingCandidates.add(i); |
| 413 | } |
| 414 | } |
| 415 | break; |
| 416 | } |
| 417 | return pollingCandidates; |
| 418 | } |
| 419 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 420 | @ServiceThreadOnly |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 421 | private boolean isAllocatedLocalDeviceAddress(int address) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 422 | assertRunOnServiceThread(); |
Jinsuk Kim | 7fe2ae0 | 2014-05-26 17:33:05 +0900 | [diff] [blame] | 423 | for (int i = 0; i < mLocalDevices.size(); ++i) { |
| 424 | if (mLocalDevices.valueAt(i).isAddressOf(address)) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 425 | return true; |
| 426 | } |
| 427 | } |
| 428 | return false; |
| 429 | } |
| 430 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 431 | @ServiceThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 432 | private void runDevicePolling(final int sourceAddress, |
| 433 | final List<Integer> candidates, final int retryCount, |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 434 | final DevicePollingCallback callback) { |
| 435 | assertRunOnServiceThread(); |
| 436 | runOnIoThread(new Runnable() { |
| 437 | @Override |
| 438 | public void run() { |
| 439 | final ArrayList<Integer> allocated = new ArrayList<>(); |
| 440 | for (Integer address : candidates) { |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 441 | if (sendPollMessage(sourceAddress, address, retryCount)) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 442 | allocated.add(address); |
| 443 | } |
| 444 | } |
| 445 | if (callback != null) { |
| 446 | runOnServiceThread(new Runnable() { |
| 447 | @Override |
| 448 | public void run() { |
| 449 | callback.onPollingFinished(allocated); |
| 450 | } |
| 451 | }); |
| 452 | } |
| 453 | } |
| 454 | }); |
| 455 | } |
| 456 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 457 | @IoThreadOnly |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 458 | private boolean sendPollMessage(int sourceAddress, int destinationAddress, int retryCount) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 459 | assertRunOnIoThread(); |
| 460 | for (int i = 0; i < retryCount; ++i) { |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 461 | // <Polling Message> is a message which has empty body. |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 462 | // If sending <Polling Message> failed (NAK), it becomes |
| 463 | // new logical address for the device because no device uses |
| 464 | // it as logical address of the device. |
Jungshik Jang | 1de5142 | 2014-07-03 11:14:26 +0900 | [diff] [blame] | 465 | if (nativeSendCecCommand(mNativePtr, sourceAddress, destinationAddress, EMPTY_BODY) |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 466 | == Constants.SEND_RESULT_SUCCESS) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 467 | return true; |
| 468 | } |
| 469 | } |
| 470 | return false; |
| 471 | } |
| 472 | |
| 473 | private void assertRunOnIoThread() { |
| 474 | if (Looper.myLooper() != mIoHandler.getLooper()) { |
| 475 | throw new IllegalStateException("Should run on io thread."); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | private void assertRunOnServiceThread() { |
| 480 | if (Looper.myLooper() != mControlHandler.getLooper()) { |
| 481 | throw new IllegalStateException("Should run on service thread."); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | // Run a Runnable on IO thread. |
| 486 | // It should be careful to access member variables on IO thread because |
| 487 | // it can be accessed from system thread as well. |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 488 | private void runOnIoThread(Runnable runnable) { |
| 489 | mIoHandler.post(runnable); |
| 490 | } |
| 491 | |
| 492 | private void runOnServiceThread(Runnable runnable) { |
| 493 | mControlHandler.post(runnable); |
| 494 | } |
| 495 | |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 496 | private boolean isAcceptableAddress(int address) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 497 | // Can access command targeting devices available in local device or broadcast command. |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 498 | if (address == Constants.ADDR_BROADCAST) { |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 499 | return true; |
| 500 | } |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 501 | return isAllocatedLocalDeviceAddress(address); |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 502 | } |
| 503 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 504 | @ServiceThreadOnly |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 505 | private void onReceiveCommand(HdmiCecMessage message) { |
Jungshik Jang | 02bb426 | 2014-05-23 16:48:31 +0900 | [diff] [blame] | 506 | assertRunOnServiceThread(); |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 507 | if (isAcceptableAddress(message.getDestination()) |
| 508 | && mService.handleCecCommand(message)) { |
Jungshik Jang | a1fa91f | 2014-05-08 20:56:41 +0900 | [diff] [blame] | 509 | return; |
| 510 | } |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 511 | |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 512 | if (message.getDestination() != Constants.ADDR_BROADCAST) { |
Jinsuk Kim | 3a2f743 | 2014-05-29 06:52:45 +0900 | [diff] [blame] | 513 | int sourceAddress = message.getDestination(); |
| 514 | // Reply <Feature Abort> to initiator (source) for all requests. |
| 515 | HdmiCecMessage cecMessage = HdmiCecMessageBuilder.buildFeatureAbortCommand( |
| 516 | sourceAddress, message.getSource(), message.getOpcode(), |
Jinsuk Kim | c0c20d0 | 2014-07-04 14:34:31 +0900 | [diff] [blame] | 517 | Constants.ABORT_REFUSED); |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 518 | sendCommand(cecMessage); |
Jinsuk Kim | 3a2f743 | 2014-05-29 06:52:45 +0900 | [diff] [blame] | 519 | } |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 520 | } |
| 521 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 522 | @ServiceThreadOnly |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 523 | void sendCommand(HdmiCecMessage cecMessage) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 524 | assertRunOnServiceThread(); |
Jinsuk Kim | 2918e9e | 2014-05-20 16:45:45 +0900 | [diff] [blame] | 525 | sendCommand(cecMessage, null); |
| 526 | } |
| 527 | |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 528 | @ServiceThreadOnly |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 529 | void sendCommand(final HdmiCecMessage cecMessage, |
| 530 | final HdmiControlService.SendMessageCallback callback) { |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 531 | assertRunOnServiceThread(); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 532 | runOnIoThread(new Runnable() { |
| 533 | @Override |
| 534 | public void run() { |
| 535 | byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams()); |
Jungshik Jang | 8ed86c4 | 2014-07-11 11:56:46 +0900 | [diff] [blame^] | 536 | int i = 0; |
| 537 | int errorCode = Constants.SEND_RESULT_SUCCESS; |
| 538 | do { |
| 539 | errorCode = nativeSendCecCommand(mNativePtr, cecMessage.getSource(), |
| 540 | cecMessage.getDestination(), body); |
| 541 | if (errorCode == Constants.SEND_RESULT_SUCCESS) { |
| 542 | break; |
| 543 | } |
| 544 | } while (i++ < HdmiConfig.RETRANSMISSION_COUNT); |
| 545 | |
| 546 | final int finalError = errorCode; |
| 547 | if (finalError != Constants.SEND_RESULT_SUCCESS) { |
Yuncheol Heo | ece603b | 2014-05-23 20:10:19 +0900 | [diff] [blame] | 548 | Slog.w(TAG, "Failed to send " + cecMessage); |
| 549 | } |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 550 | if (callback != null) { |
| 551 | runOnServiceThread(new Runnable() { |
| 552 | @Override |
| 553 | public void run() { |
Jungshik Jang | 8ed86c4 | 2014-07-11 11:56:46 +0900 | [diff] [blame^] | 554 | callback.onSendCompleted(finalError); |
Jungshik Jang | d643f76 | 2014-05-22 19:28:09 +0900 | [diff] [blame] | 555 | } |
| 556 | }); |
| 557 | } |
| 558 | } |
| 559 | }); |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 560 | } |
| 561 | |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 562 | /** |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 563 | * Called by native when incoming CEC message arrived. |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 564 | */ |
Jungshik Jang | a5b7414 | 2014-06-23 18:03:10 +0900 | [diff] [blame] | 565 | @ServiceThreadOnly |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 566 | private void handleIncomingCecCommand(int srcAddress, int dstAddress, byte[] body) { |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 567 | assertRunOnServiceThread(); |
| 568 | onReceiveCommand(HdmiCecMessageBuilder.of(srcAddress, dstAddress, body)); |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Called by native when a hotplug event issues. |
| 573 | */ |
Jungshik Jang | 4223072 | 2014-07-07 17:40:25 +0900 | [diff] [blame] | 574 | @ServiceThreadOnly |
| 575 | private void handleHotplug(int port, boolean connected) { |
| 576 | assertRunOnServiceThread(); |
| 577 | mService.onHotplug(port, connected); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 578 | } |
| 579 | |
Jungshik Jang | 4085d0e | 2014-05-27 19:52:39 +0900 | [diff] [blame] | 580 | private static native long nativeInit(HdmiCecController handler, MessageQueue messageQueue); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 581 | private static native int nativeSendCecCommand(long controllerPtr, int srcAddress, |
Jungshik Jang | e9c77c8 | 2014-04-24 20:30:09 +0900 | [diff] [blame] | 582 | int dstAddress, byte[] body); |
Jungshik Jang | a9095ba | 2014-05-02 13:06:22 +0900 | [diff] [blame] | 583 | private static native int nativeAddLogicalAddress(long controllerPtr, int logicalAddress); |
| 584 | private static native void nativeClearLogicalAddress(long controllerPtr); |
| 585 | private static native int nativeGetPhysicalAddress(long controllerPtr); |
| 586 | private static native int nativeGetVersion(long controllerPtr); |
| 587 | private static native int nativeGetVendorId(long controllerPtr); |
Jinsuk Kim | 0340bbc | 2014-06-05 11:07:47 +0900 | [diff] [blame] | 588 | private static native HdmiPortInfo[] nativeGetPortInfos(long controllerPtr); |
Jungshik Jang | 092b445 | 2014-06-11 15:19:17 +0900 | [diff] [blame] | 589 | private static native void nativeSetOption(long controllerPtr, int flag, int value); |
| 590 | private static native void nativeSetAudioReturnChannel(long controllerPtr, boolean flag); |
| 591 | private static native boolean nativeIsConnected(long controllerPtr, int port); |
Jungshik Jang | 0792d37 | 2014-04-23 17:57:26 +0900 | [diff] [blame] | 592 | } |