summaryrefslogtreecommitdiff
path: root/msm8909/libhdmi/hdmi.h
blob: 605d9be817828a720e9384a56aab19c3aa59a2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright (C) 2010 The Android Open Source Project
 * Copyright (C) 2012-2014, The Linux Foundation. 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.
 */

#ifndef HWC_HDMI_DISPLAY_H
#define HWC_HDMI_DISPLAY_H

#include <linux/fb.h>

struct msm_hdmi_mode_timing_info;

namespace qhwc {

//Type of scanning of EDID(Video Capability Data Block)
enum hdmi_scansupport_type {
    HDMI_SCAN_NOT_SUPPORTED      = 0,
    HDMI_SCAN_ALWAYS_OVERSCANED  = 1,
    HDMI_SCAN_ALWAYS_UNDERSCANED = 2,
    HDMI_SCAN_BOTH_SUPPORTED     = 3
};

// Structure to store EDID related data
struct EDIDData {
    int mMode, mWidth, mHeight, mFps;
    // Predetermined ordering for each mode
    int mModeOrder;
    EDIDData(int mode, int width, int height, int fps, int order)
    : mMode(mode), mWidth(width), mHeight(height), mFps(fps), mModeOrder(order)
    { }
};

class HDMIDisplay
{
public:
    HDMIDisplay();
    ~HDMIDisplay();
    void setHPD(uint32_t startEnd);
    void setActionSafeDimension(int w, int h);
    bool isCEUnderscanSupported() { return mUnderscanSupported; }
    int configure();
    void getAttributes(uint32_t& width, uint32_t& height);
    int teardown();
    uint32_t getWidth() const { return mXres; };
    uint32_t getHeight() const { return mYres; };
    uint32_t getVsyncPeriod() const { return mVsyncPeriod; };
    int getFd() const { return mFd; };
    bool getMDPScalingMode() const { return mMDPScalingMode; }
    void activateDisplay();
    /* Returns true if HDMI is the PRIMARY display device*/
    bool isHDMIPrimaryDisplay();
    int getConnectedState();
    /* when HDMI is an EXTERNAL display, PRIMARY display attributes are needed
       for scaling mode */
    void setPrimaryAttributes(uint32_t primaryWidth, uint32_t primaryHeight);

private:
    int getModeCount() const;
    void setSPDInfo(const char* node, const char* property);
    void readCEUnderscanInfo();
    bool readResolution();
    int  parseResolution(char* edidMode);
    bool openFrameBuffer();
    bool closeFrameBuffer();
    bool writeHPDOption(int userOption) const;
    bool isValidMode(int mode);
    int  getModeOrder(int mode);
    int  getUserMode();
    int  getBestMode();
    bool isInterlacedMode(int mode);
    void resetInfo();
    void setAttributes();
    void getAttrForMode(uint32_t& width, uint32_t& height, uint32_t& fps);
    int openDeviceNode(const char* node, int fileMode) const;

    int mFd;
    int mFbNum;
    int mCurrentMode;
    int mEDIDModes[64];
    int mModeCount;
    fb_var_screeninfo mVInfo;
    // Holds all the HDMI modes and timing info supported by driver
    msm_hdmi_mode_timing_info* supported_video_mode_lut;
    uint32_t mXres, mYres, mVsyncPeriod, mPrimaryWidth, mPrimaryHeight;
    bool mMDPScalingMode;
    bool mUnderscanSupported;
    // Downscale feature switch, set via system property
    // sys.hwc.mdp_downscale_enabled
    bool mMDPDownscaleEnabled;
    int mDisplayId;
};

}; //qhwc
// ---------------------------------------------------------------------------
#endif //HWC_HDMI_DISPLAY_H