2012-06-26 00:34:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
* Copyright (C) 2012, Code Aurora Forum. All rights reserved.
|
|
|
|
*
|
|
|
|
* Not a Contribution, Apache license notifications and license are
|
|
|
|
* retained for attribution purposes only.
|
|
|
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-07-21 19:17:13 +00:00
|
|
|
#ifndef HWC_EXTERNAL_DISPLAY_H
|
|
|
|
#define HWC_EXTERNAL_DISPLAY_H
|
2012-06-26 00:34:58 +00:00
|
|
|
|
2012-08-07 22:27:06 +00:00
|
|
|
#include <utils/threads.h>
|
|
|
|
#include <linux/fb.h>
|
2012-07-23 20:44:38 +00:00
|
|
|
|
2012-06-26 00:34:58 +00:00
|
|
|
struct hwc_context_t;
|
|
|
|
|
|
|
|
namespace qhwc {
|
|
|
|
|
2012-08-02 15:26:21 +00:00
|
|
|
#define DEVICE_ROOT "/sys/devices/virtual/graphics"
|
|
|
|
#define DEVICE_NODE_FB1 "fb1"
|
|
|
|
#define DEVICE_NODE_FB2 "fb2"
|
|
|
|
#define HDMI_PANEL "dtv panel"
|
|
|
|
#define WFD_PANEL "writeback panel"
|
|
|
|
#define EXTERN_DISPLAY_NONE 0
|
|
|
|
#define EXTERN_DISPLAY_FB1 1
|
|
|
|
#define EXTERN_DISPLAY_FB2 2
|
|
|
|
#define MAX_FRAME_BUFFER_NAME_SIZE 80
|
|
|
|
#define MAX_DISPLAY_EXTERNAL_DEVICES 2
|
|
|
|
#define HPD_ENABLE 1
|
|
|
|
#define HPD_DISABLE 0
|
|
|
|
#define DEVICE_ONLINE true
|
|
|
|
#define DEVICE_OFFLINE false
|
|
|
|
|
|
|
|
|
|
|
|
#define SYSFS_EDID_MODES DEVICE_ROOT "/" DEVICE_NODE_FB1 "/edid_modes"
|
|
|
|
#define SYSFS_HPD DEVICE_ROOT "/" DEVICE_NODE_FB1 "/hpd"
|
|
|
|
|
2012-07-21 19:17:13 +00:00
|
|
|
class ExternalDisplay
|
2012-06-26 00:34:58 +00:00
|
|
|
{
|
|
|
|
//Type of external display - OFF, HDMI, WFD
|
|
|
|
enum external_display_type {
|
|
|
|
EXT_TYPE_NONE,
|
|
|
|
EXT_TYPE_HDMI,
|
|
|
|
EXT_TYPE_WIFI
|
|
|
|
};
|
|
|
|
|
|
|
|
// Mirroring state
|
|
|
|
enum external_mirroring_state {
|
|
|
|
EXT_MIRRORING_OFF,
|
|
|
|
EXT_MIRRORING_ON,
|
|
|
|
};
|
|
|
|
public:
|
2012-07-21 19:17:13 +00:00
|
|
|
ExternalDisplay(hwc_context_t* ctx);
|
|
|
|
~ExternalDisplay();
|
2012-08-07 22:27:06 +00:00
|
|
|
int getModeCount() const;
|
|
|
|
void getEDIDModes(int *out) const;
|
|
|
|
int getExternalDisplay() const;
|
2012-07-23 20:44:38 +00:00
|
|
|
void setExternalDisplay(int connected);
|
|
|
|
bool commit();
|
|
|
|
int enableHDMIVsync(int enable);
|
2012-08-07 22:27:06 +00:00
|
|
|
void setHPDStatus(int enabled);
|
|
|
|
void setEDIDMode(int resMode);
|
|
|
|
void setActionSafeDimension(int w, int h);
|
2012-08-02 15:26:21 +00:00
|
|
|
void processUEventOnline(const char *str);
|
|
|
|
void processUEventOffline(const char *str);
|
|
|
|
bool isHDMIConfigured();
|
2012-06-26 00:34:58 +00:00
|
|
|
|
|
|
|
private:
|
2012-07-21 19:17:13 +00:00
|
|
|
bool readResolution();
|
2012-07-23 20:44:38 +00:00
|
|
|
int parseResolution(char* edidStr, int* edidModes);
|
2012-07-21 19:17:13 +00:00
|
|
|
void setResolution(int ID);
|
2012-08-02 15:26:21 +00:00
|
|
|
bool openFrameBuffer(int fbNum);
|
2012-07-23 20:44:38 +00:00
|
|
|
bool closeFrameBuffer();
|
2012-07-21 19:17:13 +00:00
|
|
|
bool writeHPDOption(int userOption) const;
|
|
|
|
bool isValidMode(int ID);
|
|
|
|
void handleUEvent(char* str, int len);
|
|
|
|
int getModeOrder(int mode);
|
|
|
|
int getBestMode();
|
2012-07-23 20:44:38 +00:00
|
|
|
void resetInfo();
|
2012-08-29 17:35:19 +00:00
|
|
|
void configureWFDDisplay(int fbIndex);
|
2012-06-26 00:34:58 +00:00
|
|
|
|
2012-08-07 22:27:06 +00:00
|
|
|
mutable android::Mutex mExtDispLock;
|
2012-07-23 20:44:38 +00:00
|
|
|
int mFd;
|
|
|
|
int mCurrentMode;
|
2012-08-07 22:27:06 +00:00
|
|
|
int mExternalDisplay;
|
|
|
|
int mResolutionMode;
|
2012-07-21 19:17:13 +00:00
|
|
|
char mEDIDs[128];
|
|
|
|
int mEDIDModes[64];
|
|
|
|
int mModeCount;
|
|
|
|
hwc_context_t *mHwcContext;
|
2012-07-23 20:44:38 +00:00
|
|
|
fb_var_screeninfo mVInfo;
|
2012-06-26 00:34:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; //qhwc
|
|
|
|
// ---------------------------------------------------------------------------
|
2012-07-21 19:17:13 +00:00
|
|
|
#endif //HWC_EXTERNAL_DISPLAY_H
|