summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev/msm/mdss_livedisplay.h
blob: 58b4f9f6a86602e96f1c5626a51075b120bdccf8 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Copyright (c) 2015 The CyanogenMod Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef MDSS_LIVEDISPLAY_H
#define MDSS_LIVEDISPLAY_H

#include <linux/of.h>
#include <linux/sysfs.h>

#include "mdss_dsi.h"
#include "mdss_fb.h"

#define MAX_PRESETS 10

struct mdss_livedisplay_ctx {
	uint8_t cabc_ui_value;
	uint8_t cabc_image_value;
	uint8_t cabc_video_value;
	uint8_t sre_weak_value;
	uint8_t sre_medium_value;
	uint8_t sre_strong_value;
	uint8_t aco_value;

	const uint8_t *ce_off_cmds;
	const uint8_t *ce_on_cmds;
	unsigned int ce_off_cmds_len;
	unsigned int ce_on_cmds_len;

	const uint8_t *hbm_off_cmds;
	const uint8_t *hbm_on_cmds;
	unsigned int hbm_off_cmds_len;
	unsigned int hbm_on_cmds_len;

	const uint8_t *presets[MAX_PRESETS];
	unsigned int presets_len[MAX_PRESETS];

	const uint8_t *cabc_cmds;
	const uint8_t *cabc_ui_cmds;
	const uint8_t *cabc_image_cmds;
	const uint8_t *cabc_video_cmds;
	unsigned int cabc_cmds_len;
	unsigned int cabc_ui_cmds_len;
	unsigned int cabc_image_cmds_len;
	unsigned int cabc_video_cmds_len;
	bool unified_cabc_cmds;

	const uint8_t *post_cmds;
	unsigned int post_cmds_len;

	unsigned int preset;
	unsigned int cabc_level;
	unsigned int sre_level;
	bool aco_enabled;
	bool ce_enabled;
	bool hbm_enabled;

	unsigned int link_state;

	unsigned int num_presets;
	unsigned int caps;

	struct msm_fb_data_type *mfd;

	struct mutex lock;
};

enum {
	CABC_OFF,
	CABC_UI,
	CABC_IMAGE,
	CABC_VIDEO,
	CABC_MAX
};

enum {
	SRE_OFF,
	SRE_WEAK,
	SRE_MEDIUM,
	SRE_STRONG,
	SRE_MAX
};

enum {
	MODE_CABC		= 0x01,
	MODE_SRE		= 0x02,
	MODE_AUTO_CONTRAST	= 0x04,
	MODE_COLOR_ENHANCE	= 0x08,
	MODE_PRESET		= 0x10,
	MODE_HIGH_BRIGHTNESS	= 0x20,
	MODE_UPDATE_ALL		= 0xFF,
};

int mdss_livedisplay_update(struct mdss_dsi_ctrl_pdata *ctrl_pdata, int types);
int mdss_livedisplay_parse_dt(struct device_node *np, struct mdss_panel_info *pinfo);
int mdss_livedisplay_create_sysfs(struct msm_fb_data_type *mfd);
int mdss_livedisplay_event(struct msm_fb_data_type *mfd, int types);

static inline bool is_cabc_cmd(unsigned int value)
{
    return (value & MODE_CABC) || (value & MODE_SRE) || (value & MODE_AUTO_CONTRAST);
}

static inline struct mdss_livedisplay_ctx* get_ctx(struct msm_fb_data_type *mfd)
{
    return mfd->panel_info->livedisplay;
}

static inline struct mdss_dsi_ctrl_pdata* get_ctrl(struct msm_fb_data_type *mfd)
{
    struct mdss_panel_data *pdata = dev_get_platdata(&mfd->pdev->dev);
    return container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data);
}

#endif